//============================================================================* // OnViewLoad() //============================================================================* protected void OnViewLoad(object sender, EventArgs args) { //----------------------------------------------------------------------------* // Get the selected load //----------------------------------------------------------------------------* if (m_LoadDataListView.SelectedItems.Count == 0) { return; } ListViewItem Item = m_LoadDataListView.SelectedItems[0]; if (Item == null) { return; } cLoad Load = (cLoad)Item.Tag; if (Load == null) { return; } //----------------------------------------------------------------------------* // Start the dialog //----------------------------------------------------------------------------* cLoadForm LoadForm = new cLoadForm(Load, m_DataFiles, true); LoadForm.ShowDialog(); m_LoadDataListView.Focus(); }
//============================================================================* // VerifyLoad() //============================================================================* public bool VerifyLoad(cLoad Load, cFirearm.eFireArmType eFirearmType, cCaliber Caliber, cBullet Bullet, cPowder Powder) { if (Load == null) { return(false); } //----------------------------------------------------------------------------* // See if we need to show this load regardless of other considerations //----------------------------------------------------------------------------* if (m_fShowBatchLoad && m_Batch.Load.CompareTo(Load) == 0) { return(true); } //----------------------------------------------------------------------------* // Check Filters //----------------------------------------------------------------------------* if ((eFirearmType != cFirearm.eFireArmType.None && Load.FirearmType != eFirearmType) || (Caliber != null && Load.Caliber.CompareTo(Caliber) != 0) || (Bullet != null && Load.Bullet.CompareTo(Bullet) != 0) || (Powder != null && Load.Powder.CompareTo(Powder) != 0)) { return(false); } //----------------------------------------------------------------------------* // Check Inventory //----------------------------------------------------------------------------* if (!m_DataFiles.VerifyLoadQuantities(m_Batch, Load)) { return(false); } //----------------------------------------------------------------------------* // Make sure the caliber is not hidden //----------------------------------------------------------------------------* if (m_DataFiles.Preferences.HideUncheckedCalibers && !Load.Caliber.Checked) { return(false); } //----------------------------------------------------------------------------* // Make sure the supplies are not hidden //----------------------------------------------------------------------------* if (m_DataFiles.Preferences.HideUncheckedSupplies) { if (!Load.Bullet.Checked || !Load.Powder.Checked || !Load.Primer.Checked || !Load.Case.Checked) { return(false); } } return(true); }
//============================================================================* // AddLoad() //============================================================================* public ListViewItem AddLoad(cLoad Load, cFirearm.eFireArmType eFirearmType, cCaliber Caliber, cBullet Bullet, cPowder Powder) { //----------------------------------------------------------------------------* // Verify that the load should be added //----------------------------------------------------------------------------* if (!VerifyLoad(Load, eFirearmType, Caliber, Bullet, Powder)) { return(null); } //----------------------------------------------------------------------------* // Create the Item //----------------------------------------------------------------------------* ListViewItem Item = new ListViewItem(); SetLoadData(Item, Load); //----------------------------------------------------------------------------* // Add the item and exit //----------------------------------------------------------------------------* AddItem(Item); return(Item); }
//============================================================================* // VerifyLoad() //============================================================================* public bool VerifyLoad(cLoad Load, cFirearm.eFireArmType eFirearmType, cCaliber Caliber, cBullet Bullet, cPowder Powder) { //----------------------------------------------------------------------------* // Check the filters //----------------------------------------------------------------------------* if (Load.FirearmType != eFirearmType || (Caliber != null && Load.Caliber.CompareTo(Caliber) != 0) || (Bullet != null && Load.Bullet.CompareTo(Bullet) != 0) || (Powder != null && Load.Powder.CompareTo(Powder) != 0)) { return(false); } //----------------------------------------------------------------------------* // Make sure the components aren't hidden //----------------------------------------------------------------------------* if ((m_DataFiles.Preferences.HideUncheckedCalibers && !Load.Caliber.Checked)) { return(false); } if (m_DataFiles.Preferences.HideUncheckedSupplies && (!Load.Bullet.Checked || !Load.Powder.Checked || !Load.Primer.Checked || !Load.Case.Checked)) { return(false); } //----------------------------------------------------------------------------* // Good to go! //----------------------------------------------------------------------------* return(true); }
//============================================================================* // OnOKClicked() //============================================================================* private void OnOKClicked(object sender, EventArgs e) { cLoad Load = (cLoad)m_ChargeListView.SelectedItems[0].Tag; m_Load.ChargeList = new cChargeList(Load.ChargeList); foreach (cCharge Charge in m_Load.ChargeList) { while (true) { bool fTestRemoved = false; foreach (cChargeTest ChargeTest in Charge.TestList) { if (ChargeTest.BatchTest) { Charge.TestList.Remove(ChargeTest); fTestRemoved = true; break; } } if (!fTestRemoved) { break; } } } }
//============================================================================* // SetLoadData() //============================================================================* public void SetLoadData(ListViewItem Item, cLoad Load) { Item.SubItems.Clear(); Item.Text = Load.Caliber.ToString(); Item.Tag = Load; Item.Checked = Load.Checked; Item.SubItems.Add(Load.Bullet.ToWeightString()); Item.SubItems.Add(Load.Powder.ToString()); Item.SubItems.Add(Load.Primer.ToShortString()); Item.SubItems.Add(Load.Case.ToShortString()); int nColumnCount = 6; foreach (cCharge Charge in Load.ChargeList) { if (Columns.Count < nColumnCount) { ColumnHeader Column = Columns.Add(String.Format("Charge {0:G} ({1})", nColumnCount - 5, cDataFiles.MetricString(cDataFiles.eDataType.PowderWeight))); Column.TextAlign = nColumnCount == 6 ? HorizontalAlignment.Left : HorizontalAlignment.Center; Column.Width = 100; } Item.SubItems.Add(String.Format(Charge.ToString())); nColumnCount++; } }
//============================================================================* // VerifyLoad() //============================================================================* public bool VerifyLoad(cLoad Load) { if (m_Caliber != null && Load.Caliber.CompareTo(m_Caliber) != 0) { return(false); } if (m_Bullet != null && Load.Bullet.CompareTo(m_Bullet) != 0) { return(false); } if (m_Powder != null && Load.Powder.CompareTo(m_Powder) != 0) { return(false); } if (m_Primer != null && Load.Primer.CompareTo(m_Primer) != 0) { return(false); } if (m_Case != null && Load.Case.CompareTo(m_Case) != 0) { return(false); } return(true); }
//============================================================================* // cCopyChargeListForm() - Constructor //============================================================================* public cCopyChargeListForm(cLoad Load, cDataFiles DataFiles) { InitializeComponent(); if (Load == null) { throw (new Exception("Inavlid Load.")); } m_DataFiles = DataFiles; //----------------------------------------------------------------------------* // Get starting load info //----------------------------------------------------------------------------* m_Load = new cLoad(Load); FirearmTypeLabel.Text = m_Load.FirearmType == 0 ? "Handgun" : "Rifle"; CaliberLabel.Text = m_Load.Caliber.ToString(); BulletLabel.Text = m_Load.Bullet.ToString(); PowderLabel.Text = m_Load.Powder.ToString(); CaseLabel.Text = m_Load.Case.ToString(); PrimerLabel.Text = m_Load.Primer.ToString(); //----------------------------------------------------------------------------* // Set Control Event Handlers //----------------------------------------------------------------------------* CopyChargeListOKButton.Click += OnOKClicked; MatchBulletRadioButton.Click += OnMatchBulletClicked; MatchPrimerRadioButton.Click += OnMatchPrimerClicked; MatchCaseRadioButton.Click += OnMatchCaseClicked; //----------------------------------------------------------------------------* // Create Charge List View //----------------------------------------------------------------------------* m_ChargeListView = new cCopyChargeListView(m_DataFiles); m_ChargeListView.Location = new Point(6, FiltersGroupBox.Location.Y + FiltersGroupBox.Height + 6); m_ChargeListView.Size = new Size(ClientSize.Width - 12, CopyChargeListOKButton.Location.Y - FiltersGroupBox.Location.Y - FiltersGroupBox.Height - 16); Controls.Add(m_ChargeListView); m_ChargeListView.SelectedIndexChanged += OnChargeListSelected; SetClientSizeCore(FiltersGroupBox.Location.X + FiltersGroupBox.Width + 10, CopyChargeListCancelButton.Location.Y + CopyChargeListCancelButton.Height + 20); //----------------------------------------------------------------------------* // Populate Charge List view //----------------------------------------------------------------------------* PopulateChargeListView(); UpdateButtons(); }
//============================================================================* // Populate() //============================================================================* public void Populate(cLoad Load, cCharge SelectCharge) { Populating = true; //----------------------------------------------------------------------------* // Create the format strings //----------------------------------------------------------------------------* m_strPowderWeightFormat = m_DataFiles.Preferences.FormatString(cDataFiles.eDataType.PowderWeight); //----------------------------------------------------------------------------* // Reset the list view //----------------------------------------------------------------------------* Items.Clear(); ListViewItem SelectItem = null; //----------------------------------------------------------------------------* // Loop through the charges //----------------------------------------------------------------------------* foreach (cCharge Charge in Load.ChargeList) { ListViewItem Item = AddCharge(Charge); if (Item != null && SelectCharge != null && SelectCharge.CompareTo(Charge) == 0) { SelectItem = Item; } } Focus(); //----------------------------------------------------------------------------* // Select a charge //----------------------------------------------------------------------------* if (SelectItem != null) { SelectItem.Selected = true; m_DataFiles.Preferences.LastChargeSelected = (cCharge)Items[0].Tag; EnsureVisible(SelectItem.Index); } else { if (Items.Count > 0) { Items[0].Selected = true; EnsureVisible(Items[0].Index); } } Populating = false; }
//============================================================================* // Synch() - Load //============================================================================* public bool Synch(cLoad Load) { if (m_Load != null && m_Load.CompareTo(Load) == 0) { m_Load = Load; return(true); } return(false); }
//============================================================================* // OnRemoveLoad() //============================================================================* protected void OnRemoveLoad(object sender, EventArgs args) { cLoad Load = null; ListViewItem Item = m_LoadDataListView.SelectedItems[0]; if (Item != null) { Load = (cLoad)Item.Tag; } if (Load == null) { m_LoadDataListView.Focus(); return; } //----------------------------------------------------------------------------* // See if the Load is being used in other records //----------------------------------------------------------------------------* string strCount = m_DataFiles.DeleteLoad(Load, true); if (strCount.Length > 0) { string strMessage = "This load is used in\n\n"; strMessage += strCount; strMessage += "\nThe above item(s) must be removed in order to remove this load."; MessageBox.Show(this, strMessage, "Load in Use", MessageBoxButtons.OK, MessageBoxIcon.Information); m_LoadDataListView.Focus(); return; } //----------------------------------------------------------------------------* // Make sure the user is sure //----------------------------------------------------------------------------* if (MessageBox.Show(this, "Are you sure you wish to remove this load data?", "Data Deletion Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { m_DataFiles.DeleteLoad(Load); m_LoadDataListView.Items.Remove(Item); UpdateButtons(); } m_LoadDataListView.Focus(); }
//============================================================================* // cLoad() - Copy Constructor //============================================================================* public cLoad(cLoad Load) { m_eFirearmType = Load.m_eFirearmType; m_Caliber = Load.m_Caliber; m_Bullet = Load.m_Bullet; m_Powder = Load.m_Powder; m_Case = Load.m_Case; m_Primer = Load.m_Primer; m_fChecked = Load.m_fChecked; m_fIdentity = Load.m_fIdentity; m_ChargeList = new cChargeList(Load.m_ChargeList); }
//============================================================================* // AddLoad() //============================================================================* public void AddLoad(cLoad Load) { if (!VerifyLoad(Load)) { return; } //----------------------------------------------------------------------------* // Add the load test item to the list and exit //----------------------------------------------------------------------------* SetLoadData(Load); }
//============================================================================* // SetLoadData() //============================================================================* public void SetLoadData(ListViewItem Item, cLoad Load) { Item.SubItems.Clear(); Item.Text = Load.Caliber.ToString(); Item.Tag = Load; Item.Checked = Load.Checked; Item.SubItems.Add(Load.Bullet.ToWeightString()); Item.SubItems.Add(Load.Powder.ToString()); Item.SubItems.Add(Load.Primer.ToShortString()); Item.SubItems.Add(Load.Case.ToShortString()); }
//============================================================================* // UpdateLoadDataTabButtons() //============================================================================* private void UpdateLoadDataTabButtons() { //----------------------------------------------------------------------------* // Edit, View, Remove Buttons //----------------------------------------------------------------------------* EditLoadButton.Enabled = m_LoadDataListView.SelectedItems.Count > 0; ViewLoadButton.Enabled = m_LoadDataListView.SelectedItems.Count > 0; RemoveLoadButton.Enabled = m_LoadDataListView.SelectedItems.Count > 0; //----------------------------------------------------------------------------* // Evaluate Button //----------------------------------------------------------------------------* int nTestCount = 0; if (m_LoadDataListView.CheckedCount > 0) { foreach (ListViewItem Item in m_LoadDataListView.CheckedItems) { cLoad Load = (cLoad)Item.Tag; foreach (cCharge Charge in Load.ChargeList) { foreach (cChargeTest ChargeTest in Charge.TestList) { if (ChargeTest.BatchID != 0) { nTestCount++; } } } } EvaluateLoadButton.Enabled = nTestCount > 1; } else { EvaluateLoadButton.Enabled = false; } //----------------------------------------------------------------------------* // Shopping List, share, and email buttons //----------------------------------------------------------------------------* LoadShoppingListButton.Enabled = m_LoadDataListView.CheckedCount > 0; ShareFileButton.Enabled = m_LoadDataListView.CheckedItems.Count > 0; }
//============================================================================* // OnEvaluateLoad() //============================================================================* protected void OnEvaluateLoad(Object sender, EventArgs args) { cLoadList LoadList = new cLoadList(); foreach (ListViewItem Item in m_LoadDataListView.CheckedItems) { cLoad Load = (cLoad)Item.Tag; LoadList.AddLoad(Load); } cLoadEvaluationForm Form = new cLoadEvaluationForm(m_DataFiles, LoadList); DialogResult rc = Form.ShowDialog(); }
//============================================================================* // UpdateLoad() //============================================================================* private void UpdateLoad(cLoad OldLoad, cLoad NewLoad) { //----------------------------------------------------------------------------* // Find the NewLoad //----------------------------------------------------------------------------* foreach (cLoad CheckLoad in m_DataFiles.LoadList) { //----------------------------------------------------------------------------* // See if this is the same Load //----------------------------------------------------------------------------* if (CheckLoad.CompareTo(OldLoad) == 0) { //----------------------------------------------------------------------------* // Update the current NewLoad record //----------------------------------------------------------------------------* CheckLoad.FirearmType = NewLoad.FirearmType; CheckLoad.Caliber = NewLoad.Caliber; CheckLoad.Bullet = NewLoad.Bullet; CheckLoad.Powder = NewLoad.Powder; CheckLoad.Case = NewLoad.Case; CheckLoad.Primer = NewLoad.Primer; CheckLoad.ChargeList = new cChargeList(NewLoad.ChargeList); //----------------------------------------------------------------------------* // Update the New Load on the LoadData tab //----------------------------------------------------------------------------* m_LoadDataListView.UpdateLoad(CheckLoad, LoadDataFirearmTypeCombo.Value, LoadDataCaliberCombo.SelectedIndex > 0 ? (cCaliber)LoadDataCaliberCombo.SelectedItem : null, LoadDataBulletCombo.SelectedIndex > 0 ? (cBullet)LoadDataBulletCombo.SelectedItem : null, LoadDataPowderCombo.SelectedIndex > 0 ? (cPowder)LoadDataPowderCombo.SelectedItem : null, true); //----------------------------------------------------------------------------* // Update the tab data //----------------------------------------------------------------------------* PopulateBatchListView(); return; } } //----------------------------------------------------------------------------* // If the NewLoad was not found, add it //----------------------------------------------------------------------------* AddLoad(NewLoad); }
//============================================================================* // UpdateLoad() //============================================================================* public ListViewItem UpdateLoad(cLoad Load, cFirearm.eFireArmType eFirearmType, cCaliber Caliber, cBullet Bullet, cPowder Powder, bool fSelect = false) { //----------------------------------------------------------------------------* // Find the Item //----------------------------------------------------------------------------* ListViewItem Item = null; foreach (ListViewItem CheckItem in Items) { if ((CheckItem.Tag as cLoad).Equals(Load)) { Item = CheckItem; break; } } //----------------------------------------------------------------------------* // If the item was not found, add it //----------------------------------------------------------------------------* if (Item == null) { return(AddLoad(Load, eFirearmType, Caliber, Bullet, Powder, fSelect)); } //----------------------------------------------------------------------------* // Otherwise, update the Item Data //----------------------------------------------------------------------------* SetLoadData(Item, Load); Item.Selected = fSelect; if (SelectedItems.Count > 0) { SelectedItems[0].EnsureVisible(); } Focus(); return(Item); }
//============================================================================* // OnEditLoad() //============================================================================* protected void OnEditLoad(object sender, EventArgs args) { //----------------------------------------------------------------------------* // Get the selected LoadData //----------------------------------------------------------------------------* ListViewItem Item = m_LoadDataListView.SelectedItems[0]; if (Item == null) { return; } cLoad Load = (cLoad)Item.Tag; if (Load == null) { return; } //----------------------------------------------------------------------------* // Start the dialog //----------------------------------------------------------------------------* cLoadForm LoadForm = new cLoadForm(Load, m_DataFiles); if (LoadForm.ShowDialog() == DialogResult.OK) { //----------------------------------------------------------------------------* // Get the new Load Data //----------------------------------------------------------------------------* cLoad NewLoad = LoadForm.Load; m_DataFiles.Preferences.LastLoad = LoadForm.Load; UpdateLoad(Load, NewLoad); } m_LoadDataListView.Focus(); }
//============================================================================* // 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; }
//============================================================================* // cChargeListView() - Constructor //============================================================================* public cChargeListView(cDataFiles DataFiles, cLoad Load) : base(DataFiles, cPreferences.eApplicationListView.ChargeListView) { m_DataFiles = DataFiles; m_Load = Load; //----------------------------------------------------------------------------* // Set Properties //----------------------------------------------------------------------------* //----------------------------------------------------------------------------* // Event Handlers //----------------------------------------------------------------------------* //----------------------------------------------------------------------------* // Load Images //----------------------------------------------------------------------------* //----------------------------------------------------------------------------* // Populate Columns and Groups //----------------------------------------------------------------------------* SortingOrder = m_DataFiles.Preferences.ChargeSortOrder; SortingColumn = m_DataFiles.Preferences.ChargeSortColumn; m_arColumns[0].Text += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.PowderWeight)); PopulateColumns(m_arColumns); //----------------------------------------------------------------------------* // Populate Data //----------------------------------------------------------------------------* Populate(m_Load, null); Initialized = true; }
//============================================================================* // Populate() //============================================================================* public void Populate(cLoad Load, cFirearm.eFireArmType eFirearmType, cCaliber Caliber, cBullet Bullet, cPowder Powder) { Populating = true; Items.Clear(); ListViewItem SelectItem = null; foreach (cLoad CheckLoad in m_DataFiles.LoadList) { if (CheckLoad.CompareTo(Load) == 0) { ListViewItem Item = AddLoad(CheckLoad, eFirearmType, Caliber, Bullet, Powder); SelectItem = Item; } } if (SelectItem != null) { SelectItem.Selected = true; EnsureVisible(SelectItem.Index); } else { if (Items.Count > 0) { Items[0].Selected = true; m_DataFiles.Preferences.LastBatchLoadSelected = (cLoad)Items[0].Tag; EnsureVisible(Items[0].Index); } } Populating = false; }
//============================================================================* // AddLoad() //============================================================================* private void AddLoad(cLoad Load) { //----------------------------------------------------------------------------* // If the Load already exists, update the existing one and exit //----------------------------------------------------------------------------* foreach (cLoad CheckLoad in m_DataFiles.LoadList) { if (CheckLoad.CompareTo(Load) == 0) { UpdateLoad(CheckLoad, Load); return; } } //----------------------------------------------------------------------------* // Add the new Load to the list //----------------------------------------------------------------------------* m_DataFiles.LoadList.Add(Load); //----------------------------------------------------------------------------* // Add the new Load to the LoadData tab //----------------------------------------------------------------------------* cCaliber.CurrentFirearmType = Load.FirearmType; m_LoadDataListView.AddLoad(Load, LoadDataFirearmTypeCombo.Value, LoadDataCaliberCombo.SelectedIndex > 0 ? (cCaliber)LoadDataCaliberCombo.SelectedItem : null, LoadDataBulletCombo.SelectedIndex > 0 ? (cBullet)LoadDataBulletCombo.SelectedItem : null, LoadDataPowderCombo.SelectedIndex > 0 ? (cPowder)LoadDataPowderCombo.SelectedItem : null, true); //----------------------------------------------------------------------------* // Update the Load Data Tab BulletCombo //----------------------------------------------------------------------------* PopulateLoadDataCaliberCombo(); m_LoadDataListView.Focus(); }
//============================================================================* // Comparer() //============================================================================* public static int Comparer(cLoad Load1, cLoad Load2) { if (Load1 == null) { if (Load2 != null) { return(-1); } else { return(0); } } else { if (Load2 == null) { return(1); } } return(Load1.CompareTo(Load2)); }
//============================================================================* // AddLoad() //============================================================================* public ListViewItem AddLoad(cLoad Load, cFirearm.eFireArmType eFirearmType, cCaliber Caliber, cBullet Bullet, cPowder Powder, bool fSelect = false) { if (!VerifyLoad(Load, eFirearmType, Caliber, Bullet, Powder)) { return(null); } //----------------------------------------------------------------------------* // Create the ListViewItem //----------------------------------------------------------------------------* ListViewItem Item = new ListViewItem(); SetLoadData(Item, Load); //----------------------------------------------------------------------------* // Add the item to the list and exit //----------------------------------------------------------------------------* AddItem(Item, fSelect); return(Item); }
//============================================================================* // OnAddLoad() //============================================================================* protected void OnAddLoad(object sender, EventArgs args) { //----------------------------------------------------------------------------* // Start the dialog //----------------------------------------------------------------------------* cLoadForm LoadForm = new cLoadForm(null, m_DataFiles); if (LoadForm.ShowDialog() == DialogResult.OK) { //----------------------------------------------------------------------------* // Get the new Load Data //----------------------------------------------------------------------------* cLoad NewLoad = new cLoad(LoadForm.Load); m_DataFiles.Preferences.LastLoad = LoadForm.Load; AddLoad(NewLoad); } m_LoadDataListView.Focus(); }
//============================================================================* // 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); }
//============================================================================* // cEvaluationItem() - Constructor //============================================================================* public cEvaluationItem(cLoad Load, cCharge Charge, cChargeTest ChargeTest) { m_Load = Load; m_Charge = Charge; m_ChargeTest = ChargeTest; }
//============================================================================* // 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); } } cLoad Load1 = (cLoad)(Object1 as ListViewItem).Tag; cLoad Load2 = (cLoad)(Object2 as ListViewItem).Tag; if (Load1 == null) { if (Load2 == null) { return(0); } else { return(0); } } else { if (Load2 == null) { return(1); } } //----------------------------------------------------------------------------* // Do Special Compares //----------------------------------------------------------------------------* bool fSpecial = false; int rc = 0; switch (SortColumn) { //----------------------------------------------------------------------------* // Caliber //----------------------------------------------------------------------------* case 0: rc = Load1.Caliber.CompareTo(Load2.Caliber); //----------------------------------------------------------------------------* // Bullet //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Bullet.CompareTo(Load2.Bullet); //----------------------------------------------------------------------------* // Powder //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Powder.CompareTo(Load2.Powder); //----------------------------------------------------------------------------* // Primer //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Primer.CompareTo(Load2.Primer); //----------------------------------------------------------------------------* // Case //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Case.CompareTo(Load2.Case); } } } } fSpecial = true; break; //----------------------------------------------------------------------------* // Bullet //----------------------------------------------------------------------------* case 1: rc = Load1.Bullet.CompareTo(Load2.Bullet); //----------------------------------------------------------------------------* // Caliber //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Caliber.CompareTo(Load2.Caliber); //----------------------------------------------------------------------------* // Powder //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Powder.CompareTo(Load2.Powder); //----------------------------------------------------------------------------* // Primer //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Primer.CompareTo(Load2.Primer); //----------------------------------------------------------------------------* // Case //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Case.CompareTo(Load2.Case); } } } } fSpecial = true; break; //----------------------------------------------------------------------------* // Powder //----------------------------------------------------------------------------* case 2: rc = Load1.Powder.CompareTo(Load2.Powder); //----------------------------------------------------------------------------* // Caliber //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Caliber.CompareTo(Load2.Caliber); //----------------------------------------------------------------------------* // Bullet //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Bullet.CompareTo(Load2.Bullet); //----------------------------------------------------------------------------* // Primer //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Primer.CompareTo(Load2.Primer); //----------------------------------------------------------------------------* // Case //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Case.CompareTo(Load2.Case); } } } } fSpecial = true; break; //----------------------------------------------------------------------------* // Primer //----------------------------------------------------------------------------* case 3: rc = Load1.Primer.Manufacturer.CompareTo(Load2.Primer.Manufacturer); //----------------------------------------------------------------------------* // Caliber //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Caliber.CompareTo(Load2.Caliber); //----------------------------------------------------------------------------* // Bullet //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Bullet.CompareTo(Load2.Bullet); //----------------------------------------------------------------------------* // Powder //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Powder.CompareTo(Load2.Powder); //----------------------------------------------------------------------------* // Primer //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Primer.CompareTo(Load2.Primer); //----------------------------------------------------------------------------* // Case //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Case.CompareTo(Load2.Case); } } } } } fSpecial = true; break; //----------------------------------------------------------------------------* // Case //----------------------------------------------------------------------------* case 4: //----------------------------------------------------------------------------* // Case //----------------------------------------------------------------------------* rc = Load1.Case.CompareTo(Load2.Case); //----------------------------------------------------------------------------* // Caliber //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Case.Caliber.CompareTo(Load2.Case.Caliber); //----------------------------------------------------------------------------* // Bullet //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Bullet.CompareTo(Load2.Bullet); //----------------------------------------------------------------------------* // Powder //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Powder.CompareTo(Load2.Powder); //----------------------------------------------------------------------------* // Primer //----------------------------------------------------------------------------* if (rc == 0) { rc = Load1.Primer.CompareTo(Load2.Primer); } } } } fSpecial = true; break; } if (fSpecial) { if (SortingOrder == SortOrder.Descending) { return(0 - rc); } return(rc); } return(base.Compare(Object1, Object2)); }
//============================================================================* // cChargeForm() - Constructor //============================================================================* public cChargeForm(cCharge Charge, cLoad Load, cDataFiles DataFiles, bool fViewOnly = false) { InitializeComponent(); m_Load = Load; m_DataFiles = DataFiles; m_fViewOnly = fViewOnly; m_fEditCharge = !m_fViewOnly; //----------------------------------------------------------------------------* // Get starting load info //----------------------------------------------------------------------------* if (Charge == null) { Text = "Add Charge"; ChargeOKButton.Text = "Add"; if (m_DataFiles.Preferences.LastCharge == null) { m_Charge = new cCharge(); } else { m_Charge = new cCharge(m_DataFiles.Preferences.LastCharge); m_Charge.PowderWeight = 0.0; m_Charge.Favorite = false; m_Charge.Reject = false; m_Charge.TestList.Clear(); } m_fAdd = true; m_fEditCharge = true; } else { m_Charge = new cCharge(Charge); if (!m_fViewOnly) { Text = "Edit Charge"; ChargeOKButton.Text = "Update"; } else { Text = "View Charge"; ChargeOKButton.Visible = false; int nButtonX = (this.Size.Width / 2) - (ChargeCancelButton.Width / 2); ChargeCancelButton.Location = new Point(nButtonX, ChargeCancelButton.Location.Y); ChargeCancelButton.Text = "Close"; } } SetClientSizeCore(LoadDataGroupBox.Location.X + LoadDataGroupBox.Width + 10, ChargeCancelButton.Location.Y + ChargeCancelButton.Height + 20); m_dOriginalCharge = m_Charge.PowderWeight; //----------------------------------------------------------------------------* // Set Control Event Handlers //----------------------------------------------------------------------------* ChargeTestListView.ListViewItemSorter = new cListViewChargeTestComparer(m_DataFiles.Preferences.ChargeTestSortColumn, m_DataFiles.Preferences.ChargeTestSortOrder); ChargeTestListView.ColumnWidthChanged += OnChargeTestListViewColumnWidthChanged; ChargeTestListView.SelectedIndexChanged += OnTestSelected; ChargeTestListView.ColumnWidthChanged += OnChargeTestListViewColumnWidthChanged; if (!m_fViewOnly) { PowderWeightTextBox.TextChanged += OnPowderWeightChanged; FillRatioTextBox.TextChanged += OnFillRatioChanged; AddChargeTestButton.Click += OnAddChargeTest; EditChargeTestButton.Click += OnEditChargeTest; RemoveChargeTestButton.Click += OnRemoveChargeTest; FavoriteRadioButton.Click += OnFavoriteClicked; RejectRadioButton.Click += OnRejectClicked; PowderWeightTextBox.ReadOnly = false; FillRatioTextBox.ReadOnly = false; AddChargeTestButton.Enabled = true; EditChargeTestButton.Enabled = true; RemoveChargeTestButton.Enabled = true; } else { PowderWeightTextBox.ReadOnly = true; FillRatioTextBox.ReadOnly = true; AddChargeTestButton.Enabled = false; EditChargeTestButton.Enabled = false; RemoveChargeTestButton.Enabled = false; } //----------------------------------------------------------------------------* // Set Column Headers //----------------------------------------------------------------------------* ChargeTestListView.Columns[1].Text += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.Firearm)); ChargeTestListView.Columns[3].Text += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.Velocity)); ChargeTestListView.Columns[5].Text += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.GroupSize)); ChargeTestListView.Columns[6].Text += String.Format(" ({0})", cDataFiles.MetricString(cDataFiles.eDataType.Range)); //----------------------------------------------------------------------------* // Fill in load data //----------------------------------------------------------------------------* FirearmTypeLabel.Text = cFirearm.FirearmTypeString(m_Load.FirearmType); if (m_Load != null) { if (m_Load.Caliber != null) { CaliberLabel.Text = m_Load.Caliber.ToString(); } if (m_Load.Bullet != null) { BulletLabel.Text = m_Load.Bullet.ToString(); } if (m_Load.Powder != null) { PowderLabel.Text = m_Load.Powder.ToString(); } if (m_Load.Primer != null) { PrimerLabel.Text = m_Load.Primer.ToString(); } if (m_Load.Case != null) { CaseLabel.Text = m_Load.Case.ToString(); } } SetStaticToolTips(); SetInputParameters(); PopulateChargeData(); if (!m_fViewOnly) { PowderWeightTextBox.Focus(); } else { ChargeCancelButton.Focus(); } UpdateButtons(); m_fInitialized = true; }