private void button_draw_Click(object sender, EventArgs e) { if (!get_circle2D()) { return; } DrawCircle drawCircle2D = new DrawCircle(bitmap); if (comboBox_algo.Text.Equals("DDA")) { drawCircle2D.DDA(circle, Color.Blue); } else if (comboBox_algo.Text.Equals("Bresenham")) { drawCircle2D.Bresenham(circle, Color.Blue); } else if (comboBox_algo.Text.Equals("MidPoint")) { drawCircle2D.MidPoint(circle, Color.Blue); } // refresh picture box every draw pictureBox_draw.Refresh(); }
private void button_randDraw_click(object sender, EventArgs e) { if (!get_randNum()) { return; } // clear all drawings before random clearAll(); // if no random list circle, or old one is not enough, create new one // otherwise, use the already have random list circle if (circleS.Count < this.numRand) { randCircleS(numRand); } // StopWatch object for calculating execution time of the algorithm // StartNew and Stop for make sure stopwatch is not redundant object Stopwatch stopwatch = Stopwatch.StartNew(); stopwatch.Stop(); DrawCircle drawCircle2D = new DrawCircle(bitmap); if (comboBox_algo.Text.Equals("DDA")) { stopwatch.Restart(); for (int i = 0; i < numRand; ++i) { drawCircle2D.DDA(circleS[i], Color.Blue); } stopwatch.Stop(); } else if (comboBox_algo.Text.Equals("Bresenham")) { stopwatch.Restart(); for (int i = 0; i < numRand; ++i) { drawCircle2D.Bresenham(circleS[i], Color.Blue); } stopwatch.Stop(); } else if (comboBox_algo.Text.Equals("MidPoint")) { stopwatch.Restart(); for (int i = 0; i < numRand; ++i) { drawCircle2D.MidPoint(circleS[i], Color.Blue); } stopwatch.Stop(); } // set running time to text box textBox_timeRand.Text = stopwatch.ElapsedMilliseconds.ToString() + " ms"; // refresh picture box every draw pictureBox_draw.Refresh(); }