private void Button_Move_Tick(object sender, EventArgs e) { if (Button.Left <= 19) { if (Button.Left != 0) { Button.Left = Button.Left - 1; ON.Width = Button.Left; Off.Width = 50; } } else { if (Button.Left != 38) { Button.Left = Button.Left + 1; ON.Width = Button.Left; } } if (Button.Left == 0 | Button.Left == 38) { Button_Move.Stop(); if (Button.Left == 0) { Checked = false; this.OnClick(null); } if (Button.Left == 38) { Checked = true; this.OnClick(null); } } }
private void Button_MouseUp(object sender, MouseEventArgs e) { Button_On.Stop(); Button_Move.Start(); }