Hi, I've been thinking for a long time about how to create a project in C# in winforms, where I select 2 points with the mouse and create a line between them that will have the whole RGB spectrum.
public partial class Form1 : Form { class Line { public Point Start { get; set; } public Point End { get; set; } } public Form1() { var pb = new PictureBox { Parent = this, Dock = DockStyle.Fill }; Line line = null; pb.MouseMove += (s, e) => { if (e.Button == MouseButtons.Left) { line.End = e.Location; pb.Invalidate(); } }; pb.MouseDown += (s, e) => { if (e.Button == MouseButtons.Left) line = new Line { Start = e.Location, End = e.Location }; }; var lines = new List<Line>(); pb.MouseUp += (s, e) => { if (e.Button == MouseButtons.Left) lines.Add(line); }; pb.Paint += (s, e) => { if (line != null) e.Graphics.DrawLine(Pens.Red, line.Start, line.End); foreach (var l in lines) e.Graphics.DrawLine(Pens.Silver, l.Start, l.End); }; } }
line
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)