//============================================================================* // AddFirearm() //============================================================================* public bool AddFirearm(cFirearm Firearm, bool fCountOnly = false) { m_nImportCount++; foreach (cFirearm CheckFirearm in this) { if (CheckFirearm.CompareTo(Firearm) == 0) { m_nUpdateCount += CheckFirearm.Append(Firearm, fCountOnly); return(false); } } if (!fCountOnly) { Add(Firearm); } m_nNewCount++; return(true); }
//============================================================================* // PopulateFirearmCombo() //============================================================================* public static void PopulateFirearmCombo(ComboBox FirearmCombo, cDataFiles DataFiles, cFirearm Firearm = null, cCaliber Caliber = null, cFirearm.eFireArmType eFirearmType = cFirearm.eFireArmType.None, bool fAddFactory = false) { //----------------------------------------------------------------------------* // Validate Input //----------------------------------------------------------------------------* if (DataFiles == null || FirearmCombo == null) { return; } //----------------------------------------------------------------------------* // Populate Combo //----------------------------------------------------------------------------* FirearmCombo.Items.Clear(); if (fAddFactory) { FirearmCombo.Items.Add("Factory"); } cCaliber.CurrentFirearmType = eFirearmType; cFirearm SelectedFirearm = null; foreach (cFirearm CheckFirearm in DataFiles.FirearmList) { if (Caliber == null || CheckFirearm.HasCaliber(Caliber)) { if ((eFirearmType == cFirearm.eFireArmType.None || CheckFirearm.FirearmType == eFirearmType)) { FirearmCombo.Items.Add(CheckFirearm); if (Firearm != null && CheckFirearm.CompareTo(Firearm) == 0) { SelectedFirearm = CheckFirearm; } } } } //----------------------------------------------------------------------------* // Select a firearm in the combo //----------------------------------------------------------------------------* if (SelectedFirearm != null) { FirearmCombo.SelectedItem = SelectedFirearm; } else { if (FirearmCombo.Items.Count > 0) { FirearmCombo.SelectedIndex = 0; } else { FirearmCombo.SelectedIndex = -1; } } }