//============================================================================* // CanUseBullet() //============================================================================* public bool CanUseBullet(cBullet Bullet) { if (Bullet != null) { foreach (cFirearmCaliber FirearmCaliber in m_FirearmCaliberList) { if (Bullet.HasCaliber(FirearmCaliber.Caliber)) { return(true); } } } return(false); }
//============================================================================* // SetMinMax() //============================================================================* private void SetMinMax() { //----------------------------------------------------------------------------* // Get Load //----------------------------------------------------------------------------* cLoad Load = null; if (LoadCombo.SelectedIndex > 0) { Load = (cLoad)LoadCombo.SelectedItem; } //----------------------------------------------------------------------------* // Get Bullet //----------------------------------------------------------------------------* cBullet Bullet = null; if (BulletCombo.SelectedIndex > 0 || BulletCombo.SelectedItem is cBullet) { Bullet = (cBullet)BulletCombo.SelectedItem; } //----------------------------------------------------------------------------* // Get Firearm //----------------------------------------------------------------------------* cFirearm Firearm = null; if (FirearmCombo.SelectedIndex > 0) { Firearm = (cFirearm)FirearmCombo.SelectedItem; } //----------------------------------------------------------------------------* // Get caliber list depending on the firearm or bullet selected //----------------------------------------------------------------------------* cCaliberList CaliberList = m_DataFiles.CaliberList; if (Bullet != null) { CaliberList = new cCaliberList(); foreach (cBulletCaliber BulletCaliber in Bullet.BulletCaliberList) { CaliberList.Add(BulletCaliber.Caliber); } } else { if (Firearm != null) { CaliberList = new cCaliberList(); foreach (cFirearmCaliber FirearmCaliber in Firearm.CaliberList) { CaliberList.Add(FirearmCaliber.Caliber); } } } //----------------------------------------------------------------------------* // Set Caliber Min/Max //----------------------------------------------------------------------------* double dMinDiameter = 1000.0; double dMaxDiameter = 0.0; double dMinWeight = cBullet.MaxBulletWeight; double dMaxWeight = 0.0; foreach (cCaliber Caliber in CaliberList) { if ((Load == null || Load.Caliber.CompareTo(Caliber) == 0) && (Firearm == null || Firearm.HasCaliber(Caliber)) && (Bullet == null || Bullet.HasCaliber(Caliber))) { if (Caliber.MinBulletDiameter < dMinDiameter) { dMinDiameter = Caliber.MinBulletDiameter; } if (Caliber.MaxBulletDiameter > dMaxDiameter) { dMaxDiameter = Caliber.MaxBulletDiameter; } if (Caliber.MinBulletWeight < dMinWeight) { dMinWeight = Caliber.MinBulletWeight; } if (Caliber.MaxBulletWeight > dMaxWeight) { dMaxWeight = Caliber.MaxBulletWeight; } } } CaliberTextBox.MinValue = cDataFiles.StandardToMetric(dMinDiameter, cDataFiles.eDataType.Dimension); CaliberTextBox.MaxValue = cDataFiles.StandardToMetric(dMaxDiameter, cDataFiles.eDataType.Dimension); if (!CaliberTextBox.ValueOK) { CaliberTextBox.Value = CaliberTextBox.MinValue; m_StabilityData.BulletDiameter = cDataFiles.MetricToStandard(CaliberTextBox.MinValue, cDataFiles.eDataType.Dimension); } if (CaliberTextBox.MinValue == CaliberTextBox.MaxValue) { CaliberTextBox.Enabled = false; m_StabilityData.BulletDiameter = cDataFiles.MetricToStandard(CaliberTextBox.MinValue, cDataFiles.eDataType.Dimension); } else { CaliberTextBox.Enabled = true; } //----------------------------------------------------------------------------* // Set Weight Min/Max //----------------------------------------------------------------------------* if (Bullet != null) { WeightTextBox.MinValue = cDataFiles.StandardToMetric(Bullet.Weight, cDataFiles.eDataType.BulletWeight); WeightTextBox.MaxValue = cDataFiles.StandardToMetric(Bullet.Weight, cDataFiles.eDataType.BulletWeight); WeightTextBox.Enabled = false; } else { WeightTextBox.MinValue = cDataFiles.StandardToMetric(dMinWeight, cDataFiles.eDataType.BulletWeight); WeightTextBox.MaxValue = cDataFiles.StandardToMetric(dMaxWeight, cDataFiles.eDataType.BulletWeight); WeightTextBox.Enabled = true; } if (!WeightTextBox.ValueOK) { WeightTextBox.Value = WeightTextBox.MinValue; m_StabilityData.BulletWeight = cDataFiles.MetricToStandard(WeightTextBox.Value, cDataFiles.eDataType.BulletWeight); } //----------------------------------------------------------------------------* // Set Length Min/Max //----------------------------------------------------------------------------* LengthTextBox.MinValue = cDataFiles.StandardToMetric(0.050, cDataFiles.eDataType.Dimension); LengthTextBox.MaxValue = cDataFiles.StandardToMetric(3.0, cDataFiles.eDataType.Dimension); LengthTextBox.Enabled = Bullet == null || Bullet.Length == 0.0; //----------------------------------------------------------------------------* // Set Ballistic Coefficient Min/Max //----------------------------------------------------------------------------* BallisticCoefficientTextBox.Enabled = (Bullet != null) ? false : true; //----------------------------------------------------------------------------* // Set Muzzle Velocity Min/Max //----------------------------------------------------------------------------* if (Load != null) { int nMinValue = 5000; int nMaxValue = 500; bool fTestFound = false; foreach (cCharge Charge in Load.ChargeList) { foreach (cChargeTest ChargeTest in Charge.TestList) { fTestFound = true; if (ChargeTest.MuzzleVelocity < nMinValue) { nMinValue = ChargeTest.MuzzleVelocity; } if (ChargeTest.MuzzleVelocity > nMaxValue) { nMaxValue = ChargeTest.MuzzleVelocity; } } } if (fTestFound) { VelocityTextBox.MinValue = (int)cDataFiles.StandardToMetric(nMinValue, cDataFiles.eDataType.Velocity); VelocityTextBox.MaxValue = (int)cDataFiles.StandardToMetric(nMaxValue, cDataFiles.eDataType.Velocity); } else { VelocityTextBox.MinValue = cm_nMinVelocity; VelocityTextBox.MaxValue = (int)cDataFiles.StandardToMetric(5000, cDataFiles.eDataType.Velocity); } } else { VelocityTextBox.MinValue = (int)cDataFiles.StandardToMetric(cm_nMinVelocity, cDataFiles.eDataType.Velocity); VelocityTextBox.MaxValue = (int)cDataFiles.StandardToMetric(5000, cDataFiles.eDataType.Velocity); } if (!VelocityTextBox.ValueOK) { VelocityTextBox.Value = VelocityTextBox.MinValue; m_StabilityData.MuzzleVelocity = (int)cDataFiles.MetricToStandard(VelocityTextBox.Value, cDataFiles.eDataType.Velocity); } //----------------------------------------------------------------------------* // Set Twist Min/Max //----------------------------------------------------------------------------* if (Firearm != null) { TwistTextBox.Enabled = false; } else { TwistTextBox.MinValue = cDataFiles.StandardToMetric(5, cDataFiles.eDataType.Firearm); TwistTextBox.MaxValue = cDataFiles.StandardToMetric(78, cDataFiles.eDataType.Firearm); TwistTextBox.Enabled = true; } }