InputDialog.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System;
  2. using System.Windows.Forms;
  3. public class InputDialog : Form
  4. {
  5. private Label _label1;
  6. private Label _label2;
  7. private NumericUpDown _numericUpDown1;
  8. private NumericUpDown _numericUpDown2;
  9. private Button _buttonOk;
  10. private Button _buttonCancel;
  11. public InputDialog()
  12. {
  13. InitializeComponent();
  14. }
  15. private void InitializeComponent()
  16. {
  17. _label1 = new Label();
  18. _label2 = new Label();
  19. _numericUpDown1 = new NumericUpDown();
  20. _numericUpDown2 = new NumericUpDown();
  21. _buttonOk = new Button();
  22. _buttonCancel = new Button();
  23. // Label 1
  24. _label1.Text = "Offset X:";
  25. _label1.AutoSize = true;
  26. _label1.Location = new System.Drawing.Point(12, 20);
  27. // Numeric Up-Down 1
  28. _numericUpDown1.Location = new System.Drawing.Point(70, 18);
  29. _numericUpDown1.Width = 120;
  30. _numericUpDown1.Maximum = 1000;
  31. _numericUpDown1.Minimum = -1000;
  32. // Label 2
  33. _label2.Text = "Offset Y:";
  34. _label2.AutoSize = true;
  35. _label2.Location = new System.Drawing.Point(12, 50);
  36. // Numeric Up-Down 2
  37. _numericUpDown2.Location = new System.Drawing.Point(70, 48);
  38. _numericUpDown2.Width = 120;
  39. _numericUpDown1.Maximum = 1000;
  40. _numericUpDown2.Minimum = -1000;
  41. // Button Ok
  42. _buttonOk.Text = "Ok";
  43. _buttonOk.DialogResult = DialogResult.OK;
  44. _buttonOk.Location = new System.Drawing.Point(24, 90);
  45. // Button Cancel
  46. _buttonCancel.Text = "Cancel";
  47. _buttonCancel.DialogResult = DialogResult.Cancel;
  48. _buttonCancel.Location = new System.Drawing.Point(100, 90);
  49. // Form
  50. this.Text = "Input Dialog";
  51. this.ClientSize = new System.Drawing.Size(200, 130);
  52. this.Controls.Add(_label1);
  53. this.Controls.Add(_label2);
  54. this.Controls.Add(_numericUpDown1);
  55. this.Controls.Add(_numericUpDown2);
  56. this.Controls.Add(_buttonOk);
  57. this.Controls.Add(_buttonCancel);
  58. this.FormBorderStyle = FormBorderStyle.FixedDialog;
  59. this.StartPosition = FormStartPosition.CenterParent;
  60. this.MaximizeBox = false;
  61. this.MinimizeBox = false;
  62. this.AcceptButton = _buttonOk;
  63. this.CancelButton = _buttonCancel;
  64. this.ShowInTaskbar = false;
  65. }
  66. public decimal Value1
  67. {
  68. get { return _numericUpDown1.Value; }
  69. }
  70. public decimal Value2
  71. {
  72. get { return _numericUpDown2.Value; }
  73. }
  74. }