//============================================================================* // SetFirearmData() //============================================================================* public void SetFirearmData(ListViewItem Item, cFirearm Firearm) { Item.SubItems.Clear(); cCaliber.CurrentFirearmType = Firearm.FirearmType; Item.Text = Firearm.Manufacturer.ToString(); Item.Group = Groups[(int)Firearm.FirearmType]; Item.Tag = Firearm; Item.Checked = Firearm.Checked; Item.SubItems.Add(Firearm.PartNumber); Item.SubItems.Add(Firearm.SerialNumber); Item.SubItems.Add(Firearm.Description); Item.SubItems.Add(Firearm.PrimaryCaliber.ToString()); Item.SubItems.Add(Firearm.Source); if (Firearm.PurchaseDate.Year == 1) { Firearm.PurchaseDate = DateTime.Today; } Item.SubItems.Add(!String.IsNullOrEmpty(Firearm.Source)? String.Format("{0}", Firearm.PurchaseDate.ToShortDateString()) : ""); Item.SubItems.Add(!String.IsNullOrEmpty(Firearm.Source) && Firearm.PurchasePrice != 0.0? String.Format("{0:F2}", Firearm.PurchasePrice) : "-"); Item.SubItems.Add(!String.IsNullOrEmpty(Firearm.Source) && Firearm.Tax != 0.0 ? String.Format("{0:F2}", Firearm.Tax) : "-"); Item.SubItems.Add(!String.IsNullOrEmpty(Firearm.Source) && Firearm.Shipping != 0.0 ? String.Format("{0:F2}", Firearm.Shipping) : "-"); Item.SubItems.Add(!String.IsNullOrEmpty(Firearm.Source) && Firearm.TransferFees != 0.0 ? String.Format("{0:F2}", Firearm.TransferFees) : "-"); Item.SubItems.Add(!String.IsNullOrEmpty(Firearm.Source) && Firearm.OtherFees != 0.0 ? String.Format("{0:F2}", Firearm.OtherFees) : "-"); double dTotal = Firearm.PurchasePrice + Firearm.Tax + Firearm.Shipping + Firearm.TransferFees + Firearm.OtherFees; Item.SubItems.Add(!String.IsNullOrEmpty(Firearm.Source) && dTotal != 0.0 && Firearm.PurchaseDate.Year > 1 ? String.Format("{0:F2}", dTotal) : "-"); }
//============================================================================* // OnFirearmSelected() //============================================================================* private void OnFirearmSelected(object sender, EventArgs e) { if (FirearmCombo.SelectedIndex == 0) { m_ChargeTest.Firearm = null; BarrelLengthTextBox.Enabled = true; TwistTextBox.Enabled = true; } else { cFirearm Firearm = (cFirearm)FirearmCombo.SelectedItem; m_ChargeTest.Firearm = Firearm; m_ChargeTest.BarrelLength = Firearm.BarrelLength; m_ChargeTest.Twist = Firearm.Twist; BarrelLengthTextBox.Value = cDataFiles.StandardToMetric(m_ChargeTest.BarrelLength, cDataFiles.eDataType.Firearm); TwistTextBox.Value = cDataFiles.StandardToMetric(m_ChargeTest.Twist, cDataFiles.eDataType.Firearm); BarrelLengthTextBox.Enabled = false; TwistTextBox.Enabled = false; } UpdateButtons(); }
//============================================================================* // VerifyFirearmAccessory() //============================================================================* public bool VerifyFirearmAccessory(cGear Gear) { //----------------------------------------------------------------------------* // Check Filters //----------------------------------------------------------------------------* if (!m_afFilters[(int)Gear.GearType]) { return(false); } //----------------------------------------------------------------------------* // If firearm is null, it's good to go //----------------------------------------------------------------------------* if (m_Firearm == null) { return(true); } //----------------------------------------------------------------------------* // Otherwise, only gear for the specified firearm is ok //----------------------------------------------------------------------------* cFirearm Firearm = (cFirearm)Gear.Parent; if (Firearm == null || Firearm.CompareTo(m_Firearm) != 0) { return(false); } return(true); }
//============================================================================* // PopulateAmmoTestData() //============================================================================* public void PopulateAmmoTestData() { TestDatePicker.Value = m_AmmoTest.TestDate; cFirearm Firearm = (cFirearm)FirearmCombo.SelectedItem; if (Firearm != null) { BarrelLengthTextBox.Value = Firearm.BarrelLength; BarrelLengthTextBox.Enabled = false; TwistTextBox.Value = Firearm.Twist; TwistTextBox.Enabled = false; } else { BarrelLengthTextBox.Value = 0; BarrelLengthTextBox.Enabled = true; TwistTextBox.Value = 0; TwistTextBox.Enabled = true; } NumShotsTextBox.Value = m_AmmoTest.NumRounds; BestGroupTextBox.Value = cDataFiles.StandardToMetric(m_AmmoTest.BestGroup, cDataFiles.eDataType.GroupSize); BestGroupRangeTextBox.Value = (int)cDataFiles.StandardToMetric(m_AmmoTest.BestGroupRange, cDataFiles.eDataType.Range); }
//============================================================================* // AddFirearm() //============================================================================* public ListViewItem AddFirearm(cFirearm Firearm, bool fSelect = false) { //----------------------------------------------------------------------------* // Verify that the firearm should be added to the list //----------------------------------------------------------------------------* if (!VerifyFirearm(Firearm)) { return(null); } //----------------------------------------------------------------------------* // Create the ListViewItem //----------------------------------------------------------------------------* ListViewItem Item = new ListViewItem(); SetFirearmData(Item, Firearm); //----------------------------------------------------------------------------* // Add the item to the list and exit //----------------------------------------------------------------------------* AddItem(Item, fSelect); return(Item); }
//============================================================================* // 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; }
//============================================================================* // Copy() - BatchTest //============================================================================* public void Copy(cBatchTest BatchTest) { if (BatchTest != null) { return; } foreach (cCharge Charge in BatchTest.Batch.Load.ChargeList) { if (Charge.PowderWeight == BatchTest.Batch.PowderWeight) { break; } } m_dBarrelLength = BatchTest.Firearm.BarrelLength; m_dBestGroup = BatchTest.BestGroup; m_dBestGroupRange = BatchTest.BestGroupRange; m_Firearm = BatchTest.Firearm; m_nMuzzleVelocity = BatchTest.MuzzleVelocity; m_strNotes = BatchTest.Notes; m_nPressure = BatchTest.Pressure; m_TestDate = BatchTest.TestDate; m_dTwist = BatchTest.Firearm.Twist; m_dPowderWeight = BatchTest.Batch.PowderWeight; m_fBatchTest = true; if (BatchTest.Batch != null) { m_nBatchID = BatchTest.Batch.BatchID; m_strSource = String.Format("Batch #{0:G0} Testing", BatchTest.Batch.BatchID); } }
//============================================================================* // OnFirearmSelected() //============================================================================* private void OnFirearmSelected(Object sender, EventArgs e) { if (!m_fInitialized || m_fPopulating) { return; } cFirearm Firearm = null; if (FirearmCombo.SelectedIndex > 0) { Firearm = (cFirearm)FirearmCombo.SelectedItem; } if (Firearm != null) { m_StabilityData.Twist = Firearm.Twist; } PopulateLoadCombo(); PopulateBulletCombo(); PopulateData(); SetMinMax(); UpdateButtons(); SetStabilityFactor(); }
//============================================================================* // PopulateFirearmCombo() //============================================================================* private void PopulateFirearmCombo() { m_fPopulating = true; //----------------------------------------------------------------------------* // Get the currently selected firearm //----------------------------------------------------------------------------* cFirearm SelectedFirearm = null; if (FirearmCombo.SelectedIndex > 0 || FirearmCombo.SelectedItem is cFirearm) { SelectedFirearm = (cFirearm)FirearmCombo.SelectedItem; } //----------------------------------------------------------------------------* // Reset the firearm combo //----------------------------------------------------------------------------* FirearmCombo.Items.Clear(); //----------------------------------------------------------------------------* // Get the selected Bullet //----------------------------------------------------------------------------* cBullet Bullet = null; if (BulletCombo.SelectedIndex > 0 || BulletCombo.SelectedItem is cBullet) { Bullet = (cBullet)BulletCombo.SelectedItem; } //----------------------------------------------------------------------------* // Populate the firearm combo //----------------------------------------------------------------------------* FirearmCombo.Items.Add("No Specific Firearm"); foreach (cFirearm Firearm in m_DataFiles.FirearmList) { if (Firearm.FirearmType == cFirearm.eFireArmType.Rifle && (Bullet == null || Firearm.CanUseBullet(Bullet))) { FirearmCombo.Items.Add(Firearm); } } if (SelectedFirearm != null) { FirearmCombo.SelectedItem = SelectedFirearm; } if (FirearmCombo.SelectedIndex == -1) { FirearmCombo.SelectedIndex = 0; } m_fPopulating = false; }
//============================================================================* // VerifyFirearm() //============================================================================* public bool VerifyFirearm(cFirearm Firearm) { //----------------------------------------------------------------------------* // In this version, all firearms are verified OK //----------------------------------------------------------------------------* return(true); }
//============================================================================* // Synch() - Firearm //============================================================================* public bool Synch(cFirearm Firearm) { if (m_Firearm != null && m_Firearm.CompareTo(Firearm) == 0) { m_Firearm = Firearm; return(true); } return(false); }
//============================================================================* // Synch() - Firearm //============================================================================* public bool Synch(cFirearm Firearm) { bool fFound = false; foreach (cCharge CheckCharge in m_ChargeList) { fFound = CheckCharge.Synch(Firearm); } return(fFound); }
//============================================================================* // Synch() - Firearm //============================================================================* public bool Synch(cFirearm Firearm) { bool fFound = false; foreach (cChargeTest CheckChargeTest in m_TestList) { fFound = CheckChargeTest.Synch(Firearm); } return(fFound); }
//============================================================================* // Synch() - Firearm //============================================================================* public void Synch(cFirearm Firearm) { if (Firearm != null) { foreach (cAmmoTest AmmoTest in m_TestList) { if (Firearm.CompareTo(AmmoTest.Firearm) == 0) { AmmoTest.Firearm = Firearm; } } } }
//============================================================================* // Copy() //============================================================================* public void Copy(cFirearm Firearm) { base.Copy(Firearm); //----------------------------------------------------------------------------* // General //----------------------------------------------------------------------------* m_eFirearmType = Firearm.m_eFirearmType; //----------------------------------------------------------------------------* // Specs //----------------------------------------------------------------------------* m_dBarrelLength = Firearm.m_dBarrelLength; m_fScoped = Firearm.m_fScoped; m_dTwist = Firearm.m_dTwist; m_eTurretType = Firearm.m_eTurretType; m_dSightHeight = Firearm.m_dSightHeight; m_dScopeClick = Firearm.m_dScopeClick; m_dZeroRange = Firearm.m_dZeroRange; m_dHeadSpace = Firearm.m_dHeadSpace; m_dNeck = Firearm.m_dNeck; m_FirearmCaliberList = new cFirearmCaliberList(Firearm.m_FirearmCaliberList); m_FirearmBulletList = new cFirearmBulletList(Firearm.m_FirearmBulletList); //----------------------------------------------------------------------------* // Details //----------------------------------------------------------------------------* m_strImageFile = Firearm.m_strImageFile; m_dTransferFees = Firearm.m_dTransferFees; m_dOtherFees = Firearm.m_dOtherFees; m_strReceiverFinish = Firearm.m_strReceiverFinish; m_strBarrelFinish = Firearm.m_strBarrelFinish; m_strType = Firearm.m_strType; m_strAction = Firearm.m_strAction; m_strHammer = Firearm.m_strHammer; m_strMagazine = Firearm.m_strMagazine; m_nCapacity = Firearm.m_nCapacity; }
//============================================================================* // Synch() - Firearm //============================================================================* public virtual bool Firearm(cFirearm Firearm) { if (Firearm == null || Parent == null) { return(false); } if (CompareTo(Firearm) == 0) { m_Parent = Firearm; return(true); } return(false); }
//============================================================================* // 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); }
//============================================================================* // PopulateFirearmCombo() //============================================================================* private void PopulateFirearmCombo() { FirearmCombo.Items.Clear(); FirearmCombo.Items.Add("No Specific Firearm"); if (m_Target.BatchID == 0) { cFirearm SelectFirearm = null; foreach (cFirearm Firearm in m_DataFiles.FirearmList) { if (Firearm.HasCaliber(m_Target.Caliber)) { FirearmCombo.Items.Add(Firearm); if (m_Target.Firearm != null && Firearm.CompareTo(m_Target.Firearm) == 0) { SelectFirearm = Firearm; } } } if (SelectFirearm != null) { FirearmCombo.SelectedItem = SelectFirearm; } } else { if (m_Target.Firearm != null) { FirearmCombo.Items.Clear(); FirearmCombo.Items.Add(m_Target.Firearm); FirearmCombo.SelectedItem = m_Target.Firearm; } } if (FirearmCombo.SelectedIndex < 0 && FirearmCombo.Items.Count > 0) { FirearmCombo.SelectedIndex = 0; } }
//============================================================================* // UpdateFirearm() //============================================================================* public ListViewItem UpdateFirearm(cFirearm Firearm, bool fSelect = false) { //----------------------------------------------------------------------------* // Find the Item //----------------------------------------------------------------------------* ListViewItem Item = null; foreach (ListViewItem CheckItem in Items) { if ((CheckItem.Tag as cFirearm).CompareTo(Firearm) == 0) { Item = CheckItem; break; } } //----------------------------------------------------------------------------* // If the item was not found, add it //----------------------------------------------------------------------------* if (Item == null) { return(AddFirearm(Firearm, fSelect)); } //----------------------------------------------------------------------------* // Otherwise, update the Item Data //----------------------------------------------------------------------------* SetFirearmData(Item, Firearm); if (fSelect) { Item.Selected = fSelect; Item.EnsureVisible(); } Focus(); return(Item); }
//============================================================================* // cTarget() - Copy Constructor //============================================================================* public cTarget(cTarget Target) { m_nBatchID = Target.m_nBatchID; m_dRange = Target.m_dRange; m_nRotation = Target.m_nRotation; m_dBulletDiameter = Target.m_dBulletDiameter; m_Caliber = Target.m_Caliber; m_dCalibrationLength = Target.m_dCalibrationLength; m_CalibrationStart = new Point(Target.m_CalibrationStart.X, Target.m_CalibrationStart.Y); m_CalibrationEnd = new Point(Target.m_CalibrationEnd.X, Target.m_CalibrationEnd.Y); m_dGroupSize = Target.m_dGroupSize; if (Target.m_TargetImage != null) { m_TargetImage = new Bitmap(Target.m_TargetImage); } m_AimPoint = new Point(Target.m_AimPoint.X, Target.m_AimPoint.Y); m_ShotList = new List <Point>(Target.m_ShotList); m_Date = Target.m_Date; m_strShooter = Target.m_strShooter; m_strLocation = Target.m_strLocation; m_strEvent = Target.m_strEvent; m_strNotes = Target.m_strNotes; m_Firearm = Target.Firearm; m_AimPointColor = Target.m_AimPointColor; m_OffsetColor = Target.m_OffsetColor; m_ShotColor = Target.m_ShotColor; m_ShotForecolor = Target.m_ShotForecolor; m_ReticleColor = Target.m_ReticleColor; m_ScaleForecolor = Target.m_ScaleForecolor; m_ScaleBackcolor = Target.m_ScaleBackcolor; m_ExtremesColor = Target.m_ExtremesColor; m_GroupBoxColor = Target.m_GroupBoxColor; }
//============================================================================* // ResolveIdentities() //============================================================================* public bool ResolveIdentities(cDataFiles DataFiles) { bool fChanged = false; if (m_Firearm.Identity) { foreach (cFirearm Firearm in DataFiles.FirearmList) { if (!Firearm.Identity && Firearm.CompareTo(m_Firearm) == 0) { m_Firearm = Firearm; fChanged = true; break; } } } return(fChanged); }
//============================================================================* // Copy() - ChargeTest //============================================================================* public void Copy(cChargeTest ChargeTest) { m_TestDate = ChargeTest.m_TestDate; m_strSource = ChargeTest.m_strSource; m_Firearm = ChargeTest.m_Firearm; m_dBarrelLength = ChargeTest.m_dBarrelLength; m_dTwist = ChargeTest.m_dTwist; m_nMuzzleVelocity = ChargeTest.m_nMuzzleVelocity; m_nPressure = ChargeTest.m_nPressure; m_dBestGroup = ChargeTest.m_dBestGroup; m_dBestGroupRange = ChargeTest.m_dBestGroupRange; m_strNotes = ChargeTest.m_strNotes; m_fBatchTest = ChargeTest.m_fBatchTest; m_nBatchID = ChargeTest.m_nBatchID; m_dPowderWeight = ChargeTest.m_dPowderWeight; }
//============================================================================* // Copy() //============================================================================* public void Copy(cBatch Batch) { m_nBatchID = Batch.m_nBatchID; m_nOCWBatchID = Batch.m_nOCWBatchID; m_strUserID = Batch.m_strUserID; m_DateLoaded = new DateTime(Batch.DateLoaded.Ticks); m_dPowderWeight = Batch.m_dPowderWeight; m_nNumRounds = Batch.m_nNumRounds; m_nTimesFired = Batch.m_nTimesFired; m_dCOL = Batch.m_dCOL; m_dCBTO = Batch.m_dCBTO; m_dHeadSpace = Batch.m_dHeadSpace; m_dNeckSize = Batch.m_dNeckSize; m_dNeckWall = Batch.m_dNeckWall; m_dCaseTrimLength = Batch.m_dCaseTrimLength; m_dBulletDiameter = Batch.m_dBulletDiameter; m_fFullLengthSized = Batch.m_fFullLengthSized; m_fNeckSized = Batch.m_fNeckSized; m_fExpandedNeck = Batch.m_fExpandedNeck; m_fGasCheck = Batch.m_fGasCheck; m_fNeckTurned = Batch.m_fNeckTurned; m_fAnnealed = Batch.m_fAnnealed; m_fModifiedBullet = Batch.m_fModifiedBullet; m_fJumpSet = Batch.m_fJumpSet; m_dJump = Batch.m_dJump; m_Firearm = Batch.m_Firearm; m_Load = Batch.m_Load; m_BatchTestList = new cBatchTestList(Batch.BatchTestList); m_fArchive = Batch.m_fArchive; m_fTrackInventory = Batch.m_fTrackInventory; }
//============================================================================* // CompareTo() //============================================================================* public override int CompareTo(Object obj) { if (obj == null) { return(1); } cFirearm Firearm = (cFirearm)obj; int rc = base.CompareTo(Firearm); //----------------------------------------------------------------------------* // Firearm Type //----------------------------------------------------------------------------* if (rc == 0) { rc = m_eFirearmType.CompareTo(Firearm.m_eFirearmType); } return(rc); }
//============================================================================* // cFirearmBulletListView() - Constructor //============================================================================* public cFirearmBulletListView(cDataFiles DataFiles, cFirearm Firearm) : base(DataFiles, cPreferences.eApplicationListView.FirearmsBulletListView) { m_DataFiles = DataFiles; m_Firearm = Firearm; m_Caliber = m_Firearm.PrimaryCaliber; //----------------------------------------------------------------------------* // Set Properties //----------------------------------------------------------------------------* Font = new System.Drawing.Font(Font, System.Drawing.FontStyle.Bold); //----------------------------------------------------------------------------* // Set column measurements //----------------------------------------------------------------------------* m_arColumns[1].Text += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.Dimension)); m_arColumns[2].Text += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.Dimension)); m_arColumns[3].Text += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.Dimension)); //----------------------------------------------------------------------------* // Populate Columns and Groups //----------------------------------------------------------------------------* SortingOrder = m_DataFiles.Preferences.FirearmBulletSortOrder; SortingColumn = m_DataFiles.Preferences.FirearmBulletSortColumn; PopulateColumns(m_arColumns); //----------------------------------------------------------------------------* // Populate Data //----------------------------------------------------------------------------* Populate(); Initialized = true; }
//============================================================================* // Comparer() //============================================================================* public static int Comparer(cFirearm Firearm1, cFirearm Firearm2) { if (Firearm1 == null) { if (Firearm2 != null) { return(-1); } else { return(0); } } else { if (Firearm2 == null) { return(1); } } return(Firearm1.CompareTo(Firearm2)); }
//============================================================================* // ResolveIdentities() //============================================================================* public bool ResolveIdentities(cDataFiles Datafiles) { bool fChanged = false; if (m_Ammo != null && m_Ammo.Identity) { foreach (cAmmo Ammo in Datafiles.AmmoList) { if (m_Ammo.CompareTo(Ammo) == 0) { m_Ammo = Ammo; fChanged = true; break; } } } if (m_Firearm != null && m_Firearm.Identity) { foreach (cFirearm Firearm in Datafiles.FirearmList) { if (m_Firearm.CompareTo(Firearm) == 0) { m_Firearm = Firearm; fChanged = true; break; } } } return(fChanged); }
//============================================================================* // ResolveIdentities() //============================================================================* public bool ResolveIdentities(cDataFiles DataFiles) { bool fChanged = false; if (m_Firearm != null && m_Firearm.Identity) { foreach (cFirearm Firearm in DataFiles.FirearmList) { if (!Firearm.Identity && m_Firearm.CompareTo(Firearm) == 0) { m_Firearm = Firearm; fChanged = true; break; } } } if (m_Load != null && m_Load.Identity) { foreach (cLoad Load in DataFiles.LoadList) { if (!Load.Identity && m_Load.CompareTo(Load) == 0) { m_Load = Load; fChanged = true; break; } } } return(fChanged); }
//============================================================================* // Compare() //============================================================================* public override int Compare(Object Object1, Object Object2) { if (Object1 == null) { if (Object2 == null) { return(0); } else { return(-1); } } else { if (Object2 == null) { return(1); } } cFirearm Firearm1 = (cFirearm)(Object1 as ListViewItem).Tag; cFirearm Firearm2 = (cFirearm)(Object2 as ListViewItem).Tag; if (Firearm1 == null) { if (Firearm2 == null) { return(0); } else { return(0); } } else { if (Firearm2 == null) { return(1); } } //----------------------------------------------------------------------------* // Do Special Compares //----------------------------------------------------------------------------* bool fSpecial = false; int rc = 0; double dTotal1 = 0.0; double dTotal2 = 0.0; switch (SortColumn) { //----------------------------------------------------------------------------* // Manufacturer //----------------------------------------------------------------------------* case 0: rc = CompareGear(Firearm1, Firearm2); if (rc == 0) { rc = Firearm1.PrimaryCaliber.CompareTo(Firearm2.PrimaryCaliber); } fSpecial = true; break; //----------------------------------------------------------------------------* // Model //----------------------------------------------------------------------------* case 1: rc = cDataFiles.ComparePartNumbers(Firearm1.PartNumber, Firearm2.PartNumber); if (rc == 0) { rc = Firearm1.Manufacturer.CompareTo(Firearm2.Manufacturer); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.SerialNumber, Firearm2.SerialNumber); } } fSpecial = true; break; //----------------------------------------------------------------------------* // Serial Number //----------------------------------------------------------------------------* case 2: rc = cDataFiles.ComparePartNumbers(Firearm1.SerialNumber, Firearm2.SerialNumber); if (rc == 0) { rc = Firearm1.Manufacturer.CompareTo(Firearm2.Manufacturer); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.PartNumber, Firearm2.PartNumber); } } fSpecial = true; break; //----------------------------------------------------------------------------* // Description //----------------------------------------------------------------------------* case 3: rc = Firearm1.Description.CompareTo(Firearm2.Description); if (rc == 0) { rc = Firearm1.Manufacturer.CompareTo(Firearm2.Manufacturer); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.PartNumber, Firearm2.PartNumber); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.SerialNumber, Firearm2.SerialNumber); } } } fSpecial = true; break; //----------------------------------------------------------------------------* // Caliber //----------------------------------------------------------------------------* case 4: rc = Firearm1.PrimaryCaliber.CompareTo(Firearm2.PrimaryCaliber); if (rc == 0) { CompareGear(Firearm1, Firearm2); } fSpecial = true; break; //----------------------------------------------------------------------------* // Source //----------------------------------------------------------------------------* case 5: rc = Firearm1.Source.CompareTo(Firearm2.Source); if (rc == 0) { rc = Firearm1.Manufacturer.CompareTo(Firearm2.Manufacturer); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.PartNumber, Firearm2.PartNumber); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.SerialNumber, Firearm2.SerialNumber); if (rc == 0) { rc = Firearm1.Description.CompareTo(Firearm2.Description); } } } } fSpecial = true; break; //----------------------------------------------------------------------------* // Date //----------------------------------------------------------------------------* case 6: rc = Firearm1.PurchaseDate.CompareTo(Firearm2.PurchaseDate); if (rc == 0) { rc = CompareGear(Firearm1, Firearm2); } fSpecial = true; break; //----------------------------------------------------------------------------* // Price //----------------------------------------------------------------------------* case 7: rc = Firearm1.PurchasePrice.CompareTo(Firearm2.PurchasePrice); if (rc == 0) { rc = Firearm1.Manufacturer.CompareTo(Firearm2.Manufacturer); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.PartNumber, Firearm2.PartNumber); if (rc == 0) { rc = Firearm1.Description.CompareTo(Firearm2.Description); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.SerialNumber, Firearm2.SerialNumber); if (rc == 0) { rc = Firearm1.Source.CompareTo(Firearm2.Source); } } } } } fSpecial = true; break; //----------------------------------------------------------------------------* // Tax //----------------------------------------------------------------------------* case 8: rc = Firearm1.Tax.CompareTo(Firearm2.Tax); if (rc == 0) { rc = Firearm1.Manufacturer.CompareTo(Firearm2.Manufacturer); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.PartNumber, Firearm2.PartNumber); if (rc == 0) { rc = Firearm1.Description.CompareTo(Firearm2.Description); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.SerialNumber, Firearm2.SerialNumber); if (rc == 0) { rc = Firearm1.Source.CompareTo(Firearm2.Source); } } } } } fSpecial = true; break; //----------------------------------------------------------------------------* // Shipping //----------------------------------------------------------------------------* case 9: rc = Firearm1.Shipping.CompareTo(Firearm2.Shipping); if (rc == 0) { rc = Firearm1.Manufacturer.CompareTo(Firearm2.Manufacturer); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.PartNumber, Firearm2.PartNumber); if (rc == 0) { rc = Firearm1.Description.CompareTo(Firearm2.Description); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.SerialNumber, Firearm2.SerialNumber); if (rc == 0) { rc = Firearm1.Source.CompareTo(Firearm2.Source); } } } } } fSpecial = true; break; //----------------------------------------------------------------------------* // Transfer Fees //----------------------------------------------------------------------------* case 10: dTotal1 = 0.0; if ((Object1 as ListViewItem).Text != "-") { Double.TryParse((Object1 as ListViewItem).SubItems[10].Text, out dTotal1); } dTotal2 = 0.0; if ((Object2 as ListViewItem).Text != "-") { Double.TryParse((Object2 as ListViewItem).SubItems[10].Text, out dTotal2); } rc = dTotal1.CompareTo(dTotal2); if (rc == 0) { rc = Firearm1.Manufacturer.CompareTo(Firearm2.Manufacturer); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.PartNumber, Firearm2.PartNumber); if (rc == 0) { rc = Firearm1.Description.CompareTo(Firearm2.Description); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.SerialNumber, Firearm2.SerialNumber); if (rc == 0) { rc = Firearm1.Source.CompareTo(Firearm2.Source); } } } } } fSpecial = true; break; //----------------------------------------------------------------------------* // Other Fees //----------------------------------------------------------------------------* case 11: dTotal1 = 0.0; if ((Object1 as ListViewItem).Text != "-") { Double.TryParse((Object1 as ListViewItem).SubItems[11].Text, out dTotal1); } dTotal2 = 0.0; if ((Object2 as ListViewItem).Text != "-") { Double.TryParse((Object2 as ListViewItem).SubItems[11].Text, out dTotal2); } rc = dTotal1.CompareTo(dTotal2); if (rc == 0) { rc = Firearm1.Manufacturer.CompareTo(Firearm2.Manufacturer); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.PartNumber, Firearm2.PartNumber); if (rc == 0) { rc = Firearm1.Description.CompareTo(Firearm2.Description); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.SerialNumber, Firearm2.SerialNumber); if (rc == 0) { rc = Firearm1.Source.CompareTo(Firearm2.Source); } } } } } fSpecial = true; break; //----------------------------------------------------------------------------* // Total //----------------------------------------------------------------------------* case 12: dTotal1 = 0.0; if ((Object1 as ListViewItem).Text != "-") { Double.TryParse((Object1 as ListViewItem).SubItems[12].Text, out dTotal1); } dTotal2 = 0.0; if ((Object2 as ListViewItem).Text != "-") { Double.TryParse((Object2 as ListViewItem).SubItems[12].Text, out dTotal2); } rc = dTotal1.CompareTo(dTotal2); if (rc == 0) { rc = Firearm1.Manufacturer.CompareTo(Firearm2.Manufacturer); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.PartNumber, Firearm2.PartNumber); if (rc == 0) { rc = Firearm1.Description.CompareTo(Firearm2.Description); if (rc == 0) { rc = cDataFiles.ComparePartNumbers(Firearm1.SerialNumber, Firearm2.SerialNumber); if (rc == 0) { rc = Firearm1.Source.CompareTo(Firearm2.Source); } } } } } fSpecial = true; break; } if (fSpecial) { if (SortingOrder == SortOrder.Descending) { return(0 - rc); } return(rc); } return(base.Compare(Object1, Object2)); }
//============================================================================* // cFirearmCOLForm() - Constructor //============================================================================* public cFirearmCOLForm(cFirearmCOL FirearmCOL, cFirearm Firearm, cBulletList BulletList, cPreferences Preferences) { InitializeComponent(); m_Firearm = Firearm; m_BulletList = BulletList; m_Preferences = Preferences; if (FirearmCOL == null) { FirearmCOLOKButton.Text = "Add"; if (m_Preferences.LastFirearmCOL == null) { m_FirearmCOL = new cFirearmCOL(); } else { m_FirearmCOL = new cFirearmCOL(m_Preferences.LastFirearmCOL); m_FirearmCOL.COL = 0.0; m_FirearmCOL.OgiveOAL = 0.0; } } else { m_FirearmCOL = new cFirearmCOL(FirearmCOL); FirearmCOLOKButton.Text = "Update"; } //----------------------------------------------------------------------------* // Set Control Event Handlers //----------------------------------------------------------------------------* BulletCombo.SelectedIndexChanged += OnBulletSelected; COLTextBox.TextChanged += OnDoubleValueTextChanged; COLTextBox.KeyPress += cControls.OnDoubleValueKeyPress; COLTextBox.LostFocus += cControls.OnDoubleValue3LostFocus; COLTextBox.GotFocus += cControls.OnTextBoxGotFocus; OgiveOALTextBox.TextChanged += OnDoubleValueTextChanged; OgiveOALTextBox.KeyPress += cControls.OnDoubleValueKeyPress; OgiveOALTextBox.LostFocus += cControls.OnDoubleValue3LostFocus; OgiveOALTextBox.GotFocus += cControls.OnTextBoxGotFocus; FirearmCOLOKButton.Click += OnOKClicked; //----------------------------------------------------------------------------* // Populate bullet Combo //----------------------------------------------------------------------------* cControls.PopulateBulletCombo(BulletCombo, m_BulletList, m_Preferences, null, m_Firearm.Caliber, (int)m_Firearm.FirearmType); //----------------------------------------------------------------------------* // Populate FirearmCOL Data //----------------------------------------------------------------------------* FirearmLabel.Text = m_Firearm.ToString(); MaxCOLTextBox.Text = String.Format("{0:F3}", m_Firearm.Caliber.MaxCOL); COLTextBox.Text = String.Format("{0:F3}", m_FirearmCOL.COL); OgiveOALTextBox.Text = String.Format("{0:F3}", m_FirearmCOL.OgiveOAL); }