public static SOBGroup GetByName(string name) { SOBGroup SOBGroup = null; foreach (SOBGroup group in SOBGroups) { if (group.Name == name) { SOBGroup = group; break; } } return(SOBGroup); }
public static SOBGroup GetByItemIndex(int itemIndex) { SOBGroup SOBGroup = null; foreach (SOBGroup group in SOBGroups) { if (group.ItemIndex == itemIndex) { SOBGroup = group; break; } } return(SOBGroup); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { SOBGroup type = SOBGroup.GetByName((string)value); if (type != null) { return(type); } else { return(null); } } return(base.ConvertFrom(context, culture, value)); }
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); }
public void RemoveSOBGroup(SOBGroup group) { ignoreListSOBGroups_SelectedIndexChanged = true; listSOBGroups.Items.RemoveAt(group.ItemIndex); foreach (SOBGroup sobGroup in SOBGroup.SOBGroups) { if (sobGroup.ItemIndex > group.ItemIndex) { sobGroup.ItemIndex--; } } listSOBGroups.ClearSelected(); ignoreListSOBGroups_SelectedIndexChanged = false; SOBGroup.CurrentSelected = null; listSOBGroups_SelectedIndexChanged(this, EventArgs.Empty); }
private void listSOBGroups_SelectedIndexChanged(object sender, EventArgs e) { if (ignoreListSOBGroups_SelectedIndexChanged) { return; } if (listSOBGroups.SelectedItem == null) { buttonRemoveSOBGroup.Enabled = false; buttonAddSquadron.Enabled = false; buttonRemoveSquadron.Enabled = false; comboSquadrons.Enabled = false; comboSquadrons.SelectedItem = null; boxSOBGroupName.Text = string.Empty; boxSOBGroupName.Enabled = false; listSquadrons.Enabled = false; listSquadrons.Items.Clear(); return; } SOBGroup.CurrentSelected = SOBGroup.GetByItemIndex(listSOBGroups.SelectedIndex); boxSOBGroupName.Text = SOBGroup.CurrentSelected.Name; listSquadrons.Items.Clear(); foreach (Squadron squadron in SOBGroup.CurrentSelected.Squadrons) { squadron.ItemIndex = listSquadrons.Items.Add(squadron.Name); } buttonRemoveSOBGroup.Enabled = true; buttonAddSquadron.Enabled = true; buttonRemoveSquadron.Enabled = false; boxSOBGroupName.Enabled = true; comboSquadrons.Enabled = true; listSquadrons.Enabled = true; }
private void buttonAddSOBGroup_Click(object sender, EventArgs e) { SOBGroup newGroup = new SOBGroup("SobGroup_" + (SOBGroup.SOBGroups.Count + 1)); listSOBGroups.SelectedIndex = newGroup.ItemIndex; }
//-------------------- SOB GROUPS -----------------------// public void AddSOBGroup(SOBGroup group) { group.ItemIndex = listSOBGroups.Items.Add(group.Name); }