using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace FCC_Uber_MDX_Configurator { public partial class GlobalGraphicPropertiesForm : Form { #region Initialize public GlobalGraphicPropertiesForm() { InitializeComponent(); SetupCurrentValues(); } #endregion #region Setup Current Values private void SetupCurrentValues() { TXT_DESIGNEDSIZE_WIDTH.Text = GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth.ToString(); TXT_DESIGNEDSIZE_HEIGHT.Text = GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight.ToString(); TXT_SHOWSIZE_WIDTH.Text = GlobalStaticClass._GlobalGraphicsPropertiesClass._ShowAtWidth.ToString(); TXT_SHOWSIZE_HEIGHT.Text = GlobalStaticClass._GlobalGraphicsPropertiesClass._ShowAtHeight.ToString(); COMBO_ApplicationBorder.Text = GlobalStaticClass._GlobalGraphicsPropertiesClass._ApplicationFormStyleToString(); COMBO_MINIMIZETRAY.Text = GlobalStaticClass._GlobalGraphicsPropertiesClass._MinimizeToTrayToString(); COMBO_STARTTRAY.Text = GlobalStaticClass._GlobalGraphicsPropertiesClass._StartInTrayToString(); } #endregion #region Save Button Clicked private void BTN_SAVE_Click(object sender, EventArgs e) { if (!int.TryParse(TXT_DESIGNEDSIZE_WIDTH.Text, out GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForWidth) || !int.TryParse(TXT_DESIGNEDSIZE_HEIGHT.Text, out GlobalStaticClass._GlobalGraphicsPropertiesClass._MadeForHeight) || !int.TryParse(TXT_SHOWSIZE_WIDTH.Text, out GlobalStaticClass._GlobalGraphicsPropertiesClass._ShowAtWidth) || !int.TryParse(TXT_SHOWSIZE_HEIGHT.Text, out GlobalStaticClass._GlobalGraphicsPropertiesClass._ShowAtHeight)) { ErrorForm _tempErrorForm = new ErrorForm("Save Error", "One of the size areas has a non-parseable error."); _tempErrorForm.ShowDialog(); return; } switch (COMBO_ApplicationBorder.Text.ToLower()) { case "hidden": GlobalStaticClass._GlobalGraphicsPropertiesClass._ApplicationFormStyle = FormBorderStyle.None; break; case "sizeable": GlobalStaticClass._GlobalGraphicsPropertiesClass._ApplicationFormStyle = FormBorderStyle.Sizable; break; case "fixed": GlobalStaticClass._GlobalGraphicsPropertiesClass._ApplicationFormStyle = FormBorderStyle.FixedSingle; break; default: ErrorForm _tempErrorForm = new ErrorForm("Save Error", "Please make sure you have selected an item from the Application Form Box"); _tempErrorForm.ShowDialog(); return; } switch (COMBO_MINIMIZETRAY.Text.ToLower()) { case "true": GlobalStaticClass._GlobalGraphicsPropertiesClass._MinimizeToSystemTray = true; break; case "false": GlobalStaticClass._GlobalGraphicsPropertiesClass._MinimizeToSystemTray = false; break; default: (new ErrorForm("Save Error", "Please make sure you have selected an item from the Minimize to Tray Box")).ShowDialog(); return; } switch (COMBO_STARTTRAY.Text.ToLower()) { case "true": GlobalStaticClass._GlobalGraphicsPropertiesClass._StartInSystemTray = true; break; case "false": GlobalStaticClass._GlobalGraphicsPropertiesClass._StartInSystemTray = false; break; default: (new ErrorForm("Save Error", "Please make sure you have selected an item from the Start in Tray Box")).ShowDialog(); return; } this.DialogResult = DialogResult.OK; this.Close(); } #endregion #region Cancel Button Clicked private void BTN_CANCEL_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; this.Close(); } #endregion #region Verify Textboxes Only get Number Inputs private void KeyDown_IsANumber(object sender, KeyEventArgs e) { if (!char.IsDigit((char)e.KeyValue) && e.KeyData != Keys.Back && e.KeyData != Keys.Left && e.KeyData != Keys.Right && e.KeyData != Keys.Decimal && e.KeyValue != 190 && !e.KeyCode.Equals(Keys.NumPad0) && !e.KeyCode.Equals(Keys.NumPad1) && !e.KeyCode.Equals(Keys.NumPad2) && !e.KeyCode.Equals(Keys.NumPad3) && !e.KeyCode.Equals(Keys.NumPad4) && !e.KeyCode.Equals(Keys.NumPad5) && !e.KeyCode.Equals(Keys.NumPad6) && !e.KeyCode.Equals(Keys.NumPad7) && !e.KeyCode.Equals(Keys.NumPad8) && !e.KeyCode.Equals(Keys.NumPad9)) { e.SuppressKeyPress = true; } return; } #endregion #region Verify a Number is entered in TextBox private void Leave_VerifyTXTIsValid(object sender, EventArgs e) { try { TextBox _senderBox = (TextBox)sender; int _tempInt; if (!int.TryParse(_senderBox.Text, out _tempInt)) { ErrorForm _tempErrorForm = new ErrorForm(_senderBox.Name, "The value you entered is not valid"); _tempErrorForm.ShowDialog(); _senderBox.Focus(); } } catch (Exception) { ErrorForm _tempErrorForm = new ErrorForm("Unknown Error", "There was an unexpected untraceable error caught in the application. If you can reproduce this error, please let me know at FusionControlCentre@gmail.com"); _tempErrorForm.ShowDialog(); } } #endregion #region Verify a Proper Item has Been Selected in Combo Box private void Leave_VerifyCOMBOIsValid(object sender, EventArgs e) { try { ComboBox _senderBox = (ComboBox)sender; if (!_senderBox.Items.Contains(_senderBox.Text)) { ErrorForm _tempErrorForm = new ErrorForm(_senderBox.Name, "The value you selected or entered is not valid"); _tempErrorForm.ShowDialog(); _senderBox.Focus(); _senderBox.SelectedIndex = 0; } } catch (Exception) { ErrorForm _tempErrorForm = new ErrorForm("Unknown Error", "There was an unexpected untraceable error caught in the application. If you can reproduce this error, please let me know at FusionControlCentre@gmail.com"); _tempErrorForm.ShowDialog(); } } #endregion } }