private void DrawGraphic() { float dx = (float)TAPBxCanvas.Width / Xn; float dy = (float)TAPBxCanvas.Height / Yn; int nx0 = Xn / 2; int ny0 = Yn / 2; RedPen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; try { float xAlg = Convert.ToSingle(TATBxAlg.Text); float xLopp = Convert.ToSingle(TATBxLopp.Text); float x1 = xAlg; float y1 = GetY(x1); for (float x2 = xAlg; x2 < xLopp; x2 += 0.01F) { float y2 = GetY(x2); g.DrawLine(CustomPen, (x1 + nx0) * dx, (ny0 - y1) * dy, (x2 + nx0) * dx, (ny0 - y2) * dy); x1 = x2; y1 = y2; } } catch (Exception error) { TATimer2.Stop(); TATimer2.Enabled = false; TABAutoDraw.Text = "Joonista Automaatselt [Sisse]"; TATimer2.Stop(); TABDraw.Enabled = true; //TACBxSuvalisedArvud.Checked = false; MessageBox.Show(caption: "Error!", text: error.Message, buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error); } }
private void TABAutoDraw_Click(object sender, EventArgs e) { TATimer2.Interval = 1; if (TATimer2.Enabled) { TABAutoDraw.Text = "Joonista Automaatselt [Sisse]"; TATimer2.Stop(); TABDraw.Enabled = true; TACBxSuvalisedArvud.Checked = false; //randomNumbers(0, 0); } else { TABAutoDraw.Text = "Joonista Automaatselt [Välja]"; TATimer2.Start(); TABDraw.Enabled = false; TACBxSuvalisedArvud.Checked = true; //randomNumbers(1, 20); } }