//============================================================================* // Copy() //============================================================================* public void Copy(cBatchTest BatchTest) { m_Batch = BatchTest.m_Batch; m_TestDate = BatchTest.m_TestDate; m_strLocation = BatchTest.m_strLocation; m_Firearm = BatchTest.m_Firearm; m_nNumRounds = BatchTest.m_nNumRounds; m_dBestGroup = BatchTest.m_dBestGroup; m_dBestGroupRange = BatchTest.m_dBestGroupRange; m_strNotes = BatchTest.m_strNotes; m_TestShotList = new cTestShotList(BatchTest.TestShotList); m_nAltitude = BatchTest.m_nAltitude; m_nTemperature = BatchTest.m_nTemperature; m_dPressure = BatchTest.m_dPressure; m_dHumidity = BatchTest.m_dHumidity; m_nWindDirection = BatchTest.m_nWindDirection; m_nWindSpeed = BatchTest.m_nWindSpeed; m_fSuppressed = BatchTest.m_fSuppressed; }
//============================================================================* // cTestShotList() - Copy Constructor //============================================================================* public cTestShotList(cTestShotList TestShotList) { foreach (cTestShot TestShot in TestShotList) { Add(new cTestShot(TestShot)); } }
//============================================================================* // Copy() //============================================================================* public void Copy(cAmmoTest AmmoTest) { m_Ammo = AmmoTest.m_Ammo; m_Firearm = AmmoTest.m_Firearm; m_TestDate = AmmoTest.m_TestDate; m_dBarrelLength = AmmoTest.m_dBarrelLength; m_dTwist = AmmoTest.m_dTwist; m_nNumRounds = AmmoTest.m_nNumRounds; m_nMuzzleVelocity = AmmoTest.m_nMuzzleVelocity; m_dBestGroup = AmmoTest.m_dBestGroup; m_dBestGroupRange = AmmoTest.m_dBestGroupRange; m_strNotes = AmmoTest.m_strNotes; m_TestShotList = new cTestShotList(AmmoTest.TestShotList); }
//============================================================================* // cTestStatistics() - From cTestShotList //============================================================================* public cTestStatistics(cTestShotList TestShotList) { Reset(); if (TestShotList == null) { return; } int nTotalVelocity = 0; foreach (cTestShot TestShot in TestShotList) { if (TestShot.MuzzleVelocity > 0 && !TestShot.Misfire && !TestShot.Squib) { m_nNumShots++; nTotalVelocity += TestShot.MuzzleVelocity; if (m_nMinVelocity == 0 || TestShot.MuzzleVelocity < m_nMinVelocity) { m_nMinVelocity = TestShot.MuzzleVelocity; } if (m_nMaxVelocity == 0 || TestShot.MuzzleVelocity > m_nMaxVelocity) { m_nMaxVelocity = TestShot.MuzzleVelocity; } } } if (m_nNumShots > 0 && nTotalVelocity > 0) { m_dAverageVelocity = (double)nTotalVelocity / (double)m_nNumShots; foreach (cTestShot TestShot in TestShotList) { if (TestShot.MuzzleVelocity > 0 && !TestShot.Misfire && !TestShot.Squib) { m_dVariance += (((double)TestShot.MuzzleVelocity - m_dAverageVelocity) * ((double)TestShot.MuzzleVelocity - m_dAverageVelocity)); } } m_dVariance /= (double)(m_nNumShots - 1); m_dStdDev = Math.Sqrt(m_dVariance); } }
//============================================================================* // 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; }