Example #1
0
 public void UnGroup2(ItopVector.Core.Figure.Group group)
 {
     if (group.ParentNode is ItopVector.Core.Figure.Group)
     {
         string LayerID=group.GetAttribute("layer");
         XmlNode node1 = group.PreviousSibling;
         while (!(node1 is SvgElement) && (node1 != null))
         {
             node1 = node1.PreviousSibling;
         }
         SvgElementCollection collection1 = group.GraphList;
         SvgDocument document1 = this.SVGDocument;
         document1.NumberOfUndoOperations += ((2*collection1.Count) + 500);
         ItopVector.Core.Figure.Group group1 = (ItopVector.Core.Figure.Group) group.ParentNode;
         Matrix matrix1 = group.Transform.Matrix.Clone();
         for (int num1 = collection1.Count - 1; num1 >= 0; num1--)
         {
             SvgElement element1 = (SvgElement) collection1[num1];
             if (element1 is IGraph)
             {
                 Matrix matrix2 = new Matrix();
                 if (element1.SvgAttributes.ContainsKey("transform"))
                 {
                     matrix2 = ((Matrix) element1.SvgAttributes["transform"]).Clone();
                 }
                 matrix2.Multiply(matrix1, MatrixOrder.Append);
                 Transf transf1 = new Transf();
                 transf1.setMatrix(matrix2);
                 string text1 = transf1.ToString();
                 AttributeFunc.SetAttributeValue(element1, "transform", text1);
     //						AttributeFunc.SetAttributeValue(element1, "layer", LayerID);
             }
             element1.AllowRename =false;
             if (node1 != null)
             {
                 group1.InsertAfter(element1, node1);
             }
             else
             {
                 group1.PrependChild(element1);
             }
             element1.AllowRename =true;
         }
         group1.RemoveChild(group);
         this.SVGDocument.NotifyUndo();
     }
 }
Example #2
0
        public SvgElement AddElement(ISvgElement mypath)
        {
            //			AttributeFunc.SetAttributeValue((XmlElement)mypath,"layer",SvgDocument.currentLayer);
            XmlNode node1 = OwnerDocument.RootElement;
            XmlNode newNode =null;

                Matrix matrix1 = new Matrix();
            //				if (node1 is IGraph)
            //				{
            //					matrix1 = ((IGraph) node1).GraphTransform.Matrix.Clone();
            //					Matrix matrix2 = this.coordTransform.Clone();
            //					matrix2.Invert();
            //					matrix1.Multiply(matrix2, MatrixOrder.Append);
            //				}
            //				matrix1.Invert();
            //				matrix1 = TransformFunc.RoundMatrix(matrix1, 2);
                bool flag1 = OwnerDocument.AcceptChanges;
                //				OwnerDocument.AcceptChanges = false;
                OwnerDocument.AcceptChanges = true;
                if (mypath is IGraphPath)
                {
                    ISvgBrush brush1 = ((IGraphPath) mypath).GraphBrush;
                    if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null))
                    {
                        bool flag2 = OwnerDocument.AcceptChanges;
                        OwnerDocument.AcceptChanges = true;
                        OwnerDocument.NumberOfUndoOperations++;
                        XmlNode node2 = OwnerDocument.AddDefsElement((SvgElement) brush1);
                        OwnerDocument.AcceptChanges = false;
                        if (node2 is ITransformBrush)
                        {
                            string text1 = ((SvgElement) node2).ID;
                            AttributeFunc.SetAttributeValue((SvgElement) mypath, "fill", "url(#" + text1 + ")");
                        }
                        OwnerDocument.AcceptChanges = flag2;
                    }
                    brush1 = ((IGraphPath) mypath).GraphStroke.Brush;
                    if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null))
                    {
                        bool flag3 = OwnerDocument.AcceptChanges;
                        OwnerDocument.AcceptChanges = true;
                        OwnerDocument.NumberOfUndoOperations++;
                        XmlNode node3 = OwnerDocument.AddDefsElement((SvgElement) brush1);
                        OwnerDocument.AcceptChanges = false;
                        if (node3 is ITransformBrush)
                        {
                            string text2 = ((SvgElement) node3).ID;
                            AttributeFunc.SetAttributeValue((SvgElement) mypath, "stroke", "url(#" + text2 + ")");
                        }
                        OwnerDocument.AcceptChanges = flag3;
                    }
                }
                if (!matrix1.IsIdentity && (mypath is IGraph))
                {
                    bool flag4 = OwnerDocument.AcceptChanges;
                    OwnerDocument.AcceptChanges = false;
                    Matrix matrix3 = ((IGraph) mypath).Transform.Matrix.Clone();
                    matrix1.Multiply(matrix3);
                    Transf transf1 = new Transf();
                    transf1.setMatrix(matrix1);
                    AttributeFunc.SetAttributeValue((SvgElement) mypath, "transform", transf1.ToString());
                    OwnerDocument.AcceptChanges = flag4;
                }
                if (((SvgElement) mypath).ParentNode != node1)
                {
                    if (((ContainerElement) node1).IsValidChild((SvgElement) mypath))
                    {
                        //						node1.AppendChild((SvgElement) mypath);
                        SvgElement element1 =(SvgElement) mypath;//(SvgElement)OwnerDocument.ImportNode((SvgElement) mypath,true);
                        newNode = node1.AppendChild(element1);
                        OwnerDocument.Render(element1);
                    }
                }
                OwnerDocument.AcceptChanges = flag1;

            return newNode!=null?newNode as SvgElement:null;
        }
Example #3
0
        public void OnMouseUp(MouseEventArgs e)
        {
            if ((this.activeGraph == null) || (this.mouseAreaControl.Cursor == this.mouseAreaControl.DefaultCursor))
            {
                return;
            }
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            if (!(this.mouseAreaControl.SVGDocument.CurrentElement is ITransformBrush))
            {
                return;
            }
            ISvgBrush brush1 = (ISvgBrush) this.mouseAreaControl.SVGDocument.CurrentElement;
            if (brush1 is SolidColor)
            {
                return;
            }
            SizeF ef1 = this.mouseAreaControl.PicturePanel.GridSize;
            float single1 = ef1.Width;
            float single2 = ef1.Height;
            this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle);
            this.win32.W32SetROP2(6);
            this.win32.W32PolyDraw(this.reversePath);
            this.win32.ReleaseDC();
            float single3 = this.mouseAreaControl.PicturePanel.ScaleUnit;
            PointF tf1 = this.mouseAreaControl.PicturePanel.PointToView(this.startPoint);
            PointF tf2 = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float) e.X, (float) e.Y));
            if (this.mouseAreaControl.PicturePanel.SnapToGrid)
            {
                int num1 = (int) ((tf1.X + (single1 / 2f)) / single1);
                int num2 = (int) ((tf1.Y + (single2 / 2f)) / single2);
                tf1 = (PointF) new Point((int) (num1 * single1), (int) (num2 * single2));
                num1 = (int) ((tf2.X + (single1 / 2f)) / single1);
                num2 = (int) ((tf2.Y + (single2 / 2f)) / single2);
                tf2 = (PointF) new Point((int) (num1 * single1), (int) (single2 * num2));
            }
            tf1 = this.mouseAreaControl.PicturePanel.PointToSystem(tf1);
            tf2 = this.mouseAreaControl.PicturePanel.PointToSystem(tf2);
            this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle);
            this.win32.W32SetROP2(6);
            this.win32.W32PolyDraw(this.reversePath);
            this.win32.ReleaseDC();
            Transf transf1 = new Transf();
            transf1 = ((ITransformBrush) brush1).Transform;
            SvgElement element1 = (SvgElement) brush1;
            ITransformBrush brush2 = (ITransformBrush) brush1;
            bool flag1 = brush2.Units == Units.UserSpaceOnUse;
            SvgDocument document1 = this.mouseAreaControl.SVGDocument;
            if (((((this.mouseAreaControl.Cursor == SpecialCursors.VScaleCursor) | (this.mouseAreaControl.Cursor == SpecialCursors.HScaleCursor)) | (this.mouseAreaControl.Cursor == SpecialCursors.TopRightScaleCursor)) | (this.mouseAreaControl.Cursor == SpecialCursors.EqualScaleCursor)) && (this.controlPoints.Length >= 6))
            {
                //string text11;
                PointF[] tfArray5 = new PointF[5] { tf1, tf2, this.controlPoints[0], this.controlPoints[1], this.controlPoints[5] } ;
                PointF[] tfArray1 = tfArray5;
                Matrix matrix1 = this.graphMatrix.Clone();
                matrix1.Multiply(this.gradientMatrix);
                matrix1.Invert();
                matrix1.TransformPoints(tfArray1);
                float single4 = 1f;
                if (tfArray1[3].X != tfArray1[2].X)
                {
                    single4 = 1f + ((tfArray1[1].X - tfArray1[0].X) / (tfArray1[3].X - tfArray1[2].X));
                }
                float single5 = 1f;
                if (tfArray1[4].Y != tfArray1[2].Y)
                {
                    single5 = 1f + ((tfArray1[1].Y - tfArray1[0].Y) / (tfArray1[4].Y - tfArray1[2].Y));
                }
                if (this.mouseAreaControl.Cursor == SpecialCursors.VScaleCursor)
                {
                    single5 = 1f;
                }
                else if (this.mouseAreaControl.Cursor == SpecialCursors.HScaleCursor)
                {
                    single4 = 1f;
                }
                else if (this.mouseAreaControl.Cursor == SpecialCursors.EqualScaleCursor)
                {
                    single5 = single4;
                }
                if ((element1.InfoList.Count == 1))
                {
                    if (flag1)
                    {
                        transf1.setTranslate(this.centerPoint.X, this.centerPoint.Y);
                    }
                    else
                    {
                        transf1.setTranslate(0.5f, 0.5f);
                    }
                    transf1.setScale(single4, single5);
                    if (flag1)
                    {
                        transf1.setTranslate(-this.centerPoint.X, -this.centerPoint.Y);
                    }
                    else
                    {
                        transf1.setTranslate(-0.5f, -0.5f);
                    }
                    string text1 = transf1.ToString();
                    string text2 = "gradientTransform";
                    if (brush2 is Pattern)
                    {
                        text2 = "patternTransform";
                    }
                    bool flag2 = document1.AcceptChanges;
                    document1.AcceptChanges = true;
                    document1.NumberOfUndoOperations = 1;
                    AttributeFunc.SetAttributeValue(element1, text2, text1);
                    document1.AcceptChanges = flag2;
                    element1.pretime = -1;
                    goto Label_1771;
                }

            }
            if ((this.mouseAreaControl.Cursor == SpecialCursors.SkewXCursor) || (this.mouseAreaControl.Cursor == SpecialCursors.SkewYCursor))
            {
                //string text16;
                PointF[] tfArray6 = new PointF[5] { tf1, tf2, this.controlPoints[0], this.controlPoints[3], this.controlPoints[4] } ;
                PointF[] tfArray2 = tfArray6;
                Matrix matrix2 = this.graphMatrix.Clone();
                matrix2.Multiply(this.gradientMatrix);
                matrix2.Invert();
                matrix2.TransformPoints(tfArray2);
                float single6 = 0f;
                if (tfArray2[3].Y != tfArray2[2].Y)
                {
                    single6 = ((tfArray2[1].X - tfArray2[0].X) / (tfArray2[3].Y - tfArray2[2].Y)) * 0.5f;
                }
                float single7 = 0f;
                if (tfArray2[4].X != tfArray2[2].X)
                {
                    single7 = ((tfArray2[1].Y - tfArray2[0].Y) / (tfArray2[4].X - tfArray2[2].X)) * 0.5f;
                }
                if (this.mouseAreaControl.Cursor == SpecialCursors.SkewXCursor)
                {
                    single7 = 0f;
                }
                else if (this.mouseAreaControl.Cursor == SpecialCursors.SkewYCursor)
                {
                    single6 = 0f;
                }
                if ( (element1.InfoList.Count == 1))
                {
                    if (flag1)
                    {
                        transf1.setTranslate(this.centerPoint.X, this.centerPoint.Y);
                    }
                    else
                    {
                        transf1.setTranslate(0.5f, 0.5f);
                    }
                    transf1.Matrix.Shear(single6, single7);
                    if (flag1)
                    {
                        transf1.setTranslate(-this.centerPoint.X, -this.centerPoint.Y);
                    }
                    else
                    {
                        transf1.setTranslate(-0.5f, -0.5f);
                    }
                    string text3 = transf1.ToString();
                    string text4 = "gradientTransform";
                    if (brush2 is Pattern)
                    {
                        text4 = "patternTransform";
                    }
                    bool flag4 = document1.AcceptChanges;
                    document1.AcceptChanges = true;
                    document1.NumberOfUndoOperations = 1;
                    AttributeFunc.SetAttributeValue(element1, text4, text3);
                    document1.AcceptChanges = flag4;
                    element1.pretime = -1;
                    goto Label_1771;
                }

            }
            if (this.mouseAreaControl.Cursor == SpecialCursors.RotateCursor)
            {
                //string text19;
                PointF tf3 = this.controlPoints[0];
                float single8 = (float) Math.Atan((double) ((tf1.Y - tf3.Y) / (tf1.X - tf3.X)));
                float single9 = (float) Math.Atan((double) ((tf2.Y - tf3.Y) / (tf2.X - tf3.X)));
                float single10 = ((float) (((double) (single9 - single8)) / 3.1415926535897931)) * 180f;
                if (((tf2.X - tf3.X) * (tf1.X - tf3.X)) < 0f)
                {
                    single10 += 180f;
                }
                if (single10 < 0f)
                {
                    single10 += 360f;
                }
                PointF[] tfArray7 = new PointF[1] { new PointF(0.5f, 0.5f) } ;
                PointF[] tfArray3 = tfArray7;
                if (flag1)
                {
                    PointF[] tfArray8 = new PointF[1] { this.centerPoint } ;
                    tfArray3 = tfArray8;
                }
                this.gradientMatrix.TransformPoints(tfArray3);
                if ( (element1.InfoList.Count == 1))
                {
                    transf1.Matrix.RotateAt(single10, tfArray3[0], MatrixOrder.Append);
                    string text5 = transf1.ToString();
                    string text6 = "gradientTransform";
                    if (brush2 is Pattern)
                    {
                        text6 = "patternTransform";
                    }
                    bool flag6 = document1.AcceptChanges;
                    document1.AcceptChanges = true;
                    AttributeFunc.SetAttributeValue(element1, text6, text5);
                    document1.AcceptChanges = flag6;
                    element1.pretime = -1;
                    goto Label_1771;
                }

            }
            else if (this.mouseAreaControl.Cursor == SpecialCursors.GradientTranslateCursor)
            {
                PointF[] tfArray9 = new PointF[5] { tf1, tf2, this.controlPoints[0], this.controlPoints[1], this.controlPoints[4] } ;
                PointF[] tfArray4 = tfArray9;
                Matrix matrix3 = this.graphMatrix.Clone();
                matrix3.Multiply(this.gradientMatrix);
                matrix3.Invert();
                matrix3.TransformPoints(tfArray4);
                float single11 = tfArray4[1].X - tfArray4[0].X;
                if (!flag1)
                {
                    single11 /= (tfArray4[3].X - tfArray4[2].X);
                }
                else
                {
                    single11 *= 2f;
                }
                float single12 = tfArray4[1].Y - tfArray4[0].Y;
                if (!flag1)
                {
                    single12 /= (tfArray4[4].Y - tfArray4[2].Y);
                }
                else
                {
                    single12 *= 2f;
                }
                single11 /= 2f;
                single12 /= 2f;
                if (element1.InfoList.Count == 1)
                {
                    transf1.setTranslate(single11, single12);
                    string text7 = transf1.ToString();
                    string text8 = "gradientTransform";
                    if (brush2 is Pattern)
                    {
                        text8 = "patternTransform";
                    }
                    bool flag7 = document1.AcceptChanges;
                    document1.AcceptChanges = true;
                    AttributeFunc.SetAttributeValue(element1, text8, text7);
                    document1.AcceptChanges = flag7;
                    element1.pretime = -1;
                }

            }
            Label_1771:
            this.mouseAreaControl.Invalidate();
        }
Example #4
0
 private int Break(SvgElement graph, SvgElement parent, XmlNode next)
 {
     if (graph is Group)
     {
         if (graph is Text)
         {
             Graphics graphics1 = base.CreateGraphics();
             SvgElementCollection collection1 = ((Text) graph).Break(graphics1);
             graphics1.Dispose();
             SvgElementCollection.ISvgElementEnumerator enumerator1 = collection1.GetEnumerator();
             while (enumerator1.MoveNext())
             {
                 SvgElement element1 = (SvgElement) enumerator1.Current;
                 this.svgDocument.NumberOfUndoOperations++;
                 element1.ID = CodeFunc.CreateString(this.svgDocument, "text");
                 ISvgBrush brush1 = ((IGraphPath) element1).GraphBrush;
                 if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null))
                 {
                     string text1 = CodeFunc.CreateString(this.svgDocument, ((SvgElement) brush1).Name);
                     AttributeFunc.SetAttributeValue(element1, "fill", "url(#" + text1 + ")");
                     AttributeFunc.SetAttributeValue((SvgElement) brush1, "id", text1);
                     this.svgDocument.NumberOfUndoOperations++;
                     this.SVGDocument.AddDefsElement((SvgElement) brush1);
                 }
                 brush1 = ((IGraphPath) element1).GraphStroke.Brush;
                 if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null))
                 {
                     string text2 = CodeFunc.CreateString(this.svgDocument, ((SvgElement) brush1).Name);
                     AttributeFunc.SetAttributeValue(element1, "stroke", "url(#" + text2 + ")");
                     AttributeFunc.SetAttributeValue((SvgElement) brush1, "id", text2);
                     this.svgDocument.NumberOfUndoOperations++;
                     this.SVGDocument.AddDefsElement((SvgElement) brush1);
                 }
                 if (next == null)
                 {
                     parent.AppendChild(element1);
                     continue;
                 }
                 parent.InsertBefore(element1, next);
             }
             this.svgDocument.NumberOfUndoOperations++;
             graph.ParentNode.RemoveChild(graph);
         }
         else
         {
             SvgElementCollection collection2 = ((Group) graph).GraphList.Clone();
             for (int num1 = collection2.Count - 1; num1 >= 0; num1--)
             {
                 SvgElement element2 = (SvgElement) collection2[num1];
                 Matrix matrix1 = new Matrix();
                 Matrix matrix2 = new Matrix();
                 if (element2 is IGraph)
                 {
                     if (graph.SvgAttributes.ContainsKey("transform"))
                     {
                         matrix1 = ((Matrix) graph.SvgAttributes["transform"]).Clone();
                     }
                     if (element2.SvgAttributes.ContainsKey("transform"))
                     {
                         matrix2 = ((Matrix) graph.SvgAttributes["transform"]).Clone();
                     }
                     matrix1.Multiply(matrix2);
                     Transf transf1 = new Transf();
                     transf1.setMatrix(matrix1);
                     AttributeFunc.SetAttributeValue(element2, "transform", transf1.ToString());
                 }
                 this.Break(element2, parent, next);
             }
             graph.ParentNode.RemoveChild(graph);
         }
         return 1;
     }
     if ((graph is IGraph) && (graph.ParentNode != parent))
     {
         this.svgDocument.NumberOfUndoOperations += 2;
         if (next != null)
         {
             parent.InsertBefore(graph.Clone(), next);
         }
         else
         {
             parent.PrependChild(graph.Clone());
         }
         return 0;
     }
     return 0;
 }
Example #5
0
        private IGraph CreateGraph(PointF startpoint, PointF endpoint, ToolOperation operation)
        {
            SvgDocument document1 = this.mouseAreaControl.SVGDocument;
            if (document1 == null)
            {
                return null;
            }
            bool flag1 = document1.AcceptChanges;
            document1.AcceptChanges = false;
            IGraph graph1 = this.mouseAreaControl.PicturePanel.PreGraph;
            if (graph1 == null)
            {
                return null;
            }
            IGraph graph2 = (IGraph) ((SvgElement) graph1).Clone();
            if ((operation == ToolOperation.Ellipse) && ((Control.ModifierKeys == Keys.Shift) || (Control.ModifierKeys == (Keys.Control | Keys.Shift))))
            {
                graph2 = (Circle) document1.CreateElement(document1.Prefix, "circle", document1.NamespaceURI);
                foreach (XmlAttribute attribute1 in ((SvgElement) graph1).Attributes)
                {
                    ((SvgElement) graph2).SetAttributeNode((XmlAttribute) attribute1.Clone());
                }
            }
            if (((SvgElement) graph1) is IGraphPath)
            {
                if ((((SvgElement) graph1).GetAttribute("style") != string.Empty) && (((SvgElement) graph1).GetAttribute("style") != null))
                {
                    this.mouseAreaControl.SVGDocument.AcceptChanges = false;
                    AttributeFunc.SetAttributeValue((SvgElement) graph2, "style", ((SvgElement) graph1).GetAttribute("style"));
                }
                ISvgBrush brush1 = ((IGraphPath) graph1).GraphBrush;
                if (brush1 is SvgElement)
                {
                    ISvgBrush brush2 = (ISvgBrush) ((SvgElement) brush1).Clone();
                    ((IGraphPath) graph2).GraphBrush = brush2;
                    ((SvgElement) brush2).pretime = -1;
                }
                else
                {
                    ((IGraphPath) graph2).GraphBrush = brush1;
                }
                brush1 = ((IGraphPath) graph1).GraphStroke.Brush;
                if (brush1 is SvgElement)
                {
                    ISvgBrush brush3 = (ISvgBrush) ((SvgElement) brush1).Clone();
                    ((IGraphPath) graph2).GraphStroke = new Stroke(brush3);
                    ((SvgElement) brush3).pretime = -1;
                }
                else
                {
                    ((IGraphPath) graph2).GraphStroke.Brush = brush1;
                }
            }
            if (document1 == null)
            {
                return null;
            }
            PointF point1 = this.mouseAreaControl.PicturePanel.PointToView(startpoint);
            PointF point2 = this.mouseAreaControl.PicturePanel.PointToView(endpoint);
            float single1 = this.mouseAreaControl.PicturePanel.ScaleUnit;
            SizeF ef1 = this.mouseAreaControl.PicturePanel.GridSize;
            float single2 = ef1.Height;
            float single3 = ef1.Width;
            if (this.mouseAreaControl.PicturePanel.SnapToGrid)
            {
                int num1 = (int) ((point1.X + (single3 / 2f)) / single3);
                int num2 = (int) ((point1.Y + (single2 / 2f)) / single2);
                point1 = new Point((int) (num1 * single3), (int) (num2 * single2));
                num1 = (int) ((point2.X + (single3 / 2f)) / single3);
                num2 = (int) ((point2.Y + (single2 / 2f)) / single2);
                point2 = new Point((int) (num1 * single3), (int) (single2 * num2));
            }
            float single4 = Math.Min(point1.X, point2.X);
            float single5 = Math.Min(point1.Y, point2.Y);
            float single6 = Math.Max(point1.X, point2.X);
            float single7 = Math.Max(point1.Y, point2.Y);
            float single8 = single6 - single4;
            float single9 = single7 - single5;
            switch (operation)
            {
                case ToolOperation.AngleRectangle:
                {
                    float single10 = 0f;
                    single10 = Math.Max(0, ((ItopVector.Core.Figure.RectangleElement)this.mouseAreaControl.PicturePanel.PreGraph).Angle);
                    float single11 = single10;
                    float single12 = single10;
                    if ((single8 < 5f) || (single9 < 5f))
                    {
                        return null;
                    }
                    if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                    {
                        single8 = single9 = Math.Max(single8, single9);
                        single4 = ((point1.X - point2.X) < 0) ? ((float)point1.X) : (point1.X - single8);
                        single5 = ((point1.Y - point2.Y) < 0) ? ((float)point1.Y) : (point1.Y - single9);
                    }
                    if (single11 > (single8 / 2f))
                    {
                        single11 = single8;
                    }
                    if (single12 > (single9 / 2f))
                    {
                        single12 = single9;
                    }
                    ItopVector.Core.Figure.RectangleElement rectangle1 = (ItopVector.Core.Figure.RectangleElement)graph2;
                    rectangle1.X = single4;
                    rectangle1.Y = single5;
                    rectangle1.Width = single8;
                    rectangle1.Height = single9;
                    rectangle1.RX = single11;
                    rectangle1.RY = single12;
                   // AttributeFunc.SetAttributeValue((XmlElement)rectangle1, "style", "fill:#C0C0FF;fill-opacity:0.3;stroke:#000000;stroke-opacity:1;");
                    goto Label_0F08;
                }
                case ToolOperation.InterEnclosurePrint:
                {
                    float single10 = 0f;
                    single10 = Math.Max(0, ((ItopVector.Core.Figure.RectangleElement) this.mouseAreaControl.PicturePanel.PreGraph).Angle);
                    float single11 = single10;
                    float single12 = single10;
                    if ((single8 < 5f) || (single9 < 5f))
                    {
                        return null;
                    }
                    if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                    {
                        single8 = single9 = Math.Max(single8, single9);
                        single4 = ((point1.X - point2.X) < 0) ? ((float) point1.X) : (point1.X - single8);
                        single5 = ((point1.Y - point2.Y) < 0) ? ((float) point1.Y) : (point1.Y - single9);
                    }
                    if (single11 > (single8 / 2f))
                    {
                        single11 = single8;
                    }
                    if (single12 > (single9 / 2f))
                    {
                        single12 = single9;
                    }
                    ItopVector.Core.Figure.RectangleElement rectangle1 = (ItopVector.Core.Figure.RectangleElement) graph2;
                    rectangle1.X = single4;
                    rectangle1.Y = single5;
                    rectangle1.Width = single8;
                    rectangle1.Height = single9;
                    rectangle1.RX = single11;
                    rectangle1.RY = single12;
                    AttributeFunc.SetAttributeValue((XmlElement)rectangle1, "style", "fill:#C0C0FF;fill-opacity:0.0;stroke:#000000;stroke-opacity:1;");
                    goto Label_0F08;
                }
                case ToolOperation.Circle:
                case ToolOperation.Bezier:
                case ToolOperation.Text:
                {
                    goto Label_0F08;
                }
                case ToolOperation.Ellipse:
                {
                    if ((single8 < 3f) || (single9 < 3f))
                    {
                        return null;
                    }
                    if (Control.ModifierKeys == Keys.Shift)
                    {
                        float single13 = Math.Max((float) (single6 - single4), (float) (single7 - single5)) / 2f;
                        if (single13 < 3f)
                        {
                            return null;
                        }
                        single4 = ((point1.X - point2.X) < 0) ? ((float) point1.X) : (point1.X - (2f * single13));
                        single5 = ((point1.Y - point2.Y) < 0) ? ((float) point1.Y) : (point1.Y - (2f * single13));
                        float single14 = single4 + single13;
                        float single15 = single5 + single13;
                        Circle circle1 = (Circle) graph2;
                        circle1.CX = single14;
                        circle1.CY = single15;
                        circle1.R = single13;
                        goto Label_0F08;
                    }
                    if (Control.ModifierKeys == (Keys.Control | Keys.Shift))
                    {
                        Circle circle2 = (Circle) graph2;
                        circle2.CX = point1.X;
                        circle2.CY = point1.Y;
                        float single16 = Math.Max(Math.Abs((int) (point1.Y - point2.Y)), Math.Abs((int) (point1.X - point2.X)));
                        if (single16 < 3f)
                        {
                            return null;
                        }
                        circle2.R = single16;
                        goto Label_0F08;
                    }
                    Ellips ellips1 = (Ellips) graph2;
                    if (Control.ModifierKeys == Keys.Control)
                    {
                        ellips1.CX = point1.X;
                        ellips1.CY = point1.Y;
                        ellips1.RX = Math.Abs((int) (point2.X - point1.X));
                        ellips1.RY = Math.Abs((int) (point2.Y - point1.Y));
                        goto Label_0F08;
                    }
                    ellips1.CX = single4 + (single8 / 2f);
                    ellips1.CY = single5 + (single9 / 2f);
                    ellips1.RX = single8 / 2f;
                    ellips1.RY = single9 / 2f;
                    goto Label_0F08;
                }
                case ToolOperation.Line:
                {
                    if ((single8 < 1f) && (single9 < 1f))
                    {
                        return null;
                    }
                    if ((Math.Abs((int) (point1.X - point2.X)) <= (2f * single1)) && (Math.Abs((int) (point1.Y - point2.Y)) <= (2f * single1)))
                    {
                        goto Label_0F07;
                    }
                    if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                    {
                        float single17 = (((float) Math.Atan2((double) (point2.Y - point1.Y), (double) (point2.X - point1.X))) * 180f) / 3.141593f;
                        single17 = ((int) Math.Round((double) (single17 / 45f), 0)) * 0x2d;
                        if ((single17 != 90f) && (single17 != -90f))
                        {
                            single17 = (float) Math.Tan((single17 / 180f) * 3.1415926535897931);
                            point2 = new PointF(point2.X, point1.Y + ((int) ((point2.X - point1.X) * single17)));
                            break;
                        }
                        point2 = new PointF(point1.X, point2.Y);
                    }
                    break;
                }
                case ToolOperation.ConnectLine://������
                 {
                     if (((single8 < 1f) && (single9 < 1f)) ||connectBegin==null || connectEnd==null || connectBegin==connectEnd)
                     {
                         return null;
                     }
                    ConnectLine cline =graph2 as ConnectLine;
                    cline.SetAttribute("start","#"+connectBegin.ID+"."+connectBeginIndex);

                    cline.SetAttribute("end","#"+connectEnd.ID+"."+connectEndIndex);

                    connectBegin=null;
                    connectEnd =null;

                     break;
                 }
                case ToolOperation.PolyLine:
                case ToolOperation.XPolyLine:
                case ToolOperation.YPolyLine:
                case ToolOperation.FreeLines:
                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.LeadLine:
                {
                    if (this.drawPath != null)
                    {
                        PointF[] tfArray1 = this.drawPath.PathPoints;
                        PointF[] tfArray2 = new PointF[tfArray1.Length];
                        for (int num3 = 0; num3 < tfArray1.Length; num3++)
                        {
                            PointF tf1 = this.mouseAreaControl.PicturePanel.PointToView(tfArray1[num3]);
                            tf1 = new PointF(tf1.X, tf1.Y);
                            tfArray2[num3] = tf1;
                        }
                        ((Polyline) graph2).Points = tfArray2;
                    }
                    goto Label_0F08;
                }
                case ToolOperation.Polygon:
                case ToolOperation.Enclosure:
                case ToolOperation.InterEnclosure:
                case ToolOperation.AreaPolygon:
                {
                    if (this.drawPath != null)
                    {
                        PointF[] tfArray3 = this.drawPath.PathPoints;
                        PointF[] tfArray4 = new PointF[tfArray3.Length];
                        for (int num4 = 0; num4 < tfArray3.Length; num4++)
                        {
                            PointF tf2 = this.mouseAreaControl.PicturePanel.PointToView(tfArray3[num4]);
                            tf2 = new PointF(tf2.X, tf2.Y);
                            tfArray4[num4] = tf2;
                        }
                        ((Polygon) graph2).Points = tfArray4;
                    }
                    goto Label_0F08;
                }
                case ToolOperation.EqualPolygon:
                {
                    int num5 = 3;
                    num5 = Math.Max(3, ((Polygon) this.mouseAreaControl.PicturePanel.PreGraph).LineCount);
                    double num6 = 6.2831853071795862 / ((double) num5);
                    GraphicsPath path1 = new GraphicsPath();
                    double num7 = 0;
                    double num8 = 0;
                    double num9 = Math.Sqrt(Math.Pow((double) (point1.X - point2.X), 2) + Math.Pow((double) (point1.Y - point2.Y), 2));
                    float single18 = (float) Math.Round((double) ((Polygon) this.mouseAreaControl.PicturePanel.PreGraph).Indent, 1);
                    int num10 = num5;
                    if (single18 < 1f)
                    {
                        num10 = num5 * 2;
                    }
                    PointF[] tfArray5 = new PointF[num10];
                    if (num9 < 2)
                    {
                        return null;
                    }
                    if (num9 >= 2)
                    {
                        double num11 = Math.Asin(((double) (point2.Y - point1.Y)) / num9);
                        if (point2.X < point1.X)
                        {
                            num11 = 3.1415926535897931 - num11;
                        }
                        PointF tf3 = PointF.Empty;
                        for (int num13 = 0; num13 < num10; num13 += (num10 / num5))
                        {
                            double num12 = num11 + (num6 * (num13 / (num10 / num5)));
                            num7 = num9 * Math.Cos(num12);
                            num8 = num9 * Math.Sin(num12);
                            tfArray5[num13] = new PointF((float) (point1.X + ((int) num7)), (float) (point1.Y + ((int) num8)));
                            if (num10 == (2 * num5))
                            {
                                if (!tf3.IsEmpty)
                                {
                                    PointF tf4 = new PointF((tf3.X + tfArray5[num13].X) / 2f, (tf3.Y + tfArray5[num13].Y) / 2f);
                                    tf4 = new PointF((float) (point1.X + ((int) (single18 * (tf4.X - point1.X)))), (float) (point1.Y + ((int) (single18 * (tf4.Y - point1.Y)))));
                                    tfArray5[num13 - 1] = tf4;
                                }
                                tf3 = tfArray5[num13];
                                if (num13 == ((2 * num5) - 2))
                                {
                                    PointF tf5 = new PointF((tfArray5[0].X + tfArray5[num13].X) / 2f, (tfArray5[0].Y + tfArray5[num13].Y) / 2f);
                                    tf5 = new PointF((float) (point1.X + ((int) (single18 * (tf5.X - point1.X)))), (float) (point1.Y + ((int) (single18 * (tf5.Y - point1.Y)))));
                                    tfArray5[num13 + 1] = tf5;
                                }
                            }
                        }
                        string text1 = string.Empty;
                        for (int num14 = 0; num14 < tfArray5.Length; num14++)
                        {
                            PointF tf6 = tfArray5[num14];
                            text1 = text1 + tf6.X.ToString() + " " + tf6.Y.ToString();
                            if (num14 < (tfArray5.Length - 1))
                            {
                                text1 = text1 + ",";
                            }
                        }
                        AttributeFunc.SetAttributeValue((SvgElement) graph2, "points", text1);
                    }
                    goto Label_0F08;
                }
                case ToolOperation.Image:
                {
                    graph2=null;
                    if (this.showdialog && (this.filename != string.Empty))
                    {
                        graph2 = (ItopVector.Core.Figure.Image) document1.CreateElement(document1.Prefix, "image", document1.NamespaceURI);
                        ItopVector.Core.Figure.Image image1 = (ItopVector.Core.Figure.Image) graph2;
                        image1.X = single4;
                        image1.Y = single5;
                        image1.Width = single8;
                        image1.Height = single9;
                        image1.ImageUrl = this.filename;
                    }
                    goto Label_0F08;
                }
                case ToolOperation.PreShape:
                {
                    GraphicsPath path2 = PathFunc.GetPathFromGraph(this.mouseAreaControl.PicturePanel.PreGraph);
                    single4 = point1.X;
                    single5 = point1.Y;
                    single8 = point2.X - point1.X;
                    single9 = point2.Y - point1.Y;
                    if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                    {
                        single8 = single9 = Math.Max(single8, single9);
                        single4 = ((point1.X - point2.X) < 0) ? ((float) point1.X) : (point1.X - single9);
                        single5 = ((point1.Y - point2.Y) < 0) ? ((float) point1.Y) : (point1.Y - single8);
                    }
                    if ((Math.Abs(single8) < 2f) || (Math.Abs(single9) < 2f))
                    {
                        return null;
                    }
                    path2.Flatten(new Matrix());
                    float single19 = single4;
                    float single20 = single5;
                    RectangleF ef2 = path2.GetBounds();
                    Matrix matrix1 = new Matrix();
                    matrix1.Translate(single19 - ef2.X, single20 - ef2.Y);
                    matrix1.Translate(ef2.X, ef2.Y);
                    matrix1.Scale(single8 / ef2.Width, single9 / ef2.Height);
                    matrix1.Translate(-ef2.X, -ef2.Y);
                    Transf transf1 = new Transf();
                    transf1.setMatrix(matrix1);
                    AttributeFunc.SetAttributeValue((SvgElement) graph2, "transform", transf1.ToString());
                    goto Label_0F08;
                }
                case ToolOperation.Pie:
                case ToolOperation.Arc:
                {

                    if (!this.pieRect.IsEmpty)
                    {
                        SvgElement element9 = graph2 as SvgElement;
                        startpoint = new PointF(this.pieRect.X + (this.pieRect.Width / 2f), this.pieRect.Y + (this.pieRect.Height / 2f));
                        PointF tf7 = this.mouseAreaControl.PicturePanel.PointToView(endpoint);
                        if (tf7 == lastPoint)
                        {
                            graph2 =null;
                            goto Label_0F08;
                        }
                        endpoint = this.lastPoint;
                        float single17 = this.startArcAngle;
                        float single18 = this.endArcAngle;
                        while (single18 > 360f)
                        {
                            single18 -= 360f;
                        }
                        float single19 = this.pieRect.Width / 2f;
                        float single20 = this.pieRect.Height / 2f;
                        float single21 = startpoint.X;
                        float single22 = startpoint.Y;
                        string text4 = (((single18 - single17) > 180f) || (single18 < single17)) ? "1" : "0";
                        single17 = (float) ((single17 / 180f) * 3.1415926535897931);
                        single18 = (float) ((single18 / 180f) * 3.1415926535897931);
                        PointF tf8 = this.GetCrossPoint(this.pieRect, startpoint, endpoint);
                        float single23 = tf8.X;
                        float single24 = tf8.Y;
                        tf8 = this.GetCrossPoint(this.pieRect, startpoint, tf7);
                        float single25 = tf8.X;
                        float single26 = tf8.Y;
                        string text5 = string.Concat(new string[] {
                                                                      "M", single21.ToString(), " ", single22.ToString(), "L", single23.ToString(), " ", single24.ToString(), "A", single19.ToString(), " ", single20.ToString(), " 0 ", text4, " 1 ", single25.ToString(),
                                                                      " ", single26.ToString(), "Z"
                                                                  });
                        if (operation ==ToolOperation.Arc)
                        {
                            text5 = string.Concat(new string[] { "M", single23.ToString(), " ", single24.ToString(), "A", single19.ToString(), " ", single20.ToString(), " 0 ", text4, " 1 ", single25.ToString(), " ", single26.ToString() });
                        }
                        element9.SetAttribute("d", text5);
                        graph2 = element9 as IGraph;
                        this.pieRect = RectangleF.Empty;
                    }
                    else
                    {
                        graph2 =null;
                    }
                    goto Label_0F08;
                }
                default:
                {
                    goto Label_0F08;
                }
            }
            Label_0F07:
                Line line1 = (Line) graph2;
            line1.X1 = point1.X;
            line1.Y1 = point1.Y;
            line1.X2 = point2.X;
            line1.Y2 = point2.Y;
            Label_0F08:
                this.mouseAreaControl.SVGDocument.AcceptChanges = flag1;
            return graph2;
        }