Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        public void AddSquadron(Squadron squadron)
        {
            if (comboSquadrons.Items.Contains(squadron.Name)) //Ignore duplicate squadron names
            {
                return;
            }

            squadron.ItemIndex = comboSquadrons.Items.Add(squadron.Name);
        }
Exemplo n.º 3
0
        public static Squadron GetByItemIndex(int itemIndex)
        {
            Squadron squadron = null;

            foreach (Squadron squad in Squadrons)
            {
                if (squad.ItemIndex == itemIndex)
                {
                    squadron = squad;
                    break;
                }
            }

            return(squadron);
        }
Exemplo n.º 4
0
        public static Squadron GetByName(string name)
        {
            Squadron squadron = null;

            foreach (Squadron squad in Squadrons)
            {
                if (squad.Name == name)
                {
                    squadron = squad;
                    break;
                }
            }

            return(squadron);
        }
Exemplo n.º 5
0
 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();
 }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
 public void RemoveSquadron(Squadron squadron)
 {
     squadron.SOBGroups.Remove(this);
     Squadrons.Remove(squadron);
 }
Exemplo n.º 9
0
 public void AddSquadron(Squadron squadron)
 {
     squadron.SOBGroups.Add(this);
     Squadrons.Add(squadron);
 }