PageRenderTime 30ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/WorldView/FormEntryBox.cs

#
C# | 95 lines | 79 code | 15 blank | 1 comment | 2 complexity | f7f5525c7086cf0376f6e823af2ef693 MD5 | raw file
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. namespace MoreTerra
  5. {
  6. public partial class FormEntryBox : Form
  7. {
  8. private String fText;
  9. private String lText;
  10. private String iText;
  11. #region Constructors
  12. public FormEntryBox()
  13. {
  14. this.Icon = Properties.Resources.Cannon;
  15. this.ShowInTaskbar = false;
  16. InitializeComponent();
  17. }
  18. #endregion
  19. #region Event Handlers
  20. private void FormEntryBox_Load(object sender, EventArgs e)
  21. {
  22. Point pt;
  23. Size size;
  24. this.Text = fText;
  25. this.labelMessage.Text = lText;
  26. textBoxItem.Text = iText;
  27. // Set the box to the center of the window.
  28. pt = this.Owner.Location;
  29. size = this.Owner.Size;
  30. pt.X = pt.X + (size.Width / 2) - (this.Size.Width / 2);
  31. pt.Y = pt.Y + (size.Height / 2) - (this.Size.Height / 2);
  32. this.Location = pt;
  33. }
  34. private void FormEntryBox_Shown(object sender, EventArgs e)
  35. {
  36. textBoxItem.Focus();
  37. }
  38. private void buttonOk_Click(object sender, EventArgs e)
  39. {
  40. if (textBoxItem.Text == "")
  41. {
  42. DialogResult = DialogResult.Cancel;
  43. return;
  44. }
  45. DialogResult = DialogResult.OK;
  46. }
  47. private void buttonCancel_Click(object sender, EventArgs e)
  48. {
  49. DialogResult = DialogResult.Cancel;
  50. }
  51. #endregion
  52. #region GetSet Functions
  53. public String EntryItem
  54. {
  55. get
  56. {
  57. return textBoxItem.Text;
  58. }
  59. set
  60. {
  61. iText = value;
  62. }
  63. }
  64. public String LabelText
  65. {
  66. set
  67. {
  68. lText = value;
  69. }
  70. }
  71. public String FormText
  72. {
  73. set
  74. {
  75. fText = value;
  76. }
  77. }
  78. #endregion
  79. }
  80. }