コード例 #1
0
ファイル: frmMain_Spatial.cs プロジェクト: EdgarEDT/myitoppsp
        void tlVectorControl1_LeftClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e)
        {
            //SvgElement ele2 = tlVectorControl1.CreateBySymbolID("kbs-8", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
            //ele2 = tlVectorControl1.AddShape(ele2, Point.Empty);
            if (tlVectorControl1.SVGDocument.CurrentElement != null &&
                tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("xlink:href").Contains("XL_GT_1"))
            {
                sel_start_point = tlVectorControl1.SVGDocument.CurrentElement.ID;
            }

            if (sel_sym == "bt_start")
            {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_1", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele = tlVectorControl1.AddShape(ele, Point.Empty);
                ele.SetAttribute("order", "0");
                ele.SetAttribute("start_point", ele.ID);
            }
            if (sel_sym == "bt_end")
            {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_2", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele.SetAttribute("start_point", sel_start_point);
                ele.SetAttribute("order", "999");
                tlVectorControl1.AddShape(ele, Point.Empty);
            }
            if (sel_sym == "bt_must")
            {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_3", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele.SetAttribute("start_point", sel_start_point);
                tlVectorControl1.AddShape(ele, Point.Empty);
                frmInputNum num = new frmInputNum();
                num.ShowDialog();
                ele.SetAttribute("order", num.InputStrSEL);
            }
            if (sel_sym == "bt_point")
            {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_4", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele.SetAttribute("start_point", sel_start_point);
                tlVectorControl1.AddShape(ele, Point.Empty);
                frmInputNum num = new frmInputNum();
                num.ShowDialog();
                ele.SetAttribute("order", num.InputStrSEL);
            }
            //if (sel_sym != "" && sel_start_point!="")
            //{
            //    XmlNodeList il= tlVectorControl1.SVGDocument.SelectNodes("svg/use [@start_point='" + sel_start_point + "']");
            //    if (il.Count < 3)
            //    {
            //        return;
            //    }
            //    for (int i = 0; i < il.Count;i++ )
            //    {
            //        Use u = (Use)il[i];
            //        PointF f = u.CenterPoint;

            //    }
            //    //PointF[] pnt = ((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)).Points;
            //    //if (pnt.Length < 3) return;
            //    for (int i = 0; i < il.Count; i++)
            //    {
            //        double ang = TLMath.getLineAngle(((Use)il[i]).CenterPoint, ((Use)il[i + 1]).CenterPoint, ((Use)il[i + 2]).CenterPoint);
            //        if (ang * 57.3 > 60)
            //        {
            //            MessageBox.Show("线路转角不能大于60度。\r\n "+"第" + (i + 1) + "转角:" + Convert.ToDouble(ang * 57.3).ToString("##.##") + "度。\r\n", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //           // tlVectorControl1.Delete();
            //            return;
            //        }

            //        if (i == il.Count - 3)
            //        {
            //            break;
            //        }
            //    }
            //}
            if (csOperation == CustomOperation.OP_MeasureDistance)
            {
                Polyline pl = tlVectorControl1.SVGDocument.CurrentElement as Polyline;
                if (pl.Points.Length > 1)
                {
                    double d = 0;
                    for (int i = 1; i < pl.Points.Length; i++)
                    {
                        d += this.mapview.CountLength(pl.Points[i - 1], pl.Points[i]);
                    }
                    label1.Text = Math.Round(d, 3) + "公里";

                    Point pt = new Point(e.Mouse.X, e.Mouse.Y);
                    pt = PointToClient(tlVectorControl1.PointToScreen(pt));
                    //tlVectorControl1.SetToolTip(label1.Text);
                    label1.Left = pt.X;
                    label1.Top = pt.Y;

                    label1.Visible = true;
                }
                return;
            }

            tip.Hide();
            fInfo.Hide();

            if (tlVectorControl1.Operation == ToolOperation.Text)
            {
                frmTextInput ft = new frmTextInput();
                if (ft.ShowDialog() == DialogResult.OK)
                {
                    string txt = ft.Content;
                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                    Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    n1.SetAttribute("x", point1.X.ToString());
                    n1.SetAttribute("y", point1.Y.ToString());
                    n1.InnerText = txt;
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                    tlVectorControl1.Operation = ToolOperation.Select;
                }
            }
            if (MapType == "规划统计")
            {
                try
                {
                    if (e.SvgElement.ID == "svg")
                    {
                        MapType = "接线图";
                        return;
                    }
                    if (((Polygon)e.SvgElement) == null) return;
                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                    Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    n1.SetAttribute("cx", point1.X.ToString());
                    n1.SetAttribute("cy", point1.Y.ToString());
                    n1.SetAttribute("r", "42.5");
                    n1.SetAttribute("r", "42.5");
                    //n1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID);
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;");
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);

                    frmMainProperty fmain = new frmMainProperty();
                    glebeProperty gp = new glebeProperty();
                    gp.EleID = ((XmlElement)e.SvgElement).GetAttribute("id");
                    gp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    //fmain.InitData(gp); ///////////////////////////////////

                    XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("use");

                    PointF[] tfArray1 = TLMath.getPolygonPoints((XmlElement)e.SvgElement);
                    string str220 = "";
                    string str110 = "";
                    string str66 = "";
                    GraphicsPath selectAreaPath = new GraphicsPath();
                    selectAreaPath.AddLines(tfArray1);
                    selectAreaPath.CloseFigure();
                    //Matrix x=new Matrix(
                    //Region region1 = new Region(selectAreaPath);
                    for (int i = 0; i < nlist.Count; i++)
                    {
                        float OffX = 0f;
                        float OffY = 0f;
                        Use use = (Use)nlist[i];
                        if (use.GetAttribute("xlink:href").Contains("Substation"))
                        {
                            string strMatrix = use.GetAttribute("transform");
                            if (strMatrix != "")
                            {
                                strMatrix = strMatrix.Replace("matrix(", "");
                                strMatrix = strMatrix.Replace(")", "");
                                string[] mat = strMatrix.Split(',');
                                if (mat.Length > 5)
                                {
                                    OffX = Convert.ToSingle(mat[4]);
                                    OffY = Convert.ToSingle(mat[5]);
                                }
                            }
                            PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href"));
                            if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY))
                            {
                                if (use.GetAttribute("xlink:href").Contains("220"))
                                {
                                    str220 = str220 + "'" + use.GetAttribute("id") + "',";
                                }
                                if (use.GetAttribute("xlink:href").Contains("110"))
                                {
                                    str110 = str110 + "'" + use.GetAttribute("id") + "',";
                                }
                                if (use.GetAttribute("xlink:href").Contains("66"))
                                {
                                    str66 = str66 + "'" + use.GetAttribute("id") + "',";
                                }
                            }
                        }
                    }
                    if (str220.Length > 1)
                    {
                        str220 = str220.Substring(0, str220.Length - 1);
                    }
                    if (str110.Length > 1)
                    {
                        str110 = str110.Substring(0, str110.Length - 1);
                    }
                    if (str66.Length > 1)
                    {
                        str66 = str66.Substring(0, str66.Length - 1);
                    }
                    fmain.InitData(gp, str220, str110, str66);

                    XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                    Point point2 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    t1.SetAttribute("x", Convert.ToString(point2.X - 20));
                    t1.SetAttribute("y", Convert.ToString(point2.Y - 10));
                    // t1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID);
                    t1.SetAttribute("layer", SvgDocument.currentLayer);
                    t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                    t1.SetAttribute("font-famliy", "宋体");
                    t1.SetAttribute("font-size", "14");
                    t1.InnerText = fmain.glebeProp.Area + "\r\n" + fmain.glebeProp.Burthen; //+"\r\n" + fmain.glebeProp.Number;
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(t1);
                    tlVectorControl1.Refresh();
                    fmain.Dispose();
                    MapType = "接线图";
                }
                catch (Exception e2) { MapType = "接线图"; }
            }
            if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1)
            {
                return;
            }
            decimal ViewScale = 1;
            string str_Scale = tlVectorControl1.SVGDocument.getViewScale();
            if (str_Scale != "")
            {
                ViewScale = Convert.ToDecimal(str_Scale);
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Text")
            {
                string showlineflag = ((XmlElement)e.SvgElement).GetAttribute("Showline");
                if (showlineflag == "1")
                {
                    XmlElement n1 = (XmlElement)e.SvgElement;
                    string suid = n1.GetAttribute("ParentID");
                    PSPDEV psp = new PSPDEV();
                    psp.SUID = suid;
                    psp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", psp);
                    if (psp != null)
                    {
                        fInfo.Info = "线路名称:" + psp.Name;
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 20;
                    fInfo.Show();

                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
            {
                string IsArea = ((XmlElement)e.SvgElement).GetAttribute("IsArea");
                if (IsArea != "")
                {
                    SelUseArea = "";
                    //XmlElement n1 = (XmlElement)e.SvgElement;
                    PointF[] pnts = ((Polygon)e.SvgElement).Points.Clone() as PointF[];
                    ((Polygon)e.SvgElement).Transform.Matrix.TransformPoints(pnts);
                    decimal temp1 = TLMath.getPolygonArea(pnts, 1);

                    temp1 = TLMath.getNumber2(temp1, tlVectorControl1.ScaleRatio) / Convert.ToDecimal(areaoption);
                    SelUseArea = temp1.ToString("#####.####");
                    //tip.Text = "区域面积:" + SelUseArea;
                    if (SelUseArea != "")
                    {
                        if (Convert.ToDecimal(SelUseArea) >= 1)
                        {
                            fInfo.Info = "区域面积:" + SelUseArea + "(KM²)";
                        }
                        else
                        {
                            fInfo.Info = "区域面积: 0" + SelUseArea + "(KM²)";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 12;
                    if (SelUseArea != "")
                    {
                        fInfo.Show();

                    }
                    //tip.ShowToolTip();
                }

            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Line")
            {
                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");
                if (IsLead != "")
                {
                    Line line = (Line)e.SvgElement;
                    decimal temp1 = TLMath.getLineLength(line, 1);
                    temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio);
                    string len = temp1.ToString("#####.####");
                    LineLen = len;
                    LineInfo lineInfo = new LineInfo();
                    lineInfo.EleID = e.SvgElement.ID;
                    lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    LineInfo _lineTemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", lineInfo);

                    if ((len != "") && (_lineTemp != null))
                    {
                        if (Convert.ToDecimal(len) >= 1)
                        {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3;
                        }
                        else
                        {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3;
                        }
                    }
                    else if (len != "")
                    {
                        if (Convert.ToDecimal(len) >= 1)
                        {
                            fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        }
                        else
                        {
                            fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 7;
                    fInfo.Height = 50;
                    if (len != "")
                    {
                        fInfo.Show();

                    }

                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline" && str_outjwd == "1")
            {
                PointF[] pf = ((Polyline)e.SvgElement).Points;
                ((Polyline)e.SvgElement).Transform.Matrix.TransformPoints(pf);

                string strM = "";
                for (int i = 0; i < pf.Length; i++)
                {
                    strM = strM + getJWD(mapview.ParseToLongLat(pf[i].X, pf[i].Y));
                }
                System.IO.FileInfo ff = new System.IO.FileInfo("c:\\temp.txt");
                System.IO.StreamWriter wt = ff.CreateText();
                wt.Write(strM);
                wt.Close();
                System.Diagnostics.Process.Start("c:\\temp.txt");
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline" && str_djcl == "1")
            {
                Layer lar = null;
                Layer lar2 = null;
                bool create = true;
                int TempObjRadius = Convert.ToInt32(ConfigurationSettings.AppSettings.Get("TempObjRadius"));
                int TempTextSize = Convert.ToInt32(ConfigurationSettings.AppSettings.Get("TempTextSize"));

                for (int n = 0; n < tlVectorControl1.SVGDocument.Layers.Count; n++)
                {
                    Layer l = tlVectorControl1.SVGDocument.Layers[n] as Layer;
                    if (l.Label == "临时显示层-杆塔号")
                    {
                        lar = l;
                    }
                    if (l.Label == "临时显示层-公里数")
                    {
                        lar2 = l;
                    }
                }
                if (!Layer.CkLayerExist("临时显示层-杆塔号", tlVectorControl1.SVGDocument))
                {
                    lar = Layer.CreateNew("临时显示层-杆塔号", tlVectorControl1.SVGDocument);
                    lar.SetAttribute("layerType", progtype);
                    lar.SetAttribute("ParentID", tlVectorControl1.SVGDocument.CurrentLayer.GetAttribute("ParentID"));
                    this.frmlar.checkedListBox1.SelectedIndex = -1;
                    this.frmlar.checkedListBox1.Items.Add(lar, true);
                    lar2 = Layer.CreateNew("临时显示层-公里数", tlVectorControl1.SVGDocument);
                    lar2.SetAttribute("layerType", progtype);
                    lar2.SetAttribute("ParentID", tlVectorControl1.SVGDocument.CurrentLayer.GetAttribute("ParentID"));
                    this.frmlar.checkedListBox1.SelectedIndex = -1;
                    this.frmlar.checkedListBox1.Items.Add(lar2, true);
                }
                string gt = ((XmlElement)e.SvgElement).GetAttribute("gt-info");
                string _gtxh = ((XmlElement)e.SvgElement).GetAttribute("gtxh-info");

                string[] gtid = gt.Split(",".ToCharArray());
                string[] strgtxh = _gtxh.Split(",".ToCharArray());

                XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("//* [@layer='" + lar.ID + "'] [@parentobj='" + ((Polyline)e.SvgElement).ID + "']");

                for (int kk = 0; kk < useList.Count; kk++)
                {
                    tlVectorControl1.SVGDocument.RootElement.RemoveChild(useList[kk]);
                }

                PointF[] pf = ((Polyline)e.SvgElement).Points;
                ((Polyline)e.SvgElement).Transform.Matrix.TransformPoints(pf);
                if (create)
                {
                    for (int i = 0; i < pf.Length; i++)
                    {

                        if (_gtxh == "")
                        {
                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                            n1.SetAttribute("cx", Convert.ToString(pf[i].X));
                            n1.SetAttribute("cy", Convert.ToString(pf[i].Y));
                            n1.SetAttribute("r", TempObjRadius.ToString());
                            n1.SetAttribute("layer", lar.ID);
                            n1.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID);
                            n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                        }
                        else
                        {
                            if (strgtxh.Length > i)
                            {
                                if (strgtxh[i] == "0")
                                {
                                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                                    n1.SetAttribute("cx", Convert.ToString(pf[i].X));
                                    n1.SetAttribute("cy", Convert.ToString(pf[i].Y));
                                    n1.SetAttribute("r", TempObjRadius.ToString());
                                    n1.SetAttribute("layer", lar.ID);
                                    n1.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID);
                                    n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                }
                                else
                                {
                                    XmlElement tk = tlVectorControl1.SVGDocument.CreateElement("rect") as RectangleElement;
                                    tk.SetAttribute("x", Convert.ToString(pf[i].X - 10));
                                    tk.SetAttribute("y", Convert.ToString(pf[i].Y - 10));
                                    tk.SetAttribute("width", Convert.ToString(TempObjRadius * 2));
                                    tk.SetAttribute("height", Convert.ToString(TempObjRadius * 2));
                                    tk.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID);
                                    tk.SetAttribute("style", "fill:#FFFFC0;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                    tk.SetAttribute("layer", lar.ID);
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(tk);
                                }
                            }
                        }
                        XmlElement t0 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                        t0.SetAttribute("x", Convert.ToString(pf[i].X));
                        t0.SetAttribute("y", Convert.ToString(pf[i].Y));
                        t0.SetAttribute("layer", lar.ID);
                        t0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                        t0.SetAttribute("font-famliy", "宋体");
                        t0.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID);
                        t0.SetAttribute("font-size", TempTextSize.ToString());

                        if (gtid.Length > i)
                        {
                            t0.InnerText = gtid[i] + "号";
                        }
                        else
                        {
                            t0.InnerText = Convert.ToString(i + 1) + "号";
                        }
                        tlVectorControl1.SVGDocument.RootElement.AppendChild(t0);
                    }
                    for (int i = 0; i < pf.Length - 1; i++)
                    {
                        double s = this.mapview.CountLength(pf[i], pf[i + 1]);
                        //   TLMath.getLength(pf[i], pf[i + 1], (decimal)tlVectorControl1.ScaleRatio);
                        XmlElement t0 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                        t0.SetAttribute("x", Convert.ToString((pf[i].X + pf[i + 1].X) / 2));
                        t0.SetAttribute("y", Convert.ToString((pf[i].Y + pf[i + 1].Y) / 2));
                        t0.SetAttribute("layer", lar2.ID);
                        t0.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID);
                        t0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                        t0.SetAttribute("font-famliy", "宋体");
                        t0.SetAttribute("font-size", TempTextSize.ToString());
                        t0.InnerText = s.ToString("0.##") + "km";
                        tlVectorControl1.SVGDocument.RootElement.AppendChild(t0);
                    }
                }
                str_djcl = "";
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline")
            {
                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");
                if (IsLead != "")
                {
                    Polyline polyline = (Polyline)e.SvgElement;
                    double temp1 = 0;
                    for (int i = 1; i < polyline.Points.Length; i++)
                    {
                        temp1 += this.mapview.CountLength(polyline.Points[i - 1], polyline.Points[i]);
                    }

                    //decimal temp1 = TLMath.getPolylineLength(polyline, 1);
                    //temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio);
                    string len = temp1.ToString("#####.####");
                    LineLen = len;
                    PSPDEV lineInfo = new PSPDEV();
                    lineInfo.SUID = ((XmlElement)e.SvgElement).GetAttribute("Deviceid");
                    // lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    PSPDEV _lineTemp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", lineInfo);

                    if ((len != "") && (_lineTemp != null))
                    {
                        if (Convert.ToDecimal(len) >= 1)
                        {
                            fInfo.Info = "线路名称:" + _lineTemp.Name + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.RateVolt.ToString() + "kV 投产年限:" + _lineTemp.OperationYear;
                        }
                        else
                        {
                            fInfo.Info = "线路名称:" + _lineTemp.Name + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.RateVolt.ToString() + "kV 投产年限:" + _lineTemp.OperationYear;
                        }
                    }
                    else if (len != "")
                    {
                        if (Convert.ToDecimal(len) >= 1)
                        {
                            fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        }
                        else
                        {
                            fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 7;
                    fInfo.Height = 50;
                    //fInfo.Right = fInfo.Left+fInfo.Info.Length*10;
                    if (len != "")
                    {
                        fInfo.Show();
                    }
                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Use")
            {
                string aaa = ((Use)e.SvgElement).RefElement.ID;
                //if (!aaa.Contains("Substation"))
                //{
                //    return;
                //}

                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");

                if (aaa.Contains("Substation"))
                {
                    PSP_Substation_Info sub = new PSP_Substation_Info();

                    string deviceid = ((XmlElement)e.SvgElement).GetAttribute("Deviceid");
                    //sub.AreaID = tlVectorControl1.SVGDocument.SvgdataUid;
                    PSP_Substation_Info _subTemp = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                    // PSP_Substation_Info _subTemp = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoListByEleID", sub);
                    if (_subTemp != null)
                    {
                        fInfo.Info = "变电站名称:" + _subTemp.Title + " 容量:" + _subTemp.L2.ToString("##.##") + "MVA\r\n" + " 电压等级:" + _subTemp.L1.ToString("##.##") + "kV 最大负荷:" + _subTemp.L9.ToString("##.##") + "MW \r\n 投产年限:" + _subTemp.S2;
                    }
                    else
                    {
                        fInfo.Info = "变电站名称:" + " " + " 容量:0" + "MVA" + "\r\n 电压等级: 最大负荷: \r\n 负荷率: 投产年限:";
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 5;
                    fInfo.Height = 60;
                    fInfo.Show();
                }
                if (aaa.Contains("kbs") || aaa.Contains("fjx") || aaa.Contains("pds") || aaa.Contains("byq") || aaa.Contains("hwg") || aaa.Contains("kg"))
                {
                    string deviceid = ((XmlElement)e.SvgElement).GetAttribute("Deviceid");
                    string s_name = "";
                    if (aaa.Contains("kbs"))
                    {
                        s_name = "开闭所";
                    }
                    if (aaa.Contains("fjx"))
                    {
                        s_name = "分接箱";
                    }
                    if (aaa.Contains("byq"))
                    {
                        s_name = "变压器";
                    }
                    if (aaa.Contains("hwg"))
                    {
                        s_name = "环网柜";
                    }
                    if (aaa.Contains("kg"))
                    {
                        s_name = "柱上开关";
                    }
                    if (aaa.Contains("pds"))
                    {
                        s_name = "配电室";
                    }
                    PSPDEV _subTemp = new PSPDEV();
                    _subTemp.SUID = deviceid;
                    _subTemp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", _subTemp);
                    //PSP_Gra_item sub = new PSP_Gra_item();
                    //sub.EleID = e.SvgElement.ID;
                    //sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    //sub.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    //PSP_Gra_item _subTemp = (PSP_Gra_item)Services.BaseService.GetObject("SelectPSP_Gra_itemByEleIDKey", sub);
                    if (_subTemp != null)
                    {
                        fInfo.Info = s_name + " 编号:" + _subTemp.EleID + " 名称:" + _subTemp.Name + " 电压等级:" + _subTemp.RateVolt + "kV";
                    }
                    else
                    {
                        fInfo.Info = s_name; // +"编号:   \r\n 名称: ";
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 15;
                    fInfo.Height = 60;
                    fInfo.Show();
                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.ConnectLine")
            {
                ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.CurrentElement;
                if (cline.StartGraph != null)
                {
                    string code = ((XmlElement)cline.StartGraph).GetAttribute("devxldm");

                    if (code != "")
                    {
                        xltProcessor.SelectLine(code);
                        tlVectorControl1.CurrentOperation = ToolOperation.Select;
                    }
                }
            }
            /*  if (tlVectorControl1.Operation == ToolOperation.LeadLine)
              {
                  string gt = sgt1.Text;
                  XmlElement u1 = tlVectorControl1.SVGDocument.CreateElement("use") as Use;
                  Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                  u1.SetAttribute("xlink:href", "#" + gt + "0");
                  u1.SetAttribute("x", point1.X.ToString());
                  u1.SetAttribute("y", point1.Y.ToString());
                  u1.SetAttribute("layer", SvgDocument.currentLayer);
                  u1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                  tlVectorControl1.SVGDocument.RootElement.AppendChild(u1);
              }*/
            //tlVectorControl1.SVGDocument.CurrentElement = null;
        }
コード例 #2
0
ファイル: frmMain_wh.cs プロジェクト: EdgarEDT/myitoppsp
        void tlVectorControl1_LeftClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e)
        {
            //SvgElement ele2 = tlVectorControl1.CreateBySymbolID("kbs-8", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
            //ele2 = tlVectorControl1.AddShape(ele2, Point.Empty);
            if (tlVectorControl1.SVGDocument.CurrentElement != null &&
                tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("xlink:href").Contains("XL_GT_1")) {
                sel_start_point = tlVectorControl1.SVGDocument.CurrentElement.ID;
            }

            if (sel_sym == "bt_start") {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_1", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele = tlVectorControl1.AddShape(ele, Point.Empty);
                ele.SetAttribute("order", "0");
                ele.SetAttribute("start_point", ele.ID);
            }
            if (sel_sym == "bt_end") {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_2", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele.SetAttribute("start_point", sel_start_point);
                ele.SetAttribute("order", "999");
                tlVectorControl1.AddShape(ele, Point.Empty);
            }
            if (sel_sym == "bt_must") {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_3", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele.SetAttribute("start_point", sel_start_point);
                tlVectorControl1.AddShape(ele, Point.Empty);
                frmInputNum num = new frmInputNum();
                num.ShowDialog();
                ele.SetAttribute("order", num.InputStrSEL);
            }
            if (sel_sym == "bt_point") {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_4", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele.SetAttribute("start_point", sel_start_point);
                tlVectorControl1.AddShape(ele, Point.Empty);
                frmInputNum num = new frmInputNum();
                num.ShowDialog();
                ele.SetAttribute("order", num.InputStrSEL);
            }
            //if (sel_sym != "" && sel_start_point!="")
            //{
            //    XmlNodeList il= tlVectorControl1.SVGDocument.SelectNodes("svg/use [@start_point='" + sel_start_point + "']");
            //    if (il.Count < 3)
            //    {
            //        return;
            //    }
            //    for (int i = 0; i < il.Count;i++ )
            //    {
            //        Use u = (Use)il[i];
            //        PointF f = u.CenterPoint;

            //    }
            //    //PointF[] pnt = ((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)).Points;
            //    //if (pnt.Length < 3) return;
            //    for (int i = 0; i < il.Count; i++)
            //    {
            //        double ang = TLMath.getLineAngle(((Use)il[i]).CenterPoint, ((Use)il[i + 1]).CenterPoint, ((Use)il[i + 2]).CenterPoint);
            //        if (ang * 57.3 > 60)
            //        {
            //            MessageBox.Show("线路转角不能大于60度。\r\n "+"第" + (i + 1) + "转角:" + Convert.ToDouble(ang * 57.3).ToString("##.##") + "度。\r\n", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //           // tlVectorControl1.Delete();
            //            return;
            //        }

            //        if (i == il.Count - 3)
            //        {
            //            break;
            //        }
            //    }
            //}
            if (csOperation == CustomOperation.OP_MeasureDistance) {
                Polyline pl = tlVectorControl1.SVGDocument.CurrentElement as Polyline;
                if (pl.Points.Length > 1) {
                    double d = 0;
                    for (int i = 1; i < pl.Points.Length; i++) {
                        d += this.mapview.CountLength(pl.Points[i - 1], pl.Points[i]);
                    }
                    label1.Text = d + "公里";

                    Point pt = new Point(e.Mouse.X, e.Mouse.Y);
                    pt = PointToClient(tlVectorControl1.PointToScreen(pt));
                    //tlVectorControl1.SetToolTip(label1.Text);
                    label1.Left = pt.X;
                    label1.Top = pt.Y;

                    label1.Visible = true;
                }
                return;
            }
            //System.IO.FileInfo ff = new System.IO.FileInfo("c:\\1111.txt");
            //System.IO.StreamWriter wt= ff.CreateText();
            //wt.Write(tlVectorControl1.SVGDocument.OuterXml);
            //wt.Close();
            //SortedList l = new SortedList();
            //l.Add("1", "aaa");
            //l.Add("5", "bbb");
            //l.Add("2", "ccc");

            //if (tlVectorControl1.ScaleRatio < 0.1f) {
            //    tlVectorControl1.ScaleRatio = 0.1f;
            //    scaleBox.ComboBoxEx.Text = "";
            //    scaleBox.SelectedText = "10%";
            //}
            tip.Hide();
            fInfo.Hide();

            if (tlVectorControl1.Operation == ToolOperation.Text) {
                frmTextInput ft = new frmTextInput();
                if (ft.ShowDialog() == DialogResult.OK) {
                    string txt = ft.Content;
                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                    Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    n1.SetAttribute("x", point1.X.ToString());
                    n1.SetAttribute("y", point1.Y.ToString());
                    n1.InnerText = txt;
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                    tlVectorControl1.Operation = ToolOperation.Select;
                }
            }
            if (MapType == "规划统计") {
                try {
                    if (e.SvgElement.ID == "svg") {
                        MapType = "接线图";
                        return;
                    }
                    if (((Polygon)e.SvgElement) == null) return;
                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                    Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    n1.SetAttribute("cx", point1.X.ToString());
                    n1.SetAttribute("cy", point1.Y.ToString());
                    n1.SetAttribute("r", "42.5");
                    n1.SetAttribute("r", "42.5");
                    //n1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID);
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;");
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);

                    frmMainProperty fmain = new frmMainProperty();
                    glebeProperty gp = new glebeProperty();
                    gp.EleID = ((XmlElement)e.SvgElement).GetAttribute("id");
                    gp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    //fmain.InitData(gp); ///////////////////////////////////

                    XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("use");

                    PointF[] tfArray1 = TLMath.getPolygonPoints((XmlElement)e.SvgElement);
                    string str220 = "";
                    string str110 = "";
                    string str66 = "";
                    GraphicsPath selectAreaPath = new GraphicsPath();
                    selectAreaPath.AddLines(tfArray1);
                    selectAreaPath.CloseFigure();
                    //Matrix x=new Matrix(
                    //Region region1 = new Region(selectAreaPath);
                    for (int i = 0; i < nlist.Count; i++) {
                        float OffX = 0f;
                        float OffY = 0f;
                        Use use = (Use)nlist[i];
                        if (use.GetAttribute("xlink:href").Contains("Substation")) {
                            string strMatrix = use.GetAttribute("transform");
                            if (strMatrix != "") {
                                strMatrix = strMatrix.Replace("matrix(", "");
                                strMatrix = strMatrix.Replace(")", "");
                                string[] mat = strMatrix.Split(',');
                                if (mat.Length > 5) {
                                    OffX = Convert.ToSingle(mat[4]);
                                    OffY = Convert.ToSingle(mat[5]);
                                }
                            }
                            PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href"));
                            if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY)) {
                                if (use.GetAttribute("xlink:href").Contains("220")) {
                                    str220 = str220 + "'" + use.GetAttribute("id") + "',";
                                }
                                if (use.GetAttribute("xlink:href").Contains("110")) {
                                    str110 = str110 + "'" + use.GetAttribute("id") + "',";
                                }
                                if (use.GetAttribute("xlink:href").Contains("66")) {
                                    str66 = str66 + "'" + use.GetAttribute("id") + "',";
                                }
                            }
                        }
                    }
                    if (str220.Length > 1) {
                        str220 = str220.Substring(0, str220.Length - 1);
                    }
                    if (str110.Length > 1) {
                        str110 = str110.Substring(0, str110.Length - 1);
                    }
                    if (str66.Length > 1) {
                        str66 = str66.Substring(0, str66.Length - 1);
                    }
                    fmain.InitData(gp, str220, str110, str66);

                    XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                    Point point2 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    t1.SetAttribute("x", Convert.ToString(point2.X - 20));
                    t1.SetAttribute("y", Convert.ToString(point2.Y - 10));
                    // t1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID);
                    t1.SetAttribute("layer", SvgDocument.currentLayer);
                    t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                    t1.SetAttribute("font-famliy", "宋体");
                    t1.SetAttribute("font-size", "14");
                    t1.InnerText = fmain.glebeProp.Area + "\r\n" + fmain.glebeProp.Burthen; //+"\r\n" + fmain.glebeProp.Number;
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(t1);
                    tlVectorControl1.Refresh();
                    fmain.Dispose();
                    MapType = "接线图";
                } catch (Exception e2) { MapType = "接线图"; }
            }
            if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1) {
                return;
            }
            decimal ViewScale = 1;
            string str_Scale = tlVectorControl1.SVGDocument.getViewScale();
            if (str_Scale != "") {
                ViewScale = Convert.ToDecimal(str_Scale);
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                string IsArea = ((XmlElement)e.SvgElement).GetAttribute("IsArea");
                if (IsArea != "") {

                    XmlElement n1 = (XmlElement)e.SvgElement;
                    string str_points = n1.GetAttribute("points");
                    string[] points = str_points.Split(",".ToCharArray());
                    PointF[] pnts = new PointF[points.Length];

                    for (int i = 0; i < points.Length; i++) {
                        string[] pointsXY = points[i].Split(" ".ToCharArray());
                        pnts[i].X = Convert.ToSingle(pointsXY[0]);
                        pnts[i].Y = Convert.ToSingle(pointsXY[1]);
                    }
                    decimal temp1 = TLMath.getPolygonArea(pnts, 1);

                    temp1 = TLMath.getNumber2(temp1, tlVectorControl1.ScaleRatio);
                    SelUseArea = temp1.ToString("#####.####");
                    //tip.Text = "区域面积:" + SelUseArea;
                    if (SelUseArea != "") {
                        if (Convert.ToDecimal(SelUseArea) >= 1) {
                            fInfo.Info = "区域面积:" + SelUseArea + "(KM²)";
                        } else {
                            fInfo.Info = "区域面积: 0" + SelUseArea + "(KM²)";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 12;
                    if (SelUseArea != "") {
                        fInfo.Show();

                    }
                    //tip.ShowToolTip();
                }

            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Line") {
                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");
                if (IsLead != "") {
                    Line line = (Line)e.SvgElement;
                    decimal temp1 = TLMath.getLineLength(line, 1);
                    temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio);
                    string len = temp1.ToString("#####.####");
                    LineLen = len;
                    LineInfo lineInfo = new LineInfo();
                    lineInfo.EleID = e.SvgElement.ID;
                    lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    LineInfo _lineTemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", lineInfo);

                    if ((len != "") && (_lineTemp != null)) {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3;
                        } else {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3;
                        }
                    } else if (len != "") {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        } else {
                            fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 7;
                    fInfo.Height = 50;
                    if (len != "") {
                        fInfo.Show();

                    }

                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");
                if (IsLead != "") {
                    Polyline polyline = (Polyline)e.SvgElement;
                    decimal temp1 = TLMath.getPolylineLength(polyline, 1);
                    temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio);
                    string len = temp1.ToString("#####.####");
                    LineLen = len;
                    LineInfo lineInfo = new LineInfo();
                    lineInfo.EleID = e.SvgElement.ID;
                    lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    LineInfo _lineTemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", lineInfo);

                    if ((len != "") && (_lineTemp != null)) {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3;
                        } else {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3;
                        }
                    } else if (len != "") {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        } else {
                            fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 7;
                    fInfo.Height = 50;
                    //fInfo.Right = fInfo.Left+fInfo.Info.Length*10;
                    if (len != "") {
                        fInfo.Show();
                    }
                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Use") {
                string aaa = ((Use)e.SvgElement).RefElement.ID;
                //if (!aaa.Contains("Substation"))
                //{
                //    return;
                //}

                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");

                if (aaa.Contains("Substation")) {
                    substation sub = new substation();
                    sub.EleID = e.SvgElement.ID;
                    sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    substation _subTemp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", sub);
                    if (_subTemp != null) {
                        fInfo.Info = "变电站名称:" + _subTemp.EleName + " 容量:" + _subTemp.Number + "MVA\r\n" + " 电压等级:" + _subTemp.ObligateField1 + "kV 最大负荷:" + _subTemp.Burthen + "MW \r\n 负荷率:" + _subTemp.ObligateField2 + " 投产年限:" + _subTemp.ObligateField5;
                    } else {
                        fInfo.Info = "变电站名称:" + " " + " 容量:0" + "MVA" + "\r\n 电压等级: 最大负荷: \r\n 负荷率: 投产年限:";
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 5;
                    fInfo.Height = 60;
                    fInfo.Show();
                }
                if (aaa.Contains("kbs") || aaa.Contains("fjx") || aaa.Contains("byq")) {
                    string s_name = "";
                    if (aaa.Contains("kbs")) {
                        s_name = "开闭所";
                    }
                    if (aaa.Contains("fjx")) {
                        s_name = "分接箱";
                    }
                    if (aaa.Contains("byq")) {
                        s_name = "变压器";
                    }
                    PSP_Gra_item sub = new PSP_Gra_item();
                    sub.EleID = e.SvgElement.ID;
                    sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    sub.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    PSP_Gra_item _subTemp = (PSP_Gra_item)Services.BaseService.GetObject("SelectPSP_Gra_itemByEleIDKey", sub);
                    if (_subTemp != null) {
                        fInfo.Info = s_name + "编号:" + _subTemp.EleKeyID + "\r\n 名称:" + _subTemp.EleName;
                    } else {
                        fInfo.Info = s_name + "编号:   \r\n 名称: ";
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 8;
                    fInfo.Height = 60;
                    fInfo.Show();
                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") {
                ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.CurrentElement;
                if (cline.StartGraph != null) {
                    string code = ((XmlElement)cline.StartGraph).GetAttribute("devxldm");

                    if (code != "") {
                        xltProcessor.SelectLine(code);
                        tlVectorControl1.CurrentOperation = ToolOperation.Select;
                    }
                }
            }
            /*  if (tlVectorControl1.Operation == ToolOperation.LeadLine)
              {
                  string gt = sgt1.Text;
                  XmlElement u1 = tlVectorControl1.SVGDocument.CreateElement("use") as Use;
                  Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                  u1.SetAttribute("xlink:href", "#" + gt + "0");
                  u1.SetAttribute("x", point1.X.ToString());
                  u1.SetAttribute("y", point1.Y.ToString());
                  u1.SetAttribute("layer", SvgDocument.currentLayer);
                  u1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                  tlVectorControl1.SVGDocument.RootElement.AppendChild(u1);
              }*/
            //tlVectorControl1.SVGDocument.CurrentElement = null;
        }
コード例 #3
0
ファイル: frmMain2.cs プロジェクト: EdgarEDT/myitoppsp
        void tlVectorControl1_LeftClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e)
        {
            if (csOperation == CustomOperation.OP_MeasureDistance) {
                Polyline pl = tlVectorControl2.SVGDocument.CurrentElement as Polyline;
                if (pl.Points.Length > 1) {
                    double d = 0;
                    for (int i = 1; i < pl.Points.Length; i++) {
                        d += this.mapview.CountLength(pl.Points[i - 1], pl.Points[i]);
                    }
                    label1.Text = d + "公里";

                    Point pt = new Point(e.Mouse.X, e.Mouse.Y);
                    pt = PointToClient(tlVectorControl2.PointToScreen(pt));
                    //tlVectorControl1.SetToolTip(label1.Text);
                    label1.Left = pt.X;
                    label1.Top = pt.Y;

                    label1.Visible = true;
                }
                return;
            }
            //System.IO.FileInfo ff = new System.IO.FileInfo("c:\\1111.txt");
            //System.IO.StreamWriter wt= ff.CreateText();
            //wt.Write(tlVectorControl1.SVGDocument.OuterXml);
            //wt.Close();
            //SortedList l = new SortedList();
            //l.Add("1", "aaa");
            //l.Add("5", "bbb");
            //l.Add("2", "ccc");

            //if (tlVectorControl1.ScaleRatio < 0.1f) {
            //    tlVectorControl1.ScaleRatio = 0.1f;
            //    scaleBox.ComboBoxEx.Text = "";
            //    scaleBox.SelectedText = "10%";
            //}
            tip.Hide();
            fInfo.Hide();
            if (tlVectorControl2.Operation == ToolOperation.Text) {
                frmTextInput ft = new frmTextInput();
                if (ft.ShowDialog() == DialogResult.OK) {
                    string txt = ft.Content;
                    XmlElement n1 = tlVectorControl2.SVGDocument.CreateElement("text") as Text;
                    Point point1 = tlVectorControl2.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    n1.SetAttribute("x", point1.X.ToString());
                    n1.SetAttribute("y", point1.Y.ToString());
                    n1.InnerText = txt;
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    tlVectorControl2.SVGDocument.RootElement.AppendChild(n1);
                    tlVectorControl2.Operation = ToolOperation.Select;
                }
            }
            if (MapType == "规划统计") {
                try {
                    if (e.SvgElement.ID == "svg") {
                        MapType = "接线图";
                        return;
                    }
                    if(((Polygon)e.SvgElement )==null)return;
                    XmlElement n1 = tlVectorControl2.SVGDocument.CreateElement("circle") as Circle;
                    Point point1 = tlVectorControl2.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    n1.SetAttribute("cx", point1.X.ToString());
                    n1.SetAttribute("cy", point1.Y.ToString());
                    n1.SetAttribute("r", "42.5");
                    n1.SetAttribute("r", "42.5");
                    //n1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID);
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;");
                    tlVectorControl2.SVGDocument.RootElement.AppendChild(n1);

                    frmMainProperty fmain = new frmMainProperty();
                    glebeProperty gp = new glebeProperty();
                    gp.EleID = ((XmlElement)e.SvgElement).GetAttribute("id");
                    gp.SvgUID = tlVectorControl2.SVGDocument.SvgdataUid;
                    //fmain.InitData(gp); ///////////////////////////////////

                    XmlNodeList nlist = tlVectorControl2.SVGDocument.GetElementsByTagName("use");

                    PointF[] tfArray1 = TLMath.getPolygonPoints((XmlElement)e.SvgElement);
                    string str220 = "";
                    string str110 = "";
                    string str66 = "";
                    GraphicsPath selectAreaPath = new GraphicsPath();
                    selectAreaPath.AddLines(tfArray1);
                    selectAreaPath.CloseFigure();
                    //Matrix x=new Matrix(
                    //Region region1 = new Region(selectAreaPath);
                    for (int i = 0; i < nlist.Count; i++) {
                        float OffX = 0f;
                        float OffY = 0f;
                        Use use = (Use)nlist[i];
                        if (use.GetAttribute("xlink:href").Contains("Substation")) {
                            string strMatrix = use.GetAttribute("transform");
                            if (strMatrix != "") {
                                strMatrix = strMatrix.Replace("matrix(", "");
                                strMatrix = strMatrix.Replace(")", "");
                                string[] mat = strMatrix.Split(',');
                                if (mat.Length > 5) {
                                    OffX = Convert.ToSingle(mat[4]);
                                    OffY = Convert.ToSingle(mat[5]);
                                }
                            }
                            PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href"));
                            if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY)) {
                                if (use.GetAttribute("xlink:href").Contains("220")) {
                                    str220 = str220 + "'" + use.GetAttribute("id") + "',";
                                }
                                if (use.GetAttribute("xlink:href").Contains("110")) {
                                    str110 = str110 + "'" + use.GetAttribute("id") + "',";
                                }
                                if (use.GetAttribute("xlink:href").Contains("66"))
                                {
                                    str66 = str66 + "'" + use.GetAttribute("id") + "',";
                                }
                            }
                        }
                    }
                    if (str220.Length > 1) {
                        str220 = str220.Substring(0, str220.Length - 1);
                    }
                    if (str110.Length > 1) {
                        str110 = str110.Substring(0, str110.Length - 1);
                    }
                    if (str66.Length > 1)
                    {
                        str66 = str66.Substring(0, str66.Length - 1);
                    }

                    fmain.InitData(gp, str220, str110,str66);

                    XmlElement t1 = tlVectorControl2.SVGDocument.CreateElement("text") as Text;
                    Point point2 = tlVectorControl2.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    t1.SetAttribute("x", Convert.ToString(point2.X - 20));
                    t1.SetAttribute("y", Convert.ToString(point2.Y - 10));
                    // t1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID);
                    t1.SetAttribute("layer", SvgDocument.currentLayer);
                    t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                    t1.SetAttribute("font-famliy", "宋体");
                    t1.SetAttribute("font-size", "14");
                    t1.InnerText = fmain.glebeProp.Area + "\r\n" + fmain.glebeProp.Burthen; //+"\r\n" + fmain.glebeProp.Number;
                    tlVectorControl2.SVGDocument.RootElement.AppendChild(t1);
                    tlVectorControl2.Refresh();
                    fmain.Dispose();
                    MapType = "接线图";
                } catch (Exception e2) { MapType = "接线图"; }
            }
            if (tlVectorControl2.SVGDocument.SelectCollection.Count > 1) {
                return;
            }
            decimal ViewScale = 1;
            string str_Scale = tlVectorControl2.SVGDocument.getViewScale();
            if (str_Scale != "") {
                ViewScale = Convert.ToDecimal(str_Scale);
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                string IsArea = ((XmlElement)e.SvgElement).GetAttribute("IsArea");
                if (IsArea != "") {

                    XmlElement n1 = (XmlElement)e.SvgElement;
                    string str_points = n1.GetAttribute("points");
                    string[] points = str_points.Split(",".ToCharArray());
                    PointF[] pnts = new PointF[points.Length];

                    for (int i = 0; i < points.Length; i++) {
                        string[] pointsXY = points[i].Split(" ".ToCharArray());
                        pnts[i].X = Convert.ToSingle(pointsXY[0]);
                        pnts[i].Y = Convert.ToSingle(pointsXY[1]);
                    }
                    decimal temp1 = TLMath.getPolygonArea(pnts, 1);

                    temp1 = TLMath.getNumber2(temp1, tlVectorControl2.ScaleRatio);
                    SelUseArea = temp1.ToString("#####.####");
                    //tip.Text = "区域面积:" + SelUseArea;
                    if (SelUseArea != "") {
                        if (Convert.ToDecimal(SelUseArea) >= 1) {
                            fInfo.Info = "区域面积:" + SelUseArea + "(KM²)";
                        } else {
                            fInfo.Info = "区域面积: 0" + SelUseArea + "(KM²)";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    if (SelUseArea != "") {
                        fInfo.Show();

                    }
                    //tip.ShowToolTip();
                }

            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Line") {
                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");
                if (IsLead != "") {
                    Line line = (Line)e.SvgElement;
                    decimal temp1 = TLMath.getLineLength(line, 1);
                    temp1 = TLMath.getNumber(temp1, tlVectorControl2.ScaleRatio);
                    string len = temp1.ToString("#####.####");
                    LineLen = len;
                    if (len != "") {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路长度:" + len + "(KM)";
                        } else {
                            fInfo.Info = "线路长度: 0" + len + "(KM)";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    if (len != "") {
                        fInfo.Show();

                    }

                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");
                if (IsLead != "") {
                    Polyline polyline = (Polyline)e.SvgElement;
                    decimal temp1 = TLMath.getPolylineLength(polyline, 1);
                    temp1 = TLMath.getNumber(temp1, tlVectorControl2.ScaleRatio);
                    string len = temp1.ToString("#####.####");
                    LineLen = len;
                    if (len != "") {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路长度:" + len + "(KM)";
                        } else {
                            fInfo.Info = "线路长度: 0" + len + "(KM)";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    if (len != "") {
                        fInfo.Show();
                    }

                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") {
                ConnectLine cline = (ConnectLine)tlVectorControl2.SVGDocument.CurrentElement;
                if (cline.StartGraph != null) {
                    string code = ((XmlElement)cline.StartGraph).GetAttribute("devxldm");

                    if (code != "") {
                        xltProcessor.SelectLine(code);
                        tlVectorControl2.CurrentOperation = ToolOperation.Select;
                    }
                }
            }
            /*  if (tlVectorControl1.Operation == ToolOperation.LeadLine)
              {
                  string gt = sgt1.Text;
                  XmlElement u1 = tlVectorControl1.SVGDocument.CreateElement("use") as Use;
                  Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                  u1.SetAttribute("xlink:href", "#" + gt + "0");
                  u1.SetAttribute("x", point1.X.ToString());
                  u1.SetAttribute("y", point1.Y.ToString());
                  u1.SetAttribute("layer", SvgDocument.currentLayer);
                  u1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                  tlVectorControl1.SVGDocument.RootElement.AppendChild(u1);
              }*/
            //tlVectorControl1.SVGDocument.CurrentElement = null;
        }