// Base Constructor for the program public NewBalance() { #if DEBUG //ApplicationSettingsBase app = new Settings(); //app.Reset(); #endif InitializeComponent(); if (Settings.Default.DefaultPath.Length < 4) { FirstRunPopup first = new FirstRunPopup(); first.ShowDialog(); if (first.DialogResult == DialogResult.OK) { FolderBrowserDialog f = new FolderBrowserDialog(); if (f.ShowDialog() == DialogResult.OK) { Settings.Default.DefaultPath = f.SelectedPath; } Settings.Default.Save(); } } App = new AppLoader(Settings.Default.DefaultPath); Balance = DefaultBalance(); if (Balance == null || !Balance.IsBalanceConnected()) { Balance = null; readBalanceButton.Enabled = false; readBalanceButton.Text = @"Disconnected"; } else { // update command being sent to the balance on click Balance.UpdateCommand(); readBalanceButton.Enabled = true; readBalanceButton.Text = @"Read Balance"; } addRowButton.Enabled = false; }
private void colorMeterToolStripMenuItem_Click(object sender, EventArgs e) { if(Balance != null) { Balance.Dispose(); Balance = null; } using (var meter = new ColorMeter(Settings.Default.ColorCOMPort)) { ColorForm c = new ColorForm(meter); c.Show(); } }
//Preferences On Close Event Handler private void serialAndAppSettings_CloseEvent(object sender, SerialAndAppSettingsCloseEventArgs e) { SerialAndAppSettings s = sender as SerialAndAppSettings; if (s.DialogResult != DialogResult.Abort) { App.UpdatePath(e.Text); // update balance settings if (Balance != null) Balance.Dispose(); Balance = DefaultBalance(); LoadAndUpdateAppFiles(); } if (Balance != null && Balance.IsBalanceConnected()) { readBalanceButton.Enabled = true; readBalanceButton.Text = @"Read Balance"; } else { readBalanceButton.Enabled = false; readBalanceButton.Text = @"Disconnected"; } }