private void optionsToolStripMenuItem_Click(object sender, EventArgs e) { connector.Stop(); currentSettings = saveSettingsToObject(); lastMode = currentSettings.ControlMode; endActiveMode(); OptionsForm frm = new OptionsForm(); //frm.Owner = this; frm.ShowDialog(this); frm.Dispose(); // If the generationmode was changed, don't use the old settings if (lastMode != Properties.Settings.Default.GenerationMode) { connector.resetChannelSettings(); } if (currentSettings != null) { currentSettings.sampleRate = Properties.Settings.Default.SampleRate; } startActiveMode(); }
private void loadControlComponent() { connector.SampleRate = Properties.Settings.Default.SampleRate; controlMode = Properties.Settings.Default.GenerationMode; switch (controlMode) { case PwmControlMode.GenericAsync: mainControl = new GenericPwmControl(PwmGeneratorModes.Asynchronous); this.Text = ApplicationTitle + " [ASynchronous mode]"; break; case PwmControlMode.GenericSync: mainControl = new GenericPwmControl(PwmGeneratorModes.Synchronous); this.Text = ApplicationTitle + " [Synchronous mode]"; break; case PwmControlMode.RCControl: mainControl = new RcPwmControl(); this.Text = ApplicationTitle + " [R/C control mode]"; break; default: MessageBox.Show("This mode is not supported yet"); endActiveMode(); return; } mainControl.ShowRealValueToolTips = Properties.Settings.Default.ShowRealValueToolTips; mainControl.ColoredBorders = Properties.Settings.Default.ColoredChannelBorders; mainControl.initialize(connector); mainControlPanel.Controls.Add((Control)mainControl); this.Size = new System.Drawing.Size(((Control)mainControl).Size.Width + 10, ((Control)mainControl).Size.Height + 100); startPwmButton.Enabled = connector.Connected; // If there are settings to be loaded if (currentSettings != null) { if (Properties.Settings.Default.GenerationMode == currentSettings.ControlMode) { mainControl.loadSettings(currentSettings.ControllerSettings); } else { currentSettings = null; } } }
private void loadControlComponent() { connector.SampleRate = Properties.Settings.Default.SampleRate; controlMode = Properties.Settings.Default.GenerationMode; switch (controlMode) { case PwmControlMode.GenericAsync: mainControl = new GenericPwmControl( PwmGeneratorModes.Asynchronous); this.Text = ApplicationTitle + " [ASynchronous mode]"; break; case PwmControlMode.GenericSync: mainControl = new GenericPwmControl( PwmGeneratorModes.Synchronous); this.Text = ApplicationTitle + " [Synchronous mode]"; break; case PwmControlMode.RCControl: mainControl = new RcPwmControl(); this.Text = ApplicationTitle + " [R/C control mode]"; break; default: MessageBox.Show("This mode is not supported yet"); endActiveMode(); return; } mainControl.ShowRealValueToolTips = Properties.Settings.Default.ShowRealValueToolTips; mainControl.ColoredBorders = Properties.Settings.Default.ColoredChannelBorders; mainControl.initialize(connector); mainControlPanel.Controls.Add((Control)mainControl); this.Size = new System.Drawing.Size(((Control)mainControl).Size.Width + 10, ((Control)mainControl).Size.Height + 100); startPwmButton.Enabled = connector.Connected; // If there are settings to be loaded if (currentSettings != null) { if (Properties.Settings.Default.GenerationMode == currentSettings.ControlMode) { mainControl.loadSettings(currentSettings.ControllerSettings); } else { currentSettings = null; } } }