private void buttonAddSquadron_Click(object sender, EventArgs e) { if (SOBGroup.CurrentSelected == null) { return; } if (comboSquadrons.SelectedItem == null) { return; } Squadron selectedSquadron = Squadron.GetByName(comboSquadrons.SelectedItem.ToString()); if (selectedSquadron == null) { return; } if (SOBGroup.CurrentSelected.Squadrons.Contains(selectedSquadron)) { return; } SOBGroup.CurrentSelected.AddSquadron(selectedSquadron); listSOBGroups_SelectedIndexChanged(this, EventArgs.Empty); listSquadrons.SelectedIndex = listSquadrons.Items.Count - 1; }
public void AddSquadron(Squadron squadron) { if (comboSquadrons.Items.Contains(squadron.Name)) //Ignore duplicate squadron names { return; } squadron.ItemIndex = comboSquadrons.Items.Add(squadron.Name); }
public static Squadron GetByItemIndex(int itemIndex) { Squadron squadron = null; foreach (Squadron squad in Squadrons) { if (squad.ItemIndex == itemIndex) { squadron = squad; break; } } return(squadron); }
public static Squadron GetByName(string name) { Squadron squadron = null; foreach (Squadron squad in Squadrons) { if (squad.Name == name) { squadron = squad; break; } } return(squadron); }
public void RemoveSquadron(Squadron squadron) { comboSquadrons.Items.Remove(squadron.Name); foreach (Squadron squad in Squadron.Squadrons) { if (squad.ItemIndex > squadron.ItemIndex) { squad.ItemIndex--; } } comboSquadrons.SelectedItem = null; listSquadrons.Items.Remove(squadron.Name); listSquadrons.ClearSelected(); listSquadrons.Refresh(); }
public static void AddToSOBGroup(string squadronName, string sobGroupName) { Squadron squadron = Squadron.GetByName(squadronName); SOBGroup sobGroup = SOBGroup.GetByName(sobGroupName); if (squadron == null) { new Problem(ProblemTypes.WARNING, "Squadron \"" + squadronName + "\" not found. Skipping adding to SOB group \"" + sobGroupName + "\"."); return; } if (sobGroup == null) { new Problem(ProblemTypes.WARNING, "SOB group \"" + sobGroupName + "\" not found. Skipping adding \"" + squadronName + "\" to group."); return; } sobGroup.AddSquadron(squadron); }
private void listSquadrons_KeyUp(object sender, KeyEventArgs e) { if (SOBGroup.CurrentSelected == null) { return; } Squadron selectedSquadron = Squadron.GetByName(listSquadrons.SelectedItem.ToString()); if (selectedSquadron == null) { return; } SOBGroup.CurrentSelected.RemoveSquadron(selectedSquadron); listSquadrons.Items.Remove(selectedSquadron.Name); listSquadrons.ClearSelected(); listSquadrons.Refresh(); }
public void RemoveSquadron(Squadron squadron) { squadron.SOBGroups.Remove(this); Squadrons.Remove(squadron); }
public void AddSquadron(Squadron squadron) { squadron.SOBGroups.Add(this); Squadrons.Add(squadron); }