Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. enum TextBoxMode
  2. {
  3. SingleLine,
  4. MultiLine
  5. }
  6.  
  7. TextBox CreateTextBox(string label, TextBoxMode textBoxMode)
  8. {
  9. var lbl = new Label();
  10. lbl.Content = $"{label}:";
  11. lbl.Dump();
  12.  
  13. var textBox = new TextBox();
  14. if (textBoxMode == TextBoxMode.MultiLine)
  15. {
  16. textBox.AcceptsReturn = true;
  17. textBox.AcceptsTab = true;
  18. textBox.Height = 150;
  19. textBox.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
  20. textBox.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
  21. }
  22. textBox.FontFamily = new System.Windows.Media.FontFamily("Courier New");
  23. textBox.Dump();
  24.  
  25. return textBox;
  26. }
  27.  
  28. Button CreateButton(string caption)
  29. {
  30. var button = new Button();
  31. button.Content = caption;
  32. button.Width = 100;
  33. button.Margin = new System.Windows.Thickness(5);
  34. button.Dump();
  35.  
  36. return button;
  37. }
  38.  
  39. void Main()
  40. {
  41. var textName = CreateTextBox("Name", TextBoxMode.SingleLine);
  42. var textInput = CreateTextBox("Input", TextBoxMode.MultiLine);
  43. var btnGo = CreateButton("Go");
  44. var textOutput = CreateTextBox("Output", TextBoxMode.MultiLine);
  45.  
  46. btnGo.Click += (s, e) => textOutput.Text = Process(textInput.Text);
  47. }
  48.  
  49. string Process(string input)
  50. {
  51. return input;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement