protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); var point = ColorGridRendering.GetGridPointFromPosition (Style, e.Location, ClientSize); if (point.X != -1 && ClickMode == ClickMode.ColorSet && NewColor != Color.Empty) { FaceColors[point.X, point.Y] = NewColor; OnCellMouseClicked(point, e.Button); } else if (ClickMode == ClickMode.Rotation) { if (e.Button != MouseButtons.Left && e.Button != MouseButtons.Right) { return; } var r = (e.Button == MouseButtons.Left) ? Rotation.Ccw : Rotation.Cw; rubiksCube.MakeMove(Face, r); InvalidateOtherCubeControls(); } Invalidate(); }
protected override void OnPaint(PaintEventArgs e) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; e.Graphics.Clear(GetBackColor()); ColorGridRendering.Draw(Style, e.Graphics, ClientSize, Enabled); if (ClickMode == ClickMode.ColorSet && hoveredRect != Rectangle.Empty) { var path = RoundedRectangleF.Create(hoveredRect, RoundedRadius); Pen pen = new Pen(Color.White, 3f); pen.Alignment = PenAlignment.Center; e.Graphics.DrawPath(pen, path); pen.Dispose(); } else if (ClickMode == ClickMode.Rotation) { var rect = ColorGridRendering.GetMasterRectangle(Style, Size); if (rect.Contains(PointToClient(Cursor.Position))) { ControlPaint.DrawBorder3D(e.Graphics, Rectangle.Truncate(rect), Border3DStyle.Flat); } } }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); var rect = ColorGridRendering.GetCellRectFromPosition (Style, e.Location, ClientSize); if (rect != hoveredRect) { hoveredRect = rect; OnHoverCellChanged(hoveredRect); if (ClickMode != ClickMode.None) { Invalidate(); } } }