Exemplo n.º 1
0
        private void olvTFUnits_SelectedIndexChanged(object sender, EventArgs e)
        {
            TaskForceEntry tfe = olvTFUnits.SelectedObject as TaskForceEntry;

            if (tfe != null)
            {
                cmbTFUnit.SelectedItem = tfe.Unit;
            }
        }
Exemplo 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;
     }
 }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
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();
        }
Exemplo n.º 5
0
        private void olvTFUnits_CellEditStarting(object sender, BrightIdeasSoftware.CellEditEventArgs e)
        {
            if (e.SubItemIndex == 1)
            {
                TaskForceEntry tfe = e.RowObject as TaskForceEntry;
                int            idx = unitTypes.TakeWhile(s => s != tfe.Unit).Count();

                // Unit selector
                ComboBox cmb = new ComboBox();
                cmb.FlatStyle     = FlatStyle.Flat;
                cmb.DropDownStyle = ComboBoxStyle.DropDownList;
                foreach (TechnoType entry in unitTypes)
                {
                    cmb.Items.Add(entry);
                }
                cmb.Bounds        = e.CellBounds;
                cmb.SelectedIndex = idx;
                e.Control         = cmb;
            }
        }
Exemplo n.º 6
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);
                }
            }
        }
Exemplo n.º 7
0
 public TaskForceEntry(TaskForceEntry other)
 {
     this.unit  = other.unit;
     this.count = other.count;
 }