Esempio n. 1
0
        private void UpdateTFCost()
        {
            TaskForce tf = olvTF.SelectedObject as TaskForce;

            if (tf == null)
            {
                return;
            }
            txtTFTotalCost.Text = "$" + tf.TotalCost().ToString();
        }
Esempio n. 2
0
 private void olvTFUnits_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Delete)
     {
         TaskForce      tf  = SelectedTaskForce();
         TaskForceEntry tfe = olvTFUnits.SelectedObject as TaskForceEntry;
         tf.Remove(tfe.Unit);
         olvTFUnits.SetObjects(tf);
         e.Handled = true;
     }
 }
Esempio n. 3
0
        private void mnuInfoTF_Click(object sender, EventArgs e)
        {
            TaskForce tf  = SelectedTaskForce();
            var       tts = FilterTeamTypes(tf);
            object    tt  = UseInfoBox.Show("Used by Teams", tts);

            if (tt != null)
            {
                tabControl1.SelectedIndex = 2;
                olvTT.SelectedObject      = tt;
                olvTT.EnsureVisible();
            }
        }
Esempio n. 4
0
        private void olvTF_SelectedIndexChanged(object sender, EventArgs e)
        {
            TaskForce tf = SelectedTaskForce();

            if (tf == null)
            {
                return;
            }
            olvTFUnits.SetObjects(tf);
            olvTFUnits.SelectedIndex = 0;
            cmbTFGroup.SelectedItem  = tf.Group;
            UpdateTFCost();
        }
Esempio n. 5
0
        private void mnuNewTF_Click(object sender, EventArgs e)
        {
            InputBox.InputResult res = InputBox.Show("New Task Force", "Enter name:");

            if (res.ReturnCode == DialogResult.OK)
            {
                string    id = nextID();
                TaskForce tf = new TaskForce(id, res.Text, groupTypes[0]);
                taskForces.Add(tf);
                olvTF.BeginUpdate();
                olvTF.AddObject(tf);
                olvTF.EndUpdate();
                olvTF.SelectedObject = tf;
                olvTF.EnsureVisible();
            }
        }
Esempio n. 6
0
        private void UpdateTFUnit(int mod)
        {
            TechnoType tt = cmbTFUnit.SelectedItem as TechnoType;
            TaskForce  tf = SelectedTaskForce();

            if (tf.Mod(tt, mod) != 0)
            {
                olvTFUnits.SetObjects(tf);
            }
            else
            {
                TaskForceEntry tfe = tf.SingleOrDefault(s => s.Unit == tt);
                olvTFUnits.RefreshObject(tfe);
            }

            UpdateTFCost();
        }
Esempio n. 7
0
        private void olvTFUnits_CellEditFinished(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            TaskForce tf = SelectedTaskForce();

            if (e.SubItemIndex == 0)
            {
                uint           val = (uint)e.NewValue;
                TaskForceEntry tfe = e.RowObject as TaskForceEntry;

                if (val == 0)
                {
                    tf.Remove(tfe.Unit);
                    olvTFUnits.SetObjects(tf);
                }
            }

            UpdateTFCost();
        }
Esempio n. 8
0
        private AITable <TaskForce> LoadTaskForces(IniDictionary ai,
                                                   List <TechnoType> technoTypes, List <AITypeListEntry> groupTypes)
        {
            HashSet <string>  ids          = new HashSet <string>();
            List <TaskForce>  items        = new List <TaskForce>();
            OrderedDictionary aiTaskForces = ai["TaskForces"] as OrderedDictionary;

            foreach (DictionaryEntry entry in aiTaskForces)
            {
                string id = entry.Value as string;

                if (id == "")
                {
                    continue;
                }

                if (ids.Contains(id))
                {
                    logger.Add("Duplicate Task Force [" + id + "] found!");
                    continue;
                }

                if (!ai.ContainsKey(id))
                {
                    logger.Add("Listed Task Force [" + id + "] does not exist!");
                    continue;
                }

                OrderedDictionary section = ai[id];
                TaskForce         tf      = TaskForce.Parse(id, section, unitTypes, groupTypes, logger);
                items.Add(tf);
                ids.Add(id);
            }

            iniIDs = new HashSet <string>();
            iniIDs.UnionWith(ids);
            return(new AITable <TaskForce>("TaskForces", items));
        }
Esempio n. 9
0
        /**
         * Control Delegates.
         **/


        private void mnuDelTF_Click(object sender, EventArgs e)
        {
            TaskForce tf = SelectedTaskForce();

            if (tf.Uses > 0)
            {
                MessageBox.Show("Cannot delete Task Force while it is in use.", "Delete Task Force");
                return;
            }

            DialogResult res = MessageBox.Show("Are you sure you want to delete this Task Force?",
                                               "Delete Task Force", MessageBoxButtons.YesNo);

            if (res == DialogResult.Yes)
            {
                int idx = Math.Min(olvTF.SelectedIndex, olvTF.Items.Count - 1);
                taskForces.Remove(tf);
                olvTF.BeginUpdate();
                olvTF.RemoveObject(tf);
                olvTF.EndUpdate();
                olvTF.SelectedIndex = idx;
            }
        }
Esempio n. 10
0
        private void olvTFUnits_CellEditFinishing(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            if (!e.Cancel && e.SubItemIndex == 1)
            {
                ComboBox       cmb  = e.Control as ComboBox;
                TaskForce      tf   = SelectedTaskForce();
                TaskForceEntry tfe  = e.RowObject as TaskForceEntry;
                TechnoType     unit = cmb.SelectedItem as TechnoType;

                TaskForceEntry exists = tf.SingleOrDefault(s => s.Unit == unit);

                if (exists != null && exists != tfe)
                {
                    tf.Remove(tfe.Unit);
                    exists.Count = exists.Count + tfe.Count;
                    olvTFUnits.SetObjects(tf);
                }
                else
                {
                    tfe.Unit = unit;
                    olvTFUnits.RefreshItem(e.ListViewItem);
                }
            }
        }
Esempio n. 11
0
        private void cmbTFGroup_SelectionChangeCommitted(object sender, EventArgs e)
        {
            TaskForce tf = SelectedTaskForce();

            tf.Group = cmbTFGroup.SelectedItem as AITypeListEntry;
        }