Forked from sinairv/Input-Output-Go-WPF-GUI-Template.linq
Created
September 6, 2019 18:15
-
-
Save nathanpjones/54a2369bf4bbe9aab0cff4502f62aab4 to your computer and use it in GitHub Desktop.
LinqPad Input-Output-Go WPF GUI Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum TextBoxMode | |
{ | |
SingleLine, | |
MultiLine | |
} | |
TextBox CreateTextBox(string label, TextBoxMode textBoxMode) | |
{ | |
var lbl = new Label(); | |
lbl.Content = $"{label}:"; | |
lbl.Dump(); | |
var textBox = new TextBox(); | |
if (textBoxMode == TextBoxMode.MultiLine) | |
{ | |
textBox.AcceptsReturn = true; | |
textBox.AcceptsTab = true; | |
textBox.Height = 150; | |
textBox.VerticalScrollBarVisibility = ScrollBarVisibility.Visible; | |
textBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible; | |
} | |
textBox.FontFamily = new System.Windows.Media.FontFamily("Courier New"); | |
textBox.Dump(); | |
return textBox; | |
} | |
Button CreateButton(string caption) | |
{ | |
var button = new Button(); | |
button.Content = caption; | |
button.Width = 100; | |
button.Margin = new System.Windows.Thickness(5); | |
button.Dump(); | |
return button; | |
} | |
void Main() | |
{ | |
var textName = CreateTextBox("Name", TextBoxMode.SingleLine); | |
var textInput = CreateTextBox("Input", TextBoxMode.MultiLine); | |
var btnGo = CreateButton("Go"); | |
var textOutput = CreateTextBox("Output", TextBoxMode.MultiLine); | |
btnGo.Click += (s, e) => textOutput.Text = Process(textInput.Text); | |
} | |
string Process(string input) | |
{ | |
return input; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment