Ejemplo n.º 1
0
        public static bool CopyFilesInDirectory(string srcDir, string destDir, PathFunc filterFunc = null)
        {
            if (!Directory.Exists(srcDir))
            {
                return(false);
            }
            if (filterFunc != null && !filterFunc(srcDir))
            {
                return(false);
            }
            if (!ExistOrCreateDirectory(destDir))
            {
                return(false);
            }

            string destFilePath = null;

            foreach (string srcFilePath in Directory.GetFiles(srcDir))
            {
                if (filterFunc == null || filterFunc(srcFilePath))
                {
                    destFilePath = destDir + srcFilePath.Substring(srcDir.Length);
                    File.Copy(srcFilePath, destFilePath, true);
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        public void DrawShape(Rectangle rect, int radius, PenPlus pen, GraphicShape shape, RoundedCorners corners)
        {
            if (rect.Width < 1 || rect.Height < 1)
            {
                return;
            }
            PathFunc     func = GetShapeFunc(shape);
            GraphicsPath path = func(rect, radius, 0, PathMode.All, corners);

            this.DrawPath(pen, path);
        }
Ejemplo n.º 3
0
 // Methods
 protected Shape(SerializationInfo info, StreamingContext context)
 {
     this.pathString = string.Empty;
     this.graphPath  = null;
     PointF[] tfArray1 = info.GetValue("points", typeof(PointF[])) as PointF[];
     byte[]   buffer1  = info.GetValue("types", typeof(byte[])) as byte[];
     if (((tfArray1 != null) && (buffer1 != null)) && (tfArray1.Length == buffer1.Length))
     {
         this.graphPath  = new GraphicsPath(tfArray1, buffer1);
         this.pathString = PathFunc.GetPathString(this.graphPath);
     }
     this.id  = info.GetValue("id", typeof(string)) as string;
     tfArray1 = null;
     buffer1  = null;
 }
Ejemplo n.º 4
0
        public override object FT(float time, DomType domtype)
        {
            if (time < base.Begin)
            {
                return(null);
            }
            if ((time < base.Begin) || (time > (base.Begin + base.Duration)))
            {
                return(null);
            }
            string text1 = base.ToWhat;

            switch (domtype)
            {
            case DomType.SvgMatrix:
            {
                return(new Transf(this.Type + "(" + text1.Trim() + ")").Matrix);
            }

            case DomType.SvgNumber:
            {
                return(ItopVector.Core.Func.Number.parseToFloat(text1.Trim(), (SvgElement)this.ParentNode, ItopVector.Core.Func.SvgLengthDirection.Horizontal));
            }

            case DomType.SvgString:
            {
                return(text1.Trim());
            }

            case DomType.SvgColor:
            {
                return(text1.Trim());
            }

            case DomType.SvgPath:
            {
                return(PathFunc.PathDataParse(text1));
            }

            case DomType.SvgPoints:
            {
                return(PointsFunc.PointsParse(text1));
            }
            }
            return(base.ToWhat);
        }
Ejemplo n.º 5
0
        public static bool CopyDirectory(string srcDir, string destDir, PathFunc filterFunc = null)
        {
            if (!CopyFilesInDirectory(srcDir, destDir, filterFunc))
            {
                return(false);
            }

            string destSubDirPath = null;

            foreach (string srcSubDirPath in Directory.GetDirectories(srcDir))
            {
                destSubDirPath = destDir + srcSubDirPath.Substring(srcDir.Length);
                if (!CopyDirectory(srcSubDirPath, destSubDirPath, filterFunc))
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 6
0
        public void Paint(GraphicsPath path, Graphics g, int time, float opacity)
        {
            int num1 = 0;
            int num2 = 0;

            AnimFunc.CreateAnimateValues(this, time, out num1, out num2);
            path.FillMode   = FillMode.Alternate;
            g.SmoothingMode = base.OwnerDocument.SmoothingMode;
            SpreadMethods methods1 = this.SpreadMethod;
            bool          flag1    = this.Units == Units.UserSpaceOnUse;
            float         single1  = this.CX;
            float         single2  = this.CY;
            float         single3  = this.R;
            float         single4  = this.FX;
            float         single5  = this.FY;

            PointF[] tfArray2 = new PointF[7] {
                new PointF(single1, single2), new PointF(single1 + single3, single2), new PointF(single1 + (single3 * ((float)Math.Sin(1.8325957145940459))), single2 + (single3 * ((float)Math.Cos(1.8325957145940459)))), new PointF(single1 + (single3 * ((float)Math.Sin(1.3089969389957472))), single2 + (single3 * ((float)Math.Cos(1.3089969389957472)))), new PointF(single1, single2 + single3), PointF.Empty, PointF.Empty
            };
            this.boundsPoints = tfArray2;
            GraphicsPath path1 = this.gradientpath;

            path1.Reset();
            path1.AddEllipse((float)(single1 - single3), (float)(single2 - single3), (float)(2f * single3), (float)(2f * single3));
            RectangleF ef1 = RectangleF.Empty;
            RectangleF ef2 = PathFunc.GetBounds(path);
            RectangleF ef3 = RectangleF.Empty;

            this.coord.Reset();
            if (flag1)
            {
                ef3 = ((SVG)base.OwnerDocument.DocumentElement).ViewPort;
            }
            else
            {
                ef2 = new RectangleF(0f, 0f, 1f, 1f);
                ef3 = ef2;
                ef1 = PathFunc.GetBounds(path);
                this.coord.Translate(ef1.X, ef1.Y);
                this.coord.Scale(ef1.Width, ef1.Height);
            }
            //if (this.stops.Count==0)return;

            ColorBlend blend1 = new ColorBlend(this.Stops.Count);

            Color[] colorArray1              = new Color[this.Stops.Count];
            float[] singleArray1             = new float[this.Stops.Count];
            SvgElementCollection collection1 = this.Stops;

            for (int num3 = 0; num3 < collection1.Count; num3++)
            {
                GradientStop stop1 = (GradientStop)collection1[num3];
                AnimFunc.CreateAnimateValues(stop1, time, out num1, out num2);
                int num4 = 0xff;
                if ((stop1.Opacity >= 0f) && (stop1.Opacity <= 255f))
                {
                    if (stop1.Opacity <= 1f)
                    {
                        num4 = (int)(stop1.Opacity * 255f);
                    }
                    else
                    {
                        num4 = (int)stop1.Opacity;
                    }
                }
                num4 = (int)Math.Min((float)(opacity * 255f), (float)num4);
                Color color1  = stop1.Color;
                float single6 = Math.Min((float)1f, Math.Max((float)0f, stop1.ColorOffset));
                colorArray1[num3]  = Color.FromArgb(num4, color1.R, color1.G, color1.B);
                singleArray1[num3] = single6;
            }
            float[] singleArray2 = (float[])singleArray1.Clone();
            Color[] colorArray2  = (Color[])colorArray1.Clone();
            Array.Sort(singleArray2, colorArray2);
            Color color2 = colorArray2[0];
            Color color3 = colorArray2[colorArray2.Length - 1];

            if (singleArray2[0] != 0f)
            {
                float[] singleArray3 = (float[])singleArray2.Clone();
                Color[] colorArray3  = (Color[])colorArray2.Clone();
                singleArray2 = new float[singleArray2.Length + 1];
                colorArray2  = new Color[colorArray2.Length + 1];
                colorArray3.CopyTo(colorArray2, 1);
                singleArray3.CopyTo(singleArray2, 1);
                singleArray2[0] = 0f;
                colorArray2[0]  = color2;
            }
            if (singleArray2[singleArray2.Length - 1] != 1f)
            {
                float[] singleArray4 = (float[])singleArray2.Clone();
                Color[] colorArray4  = (Color[])colorArray2.Clone();
                singleArray2 = new float[singleArray2.Length + 1];
                singleArray4.CopyTo(singleArray2, 0);
                singleArray2[singleArray2.Length - 1] = 1f;
                colorArray2 = new Color[colorArray2.Length + 1];
                colorArray4.CopyTo(colorArray2, 0);
                colorArray2[colorArray2.Length - 1] = color3;
            }
            if (methods1 == SpreadMethods.Pad)
            {
                float single7  = Math.Min((float)(single1 - single3), ef2.X);
                float single8  = Math.Min((float)(single2 - single3), ef2.Y);
                float single9  = Math.Max(single3, (float)(ef2.Width / 2f));
                float single10 = this.cx - single3;
                float single11 = this.r;
                for (int num5 = 0; num5 < singleArray2.Length; num5++)
                {
                    singleArray2[num5] = ((single10 + (single11 * singleArray2[num5])) - single7) / single9;
                }
                if (singleArray2[0] != 0f)
                {
                    float[] singleArray5 = (float[])singleArray2.Clone();
                    Color[] colorArray5  = (Color[])colorArray2.Clone();
                    singleArray2 = new float[singleArray2.Length + 1];
                    colorArray2  = new Color[colorArray2.Length + 1];
                    colorArray5.CopyTo(colorArray2, 1);
                    singleArray5.CopyTo(singleArray2, 1);
                    singleArray2[0] = 0f;
                    colorArray2[0]  = color2;
                }
                if (singleArray2[singleArray2.Length - 1] != 1f)
                {
                    float[] singleArray6 = (float[])singleArray2.Clone();
                    Color[] colorArray6  = (Color[])colorArray2.Clone();
                    singleArray2 = new float[singleArray2.Length + 1];
                    singleArray6.CopyTo(singleArray2, 0);
                    singleArray2[singleArray2.Length - 1] = 1f;
                    colorArray2 = new Color[colorArray2.Length + 1];
                    colorArray6.CopyTo(colorArray2, 0);
                    colorArray2[colorArray2.Length - 1] = color3;
                }
            }
            Array.Reverse(colorArray2);
            Array.Reverse(singleArray2);
            for (int num6 = 0; num6 < singleArray2.Length; num6++)
            {
                singleArray2[num6] = 1f - singleArray2[num6];
            }
            Matrix matrix1 = this.Transform.Matrix.Clone();

            path1 = (GraphicsPath)this.gradientpath.Clone();
            path1.Transform(matrix1);
            this.brush       = new PathGradientBrush(path1);
            blend1.Colors    = colorArray2;
            blend1.Positions = singleArray2;
            this.brush.InterpolationColors = blend1;
            if (methods1 == SpreadMethods.Reflect)
            {
                this.brush.WrapMode = WrapMode.Tile;
            }
            else if (methods1 == SpreadMethods.Repeat)
            {
                this.brush.WrapMode = WrapMode.TileFlipXY;
            }
            else
            {
                this.brush.WrapMode = WrapMode.Clamp;
            }
            if (AttributeFunc.FindAttribute("fx", this).ToString() == string.Empty)
            {
                single4 = this.CX;
            }
            if (AttributeFunc.FindAttribute("fy", this).ToString() == string.Empty)
            {
                single5 = this.CY;
            }
            PointF[] tfArray3 = new PointF[1] {
                new PointF(single4, single5)
            };
            PointF[] tfArray1 = tfArray3;
            matrix1.TransformPoints(tfArray1);
            this.brush.CenterPoint = tfArray1[0];
            g.FillPath(new SolidBrush(colorArray2[0]), path);
            GraphicsContainer container1 = g.BeginContainer();

            g.Transform = this.coord;
            Matrix matrix2 = this.coord.Clone();

            matrix2.Invert();
            GraphicsPath path2 = (GraphicsPath)path.Clone();

            path2.Transform(matrix2);
            g.FillPath(this.brush, path2);
            g.EndContainer(container1);
            this.pretime = -1;
        }
Ejemplo n.º 7
0
        public void OnPaint(PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
            ToolOperation operation1 = this.mouseAreaControl.CurrentOperation;
            SvgElement    element1   = this.mouseAreaControl.SVGDocument.CurrentElement;

            if (((operation1 == ToolOperation.GradientTransform) && (element1 is ISvgBrush)) && ((this.activeGraph != null) && !this.mouseAreaControl.SVGDocument.PlayAnim))
            {
                ISvgBrush  brush1 = (ISvgBrush)this.mouseAreaControl.SVGDocument.CurrentElement;
                RectangleF ef1    = RectangleF.Empty;
                if (!(brush1 is SolidColor))
                {
                    GraphicsPath path1    = new GraphicsPath();
                    PointF       tf1      = PointF.Empty;
                    PointF       tf2      = PointF.Empty;
                    PointF       tf3      = PointF.Empty;
                    PointF       tf4      = PointF.Empty;
                    PointF       tf5      = PointF.Empty;
                    PointF       tf6      = PointF.Empty;
                    PointF       tf7      = PointF.Empty;
                    PointF       tf8      = PointF.Empty;
                    PointF[]     tfArray1 = new PointF[1];
                    this.ratiomatrix.Reset();
                    this.gradientPath.Reset();
                    if (brush1 is LinearGradient)
                    {
                        LinearGradient gradient1 = (LinearGradient)brush1;
                        this.gradientPath  = (GraphicsPath)gradient1.GradientPath.Clone();
                        this.controlPoints = (PointF[])gradient1.BoundsPoints.Clone();
                        if (this.controlPoints.Length <= 0)
                        {
                            return;
                        }
                        this.graphMatrix = this.activeGraph.GraphTransform.Matrix.Clone();
                        this.graphMatrix.Multiply(gradient1.Coord);
                        this.gradientMatrix = gradient1.Transform.Matrix.Clone();
                        this.gradientPath.Transform(this.gradientMatrix);
                        this.gradientPath.Transform(this.graphMatrix);
                        e.Graphics.DrawPath(Pens.Black, this.gradientPath);
                        this.centerPoint = this.controlPoints[0];
                        this.gradientMatrix.TransformPoints(this.controlPoints);
                        this.graphMatrix.TransformPoints(this.controlPoints);
                        tf3 = this.controlPoints[0];
                        tf2 = this.controlPoints[1];
                        tf1 = this.controlPoints[2];
                        this.gradientPath = (GraphicsPath)gradient1.GradientPath.Clone();
                    }
                    else if (brush1 is RadialGradients)
                    {
                        RadialGradients gradients1 = (RadialGradients)brush1;
                        this.gradientPath  = (GraphicsPath)gradients1.GradientPath.Clone();
                        this.controlPoints = (PointF[])gradients1.BoundsPoints.Clone();
                        this.graphMatrix   = this.activeGraph.GraphTransform.Matrix.Clone();
                        this.graphMatrix.Multiply(gradients1.Coord);
                        this.gradientMatrix = gradients1.Transform.Matrix.Clone();
                        this.gradientPath.Transform(this.gradientMatrix);
                        this.gradientPath.Transform(this.graphMatrix);
                        e.Graphics.DrawPath(Pens.Black, this.gradientPath);
                        RectangleF ef3 = PathFunc.GetBounds(this.gradientPath);
                        this.gradientheight = ef3.Height;
                        this.centerPoint    = this.controlPoints[0];
                        this.gradientMatrix.TransformPoints(this.controlPoints);
                        this.graphMatrix.TransformPoints(this.controlPoints);
                        tf3 = this.controlPoints[0];
                        tf2 = this.controlPoints[2];
                        tf1 = this.controlPoints[3];
                        tf4 = this.controlPoints[1];
                        this.gradientPath = (GraphicsPath)gradients1.GradientPath.Clone();
                    }
                    else if (brush1 is Pattern)
                    {
                        Pattern pattern1 = (Pattern)brush1;
                        this.gradientPath = (GraphicsPath)pattern1.GradientPath.Clone();
                        RectangleF ef2 = this.gradientPath.GetBounds();
                        this.controlPoints  = (PointF[])pattern1.BoundsPoints.Clone();
                        this.graphMatrix    = this.activeGraph.GraphTransform.Matrix.Clone();
                        this.gradientMatrix = pattern1.Transform.Matrix.Clone();
                        this.gradientPath.Transform(this.gradientMatrix);
                        this.gradientPath.Transform(this.graphMatrix);
                        e.Graphics.DrawPath(Pens.Black, this.gradientPath);
                        RectangleF ef4 = PathFunc.GetBounds(this.gradientPath);
                        this.gradientheight = ef4.Height;
                        this.centerPoint    = this.controlPoints[0];
                        this.gradientMatrix.TransformPoints(this.controlPoints);
                        this.graphMatrix.TransformPoints(this.controlPoints);
                        tf3 = this.controlPoints[0];
                        tf1 = this.controlPoints[2];
                        tf7 = this.controlPoints[6];
                        tf5 = this.controlPoints[3];
                        tf6 = this.controlPoints[4];
                        tf2 = this.controlPoints[1];
                        tf8 = this.controlPoints[5];
                        this.gradientPath = (GraphicsPath)pattern1.GradientPath.Clone();
                    }
                    this.translatePath.Reset();
                    PointF[] tfArray2 = new PointF[4] {
                        new PointF(tf3.X, tf3.Y - 4f), new PointF(tf3.X - 4f, tf3.Y), new PointF(tf3.X, tf3.Y + 4f), new PointF(tf3.X + 4f, tf3.Y)
                    };
                    this.translatePath.AddPolygon(tfArray2);
                    e.Graphics.FillPath(Brushes.White, this.translatePath);
                    e.Graphics.DrawPath(Pens.Black, this.translatePath);
                    this.rotatePath.Reset();
                    this.rotatePath.AddEllipse((float)(tf1.X - 3f), (float)(tf1.Y - 3f), (float)6f, (float)6f);
                    this.scalePath.Reset();
                    this.scalePath.AddRectangle(new RectangleF(tf2.X - 3f, tf2.Y - 3f, 6f, 6f));
                    this.equalPath.Reset();
                    this.equalPath.AddEllipse((float)(tf4.X - 3f), (float)(tf4.Y - 3f), (float)6f, (float)6f);
                    this.skewxPath.Reset();
                    this.skewxPath.AddEllipse((float)(tf5.X - 3f), (float)(tf5.Y - 3f), (float)6f, (float)6f);
                    this.skewyPath.Reset();
                    this.skewyPath.AddEllipse((float)(tf6.X - 3f), (float)(tf6.Y - 3f), (float)6f, (float)6f);
                    this.anglescalePath.Reset();
                    this.anglescalePath.AddRectangle(new RectangleF(tf7.X - 3f, tf7.Y - 3f, 6f, 6f));
                    this.vscalPath.Reset();
                    this.vscalPath.AddRectangle(new RectangleF(tf8.X - 3f, tf8.Y - 3f, 6f, 6f));
                    e.Graphics.FillPath(Brushes.White, this.rotatePath);
                    e.Graphics.DrawPath(Pens.Black, this.rotatePath);
                    e.Graphics.FillPath(Brushes.White, this.scalePath);
                    e.Graphics.DrawPath(Pens.Black, this.scalePath);
                    e.Graphics.FillPath(Brushes.White, this.equalPath);
                    e.Graphics.DrawPath(Pens.Black, this.equalPath);
                    e.Graphics.FillPath(Brushes.White, this.skewxPath);
                    e.Graphics.DrawPath(Pens.Black, this.skewxPath);
                    e.Graphics.FillPath(Brushes.White, this.skewyPath);
                    e.Graphics.DrawPath(Pens.Black, this.skewyPath);
                    e.Graphics.FillPath(Brushes.White, this.anglescalePath);
                    e.Graphics.DrawPath(Pens.Black, this.anglescalePath);
                    e.Graphics.FillPath(Brushes.White, this.vscalPath);
                    e.Graphics.DrawPath(Pens.Black, this.vscalPath);
                }
            }
        }
Ejemplo n.º 8
0
        public void OnMouseDown(MouseEventArgs e)
        {
            bool   flag2;
            bool   flag3;
            PointF tf1;


            if (e.Button == MouseButtons.Left)
            {            //wlwl
                this.startpoint = this.mouseAreaControl.PicturePanel.PointToView(new PointF(e.X, e.Y));
                if (this.mouseAreaControl.CurrentOperation == ToolOperation.XPolyLine)
                {
                    if (points.Length > 0)
                    {
                        this.startpoint = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, points[0].Y));
                    }
                    else
                    {
                        this.startpoint = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y));
                    }
                }
                if (this.mouseAreaControl.CurrentOperation == ToolOperation.YPolyLine)
                {
                    if (points.Length > 0)
                    {
                        this.startpoint = this.mouseAreaControl.PicturePanel.PointToView(new PointF(points[0].X, (float)e.Y));
                    }
                    else
                    {
                        this.startpoint = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y));
                    }
                }
                if (this.mouseAreaControl.CurrentOperation == ToolOperation.PolyLine ||
                    this.mouseAreaControl.CurrentOperation == ToolOperation.Polygon ||
                    this.mouseAreaControl.CurrentOperation == ToolOperation.InterEnclosure ||
                    this.mouseAreaControl.CurrentOperation == ToolOperation.Enclosure ||
                    this.mouseAreaControl.CurrentOperation == ToolOperation.LeadLine ||
                    this.mouseAreaControl.CurrentOperation == ToolOperation.AreaPolygon)
                {
                    this.startpoint = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y));
                }
                if (this.mouseAreaControl.CurrentOperation == ToolOperation.Enclosure || this.mouseAreaControl.CurrentOperation == ToolOperation.InterEnclosure)
                {
                    this.AreaPoints.Add(new PointF((float)e.X, (float)e.Y));
                }
                SizeF ef1     = this.mouseAreaControl.PicturePanel.GridSize;
                float single1 = ef1.Height;
                float single2 = ef1.Width;
                if (this.mouseAreaControl.PicturePanel.SnapToGrid)
                {
                    int num1 = (int)((this.startpoint.X + (single2 / 2f)) / single2);
                    int num2 = (int)((this.startpoint.Y + (single1 / 2f)) / single1);
                    this.startpoint = (PointF) new Point((int)(num1 * single2), (int)(num2 * single1));
                }
                SvgDocument document1 = this.mouseAreaControl.SVGDocument;
                bool        flag1     = document1.AcceptChanges;
                document1.NumberOfUndoOperations = 200;
                this.mousedown = true;
                switch (this.operate)
                {
                case PolyOperate.Draw:
                {
                    document1.AcceptChanges = false;
                    flag2 = false;
                    if (this.graph != null)
                    {
                        if (!(this.graph is Polygon) && !(this.graph is Polyline))
                        {
                            flag2 = true;
                        }
                        break;
                    }
                    flag2 = true;
                    break;
                }

                case PolyOperate.MovePath:
                {
                    goto Label_05F5;
                }

                case PolyOperate.MovePoint:
                {
                    PointF tf3;
                    this.nextPoint = tf3 = PointF.Empty;
                    this.prePoint  = tf3;
                    if ((this.moveindex < 0) || (this.moveindex >= this.points.Length))
                    {
                        goto Label_05F5;
                    }
                    flag3 = this.graph is Polygon;
                    if ((this.moveindex - 1) < 0)
                    {
                        if ((this.points.Length >= 3) && flag3)
                        {
                            this.prePoint = this.points[this.points.Length - 1];
                        }
                        goto Label_042C;
                    }
                    this.prePoint = this.points[this.moveindex - 1];
                    goto Label_042C;
                }

                case PolyOperate.Del:
                {
                    if ((this.moveindex >= 0) && (this.moveindex < this.points.Length))
                    {
                        ArrayList list1 = new ArrayList(this.points);
                        list1.RemoveAt(this.moveindex);
                        this.points = new PointF[list1.Count];
                        list1.CopyTo(this.points);
                        Matrix matrix1 = this.graph.GraphTransform.Matrix.Clone();
                        matrix1.Invert();
                        if (this.points.Length > 0)
                        {
                            matrix1.TransformPoints(this.points);
                        }
                    }
                    goto Label_05F5;
                }

                case PolyOperate.Break:                        //线路断开
                {
                    if ((this.moveindex > 0) && (this.moveindex < this.points.Length - 1))
                    {
                        ArrayList list1   = new ArrayList(this.points);
                        PointF[]  points2 = new PointF[this.points.Length - moveindex];

                        this.points = new PointF[moveindex + 1];
                        list1.CopyTo(0, this.points, 0, this.moveindex + 1);
                        list1.CopyTo(moveindex, points2, 0, list1.Count - moveindex);

                        Matrix matrix1 = this.graph.GraphTransform.Matrix.Clone();
                        matrix1.Invert();
                        if (points2.Length > 0)
                        {
                            matrix1.TransformPoints(points2);
                            SvgElement copyEelement = (this.graph as XmlNode).CloneNode(true) as SvgElement;
                            IGraph     graph1       = this.graph;

                            copyEelement.SetAttribute("info-name", ((SvgElement)graph1).GetAttribute("info-name") + "-2");
                            ((SvgElement)graph).SetAttribute("info-name", ((SvgElement)graph1).GetAttribute("info-name") + "-1");
                            copyEelement = this.mouseAreaControl.PicturePanel.AddElement(copyEelement);
                            this.mouseAreaControl.SVGDocument.CurrentElement = graph1 as SvgElement;
                            copyEelement.RemoveAttribute("points");
                            UpdateGraph(copyEelement, points2);
                            this.mouseAreaControl.PicturePanel.InvalidateElement(copyEelement);
                            BreakElementEventArgs copy = new BreakElementEventArgs(copyEelement);
                            if (OnPolyLineBreak != null && copyEelement != null)
                            {
                                OnPolyLineBreak(this.mouseAreaControl.SVGDocument.CurrentElement, copy);
                            }
                        }
                        if (this.points.Length > 0)
                        {
                            matrix1.TransformPoints(this.points);
                        }
                    }
                    else
                    {
                        return;
                    }
                    goto Label_05F5;
                }

                case PolyOperate.Add:
                {
                    if ((this.insertindex < 0) || (this.insertindex >= this.points.Length))
                    {
                        goto Label_05F5;
                    }
                    this.points = new PointF[0];
                    if (!(this.graph is Polygon))
                    {
                        if (this.graph is Polyline)
                        {
                            this.points = ((Polyline)this.graph).Points;
                        }
                        goto Label_058D;
                    }
                    this.points = ((Polygon)this.graph).Points;
                    goto Label_058D;
                }

                default:
                {
                    goto Label_05F5;
                }
                }
                if (flag2)
                {
                    IGraph graph1 = this.mouseAreaControl.PicturePanel.PreGraph;
                    if (graph1 == null)
                    {
                        return;
                    }
                    this.graph = (Graph)((SvgElement)graph1).Clone();
                    this.mouseAreaControl.SVGDocument.AcceptChanges = false;
                    if (this.graph != null)
                    {
                        ((SvgElement)this.graph).RemoveAttribute("points");
                    }
                    if (((SvgElement)this.graph) is IGraphPath)
                    {
                        if ((((SvgElement)graph1).GetAttribute("style") != string.Empty) && (((SvgElement)graph1).GetAttribute("style") != null))
                        {
                            this.mouseAreaControl.SVGDocument.AcceptChanges = false;
                            AttributeFunc.SetAttributeValue((SvgElement)this.graph, "style", ((SvgElement)this.graph).GetAttribute("style"));
                        }
                        ISvgBrush brush1 = ((IGraphPath)graph1).GraphBrush;
                        if (brush1 is SvgElement)
                        {
                            ISvgBrush brush2 = (ISvgBrush)((SvgElement)brush1).Clone();
                            ((IGraphPath)this.graph).GraphBrush = brush2;
                            ((SvgElement)brush2).pretime        = -1;
                        }
                        else
                        {
                            ((IGraphPath)this.graph).GraphBrush = brush1;
                        }
                        brush1 = ((IGraphPath)graph1).GraphStroke.Brush;
                        if (brush1 is SvgElement)
                        {
                            ISvgBrush brush3 = (ISvgBrush)((SvgElement)brush1).Clone();
                            ((IGraphPath)this.graph).GraphStroke = new Stroke(brush3);
                            ((SvgElement)brush3).pretime         = -1;
                        }
                        else
                        {
                            ((IGraphPath)this.graph).GraphStroke.Brush = brush1;
                        }
                    }
                }
                PointF[] tfArray1 = new PointF[0];
                if (this.graph is Polygon)
                {
                    tfArray1 = ((Polygon)this.graph).Points;
                }
                else if (this.graph is Polyline)
                {
                    tfArray1 = ((Polyline)this.graph).Points;
                }
                this.points = new PointF[1];
                int insertIndex = 0;
                if (tfArray1 != null)
                {
                    ;
                    this.points = new PointF[tfArray1.Length + 1];

                    if (addBegin)
                    {
                        tfArray1.CopyTo(this.points, 1);
                    }
                    else
                    {
                        tfArray1.CopyTo(this.points, 0);
                        insertIndex = tfArray1.Length;
                    }
                }
                if (addBegin || addEnd)
                {
                    Matrix matrix1 = this.graph.GraphTransform.Matrix.Clone();
                    matrix1.Invert();
                    PointF[] points2 = new PointF[1] {
                        new PointF(e.X, e.Y)
                    };
                    matrix1.TransformPoints(points2);
                    this.startpoint = points2[0];
                }

                this.points[insertIndex] = this.startpoint;
                goto Label_05F5;
Label_042C:
                if ((this.moveindex + 1) < this.points.Length)
                {
                    this.nextPoint = this.points[this.moveindex + 1];
                    goto Label_05F5;
                }
                if ((this.points.Length >= 3) && flag3)
                {
                    this.nextPoint = this.points[0];
                }
                goto Label_05F5;
Label_058D:
                Matrix matrix2 = this.graph.GraphTransform.Matrix.Clone();
                matrix2.Invert();
                //tf1 = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y));//new PointF((float) e.X, (float) e.Y)
                PointF[] tfTemp = new PointF[1] {
                    new PointF(e.X, e.Y)
                };
                matrix2.TransformPoints(tfTemp);
                ArrayList list2 = new ArrayList(this.points);
                list2.Insert(this.insertindex, tfTemp[0]);
                this.points = new PointF[list2.Count];
                list2.CopyTo(this.points);

Label_05F5:
                //2006-10-23 设置围栏初始颜色
//				if(this.mouseAreaControl.CurrentOperation == ToolOperation.Enclosure || this.mouseAreaControl.CurrentOperation == ToolOperation.InterEnclosure)
//				{
//					((XmlElement) this.graph).SetAttribute("style","fill:#C0C0FF;fill-opacity:0.3;stroke:#000000;stroke-opacity:1;");
//				}


                if (((this.operate == PolyOperate.Del) || (this.operate == PolyOperate.Draw)) || (this.operate == PolyOperate.Add) || (this.operate == PolyOperate.Break))
                {
                    StringBuilder text1    = new StringBuilder();
                    int           num3     = 0;
                    PointF[]      tfArray2 = this.points;
                    for (int num4 = 0; num4 < tfArray2.Length; num4++)
                    {
                        PointF tf2 = tfArray2[num4];
                        text1.Append(tf2.X.ToString() + " " + tf2.Y.ToString());
                        if (num3 < (this.points.Length - 1))
                        {
                            text1.Append(",");
                        }
                        num3++;
                    }
                    this.mouseAreaControl.PicturePanel.InvalidateElement((SvgElement)this.graph);
                    if (((SvgElement)this.graph).ParentNode == null)
                    {
                        this.UpdateGraph(text1.ToString());
                        document1.AcceptChanges = true;
                        IGraph graph2 = this.graph;
                        this.mouseAreaControl.PicturePanel.AddElement(this.graph);
                        this.graph = graph2;
                    }
                    else
                    {
                        document1.AcceptChanges = true;
                        this.UpdateGraph(text1.ToString());
                    }
                    document1.AcceptChanges = flag1;
                    this.mouseAreaControl.Invalidate();
                    if (this.graph != null)
                    {
                        ((SvgElement)this.graph).pretime = -1;
                        this.mouseAreaControl.PicturePanel.InvalidateElement((SvgElement)this.graph);
                    }
                }
                document1.NotifyUndo();
                this.reversePath.Reset();
            }
            else if (e.Button == MouseButtons.Right)           //任务1
            {
                if (this.mouseAreaControl.CurrentOperation == ToolOperation.Enclosure || this.mouseAreaControl.CurrentOperation == ToolOperation.InterEnclosure)
                {
                    //this.AreaPoints.Add(new PointF((float) e.X, (float) e.Y));

//					this.mouseAreaControl.GoBottom((SvgElement)this.graph);
//					((SvgElement)this.graph).Clone();
                    PointF[] tfArray1 = new PointF[this.AreaPoints.Count];
                    this.AreaPoints.CopyTo(tfArray1, 0);
                    this.AreaPoints.Clear();

                    Matrix matrix1 = new Matrix();
                    if (tfArray1.Length < 3)
                    {
                        this.mouseAreaControl.CurrentOperation = ToolOperation.Select;
                        return;
                    }
                    this.selectAreaPath = new GraphicsPath();
                    this.selectAreaPath.AddLines(tfArray1);
                    this.selectAreaPath.CloseFigure();


                    Region region1 = new Region(this.selectAreaPath);

                    RectangleF r1 = selectAreaPath.GetBounds();
                    /* 2005环境 当前区域需要手动添加进集合*/
                    XmlNode    node1  = ((SvgElement)this.graph).Clone();
                    SvgElement svgele = (SvgElement)node1;

                    this.mouseAreaControl.SVGDocument.ClearSelects();

                    using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
                    {
                        foreach (ILayer layer1 in mouseAreaControl.SVGDocument.Layers)
                        {
                            if (!layer1.Visible)
                            {
                                continue;
                            }

                            SvgElementCollection.ISvgElementEnumerator enumerator1 = layer1.GraphList.GetEnumerator();
                            while (enumerator1.MoveNext())
                            {
                                IGraph graph1 = (IGraph)enumerator1.Current;
                                if (!graph1.Visible || !graph1.DrawVisible || this.graph == graph1)
                                {
                                    continue;
                                }
                                GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                                path1.Transform(graph1.GraphTransform.Matrix);
                                Region ef1 = null;
                                if (graph1 is Use)
                                {
                                    ef1 = new Region(PathFunc.GetBounds(path1));
                                }
                                else if (graph1 is Line)
                                {
                                    ef1 = new Region(PathFunc.GetBounds(path1));
                                }
                                else
                                {
                                    ef1 = new Region(path1);
                                }

                                // 设置围栏选择方式为完全包含才能选中
                                if (this.mouseAreaControl.CurrentOperation == ToolOperation.Enclosure)
                                {
                                    RectangleF rt1 = ef1.GetBounds(g);
                                    ef1.Intersect(region1);
                                    if (ef1.GetBounds(g) == rt1)
                                    {
                                        this.mouseAreaControl.SVGDocument.AddSelectElement(graph1);
                                    }
                                    continue;
                                }

                                // 设置围栏选择方式为搭边即选中
                                if (this.mouseAreaControl.CurrentOperation == ToolOperation.InterEnclosure)
                                {
                                    ef1.Intersect(region1);

                                    if (!ef1.GetBounds(g).IsEmpty)
                                    //if ((region1.IsVisible(ef1/*new System.Drawing.Rectangle((int) ef1.X, (int) ef1.Y, (int) ef1.Width, (int) ef1.Height)*/) && !graph1.IsLock) && (graph1.DrawVisible /*&& (AnimFunc.GetKeyIndex((SvgElement) graph1, this.mouseAreaControl.SVGDocument.ControlTime, true) >= 0)*/))
                                    {
                                        this.mouseAreaControl.SVGDocument.AddSelectElement(graph1);
                                    }
                                }
                            }
                        }
                        this.mouseAreaControl.SVGDocument.AddSelectElement(graph);
                    }

                    GraphicsPath path2 = new GraphicsPath();
                    path2.AddLines(tfArray1);
                    RectangleF ef2 = path2.GetBounds();
                    /* 2005 环境下使用,2003环境下需删除否则出现重复.原因不明.*/
                    if (this.mouseAreaControl.CurrentOperation == ToolOperation.Enclosure)
                    {
                        this.mouseAreaControl.SVGDocument.AddSelectElement(svgele);
                    }
                    this.mouseAreaControl.Invalidate(new System.Drawing.Rectangle(((int)ef2.X) - 10, ((int)ef2.Y) - 10, ((int)ef2.Width) + 20, ((int)ef2.Height) + 20));
                    return;
                }
            }             //鼠标右键抬起
        }
Ejemplo n.º 9
0
        public virtual object FT(float time, DomType domtype)
        {
            if ((time < this.Begin) || (time > (this.Begin + this.Duration)))
            {
                return(null);
            }
            ArrayList list1   = (ArrayList)this.Values.Clone();
            ArrayList list2   = (ArrayList)this.KeyTimes.Clone();
            float     single1 = 0f;
            float     single2 = 1f;
            float     single3 = this.Begin;
            float     single4 = this.Duration;

            if (single4 == 0f)
            {
                single4 = 0.1f;
            }
            if (list1.Count == 0)
            {
                list1.Add(this.FromWhat);
                list2.Add(single3.ToString());
                list1.Add(this.ToWhat);
                float single7 = single3 + single4;
                list2.Add(single7.ToString());
            }
            int   num1    = -1;
            float single5 = 0f;
            float single6 = 0f;

            for (int num2 = 1; num2 < list2.Count; num2++)
            {
                single5 = float.Parse(((string)list2[num2 - 1]).Trim());
                single6 = float.Parse(((string)list2[num2]).Trim());
                if ((time >= single5) && (time <= single6))
                {
                    num1 = num2 - 1;
                    break;
                }
            }
            string text1 = (string)list1[num1];
            string text2 = (string)list1[num1 + 1];

            if (list2[num1] != null)
            {
                single1 = float.Parse((string)list2[num1]);
            }
            if (list2[num1 + 1] != null)
            {
                single2 = float.Parse((string)list2[num1 + 1]);
            }
            string text3 = string.Empty;

            string[] textArray1 = AnimFunc.Linear(text1.Trim(), single1, text2.Trim(), single2, domtype, (int)time);
            string[] textArray2 = textArray1;
            for (int num3 = 0; num3 < textArray2.Length; num3++)
            {
                string text4 = textArray2[num3];
                text3 = text3 + text4 + " ";
            }
            switch (domtype)
            {
            case DomType.SvgMatrix:
            {
                return(new Transf(this.Type + "(" + text3.Trim() + ")").Matrix);
            }

            case DomType.SvgNumber:
            {
                return(ItopVector.Core.Func.Number.parseToFloat(text3.Trim(), (SvgElement)this.ParentNode, ItopVector.Core.Func.SvgLengthDirection.Horizontal));
            }

            case DomType.SvgColor:
            {
                return(text3.Trim());
            }

            case DomType.SvgPath:
            {
                SvgElement element1 = this.RefElement;
                if (element1 is IPath)
                {
                    return(PathFunc.PathDataParse(text3, ((IPath)element1).PointsInfo));
                }
                return(PathFunc.PathDataParse(text3));
            }

            case DomType.SvgPoints:
            {
                return(PointsFunc.PointsParse(text3));
            }
            }
            return(text3.Trim());
        }
Ejemplo n.º 10
0
 internal Shape(string pathstr, string id)
 {
     this.pathString = pathstr;
     this.id         = id;
     this.graphPath  = PathFunc.PathDataParse(pathstr);
 }
Ejemplo n.º 11
0
        public void GradientFillShape(Rectangle rect, int radius, Color startColor, Color endColor, GradientMode gradientMode, GraphicShape shape, RoundedCorners corners)
        {
            if (rect.Width < 1 || rect.Height < 1)
            {
                return;
            }
            PathFunc      func = GetShapeFunc(shape);
            SmoothingMode mode = SmoothingMode;

            try
            {
                SmoothingMode = SmoothingMode.None;
                int x = rect.X, y = rect.Y, w = rect.Width, h = rect.Height;
                int reflectionHeight = h / 2;


                PointF p1            = new PointF(x, y);
                PointF p2            = new PointF(x, y + reflectionHeight);

                if (gradientMode == GradientMode.Top)
                {
                    PathMode pathMode = endColor.A == 255 ? PathMode.Bottom : PathMode.All;
                    using (GraphicsPath path = func(rect, radius, reflectionHeight, pathMode, corners))
                    {
                        using (SolidBrushPlus brush = new SolidBrushPlus(endColor))
                        {
                            this.FillPath(brush, path);
                        }
                    }
                    using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.Top, corners))
                    {
                        using (LinearGradientBrush brush = new LinearGradientBrush(p1, p2, startColor, endColor))
                        {
                            this.FillPath(brush, path);
                        }
                    }
                }
                else
                {
                    PathMode pathMode = endColor.A == 255 ? PathMode.Top : PathMode.All;
                    using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.All, corners))
                    {
                        using (SolidBrushPlus brush = new SolidBrushPlus(endColor))
                        {
                            this.FillPath(brush, path);
                        }
                    }
                    using (GraphicsPath path = func(rect, radius, reflectionHeight, PathMode.Bottom, corners))
                    {
                        p1.Y = y + reflectionHeight - 1;
                        p2.Y = y + h;
                        using (LinearGradientBrush brush = new LinearGradientBrush(p1, p2, endColor, startColor))
                        {
                            this.FillPath(brush, path);
                        }
                    }
                }
            }
            finally
            {
                SmoothingMode = mode;
            }
        }
Ejemplo n.º 12
0
        private void DrawSelection(Graphics g)
        {
//			gra1=g;
            this.selectpath.Reset();
            this.selectMatrix = new Matrix();
            if (((this.svgDocument.CurrentElement is MotionAnimate) && (this.svgDocument.SelectCollection.Count == 1)) && (this.svgDocument.CurrentElement.ParentNode is IGraph))
            {
                this.selectMatrix = ((IGraph)this.svgDocument.CurrentElement.ParentNode).GraphTransform.Matrix.Clone();
            }
            else
            {
                for (int num1 = 0; num1 < this.svgDocument.SelectCollection.Count; num1++)
                {
                    SvgElement element1 = (SvgElement)this.svgDocument.SelectCollection[num1];
                    if ((element1 is IGraph) && (element1 != this.svgDocument.DocumentElement))
                    {
                        if (element1.ParentNode == null)
                        {
                            bool flag1 = true;
                            if ((element1 is Text) && (((Text)element1).EditMode || ((Text)element1).OwnerTextElement.EditMode))
                            {
                                flag1 = false;
                            }
                            if (flag1)
                            {
                                this.svgDocument.SelectCollection.Remove(element1);
                                num1--;
                                goto Label_014B;
                            }
                        }
                        if (!((IGraph)element1).IsLock && ((IGraph)element1).DrawVisible)
                        {
                            GraphicsPath path1 = this.DrawSelectElement((IGraph)element1, g);
                            if ((path1 != null) && (path1.PointCount > 1))
                            {
                                this.selectpath.AddPath(path1, false);
                            }
                        }
                    }
                    Label_014B :;
                }
                if (this.svgDocument.SelectCollection.Count > 1)
                {
                    GraphicsPath path2 = (GraphicsPath)this.selectpath.Clone();

                    selectedViewRectangle = PathFunc.GetBounds(path2);

                    path2.Transform(this.selectMatrix);
                    RectangleF ef1 = PathFunc.GetBounds(path2);
                    this.SelectedRectangle = ef1;
                    Pen pen1 = new Pen(Color.Blue, 1f);  //wl
                    pen1.Alignment = PenAlignment.Outset;
                    GraphicsPath path3 = new GraphicsPath();
                    g.DrawPath(pen1, path2);
                    switch (this.drawArea.Operation)
                    {
                    case ToolOperation.Select:
                    case ToolOperation.WindowZoom:
                    case ToolOperation.Exceptant:
                    {
                        return;
                    }

                    case ToolOperation.ShapeTransform:
                    case ToolOperation.Custom11:
                    case ToolOperation.Custom12:
                    case ToolOperation.Custom13:
                    case ToolOperation.Custom14:
                    case ToolOperation.Custom15:
                    case ToolOperation.Rectangle:
                    case ToolOperation.AngleRectangle:
                    case ToolOperation.InterEnclosure:
                    case ToolOperation.InterEnclosurePrint:
                    case ToolOperation.Circle:
                    case ToolOperation.Ellipse:
                    case ToolOperation.Line:
                    case ToolOperation.PolyLine:
                    case ToolOperation.XPolyLine:
                    case ToolOperation.YPolyLine:
                    case ToolOperation.LeadLine:
                    case ToolOperation.Confines_GuoJie:
                    case ToolOperation.Confines_ShengJie:
                    case ToolOperation.Confines_ShiJie:
                    case ToolOperation.Confines_XianJie:
                    case ToolOperation.Confines_XiangJie:
                    case ToolOperation.Railroad:
                    case ToolOperation.Polygon:
                    case ToolOperation.EqualPolygon:
                    case ToolOperation.Bezier:
                    case ToolOperation.FreeLines:
                    case ToolOperation.Text:
                    case ToolOperation.Image:
                    case ToolOperation.ColorSelect:
                    case ToolOperation.AreaSelect:
                    {
                        return;
                    }

                    case ToolOperation.FreeTransform:
                    case ToolOperation.Rotate:
                    case ToolOperation.Scale:
                    case ToolOperation.Skew:
                    {
                        g.DrawRectangle(new Pen(ControlPaint.Light(Color.Black)), ef1.X, ef1.Y, ef1.Width, ef1.Height);
                        PointF[] tfArray2 = new PointF[8] {
                            new PointF(ef1.X, ef1.Y), new PointF(ef1.X, ef1.Bottom), new PointF(ef1.X, ef1.Y + (ef1.Height / 2f)), new PointF(ef1.X + (ef1.Width / 2f), ef1.Y), new PointF(ef1.Right, ef1.Y), new PointF(ef1.Right, ef1.Y + (ef1.Height / 2f)), new PointF(ef1.Right, ef1.Bottom), new PointF(ef1.X + (ef1.Width / 2f), ef1.Bottom)
                        };
                        PointF[] tfArray1 = tfArray2;
                        path3.Reset();
                        PointF[] tfArray3 = tfArray1;
                        for (int num2 = 0; num2 < tfArray3.Length; num2++)
                        {
                            PointF tf1 = tfArray3[num2];
                            path3.AddRectangle(new RectangleF(tf1.X - 3f, tf1.Y - 3f, 5f, 5f));
                            path3.CloseFigure();
                        }
                        g.FillPath(Brushes.White, path3);
                        g.DrawPath(new Pen(ControlPaint.Light(Color.Blue)), path3);
                        return;
                    }

                    case ToolOperation.Roam:
                    case ToolOperation.IncreaseView:
                    case ToolOperation.DecreaseView:
                    case ToolOperation.None:
                    {
                        return;
                    }
                    }
                    path2.Dispose();
                    path3.Dispose();
                }
            }
        }
Ejemplo n.º 13
0
        private GraphicsPath DrawSelectElement(IGraph path, Graphics g)
        {
            if (!path.DrawVisible)
            {
                return(new GraphicsPath());
            }
            if ((path is Text) && ((((Text)path).EditMode || ((Text)path).OwnerTextElement.EditMode) || ((path is TRef) || (path is TSpan))))
            {
                return(new GraphicsPath());
            }
            GraphicsPath path1 = (GraphicsPath)path.GPath.Clone();
            RectangleF   ef1   = PathFunc.GetBounds(path1);
            Pen          pen1;

            if (tempPen == null)
            {
                pen1 = new Pen(ControlPaint.Light(Color.Blue), 1f);               //wl
            }
            else
            {
                pen1 = tempPen;
            }
            pen1.Alignment = PenAlignment.Outset;
            GraphicsPath path2   = new GraphicsPath();
            Matrix       matrix1 = path.GraphTransform.Matrix.Clone();

            path1.Transform(matrix1);
            g.DrawPath(pen1, path1);
            switch (this.drawArea.Operation)
            {
            case ToolOperation.FreeTransform:
            case ToolOperation.Rotate:
            case ToolOperation.Scale:
            case ToolOperation.Skew:
            {
                if (this.svgDocument.SelectCollection.Count == 1)
                {
                    PointF[]   tfArray1;
                    RectangleF ef2 = PathFunc.GetBounds(path.GPath);
                    path2.AddRectangle(ef2);
                    path2.Transform(matrix1);
                    g.DrawPath(new Pen(ControlPaint.Light(Color.Blue)), path2);
                    tfArray1 = new PointF[8] {
                        new PointF(ef1.X, ef1.Y), new PointF(ef1.X, ef1.Bottom), new PointF(ef1.X, ef1.Y + (ef1.Height / 2f)), new PointF(ef1.X + (ef1.Width / 2f), ef1.Y), new PointF(ef1.Right, ef1.Y), new PointF(ef1.Right, ef1.Y + (ef1.Height / 2f)), new PointF(ef1.Right, ef1.Bottom), new PointF(ef1.X + (ef1.Width / 2f), ef1.Bottom)
                    };
                    this.Bouns = tfArray1;
                    path.GraphTransform.Matrix.TransformPoints(tfArray1);
                    path2.Reset();
                    for (int num1 = 0; num1 < tfArray1.Length; num1++)
                    {
                        PointF tf1 = tfArray1[num1];
                        path2.AddRectangle(new RectangleF(tf1.X - 3f, tf1.Y - 3f, 5f, 5f));
                        path2.CloseFigure();
                    }
                    g.FillPath(Brushes.White, path2);
                    g.DrawPath(new Pen(ControlPaint.Light(Color.Blue)), path2);
                }
                break;
            }
            }
            if (this.svgDocument.SelectCollection.Count > 1)
            {
                Matrix matrix2 = path.GraphTransform.Matrix.Clone();
                this.selectMatrix = this.drawArea.CoordTransform.Clone();
                Matrix matrix3 = this.selectMatrix.Clone();
                matrix3.Invert();
                matrix2.Multiply(matrix3, MatrixOrder.Append);
                GraphicsPath path3 = (GraphicsPath)path.GPath.Clone();
                path3.Transform(matrix2);
                matrix2.Dispose();
                matrix3.Dispose();
                return(path3);
            }

            this.selectMatrix = path.GraphTransform.Matrix.Clone();
            path1.Dispose();
            matrix1.Dispose();


            return((GraphicsPath)path.GPath.Clone());
        }
Ejemplo n.º 14
0
        public void Paint(GraphicsPath path, Graphics g, int time, float opacity)
        {
            int num1 = 0;
            int num2 = 0;
            GraphicsContainer container1 = g.BeginContainer();

            AnimFunc.CreateAnimateValues(this, time, out num1, out num2);
            g.SmoothingMode = base.OwnerDocument.SmoothingMode;
            SpreadMethods methods1 = this.SpreadMethod;
            bool          flag1    = this.Units == Units.UserSpaceOnUse;
            float         single1  = this.X1;
            float         single2  = this.Y1;
            float         single3  = this.X2;
            float         single4  = this.Y2;

            if ((single1 == single3) && (single2 == single4))
            {
                single1 -= 1E-05f;
                single3 += 1E-05f;
            }
            float      single5 = single1;
            float      single6 = single2;
            float      single7 = single3;
            float      single8 = single4;
            RectangleF ef1     = RectangleF.Empty;
            RectangleF ef2     = RectangleF.Empty;
            Matrix     matrix1 = this.Transform.Matrix.Clone();

            PointF[] tfArray4 = new PointF[2] {
                new PointF(single1, single2), new PointF(single3, single4)
            };
            PointF[] tfArray1 = tfArray4;
            matrix1.TransformPoints(tfArray1);
            single1 = tfArray1[0].X;
            single3 = tfArray1[1].X;
            single2 = tfArray1[0].Y;
            single4 = tfArray1[1].Y;
            bool  flag2   = single2 == single4;
            bool  flag3   = single1 == single3;
            float single9 = 1f;

            this.coord       = new Matrix();
            this.ratiomatrix = new Matrix();
            RectangleF ef3 = PathFunc.GetBounds(path);

            if (flag1)
            {
                ef1 = ((SVG)base.OwnerDocument.DocumentElement).ViewPort;
            }
            else
            {
                ef3 = new RectangleF(0f, 0f, 1f, 1f);
                ef1 = ef3;
                ef2 = PathFunc.GetBounds(path);
                this.coord.Translate(ef2.X, ef2.Y);
                this.coord.Scale(ef2.Width, ef2.Width);
                this.ratiomatrix.Scale(1f, ef2.Height / ef2.Width);
            }
            PointF     tf1    = new PointF(single1, single2);
            PointF     tf2    = new PointF(single3, single4);
            PointF     tf3    = tf1;
            PointF     tf4    = tf2;
            ColorBlend blend1 = new ColorBlend(this.Stops.Count);

            Color[] colorArray1              = new Color[this.Stops.Count];
            float[] singleArray1             = new float[this.Stops.Count];
            SvgElementCollection collection1 = this.Stops;

            for (int num3 = 0; num3 < collection1.Count; num3++)
            {
                GradientStop stop1 = (GradientStop)collection1[num3];
                AnimFunc.CreateAnimateValues(stop1, time, out num1, out num2);
                int num4 = 0xff;
                if ((stop1.Opacity >= 0f) && (stop1.Opacity <= 255f))
                {
                    if (stop1.Opacity <= 1f)
                    {
                        num4 = (int)(stop1.Opacity * 255f);
                    }
                    else
                    {
                        num4 = (int)stop1.Opacity;
                    }
                }
                num4 = (int)Math.Min((float)(opacity * 255f), (float)num4);
                Color color1   = stop1.Color;
                float single10 = Math.Min((float)1f, Math.Max((float)0f, stop1.ColorOffset));
                colorArray1[num3]  = Color.FromArgb(num4, color1.R, color1.G, color1.B);
                singleArray1[num3] = single10;
            }
            float[] singleArray2 = (float[])singleArray1.Clone();
            Color[] colorArray2  = (Color[])colorArray1.Clone();
            Array.Sort(singleArray2, colorArray2);
            Color color2   = colorArray2[0];
            Color color3   = colorArray2[colorArray2.Length - 1];
            float single11 = singleArray2[0];
            float single12 = singleArray2[singleArray2.Length - 1];

            if (singleArray2[0] != 0f)
            {
                float[] singleArray3 = (float[])singleArray2.Clone();
                Color[] colorArray3  = (Color[])colorArray2.Clone();
                singleArray2 = new float[singleArray2.Length + 1];
                colorArray2  = new Color[colorArray2.Length + 1];
                colorArray3.CopyTo(colorArray2, 1);
                singleArray3.CopyTo(singleArray2, 1);
                singleArray2[0] = 0f;
                colorArray2[0]  = color2;
            }
            if (singleArray2[singleArray2.Length - 1] != 1f)
            {
                float[] singleArray4 = (float[])singleArray2.Clone();
                Color[] colorArray4  = (Color[])colorArray2.Clone();
                singleArray2 = new float[singleArray2.Length + 1];
                singleArray4.CopyTo(singleArray2, 0);
                singleArray2[singleArray2.Length - 1] = 1f;
                colorArray2 = new Color[colorArray2.Length + 1];
                colorArray4.CopyTo(colorArray2, 0);
                colorArray2[colorArray2.Length - 1] = color3;
            }
            PointF[] tfArray2 = new PointF[1];
            PointF[] tfArray3 = new PointF[4];
            if (methods1 == SpreadMethods.Pad)
            {
                if (flag2)
                {
                    tf1 = new PointF(Math.Min(single1, ef3.X), tf1.Y);
                    tf2 = new PointF(Math.Max(single3, ef3.Right), tf2.Y);
                    float single13 = single1;
                    float single14 = single3 - single1;
                    for (int num5 = 0; num5 < singleArray2.Length; num5++)
                    {
                        singleArray2[num5] = ((single13 + (single14 * singleArray2[num5])) - tf1.X) / (tf2.X - tf1.X);
                    }
                }
                else if (flag3)
                {
                    tf1 = new PointF(tf1.X, Math.Min(single2, ef3.Y));
                    tf2 = new PointF(tf2.X, Math.Max(single4, ef3.Bottom));
                    float single15 = single2;
                    float single16 = single4 - single2;
                    for (int num6 = 0; num6 < singleArray2.Length; num6++)
                    {
                        singleArray2[num6] = ((single15 + (single16 * singleArray2[num6])) - tf1.Y) / (tf2.Y - tf1.Y);
                    }
                }
                else
                {
                    single9 = (single4 - single2) / (single3 - single1);
                    float    single17 = (single2 - (single9 * single1)) / (1f + (single9 * single9));
                    PointF   tf5      = ef3.Location;
                    PointF   tf6      = new PointF(ef3.Right, ef3.Y);
                    PointF   tf7      = new PointF(ef3.Right, ef3.Bottom);
                    PointF   tf8      = new PointF(ef3.X, ef3.Bottom);
                    PointF[] tfArray5 = new PointF[4] {
                        tf5, tf6, tf7, tf8
                    };
                    tfArray2 = tfArray5;
                    for (int num7 = 0; num7 < tfArray2.Length; num7++)
                    {
                        PointF tf9      = tfArray2[num7];
                        float  single18 = ((((single9 * single9) * tf9.Y) + (single9 * tf9.X)) / (1f + (single9 * single9))) + single17;
                        float  single19 = (single9 * (tf9.Y - single18)) + tf9.X;
                        tfArray3[num7] = new PointF(single19, single18);
                        if (single1 < single3)
                        {
                            if (single19 < tf1.X)
                            {
                                tf1 = new PointF(single19, single18);
                            }
                            else if (single19 > tf2.X)
                            {
                                tf2 = new PointF(single19, single18);
                            }
                        }
                        else if (single19 < tf2.X)
                        {
                            tf2 = new PointF(single19, single18);
                        }
                        else if (single19 > tf1.X)
                        {
                            tf1 = new PointF(single19, single18);
                        }
                    }
                    float single20 = single1;
                    float single21 = single3 - single1;
                    for (int num8 = 0; num8 < singleArray2.Length; num8++)
                    {
                        singleArray2[num8] = ((single20 + (single21 * singleArray2[num8])) - tf1.X) / (tf2.X - tf1.X);
                    }
                }
                if (singleArray2[0] != 0f)
                {
                    float[] singleArray5 = (float[])singleArray2.Clone();
                    Color[] colorArray5  = (Color[])colorArray2.Clone();
                    singleArray2 = new float[singleArray2.Length + 1];
                    colorArray2  = new Color[colorArray2.Length + 1];
                    colorArray5.CopyTo(colorArray2, 1);
                    singleArray5.CopyTo(singleArray2, 1);
                    singleArray2[0] = 0f;
                    colorArray2[0]  = color2;
                }
                if (singleArray2[singleArray2.Length - 1] != 1f)
                {
                    float[] singleArray6 = (float[])singleArray2.Clone();
                    Color[] colorArray6  = (Color[])colorArray2.Clone();
                    singleArray2 = new float[singleArray2.Length + 1];
                    singleArray6.CopyTo(singleArray2, 0);
                    singleArray2[singleArray2.Length - 1] = 1f;
                    colorArray2 = new Color[colorArray2.Length + 1];
                    colorArray6.CopyTo(colorArray2, 0);
                    colorArray2[colorArray2.Length - 1] = color3;
                }
            }
            this.brush = new LinearGradientBrush(tf1, tf2, color2, color3);
            if (methods1 == SpreadMethods.Reflect)
            {
                this.brush.WrapMode = WrapMode.TileFlipXY;
            }
            else
            {
                this.brush.WrapMode = WrapMode.Tile;
            }
            blend1.Colors    = colorArray2;
            blend1.Positions = singleArray2;
            this.brush.InterpolationColors = blend1;
            this.coord.Multiply(this.ratiomatrix);
            GraphicsContainer container2 = g.BeginContainer();

            g.Transform = this.coord;
            Matrix matrix2 = this.coord.Clone();

            matrix2.Invert();
            GraphicsPath path1 = (GraphicsPath)path.Clone();

            path1.Transform(matrix2);
            g.FillPath(this.brush, path1);
            g.EndContainer(container2);
            if (!base.OwnerDocument.PlayAnim)
            {
                this.gradientpath = new GraphicsPath();
                PointF[] tfArray6 = new PointF[8] {
                    new PointF((single5 + single7) / 2f, ((single6 + single8) / 2f) + 0.5f), new PointF(single7, single8 + 0.5f), new PointF(single7, single8), PointF.Empty, new PointF(single7, ((single6 + single8) / 2f) + 1f), PointF.Empty, PointF.Empty, PointF.Empty
                };
                this.boundsPoints = tfArray6;
                this.gradientpath.AddLine(new PointF(single5, single6), new PointF(single5, single6 + 1f));
                this.gradientpath.StartFigure();
                this.gradientpath.AddLine(new PointF(single7, single8), new PointF(single7, single8 + 1f));
            }
            this.pretime = time;
            g.EndContainer(container1);
        }