private void AccelerateClick(object sender, EventArgs e) { IAccelerate accelerate = (IAccelerate)objectComboBox.SelectedItem; accelerate.Accelerate(5); panel.GetChildAtPoint(new Point(0, 0)).Text = "Speed: " + accelerate.getSpeed(); }
private void speedUpButton_Click(object sender, EventArgs e) { object toy = selectedList.SelectedItem; IAccelerate accelerate = toy as IAccelerate; accelerate.Accelerate(accelerate.Speed + 1); speedLabel.Text = accelerate.Speed.ToString(); }
private void increaseSpeed_Click(object sender, EventArgs e) { object toy = toyOwned.SelectedItem; IAccelerate accelerate = toy as IAccelerate; accelerate.Accelerate(accelerate.Speed + 1); speedValue.Text = accelerate.Speed.ToString(); }
public void zmienSzybkosc(int change) { foreach (Zabawki zabawka in listaZabawek) { if (zabawka is IAccelerate) { IAccelerate szybkosc = zabawka as IAccelerate; szybkosc.Accelerate(change); } } }
private void toyInstanceCombo_SelectionChangeCommitted(object sender, EventArgs e) { controlsPanel.Controls.Clear(); object toy = toyInstanceCombo.SelectedItem; //to wbrew mojej godności if (toy is IAccelerate) { IAccelerate accelerator = toy as IAccelerate; Label propertyLabel = new Label(); propertyLabel.Text = "przyśpieszenie"; NumericUpDown propertySpinner = new NumericUpDown(); propertySpinner.Value = accelerator.speed; propertySpinner.ValueChanged += new EventHandler(delegate(Object o, EventArgs a) { accelerator.Accelerate(Convert.ToInt32(propertySpinner.Value)); }); controlsPanel.Controls.Add(propertyLabel); controlsPanel.Controls.Add(propertySpinner); } if (toy is IDive) { IDive diver = toy as IDive; Label propertyLabel = new Label(); propertyLabel.Text = "zanurzenie"; NumericUpDown propertySpinner = new NumericUpDown(); propertySpinner.Value = diver.submersion; propertySpinner.ValueChanged += new EventHandler(delegate(Object o, EventArgs a) { diver.Dive(Convert.ToInt32(propertySpinner.Value)); }); controlsPanel.Controls.Add(propertyLabel); controlsPanel.Controls.Add(propertySpinner); } if (toy is IRise) { IRise riser = toy as IRise; NumericUpDown propertySpinner = new NumericUpDown(); Label propertyLabel = new Label(); propertyLabel.Text = "wzniesienie"; propertySpinner.Value = riser.altitude; propertySpinner.ValueChanged += new EventHandler(delegate(Object o, EventArgs a) { riser.Rise(Convert.ToInt32(propertySpinner.Value)); }); controlsPanel.Controls.Add(propertyLabel); controlsPanel.Controls.Add(propertySpinner); } }