private void btnAppendTrening_Click(object sender, EventArgs e) { SportsmanCommand item = (SportsmanCommand)lbCommands.SelectedItem; lbTrening.Items.Add(item); lbTrening.SelectedIndex = lbTrening.Items.Count - 1; AdjustButtons(); }
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(); }
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(); }
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); }
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(); }
public string Execute(SportsmanCommand command) { return(name + " : " + command.execute(this)); }
public SportsmanMultiply(string Name, uint Count, SportsmanCommand Cmd) { this.Name = Name; this.Cmd = Cmd; }
public string execute(SportsmanCommand cmd) { return(Name + ": " + cmd.execute(this)); }