Ejemplo n.º 1
0
        public override void MouseUp(int x, int y)
        {
            if (currentSelectedPath != null)
            {
                this.currentSelectedPath.FillColor = ColorRGBA.Black;
            }
            this.currentSelectedPath = null;
            if (EditMode == Samples.EditMode.Select)
            {
                return;
            }

            if (currentBrushPath != null)
            {
                //1. close current path


                switch (currentBrushPath.BrushMode)
                {
                case SmoothBrushMode.CutBrush:
                {
                    currentBrushPath.MakeSmoothPath();
                    if (myBrushPathList.Count > 0)
                    {
                        //1. remove
                        myBrushPathList.RemoveAt(myBrushPathList.Count - 1);
                        //

                        if (myBrushPathList.Count > 0)
                        {
                            var lastPath = myBrushPathList[myBrushPathList.Count - 1];
                            //do path clip***
                            var paths = PixelFarm.Agg.VertexSource.VxsClipper.CombinePaths(new VertexStoreSnap(lastPath.Vxs),
                                                                                           new VertexStoreSnap(currentBrushPath.Vxs), VertexSource.VxsClipperType.Difference,
                                                                                           false);
                            myBrushPathList.RemoveAt(myBrushPathList.Count - 1);
                            MyBrushPath newBrushPath = new MyBrushPath();
                            newBrushPath.BrushMode   = lastPath.BrushMode;
                            newBrushPath.StrokeColor = lastPath.StrokeColor;
                            newBrushPath.FillColor   = lastPath.FillColor;
                            newBrushPath.SetVxs(paths[0]);
                            myBrushPathList.Add(newBrushPath);
                        }
                    }
                }
                break;

                case SmoothBrushMode.SolidBrush:
                {
                    //create close point
                    currentBrushPath.AddPointAtLast(x, y);
                    currentBrushPath.MakeSmoothPath();
                }
                break;
                }
                currentBrushPath = null;
            }

            base.MouseUp(x, y);
        }
Ejemplo n.º 2
0
        public override void MouseDown(int x, int y, bool isRightButton)
        {
            latestMousePoint = new Point(x, y);
            currentBrushPath = new MyBrushPath();
            switch (BrushMode)
            {
            case SmoothBrushMode.SolidBrush:
                currentBrushPath.FillColor   = ColorRGBA.Black;
                currentBrushPath.StrokeColor = ColorRGBA.Red;
                break;

            case SmoothBrushMode.EraseBrush:
                currentBrushPath.FillColor   = ColorRGBA.White;
                currentBrushPath.StrokeColor = ColorRGBA.Transparent;
                break;

            case SmoothBrushMode.CutBrush:

                break;
            }
            currentBrushPath.BrushMode = this.BrushMode;
            this.myBrushPathList.Add(currentBrushPath);
            currentBrushPath.AddPointFirst(x, y);
            base.MouseDown(x, y, isRightButton);
        }
Ejemplo n.º 3
0
 public override void MouseDown(int x, int y, bool isRightButton)
 {
     latestMousePoint = new Point(x, y);
     currentBrushPath = new MyBrushPath();
     this.myBrushPathList.Add(currentBrushPath);
     currentBrushPath.AddPointFirst(x, y);
     base.MouseDown(x, y, isRightButton);
 }
Ejemplo n.º 4
0
 public override void MouseUp(int x, int y)
 {
     if (currentBrushPath != null)
     {
         currentBrushPath.Close();
         currentBrushPath = null;
     }
     base.MouseUp(x, y);
 }
Ejemplo n.º 5
0
        public override void MouseUp(int x, int y)
        {
            if (currentBrushPath != null)
            {
                currentBrushPath.GetSmooth();
                switch (currentBrushPath.BrushMode)
                {
                case SmoothBrushMode.CutBrush:
                {
                    if (myBrushPathList.Count > 0)
                    {
                        //1. remove
                        myBrushPathList.RemoveAt(myBrushPathList.Count - 1);
                        //

                        if (myBrushPathList.Count > 0)
                        {
                            var lastPath = myBrushPathList[myBrushPathList.Count - 1];

                            //do path clip***

                            PathWriter result = CombinePaths(
                                new VertexStoreSnap(lastPath.vxs),
                                new VertexStoreSnap(currentBrushPath.vxs),
                                ClipType.ctDifference);

                            myBrushPathList.RemoveAt(myBrushPathList.Count - 1);

                            MyBrushPath newBrushPath = new MyBrushPath();
                            newBrushPath.BrushMode   = lastPath.BrushMode;
                            newBrushPath.StrokeColor = lastPath.StrokeColor;
                            newBrushPath.FillColor   = lastPath.FillColor;
                            newBrushPath.vxs         = result.Vxs;
                            myBrushPathList.Add(newBrushPath);
                        }
                    }
                } break;
                }
                currentBrushPath = null;
            }

            base.MouseUp(x, y);
        }
Ejemplo n.º 6
0
        public override void MouseDown(int x, int y, bool isRightButton)
        {
            this.lastMousePosX = x;
            this.lastMousePosY = y;
            switch (this.EditMode)
            {
            case Samples.EditMode.Select:
            {
                //hit test find path object
                HandleMouseDownOnSelectMode(x, y);
            }
            break;

            case Samples.EditMode.Draw:
            {
                latestMousePoint = new Point(x, y);
                currentBrushPath = new MyBrushPath();
                switch (BrushMode)
                {
                case SmoothBrushMode.SolidBrush:
                    currentBrushPath.FillColor   = Drawing.Color.Black;
                    currentBrushPath.StrokeColor = Drawing.Color.Red;
                    break;

                case SmoothBrushMode.EraseBrush:
                    currentBrushPath.FillColor   = Drawing.Color.White;
                    currentBrushPath.StrokeColor = Drawing.Color.Transparent;
                    break;

                case SmoothBrushMode.CutBrush:

                    break;
                }
                currentBrushPath.BrushMode = this.BrushMode;
                this.myBrushPathList.Add(currentBrushPath);
                currentBrushPath.AddPointAtFirst(x, y);
            }
            break;
            }

            base.MouseDown(x, y, isRightButton);
        }
Ejemplo n.º 7
0
        void HandleMouseDownOnSelectMode(int x, int y)
        {
            //hit test ...

            MyBrushPath selectedPath = null;
            int         j            = this.myBrushPathList.Count;

            for (int i = this.myBrushPathList.Count - 1; i >= 0; --i)
            {
                MyBrushPath mypath = myBrushPathList[i];
                if (mypath.HitTest(x, y))
                {
                    //found
                    //then check fill color
                    selectedPath = mypath;
                    break;
                }
            }

            if (selectedPath == this.currentSelectedPath)
            {
                return;
            }

            if (this.currentSelectedPath != null && selectedPath != this.currentSelectedPath)
            {
                //clear prev
                currentSelectedPath.FillColor = Drawing.Color.Black;
            }

            if (selectedPath != null)
            {
                selectedPath.FillColor   = Drawing.Color.Red;
                this.currentSelectedPath = selectedPath;
            }
        }
Ejemplo n.º 8
0
        public override void MouseUp(int x, int y)
        {
            if (currentSelectedPath != null)
            {
                this.currentSelectedPath.FillColor = Drawing.Color.Black;
            }
            this.currentSelectedPath = null;
            if (EditMode == Samples.EditMode.Select)
            {
                return;
            }

            if (currentBrushPath != null)
            {
                //1. close current path


                switch (currentBrushPath.BrushMode)
                {
                case SmoothBrushMode.CutBrush:
                {
                    currentBrushPath.MakeSmoothPath();
                    if (myBrushPathList.Count > 0)
                    {
                        //1. remove
                        myBrushPathList.RemoveAt(myBrushPathList.Count - 1);
                        //

                        if (myBrushPathList.Count > 0)
                        {
                            int j = myBrushPathList.Count - 1;
                            for (int i = j; i >= 0; --i)
                            {
                                //cut each path
                                var lastPath = myBrushPathList[i];
                                //do path clip***
                                List <VertexStore> paths = PixelFarm.Agg.VertexSource.VxsClipper.CombinePaths(new VertexStoreSnap(lastPath.Vxs),
                                                                                                              new VertexStoreSnap(currentBrushPath.Vxs), VertexSource.VxsClipperType.Difference,
                                                                                                              true);

                                myBrushPathList.RemoveAt(i);

                                if (i == j)
                                {
                                    //the last one
                                    for (int s = paths.Count - 1; s >= 0; --s)
                                    {
                                        MyBrushPath newBrushPath = new MyBrushPath();
                                        newBrushPath.BrushMode   = lastPath.BrushMode;
                                        newBrushPath.StrokeColor = lastPath.StrokeColor;
                                        newBrushPath.FillColor   = lastPath.FillColor;
                                        newBrushPath.SetVxs(paths[s]);
                                        myBrushPathList.Add(newBrushPath);         //add last
                                    }
                                }
                                else
                                {
                                    for (int s = paths.Count - 1; s >= 0; --s)
                                    {
                                        MyBrushPath newBrushPath = new MyBrushPath();
                                        newBrushPath.BrushMode   = lastPath.BrushMode;
                                        newBrushPath.StrokeColor = lastPath.StrokeColor;
                                        newBrushPath.FillColor   = lastPath.FillColor;
                                        newBrushPath.SetVxs(paths[s]);
                                        myBrushPathList.Insert(i, newBrushPath);
                                    }
                                }
                            }
                        }
                    }
                }
                break;

                case SmoothBrushMode.SolidBrush:
                {
                    //create close point
                    currentBrushPath.AddPointAtLast(x, y);
                    currentBrushPath.MakeSmoothPath();
                }
                break;
                }
                currentBrushPath = null;
            }

            base.MouseUp(x, y);
        }