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);
        }
示例#2
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);
        }