protected override void OnMouseUp(MouseEventArgs e) { if (moving) { selectedShape = null; moving = false; } base.OnMouseUp(e); }
protected override void OnMouseDown(MouseEventArgs e) { for (var i = Rectangles.Count - 1; i >= 0; i--) { if (Rectangles[i].HitTest(e.Location)) { selectedShape = Rectangles[i]; break; } } if (selectedShape != null && e.Button == MouseButtons.Left) { moving = true; previousPoint = e.Location; } if (selectedShape != null && e.Button == MouseButtons.Right) { colorDialog1.ShowDialog(); selectedShape.FillColor = colorDialog1.Color.ToArgb(); this.Invalidate(); } base.OnMouseDown(e); }