Ejemplo n.º 1
0
        private void btnAddSlot_Click(object sender, EventArgs e)
        {
            if (detachment != null)
            {
                if (cmbBattleRoles.SelectedItem != null)
                {
                    Boolean IsSlotAlreadyAssigned        = false;
                    ModelClasses.BattleRole selectedRole = (ModelClasses.BattleRole)cmbBattleRoles.SelectedItem;
                    ModelClasses.Slot       newSlot      = new ModelClasses.Slot();
                    newSlot.BattleRole   = selectedRole;
                    newSlot.MinimumUnits = 0;
                    newSlot.MaximumUnits = 0;

                    foreach (ModelClasses.Slot slot in detachment.Slots)
                    {
                        if (slot.BattleRole.Name == newSlot.BattleRole.Name)
                        {
                            IsSlotAlreadyAssigned = true;
                            break;
                        }
                    }

                    if (!IsSlotAlreadyAssigned)
                    {
                        detachment.Slots.Add(newSlot);
                        edited = true;
                        RefreshDetachment();
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private void lbSlots_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (detachment != null)
     {
         if (lbSlots.SelectedItem != null)
         {
             selectedSlot = (ModelClasses.Slot)lbSlots.SelectedItem;
             RefreshSlotInfo();
         }
     }
 }
Ejemplo n.º 3
0
        private void cbIncludeTransports_CheckedChanged(object sender, EventArgs e)
        {
            if (detachment != null)
            {
                detachment.DoesContainTransports = cbIncludeTransports.Checked;

                bool alreadyExists = false;

                if (detachment.DoesContainTransports)
                {
                    foreach (ModelClasses.Slot existingslot in detachment.Slots)
                    {
                        if (existingslot.BattleRole != null && existingslot.BattleRole.Name == "Transport")
                        {
                            alreadyExists = true;
                            break;
                        }
                    }

                    if (!alreadyExists)
                    {
                        ModelClasses.Slot transportSlot = new ModelClasses.Slot();
                        transportSlot.BattleRole      = new ModelClasses.BattleRole();
                        transportSlot.BattleRole.Name = "Transport";
                        detachment.Slots.Add(transportSlot);
                    }
                }
                else
                {
                    ModelClasses.Slot foundSlot = null;
                    foreach (ModelClasses.Slot existingslot in detachment.Slots)
                    {
                        if (existingslot.BattleRole != null && existingslot.BattleRole.Name == "Transport")
                        {
                            alreadyExists = true;
                            foundSlot     = existingslot;
                            break;
                        }
                    }

                    if (alreadyExists)
                    {
                        detachment.Slots.Remove(foundSlot);
                    }
                }

                RefreshDetachment();
                edited = true;
            }
        }