Esempio n. 1
0
        private void UpdateGraph(string newpoints)
        {
            if (this.graph != null)
            {
                PointF[] tfArray1 = new PointF[0];
                if (this.graph is Line)
                {
                    tfArray1 = ((Line)this.graph).Points;
                }

                SvgDocument document1 = this.mouseAreaControl.SVGDocument;
                bool        flag1     = document1.AcceptChanges;
                document1.AcceptChanges          = true;
                document1.NumberOfUndoOperations = 200;
                if ((((((SvgElement)this.graph).InfoList.Count == 1) && (this.mouseAreaControl.SVGDocument.ControlTime == 0))) || (((SvgElement)this.graph).ParentNode == null))
                {
                    //AttributeFunc.SetAttributeValue((SvgElement) this.graph, "points", newpoints);
                    if (this.points[0] != tfArray1[0])
                    {
                        AttributeFunc.SetAttributeValue((SvgElement)this.graph, "x1", this.points[0].X.ToString());
                        AttributeFunc.SetAttributeValue((SvgElement)this.graph, "y1", this.points[0].Y.ToString());
                    }
                    if (this.points[1] != tfArray1[1])
                    {
                        AttributeFunc.SetAttributeValue((SvgElement)this.graph, "x2", this.points[1].X.ToString());
                        AttributeFunc.SetAttributeValue((SvgElement)this.graph, "y2", this.points[1].Y.ToString());
                    }
                    this.graph.IsChanged = true;
                }


                document1.NotifyUndo();
                document1.AcceptChanges = flag1;
            }
        }
Esempio n. 2
0
        public void Remove(IGraph graph)
        {
            if (graph == this.startGraph)
            {
                AttributeFunc.SetAttributeValue(this, "start", string.Empty);
                using (GraphicsPath path = graph.GPath.Clone() as GraphicsPath)
                {
                    RectangleF tf = path.GetBounds(graph.Transform.Matrix);
                    PointF     pf = new PointF(tf.X + tf.Width / 2, tf.Y + tf.Height / 2);
                    X1 = pf.X;
                    Y1 = pf.Y;
                }
                this.startGraph = null;
            }
            else if (graph == this.endGraph)
            {
                AttributeFunc.SetAttributeValue(this, "end", string.Empty);
                using (GraphicsPath path = graph.GPath.Clone() as GraphicsPath)
                {
                    RectangleF tf = path.GetBounds(graph.Transform.Matrix);
                    PointF     pf = new PointF(tf.X + tf.Width / 2, tf.Y + tf.Height / 2);
                    X2 = pf.X;
                    Y2 = pf.Y;
                }
                this.endGraph = null;
//				AttributeFunc.SetAttributeValue(this,"end","use97633.4");
            }
            this.Attributes.RemoveNamedItem("transform");
        }
Esempio n. 3
0
        private void UpdateGraph(SvgElement polyline, PointF[] newpoints)
        {
            if (polyline != null)
            {
                StringBuilder text1    = new StringBuilder();
                PointF[]      tfArray1 = (PointF[])newpoints.Clone();

                for (int num10 = 0; num10 < tfArray1.Length; num10++)
                {
                    PointF tf1 = tfArray1[num10];
                    text1.Append(tf1.X.ToString() + " " + tf1.Y.ToString());
                    if (num10 < (tfArray1.Length - 1))
                    {
                        text1.Append(",");
                    }
                }
                SvgDocument document1 = this.mouseAreaControl.SVGDocument;
                bool        flag1     = document1.AcceptChanges;
                document1.AcceptChanges          = true;
                document1.NumberOfUndoOperations = 200;
                if (((((polyline).InfoList.Count == 1) && (this.mouseAreaControl.SVGDocument.ControlTime == 0))) || ((polyline).ParentNode == null))
                {
                    AttributeFunc.SetAttributeValue(polyline, "points", text1.ToString());
                }

                document1.NotifyUndo();
                document1.AcceptChanges = flag1;
            }
        }
Esempio n. 4
0
        protected void SetAttributeValue(string attributeName, string attributeValue)
        {
            if ((svgElement as IGraph).IsLock)
            {
                return;
            }
            this.svgElement.OwnerDocument.AcceptChanges = true;

            this.svgElement.OwnerDocument.ChangeElements.Add(svgElement);

            bool flag1 = false;

            //			if(attributeName=="fill" || attributeName=="stroke")
            {
                if (this.svgElement is IGraphPath)
                {
                    flag1 = true;
                    (this.svgElement as IGraphPath).UpdateAttribute = false;
                }
            }

            AttributeFunc.SetAttributeValue(svgElement, attributeName, attributeValue);

            this.svgElement.OwnerDocument.NotifyUndo();


            if (flag1)
            {
                (this.svgElement as IGraphPath).UpdateAttribute = true;
            }
        }
Esempio n. 5
0
        private void ChangeStrokeBrush(object sender, EventArgs e)
        {
            if (this.updateattribute)
            {
                ISvgBrush brush1 = this.graphStroke.Brush;
                if (brush1 is SvgElement)
                {
//					SvgElement element1 = (SvgElement) brush1;
                    string text1 = CodeFunc.CreateString(base.OwnerDocument, ((SvgElement)brush1).Name);
                    if ((this.ParentNode != null) && (((SvgElement)brush1).ParentNode == null))
                    {
                        AttributeFunc.SetAttributeValue((SvgElement)brush1, "id", text1);
                        AttributeFunc.SetAttributeValue(this, "stroke", "url(#" + text1 + ");");
                        base.OwnerDocument.AddDefsElement((SvgElement)brush1);
                    }
                    else
                    {
                        this.svgAttributes["stroke"]     = this.graphStroke;
                        this.svgAnimAttributes["stroke"] = this.graphStroke;
                    }
                }
                else if (brush1 == null)
                {
                    AttributeFunc.SetAttributeValue(this, "stroke", "none");
                }
                else
                {
                    AttributeFunc.SetAttributeValue(this, "stroke", ColorFunc.GetColorString(((SolidColor)brush1).Color));
                    AttributeFunc.SetAttributeValue(this, "stroke-opacity", ((SolidColor)brush1).Opacity.ToString());
                }
            }
        }
Esempio n. 6
0
        private void AddMarker(Marker svgElement, string attributeName, bool isendarrow)
        {
            if (svgElement != null)
            {
                SvgDocument fadde1 = base.svgElement.OwnerDocument;
                bool        flag1  = fadde1.AcceptChanges;
                string      text1  = svgElement.GetAttribute("id").Trim();
                string      text2  = string.Empty;
                if (text1.Length > 0)
                {
                    if (isendarrow)
                    {
                        text1 = "end" + text1;
                    }
                    else
                    {
                        text1 = "start" + text1;
                    }
                }
                text2 = "url(#" + text1 + ")";
                if (text1.Length == 0)
                {
                    text2 = string.Empty;
                }
                string text3 = (base.svgElement as SvgElement).GetAttribute(attributeName);
                if (text2 != text3)
                {
                    string[] textArray1 = new string[] { "marker" };
                    Marker   cfb1       = NodeFunc.GetRefNode(text1, fadde1) as Marker;
                    if (cfb1 == null)
                    {
                        cfb1 = svgElement;

                        if (isendarrow)
                        {
                            //fadde1.AcceptChanges = false;
                            for (int num1 = 0; num1 < cfb1.GraphList.Count; num1++)
                            {
                                SvgElement facbce1 = cfb1.GraphList[num1] as SvgElement;
                                if (facbce1 != null)
                                {
                                    string text4 = facbce1.GetAttribute("transform");
                                    text4 = "matrix(-1,0,0,1,0,0) " + text4;
                                    facbce1.SetAttribute("transform", text4);

                                    text4 = null;
                                }
                            }
                        }
                        cfb1.SetAttribute("id", text1);
                        fadde1.AddDefsElement(cfb1);
                    }

                    AttributeFunc.SetAttributeValue(base.svgElement, attributeName, text2);
                }
                fadde1.AcceptChanges = flag1;
            }
        }
Esempio n. 7
0
        private void UpdateGraph(string newpoints)
        {
            if (this.graph != null)
            {
//                string text1 = string.Empty;
//                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;
//                }
//                int num1 = 0;
//                PointF[] tfArray2 = tfArray1;
//                for (int num10 = 0; num10 < tfArray2.Length; num10++)
//                {
//                    PointF tf1 = tfArray2[num10];
//                    text1 = text1 + tf1.X.ToString() + " " + tf1.Y.ToString();
//                    if (num1 < (tfArray1.Length - 1))
//                    {
//                        text1 = text1 + ",";
//                    }
//                    num1++;
//                }
                SvgDocument document1 = this.mouseAreaControl.SVGDocument;
                bool        flag1     = document1.AcceptChanges;
                document1.AcceptChanges          = true;
                document1.NumberOfUndoOperations = 200;
                if ((((((SvgElement)this.graph).InfoList.Count == 1) && (this.mouseAreaControl.SVGDocument.ControlTime == 0))) || (((SvgElement)this.graph).ParentNode == null))
                {
                    AttributeFunc.SetAttributeValue((SvgElement)this.graph, "points", newpoints);
                }

                document1.NotifyUndo();
                document1.AcceptChanges = flag1;
            }
        }
Esempio n. 8
0
        public void OnMouseDown(MouseEventArgs e)
        {
            bool   flag2;
            bool   flag3;
            PointF tf1;

            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            this.startpoint = this.mouseAreaControl.PicturePanel.PointToView(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.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];
            if (tfArray1 != null)
            {
                this.points = new PointF[tfArray1.Length + 1];
                tfArray1.CopyTo(this.points, 0);
            }
            this.points[this.points.Length - 1] = 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:
            tf1 = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float)e.X, (float)e.Y));
            ArrayList list2 = new ArrayList(this.points);

            list2.Insert(this.insertindex, tf1);
            this.points = new PointF[list2.Count];
            list2.CopyTo(this.points);
Label_05F5:
            if (((this.operate == PolyOperate.Del) || (this.operate == PolyOperate.Draw)) || (this.operate == PolyOperate.Add))
            {
                string   text1    = string.Empty;
                int      num3     = 0;
                PointF[] tfArray2 = this.points;
                for (int num4 = 0; num4 < tfArray2.Length; num4++)
                {
                    PointF tf2 = tfArray2[num4];
                    text1 = text1 + tf2.X.ToString() + " " + tf2.Y.ToString();
                    if (num3 < (this.points.Length - 1))
                    {
                        text1 = text1 + ",";
                    }
                    num3++;
                }
                this.mouseAreaControl.PicturePanel.InvalidateElement((SvgElement)this.graph);
                if (((SvgElement)this.graph).ParentNode == null)
                {
                    this.UpdateGraph(text1);
                    document1.AcceptChanges = true;
                    IGraph graph2 = this.graph;
                    this.mouseAreaControl.PicturePanel.AddElement(this.graph);
                    this.graph = graph2;
                }
                else
                {
                    document1.AcceptChanges = true;
                    this.UpdateGraph(text1);
                }
                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();
        }
Esempio n. 9
0
        public void OnMouseUp(MouseEventArgs e)
        {
            this.tempPath.Reset();
            if (((this.graph != null) && (((SvgElement)this.graph).ParentNode != null)) && ((e.Button == MouseButtons.Left) && this.mousedown))
            {
                this.mousedown = false;
                if ((this.operate == PolyOperate.MovePoint) || (this.operate == PolyOperate.MovePath))
                {
                    PointF tf1     = this.mouseAreaControl.PicturePanel.PointToView(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)((tf1.X + (single2 / 2f)) / single2);
                        int num2 = (int)((tf1.Y + (single1 / 2f)) / single1);
                        tf1 = (PointF) new Point((int)(num1 * single2), (int)(num2 * single1));
                    }
                    tf1 = this.mouseAreaControl.PicturePanel.PointToSystem(tf1);
                    switch (this.operate)
                    {
                    case PolyOperate.MovePath:
                    {
                        PointF tf2     = this.mouseAreaControl.PicturePanel.PointToSystem(this.startpoint);
                        Matrix matrix1 = new Matrix();
                        matrix1.Translate(tf1.X - tf2.X, tf1.Y - tf2.Y);
                        matrix1.TransformPoints(this.points);
                        break;
                    }

                    case PolyOperate.MovePoint:
                    {
                        if ((this.moveindex >= 0) && (this.moveindex < this.points.Length))
                        {
                            this.points[this.moveindex] = tf1;

                            if (this.graph is ConnectLine)
                            {                                    //连接线
                                bool        flag2  = false;
                                ConnectLine cebfd1 = this.graph as ConnectLine;

                                if (this.connectGraph == null)
                                {
                                    if (this.moveindex == 0)
                                    {
                                        string text3 = cebfd1.GetAttribute("start");
                                        if ((text3 != null) && (text3.Length > 0))
                                        {
                                            if (cebfd1.StartGraph != null)
                                            {
                                                cebfd1.StartGraph.ConnectLines.Remove(cebfd1);
                                            }
                                            AttributeFunc.SetAttributeValue(cebfd1, "start", string.Empty);

                                            flag2 = true;
                                        }
                                        float single11 = tf1.X;
                                        if (cebfd1.GetAttribute("x1") != single11.ToString())
                                        {
                                            AttributeFunc.SetAttributeValue(cebfd1, "x1", single11.ToString());
                                            flag2 = true;
                                        }
                                        single11 = tf1.Y;
                                        if (cebfd1.GetAttribute("y1") != single11.ToString())
                                        {
                                            AttributeFunc.SetAttributeValue(cebfd1, "y1", single11.ToString());
                                            flag2 = true;
                                        }
                                    }
                                    else
                                    {
                                        string text2 = cebfd1.GetAttribute("end");
                                        if ((text2 != null) && (text2.Length > 0))
                                        {
                                            if (cebfd1.EndGraph != null)
                                            {
                                                cebfd1.EndGraph.ConnectLines.Remove(cebfd1);
                                            }
                                            AttributeFunc.SetAttributeValue(cebfd1, "end", string.Empty);

                                            flag2 = true;
                                        }
                                        float single12 = tf1.X;
                                        if (cebfd1.GetAttribute("x2") != single12.ToString())
                                        {
                                            AttributeFunc.SetAttributeValue(cebfd1, "x2", single12.ToString());
                                            flag2 = true;
                                        }
                                        single12 = tf1.Y;
                                        if (cebfd1.GetAttribute("y2") != single12.ToString())
                                        {
                                            AttributeFunc.SetAttributeValue(cebfd1, "y2", single12.ToString());
                                            flag2 = true;
                                        }
                                    }
                                }
                                else
                                {
                                    SvgElement ab1   = this.connectGraph as SvgElement;
                                    string     text3 = ab1.GetAttribute("id");
                                    if ((text3 == null) || (text3.Trim().Length == 0))
                                    {
                                        text3 = CodeFunc.CreateString(this.mouseAreaControl.SVGDocument, ab1.LocalName);
                                        AttributeFunc.SetAttributeValue(ab1, "id", text3);
                                    }
                                    if (this.moveindex == 0)
                                    {
                                        text3 = "#" + text3;
                                        using (Matrix matrix1 = ((IGraph)ab1).GraphTransform.Matrix.Clone())
                                        {
                                            PointF[] tfArray3 = ((IGraph)ab1).ConnectPoints.Clone() as PointF[];
                                            matrix1.TransformPoints(tfArray3);
                                            int num1 = Array.IndexOf(tfArray3, this.connectPoint);
                                            if ((num1 >= 0) && (num1 < tfArray3.Length))
                                            {
                                                text3 = text3 + "." + num1.ToString();
                                            }
                                            tfArray3 = null;
                                        }
                                        if (text3 != cebfd1.GetAttribute("start"))
                                        {
                                            IGraph oldgraph = cebfd1.StartGraph;
                                            if (oldgraph != null)
                                            {
                                                oldgraph.ConnectLines.Remove(cebfd1);
                                            }
                                            AttributeFunc.SetAttributeValue(cebfd1, "start", text3);
                                            flag2 = true;
                                        }
                                    }
                                    else
                                    {
                                        text3 = "#" + text3;
                                        using (Matrix matrix3 = ((IGraph)ab1).GraphTransform.Matrix.Clone())
                                        {
                                            PointF[] tfArray3 = ((IGraph)ab1).ConnectPoints.Clone() as PointF[];
                                            matrix3.TransformPoints(tfArray3);
                                            int num2 = Array.IndexOf(tfArray3, this.connectPoint);
                                            if ((num2 >= 0) && (num2 < tfArray3.Length))
                                            {
                                                text3 = text3 + "." + num2.ToString();
                                            }
                                            tfArray3 = null;
                                        }
                                        if (text3 != cebfd1.GetAttribute("end"))
                                        {
                                            IGraph oldgraph = cebfd1.EndGraph;
                                            if (oldgraph != null)
                                            {
                                                oldgraph.ConnectLines.Remove(cebfd1);
                                            }
                                            AttributeFunc.SetAttributeValue(cebfd1, "end", text3);
                                            flag2 = true;
                                        }
                                    }
                                }
                                if (flag2)
                                {
                                    this.mouseAreaControl.PicturePanel.InvalidateElement(this.connectGraph as SvgElement);
                                }
                            }
                        }
                        break;
                    }
                    }
                    Matrix matrix2 = this.graph.GraphTransform.Matrix.Clone();
                    matrix2.Invert();
                    if (this.points.Length > 0)
                    {
                        matrix2.TransformPoints(this.points);
                    }
                    SvgDocument document1 = this.mouseAreaControl.SVGDocument;
                    bool        flag1     = document1.AcceptChanges;
                    document1.AcceptChanges = true;
                    string   text1    = string.Empty;
                    int      num3     = 0;
                    PointF[] tfArray1 = this.points;
                    for (int num4 = 0; num4 < tfArray1.Length; num4++)
                    {
                        PointF tf3 = tfArray1[num4];
                        text1 = text1 + tf3.X.ToString() + " " + tf3.Y.ToString();
                        if (num3 < (this.points.Length - 1))
                        {
                            text1 = text1 + ",";
                        }
                        num3++;
                    }
                    this.mouseAreaControl.PicturePanel.InvalidateElement((SvgElement)this.graph);
                    document1.AcceptChanges = true;
                    this.UpdateGraph(text1);
                    document1.AcceptChanges          = flag1;
                    ((SvgElement)this.graph).pretime = -1;
                    this.mouseAreaControl.Invalidate();
                    this.mouseAreaControl.PicturePanel.InvalidateElement((SvgElement)this.graph);
                }
            }
        }
Esempio n. 10
0
        public SvgElementCollection Break(Graphics g)
        {
            SvgElementCollection collection1 = new SvgElementCollection();

            if (this == this.OwnerTextElement)
            {
                this.currentPostion = PointF.Empty;
            }
            SvgDocument  document1 = base.OwnerDocument;
            float        single1   = this.Size;
            StringFormat format1   = this.GetGDIStringFormat();
            FontFamily   family1   = this.GetGDIFontFamily();

            if (this.X == 0)
            {
                this.currentPostion.X = this.currentPostion.X + this.Dx;
            }
            else
            {
                this.currentPostion.X = (this.X + this.Dx);
            }
            if (this.Y == 0)
            {
                this.currentPostion.Y = this.currentPostion.Y + this.Dy;
            }
            else
            {
                this.currentPostion.Y = (this.Y + this.Dy);
            }
            int  num1  = this.GetGDIStyle();
            bool flag1 = document1.AcceptChanges;

            document1.AcceptChanges = false;
            foreach (XmlNode node1 in this.ChildNodes)
            {
//				GraphicsPath path1 = new GraphicsPath();
                if (node1 is Text)
                {
                    ((Text)node1).currentPostion = this.currentPostion;
                    collection1.AddRange(((Text)node1).Break(g));
                    this.currentPostion = ((Text)node1).currentPostion;
                    continue;
                }
                if (node1.NodeType == XmlNodeType.Text)
                {
                    string text1   = this.TrimText(node1.Value);
                    Font   font1   = new Font(family1.Name, single1, (FontStyle)num1);
                    float  single2 = (((float)family1.GetCellAscent(FontStyle.Regular)) / ((float)family1.GetEmHeight(FontStyle.Regular))) * single1;
//					ISvgBrush brush1 = base.GraphBrush.Clone();
//					ISvgBrush brush2 = base.GraphStroke.Brush.Clone();
                    CharEnumerator enumerator2 = text1.GetEnumerator();
                    while (enumerator2.MoveNext())
                    {
                        char ch1   = enumerator2.Current;
                        Text text2 = (Text)document1.CreateElement(document1.Prefix, "text", document1.NamespaceURI);
                        text2.AppendChild(document1.CreateTextNode(ch1.ToString()));
                        foreach (XmlAttribute attribute1 in this.Attributes)
                        {
                            text2.SetAttributeNode((XmlAttribute)attribute1.Clone());
                        }
                        string text3   = ch1.ToString();
                        SizeF  ef1     = g.MeasureString(text3, font1, new PointF(this.currentPostion.X, this.currentPostion.Y - single2), format1);
                        float  single3 = ef1.Width;
                        AttributeFunc.SetAttributeValue(text2, "x", this.currentPostion.X.ToString());
                        AttributeFunc.SetAttributeValue(text2, "y", this.currentPostion.Y.ToString());
                        this.currentPostion.X += ((single3 * 3f) / 4f);
                        collection1.Add(text2);
                    }
                }
            }
            document1.AcceptChanges = flag1;
            return(collection1);
        }
Esempio n. 11
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();
        }
Esempio n. 12
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;
                }
            }             //鼠标右键抬起
        }
Esempio n. 13
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);
        }
Esempio n. 14
0
        public void AdaptKeyTime(int keytime, int delta)
        {
            int num1 = this.Begin;
            int num2 = this.Duration;
            int num3 = keytime + delta;

            object[] objArray1 = new object[this.Values.Count];
            this.values.CopyTo(objArray1);
            int[]     numArray1 = new int[this.VirtualTimes.Count];
            ArrayList list1     = (ArrayList)this.VirtualTimes.Clone();
            int       num4      = 0;
            int       num5      = 0;

            for (int num6 = 0; num6 < numArray1.Length; num6++)
            {
                int num7 = (int)ItopVector.Core.Func.Number.ParseFloatStr((string)list1[num6]);
                if (num7 == keytime)
                {
                    numArray1[num6] = num3;
                }
                else
                {
                    numArray1[num6] = num7;
                }
                if (num6 == 0)
                {
                    num4 = num5 = numArray1[num6];
                }
                else
                {
                    num4 = Math.Min(num4, numArray1[num6]);
                    num5 = Math.Max(num5, numArray1[num6]);
                }
            }
            if (this.values.Count > 0)
            {
                if (numArray1.Length == objArray1.Length)
                {
                    Array.Sort(numArray1, objArray1);
                }
                num1          = num4;
                num2          = num5 - num4;
                this.values   = new ArrayList(objArray1);
                this.keyTimes = new ArrayList(numArray1);
                string text1 = "";
                if ((numArray1.Length > 0) && (num2 > 0))
                {
                    for (int num8 = 0; num8 < numArray1.Length; num8++)
                    {
                        float single1 = ((float)(numArray1[num8] - num1)) / ((float)num2);
                        if (num8 == (numArray1.Length - 1))
                        {
                            text1 = text1 + single1.ToString();
                        }
                        else
                        {
                            text1 = text1 + single1.ToString() + ";";
                        }
                    }
                    AttributeFunc.SetAttributeValue(this, "keyTimes", text1);
                }
                text1 = "";
                if (objArray1.Length > 0)
                {
                    for (int num9 = 0; num9 < objArray1.Length; num9++)
                    {
                        if (num9 == (objArray1.Length - 1))
                        {
                            text1 = text1 + objArray1[num9].ToString();
                        }
                        else
                        {
                            text1 = text1 + objArray1[num9].ToString() + ";";
                        }
                    }
                    AttributeFunc.SetAttributeValue(this, "values", text1);
                }
            }
            this.Begin    = num4;
            this.Duration = num5 - num4;
        }
Esempio n. 15
0
 public virtual void InsertKey(int time, string keyvalues)
 {
     if ((time >= this.Begin) && (time <= (this.Begin + this.Duration)))
     {
         int num1 = this.pretime;
         this.pretime++;
         bool flag1 = false;
         if (this.KeyTimes.Count == 0)
         {
             if (time == this.Begin)
             {
                 this.FromWhat = keyvalues;
                 return;
             }
             if (time == (this.Begin + this.Duration))
             {
                 this.ToWhat = keyvalues;
                 return;
             }
             this.keyTimes = (ArrayList)this.VirtualTimes.Clone();
             this.values.Add(this.FromWhat);
             this.values.Add(this.ToWhat);
         }
         for (int num2 = 0; num2 < this.KeyTimes.Count; num2++)
         {
             float single1 = float.Parse((string)this.KeyTimes[num2]);
             float single2 = time;
             if ((single1 - single2) >= 1f)
             {
                 this.KeyTimes.Insert(num2, time.ToString());
                 this.values.Insert(num2, keyvalues);
                 flag1 = true;
                 break;
             }
             if (Math.Abs((float)(single1 - single2)) < 1f)
             {
                 this.values[num2] = keyvalues;
                 flag1             = true;
                 break;
             }
         }
         if (!flag1)
         {
             this.KeyTimes.Add(time.ToString());
             this.values.Add(keyvalues);
         }
         if (base.OwnerDocument.AcceptChanges)
         {
             SvgDocument document1 = base.OwnerDocument;
             document1.NumberOfUndoOperations++;
         }
         string text1 = "";
         for (int num3 = 0; num3 < this.KeyTimes.Count; num3++)
         {
             float single3 = (float.Parse((string)this.KeyTimes[num3]) - this.Begin) / ((float)this.Duration);
             if (num3 == (this.KeyTimes.Count - 1))
             {
                 text1 = text1 + single3.ToString();
             }
             else
             {
                 text1 = text1 + single3.ToString() + ";";
             }
         }
         AttributeFunc.SetAttributeValue(this, "keyTimes", text1);
         text1 = "";
         if (this.values != null)
         {
             for (int num4 = 0; num4 < this.values.Count; num4++)
             {
                 if (num4 == (this.values.Count - 1))
                 {
                     text1 = text1 + this.values[num4].ToString();
                 }
                 else
                 {
                     text1 = text1 + this.values[num4].ToString() + ";";
                 }
             }
             AttributeFunc.SetAttributeValue(this, "values", text1);
         }
         this.pretime = num1;
     }
 }
Esempio n. 16
0
 public void DelKeyTime(int time)
 {
     if (this.values.Count == 0)
     {
         if ((this.Begin == time) || ((this.Duration + this.Begin) == time))
         {
             this.ParentNode.RemoveChild(this);
         }
     }
     else
     {
         ArrayList list1 = (ArrayList)this.KeyTimes.Clone();
         int       num1  = 0;
         int       num2  = 0;
         bool      flag1 = false;
         ArrayList list2 = new ArrayList(0x10);
         for (int num3 = 0; num3 < list1.Count; num3++)
         {
             float single1 = float.Parse((string)list1[num3]);
             if (single1 == time)
             {
                 list1.RemoveAt(num3);
                 this.values.RemoveAt(num3);
                 num3--;
             }
             else
             {
                 if (!flag1)
                 {
                     num1  = num2 = (int)single1;
                     flag1 = true;
                 }
                 else
                 {
                     num1 = (int)Math.Min((float)num1, single1);
                     num2 = (int)Math.Max((float)num2, single1);
                 }
                 list2.Add((int)single1);
             }
         }
         int[] numArray1 = new int[list2.Count];
         list2.CopyTo(numArray1);
         object[] objArray1 = new object[this.values.Count];
         this.values.CopyTo(objArray1);
         Array.Sort(numArray1, objArray1);
         if (num1 == num2)
         {
             if (this.values.Count > 0)
             {
                 this.FromWhat = this.values[0].ToString();
                 this.ToWhat   = this.values[this.values.Count - 1].ToString();
             }
             this.RemoveAttribute("keyTimes");
             this.RemoveAttribute("values");
             this.Duration = 0;
             this.Begin    = num1;
         }
         else
         {
             string text1 = string.Empty;
             for (int num4 = 0; num4 < numArray1.Length; num4++)
             {
                 float single2 = ((float)numArray1[num4]) / ((float)(num2 - num1));
                 text1 = text1 + single2.ToString();
                 if (num4 != (numArray1.Length - 1))
                 {
                     text1 = text1 + ";";
                 }
             }
             AttributeFunc.SetAttributeValue(this, "keyTimes", text1);
             text1 = string.Empty;
             for (int num5 = 0; num5 < objArray1.Length; num5++)
             {
                 text1 = text1 + objArray1[num5].ToString();
                 if (num5 != (objArray1.Length - 1))
                 {
                     text1 = text1 + ";";
                 }
             }
             AttributeFunc.SetAttributeValue(this, "values", text1);
             this.Begin    = num1;
             this.Duration = num2 - num1;
         }
     }
 }