Пример #1
0
 void polyOperation_OnPolyLineBreak(object sender, BreakElementEventArgs e)
 {
     if (OnPolyLineBreak!=null)
     {
         OnPolyLineBreak(sender,e);
     }
 }
Пример #2
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;
                }

            } //����Ҽ�̧��
        }
Пример #3
0
        void DrawArea_OnPolyLineBreak(object sender, BreakElementEventArgs e)
        {
            string currentElementID = (sender as SvgElement).ID;
            string copyElementID = e.SvgElement.ID;
            if (currentElementID != null && copyElementID != null) {
                LineInfo temp = new LineInfo();
                temp.EleID = currentElementID;
                temp.SvgUID = SVGUID;
                LineInfo lineCurrent = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", temp);
                if (lineCurrent != null) {
                    string lineName = lineCurrent.LineName;

                    lineCurrent.LineName = lineName + "-1";
                    lineCurrent.Length = "";
                    Services.BaseService.Update("UpdateLineInfo", lineCurrent);
                    LineInfo copyElement = new LineInfo();
                    copyElement.UID = Guid.NewGuid().ToString();
                    copyElement.EleID = copyElementID;// +"1";
                    copyElement.LayerID = lineCurrent.LayerID;

                    copyElement.Length = "";
                    copyElement.LineName = lineName + "-2";
                    copyElement.LineType = lineCurrent.LineType;
                    copyElement.ObligateField1 = lineCurrent.ObligateField1;
                    copyElement.ObligateField2 = lineCurrent.ObligateField2;
                    copyElement.SvgUID = lineCurrent.SvgUID;
                    copyElement.Voltage = lineCurrent.Voltage;
                    Services.BaseService.Create<LineInfo>(copyElement);
                }
            }
        }
Пример #4
0
 void mouseAreaControl_OnPolyLineBreak(object sender, BreakElementEventArgs e)
 {
     if (OnPolyLineBreak!=null)
     {
         OnPolyLineBreak(sender,e);
     }
 }