//============================================================================* // PopulateStatistics() //============================================================================* private void PopulateStatistics() { cTestStatistics Statistics = new cTestStatistics(m_AmmoTest.TestShotList); m_AmmoTest.MuzzleVelocity = (int)Statistics.AverageVelocity; MuzzleVelocityTextBox.Value = (int)cDataFiles.StandardToMetric(m_AmmoTest.MuzzleVelocity, cDataFiles.eDataType.Velocity); }
//============================================================================* // cTestStatistics() - Copy Constructor //============================================================================* public cTestStatistics(cTestStatistics TestStatistics) { m_nNumShots = TestStatistics.m_nNumShots; m_dAverageVelocity = TestStatistics.m_dAverageVelocity; m_nMinVelocity = TestStatistics.m_nMinVelocity; m_nMaxVelocity = TestStatistics.m_nMaxVelocity; m_dVariance = TestStatistics.m_dVariance; m_dStdDev = TestStatistics.m_dStdDev; }
//============================================================================* // PopulateStatistics() //============================================================================* private void PopulateStatistics() { cTestStatistics Statistics = new cTestStatistics(m_TestShotList); AvgLabel.Text = String.Format("{0:F1} {1}", cDataFiles.StandardToMetric(Statistics.AverageVelocity, cDataFiles.eDataType.Velocity), cDataFiles.MetricString(cDataFiles.eDataType.Velocity)); MinLabel.Text = String.Format("{0:G0} {1}", cDataFiles.StandardToMetric(Statistics.MinVelocity, cDataFiles.eDataType.Velocity), cDataFiles.MetricString(cDataFiles.eDataType.Velocity)); MaxLabel.Text = String.Format("{0:G0} {1}", cDataFiles.StandardToMetric(Statistics.MaxVelocity, cDataFiles.eDataType.Velocity), cDataFiles.MetricString(cDataFiles.eDataType.Velocity)); DeviationLabel.Text = String.Format("{0:G0} {1}", cDataFiles.StandardToMetric(Statistics.MaxVelocity - Statistics.MinVelocity, cDataFiles.eDataType.Velocity), cDataFiles.MetricString(cDataFiles.eDataType.Velocity)); StdDevLabel.Text = String.Format("{0:F2} {1}", cDataFiles.StandardToMetric(Statistics.StdDev, cDataFiles.eDataType.Velocity), cDataFiles.MetricString(cDataFiles.eDataType.Velocity)); }
//============================================================================* // CompareTo() //============================================================================* public int CompareTo(cTestStatistics TestStatistics) { if (TestStatistics == null) { return(1); } // TODO: finish this up return(0); }
//============================================================================* // Comparer() //============================================================================* public static int Comparer(cTestStatistics Test1, cTestStatistics Test2) { if (Test1 == null) { if (Test2 != null) { return(-1); } else { return(0); } } return(Test1.CompareTo(Test2)); }
//============================================================================* // DrawLabel() //============================================================================* private void DrawLabel(Rectangle LabelRect, Graphics Graphics) { cCaliber.CurrentFirearmType = m_Ammo.FirearmType; m_strBulletWeightFormat = m_DataFiles.Preferences.FormatString(cDataFiles.eDataType.BulletWeight); m_strDimensionFormat = m_DataFiles.Preferences.FormatString(cDataFiles.eDataType.Dimension); //----------------------------------------------------------------------------* // Print the label header //----------------------------------------------------------------------------* Font LabelHeaderFont = new Font("Trebuchet MS", (float)10.0, FontStyle.Bold); Font LabelFont = new Font("Trebuchet MS", (float)8.0, FontStyle.Regular); Font LabelUnderlineFont = new Font("Trebuchet MS", (float)8.0, FontStyle.Underline); Font LabelBoldFont = new Font("Trebuchet MS", (float)8.0, FontStyle.Bold); // Don't fill in a colored header for Avery 6482 since it's a colored paper if (PaperComboBox.SelectedIndex != 3) { Graphics.FillRectangle(Brushes.LightBlue, LabelRect.X, LabelRect.Y, LabelRect.Width, (int)((double)LabelHeaderFont.Height * 4.5)); } Graphics.DrawLine(Pens.Black, LabelRect.X, LabelRect.Y + (int)((double)LabelHeaderFont.Height * 4.5) + 1, LabelRect.X + LabelRect.Width, LabelRect.Y + (int)((double)LabelHeaderFont.Height * 4.5) + 1); float dX = LabelRect.X; float dY = LabelRect.Y; // Manufacturer and Type Graphics.DrawString(String.Format("{0}", m_Ammo.ToShortString()), LabelHeaderFont, Brushes.Black, dX, dY); dY += (float)LabelHeaderFont.Height; // Model Graphics.DrawString(String.Format("{0}", m_Ammo.Type), LabelHeaderFont, Brushes.Black, dX, dY); dY += ((float)LabelHeaderFont.Height * (float)2.0); // Caliber Graphics.DrawString(String.Format("{0}", m_Ammo.Caliber.ToString()), LabelHeaderFont, Brushes.Black, dX, dY); dY = LabelRect.Y + (float)(LabelHeaderFont.Height * 5.0); //----------------------------------------------------------------------------* // Print Ammo Data //----------------------------------------------------------------------------* // Bullet Weight SizeF LabelSize = Graphics.MeasureString("Ballistic Coefficient: ", LabelFont); dX += (int)LabelSize.Width; float dDataX = dX + 10; LabelSize = Graphics.MeasureString("Bullet Weight: ", LabelFont); dX = dDataX - LabelSize.Width; Graphics.DrawString("Bullet Weight:", LabelFont, Brushes.Black, dX, dY); SizeF BoldSize = Graphics.MeasureString("Bullet Weight: ", LabelBoldFont); dY -= (int)(BoldSize.Height - LabelSize.Height); string strString = String.Format(m_strBulletWeightFormat + " {1}", cDataFiles.StandardToMetric(m_Ammo.BulletWeight, cDataFiles.eDataType.BulletWeight), cDataFiles.MetricString(cDataFiles.eDataType.BulletWeight)); Graphics.DrawString(strString, LabelBoldFont, Brushes.Black, dDataX, dY); BoldSize = Graphics.MeasureString(strString, LabelBoldFont); float dDiameterX = dDataX + BoldSize.Width + 15; // Bullet Diameter strString = "Bullet Diameter: "; Graphics.DrawString(strString, LabelFont, Brushes.Black, dDiameterX, dY); BoldSize = Graphics.MeasureString(strString, LabelBoldFont); dX = dDiameterX + BoldSize.Width; dY -= (int)(BoldSize.Height - LabelSize.Height); strString = String.Format(m_strDimensionFormat + " {1}", cDataFiles.StandardToMetric(m_Ammo.BulletDiameter, cDataFiles.eDataType.Dimension), cDataFiles.MetricString(cDataFiles.eDataType.Dimension)); Graphics.DrawString(strString, LabelBoldFont, Brushes.Black, dX, dY); dX = LabelRect.X; dY += LabelBoldFont.Height; // Ballistic Coefficient LabelSize = Graphics.MeasureString("Ballistic Coefficient: ", LabelFont); dX = dDataX - LabelSize.Width; Graphics.DrawString("Ballistic Coefficient:", LabelFont, Brushes.Black, dX, dY); BoldSize = Graphics.MeasureString("Ballistic Coefficient: ", LabelBoldFont); dY -= (int)(BoldSize.Height - LabelSize.Height); Graphics.DrawString(String.Format("{0:F3}", m_Ammo.BallisticCoefficient), LabelBoldFont, Brushes.Black, dDataX, dY); dY += (float)(LabelBoldFont.Height * 1.5); //----------------------------------------------------------------------------* // Test Shot Blanks //----------------------------------------------------------------------------* if (TestShotBlanksRadioButton.Checked) { dX = LabelRect.X; Graphics.DrawString("Test Shots (Muzzle Vel.)", LabelBoldFont, Brushes.Black, dX, dY); string strBlank = "____________"; strString = "Best Group: " + strBlank; BoldSize = Graphics.MeasureString(strString, LabelBoldFont); dX = LabelRect.X + LabelRect.Width - LabelSize.Width - 10; Graphics.DrawString(strString, LabelBoldFont, Brushes.Black, dX, dY); dX = LabelRect.X; dY += ((float)LabelBoldFont.Height * (float)1.5); float dTestShotTop = dY; int nShotNum = 1; strString = String.Format("{0:G0} {1} ", nShotNum, strBlank); SizeF StringSize = Graphics.MeasureString(strString, LabelFont); while (dX + StringSize.Width < LabelRect.X + LabelRect.Width) { if (dY + StringSize.Height > LabelRect.Y + LabelRect.Height) { dY = dTestShotTop; dX += StringSize.Width; continue; } strString = String.Format("{0:G0} {1} ", nShotNum++, strBlank); StringSize = Graphics.MeasureString(strString, LabelFont); Graphics.DrawString(strString, LabelFont, Brushes.Black, dX, dY); dY += ((float)LabelFont.Height * (float)1.5); } } //----------------------------------------------------------------------------* // Ammo Test Data //----------------------------------------------------------------------------* if (TestDataRadioButton.Checked) { dX = LabelRect.X; strString = "Test Data"; Graphics.DrawString(strString, LabelBoldFont, Brushes.Black, dX, dY); dY += (float)(LabelBoldFont.Height * 1.25); //----------------------------------------------------------------------------* // Loop through the tests //----------------------------------------------------------------------------* foreach (cAmmoTest AmmoTest in m_Ammo.TestList) { cTestStatistics Statistics = new cTestStatistics(AmmoTest.TestShotList); dX = LabelRect.X; // Test Date strString = "Date: "; Graphics.DrawString(strString, LabelFont, Brushes.Black, dX, dY); LabelSize = Graphics.MeasureString(strString, LabelFont); BoldSize = Graphics.MeasureString(strString, LabelBoldFont); dX += LabelSize.Width; dY -= (BoldSize.Height - LabelSize.Height); strString = String.Format("{0} ", AmmoTest.TestDate.ToShortDateString()); Graphics.DrawString(strString, LabelBoldFont, Brushes.Black, dX, dY); BoldSize = Graphics.MeasureString(strString, LabelBoldFont); dX += BoldSize.Width; float dDataHeaderX = dX; dY += (BoldSize.Height - LabelSize.Height); // Firearm strString = "Muzzel Vel.: "; LabelSize = Graphics.MeasureString(strString, LabelFont); dDataX = dX + LabelSize.Width; strString = "Firearm: "; LabelSize = Graphics.MeasureString(strString, LabelFont); Graphics.DrawString(strString, LabelFont, Brushes.Black, dDataX - LabelSize.Width, dY); LabelSize = Graphics.MeasureString(strString, LabelFont); BoldSize = Graphics.MeasureString(strString, LabelBoldFont); dX = dDataX; dY -= (BoldSize.Height - LabelSize.Height); strString = String.Format("{0}", AmmoTest.Firearm != null ? AmmoTest.Firearm.ToString() : "Factory"); Graphics.DrawString(strString, LabelBoldFont, Brushes.Black, dX, dY); BoldSize = Graphics.MeasureString(strString, LabelBoldFont); dX += BoldSize.Width; dY += BoldSize.Height; // Muzzle Velocity strString = "Muzzle Vel.: "; LabelSize = Graphics.MeasureString(strString, LabelFont); dX = dDataX - LabelSize.Width; Graphics.DrawString(strString, LabelFont, Brushes.Black, dX, dY); BoldSize = Graphics.MeasureString(strString, LabelBoldFont); dX += LabelSize.Width; dY -= (BoldSize.Height - LabelSize.Height); strString = String.Format("{0:F0} {1}", AmmoTest.Firearm != null ? cDataFiles.StandardToMetric(Statistics.AverageVelocity, cDataFiles.eDataType.Velocity) : cDataFiles.StandardToMetric(AmmoTest.MuzzleVelocity, cDataFiles.eDataType.Velocity), cDataFiles.MetricString(cDataFiles.eDataType.Velocity)); Graphics.DrawString(strString, LabelBoldFont, Brushes.Black, dX, dY); BoldSize = Graphics.MeasureString(strString, LabelBoldFont); dY += (BoldSize.Height * (float)1.25); if (dY > LabelRect.Y + LabelRect.Height) { break; } } } }
//============================================================================* // SetLoadData() //============================================================================* public void SetLoadData(cLoad Load) { //----------------------------------------------------------------------------* // Create the format strings //----------------------------------------------------------------------------* string strChargeFormat = m_DataFiles.Preferences.FormatString(cDataFiles.eDataType.PowderWeight); string strGroupFormat = m_DataFiles.Preferences.FormatString(cDataFiles.eDataType.GroupSize); //----------------------------------------------------------------------------* // Loop through the charges //----------------------------------------------------------------------------* foreach (cCharge Charge in Load.ChargeList) { //----------------------------------------------------------------------------* // Loop through the charge tests //----------------------------------------------------------------------------* foreach (cChargeTest ChargeTest in Charge.TestList) { if (ChargeTest.BatchID == 0 && !m_fFactoryTest) { continue; } //----------------------------------------------------------------------------* // Create the ListViewItem //----------------------------------------------------------------------------* ListViewItem Item = new ListViewItem(); //----------------------------------------------------------------------------* // Set the ListViewItem Data //----------------------------------------------------------------------------* Item.Text = (ChargeTest.BatchID != 0) ? String.Format("Batch #{0:G0}", ChargeTest.BatchID) : ChargeTest.Source; Item.Tag = new cEvaluationItem(Load, Charge, ChargeTest); Item.SubItems.Add(Load.Caliber.ToString()); Item.SubItems.Add(Load.Bullet.ToString()); Item.SubItems.Add(Load.Powder.ToString()); Item.SubItems.Add(String.Format(strChargeFormat, cDataFiles.StandardToMetric(Charge.PowderWeight, cDataFiles.eDataType.PowderWeight))); Item.SubItems.Add(Load.Primer.ToShortString()); Item.SubItems.Add(Load.Case.ToShortString()); cBatch Batch = null; if (ChargeTest.BatchID != 0) { Batch = m_DataFiles.GetBatchByID(ChargeTest.BatchID); } if (Batch == null || Batch.BatchTest == null) { Item.SubItems.Add("-"); } else { Item.SubItems.Add(String.Format("{0:G0}", Batch.BatchTest.NumRounds)); } if (ChargeTest.BestGroup == 0.0) { Item.SubItems.Add("-"); } else { Item.SubItems.Add(String.Format(strGroupFormat, cDataFiles.StandardToMetric(ChargeTest.BestGroup, cDataFiles.eDataType.GroupSize))); } if (ChargeTest.BestGroupRange == 0.0) { Item.SubItems.Add("-"); Item.SubItems.Add("-"); } else { Item.SubItems.Add(String.Format("{0:F3}", ChargeTest.BestGroup / ((double)((double)ChargeTest.BestGroupRange / 100.0) * 1.047))); Item.SubItems.Add(String.Format("{0:N0}", cDataFiles.StandardToMetric(ChargeTest.BestGroupRange, cDataFiles.eDataType.Range))); } if (ChargeTest.MuzzleVelocity == 0) { Item.SubItems.Add("-"); } else { Item.SubItems.Add(String.Format("{0:N0}", cDataFiles.StandardToMetric(ChargeTest.MuzzleVelocity, cDataFiles.eDataType.Velocity))); } if (Batch == null || Batch.BatchTest == null || Batch.BatchTest.TestShotList == null) { Item.SubItems.Add("-"); Item.SubItems.Add("-"); } else { cTestStatistics Statistics = new cTestStatistics(Batch.BatchTest.TestShotList); if (Statistics.MaxDeviation == 0) { Item.SubItems.Add("-"); } else { Item.SubItems.Add(String.Format("{0:N0}", cDataFiles.StandardToMetric(Statistics.MaxDeviation, cDataFiles.eDataType.Velocity))); } if (Statistics.StdDev == 0.0) { Item.SubItems.Add("-"); } else { Item.SubItems.Add(String.Format("{0:F2}", cDataFiles.StandardToMetric(Statistics.StdDev, cDataFiles.eDataType.Velocity))); } } //----------------------------------------------------------------------------* // Add the item to the list //----------------------------------------------------------------------------* AddItem(Item); } } }