public GlobalConfigurationForm(StartupAction startupAction, Controller controller) { InitializeComponent(); Controller = controller; ComPortComboBox.Items.AddRange(System.IO.Ports.SerialPort.GetPortNames()); ComPortComboBox.SelectedIndex = string.IsNullOrEmpty(controller.ComPort) ? 0 : ComPortComboBox.FindString(controller.ComPort); ComPortComboBox.Enabled = !controller.IsConnected; RefreshIntervalNumericUpDown.Value = controller.RefreshInterval; RefreshIntervalNumericUpDown.Enabled = !controller.IsConnected; LoadTypeComboBox.Items.AddRange(Enum.GetNames(typeof(LoadType)).Where(item => item != "Unknown").ToArray()); LoadTypeComboBox.SelectedIndex = LoadTypeComboBox.FindString(controller.GlobalConfiguration.LoadType.ToString()); LoadTypeComboBox.Enabled = controller.IsConnected; AspirationTypeComboBox.Items.AddRange(Enum.GetNames(typeof(AspirationType)).Where(item => item != "Unknown").ToArray()); AspirationTypeComboBox.SelectedIndex = AspirationTypeComboBox.FindString(controller.GlobalConfiguration.AspirationType.ToString()); AspirationTypeComboBox.Enabled = controller.IsConnected; StartupActionComboBox.Items.AddRange(Enum.GetNames(typeof(StartupAction))); StartupActionComboBox.SelectedIndex = StartupActionComboBox.FindString(startupAction.ToString()); StartupActionComboBox.Enabled = controller.IsConnected; EdisTypeComboBox.Items.AddRange(Enum.GetNames(typeof(EdisType)).Where(item => item != "Unknown").ToArray()); EdisTypeComboBox.SelectedIndex = EdisTypeComboBox.FindString(controller.GlobalConfiguration.EdisType.ToString()); EdisTypeComboBox.Enabled = controller.IsConnected; PipNoiseFilterNumericUpDown.Value = controller.GlobalConfiguration.PipNoiseFilter; PipNoiseFilterNumericUpDown.Enabled = controller.IsConnected; CrankingAdvanceNumericUpDown.Value = controller.GlobalConfiguration.CrankingAdvance; CrankingAdvanceNumericUpDown.Enabled = controller.IsConnected; TriggerWheelOffsetNumericUpDown.Value = controller.GlobalConfiguration.TriggerWheelOffset; TriggerWheelOffsetNumericUpDown.Enabled = controller.IsConnected; if (ComPortComboBox.Enabled) { ComPortComboBox.Focus(); } else { LoadTypeComboBox.Focus(); } }
public MainForm() { InitializeComponent(); base.CreateHandle(); Settings setttings = Settings.Default; //Window Settings StartPosition = FormStartPosition.Manual; if (setttings.Height > base.MinimumSize.Height) { Height = setttings.Height; } if (setttings.Width > base.MinimumSize.Width) { Width = setttings.Width; } Left = setttings.Left > int.MinValue ? setttings.Left : (Screen.PrimaryScreen.WorkingArea.Width - Width) / 2; Top = setttings.Top > int.MinValue ? setttings.Top : (Screen.PrimaryScreen.WorkingArea.Height - Height) / 2; if (setttings.WindowState != FormWindowState.Minimized) { WindowState = setttings.WindowState; } //Ignition Configuration Settings RpmBins = setttings.RpmBins ?? new byte[10]; LoadBins = setttings.LoadBins ?? new byte[10]; IgnitionMap = setttings.IgnitionMap ?? new byte[100]; UserOutputTypes = setttings.UserOutputTypes; UserOutputModeConfigurations = setttings.UserOutputModeConfigurations; UserOutput1Threshold = setttings.UserOutput1Threshold; UserOutput2Threshold = setttings.UserOutput2Threshold; UserOutput3Threshold = setttings.UserOutput3Threshold; UserOutput4Threshold = setttings.UserOutput4Threshold; RevLimitThreshold = setttings.RevLimitThreshold; ShiftLightThreshold = setttings.ShiftLightThreshold; AdvanceCorrectionBins = setttings.AdvanceCorrectionBins ?? new byte[10]; AdvanceCorrectionValues = setttings.AdvanceCorrectionValues ?? new byte[10]; AuxiliaryInputPeakHoldDecay = setttings.AuxiliaryInputPeakHoldDecay; //Application Settings LogMessagesCheckBox.Checked = setttings.LogMessages; LogPropertyChangesCheckBox.Checked = setttings.LogPropertyChanges; LogEventsCheckBox.Checked = setttings.LogEvents; //Global Settings VersionComboBox.SelectedIndex = VersionComboBox.FindString(setttings.Version); EdisTypeComboBox.SelectedIndex = EdisTypeComboBox.FindString(setttings.EdisType); LoadTypeComboBox.SelectedIndex = LoadTypeComboBox.FindString(setttings.LoadType); CrankingAdvanceNumericUpDown.Value = setttings.CrankingAdvance; TriggerWheelOffsetNumericUpDown.Value = setttings.TriggerWheelOffset; PipNoiseFilterNumericUpDown.Value = setttings.PipNoiseFilter; AspirationTypeComboBox.SelectedIndex = AspirationTypeComboBox.FindString(setttings.AspirationType); //Current State Settings IgnitionConfigurationComboBox.SelectedIndex = IgnitionConfigurationComboBox.FindString(setttings.IgnitionConfiguration); AuxiliaryInputNumericUpDown.Value = setttings.AuxiliaryInput; LoadNumericUpDown.Value = setttings.Load; RpmNumericUpDown.Value = setttings.Rpm; DynamicStateCheckBox.Checked = setttings.DynamicState; UserOutput1CheckBox.Checked = setttings.UserOutput1; UserOutput2CheckBox.Checked = setttings.UserOutput2; UserOutput3CheckBox.Checked = setttings.UserOutput3; UserOutput4CheckBox.Checked = setttings.UserOutput4; }