Skip to content

Instantly share code, notes, and snippets.

@sinairv
Last active September 6, 2019 18:15
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save sinairv/1e29f38dec308a78159fecaa80ac1aa5 to your computer and use it in GitHub Desktop.
LinqPad Input-Output-Go WPF GUI Template
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