/// <summary> /// Sets the current paint operation of this InternalPictureBox to be of the given type /// </summary> /// <param name="newPaintTool"></param> public void SetPaintOperation(IPaintTool newPaintTool) { if (_currentPaintTool != null) { _owningPanel.FireOperationStatusEvent(_currentPaintTool, ""); _currentPaintTool.Destroy(); } _currentPaintTool = newPaintTool; if (Image != null) { _currentPaintTool.Initialize(this); if (!_mouseOverImage) { _currentPaintTool.MouseLeave(new EventArgs()); } Cursor = _currentPaintTool.ToolCursor; } var operation = _currentPaintTool as ICompositingPaintTool; if (operation != null) { operation.CompositingMode = _owningPanel._defaultCompositingMode; } if (_currentPaintTool is IFillModePaintTool) { (_currentPaintTool as IFillModePaintTool).FillMode = _owningPanel._defaultFillMode; } }
/// <summary> /// Register the specified tool to the scene view update. /// </summary> /// <param name="tool"></param> private void RegisterTool(IPaintTool tool) { m_activeTool = tool; UnityEditor.Tools.current = Tool.None; SceneView.onSceneGUIDelegate += m_activeTool.OnSceneGUI; }
private void ApplyMovedControl() { _paintTool = null; if (_movedControl != null) { _canvas.ApplyPictureObj(_movedControl.UniqueID); } }
/// <summary> /// Unregister the active tool from the scene view update. /// </summary> private void UnregisterTool() { if (m_activeTool != null) { UnityEditor.Tools.current = Tool.Move; SceneView.onSceneGUIDelegate -= m_activeTool.OnSceneGUI; m_activeTool = null; } }
private void OnMouseDown(object sender, MouseEventArgs e) { PictureBoxObj picObj = sender as PictureBoxObj; if (e.Button == MouseButtons.Right || picObj != _movedControl) { if (_movedControl != null) { SendApplyPictureBox(_movedControl.UniqueID); _movedControl.Dispose(); _movedControl = null; } } else { Point canvasPos = GetCanvasPoint(sender as Control, e.X, e.Y); _paintTool = new PMoveTool(_movedControl, canvasPos); return; } if (_toolType == SelectedTool.None) { return; } if (_toolType == SelectedTool.Brush) { _paintTool = new PBrushTool(sender as PictureBoxObj, _toolSize, _toolColor); } else { Point canvasPos = GetCanvasPoint(sender as Control, e.X, e.Y); _movedControl = CreateNewPictureBox(null, canvasPos); if (_toolType == SelectedTool.Line) { _paintTool = new PDrawLine(_movedControl, canvasPos, _toolSize, _toolColor); } else if (_toolType == SelectedTool.Rect) { _paintTool = new PDrawRect(_movedControl, canvasPos, _toolSize, _toolColor); } else if (_toolType == SelectedTool.Ellipse) { _paintTool = new PDrawEllipse(_movedControl, canvasPos, _toolSize, _toolColor); } else if (_toolType == SelectedTool.SelectorRect) { _paintTool = new PSelectorRect(_movedControl, canvasPos, _canvas.BackPicture, false); } else if (_toolType == SelectedTool.SelectorRect) { _paintTool = new PSelectorRect(_movedControl, canvasPos, _canvas.BackPicture, true); } } }
private void OnMouseUp(object sender, MouseEventArgs e) { if (_paintTool != null) { Point canvasPos = GetCanvasPoint(sender as Control, e.X, e.Y); DrawObject drObj = _paintTool.Draw(canvasPos.X, canvasPos.Y); if (drObj is SelectorObject) { SelectorObject selector = drObj as SelectorObject; selector.NeedCopy = true; } SendDrawObject(drObj); _paintTool = null; } }
public void Draw(IPixelSet pixelSet, IDrawingArea drawingArea) { var cut = new CuttingArguments { MinX = Math.Min(x0, x1), MinY = Math.Min(y0, y1), MaxX = Math.Max(x0, x1), MaxY = Math.Max(y0, y1), }; IPaintTool line1 = Line2Tool.Build(); line1.OnMouseClick(cut.MinX, cut.MinY); line1.OnMouseClicked(cut.MinX, cut.MaxY); line1.Draw(pixelSet, drawingArea); IPaintTool line2 = Line2Tool.Build(); line2.OnMouseClick(cut.MinX, cut.MaxY); line2.OnMouseClicked(cut.MaxX, cut.MaxY); line2.Draw(pixelSet, drawingArea); IPaintTool line3 = Line2Tool.Build(); line3.OnMouseClick(cut.MaxX, cut.MaxY); line3.OnMouseClicked(cut.MaxX, cut.MinY); line3.Draw(pixelSet, drawingArea); IPaintTool line4 = Line2Tool.Build(); line4.OnMouseClick(cut.MaxX, cut.MinY); line4.OnMouseClicked(cut.MinX, cut.MinY); line4.Draw(pixelSet, drawingArea); foreach (IPaintTool paintTool in drawingArea) { paintTool.Cutting(cut); } }
public void Add(IPaintTool paintTool) { paintTools.Add(paintTool); }
protected AbstractPaintToolDecorator(IPaintTool paintTool) { this.PaintTool = paintTool; }
/// <summary> /// Fires the OperationStatusChanged event with the given parameters /// </summary> /// <param name="tool">The operation that fired the event</param> /// <param name="status">The status for the event</param> public void FireOperationStatusEvent(IPaintTool tool, string status) { OperationStatusChanged?.Invoke(this, new OperationStatusEventArgs(tool, status)); }
/// <summary> /// Creates a new instance of the OperationStatusChange event /// </summary> /// <param name="tool">The operation that fired the status change</param> /// <param name="status">The operation status</param> public OperationStatusEventArgs(IPaintTool tool, string status) { Tool = tool; Status = status; }
public UpDownPaintToolDecorator(IPaintTool paintTool) : base(paintTool) { }