private void PNL_Canvas_MouseMove(object sender, MouseEventArgs e) { PNL_Canvas.Focus(); Cursor.Current = Cursors.Cross; if (e.Button == MouseButtons.Left) { switch (CurrentTool) { case Tool.Pen: DrawOnCanvas(MainPen, e, false); break; case Tool.Eraser: DrawOnCanvas(MainPen, e, true); break; case Tool.Select: HandleSelection(e); break; case Tool.Line: DragLine(ref MainPen, e); break; } } else { if (e.Button == MouseButtons.Right) { switch (CurrentTool) { case Tool.Pen: DrawOnCanvas(SecondPen, e, false); break; case Tool.Eraser: DrawOnCanvas(SecondPen, e, true); break; case Tool.Select: DisplayContextMenu(e); break; case Tool.Line: DragLine(ref MainPen, e); break; } } else if (e.Button == MouseButtons.Middle) { DragCanvas(PNL_Drag_Zone.PointToClient(Cursor.Position)); } if (DraggingSelection) { DraggingSelection = false; } } }
private void PNL_Canvas_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { switch (CurrentTool) { case Tool.Pen: UpdateTimeline(); DrawSingleDotOnCanvas(MainPen.Color, e); break; case Tool.Eraser: UpdateTimeline(); DrawSingleDotOnCanvas(Color.Transparent, e); break; case Tool.Select: HandleClickSelection(e); break; case Tool.MagicWand: MagicWand(e); break; case Tool.Bucket: Fill(MainPen.Color, e); break; case Tool.ColorPicker: PickColor(e, true); break; case Tool.Line: StartLine(MainPen.Color, e); break; } } else if (e.Button == MouseButtons.Right) { switch (CurrentTool) { case Tool.Pen: DrawSingleDotOnCanvas(SecondPen.Color, e); break; case Tool.Eraser: DrawSingleDotOnCanvas(Color.Transparent, e); break; case Tool.Bucket: Fill(SecondPen.Color, e); break; case Tool.ColorPicker: PickColor(e, false); break; case Tool.Line: StartLine(SecondPen.Color, e); break; } } if (e.Button == MouseButtons.Middle) { OldDragPoint = PNL_Drag_Zone.PointToClient(Cursor.Position); CurrentDragPoint = OldDragPoint; } }