using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; namespace VstupniTest { public struct Line { public Point a, b; public Color color; public int width; public Line(Point a, Point b, int width = 1, Color? color = null) { this.a = a; this.b = b; this.width = width; this.color = color == null ? Color.Black : (Color)color; } } public partial class Window : Form { private Control control; private List lines; public Window(Control control) { this.control = control; this.lines = new List(); InitializeComponent(); } public void AddLine(Line line) { this.lines.Add(line); } public void SetDrawCount(int count) { this.labelDrawCount.Text = count.ToString(); } public void SetMoveCount(int count) { this.labelMoveCount.Text = count.ToString(); } public void Reset() { this.lines.Clear(); this.pictureBox1.Refresh(); } private void pictureBox1_Paint(object sender, PaintEventArgs paintEventArgs) { Graphics graphics = paintEventArgs.Graphics; graphics.SmoothingMode = SmoothingMode.HighQuality; Size center = new Size(this.pictureBox1.Width / 2, this.pictureBox1.Height / 2); graphics.DrawLine(Pens.LightGray, new Point(center.Width, 0), new Point(center.Width, this.pictureBox1.Height)); graphics.DrawLine(Pens.LightGray, new Point(0, center.Height), new Point(this.pictureBox1.Width, center.Height)); foreach (Line line in this.lines) { graphics.DrawLine(new Pen(line.color, line.width), line.a + center, line.b + center); } } private void pictureBox1_Resize(object sender, EventArgs e) { this.pictureBox1.Refresh(); } private void button1_Click(object sender, EventArgs e) { this.control.Next(); } } }