Пример #1
0
            /// <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;
                }
            }
Пример #2
0
        /// <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;
        }
Пример #3
0
 private void ApplyMovedControl()
 {
     _paintTool = null;
     if (_movedControl != null)
     {
         _canvas.ApplyPictureObj(_movedControl.UniqueID);
     }
 }
Пример #4
0
        /// <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;
            }
        }
Пример #5
0
        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);
                }
            }
        }
Пример #6
0
        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;
            }
        }
Пример #7
0
        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);
            }
        }
Пример #8
0
 public void Add(IPaintTool paintTool)
 {
     paintTools.Add(paintTool);
 }
Пример #9
0
 protected AbstractPaintToolDecorator(IPaintTool paintTool)
 {
     this.PaintTool = paintTool;
 }
Пример #10
0
 protected AbstractPaintToolDecorator(IPaintTool paintTool)
 {
     this.PaintTool = paintTool;
 }
Пример #11
0
 /// <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));
 }
Пример #12
0
 /// <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;
 }
Пример #13
0
 public UpDownPaintToolDecorator(IPaintTool paintTool)
     : base(paintTool)
 {
 }
Пример #14
0
 public void Add(IPaintTool paintTool)
 {
     paintTools.Add(paintTool);
 }
Пример #15
0
 public UpDownPaintToolDecorator(IPaintTool paintTool) : base(paintTool)
 {
 }