Esempio n. 1
0
        private void SelectNewArmyEditorDivision(DivisionControl newSelection)
        {
            if (selectedDivisionControl != null)
            {
                selectedDivisionControl.BackColor = DefaultDivisionBgColour;
            }

            if (newSelection != null)
            {
                selectedDivisionControl = newSelection;

                selectedDivisionControl.BackColor = SelectedDivisionBgColour;

                CDivision division = selectedDivisionControl.DisplayedDivision;

                DivisionNameText.Text       = division.Name;
                divisionSelectedUnitType    = division.UnitType;
                DivisionUnitText.Text       = divisionSelectedUnitType.Name;
                DivisionSizeNumeric.Value   = division.StartingSize;
                DivisionSizeNumeric.Value   = division.CurrentSize;
                DivisionMoraleNumeric.Value = division.Morale;

                RefreshDivisionTraitDescriptionList();
            }
            else
            {
                throw new ArgumentNullException("newSelection", "Tried to select a null carmy division control");
            }
        }
Esempio n. 2
0
        private void AddNewArmyRow(CDivision division)
        {
            AddNewArmyRow();
            int             lastRow = ArmyTable.RowCount - 1;
            DivisionControl control = (DivisionControl)(ArmyTable.Controls[ARMY_EDIT_DIVISION_CONTROL_PREFIX + lastRow.ToString()]);

            control.DisplayedDivision = division;
        }
Esempio n. 3
0
        private void RemoveLastArmyRow()
        {
            int lastRow = ArmyTable.RowCount - 1;

            if (lastRow >= 0)
            {
                DivisionControl lastDivisionControl = (DivisionControl)(ArmyTable.Controls[ARMY_EDIT_DIVISION_CONTROL_PREFIX + lastRow.ToString()]);
                if (lastDivisionControl != null)
                {
                    if (lastDivisionControl == selectedDivisionControl)
                    {
                        selectedDivisionControl = null;
                    }
                    armyCreatorWorkingCopy.Divisions.Remove(lastDivisionControl.DisplayedDivision);
                    ArmyTable.Controls.Remove(lastDivisionControl);
                }
                ArmyTable.RowCount--;
            }
        }
Esempio n. 4
0
        private void AddNewArmyRow()
        {
            int newRow = ArmyTable.RowCount;

            if (newRow < MAX_ARMY_DIVISIONS)
            {
                DivisionControl newDivision = new DivisionControl()
                {
                    Name = ARMY_EDIT_DIVISION_CONTROL_PREFIX + newRow.ToString(),
                };
                newDivision.MouseClick += ArmyEditorDivision_Click;
                foreach (Control ctrl in newDivision.Controls)
                {
                    ctrl.MouseClick += ArmyEditorDivision_Click;
                }
                ArmyTable.Controls.Add(newDivision, 0, newRow);
                ArmyTable.RowCount++;
            }
        }
Esempio n. 5
0
        private void ArmyRemoveDivisionButton_Click(object sender, EventArgs e)
        {
            int foundRow = -1;

            for (int row = 0; row < ArmyTable.RowCount; row++)
            {
                if (foundRow >= 0)
                {
                    ArmyTable.SetRow(ArmyTable.Controls[ARMY_EDIT_DIVISION_CONTROL_PREFIX + row.ToString()], row - 1);
                    ArmyTable.Controls[ARMY_EDIT_DIVISION_CONTROL_PREFIX + row.ToString()].Name = ARMY_EDIT_DIVISION_CONTROL_PREFIX + (row - 1).ToString();
                }

                if (ArmyTable.Controls[ARMY_EDIT_DIVISION_CONTROL_PREFIX + row.ToString()] == selectedDivisionControl)
                {
                    foundRow = row;
                    ArmyTable.Controls.RemoveByKey(ARMY_EDIT_DIVISION_CONTROL_PREFIX + row.ToString());
                    armyCreatorWorkingCopy.Divisions.Remove(selectedDivisionControl.DisplayedDivision);
                }
            }

            if (foundRow >= 0)
            {
                ArmyTable.RowCount--;
                if (foundRow > 0)
                {
                    int newSelectRow = foundRow;
                    if (newSelectRow > ArmyTable.RowCount - 1)
                    {
                        newSelectRow = ArmyTable.RowCount - 1;
                    }

                    DivisionControl replacementControl =
                        (DivisionControl)(ArmyTable.Controls[ARMY_EDIT_DIVISION_CONTROL_PREFIX + newSelectRow.ToString()]);
                    SelectNewArmyEditorDivision(replacementControl);
                }
                else
                {
                    selectedDivisionControl = null;
                }
            }
        }