public Form1() { InitializeComponent(); g = pictureBox1.CreateGraphics(); v = (float)Speed_trackBar.Value * 2 / 1000; l = l_trackBar.Value * 10; p.Width = Whide_trackBar.Value; x = pictureBox1.Width / 2; y = pictureBox1.Height / 2; X_textBox.Text = x.ToString(); Y_textBox.Text = y.ToString(); Step_timer.Interval = 1; Step_timer.Start(); Start_button.Enabled = false; }
private void X_textBox_TextChanged(object sender, EventArgs e) { if (int.TryParse(X_textBox.Text, out x)) { if ((x >= 0) && (x <= pictureBox1.Width)) { g.Clear(System.Drawing.Color.White); g.DrawLine(p, x, y, l * MathF.Cos(angal) + x, l * MathF.Sin(angal) + y); } else { Step_timer.Stop(); MessageBox.Show("Значения должны быть в диапазоне от 0 до " + pictureBox1.Width); Step_timer.Start(); } } }
private void Pause_button_Click(object sender, EventArgs e) { Step_timer.Stop(); Start_button.Enabled = true; Pause_button.Enabled = false; }