Beispiel #1
0
        private void btnAppendTrening_Click(object sender, EventArgs e)
        {
            SportsmanCommand item = (SportsmanCommand)lbCommands.SelectedItem;

            lbTrening.Items.Add(item);
            lbTrening.SelectedIndex = lbTrening.Items.Count - 1;
            AdjustButtons();
        }
Beispiel #2
0
        private void BtnDropTreningItem_Click(object sender, EventArgs e)
        {
            int index             = lbTrening.SelectedIndex;
            SportsmanCommand item = (SportsmanCommand)lbTrening.SelectedItem;

            lbTrening.Items.Remove(item);
            lbTrening.SelectedIndex = Math.Min(lbTrening.Items.Count - 1, index);
            AdjustButtons();
        }
Beispiel #3
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string           SportsmenName = txtSportsmenName.Text;
            SportsmanCommand item          = (SportsmanCommand)lbCommands.SelectedItem;
            Sportsman        sportsman     = new Sportsman(SportsmenName);
            string           result        = sportsman.Execute(item);

            txtLog.AppendText(result + Environment.NewLine);
            AdjustButtons();
        }
Beispiel #4
0
        private void AdjustButtons()
        {
            string           TreningName            = txtTreningName.Text.Trim();
            SportsmanCommand sportsmanCommand       = (SportsmanCommand)lbCommands.SelectedItem;
            bool             TreningNameNotEmpty    = (TreningName.Length > 0);
            bool             TreningListNotEmpty    = (lbTrening.Items.Count > 0);
            bool             TreningNameNotUsed     = (lbCommands.Items.IndexOf(TreningName) < 0);
            bool             SportsmanNameNotEmpty  = (txtSportsmenName.Text.Trim().Length > 0);
            bool             ComplexCommandSelected = sportsmanCommand is SportsmanCommandComplex;

            btnAppendCommand.Enabled     = (TreningNameNotEmpty && TreningListNotEmpty && TreningNameNotUsed);
            btnExecute.Enabled           = (SportsmanNameNotEmpty);
            BtnDropTreningItem.Enabled   = (TreningListNotEmpty);
            btnDeleteCommandItem.Enabled = (ComplexCommandSelected);
        }
Beispiel #5
0
        private void BtnAddTrening_Click(object sender, EventArgs e)
        {
            int count = LbTrening.Items.Count;

            SportsmanCommand[] list = new SportsmanCommand[count];
            for (int i = 0; i < count; ++i)
            {
                list[i] = LbTrening.Items[i] as SportsmanCommand;
            }
            SportsmanCommand cmd = new SportsmanTrening(GetTreningName(), list);

            LbCommands.Items.Add(cmd);
            LbCommands.SelectedItem = cmd;
            LbTrening.Items.Clear();
            EdTrening.SelectAll();
            LbCommands.Focus();
            SomeChanged();
        }
Beispiel #6
0
 public string Execute(SportsmanCommand command)
 {
     return(name + " : " + command.execute(this));
 }
Beispiel #7
0
 public SportsmanMultiply(string Name, uint Count, SportsmanCommand Cmd)
 {
     this.Name = Name;
     this.Cmd  = Cmd;
 }
Beispiel #8
0
 public string execute(SportsmanCommand cmd)
 {
     return(Name + ": " + cmd.execute(this));
 }