public AxisSetupForm(AxisMapping axisMapping) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); this.axisMapping = axisMapping; this.parameters = axisMapping.Parameters; DialogResult = DialogResult.Cancel; MainForm.Instance.ChannelDataUpdate += onChannelDataUpdate; Disposed += delegate(object sender, EventArgs e) { MainForm.Instance.ChannelDataUpdate -= onChannelDataUpdate; }; numericMin.Value = parameters.Min; numericMax.Value = parameters.Max; numericCenter.Value = parameters.Center; numericExpo.Value = parameters.Expo; numericDeadband.Value = parameters.Deadband; checkInvert.Checked = parameters.Invert; checkSymmetric.Checked = parameters.Symmetric; initialized = true; OnChange(null, null); }
void OnChange(object sender, EventArgs e) { if (!initialized) { return; } badValues = true; if (calibrationStep == 0 && numericMin.Value >= numericMax.Value) { MessageBox.Show("Min cannot be bigger than Max"); return; } if (checkSymmetric.Checked) { numericCenter.Enabled = true; numericDeadband.Enabled = true; if (calibrationStep == 0 && (numericCenter.Value <= numericMin.Value || numericCenter.Value >= numericMax.Value)) { MessageBox.Show("Center must be between Min and Max"); return; } } else { numericCenter.Enabled = false; numericDeadband.Enabled = false; } numericFailsafe.Enabled = !checkFailsafeLast.Checked; Parameters = new AxisMapping.AxisParameters() { Min = (int)numericMin.Value, Max = (int)numericMax.Value, Center = (int)numericCenter.Value, Expo = (int)numericExpo.Value, Invert = checkInvert.Checked, Symmetric = checkSymmetric.Checked, Deadband = (int)numericDeadband.Value, Failsafe = checkFailsafeLast.Checked ? -1 : (int)numericFailsafe.Value }; pictureBox.Invalidate(); badValues = false; }