//============================================================================* // PopulateShotData() //============================================================================* public void PopulateShotData() { ShotNumLabel.Text = string.Format("Shot {0:N0} of {1:N0}", m_nShotNum + 1, m_nNumShots); MisfireRadioButton.Checked = m_TestShotList[m_nShotNum].Misfire; SquibRadioButton.Checked = m_TestShotList[m_nShotNum].Squib; if (m_TestShotList[m_nShotNum].Misfire || m_TestShotList[m_nShotNum].Squib) { MuzzleVelocityTextBox.Enabled = false; PressureTextBox.Enabled = false; m_TestShotList[m_nShotNum].MuzzleVelocity = 0; m_TestShotList[m_nShotNum].Pressure = 0; } else { MuzzleVelocityTextBox.Enabled = true; PressureTextBox.Enabled = true; } MuzzleVelocityTextBox.Value = (int)Math.Round(cDataFiles.StandardToMetric(m_TestShotList[m_nShotNum].MuzzleVelocity, cDataFiles.eDataType.Velocity), 0); PressureTextBox.Value = m_TestShotList[m_nShotNum].Pressure; MuzzleVelocityTextBox.Focus(); }
//============================================================================* // OnSquibClicked() //============================================================================* private void OnSquibClicked(object sender, EventArgs args) { if (!m_fInitialized) { return; } SquibRadioButton.Checked = SquibRadioButton.Checked ? false : true; if (SquibRadioButton.Checked) { MisfireRadioButton.Checked = false; m_TestShotList[m_nShotNum].MuzzleVelocity = 0; m_TestShotList[m_nShotNum].Pressure = 0; } else { MuzzleVelocityTextBox.Focus(); } m_TestShotList[m_nShotNum].Misfire = MisfireRadioButton.Checked; m_TestShotList[m_nShotNum].Squib = SquibRadioButton.Checked; PopulateShotData(); PopulateStatistics(); UpdateButtons(); }
//============================================================================* // SetInitialFocus() //============================================================================* private void SetInitialFocus() { if (SourceComboBox.BackColor == Color.LightPink) { SourceComboBox.Focus(); } else { if (BarrelLengthTextBox.BackColor == Color.LightPink) { BarrelLengthTextBox.Focus(); } else { if (TwistTextBox.BackColor == Color.LightPink) { TwistTextBox.Focus(); } else { if (MuzzleVelocityTextBox.BackColor == Color.LightPink) { MuzzleVelocityTextBox.Focus(); } else { if (PressureTextBox.BackColor == Color.LightPink) { PressureTextBox.Focus(); } else { if (BestGroupTextBox.BackColor == Color.LightPink) { BestGroupTextBox.Focus(); } else { if (BestGroupRangeTextBox.BackColor == Color.LightPink) { BestGroupRangeTextBox.Focus(); } else { TestDatePicker.Focus(); } } } } } } } }
//============================================================================* // OnPreviousShotClicked() //============================================================================* private void OnPreviousShotClicked(object sender, EventArgs args) { m_nShotNum--; if (m_nShotNum < 0) { m_nShotNum = m_nNumShots - 1; } PopulateShotData(); UpdateButtons(); MuzzleVelocityTextBox.Focus(); }
//============================================================================* // OnNextShotClicked() //============================================================================* private void OnNextShotClicked(object sender, EventArgs args) { m_nShotNum++; if (m_nShotNum >= m_nNumShots) { m_nShotNum = 0; } PopulateShotData(); UpdateButtons(); MuzzleVelocityTextBox.Focus(); }
//============================================================================* // cTestShotForm() - Constructor //============================================================================* public cTestShotForm(cDataFiles DataFiles, int nNumshots, cTestShotList TestShotList, int nNumRounds, bool fViewOnly = false) { InitializeComponent(); m_TestShotList = TestShotList; m_nNumShots = nNumshots; m_nNumRounds = nNumRounds; m_DataFiles = DataFiles; m_fViewOnly = fViewOnly; string strTitle = ""; if (TestShotList == null) { m_TestShotList = new cTestShotList(); TestShotOKButton.Text = "Add"; } else { m_TestShotList = new cTestShotList(TestShotList); TestShotOKButton.Text = "Update"; } SetClientSizeCore(ShotDataGroupBox.Location.X + ShotDataGroupBox.Width + 10, TestShotCancelButton.Location.Y + TestShotCancelButton.Height + 20); //----------------------------------------------------------------------------* // Event handlers //----------------------------------------------------------------------------* PreviousShotButton.Click += OnPreviousShotClicked; NextShotButton.Click += OnNextShotClicked; if (!m_fViewOnly) { MuzzleVelocityTextBox.TextChanged += OnMuzzleVelocityChanged; PressureTextBox.TextChanged += OnPressureChanged; MisfireRadioButton.Click += OnMisfireClicked; SquibRadioButton.Click += OnSquibClicked; } else { MuzzleVelocityTextBox.ReadOnly = true; PressureTextBox.ReadOnly = true; } //----------------------------------------------------------------------------* // Set up the buttons and title //----------------------------------------------------------------------------* if (m_fViewOnly) { TestShotOKButton.Visible = false; TestShotCancelButton.Text = "Close"; int nButtonX = (this.Size.Width / 2) - (TestShotCancelButton.Width / 2); TestShotCancelButton.Location = new Point(nButtonX, TestShotCancelButton.Location.Y); strTitle = "View"; } else { strTitle = "Edit"; } strTitle += " Test Shots"; //----------------------------------------------------------------------------* // Populate data fields //----------------------------------------------------------------------------* cDataFiles.SetMetricLabel(VelocityMeasurementLabel, cDataFiles.eDataType.Velocity); PopulateShotData(); SetStaticToolTips(); PopulateStatistics(); UpdateButtons(); MuzzleVelocityTextBox.Focus(); m_fInitialized = true; }
//============================================================================* // Initialize() //============================================================================* public void Initialize() { MuzzleVelocityTextBox.Focus(); MuzzleVelocityTextBox.Select(0, 5); }