diff --git a/Warmly_Lokomotive_Base/Warmly_Lokomotive_Base/FormLokomotive.Designer.cs b/Warmly_Lokomotive_Base/Warmly_Lokomotive_Base/FormLokomotive.Designer.cs index af5767f..99fc309 100644 --- a/Warmly_Lokomotive_Base/Warmly_Lokomotive_Base/FormLokomotive.Designer.cs +++ b/Warmly_Lokomotive_Base/Warmly_Lokomotive_Base/FormLokomotive.Designer.cs @@ -105,7 +105,7 @@ this.buttonRight.Size = new System.Drawing.Size(30, 30); this.buttonRight.TabIndex = 3; this.buttonRight.UseVisualStyleBackColor = true; - this.buttonRight.Click += new System.EventHandler(this.buttonRight_Click); + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_click); // // buttonLeft // @@ -117,7 +117,7 @@ this.buttonLeft.Size = new System.Drawing.Size(30, 30); this.buttonLeft.TabIndex = 4; this.buttonLeft.UseVisualStyleBackColor = true; - this.buttonLeft.Click += new System.EventHandler(this.buttonLeft_Click); + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_click); // // buttonDown // @@ -129,7 +129,7 @@ this.buttonDown.Size = new System.Drawing.Size(30, 30); this.buttonDown.TabIndex = 5; this.buttonDown.UseVisualStyleBackColor = true; - this.buttonDown.Click += new System.EventHandler(this.buttonDown_Click); + this.buttonDown.Click += new System.EventHandler(this.ButtonMove_click); // // buttonUp // @@ -141,7 +141,7 @@ this.buttonUp.Size = new System.Drawing.Size(30, 30); this.buttonUp.TabIndex = 6; this.buttonUp.UseVisualStyleBackColor = true; - this.buttonUp.Click += new System.EventHandler(this.buttonUp_Click); + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_click); // // FormLokomotive // @@ -167,6 +167,14 @@ #endregion + + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + + private StatusStrip statusStrip1; private ToolStripStatusLabel toolStripStatusLabelSpeed; private ToolStripStatusLabel toolStripStatusLabelWeight; diff --git a/Warmly_Lokomotive_Base/Warmly_Lokomotive_Base/FormLokomotive.cs b/Warmly_Lokomotive_Base/Warmly_Lokomotive_Base/FormLokomotive.cs index c56aaa3..e92a8c6 100644 --- a/Warmly_Lokomotive_Base/Warmly_Lokomotive_Base/FormLokomotive.cs +++ b/Warmly_Lokomotive_Base/Warmly_Lokomotive_Base/FormLokomotive.cs @@ -40,25 +40,24 @@ namespace Warmly_Lokomotive_Base private void pictureBox1_Click(object sender, EventArgs e) { } - private void buttonRight_Click(object sender, EventArgs e) + private void ButtonMove_click(object sender, EventArgs e) { - _locomotive?.MoveTransport(Direction.Right); - Draw(); - } - private void buttonLeft_Click(object sender, EventArgs e) - { - _locomotive?.MoveTransport(Direction.Left); - Draw(); - } - - private void buttonDown_Click(object sender, EventArgs e) - { - _locomotive?.MoveTransport(Direction.Down); - Draw(); - } - private void buttonUp_Click(object sender, EventArgs e) - { - _locomotive?.MoveTransport(Direction.Up); + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _locomotive?.MoveTransport(Direction.Up); + break; + case "buttonDown": + _locomotive?.MoveTransport(Direction.Down); + break; + case "buttonLeft": + _locomotive?.MoveTransport(Direction.Left); + break; + case "buttonRight": + _locomotive?.MoveTransport(Direction.Right); + break; + } Draw(); }