Example #1
0
        /*public void ResetPoly()
        {
            SvgElementCollection col= tlVectorControl1.SVGDocument.SelectCollection;
            if(col.Count<1){
                return;
            }
            SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();
            foreach(SvgElement ele in col){
                if (ele.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                {
                    glebeProperty p=new glebeProperty();
                    p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    p.EleID = ((IGraph)ele).ID;
                    p = Services.BaseService.GetObject("SelectglebePropertyByEleID", p);
                    if(p!=null){
                        PointF[] tfArray1 = TLMath.getPolygonPoints(ele);
                        GraphicsPath selectAreaPath = new GraphicsPath();
                        selectAreaPath.AddLines(tfArray1);
                        selectAreaPath.CloseFigure();
                        Region region1 = new Region(selectAreaPath);
                        while (enumerator1.MoveNext())
                        {
                            IGraph graph1 = (IGraph)enumerator1.Current;
                            GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                            path1.Transform(graph1.GraphTransform.Matrix);
                            Region region2 = new Region(path1);
                            region2.Intersect(region1);
                            if (!region2.GetBounds(Graphics.FromHwnd(IntPtr.Zero)).IsEmpty)
                            {
                                glebeProperty p1 = new glebeProperty();
                                p1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                p1.EleID = graph1.ID;
                                p1 = Services.BaseService.GetObject("SelectglebePropertyByEleID", p1);
                                if(p1!=null){
                                    p1.ParentEleID = p.UID;
                                    Services.BaseService.Update("UpdateglebePropertyAreaAll", p1);
                                }
                            }
                        }
                    }
                }
            }
            MessageBox.Show("更新完成。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }*/
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try {
                if (e.ClickedItem.Text == "属性") {
                    XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    //PointF[] pf = TLMath.getPolygonPoints(xml1);

                    //((Polygon)xml1).Transform.Matrix.TransformPoints(pf);
                    // 规划
                    if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) {

                        if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请先选择规划区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") {
                            //frmImgManager frm = new frmImgManager();
                            //frm.Show();
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            XmlNodeList n1 = tlVectorControl1.SVGDocument.GetElementsByTagName("use");
                            PointF[] tfArray1 = TLMath.getPolygonPoints(xml1);
                            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 < n1.Count; i++) {
                                float OffX = 0f;
                                float OffY = 0f;
                                bool ck = false;
                                Use use = (Use)n1[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]);
                                        }
                                    }
                                    if (frmlar.getSelectedLayer().Contains(use.GetAttribute("layer"))) {
                                        ck = true;
                                    }
                                    PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href"));
                                    if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY) && ck) {
                                        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);
                            }
                            glebeProperty _gle = new glebeProperty();
                            _gle.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                            _gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;

                            IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle);
                            if (UseProList.Count > 0) {
                                _gle = UseProList[0];
                                _gle.LayerID = SvgDocument.currentLayer;
                                frmMainProperty f = new frmMainProperty();

                                f.InitData(_gle, str220, str110, str66);

                                f.ShowDialog();
                                if (f.checkBox1.Checked == false) {
                                    tlVectorControl1.SVGDocument.RootElement.RemoveChild(tlVectorControl1.SVGDocument.CurrentElement);
                                }
                                //tlVectorControl1.Refresh();
                            }
                            //}
                        }

                    }
                    if (getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())) {

                        if (tlVectorControl1.SVGDocument.getRZBRatio() != "") {
                            rzb = tlVectorControl1.SVGDocument.getRZBRatio();
                        }

                        if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请先选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            string IsArea = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsArea");
                            if (IsArea != "") {
                                frmProperty f = new frmProperty();
                                if (SelUseArea == "") { SelUseArea = "0"; }
                                f.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer);
                                //f.ShowDialog();
                                if (progtype != "城市规划层") {
                                    f.IsReadonly = true;
                                }
                                if (f.ShowDialog() == DialogResult.OK) {
                                    SVG_ENTITY ent = new SVG_ENTITY();
                                    if (f.IsCreate) {
                                        ent.SUID = Guid.NewGuid().ToString();
                                        ent.EleID = f.gPro.EleID;
                                        ent.layerID = f.gPro.LayerID;
                                        ent.MDATE = System.DateTime.Now;
                                        ent.NAME = f.gPro.UseID;
                                        ent.svgID = f.gPro.SvgUID;
                                        ent.TYPE = "polygon-dk";
                                        //ent.voltage = f.gPro.Voltage;
                                        Services.BaseService.Create<SVG_ENTITY>(ent);
                                    } else {
                                        ent.NAME = f.gPro.UseID;
                                        ent.layerID = f.gPro.LayerID;
                                        ent.MDATE = System.DateTime.Now;
                                        //ent.voltage = fl.Line.Voltage;
                                        Services.BaseService.Update<SVG_ENTITY>(ent);
                                    }
                                    if (f.gPro.ObligateField1 != "") {
                                        string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(f.gPro.ObligateField1)));
                                        color1 = "fill:" + color1 + ";";
                                        ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", color1);
                                        tlVectorControl1.UpdateProperty();
                                    }

                                }
                            }
                        }
                    }

                    if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                        string lineWidth = "2";
                        string IsLead = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsLead");
                        //if (IsLead != "")       //原先导线的属性添加情况
                        //{
                        //    frmLineProperty fl = new frmLineProperty();
                        //    fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement;
                        //    fl.InitData(tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, LineLen, SvgDocument.currentLayer);
                        //    if (fl.ShowDialog() == DialogResult.OK)
                        //    {
                        //        SVG_ENTITY ent = new SVG_ENTITY();
                        //        if (fl.IsCreate)
                        //        {
                        //            ent.SUID = Guid.NewGuid().ToString();
                        //            ent.EleID = fl.Line.EleID;
                        //            ent.layerID = fl.Line.LayerID;
                        //            ent.MDATE = System.DateTime.Now;
                        //            ent.NAME = fl.Line.LineName;
                        //            ent.svgID = fl.Line.SvgUID;
                        //            ent.TYPE = "line";
                        //            ent.voltage =Convert.ToInt32(fl.Line.Voltage);
                        //            Services.BaseService.Create<SVG_ENTITY>(ent);
                        //        }
                        //        else
                        //        {
                        //            ent.NAME = fl.Line.LineName;
                        //            ent.layerID = fl.Line.LayerID;
                        //            ent.MDATE = System.DateTime.Now;
                        //            ent.voltage =Convert.ToInt32( fl.Line.Voltage);
                        //            Services.BaseService.Update<SVG_ENTITY>(ent);
                        //        }

                        //        lineWidth = fl.LineWidth;
                        //        string styleValue = "";
                        //        if (fl.Line.ObligateField1 == "规划")
                        //        {
                        //            styleValue = "stroke-dasharray:" + ghType + ";stroke-width:" + lineWidth + ";";
                        //        }
                        //        else
                        //        {
                        //            styleValue = "stroke-width:" + lineWidth + ";";
                        //        }
                        //        //string aa= ColorTranslator.ToHtml(Color.Black);
                        //        styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                        //        SvgElement se = tlVectorControl1.SVGDocument.CurrentElement;
                        //        se.RemoveAttribute("style");
                        //        se.SetAttribute("style", styleValue);
                        //        se.SetAttribute("info-name", fl.Line.LineName);

                        //    }
                        //}
                        if (IsLead != "")       //修改后的导线的属性添加情况
                        {
                            PSPDEV obj = new PSPDEV();
                            string deviceid = xml1.GetAttribute("Deviceid");
                            if (string.IsNullOrEmpty(deviceid)) {
                                obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.XL, Itop.Client.MIS.ProgUID);
                                if (obj==null)
                                {
                                    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    tlVectorControl1.Delete();
                                }
                                if ( obj is PSPDEV) {
                                    deviceid = ((PSPDEV)obj).SUID;
                                    xml1.SetAttribute("Deviceid", deviceid);
                                }
                            }
                            if (!string.IsNullOrEmpty(deviceid)) {
                                obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                                if (obj != null) {
                                    xml1.SetAttribute("info-name", ((PSPDEV)obj).Name);
                                    DeviceHelper.ShowDeviceDlg(DeviceType.XL, deviceid, false);
                                }

                                LineInfo li = new LineInfo();
                                li.UID = obj.SUID;
                                li = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByKey", li);
                                if (li != null) {
                                    li.LayerID = SvgDocument.currentLayer;
                                    li.EleID = xml1.GetAttribute("id");
                                    li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    LineType lt = new LineType();
                                    lt.TypeName = li.Voltage.ToString() + "kV";
                                    lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt);
                                    li.ObligateField3 = obj.OperationYear;
                                    if (lt != null)
                                    {
                                        li.ObligateField2 = lt.Color;
                                        lineWidth = lt.ObligateField1;
                                    }

                                    if (!string.IsNullOrEmpty(li.ObligateField3)) {
                                        if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) {
                                            li.ObligateField1 = "规划";
                                        } else
                                            li.ObligateField1 = "运行";
                                    }
                                    Services.BaseService.Update<LineInfo>(li);
                                } else {
                                    li = new LineInfo();
                                    li.UID = obj.SUID;
                                    li.LineName = obj.Name;
                                    li.Length = obj.LineLength.ToString();
                                    li.LineType = obj.LineType;
                                    li.Voltage = obj.ReferenceVolt.ToString();
                                    li.EleID = xml1.GetAttribute("id");
                                    li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    LineType lt = new LineType();
                                    lt.TypeName = obj.ReferenceVolt.ToString() + "kV";
                                    lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt);
                                    li.ObligateField3 = obj.OperationYear;
                                    if (lt != null)
                                    {
                                        li.ObligateField2 = lt.Color;
                                        lineWidth = lt.ObligateField1;
                                    }

                                    if (!string.IsNullOrEmpty(li.ObligateField3)) {
                                        if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) {
                                            li.ObligateField1 = "规划";
                                        } else
                                            li.ObligateField1 = "运行";
                                    }

                                    Services.BaseService.Create<LineInfo>(li);
                                }

                                string styleValue = "";
                                if (li.ObligateField1 == "规划") {
                                    styleValue = "stroke-dasharray:" + ghType + ";stroke-width:" + lineWidth + ";";
                                } else {
                                    styleValue = "stroke-width:" + lineWidth + ";";
                                }
                                //string aa= ColorTranslator.ToHtml(Color.Black);
                                styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(li.ObligateField2)));
                                SvgElement se = tlVectorControl1.SVGDocument.CurrentElement;
                                se.RemoveAttribute("style");
                                se.SetAttribute("style", styleValue);
                                se.SetAttribute("info-name", li.LineName);
                                //***** ********添加FistNode和LastNode
                                XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");

                                foreach (XmlNode element in useList) {
                                    if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid"))) {
                                        string con = "WHERE SvgUID='" + (element as XmlElement).GetAttribute("Deviceid") + "'AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='01'";
                                        IList pspMX = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                        if (pspMX != null) {
                                            foreach (PSPDEV pspmx in pspMX) {
                                                if (obj.IName == pspmx.Name) {
                                                    (xml1 as XmlElement).SetAttribute("FirstNode", (element as XmlElement).GetAttribute("id"));

                                                } else if (obj.JName == pspmx.Name) {
                                                    (xml1 as XmlElement).SetAttribute("LastNode", (element as XmlElement).GetAttribute("id"));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            //**

                        }
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("Substation") || xml1.GetAttribute("xlink:href").Contains("Power")) {
                        string lab = xml1.GetAttribute("xlink:href");

                        float x = 0f;
                        float y = 0f;

                        x = ((Use)xml1).X;

                        y = ((Use)xml1).Y;

                        PointF p1 = new PointF(x, y);
                        PointF[] pnt = new PointF[1];
                        pnt[0] = p1;
                        Use temp = xml1.Clone() as Use;
                        temp.Transform.Matrix.TransformPoints(pnt);

                        LongLat templat = mapview.OffSetZero(-(int)(pnt[0].X * tlVectorControl1.ScaleRatio), -(int)(pnt[0].Y * tlVectorControl1.ScaleRatio));

                        string[] jd = templat.Longitude.ToString("####.####").Split('.');
                        int d1 = Convert.ToInt32(jd[0]);
                        string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.');
                        int f1 = Convert.ToInt32(df1[0]);
                        decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60;

                        string[] wd = templat.Latitude.ToString("####.####").Split('.');
                        int d2 = Convert.ToInt32(wd[0]);
                        string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.');
                        int f2 = Convert.ToInt32(df2[0]);
                        decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60;

                        string strjwd = "经纬度: " + d1.ToString() + "°" + f1.ToString() + "′" + m1.ToString("##.#") + "″," + d2.ToString() + "°" + f2.ToString() + "′" + m2.ToString("##.#") + "″";
                        object obj = null;
                        string deviceid = xml1.GetAttribute("Deviceid");
                        if (string.IsNullOrEmpty(deviceid)) {
                            //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                obj = DeviceHelper.SelectDevice(DeviceType.DY, Itop.Client.MIS.ProgUID);
                                if (obj == null)
                                {
                                    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    tlVectorControl1.Delete();
                                }
                                if (obj is PSP_PowerSubstation_Info) {
                                    deviceid = ((PSP_PowerSubstation_Info)obj).UID;
                                    xml1.SetAttribute("Deviceid", deviceid);
                                }
                                substation sb = new substation();
                                sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                if (sb != null) {
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    sb.EleID = xml1.GetAttribute("id");
                                    if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Update<substation>(sb);
                                } else {
                                    sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.EleID = xml1.GetAttribute("id");
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Create<substation>(sb);
                                }
                            } else {
                                obj = DeviceHelper.SelectDevice(DeviceType.BDZ, Itop.Client.MIS.ProgUID);
                                if (obj == null)
                                {
                                    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    tlVectorControl1.Delete();
                                }
                                if (obj is PSP_Substation_Info) {
                                    deviceid = ((PSP_Substation_Info)obj).UID;
                                    xml1.SetAttribute("Deviceid", deviceid);
                                    //RectangleF t = ((IGraph)xml1).GetBounds();
                                    //n1.SetAttribute("x", (t.X - 30).ToString());
                                    //n1.SetAttribute("y", (t.Y - 30).ToString());
                                    //n1.SetAttribute("font-size", "24");
                                    //n1.InnerText = ((PSP_Substation_Info)obj).Title;
                                    //n1.SetAttribute("layer", SvgDocument.currentLayer);
                                    //n1.SetAttribute("ParentID", temp.GetAttribute("id"));
                                    //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                    //tlVectorControl1.Operation = ToolOperation.Select;
                                }
                                substation sb = new substation();
                                sb.UID = ((PSP_Substation_Info)obj).UID;
                                sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                if (sb != null) {

                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    sb.EleID = xml1.GetAttribute("id");
                                    if (((PSP_Substation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Update<substation>(sb);
                                } else {
                                    sb = new substation();
                                    sb.UID = ((PSP_Substation_Info)obj).UID;
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.EleID = xml1.GetAttribute("id");
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    if (((PSP_Substation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Create<substation>(sb);
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(deviceid)) {
                            if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid);
                                if (obj != null) {
                                    xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title);
                                    //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                    DeviceHelper.ShowDeviceDlg(DeviceType.DY, deviceid, false);
                                }
                                substation sb = new substation();
                                sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                if (sb != null) {
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    sb.EleID = xml1.GetAttribute("id");
                                    if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Update<substation>(sb);
                                } else {
                                    sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    sb.EleID = xml1.GetAttribute("id");
                                    if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Create<substation>(sb);
                                }
                            } else {
                                obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                                if (obj != null) {
                                    xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title);
                                    //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                    DeviceHelper.ShowDeviceDlg(DeviceType.BDZ, deviceid, false);
                                }
                                substation sb = new substation();
                                sb.UID = ((PSP_Substation_Info)obj).UID;
                                sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                if (sb != null) {
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    sb.EleID = xml1.GetAttribute("id");
                                    if (((PSP_Substation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Update<substation>(sb);
                                } else {
                                    sb = new substation();
                                    sb.UID = ((PSP_Substation_Info)obj).UID;
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.EleID = xml1.GetAttribute("id");
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    if (((PSP_Substation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Create<substation>(sb);
                                }
                            }

                        }
                        //frmSubstationProperty frmSub = new frmSubstationProperty();
                        //frmSub.jwstr = strjwd;
                        //frmSub.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SvgDocument.currentLayer, lab);
                        //if (frmSub.ShowDialog() == DialogResult.OK)
                        //{
                        //    xml1.SetAttribute("info-name", frmSub.Sub.EleName);
                        //    SVG_ENTITY ent = new SVG_ENTITY();
                        //    if (frmSub.IsCreate)
                        //    {
                        //        ent.SUID = Guid.NewGuid().ToString();
                        //        ent.EleID = frmSub.Sub.EleID;
                        //        ent.layerID = frmSub.Sub.LayerID;
                        //        ent.MDATE = System.DateTime.Now;
                        //        ent.NAME = frmSub.Sub.EleName;
                        //        ent.svgID = frmSub.Sub.SvgUID;
                        //        ent.TYPE = "substation";
                        //        ent.voltage = Convert.ToInt32(frmSub.Sub.ObligateField1);
                        //        Services.BaseService.Create<SVG_ENTITY>(ent);
                        //    }
                        //    else
                        //    {
                        //        ent.NAME = frmSub.Sub.EleName;
                        //        ent.layerID = frmSub.Sub.LayerID;
                        //        ent.MDATE = System.DateTime.Now;
                        //        //ent.voltage = fl.Line.Voltage;
                        //        Services.BaseService.Update<SVG_ENTITY>(ent);
                        //    }
                        //}
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("XL_GT_3") || xml1.GetAttribute("xlink:href").Contains("XL_GT_4")) {
                        frmInputNum num = new frmInputNum();
                        num.InputStr = xml1.GetAttribute("order");
                        num.ShowDialog();
                        xml1.SetAttribute("order", num.InputStrSEL);
                    }
                    //if (xml1.GetAttribute("xlink:href").Contains("bdz") || xml1.GetAttribute("xlink:href").Contains("hwg") ||
                    //    xml1.GetAttribute("xlink:href").Contains("fjx") || xml1.GetAttribute("xlink:href").Contains("kbs") ||
                    //    xml1.GetAttribute("xlink:href").Contains("byq") || xml1.GetAttribute("xlink:href").Contains("kg"))
                    //{
                    //    frmInputDialog n1 = new frmInputDialog();
                    //    n1.InputStr = xml1.GetAttribute("info-name").ToString();
                    //    if (n1.ShowDialog() == DialogResult.OK)
                    //    {
                    //        xml1.SetAttribute("info-name",n1.InputStr);
                    //    }

                    //}
                    if (xml1.GetAttribute("xlink:href").Contains("kbs") || xml1.GetAttribute("xlink:href").Contains("hwg")) {
                        frmkbsProperty num = new frmkbsProperty();
                        num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        num.ShowDialog();
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("fjx")) {
                        frmfjxProperty num = new frmfjxProperty();
                        num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        num.ShowDialog();
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("byq")) {
                        frmbyqProperty num = new frmbyqProperty();
                        num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        num.ShowDialog();
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("SB_GT")) {
                        string lineWidth = "2";

                        string Code = xltProcessor.GetCurrentLineCode();
                        string _len = xltProcessor.GetWholeLineLength(Code).ToString("#####.####");

                        frmLineProperty fl = new frmLineProperty();
                        fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement;
                        fl.InitData(Code, tlVectorControl1.SVGDocument.SvgdataUid, _len, SvgDocument.currentLayer);
                        if (fl.ShowDialog() == DialogResult.OK) {
                            //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;"
                            lineWidth = fl.LineWidth;
                            string styleValue = "";
                            if (fl.Line.ObligateField1 == "规划") {
                                styleValue = "stroke-dasharray:4 4;stroke-width:" + lineWidth + ";";
                            } else {
                                styleValue = "stroke-width:" + lineWidth + ";";
                            }

                            styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                            ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("style");
                            ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", styleValue);

                            xltProcessor.SetWholeLineAttribute(Code, "style", styleValue);
                        }
                    }

                }
                if (e.ClickedItem.Text == "移动") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    XmlElement xmln = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    frmMove fm = new frmMove();
                    PointF pf11 = ((Use)xmln).CenterPoint;
                    LongLat temp = mapview.ParseToLongLat((int)pf11.X, (int)pf11.Y);
                    string[] jd = temp.Longitude.ToString("####.####").Split('.');
                    int d1 = Convert.ToInt32(jd[0]);
                    string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.');
                    int f1 = Convert.ToInt32(df1[0]);
                    decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60;

                    string[] wd = temp.Latitude.ToString("####.####").Split('.');
                    int d2 = Convert.ToInt32(wd[0]);
                    string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.');
                    int f2 = Convert.ToInt32(df2[0]);
                    decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60;
                    strj1 = d1.ToString();
                    strw1 = f1.ToString();
                    strd1 = m1.ToString();
                    strj2 = d2.ToString();
                    strw2 = f2.ToString();
                    strd2 = m2.ToString();
                    fm.Init(strj1, strw1, strd1, strj2, strw2, strd2);
                    if (fm.ShowDialog() == DialogResult.OK) {
                        string strValue = fm.StrValue;
                        string[] str = strValue.Split(',');
                        string[] JWD1 = str[0].Split(' ');
                        decimal J1 = Convert.ToDecimal(JWD1[0]);
                        decimal W1 = Convert.ToDecimal(JWD1[1]);
                        decimal D1 = Convert.ToDecimal(JWD1[2]);
                        string[] JWD2 = str[1].Split(' ');
                        decimal J2 = Convert.ToDecimal(JWD2[0]);
                        decimal W2 = Convert.ToDecimal(JWD2[1]);
                        decimal D2 = Convert.ToDecimal(JWD2[2]);

                        decimal JD = J1 + W1 / 60 + D1 / 3600;
                        decimal WD = J2 + W2 / 60 + D2 / 3600;

                        PointF pf1 = mapview.ParseToPoint(JD, WD);

                        PointF p1 = ((Use)xmln).CenterPoint;

                        SvgElement e1 = xmln as SvgElement;
                        Matrix matrix2 = ((IGraph)e1).GraphTransform.Matrix.Clone();
                        Matrix matrix3 = tlVectorControl1.DrawArea.CoordTransform.Clone();
                        matrix3.Invert();
                        matrix2.Multiply(matrix3, MatrixOrder.Append);
                        matrix2.Invert();
                        PointF[] pfArray1 = new PointF[] { new PointF(pf1.X / tlVectorControl1.ScaleRatio, pf1.Y / tlVectorControl1.ScaleRatio), p1 };
                        matrix2.TransformPoints(pfArray1);

                        float single1 = pfArray1[0].X - pfArray1[1].X;
                        float single2 = pfArray1[0].Y - pfArray1[1].Y;

                        Matrix matrix6 = ((IGraph)e1).Transform.Matrix.Clone();
                        if (e1.SvgAttributes.ContainsKey("transform")) {
                            Matrix matrix7 = ((Matrix)e1.SvgAttributes["transform"]).Clone();
                            matrix7.Invert();
                            matrix6.Multiply(matrix7, MatrixOrder.Append);
                        }
                        Matrix matrix5 = new Matrix();
                        matrix5.Translate(single1, single2);
                        Matrix matrix8 = ((IGraph)e1).Transform.Matrix.Clone();
                        matrix8.Multiply(matrix5);
                        matrix6.Invert();
                        matrix6.Multiply(matrix8, MatrixOrder.Append);
                        Transf tf = new Transf();
                        tf.setMatrix(matrix6);
                        (xmln as Use).Transform = tf;

                    }
                }
                if (e.ClickedItem.Text == "接线图") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    ParentUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    Save();
                    ParentUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    SVGFILE svg_temp = new SVGFILE();
                    //XmlElement xml1 = ((XmlElement)(e.Elements[0]));xml1.GetAttribute("id");
                    svg_temp.SUID = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("id");
                    svg_temp.FILENAME = getBdzName(svg_temp.SUID);// ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("info-name");
                    string strWhere = string.Format("suid='{0}' or filename='{1}' ", svg_temp.SUID, svg_temp.FILENAME);
                    IList svglist = Services.BaseService.GetList("SelectSVGFILEByWhere", strWhere);
                    OpenJXT(svglist, svg_temp);
                    //frmlar.SymbolDoc = tlVectorControl1.SVGDocument;
                    //frmlar.Progtype = MapType;
                    //frmlar.InitData();
                    //JxtBar();
                }
                if (e.ClickedItem.Text == "打开") {
                    if (tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRelating UseRel = new UseRelating();
                    UseRel.UseID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                    IList<UseRelating> UseRelList = Services.BaseService.GetList<UseRelating>("SelectUseRelatingByUseID", UseRel);
                    if (UseRelList.Count < 1) {
                        MessageBox.Show("选择的地块还没有关联到其他地图,请先设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRel = UseRelList[0];
                    SVGFILE svgFile = new SVGFILE();
                    svgFile.SUID = UseRel.LinkUID;
                    IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile);
                    if (svgList.Count < 1) {
                        MessageBox.Show("被关联的地图已经被删除,请重新设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    svgFile = (SVGFILE)svgList[0];
                    //SvgDocument doc = new SvgDocument();

                    if (!string.IsNullOrEmpty(svgFile.SVGDATA)) {
                        //doc.LoadXml(svgFile.SVGDATA);
                        ctlfile_OnOpenSvgDocument(sender, svgFile.SUID);
                    }

                }
                if (e.ClickedItem.Text == "区域打印") {
                    PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                    frmPrinter dlg = new frmPrinter();
                    dlg.printHelper = ph;
                    dlg.ShowDialog();
                    return;
                    ArrayList idlist = new ArrayList();
                    ArrayList symlist = new ArrayList();

                    SvgDocument _doc = new SvgDocument();

                    Graph poly1 = tlVectorControl1.SVGDocument.CurrentElement as Graph;
                    if (poly1 == null || poly1.GetAttribute("id") == "svg") {
                        return;
                    }

                    GraphicsPath gr1 = new GraphicsPath();
                    //gr1.AddRectangle(TLMath.getRectangle(poly1));
                    gr1.AddPolygon(TLMath.getPolygonPoints(poly1));
                    //gr1.CloseFigure();
                    gr1 = (GraphicsPath)poly1.GPath.Clone();
                    gr1.Transform((poly1 as IGraph).Transform.Matrix);

                    RectangleF ef1 = gr1.GetBounds();
                    ef1 = PathFunc.GetBounds(gr1);
                    StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">");

                    XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("defs");
                    if (nlist.Count > 0) {
                        XmlNode node = nlist[0];
                        svgtxt.AppendLine(node.OuterXml);
                    }
                    SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator();
                    while (enumerator1.MoveNext()) {
                        IGraph graph1 = (IGraph)enumerator1.Current;

                        GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                        //path1.Transform(graph1.GraphTransform.Matrix);
                        //path1.Transform(graph1.Transform.Matrix);
                        // RectangleF ef2 = path1.GetBounds();// PathFunc.GetBounds(path1);

                        //for (int n = 0; n < selCol.Count - 1; n++)
                        //{
                        //    //_doc.AppendChild((XmlNode)selCol[n]);
                        //    svgtxt = svgtxt + ((XmlElement)selCol[n]).OuterXml + "\r\n";
                        //}
                        if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue;

                        GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone();
                        path2.Transform(graph1.Transform.Matrix);
                        RectangleF ef2 = PathFunc.GetBounds(path2);

                        if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty) {

                            SvgElement ele = (SvgElement)graph1;
                            svgtxt.AppendLine(ele.OuterXml);
                            //tlVectorControl1.SVGDocument.AddSelectElement(graph1);
                            if (graph1 is Use) {
                                //PointF offset = TLMath.getUseOffset(((XmlElement)graph1).GetAttribute("xlink:href"));
                                //if (ef1.Contains(new PointF(((Use)graph1).X + offset.X, ((Use)graph1).Y + offset.Y))) {
                                //SvgElement ele = (SvgElement)graph1;
                                //svgtxt.AppendLine(ele.OuterXml);

                                string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                                if (!symlist.Contains(symid)) {
                                    symlist.Add(symid);
                                }
                                //}
                            }
                            if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") {
                                string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                                if (IsLead != "") {
                                    if (ef1.Contains(ef2)) {
                                        idlist.Add(graph1.ID);
                                    }
                                }
                            }

                        }
                        //if (ef1.Contains(ef2)|| RectangleF.Intersect(ef1,ef2) !=RectangleF.Empty )
                        //{
                        //    SvgElement ele = (SvgElement)graph1;
                        //    svgtxt.AppendLine(ele.OuterXml);
                        //    //tlVectorControl1.SVGDocument.AddSelectElement(graph1);
                        //    if (graph1 is Use ) {
                        //        PointF offset = TLMath.getUseOffset(((XmlElement)graph1).GetAttribute("xlink:href"));
                        //        if (ef1.Contains(new PointF(((Use)graph1).X + offset.X, ((Use)graph1).Y + offset.Y))) {
                        //            //SvgElement ele = (SvgElement)graph1;
                        //            //svgtxt.AppendLine(ele.OuterXml);

                        //            string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                        //            if (!symlist.Contains(symid)) {
                        //                symlist.Add(symid);
                        //            }
                        //        }
                        //    }
                        //    if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") {
                        //        string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                        //        if (IsLead != "") {
                        //            if (ef1.Contains(ef2)) {
                        //                idlist.Add(graph1.ID);
                        //            }
                        //        }
                        //    }
                        //}

                    }
                    symlist = ResetList(symlist);
                    svgtxt.AppendLine("</svg>");
                    _doc.LoadXml(svgtxt.ToString());
                    _doc.SvgdataUid = tlVectorControl1.SVGDocument.SvgdataUid;
                    frmPrintF pri = new frmPrintF();
                    pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid);
                    if (pri.ShowDialog() == DialogResult.OK) {
                        frmSubPrint s = new frmSubPrint();
                        s.Vector = tlVectorControl1;
                        s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist);
                        s.Open(_doc, ef1);
                        s.Show();
                    }
                }
                if (e.ClickedItem.Text == "分类统计报表") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    IGraph poly1 = (IGraph)tlVectorControl1.SVGDocument.CurrentElement;
                    frmPloyPrint p = new frmPloyPrint();

                    p.InitDate(poly1.ID, tlVectorControl1.SVGDocument.SvgdataUid);
                    p.ShowDialog();
                }
                if (e.ClickedItem.Text == "保存图片") {
                    if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") {
                        //frmImgInfoInput finput = new frmImgInfoInput();
                        //if (finput.ShowDialog() == DialogResult.OK)
                        //{
                        PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                        frmImgManager frm = new frmImgManager();
                        //frm.StrName = finput.StrName;
                        //frm.StrRemark = finput.StrRemark;
                        frm.Pic = ph.getImage();
                        frm.ShowDialog();
                        //}
                    }
                }
            } catch (Exception e1) {
                //MessageBox.Show(e1.Message);
            }
            if (e.ClickedItem.Text == "三维变电站") {
                try {
                    string strid = tlVectorControl1.SVGDocument.CurrentElement.ID;
                    substation s = new substation();
                    s.EleID = strid;
                    s.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    s = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", s);
                    ProcessStartInfo p = new ProcessStartInfo();
                    p.FileName = Application.StartupPath + "\\" + s.EleName + "\\bdz.exe";
                    p.WorkingDirectory = Application.StartupPath + "\\" + s.EleName;
                    Process.Start(p);
                } catch (Exception e1) { }
            }
            if (e.ClickedItem.Text == "更新关联变电站") {
                UpdateLine();
            }
            if (e.ClickedItem.Text == "删除") {
                Delete();
            }
        }
Example #2
0
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem.Text == "短路计算")
            {
                int tuxing = 0;
                int baobiao = 0;
                PSPDEV pspDuanlu = new PSPDEV();
                pspDuanlu.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                XmlElement element = tlVectorControl1.SVGDocument.CurrentElement;
                pspDuanlu.EleID = element.GetAttribute("id");
                pspDuanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDuanlu);
                if (pspDuanlu == null)
                    return;
                if (pspDuanlu.Type == "Polyline" && pspDuanlu.Lable != "支路")
                    return;
                frmDuanlu dudu = new frmDuanlu(pspDuanlu);
                PSPDEV Duanlu = new PSPDEV();
                Duanlu.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                int n11 = 0, n2 = 0, n3 = 0, n4 = 0;

                if (dudu.ShowDialog() == DialogResult.OK)
                {
                    //int bigsmall=Convert.ToInt32(dudu.DuanluBigsmall);
                    CheckDL();
                    string nodeType;
                    if (dudu.DuanluBaobiao == "是")
                        baobiao = 1;
                    if (dudu.DuanluTuxing == "所有故障点短路电流")
                        tuxing = 1;
                    if (dudu.DuanluTuxing == "指定故障点短路电流")
                        tuxing = 2;
                    //Duanlu.Name = dudu.DuanluPoint;
                    //Duanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", Duanlu);
                    n4 = Convert.ToInt32(dudu.hscool);
                    nodeType = pspDuanlu.Type;
                    if (pspDuanlu.Type == "Use")
                    {
                        n11 = 0;
                        n2 = pspDuanlu.Number;
                        switch (dudu.DuanluType)
                        {
                            case "单相接地":
                                n3 = 1;
                                break;

                            case "两相接地":
                                n3 = 3;
                                break;
                            case "两相故障":
                                n3 = 2;
                                break;
                            case "三相故障":
                                n3 = 0;
                                break;
                            default:
                                n3 = 1;
                                break;
                        }
                        string dlr = null;
                        dlr = "0" + " " + n3.ToString() + " " + pspDuanlu.Number + " " + "-1" + " " + "-1" + n4;

                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                        }

                        FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                        StreamWriter str11 = new StreamWriter(VK);
                        str11.Write(dlr);
                        str11.Close();
                        n4 = 0;

                    }
                    else if (pspDuanlu.Type == "Polyline")
                    {
                        //n11 = pspDuanlu.FirstNode;
                        //n2 = pspDuanlu.LastNode;
                        n11 = pspDuanlu.Number;
                        n2 = n11;
                        switch (dudu.DuanluType)
                        {
                            case "单相接地":
                                n3 = 1;
                                break;

                            case "两相接地":
                                n3 = 3;
                                break;
                            case "两相故障":
                                n3 = 2;
                                break;
                            case "三相故障":
                                n3 = 0;
                                break;
                            default:
                                n3 = 1;
                                break;
                        }
                        string dlr = null;
                        dlr = "0" + " " + n3.ToString() + " " + pspDuanlu.Number + " " + pspDuanlu.FirstNode + " " + pspDuanlu.LastNode + " " + n4;

                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt");
                        }

                        FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate);
                        StreamWriter str11 = new StreamWriter(VK);
                        str11.Write(dlr);
                        str11.Close();
                    }
                    else
                    {
                        return;
                    }
                    XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");
                    foreach (XmlNode node in list)
                    {
                        SvgElement elementde = node as SvgElement;
                        tlVectorControl1.SVGDocument.CurrentElement = elementde;
                        tlVectorControl1.Delete();
                    }
                    shortcir shortCutCal = new shortcir();
                    shortCutCal.Show_shortcir(0,0);

                    string duanResult = null;
                    duanResult += "短路电流简表" + "\r\n" + "\r\n";
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"))
                    {
                    }
                    else
                    {
                        return;
                    }
                    FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open);
                    StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default);
                    string strLineGU;
                    string[] arrayGU;
                    char[] charSplitGU = new char[] { ' ' };
                    strLineGU = readLineGU.ReadLine();

                    while (strLineGU != null)
                    {
                        arrayGU = strLineGU.Split(charSplitGU);
                        int i = 0;
                        string[] dev = new string[9];
                        dev.Initialize();
                        foreach (string str in arrayGU)
                        {
                            if (str != "")
                            {
                                dev[i++] = str;
                            }
                        }
                        if (tuxing == 2)
                        {
                            PSPDEV CR = new PSPDEV();
                            CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            CR.Name = dev[1];
                            CR.Type = nodeType;
                            CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                            if (CR != null)
                            {
                                if (CR.Type != "Polyline")
                                {
                                    XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement;

                                    if (elementdl != null)
                                    {
                                        RectangleF bound = ((IGraph)elementdl).GetBounds();
                                        XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                        n1.SetAttribute("x", Convert.ToString(bound.X));
                                        n1.SetAttribute("y", Convert.ToString(bound.Y - 20));
                                        n1.InnerText = (Convert.ToDouble(dev[3])).ToString("N4");
                                        n1.SetAttribute("layer", SvgDocument.currentLayer);
                                        n1.SetAttribute("flag", "1");
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                        tlVectorControl1.Operation = ToolOperation.Select;
                                        tlVectorControl1.Refresh();
                                    }
                                }
                                else
                                {
                                    XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement;

                                    if (elementdl != null)
                                    {
                                        PointF[] t = ((Polyline)elementdl).Points;

                                        PointF[] t2 = ((Polyline)elementdl).FirstTwoPoint;
                                        t = t2;
                                        PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2));
                                        float angel = 0f;
                                        angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);

                                        string l3 = Convert.ToString(midt.X);
                                        string l4 = Convert.ToString(midt.Y);

                                        string tran = ((Polyline)elementdl).Transform.ToString();

                                        PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2));
                                        XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                        XmlElement n2dl = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                                        PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                                        PSPDEV psp = new PSPDEV();
                                        psp.FirstNode = CR.FirstNode;
                                        psp.LastNode = CR.LastNode;
                                        psp.SvgUID = CR.SvgUID;
                                        PSPDEV tempss = new PSPDEV();
                                        IList listParallel = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandFirstOrLastNode", psp);
                                        foreach (PSPDEV devP in listParallel)
                                        {
                                            if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350))
                                            {
                                                if (((devP.X1) > (CR.X1)))
                                                {
                                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                                }
                                            }
                                            else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90))
                                            {
                                                if (((devP.Y1) > (CR.Y1)))
                                                {
                                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                                }
                                            }
                                            else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180))
                                            {
                                                if (((devP.Y1) > (CR.Y1)))
                                                {
                                                    pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));

                                                }
                                            }
                                        }

                                        PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));

                                        n1.SetAttribute("x", Convert.ToString(pStart.X));
                                        n1.SetAttribute("y", Convert.ToString(pStart.Y));

                                        //if (Convert.ToDouble(dev[4]) >= 0)
                                        //{
                                        n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4");
                                        //}
                                        //else
                                        //{
                                        //    n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4");
                                        //}
                                        n1.SetAttribute("layer", SvgDocument.currentLayer);
                                        n1.SetAttribute("flag", "1");

                                        //if (Convert.ToDouble(dev[5]) == 1)
                                        //    n1.SetAttribute("stroke", "#FF0000");

                                        PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 25) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 25) * Math.PI / 180)));
                                        PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 335) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 335) * Math.PI / 180)));

                                        if (Convert.ToDouble(dev[3]) < 0)
                                        {
                                            p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 155) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 155) * Math.PI / 180)));
                                            p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 205) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 205) * Math.PI / 180)));
                                        }

                                        string l1 = Convert.ToString(p1.X);
                                        string l2 = Convert.ToString(p1.Y);
                                        string l5 = Convert.ToString(p2.X);
                                        string l6 = Convert.ToString(p2.Y);

                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                        tlVectorControl1.Operation = ToolOperation.Select;

                                        tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                                        RectangleF ttt = ((Polyline)elementdl).GetBounds();

                                        tlVectorControl1.RotateSelection(angel, pStart);
                                        if (Math.Abs(angel) > 90)
                                            tlVectorControl1.RotateSelection(180, pStart);
                                        PointF newp = new PointF(center.X + 10, center.Y + 10);

                                        tlVectorControl1.Refresh();

                                    }
                                }
                            }

                        }
                        duanResult += dev[0] + "," + dev[1] + "," + dev[3] + "\r\n";
                        strLineGU = readLineGU.ReadLine();
                    }

                    string dianYaResult = null;
                    dianYaResult += "母线电压结果" + "\r\n" + "\r\n";
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"))
                    {
                    }
                    else
                    {
                        return;
                    }
                    FileStream dianYa = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt", FileMode.Open);
                    StreamReader readLineDY = new StreamReader(dianYa, System.Text.Encoding.Default);
                    string strLineDY;
                    string[] arrayDY;
                    char[] charSplitDY = new char[] { ' ' };
                    strLineDY = readLineDY.ReadLine();
                    while (strLineDY != null)
                    {
                        arrayDY = strLineDY.Split(charSplitDY);
                        int i = 0;
                        string[] dev = new string[14];
                        dev.Initialize();
                        foreach (string str in arrayDY)
                        {
                            if (str != "")
                            {
                                dev[i++] = str;
                            }
                        }
                        PSPDEV CR = new PSPDEV();
                        CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        CR.Name = dev[1];
                        CR.Type = nodeType;
                        CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                        if (tuxing == 1)
                        {
                            XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement;

                            if (elementdl != null)
                            {
                                RectangleF bound = ((IGraph)elementdl).GetBounds();
                                XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                XmlElement n22 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                XmlElement n33 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                n1.SetAttribute("x", Convert.ToString(bound.X));
                                n1.SetAttribute("y", Convert.ToString(bound.Y - 60));
                                n1.InnerText = "A相:" + (Convert.ToDouble(dev[8])).ToString("N4") + "Kv/" + (Convert.ToDouble(dev[9])).ToString("N4") + "°";
                                n1.SetAttribute("layer", SvgDocument.currentLayer);
                                n1.SetAttribute("flag", "1");
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                tlVectorControl1.Operation = ToolOperation.Select;
                                tlVectorControl1.Refresh();
                                n22.SetAttribute("x", Convert.ToString(bound.X));
                                n22.SetAttribute("y", Convert.ToString(bound.Y - 40));
                                n22.InnerText = "B相:" + (Convert.ToDouble(dev[10])).ToString("N4") + "Kv/" + (Convert.ToDouble(dev[11])).ToString("N4") + "°";
                                n22.SetAttribute("layer", SvgDocument.currentLayer);
                                n22.SetAttribute("flag", "1");
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n22);
                                tlVectorControl1.Operation = ToolOperation.Select;
                                tlVectorControl1.Refresh();
                                n33.SetAttribute("x", Convert.ToString(bound.X));
                                n33.SetAttribute("y", Convert.ToString(bound.Y - 20));
                                n33.InnerText = "C相:" + (Convert.ToDouble(dev[12])).ToString("N4") + "Kv/" + (Convert.ToDouble(dev[13])).ToString("N4") + "°";
                                n33.SetAttribute("layer", SvgDocument.currentLayer);
                                n33.SetAttribute("flag", "1");
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n33);
                                tlVectorControl1.Operation = ToolOperation.Select;
                                tlVectorControl1.Refresh();
                            }
                        }
                        dianYaResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," +
                            dev[9] + "," + dev[10] + "," + dev[11] + "," + dev[12] + "," + dev[13] + "\r\n";
                        strLineDY = readLineDY.ReadLine();
                    }

                    string dianLiuResult = null;
                    dianLiuResult += "支路电流结果" + "\r\n" + "\r\n";
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"))
                    {
                    }
                    else
                    {
                        return;
                    }
                    FileStream dianLiu = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt", FileMode.Open);
                    StreamReader readLineDL = new StreamReader(dianLiu, System.Text.Encoding.Default);
                    string strLineDL;
                    string[] arrayDL;
                    char[] charSplitDL = new char[] { ' ' };
                    strLineDL = readLineDL.ReadLine();
                    while (strLineDL != null)
                    {
                        arrayDL = strLineDL.Split(charSplitDL);
                        int i = 0;
                        string[] dev = new string[15];
                        dev.Initialize();
                        foreach (string str in arrayDL)
                        {
                            if (str != "")
                            {
                                dev[i++] = str;
                            }
                        }
                        PSPDEV CR = new PSPDEV();
                        CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        CR.Name = dev[1];
                        CR.Type = nodeType;
                        CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR);
                        if (tuxing == 1)
                        {
                            XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement;

                            if (elementdl != null)
                            {
                                PointF[] t = ((Polyline)elementdl).Points;

                                PointF[] t2 = ((Polyline)elementdl).FirstTwoPoint;
                                t = t2;
                                PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2));
                                float angel = 0f;
                                angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI);

                                string l3 = Convert.ToString(midt.X);
                                string l4 = Convert.ToString(midt.Y);

                                string tran = ((Polyline)elementdl).Transform.ToString();

                                PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2));
                                XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                XmlElement n2dl = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                                PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                                PSPDEV psp = new PSPDEV();
                                psp.FirstNode = CR.FirstNode;
                                psp.LastNode = CR.LastNode;
                                psp.SvgUID = CR.SvgUID;
                                PSPDEV tempss = new PSPDEV();
                                IList listParallel = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandFirstOrLastNode", psp);
                                foreach (PSPDEV devP in listParallel)
                                {
                                    if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350))
                                    {
                                        if (((devP.X1) > (CR.X1)))
                                        {
                                            pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                        }
                                    }
                                    else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90))
                                    {
                                        if (((devP.Y1) > (CR.Y1)))
                                        {
                                            pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                                        }
                                    }
                                    else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180))
                                    {
                                        if (((devP.Y1) > (CR.Y1)))
                                        {
                                            pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));

                                        }
                                    }
                                }

                                PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));

                                n1.SetAttribute("x", Convert.ToString(pStart.X));
                                n1.SetAttribute("y", Convert.ToString(pStart.Y));

                                //if (Convert.ToDouble(dev[4]) >= 0)
                                //{
                                n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4");
                                //}
                                //else
                                //{
                                //    n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4");
                                //}
                                n1.SetAttribute("layer", SvgDocument.currentLayer);
                                n1.SetAttribute("flag", "1");

                                //if (Convert.ToDouble(dev[3]) == 1)
                                //    n1.SetAttribute("stroke", "#FF0000");

                                PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 25) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 25) * Math.PI / 180)));
                                PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 335) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 335) * Math.PI / 180)));

                                if (Convert.ToDouble(dev[3]) < 0)
                                {
                                    p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 155) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 155) * Math.PI / 180)));
                                    p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 205) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 205) * Math.PI / 180)));
                                }

                                string l1 = Convert.ToString(p1.X);
                                string l2 = Convert.ToString(p1.Y);
                                string l5 = Convert.ToString(p2.X);
                                string l6 = Convert.ToString(p2.Y);

                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                tlVectorControl1.Operation = ToolOperation.Select;

                                tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                                RectangleF ttt = ((Polyline)elementdl).GetBounds();

                                tlVectorControl1.RotateSelection(angel, pStart);
                                if (Math.Abs(angel) > 90)
                                    tlVectorControl1.RotateSelection(180, pStart);
                                PointF newp = new PointF(center.X + 10, center.Y + 10);

                                tlVectorControl1.Refresh();

                            }
                        }
                        dianLiuResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," +
                            dev[9] + "," + dev[10] + "," + dev[11] + dev[12] + "," + dev[13] + "," + dev[14] + "\r\n";
                        strLineDL = readLineDL.ReadLine();
                    }

                    if (baobiao == 1)
                    {
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv");
                        }
                        FileStream tempGU = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate);
                        StreamWriter strGU = new StreamWriter(tempGU, Encoding.GetEncoding("GB2312"));
                        strGU.Write(duanResult);
                        strGU.Close();
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                        }
                        FileStream tempDY = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate);
                        StreamWriter strDY = new StreamWriter(tempDY, Encoding.GetEncoding("GB2312"));
                        strDY.Write(dianYaResult);
                        strDY.Close();
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result2.csv"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                        }
                        FileStream tempDL = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result2.csv"), FileMode.OpenOrCreate);
                        StreamWriter strDL = new StreamWriter(tempDL, Encoding.GetEncoding("GB2312"));
                        strDL.Write(dianLiuResult);
                        strDL.Close();
                        if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + "短路计算结果.xls"))
                        {
                            File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + "短路计算结果.xls");
                        }

                        Excel.Application ex;
                        Excel.Worksheet xSheet;
                        Excel.Application result1;
                        Excel.Application result2;
                        Excel.Worksheet tempSheet;
                        Excel.Worksheet tempSheet1;
                        Excel.Worksheet newWorksheet;
                        Excel.Worksheet newWorkSheet1;

                        object oMissing = System.Reflection.Missing.Value;
                        ex = new Excel.Application();
                        ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv");

                        xSheet = (Excel.Worksheet)ex.Worksheets[1];
                        ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);
                        xSheet = (Excel.Worksheet)ex.Worksheets[2];
                        ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value);
                        xSheet = (Excel.Worksheet)ex.Worksheets[1];
                        result1 = new Excel.Application();
                        result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv");
                        result2 = new Excel.Application();
                        result2.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result2.csv");
                        tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1);
                        tempSheet1 = (Excel.Worksheet)result2.Worksheets.get_Item(1);
                        newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2);
                        newWorkSheet1 = (Excel.Worksheet)ex.Worksheets.get_Item(3);
                        newWorksheet.Name = "母线电压";
                        newWorkSheet1.Name = "支路电流";
                        xSheet.Name = "短路电流";
                        ex.Visible = true;

                        tempSheet.Cells.Select();
                        tempSheet.Cells.Copy(System.Reflection.Missing.Value);
                        newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                        tempSheet1.Cells.Select();
                        tempSheet1.Cells.Copy(System.Reflection.Missing.Value);
                        newWorkSheet1.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                        xSheet.Rows.AutoFit();
                        xSheet.Columns.AutoFit();
                        newWorksheet.Rows.AutoFit();
                        newWorksheet.Columns.AutoFit();
                        newWorkSheet1.Rows.AutoFit();
                        newWorkSheet1.Columns.AutoFit();
                        xSheet.UsedRange.Font.Name = "楷体_GB2312";
                        newWorksheet.UsedRange.Font.Name = "楷体_GB2312";
                        newWorkSheet1.UsedRange.Font.Name = "楷体_GB2312";

                        xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 3]).MergeCells = true;
                        xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20;
                        xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体";
                        xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                        xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[3, 3]).Interior.ColorIndex = 45;
                        xSheet.get_Range(xSheet.Cells[4, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                        xSheet.get_Range(xSheet.Cells[4, 3], xSheet.Cells[xSheet.UsedRange.Rows.Count, 13]).NumberFormat = "0.0000_ ";

                        newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 14]).MergeCells = true;
                        newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20;
                        newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体";
                        newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                        newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[3, 14]).Interior.ColorIndex = 45;
                        newWorksheet.get_Range(newWorksheet.Cells[4, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                        newWorksheet.get_Range(newWorksheet.Cells[4, 3], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 14]).NumberFormat = "0.0000_ ";

                        newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 15]).MergeCells = true;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Size = 20;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Name = "黑体";
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[3, 1], newWorkSheet1.Cells[3, 14]).Interior.ColorIndex = 45;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 1], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 2], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 2]).Interior.ColorIndex = 6;
                        newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 4], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 14]).NumberFormat = "0.0000_ ";

                        newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + "短路计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null);
                        System.Windows.Forms.Clipboard.Clear();
                        result1.Workbooks.Close();
                        result1.Quit();
                        result2.Workbooks.Close();
                        result2.Quit();
                    }

                }
            }

            if (e.ClickedItem.Text == "区域打印")
            {
                PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                frmPrinter dlg = new frmPrinter();
                dlg.printHelper = ph;
                dlg.ShowDialog();
                return;
                ArrayList idlist = new ArrayList();
                ArrayList symlist = new ArrayList();

                SvgDocument _doc = new SvgDocument();

                Graph poly1 = tlVectorControl1.SVGDocument.CurrentElement as Graph;
                if (poly1 == null || poly1.GetAttribute("id") == "svg")
                {
                    return;
                }

                GraphicsPath gr1 = new GraphicsPath();
                gr1.AddPolygon(TLMath.getPolygonPoints(poly1));
                gr1 = (GraphicsPath)poly1.GPath.Clone();
                gr1.Transform((poly1 as IGraph).Transform.Matrix);

                RectangleF ef1 = gr1.GetBounds();
                ef1 = PathFunc.GetBounds(gr1);
                StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">");

                XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("defs");
                if (nlist.Count > 0)
                {
                    XmlNode node = nlist[0];
                    svgtxt.AppendLine(node.OuterXml);
                }
                SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator();
                while (enumerator1.MoveNext())
                {
                    IGraph graph1 = (IGraph)enumerator1.Current;

                    GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                    if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue;

                    GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone();
                    path2.Transform(graph1.Transform.Matrix);
                    RectangleF ef2 = PathFunc.GetBounds(path2);

                    if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty)
                    {
                        SvgElement ele = (SvgElement)graph1;
                        svgtxt.AppendLine(ele.OuterXml);
                        if (graph1 is Use)
                        {
                            string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                            if (!symlist.Contains(symid))
                            {
                                symlist.Add(symid);
                            }
                        }
                        if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline")
                        {
                            string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                            if (IsLead != "")
                            {
                                if (ef1.Contains(ef2))
                                {
                                    idlist.Add(graph1.ID);
                                }
                            }
                        }
                    }

                }
                //symlist = ResetList(symlist);
                svgtxt.AppendLine("</svg>");
                _doc.LoadXml(svgtxt.ToString());
                _doc.SvgdataUid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                frmPrintF pri = new frmPrintF();
                pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                if (pri.ShowDialog() == DialogResult.OK)
                {
                    frmSubPrint s = new frmSubPrint();
                    s.Vector = tlVectorControl1;
                    s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist);
                    s.Open(_doc, ef1);
                    s.Show();
                }
            }

            if (e.ClickedItem.Text == "属性")
            {
                //if (!Check())
                //{
                //    return;
                //}
                XmlElement element = tlVectorControl1.SVGDocument.CurrentElement;
                if (element is Use)
                {
                    if (element.GetAttribute("xlink:href").Contains("Substation") || element.GetAttribute("xlink:href").Contains("motherlinenode"))
                    {

                        string str_power = getPower(element.GetAttribute("xlink:href"));

                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmSubstation dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmSubstation(pspDev);

                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = -1;
                            pspDev.Type = "Use";
                            if (element.GetAttribute("xlink:href").Contains("Substation"))
                            {
                                pspDev.Lable = "变电站";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("motherlinenode"))
                            {
                                pspDev.Lable = "母线节点";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("Power"))
                            {
                                pspDev.Lable = "电厂";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmSubstation(pspDev);
                        }
                        dlg.Str_Power = str_power;

                        dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year");

                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "Use";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                                (text as Text).SetAttribute("print", dlg.IsTJ ? "no" : "yes");
                            }
                            pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);
                            pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);
                            element.SetAttribute("print", dlg.IsTJ ? "no" : "yes");

                            pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            pspDev.OutQ = Convert.ToDouble(dlg.OutQ); ;
                            //if (pspDev.InPutP==0)
                            pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);

                            if (dlg.NodeType == "是")
                            {
                                pspDev.NodeType = "0";
                            }
                            else
                            {
                                pspDev.NodeType = "1";
                            }
                            Services.BaseService.Update<PSPDEV>(pspDev);
                            tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg.TYear);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("Power"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmSubstation dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmSubstation(pspDev);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = -1;
                            pspDev.Type = "Use";
                            if (element.GetAttribute("xlink:href").Contains("Substation"))
                            {
                                pspDev.Lable = "变电站";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("motherlinenode"))
                            {
                                pspDev.Lable = "母线节点";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("Power"))
                            {
                                pspDev.Lable = "电厂";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmSubstation(pspDev);
                            dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year");
                        }

                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "Use";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);
                            pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);

                            if (dlg.NodeType == "是")
                            {
                                pspDev.NodeType = "0";
                            }
                            else
                            {
                                pspDev.NodeType = "2";
                            }
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("dynamotorline"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmFadejie dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "dynamotorline";
                            if (element.GetAttribute("xlink:href").Contains("dynamotorline"))
                            {
                                pspDev.Lable = "发电厂支路";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("gndline"))
                            {
                                pspDev.Lable = "接地支路";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "dynamotorline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            pspDev.HuganLine3 = dlg.SwitchStatus;
                            if (dlg.OutP != "")
                                pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            if (dlg.OutQ != "")
                                pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            if (dlg.VoltV != "")
                                pspDev.VoltV = Convert.ToDouble(dlg.VoltV);
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                            if (dlg.NegativeTQ != "")
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("gndline"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmFadejie dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "gndline";
                            if (element.GetAttribute("xlink:href").Contains("dynamotorline"))
                            {
                                pspDev.Lable = "发电厂支路";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("gndline"))
                            {
                                pspDev.Lable = "接地支路";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "gndline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            pspDev.HuganLine3 = dlg.SwitchStatus;
                            if (dlg.OutP != "")
                                pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            if (dlg.OutQ != "")
                                pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            if (dlg.VoltV != "")
                                pspDev.VoltV = Convert.ToDouble(dlg.VoltV);
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                            if (dlg.NegativeTQ != "")
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("loadline"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmLoad dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmLoad(pspDev);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "loadline";

                            pspDev.Lable = "负荷支路";

                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmLoad(pspDev);
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "loadline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;

                            pspDev.HuganLine3 = dlg.LoadSwitchState;
                            if (dlg.InPutP != "")
                                pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            if (dlg.InPutQ != "")
                                pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("串联电容电抗器"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmCapacity dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmCapacity(pspDev, pspDev.SvgUID);
                            dlg.SetEnable(true);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "串联电容电抗器";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;

                            // pspDev.HuganLine2 = dlg.LastNodeName;
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("并联电容电抗器"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmCapacity dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmCapacity(pspDev, pspDev.SvgUID);
                            dlg.SetEnable(false);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "并联电容电抗器";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            //pspDev.HuganLine2 = dlg.LastNodeName;
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("transformerthirdzu"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmThridTra dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmThridTra(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "transformerthirdzu";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.IName;
                            pspDev.HuganLine2 = dlg.JName;
                            pspDev.HuganLine3 = dlg.ISwitchState;
                            pspDev.HuganLine4 = dlg.JSwitchState;
                            pspDev.LineLevel = dlg.IType;
                            pspDev.LineType = dlg.JType;
                            pspDev.LineStatus = dlg.KType;
                            pspDev.KName = dlg.KName;
                            pspDev.KSwitchStatus = dlg.KSwitchState;
                            if (dlg.IK != "")
                            {
                                pspDev.K = Convert.ToDouble(dlg.KK);
                            }
                            if (dlg.JK != "")
                            {
                                pspDev.G = Convert.ToDouble(dlg.JK);
                            }
                            if (dlg.KK != "")
                            {
                                pspDev.BigP = Convert.ToDouble(dlg.KK);
                            }
                            if (dlg.IR != "")
                            {
                                pspDev.HuganTQ1 = Convert.ToDouble(dlg.IR);
                            }
                            if (dlg.JR != "")
                            {
                                pspDev.HuganTQ2 = Convert.ToDouble(dlg.JR);
                            }
                            if (dlg.KR != "")
                            {
                                pspDev.HuganTQ3 = Convert.ToDouble(dlg.KR);
                            }
                            if (dlg.ITQ != "")
                            {
                                pspDev.HuganTQ4 = Convert.ToDouble(dlg.ITQ);
                            }
                            if (dlg.JTQ != "")
                            {
                                pspDev.HuganTQ5 = Convert.ToDouble(dlg.JTQ);
                            }
                            if (dlg.KTQ != "")
                            {
                                pspDev.SmallTQ = Convert.ToDouble(dlg.KTQ);
                            }
                            if (dlg.ZeroTQ != "")
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ);

                            if (dlg.NeutralNodeTQ != "")
                                pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("transformertwozu"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmTwoTra dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmTwoTra(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "transformertwozu";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.FirstName;
                            pspDev.HuganLine2 = dlg.LastName;
                            pspDev.HuganLine3 = dlg.FirstSwitchState;
                            pspDev.HuganLine4 = dlg.LastSwitchState;
                            pspDev.LineLevel = dlg.FirstType;
                            pspDev.LineType = dlg.LastType;

                            if (dlg.PositiveR != "")
                            {
                                pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR);
                            }
                            if (dlg.PositiveTQ != "")
                            {
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                            }

                            if (dlg.ZeroR != "")
                            {
                                pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR);
                            }

                            if (dlg.ZeroTQ != "")
                            {
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ);
                            }

                            if (dlg.K != "")
                                pspDev.K = Convert.ToDouble(dlg.K);

                            if (dlg.NeutralNodeTQ != "")
                                pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("1/2母联开关"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmMuLian dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmMuLian(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "1/2母联开关";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            pspDev.HuganLine2 = dlg.LastNodeName;
                            pspDev.HuganLine3 = dlg.SwitchStatus;

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("2/3母联开关"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmMuLian2 dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmMuLian2(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "2/3母联开关";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.INodeName;
                            pspDev.HuganLine2 = dlg.JNodeName;
                            pspDev.HuganLine3 = dlg.ILineName;
                            pspDev.HuganLine4 = dlg.JLineName;
                            pspDev.KName = dlg.ILoadName;
                            pspDev.KSwitchStatus = dlg.JLoadName;
                            pspDev.LineLevel = dlg.SwitchStatus1;
                            pspDev.LineType = dlg.SwitchStatus2;
                            pspDev.LineStatus = dlg.SwitchStatus3;

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }

                }
                else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType == true)
                {

                    PSPDEV pspDev = new PSPDEV();
                    pspDev.EleID = element.GetAttribute("id");
                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);

                    frmLinenew dlg2;
                    if (pspDev != null)
                    {
                        dlg2 = new frmLinenew(pspDev);
                        dlg2.derefucelineflag = Reducelineflag;
                    }
                    else
                    {
                        pspDev = new PSPDEV();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = -1;
                        pspDev.Type = "Polyline";
                        pspDev.Lable = "支路";
                        Services.BaseService.Create<PSPDEV>(pspDev);
                        dlg2 = new frmLinenew(pspDev);
                        dlg2.derefucelineflag = Reducelineflag;
                    }
                    dlg2.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year");
                    dlg2.linevalue = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("linevalue");   //获得线路投资
                    if (dlg2.ShowDialog() == DialogResult.OK)
                    {
                        if (dlg2.Name == null)
                        {
                            MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlg2.Name;
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspName.Type = "Polyline";
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        pspDev.Name = dlg2.Name;
                        pspDev.LineLength = Convert.ToDouble(dlg2.LineLength);
                        pspDev.LineR = Convert.ToDouble(dlg2.LineR);
                        pspDev.LineTQ = Convert.ToDouble(dlg2.LineTQ);
                        pspDev.LineGNDC = Convert.ToDouble(dlg2.LineGNDC);
                        pspDev.LineLevel = dlg2.LineLevel;
                        pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt);
                        pspDev.LineType = dlg2.LineType;
                        pspDev.LineStatus = dlg2.LineStatus;
                        WireCategory wirewire = new WireCategory();
                        wirewire.WireType = dlg2.LineType;
                        if (dlg2.linevalue != "")
                        {
                            pspDev.BigP = Convert.ToDouble(dlg2.linevalue);
                        }
                        if (dlg2.ReferenceVolt != "")
                        {
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt);
                        }
                        WireCategory wirewire2 = new WireCategory();
                        wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire);
                        //if (pspDev.LineR == 0)
                        //    pspDev.LineR = Convert.ToDouble(dlg2.LineLength)*wirewire2.WireR ;
                        //if (pspDev.LineTQ == 0)
                        //    pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireTQ;
                        //if (pspDev.LineGNDC == 0)
                        //    pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireGNDC;
                        if (wirewire2 != null)
                            pspDev.LineChange = (double)wirewire2.WireChange;
                        string tempp = dlg2.LineLev;
                        int tel = tempp.Length;
                        //tempp = tempp.Substring(0, tel - 2);
                        pspDev.VoltR = Convert.ToDouble(tempp);
                        tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg2.TYear);
                        tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("linevalue", dlg2.linevalue);   //获得线路投资

                        //switch (dlg2.LineType)
                        //{
                        //    case "2*LGJ-400":
                        //        {
                        //            if (pspDev.LineR==0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.04;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.303;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.9;
                        //            pspDev.LineChange = 1690;
                        //        } break;
                        //    case "2*LGJ-300":
                        //        {
                        //            if (pspDev.LineR == 0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.054;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.308;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.7;
                        //            pspDev.LineChange = 1400;
                        //        } break;
                        //    case "2*LGJ-240":
                        //        {
                        //            if (pspDev.LineR == 0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.066;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.310;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.5;
                        //            pspDev.LineChange = 1220;
                        //        } break;
                        //    case "LGJ-400":
                        //        {
                        //            if (pspDev.LineR == 0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.08;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.417;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 13.2;
                        //            pspDev.LineChange = 845;
                        //        } break;

                        //}
                        Services.BaseService.Update<PSPDEV>(pspDev);
                        Topology2();
                    }
                }
                else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType != true)
                {

                    PSPDEV pspDev = new PSPDEV();
                    pspDev.EleID = element.GetAttribute("id");
                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);

                    frmLine dlg;
                    if (pspDev != null)
                    {
                        dlg = new frmLine(pspDev);
                    }
                    else
                    {
                        pspDev = new PSPDEV();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = -1;
                        pspDev.Type = "Polyline";
                        pspDev.Lable = "支路";
                        Services.BaseService.Create<PSPDEV>(pspDev);
                        dlg = new frmLine(pspDev);
                    }

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        if (dlg.Name == null)
                        {
                            MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlg.Name;
                        pspName.Type = "Polyline";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        pspDev.Name = dlg.Name;
                        pspDev.LineLength = Convert.ToDouble(dlg.LineLength);
                        pspDev.LineLevel = dlg.LineLevel;
                        pspDev.LineType = dlg.LineType;
                        pspDev.LineStatus = dlg.LineStatus;
                        pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR);
                        pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                        pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR);
                        pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ);
                        if (dlg.HuganFirst == "是")
                            pspDev.HuganFirst = 1;
                        else
                            pspDev.HuganFirst = 0;
                        pspDev.HuganLine1 = dlg.HuganLine1;
                        pspDev.HuganLine2 = dlg.HuganLine2;
                        pspDev.HuganLine3 = dlg.HuganLine3;
                        pspDev.HuganLine4 = dlg.HuganLine4;
                        pspDev.HuganTQ1 = Convert.ToDouble(dlg.HuganTQ1);
                        pspDev.HuganTQ2 = Convert.ToDouble(dlg.HuganTQ2);
                        pspDev.HuganTQ3 = Convert.ToDouble(dlg.HuganTQ3);
                        pspDev.HuganTQ4 = Convert.ToDouble(dlg.HuganTQ4);
                        pspDev.HuganTQ5 = Convert.ToDouble(dlg.HuganTQ5);
                        string tempp = dlg.LineLev;
                        int tel = tempp.Length;
                        if (tel == 1)
                            pspDev.VoltR = 0;
                        else
                        {
                            //tempp = tempp.Substring(0, tel - 2);
                            pspDev.VoltR = Convert.ToDouble(tempp);
                        }
                        //switch (dlg.LineType)
                        //{
                        //    case "2*LGJ-400":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.04;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.303;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.9;
                        //            pspDev.LineChange = 1690;
                        //        } break;
                        //    case "2*LGJ-300":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.054;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.308;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.7;
                        //            pspDev.LineChange = 1400;
                        //        } break;
                        //    case "2*LGJ-240":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.066;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.310;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.5;
                        //            pspDev.LineChange = 1220;
                        //        } break;
                        //    case "LGJ-400":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.08;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.417;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 13.2;
                        //            pspDev.LineChange = 845;
                        //        } break;

                        //}
                        Services.BaseService.Update<PSPDEV>(pspDev);
                        Topology2();
                    }
                }
            }
            tlVectorControl1.Operation = ToolOperation.Select;
            //contextMenuStrip1.Hide();
        }
Example #3
0
        /*public void ResetPoly()
        {
            SvgElementCollection col= tlVectorControl1.SVGDocument.SelectCollection;
            if(col.Count<1){
                return;
            }
            SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();
            foreach(SvgElement ele in col){
                if (ele.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                {
                    glebeProperty p=new glebeProperty();
                    p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    p.EleID = ((IGraph)ele).ID;
                    p = Services.BaseService.GetObject("SelectglebePropertyByEleID", p);
                    if(p!=null){
                        PointF[] tfArray1 = TLMath.getPolygonPoints(ele);
                        GraphicsPath selectAreaPath = new GraphicsPath();
                        selectAreaPath.AddLines(tfArray1);
                        selectAreaPath.CloseFigure();
                        Region region1 = new Region(selectAreaPath);
                        while (enumerator1.MoveNext())
                        {
                            IGraph graph1 = (IGraph)enumerator1.Current;
                            GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                            path1.Transform(graph1.GraphTransform.Matrix);
                            Region region2 = new Region(path1);
                            region2.Intersect(region1);
                            if (!region2.GetBounds(Graphics.FromHwnd(IntPtr.Zero)).IsEmpty)
                            {
                                glebeProperty p1 = new glebeProperty();
                                p1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                p1.EleID = graph1.ID;
                                p1 = Services.BaseService.GetObject("SelectglebePropertyByEleID", p1);
                                if(p1!=null){
                                    p1.ParentEleID = p.UID;
                                    Services.BaseService.Update("UpdateglebePropertyAreaAll", p1);
                                }
                            }
                        }
                    }
                }
            }
            MessageBox.Show("更新完成。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }*/
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try {
                if (e.ClickedItem.Text == "可靠性分析") {
                    XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                        string deviceid = xml1.GetAttribute("Deviceid");
                        if (!string.IsNullOrEmpty(deviceid)) {
                            DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                            DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;

                            PSPDEV obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                            if (obj != null && obj.Type == "73") {
                                //更换为元件可靠性
                                Itop.TLPSP.DEVICE.FrmpdrelProject xf = new Itop.TLPSP.DEVICE.FrmpdrelProject();
                                xf.init(obj);
                                xf.ShowDialog();
                            }

                        }
                    }

                }
                if (e.ClickedItem.Text == "属性") {
                    XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    //PointF[] pf = TLMath.getPolygonPoints(xml1);
                    DeviceHelper.xml1 = xml1;
                    //((Polygon)xml1).Transform.Matrix.TransformPoints(pf);
                    // 规划
                    if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) {

                        if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请先选择规划区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") {
                            //frmImgManager frm = new frmImgManager();
                            //frm.Show();
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            XmlNodeList n1 = tlVectorControl1.SVGDocument.GetElementsByTagName("use");
                            PointF[] tfArray1 = TLMath.getPolygonPoints(xml1);
                            string str220 = "";
                            string str110 = "";
                            string str66 = "";

                            string str_id = "";
                            GraphicsPath selectAreaPath = new GraphicsPath();
                            selectAreaPath.AddLines(tfArray1);
                            selectAreaPath.CloseFigure();
                            //Matrix x=new Matrix(
                            //Region region1 = new Region(selectAreaPath);
                            for (int i = 0; i < n1.Count; i++) {
                                float OffX = 0f;
                                float OffY = 0f;
                                bool ck = false;
                                Use use = (Use)n1[i];
                                if (use.GetAttribute("xlink:href").Contains("byq") || use.GetAttribute("xlink:href").Contains("pds")) {
                                    if (selectAreaPath.IsVisible(use.CenterPoint)) {
                                        if (use.GetAttribute("Deviceid") != "") {
                                            str_id = str_id + "'" + use.GetAttribute("Deviceid") + "',";
                                        }
                                    }
                                }
                                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]);
                                    //    }
                                    //}
                                    //if (frmlar.getSelectedLayer().Contains(use.GetAttribute("layer"))) {
                                    //    ck = true;
                                    //}
                                    for (int j= 0; j< frmlar.GetSelectLayers().Count;j++ )
                                    {
                                        if ((frmlar.GetSelectLayers()[j] as Layer).ID==use.GetAttribute("layer"))
                                        {
                                            ck = true;
                                        }
                                    }
                                    PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href"));
                                    //if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY) && ck)
                                    if (selectAreaPath.IsVisible(use.CenterPoint) && ck) {
                                        if (use.GetAttribute("xlink:href").Contains("220")) {
                                            str220 = str220 + "'" + use.GetAttribute("Deviceid") + "',";
                                        }
                                        if (use.GetAttribute("xlink:href").Contains("110")) {
                                            str110 = str110 + "'" + use.GetAttribute("Deviceid") + "',";
                                        }
                                        if (use.GetAttribute("xlink:href").Contains("66")) {
                                            str66 = str66 + "'" + use.GetAttribute("Deviceid") + "',";
                                        }
                                    }
                                }
                            }
                            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);
                            }
                            if (str_id.Length > 1) {
                                str_id = str_id.Substring(0, str_id.Length - 1);
                            }
                            glebeProperty _gle = new glebeProperty();
                            _gle.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                            _gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;

                            IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle);
                            if (UseProList.Count > 0) {
                                _gle = UseProList[0];
                                _gle.LayerID = SvgDocument.currentLayer;
                                frmMainProperty f = new frmMainProperty();
                                f.strID = str_id;
                                f.InitData(_gle, str220, str110, str66);
                                PointF[] pn = (PointF[])((Polygon)xml1).Points.Clone();
                                ((Polygon)xml1).Transform.Matrix.TransformPoints(pn);
                                string s1 = "";
                                for (int p = 0; p < pn.Length; p++) {
                                    s1 = s1 + pn[p].X.ToString() + " " + pn[p].Y.ToString() + ",";
                                }
                                f.Str = s1;
                                f.ShowDialog();
                                if (f.checkBox1.Checked == false) {
                                    tlVectorControl1.SVGDocument.RootElement.RemoveChild(tlVectorControl1.SVGDocument.CurrentElement);
                                }
                                //tlVectorControl1.Refresh();
                            } else {
                                _gle = new glebeProperty();
                                _gle.LayerID = SvgDocument.currentLayer;
                                frmMainProperty f = new frmMainProperty();
                                f.strID = str_id;
                                f.InitData(_gle, str220, str110, str66);
                                PointF[] pn = (PointF[])((Polygon)xml1).Points.Clone();
                                ((Polygon)xml1).Transform.Matrix.TransformPoints(pn);
                                string s1 = "";
                                for (int p = 0; p < pn.Length; p++) {
                                    s1 = s1 + pn[p].X.ToString() + " " + pn[p].Y.ToString() + ",";
                                }
                                f.Str = s1;
                                f.ShowDialog();
                            }
                            //}
                        }

                    }
                    if (getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())) {

                        if (tlVectorControl1.SVGDocument.getRZBRatio() != "") {
                            rzb = tlVectorControl1.SVGDocument.getRZBRatio();
                        }

                        if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请先选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            string IsArea = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsArea");
                            if (IsArea != "") {

                                frmProperty f = new frmProperty();//地块属性
                                if (SelUseArea == "") { SelUseArea = "0"; }
                                f.XZ_bdz = XZ_bdz;
                                f.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer);
                                //f.ShowDialog();
            #if(!CITY)
                                //将其中心点保存在XML中
                                PointF p = TLMath.polyCentriod((XmlElement)tlVectorControl1.SVGDocument.CurrentElement);
                                string title = p.X.ToString() + "," + p.Y.ToString();
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("centrpoint", title);
                                if (progtype != "城市规划层") {
                                    f.IsReadonly = true;
                                }
            #endif
                                if (f.ShowDialog() == DialogResult.OK) {
                                    SVG_ENTITY ent = new SVG_ENTITY();
                                    if (f.IsCreate) {
                                        ent.SUID = Guid.NewGuid().ToString();
                                        ent.EleID = f.gPro.EleID;
                                        ent.layerID = f.gPro.LayerID;
                                        ent.MDATE = System.DateTime.Now;
                                        ent.NAME = f.gPro.UseID;
                                        ent.svgID = f.gPro.SvgUID;
                                        ent.TYPE = "polygon-dk";
                                        //ent.voltage = f.gPro.Voltage;
                                        Services.BaseService.Create<SVG_ENTITY>(ent);
                                    } else {
                                        ent.NAME = f.gPro.UseID;
                                        ent.layerID = f.gPro.LayerID;
                                        ent.MDATE = System.DateTime.Now;
                                        //ent.voltage = fl.Line.Voltage;
                                        Services.BaseService.Update<SVG_ENTITY>(ent);
                                    }
                                    if (f.gPro.ObligateField1 != "") {
                                        string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(f.gPro.ObligateField1)));
                                        color1 = "fill:" + color1 + ";";
                                        ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", color1);
                                        tlVectorControl1.UpdateProperty();
                                    }
                                    if (xzwcflag == "1" && f.bdzflag)
                                   {

                                          if (extsublist.Count > 0 && subandfhlist.Count > 0)
                                          {
                                              bool sfsflag=false;
                                              for(int m=0;m<polylist.Count;m++)
                                              {
                                               if((polylist[m] as XmlElement).GetAttribute("id")==f.gPro.EleID)
                                               {
                                                   sfsflag=true;
                                                   break;
                                               }

                                              }
                                              if (!sfsflag)
                                              {
                                                  MessageBox.Show("地块非选址的地块中 请重新选址!");
                                                  return;
                                              }
                                              try
                                              {
                                                List<Layer> layercol=  getxzxllayers(tlVectorControl1.SVGDocument.getLayerList());
                                                  if (layercol.Count>0)
                                                  {
                                                      FrmSelxzlayer frm=new FrmSelxzlayer();
                                                      frm.Layercol=layercol;
                                                      if (frm.ShowDialog()==DialogResult.OK)
                                                      {
                                                          string layerid=frm.sellayerid;
                                                           RebdzxzResult1(subandfhlist, extsublist, f.gPro, f.bdzzqname,layerid);
                                                      }
                                                      else
                                                        RebdzxzResult(subandfhlist, extsublist, f.gPro, f.bdzzqname);
                                                  }
                                                 // RebdzxzResult(subandfhlist, extsublist, f.gPro, f.bdzzqname);
                                              }
                                              catch (System.Exception ex)
                                              {
                                                  MessageBox.Show("请计算有问题 请重新计算!");
                                                  return;
                                              }

                                          }
                                          else
                                          {
                                              MessageBox.Show("选址变电站没有数据 请重新选址!");
                                              return;
                                          }

                                  }
                                 else
                                  {
                                      MessageBox.Show("请重新选址!");
                                     return;
                                  }

                                }
                            }
                        }
                    }
                    if (!Wjghboolflag) {
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                            string lineWidth = "2";
                            string IsLead = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsLead");
                            //if (IsLead != "")       //原先导线的属性添加情况

                            if (IsLead != "")       //修改后的导线的属性添加情况
                            {
                                XmlNodeList n11 = tlVectorControl1.SVGDocument.SelectNodes("svg/polygon [@IsArea='1']");
                                using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) {
                                    List<glebeProperty> glist = new List<glebeProperty>();
                                    for (int i = 0; i < n11.Count; i++) {
                                        IGraph graph1 = (IGraph)n11[i];
                                        GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                                        //path1.Transform(graph1.GraphTransform.Matrix);
                                        Region ef1 = new Region(path1);

                                        Polyline line = tlVectorControl1.SVGDocument.CurrentElement as Polyline;
                                        GraphicsPath gr2 = new GraphicsPath();
                                        //gr2.AddLines(pfs);
                                        gr2.AddPath(line.GPath, true);
                                        gr2.CloseFigure();
                                        Region region = new Region(gr2);
                                        ef1.Intersect(region);
                                        if (!ef1.GetBounds(g).IsEmpty) {
                                            glebeProperty gy = new glebeProperty();
                                            gy.EleID = graph1.ID;
                                            gy.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                            gy = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", gy);
                                            if (gy != null) {
                                                glebeType gt = new glebeType();
                                                gt.UID = gy.TypeUID;
                                                gt = (glebeType)Services.BaseService.GetObject("SelectglebeTypeByKey", gt);
                                                gy.TypeUID = gt.TypeName;
                                                glist.Add(gy);
                                            }
                                        }
                                    }
                                    DeviceHelper.glist = glist;
                                }
                                string dhx = xml1.GetAttribute("dhx_key");
                                if (dhx == "1" && checkEdit2.Checked == false) {
                                    frmDHXdlg d = new frmDHXdlg();
                                    d.uid = xml1.GetAttribute("id");
                                    d.Show();
                                    return;
                                }

                                PSPDEV obj = new PSPDEV();
                                string deviceid = xml1.GetAttribute("Deviceid");
                                DeviceHelper.pspflag = false;
                                DeviceHelper.Wjghflag = false;
                                if (string.IsNullOrEmpty(deviceid)) {
                                    string[] deviceType = new string[] { "05", "73", "75" };
                                    string xlwhere = " where SUID not in (";
                                    XmlNodeList lslist = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@Deviceid!=''] [@layer='" + SvgDocument.currentLayer + "']");
                                    for (int x1 = 0; x1 < lslist.Count; x1++) {
                                        XmlElement _node = lslist[x1] as XmlElement;
                                        xlwhere = xlwhere + "'" + _node.GetAttribute("Deviceid") + "',";
                                    }
                                    if (xlwhere.Length > 20) {
                                        xlwhere = xlwhere.Substring(0, xlwhere.Length - 1);
                                        xlwhere = xlwhere + ") and ";
                                    } else {
                                        xlwhere = "";
                                    }
                                    DeviceHelper.xlwhere = xlwhere;
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(Itop.Client.MIS.ProgUID, deviceType);
                                    DeviceHelper.xlwhere = "";
                                    if (obj is PSPDEV) {
                                        deviceid = ((PSPDEV)obj).SUID;
                                        xml1.SetAttribute("Deviceid", deviceid);
                                        obj.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        obj.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        obj.EleID = ((SvgElement)xml1).ID;
                                        Services.BaseService.Update<PSPDEV>(obj);

                                        //将其设备加入到计算方案中
                                        //获得方案名称
                                        PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                                        pd.ID = frmlar.FAID;
                                        pd = Services.BaseService.GetOneByKey<PSP_ELCPROJECT>(pd);
                                        if (pd != null) {
                                            bool operflag = false, dataflag = false;
                                            if (!string.IsNullOrEmpty(((PSPDEV)obj).OperationYear) && ((PSPDEV)obj).OperationYear.Length == 4 && pd.BelongYear.Length == 4) {
                                                if (Convert.ToInt32(((PSPDEV)obj).OperationYear) < Convert.ToInt32(pd.BelongYear)) {
                                                    operflag = true;
                                                }
                                            }
                                            if (!string.IsNullOrEmpty(((PSPDEV)obj).Date2) && ((PSPDEV)obj).Date2.Length == 4 && pd.BelongYear.Length == 4) {
                                                if (Convert.ToInt32(((PSPDEV)obj).Date2) > Convert.ToInt32(pd.BelongYear)) {
                                                    dataflag = true;
                                                }
                                            }
                                            if (operflag && dataflag) {
                                                PSP_ElcDevice elcDevice = new PSP_ElcDevice();
                                                elcDevice.DeviceSUID = deviceid;
                                                elcDevice.ProjectSUID = frmlar.FAID;
                                                elcDevice = UCDeviceBase.DataService.GetOneByKey<PSP_ElcDevice>(elcDevice);
                                                if (elcDevice == null) {
                                                    elcDevice = new PSP_ElcDevice();
                                                    elcDevice.DeviceSUID = deviceid;
                                                    elcDevice.ProjectSUID = frmlar.FAID;
                                                    UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice);
                                                }
                                            }

                                        }

                                    }
                                }
                                if (!string.IsNullOrEmpty(deviceid)) {
                                    DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                                    DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;

                                    obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                                    if (obj != null)//------------wwwMX
                                    {
                                        xml1.SetAttribute("info-name", ((PSPDEV)obj).Name);
                                        if (obj.Type == "05") {
                                            DeviceHelper.ShowDeviceDlg(DeviceType.XL, deviceid, false);
                                        }
                                        if (obj.Type == "01") {
                                            DeviceHelper.ShowDeviceDlg(DeviceType.MX, deviceid, false);
                                        }
                                        if (obj.Type == "73") {
                                            DeviceHelper.ShowDeviceDlg(DeviceType.PDXL, deviceid, false);
                                        }
                                        if (obj.Type == "75") {
                                            DeviceHelper.ShowDeviceDlg(DeviceType.LUX, deviceid, false);
                                        }
                                    }

                                    //***** ********添加FistNode和LastNode
                                    XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");

                                    foreach (XmlNode element in useList) {
                                        if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid"))) {
                                            string con = "WHERE SvgUID='" + (element as XmlElement).GetAttribute("Deviceid") + "'AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='01'";
                                            IList pspMX = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                            if (pspMX != null) {
                                                foreach (PSPDEV pspmx in pspMX) {
                                                    if (obj.IName == pspmx.Name) {
                                                        (xml1 as XmlElement).SetAttribute("FirstNode", (element as XmlElement).GetAttribute("id"));

                                                    } else if (obj.JName == pspmx.Name) {
                                                        (xml1 as XmlElement).SetAttribute("LastNode", (element as XmlElement).GetAttribute("id"));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                //**

                            }
                        }

                        if (xml1.GetAttribute("xlink:href").Contains("Substation") || xml1.GetAttribute("xlink:href").Contains("Power")) {//变电站属性
                            string lab = xml1.GetAttribute("xlink:href");

                            float x = 0f;
                            float y = 0f;
                            //判断电压等级
                            int dyinfo = Convert.ToInt32(getDY(lab));
                            x = ((Use)xml1).X;

                            y = ((Use)xml1).Y;

                            PointF p1 = new PointF(x, y);
                            PointF[] pnt = new PointF[1];
                            pnt[0] = p1;
                            Use temp = xml1.Clone() as Use;
                            temp.Transform.Matrix.TransformPoints(pnt);

                            LongLat templat = mapview.OffSetZero(-(int)(pnt[0].X * tlVectorControl1.ScaleRatio), -(int)(pnt[0].Y * tlVectorControl1.ScaleRatio));

                            string[] jd = templat.Longitude.ToString("####.####").Split('.');
                            int d1 = Convert.ToInt32(jd[0]);
                            string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.');
                            int f1 = Convert.ToInt32(df1[0]);
                            decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60;

                            string[] wd = templat.Latitude.ToString("####.####").Split('.');
                            int d2 = Convert.ToInt32(wd[0]);
                            string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.');
                            int f2 = Convert.ToInt32(df2[0]);
                            decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60;

                            string strjwd = "经纬度: " + d1.ToString() + "°" + f1.ToString() + "′" + m1.ToString("##.#") + "″," + d2.ToString() + "°" + f2.ToString() + "′" + m2.ToString("##.#") + "″";
                            object obj = null;
                            string deviceid = xml1.GetAttribute("Deviceid");
                            DeviceHelper.pspflag = false;
                            DeviceHelper.Wjghflag = false;
                            if (dyinfo >= 66) {
                                DeviceHelper.subflag = false;
                            } else
                                DeviceHelper.subflag = true;
                        Lab1://变电站、电源属性
                            if (string.IsNullOrEmpty(deviceid)) {
                                //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                    obj = DeviceHelper.SelectDevice(DeviceType.DY, Itop.Client.MIS.ProgUID);
                                    //if (obj == null)
                                    //{
                                    //    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    //    tlVectorControl1.Delete();
                                    //}
                                    if (obj is PSP_PowerSubstation_Info) {
                                        deviceid = ((PSP_PowerSubstation_Info)obj).UID;
                                        ((PSP_PowerSubstation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        //((PSP_PowerSubstation_Info)obj). = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        Services.BaseService.Update<PSP_PowerSubstation_Info>(((PSP_PowerSubstation_Info)obj));
                                        xml1.SetAttribute("Deviceid", deviceid);
                                        xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title);

                                        //获得方案名称
                                        PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                                        pd.ID = frmlar.FAID;
                                        pd = Services.BaseService.GetOneByKey<PSP_ELCPROJECT>(pd);
                                        if (pd != null) {
                                            string where = "where projectid='" + Itop.Client.MIS.ProgUID + "'and SvgUID='" + ((PSP_PowerSubstation_Info)obj).UID + "'";
                                            IList<PSPDEV> list = Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", where);
                                            //根据年份进行筛选
                                            if (!string.IsNullOrEmpty(pd.BelongYear))   //根据参与计算设备属于那一年先进行一次筛选
                                            {
                                                for (int i = 0; i < list.Count; i++) {
                                                    if (!string.IsNullOrEmpty((list[i] as PSPDEV).OperationYear) && (list[i] as PSPDEV).OperationYear.Length == 4 && pd.BelongYear.Length == 4) {
                                                        if (Convert.ToInt32((list[i] as PSPDEV).OperationYear) > Convert.ToInt32(pd.BelongYear)) {
                                                            list.RemoveAt(i);
                                                            i--;
                                                            continue;
                                                        }
                                                    }
                                                    if (!string.IsNullOrEmpty((list[i] as PSPDEV).Date2) && (list[i] as PSPDEV).Date2.Length == 4 && pd.BelongYear.Length == 4) {
                                                        if (Convert.ToInt32((list[i] as PSPDEV).Date2) < Convert.ToInt32(pd.BelongYear)) {
                                                            list.RemoveAt(i);
                                                            i--;
                                                            continue;
                                                        }
                                                    }
                                                }
                                            }

                                            foreach (PSPDEV pv in list) {
                                                //将其设备加入到计算方案中
                                                PSP_ElcDevice elcDevice = new PSP_ElcDevice();
                                                elcDevice.DeviceSUID = pv.SUID;
                                                elcDevice.ProjectSUID = frmlar.FAID;
                                                elcDevice = UCDeviceBase.DataService.GetOneByKey<PSP_ElcDevice>(elcDevice);
                                                if (elcDevice == null) {
                                                    elcDevice = new PSP_ElcDevice();
                                                    elcDevice.DeviceSUID = pv.SUID;
                                                    elcDevice.ProjectSUID = frmlar.FAID;
                                                    UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice);
                                                }
                                            }
                                        }
                                    }

                                    substation sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);

                                    }
                                } else {
                                    DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                                    DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;
                                    DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    //wwww
                                    string bdzwhere = " UID not in (";

                                    XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@Deviceid!=''] [@layer='" + SvgDocument.currentLayer + "']");

                                    for (int x2 = 0; x2 < useList.Count; x2++) {
                                        XmlElement _node = useList[x2] as XmlElement;
                                        bdzwhere = bdzwhere + "'" + _node.GetAttribute("Deviceid") + "',";
                                    }
                                    if (bdzwhere.Length > 13) {
                                        bdzwhere = bdzwhere.Substring(0, bdzwhere.Length - 1);
                                        bdzwhere = bdzwhere + ") and ";
                                    } else {
                                        bdzwhere = "";
                                    }

                                    DeviceHelper.bdzwhere = bdzwhere;
                                    obj = DeviceHelper.SelectDevice(DeviceType.BDZ, Itop.Client.MIS.ProgUID);
                                    DeviceHelper.bdzwhere = "";
                                    //if (obj == null)
                                    //{
                                    //    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    //    tlVectorControl1.Delete();
                                    //}
                                    if (obj is PSP_Substation_Info) {
                                        deviceid = ((PSP_Substation_Info)obj).UID;
                                        ((PSP_Substation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        ((PSP_Substation_Info)obj).EleID = tlVectorControl1.SVGDocument.CurrentElement.ID;

                                        ((PSP_Substation_Info)obj).AreaID = Itop.Client.MIS.ProgUID;

                                        Services.BaseService.Update<PSP_Substation_Info>(((PSP_Substation_Info)obj));
                                        xml1.SetAttribute("Deviceid", deviceid);
                                        xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title);

                                        //获得方案名称
                                        PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                                        pd.ID = frmlar.FAID;
                                        pd = Services.BaseService.GetOneByKey<PSP_ELCPROJECT>(pd);
                                        if (pd != null) {
                                            string where = "where projectid='" + Itop.Client.MIS.ProgUID + "'and SvgUID='" + ((PSP_Substation_Info)obj).UID + "'";
                                            IList<PSPDEV> list = Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", where);
                                            //根据年份进行筛选
                                            if (!string.IsNullOrEmpty(pd.BelongYear))   //根据参与计算设备属于那一年先进行一次筛选
                                            {
                                                for (int i = 0; i < list.Count; i++) {
                                                    if (!string.IsNullOrEmpty((list[i] as PSPDEV).OperationYear) && (list[i] as PSPDEV).OperationYear.Length == 4 && pd.BelongYear.Length == 4) {
                                                        if (Convert.ToInt32((list[i] as PSPDEV).OperationYear) > Convert.ToInt32(pd.BelongYear)) {
                                                            list.RemoveAt(i);
                                                            i--;
                                                            continue;
                                                        }
                                                    }
                                                    if (!string.IsNullOrEmpty((list[i] as PSPDEV).Date2) && (list[i] as PSPDEV).Date2.Length == 4 && pd.BelongYear.Length == 4) {
                                                        if (Convert.ToInt32((list[i] as PSPDEV).Date2) < Convert.ToInt32(pd.BelongYear)) {
                                                            list.RemoveAt(i);
                                                            i--;
                                                            continue;
                                                        }
                                                    }
                                                }
                                            }

                                            foreach (PSPDEV pv in list) {
                                                //将其设备加入到计算方案中
                                                PSP_ElcDevice elcDevice = new PSP_ElcDevice();
                                                elcDevice.DeviceSUID = pv.SUID;
                                                elcDevice.ProjectSUID = frmlar.FAID;
                                                elcDevice = UCDeviceBase.DataService.GetOneByKey<PSP_ElcDevice>(elcDevice);
                                                if (elcDevice == null) {
                                                    elcDevice = new PSP_ElcDevice();
                                                    elcDevice.DeviceSUID = pv.SUID;
                                                    elcDevice.ProjectSUID = frmlar.FAID;
                                                    UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice);
                                                }
                                            }
                                        }

                                        //return;
                                        //根据变站创建线路
                                        createLine(xml1, deviceid);
                                    }
                                    /*
                                    substation sb = new substation();
                                    sb.UID = ((PSP_Substation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null)
                                    {

                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_Substation_Info)obj).Flag == "2")
                                        {
                                            sb.ObligateField3 = "规划";
                                        }
                                        else if (((PSP_Substation_Info)obj).Flag == "1")
                                        {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    }
                                    else
                                    {
                                        sb = new substation();
                                        sb.UID = ((PSP_Substation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_Substation_Info)obj).Flag == "2")
                                        {
                                            sb.ObligateField3 = "规划";
                                        }
                                        else if (((PSP_Substation_Info)obj).Flag == "1")
                                        {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }*/
                                }
                            }
                            if (!string.IsNullOrEmpty(deviceid)) {
                                if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                    DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                                    DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;
                                    DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid);
                                    if (obj != null) {
                                        DeviceHelper.StartYear = startyear;
                                        //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                        if (DeviceHelper.ShowDeviceDlg(DeviceType.DY, deviceid, false)) {
                                            obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid);
                                            xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title);
                                        }
                                    } else {
                                        deviceid = ""; goto Lab1;
                                    }

                                    // re
                                    substation sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }
                                } else {
                                    obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                                    if (obj != null) {
                                        DeviceHelper.StartYear = startyear;
                                        //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                        if (DeviceHelper.ShowDeviceDlg(DeviceType.BDZ, deviceid, false)) {
                                            obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                                            xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title);
                                        }
                                    } else {
                                        deviceid = ""; goto Lab1;
                                    }
                                    substation sb = new substation();
                                    sb.UID = ((PSP_Substation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_Substation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_Substation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_Substation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }
                                }

                            }

                        }
                        if (xml1.GetAttribute("xlink:href").Contains("XL_GT_3") || xml1.GetAttribute("xlink:href").Contains("XL_GT_4")) {
                            frmInputNum num = new frmInputNum();
                            num.InputStr = xml1.GetAttribute("order");
                            num.ShowDialog();
                            xml1.SetAttribute("order", num.InputStrSEL);
                        }
                        if (xml1.GetAttribute("xlink:href").Contains("hwg") || xml1.GetAttribute("xlink:href").Contains("pds") ||
                            xml1.GetAttribute("xlink:href").Contains("fjx") || xml1.GetAttribute("xlink:href").Contains("kbs") ||
                            xml1.GetAttribute("xlink:href").Contains("byq") || xml1.GetAttribute("xlink:href").Contains("kg") ||
                             xml1.GetAttribute("xlink:href").Contains("gt")) {
                            //frmInputDialog n1 = new frmInputDialog();
                            //n1.InputStr = xml1.GetAttribute("info-name").ToString();
                            //if (n1.ShowDialog() == DialogResult.OK)
                            //{
                            //    xml1.SetAttribute("info-name", n1.InputStr);
                            //}
                            PSPDEV obj = new PSPDEV();
                            string deviceid = xml1.GetAttribute("Deviceid");
                            DeviceHelper.pspflag = false;
                            DeviceHelper.Wjghflag = false;
                            if (string.IsNullOrEmpty(deviceid)) {
                                if (xml1.GetAttribute("xlink:href").Contains("kbs")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.KBS, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("fjx")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.FZX, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("hwg")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.HWG, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("kg")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.ZSKG, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("pds")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.PDS, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("byq")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(Itop.Client.MIS.ProgUID, "51", "52");
                                }
                                //if (xml1.GetAttribute("xlink:href").Contains("gt"))
                                //{
                                //    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.GT, Itop.Client.MIS.ProgUID);
                                //}
                                if (obj is PSPDEV) {
                                    deviceid = ((PSPDEV)obj).SUID;
                                    xml1.SetAttribute("Deviceid", deviceid);
                                    obj.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    obj.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    // obj.EleID = ((SvgElement)xml1).ID;
                                    Services.BaseService.Update<PSPDEV>(obj);
                                }
                            }
                            if (!string.IsNullOrEmpty(deviceid)) {
                                DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                                DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;

                                obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                                if (obj != null)//------------wwwMX
                                {
                                    xml1.SetAttribute("info-name", ((PSPDEV)obj).Name);
                                    DeviceHelper.ShowDeviceDlg((DeviceType)int.Parse(obj.Type), deviceid, false);
                                    //if (obj.Type == "54")
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.KBS, deviceid, false);
                                    //}
                                    //if (obj.Type == "56")
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.HWG, deviceid, false);
                                    //}
                                    //if (obj.Type == "58")
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.FZX, deviceid, false);
                                    //}
                                    //if (obj.Type == "51" )
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.FZX, deviceid, false);
                                    //}
                                    //if (obj.Type == "52")
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.FZX, deviceid, false);
                                    //}
                                }
                            }

                        }
                        /* if (xml1.GetAttribute("xlink:href").Contains("kbs") || xml1.GetAttribute("xlink:href").Contains("hwg"))
                         {
                             //frmkbsProperty num = new frmkbsProperty();
                             //num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                             //num.ShowDialog();

                         }
                         if (xml1.GetAttribute("xlink:href").Contains("fjx"))
                         {
                             frmfjxProperty num = new frmfjxProperty();
                             num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                             num.ShowDialog();
                         }
                         if (xml1.GetAttribute("xlink:href").Contains("byq"))
                         {
                             frmbyqProperty num = new frmbyqProperty();
                             num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                             num.ShowDialog();
                         } */
                        if (xml1.GetAttribute("xlink:href").Contains("SB_GT")) {
                            string lineWidth = "2";

                            string Code = xltProcessor.GetCurrentLineCode();
                            string _len = xltProcessor.GetWholeLineLength(Code).ToString("#####.####");

                            frmLineProperty fl = new frmLineProperty();
                            fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement;
                            fl.InitData(Code, tlVectorControl1.SVGDocument.SvgdataUid, _len, SvgDocument.currentLayer);
                            if (fl.ShowDialog() == DialogResult.OK) {
                                //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;"
                                lineWidth = fl.LineWidth;
                                string styleValue = "";
                                if (fl.Line.ObligateField1 == "规划") {
                                    styleValue = "stroke-dasharray:4 4;stroke-width:" + lineWidth + ";";
                                } else {
                                    styleValue = "stroke-width:" + lineWidth + ";";
                                }

                                styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("style");
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", styleValue);

                                xltProcessor.SetWholeLineAttribute(Code, "style", styleValue);
                            }
                        }
                    }
                    #region 网架优化的属性输入

                    if (Wjghboolflag) {
                        checkwjghelement();
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                            string lineWidth = "2";
                            string IsLead = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsLead");
                            if (IsLead != "")       //修改后的导线的属性添加情况
                            {
                                PSPDEV obj = new PSPDEV();
                                string deviceid = xml1.GetAttribute("Deviceid");
                                DeviceHelper.pspflag = false;
                                DeviceHelper.Wjghflag = true;
                                DeviceHelper.wjghuid = ff.Key;
                                if (string.IsNullOrEmpty(deviceid)) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.XL, Itop.Client.MIS.ProgUID);
                                    if (obj == null) {
                                        tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                        tlVectorControl1.Delete();
                                    }
                                    if (obj is PSPDEV) {
                                        deviceid = ((PSPDEV)obj).SUID;
                                        xml1.SetAttribute("Deviceid", deviceid);
                                        obj.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        obj.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        obj.EleID = ((SvgElement)xml1).ID;
                                        Services.BaseService.Update<PSPDEV>((PSPDEV)obj);
                                    }
                                }
                                if (!string.IsNullOrEmpty(deviceid)) {
                                    obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                                    if (obj != null) {
                                        xml1.SetAttribute("info-name", ((PSPDEV)obj).Name);
                                        DeviceHelper.ShowDeviceDlg(DeviceType.XL, deviceid, false);
                                    }

                                    LineInfo li = new LineInfo();
                                    li.UID = obj.SUID;
                                    li = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByKey", li);
                                    if (li != null) {
                                        li.LayerID = SvgDocument.currentLayer;
                                        li.EleID = xml1.GetAttribute("id");
                                        li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        LineType lt = new LineType();
                                        lt.TypeName = li.Voltage.ToString() + "kV";
                                        lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt);
                                        li.ObligateField3 = obj.OperationYear;
                                        li.ObligateField2 = lt.Color;
                                        lineWidth = lt.ObligateField1;
                                        if (!string.IsNullOrEmpty(li.ObligateField3)) {
                                            if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) {
                                                li.ObligateField1 = "规划";
                                            } else
                                                li.ObligateField1 = "运行";
                                        }
                                        Services.BaseService.Update<LineInfo>(li);
                                    } else {
                                        li = new LineInfo();
                                        li.UID = obj.SUID;
                                        li.LineName = obj.Name;
                                        li.Length = obj.LineLength.ToString();
                                        li.LineType = obj.LineType;
                                        li.Voltage = obj.ReferenceVolt.ToString();
                                        li.EleID = xml1.GetAttribute("id");
                                        li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        LineType lt = new LineType();
                                        lt.TypeName = obj.ReferenceVolt.ToString() + "kV";
                                        lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt);
                                        li.ObligateField3 = obj.OperationYear;
                                        li.ObligateField2 = lt.Color;
                                        lineWidth = lt.ObligateField1;
                                        if (!string.IsNullOrEmpty(li.ObligateField3)) {
                                            if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) {
                                                li.ObligateField1 = "规划";
                                            } else
                                                li.ObligateField1 = "运行";
                                        }

                                        Services.BaseService.Create<LineInfo>(li);
                                    }

                                    string styleValue = "";
                                    if (li.ObligateField1 == "规划") {
                                        styleValue = "stroke-dasharray:" + ghType + ";stroke-width:" + lineWidth + ";";
                                    } else {
                                        styleValue = "stroke-width:" + lineWidth + ";";
                                    }
                                    //string aa= ColorTranslator.ToHtml(Color.Black);
                                    styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(li.ObligateField2)));
                                    SvgElement se = tlVectorControl1.SVGDocument.CurrentElement;
                                    se.RemoveAttribute("style");
                                    se.SetAttribute("style", styleValue);
                                    se.SetAttribute("info-name", li.LineName);
                                    //***** ********添加FistNode和LastNode
                                    XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");

                                    foreach (XmlNode element in useList) {
                                        if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid"))) {
                                            string con = "WHERE SvgUID='" + (element as XmlElement).GetAttribute("Deviceid") + "'AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='01'";
                                            IList pspMX = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                            if (pspMX != null) {
                                                foreach (PSPDEV pspmx in pspMX) {
                                                    if (obj.IName == pspmx.Name) {
                                                        (xml1 as XmlElement).SetAttribute("FirstNode", (element as XmlElement).GetAttribute("id"));

                                                    } else if (obj.JName == pspmx.Name) {
                                                        (xml1 as XmlElement).SetAttribute("LastNode", (element as XmlElement).GetAttribute("id"));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                //**

                            }
                        }

                        if (xml1.GetAttribute("xlink:href").Contains("Substation") || xml1.GetAttribute("xlink:href").Contains("Power")) {
                            string lab = xml1.GetAttribute("xlink:href");

                            float x = 0f;
                            float y = 0f;

                            x = ((Use)xml1).X;

                            y = ((Use)xml1).Y;

                            PointF p1 = new PointF(x, y);
                            PointF[] pnt = new PointF[1];
                            pnt[0] = p1;
                            Use temp = xml1.Clone() as Use;
                            temp.Transform.Matrix.TransformPoints(pnt);

                            LongLat templat = mapview.OffSetZero(-(int)(pnt[0].X * tlVectorControl1.ScaleRatio), -(int)(pnt[0].Y * tlVectorControl1.ScaleRatio));

                            string[] jd = templat.Longitude.ToString("####.####").Split('.');
                            int d1 = Convert.ToInt32(jd[0]);
                            string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.');
                            int f1 = Convert.ToInt32(df1[0]);
                            decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60;

                            string[] wd = templat.Latitude.ToString("####.####").Split('.');
                            int d2 = Convert.ToInt32(wd[0]);
                            string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.');
                            int f2 = Convert.ToInt32(df2[0]);
                            decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60;

                            string strjwd = "经纬度: " + d1.ToString() + "°" + f1.ToString() + "′" + m1.ToString("##.#") + "″," + d2.ToString() + "°" + f2.ToString() + "′" + m2.ToString("##.#") + "″";
                            object obj = null;
                            string deviceid = xml1.GetAttribute("Deviceid");
                            DeviceHelper.pspflag = false;
                            DeviceHelper.Wjghflag = true;
                            if (string.IsNullOrEmpty(deviceid)) {
                                //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                    obj = DeviceHelper.SelectDevice(DeviceType.DY, Itop.Client.MIS.ProgUID);
                                    if (obj == null) {
                                        tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                        tlVectorControl1.Delete();
                                    }
                                    if (obj is PSP_PowerSubstation_Info) {
                                        deviceid = ((PSP_PowerSubstation_Info)obj).UID;
                                        ((PSP_PowerSubstation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                                        Services.BaseService.Update<PSP_PowerSubstation_Info>(((PSP_PowerSubstation_Info)obj));
                                        xml1.SetAttribute("Deviceid", deviceid);
                                    }
                                    substation sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }
                                } else {
                                    obj = DeviceHelper.SelectDevice(DeviceType.BDZ, Itop.Client.MIS.ProgUID);
                                    if (obj == null) {
                                        tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                        tlVectorControl1.Delete();
                                    }
                                    if (obj is PSP_Substation_Info) {
                                        deviceid = ((PSP_Substation_Info)obj).UID;
                                        ((PSP_Substation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        ((PSP_Substation_Info)obj).EleID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                                        Services.BaseService.Update<PSP_Substation_Info>(((PSP_Substation_Info)obj));
                                        xml1.SetAttribute("Deviceid", deviceid);

                                    }
                                    substation sb = new substation();
                                    sb.UID = ((PSP_Substation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {

                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_Substation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_Substation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_Substation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }
                                }
                            }
                            if (!string.IsNullOrEmpty(deviceid)) {
                                if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                    obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid);
                                    if (obj != null) {
                                        xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title);
                                        //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                        DeviceHelper.ShowDeviceDlg(DeviceType.DY, deviceid, false);
                                    }

                                } else {
                                    obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                                    if (obj != null) {
                                        xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title);
                                        //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                        DeviceHelper.ShowDeviceDlg(DeviceType.BDZ, deviceid, false);
                                    }

                                }

                            }

                        }
                        if (xml1.GetAttribute("xlink:href").Contains("XL_GT_3") || xml1.GetAttribute("xlink:href").Contains("XL_GT_4")) {
                            frmInputNum num = new frmInputNum();
                            num.InputStr = xml1.GetAttribute("order");
                            num.ShowDialog();
                            xml1.SetAttribute("order", num.InputStrSEL);
                        }

                        //if (xml1.GetAttribute("xlink:href").Contains("kbs") || xml1.GetAttribute("xlink:href").Contains("hwg"))
                        //{
                        //    frmkbsProperty num = new frmkbsProperty();
                        //    num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        //    num.ShowDialog();
                        //}
                        //if (xml1.GetAttribute("xlink:href").Contains("fjx"))
                        //{
                        //    frmfjxProperty num = new frmfjxProperty();
                        //    num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        //    num.ShowDialog();
                        //}
                        //if (xml1.GetAttribute("xlink:href").Contains("byq"))
                        //{
                        //    frmbyqProperty num = new frmbyqProperty();
                        //    num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        //    num.ShowDialog();
                        //}
                        if (xml1.GetAttribute("xlink:href").Contains("SB_GT")) {
                            string lineWidth = "2";

                            string Code = xltProcessor.GetCurrentLineCode();
                            string _len = xltProcessor.GetWholeLineLength(Code).ToString("#####.####");

                            frmLineProperty fl = new frmLineProperty();
                            fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement;
                            fl.InitData(Code, tlVectorControl1.SVGDocument.SvgdataUid, _len, SvgDocument.currentLayer);
                            if (fl.ShowDialog() == DialogResult.OK) {
                                //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;"
                                lineWidth = fl.LineWidth;
                                string styleValue = "";
                                if (fl.Line.ObligateField1 == "规划") {
                                    styleValue = "stroke-dasharray:4 4;stroke-width:" + lineWidth + ";";
                                } else {
                                    styleValue = "stroke-width:" + lineWidth + ";";
                                }

                                styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("style");
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", styleValue);

                                xltProcessor.SetWholeLineAttribute(Code, "style", styleValue);
                            }
                        }
                    }
                    #endregion
                }
                if (e.ClickedItem.Text == "移动") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    XmlElement xmln = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    frmMove fm = new frmMove();
                    PointF pf11 = ((Use)xmln).CenterPoint;
                    LongLat temp = mapview.ParseToLongLat((int)pf11.X, (int)pf11.Y);
                    string[] jd = temp.Longitude.ToString("####.####").Split('.');
                    int d1 = Convert.ToInt32(jd[0]);
                    string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.');
                    int f1 = Convert.ToInt32(df1[0]);
                    decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60;

                    string[] wd = temp.Latitude.ToString("####.####").Split('.');
                    int d2 = Convert.ToInt32(wd[0]);
                    string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.');
                    int f2 = Convert.ToInt32(df2[0]);
                    decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60;
                    strj1 = d1.ToString();
                    strw1 = f1.ToString();
                    strd1 = m1.ToString();
                    strj2 = d2.ToString();
                    strw2 = f2.ToString();
                    strd2 = m2.ToString();
                    fm.Init(strj1, strw1, strd1, strj2, strw2, strd2);
                    if (fm.ShowDialog() == DialogResult.OK) {
                        string strValue = fm.StrValue;
                        string[] str = strValue.Split(',');
                        string[] JWD1 = str[0].Split(' ');
                        decimal J1 = Convert.ToDecimal(JWD1[0]);
                        decimal W1 = Convert.ToDecimal(JWD1[1]);
                        decimal D1 = Convert.ToDecimal(JWD1[2]);
                        string[] JWD2 = str[1].Split(' ');
                        decimal J2 = Convert.ToDecimal(JWD2[0]);
                        decimal W2 = Convert.ToDecimal(JWD2[1]);
                        decimal D2 = Convert.ToDecimal(JWD2[2]);

                        decimal JD = J1 + W1 / 60 + D1 / 3600;
                        decimal WD = J2 + W2 / 60 + D2 / 3600;

                        PointF pf1 = mapview.ParseToPoint(JD, WD);

                        PointF p1 = ((Use)xmln).CenterPoint;

                        SvgElement e1 = xmln as SvgElement;
                        Matrix matrix2 = ((IGraph)e1).GraphTransform.Matrix.Clone();
                        Matrix matrix3 = tlVectorControl1.DrawArea.CoordTransform.Clone();
                        matrix3.Invert();
                        matrix2.Multiply(matrix3, MatrixOrder.Append);
                        matrix2.Invert();
                        PointF[] pfArray1 = new PointF[] { new PointF(pf1.X / tlVectorControl1.ScaleRatio, pf1.Y / tlVectorControl1.ScaleRatio), p1 };
                        matrix2.TransformPoints(pfArray1);

                        float single1 = pfArray1[0].X - pfArray1[1].X;
                        float single2 = pfArray1[0].Y - pfArray1[1].Y;

                        Matrix matrix6 = ((IGraph)e1).Transform.Matrix.Clone();
                        if (e1.SvgAttributes.ContainsKey("transform")) {
                            Matrix matrix7 = ((Matrix)e1.SvgAttributes["transform"]).Clone();
                            matrix7.Invert();
                            matrix6.Multiply(matrix7, MatrixOrder.Append);
                        }
                        Matrix matrix5 = new Matrix();
                        matrix5.Translate(single1, single2);
                        Matrix matrix8 = ((IGraph)e1).Transform.Matrix.Clone();
                        matrix8.Multiply(matrix5);
                        matrix6.Invert();
                        matrix6.Multiply(matrix8, MatrixOrder.Append);
                        Transf tf = new Transf();
                        tf.setMatrix(matrix6);
                        (xmln as Use).Transform = tf;

                    }
                }
                if (e.ClickedItem.Text == "接线图") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    ParentUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    Save();
                    ParentUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    SVGFILE svg_temp = new SVGFILE();
                    //XmlElement xml1 = ((XmlElement)(e.Elements[0]));xml1.GetAttribute("id");
                    svg_temp.SUID = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("id");
                    svg_temp.FILENAME = getBdzName(svg_temp.SUID);// ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("info-name");
                    string strWhere = string.Format("suid='{0}' or filename='{1}' ", svg_temp.SUID, svg_temp.FILENAME);
                    IList svglist = Services.BaseService.GetList("SelectSVGFILEByWhere", strWhere);
                    OpenJXT(svglist, svg_temp);
                    //frmlar.SymbolDoc = tlVectorControl1.SVGDocument;
                    //frmlar.Progtype = MapType;
                    //frmlar.InitData();
                    //JxtBar();
                }
                if (e.ClickedItem.Text == "打开") {
                    if (tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRelating UseRel = new UseRelating();
                    UseRel.UseID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                    IList<UseRelating> UseRelList = Services.BaseService.GetList<UseRelating>("SelectUseRelatingByUseID", UseRel);
                    if (UseRelList.Count < 1) {
                        MessageBox.Show("选择的地块还没有关联到其他地图,请先设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRel = UseRelList[0];
                    SVGFILE svgFile = new SVGFILE();
                    svgFile.SUID = UseRel.LinkUID;
                    IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile);
                    if (svgList.Count < 1) {
                        MessageBox.Show("被关联的地图已经被删除,请重新设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    svgFile = (SVGFILE)svgList[0];
                    //SvgDocument doc = new SvgDocument();

                    if (!string.IsNullOrEmpty(svgFile.SVGDATA)) {
                        //doc.LoadXml(svgFile.SVGDATA);
                        ctlfile_OnOpenSvgDocument(sender, svgFile.SUID);
                    }

                }
                if (e.ClickedItem.Text == "区域打印") {
                    PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                    frmPrinter dlg = new frmPrinter();
                    dlg.printHelper = ph;
                    dlg.ShowDialog();
                    return;
                    ArrayList idlist = new ArrayList();
                    ArrayList symlist = new ArrayList();

                    SvgDocument _doc = new SvgDocument();

                    Graph poly1 = tlVectorControl1.SVGDocument.CurrentElement as Graph;
                    if (poly1 == null || poly1.GetAttribute("id") == "svg") {
                        return;
                    }

                    GraphicsPath gr1 = new GraphicsPath();
                    //gr1.AddRectangle(TLMath.getRectangle(poly1));
                    gr1.AddPolygon(TLMath.getPolygonPoints(poly1));
                    //gr1.CloseFigure();
                    gr1 = (GraphicsPath)poly1.GPath.Clone();
                    gr1.Transform((poly1 as IGraph).Transform.Matrix);

                    RectangleF ef1 = gr1.GetBounds();
                    ef1 = PathFunc.GetBounds(gr1);
                    StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">");

                    XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("defs");
                    if (nlist.Count > 0) {
                        XmlNode node = nlist[0];
                        svgtxt.AppendLine(node.OuterXml);
                    }
                    SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator();
                    while (enumerator1.MoveNext()) {
                        IGraph graph1 = (IGraph)enumerator1.Current;

                        GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                        //path1.Transform(graph1.GraphTransform.Matrix);
                        //path1.Transform(graph1.Transform.Matrix);
                        // RectangleF ef2 = path1.GetBounds();// PathFunc.GetBounds(path1);

                        //for (int n = 0; n < selCol.Count - 1; n++)
                        //{
                        //    //_doc.AppendChild((XmlNode)selCol[n]);
                        //    svgtxt = svgtxt + ((XmlElement)selCol[n]).OuterXml + "\r\n";
                        //}
                        if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue;

                        GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone();
                        path2.Transform(graph1.Transform.Matrix);
                        RectangleF ef2 = PathFunc.GetBounds(path2);

                        if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty) {

                            SvgElement ele = (SvgElement)graph1;
                            svgtxt.AppendLine(ele.OuterXml);
                            //tlVectorControl1.SVGDocument.AddSelectElement(graph1);
                            if (graph1 is Use) {
                                //PointF offset = TLMath.getUseOffset(((XmlElement)graph1).GetAttribute("xlink:href"));
                                //if (ef1.Contains(new PointF(((Use)graph1).X + offset.X, ((Use)graph1).Y + offset.Y))) {
                                //SvgElement ele = (SvgElement)graph1;
                                //svgtxt.AppendLine(ele.OuterXml);

                                string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                                if (!symlist.Contains(symid)) {
                                    symlist.Add(symid);
                                }
                                //}
                            }
                            if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") {
                                string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                                if (IsLead != "") {
                                    if (ef1.Contains(ef2)) {
                                        idlist.Add(graph1.ID);
                                    }
                                }
                            }
                        }
                    }
                    symlist = ResetList(symlist);
                    svgtxt.AppendLine("</svg>");
                    _doc.LoadXml(svgtxt.ToString());
                    _doc.SvgdataUid = tlVectorControl1.SVGDocument.SvgdataUid;
                    frmPrintF pri = new frmPrintF();
                    pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid);
                    if (pri.ShowDialog() == DialogResult.OK) {
                        frmSubPrint s = new frmSubPrint();
                        s.Vector = tlVectorControl1;
                        s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist);
                        s.Open(_doc, ef1);
                        s.Show();
                    }
                }
                if (e.ClickedItem.Text == "分类统计报表") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    IGraph poly1 = (IGraph)tlVectorControl1.SVGDocument.CurrentElement;
                    frmPloyPrint p = new frmPloyPrint();

                    p.InitDate(poly1.ID, tlVectorControl1.SVGDocument.SvgdataUid);
                    p.ShowDialog();
                }
                if (e.ClickedItem.Text == "保存图片") {
                    if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") {

                        PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                        frmImgManager frm = new frmImgManager();
                        frm.Pic = ph.getImage();
                        frm.ShowDialog();
                    }
                }

            } catch (Exception e1) {
                //MessageBox.Show(e1.Message);
            }
            if (e.ClickedItem.Text == "三维变电站") {
                try {
                    string strid = tlVectorControl1.SVGDocument.CurrentElement.ID;
                    substation s = new substation();
                    s.EleID = strid;
                    s.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    s = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", s);
                    ProcessStartInfo p = new ProcessStartInfo();
                    p.FileName = Application.StartupPath + "\\" + s.EleName + "\\bdz.exe";
                    p.WorkingDirectory = Application.StartupPath + "\\" + s.EleName;
                    Process.Start(p);
                } catch (Exception e1) { }
            }
            if (e.ClickedItem.Text == "清除关联") {
                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("Deviceid");
            }
            if (e.ClickedItem.Text == "更新关联变电站") {
                UpdateLine();
            }
            if (e.ClickedItem.Text == "删除") {
                Delete();
            }
        }
Example #4
0
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (e.ClickedItem.Text == "短路计算")
            {

            }

            if (e.ClickedItem.Text == "区域打印")
            {
                PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                frmPrinter dlg = new frmPrinter();
                dlg.printHelper = ph;
                dlg.ShowDialog();
                return;
                ArrayList idlist = new ArrayList();
                ArrayList symlist = new ArrayList();

                SvgDocument _doc = new SvgDocument();

                Graph poly1 = tlVectorControl1.SVGDocument.CurrentElement as Graph;
                if (poly1 == null || poly1.GetAttribute("id") == "svg")
                {
                    return;
                }

                GraphicsPath gr1 = new GraphicsPath();
                gr1.AddPolygon(TLMath.getPolygonPoints(poly1));
                gr1 = (GraphicsPath)poly1.GPath.Clone();
                gr1.Transform((poly1 as IGraph).Transform.Matrix);

                RectangleF ef1 = gr1.GetBounds();
                ef1 = PathFunc.GetBounds(gr1);
                StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">");

                XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("defs");
                if (nlist.Count > 0)
                {
                    XmlNode node = nlist[0];
                    svgtxt.AppendLine(node.OuterXml);
                }
                SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator();
                while (enumerator1.MoveNext())
                {
                    IGraph graph1 = (IGraph)enumerator1.Current;

                    GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                    if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue;

                    GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone();
                    path2.Transform(graph1.Transform.Matrix);
                    RectangleF ef2 = PathFunc.GetBounds(path2);

                    if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty)
                    {
                        SvgElement ele = (SvgElement)graph1;
                        svgtxt.AppendLine(ele.OuterXml);
                        if (graph1 is Use)
                        {
                            string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                            if (!symlist.Contains(symid))
                            {
                                symlist.Add(symid);
                            }
                        }
                        if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline")
                        {
                            string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                            if (IsLead != "")
                            {
                                if (ef1.Contains(ef2))
                                {
                                    idlist.Add(graph1.ID);
                                }
                            }
                        }
                    }

                }
                //symlist = ResetList(symlist);
                svgtxt.AppendLine("</svg>");
                _doc.LoadXml(svgtxt.ToString());
                _doc.SvgdataUid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                frmPrintF pri = new frmPrintF();
                pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                if (pri.ShowDialog() == DialogResult.OK)
                {
                    frmSubPrint s = new frmSubPrint();
                    s.Vector = tlVectorControl1;
                    s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist);
                    s.Open(_doc, ef1);
                    s.Show();
                }
            }

            if (e.ClickedItem.Text == "属性")
            {
                //if (!Check())
                //{
                //    return;
                //}
                XmlElement element = tlVectorControl1.SVGDocument.CurrentElement;
                if (element is Use)
                {
                    if (element.GetAttribute("xlink:href").Contains("Substation") || element.GetAttribute("xlink:href").Contains("motherlinenode"))
                    {

                        string str_power = getPower(element.GetAttribute("xlink:href"));

                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmSubstation dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmSubstation(pspDev);

                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = -1;
                            pspDev.Type = "Use";
                            if (element.GetAttribute("xlink:href").Contains("Substation"))
                            {
                                pspDev.Lable = "变电站";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("motherlinenode"))
                            {
                                pspDev.Lable = "母线节点";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("Power"))
                            {
                                pspDev.Lable = "电厂";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmSubstation(pspDev);
                        }
                        dlg.Str_Power = str_power;

                        dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year");

                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "Use";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                                (text as Text).SetAttribute("print", dlg.IsTJ ? "no" : "yes");
                            }
                            pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);
                            pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);
                            element.SetAttribute("print", dlg.IsTJ ? "no" : "yes");

                            pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            pspDev.OutQ = Convert.ToDouble(dlg.OutQ); ;
                            //if (pspDev.InPutP==0)
                            pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);

                            if (dlg.NodeType == "是")
                            {
                                pspDev.NodeType = "0";
                            }
                            else
                            {
                                pspDev.NodeType = "1";
                            }
                            Services.BaseService.Update<PSPDEV>(pspDev);
                            tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg.TYear);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("Power"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmSubstation dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmSubstation(pspDev);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = -1;
                            pspDev.Type = "Use";
                            if (element.GetAttribute("xlink:href").Contains("Substation"))
                            {
                                pspDev.Lable = "变电站";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("motherlinenode"))
                            {
                                pspDev.Lable = "母线节点";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("Power"))
                            {
                                pspDev.Lable = "电厂";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmSubstation(pspDev);
                            dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year");
                        }

                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "Use";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);
                            pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);

                            if (dlg.NodeType == "是")
                            {
                                pspDev.NodeType = "0";
                            }
                            else
                            {
                                pspDev.NodeType = "2";
                            }
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("dynamotorline"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmFadejie dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "dynamotorline";
                            if (element.GetAttribute("xlink:href").Contains("dynamotorline"))
                            {
                                pspDev.Lable = "发电厂支路";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("gndline"))
                            {
                                pspDev.Lable = "接地支路";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "dynamotorline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            pspDev.HuganLine3 = dlg.SwitchStatus;
                            if (dlg.OutP != "")
                                pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            if (dlg.OutQ != "")
                                pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            if (dlg.VoltV != "")
                                pspDev.VoltV = Convert.ToDouble(dlg.VoltV);
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                            if (dlg.NegativeTQ != "")
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("gndline"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmFadejie dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "gndline";
                            if (element.GetAttribute("xlink:href").Contains("dynamotorline"))
                            {
                                pspDev.Lable = "发电厂支路";
                            }
                            else if (element.GetAttribute("xlink:href").Contains("gndline"))
                            {
                                pspDev.Lable = "接地支路";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmFadejie(pspDev, pspDev.SvgUID);
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "gndline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            pspDev.HuganLine3 = dlg.SwitchStatus;
                            if (dlg.OutP != "")
                                pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            if (dlg.OutQ != "")
                                pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            if (dlg.VoltV != "")
                                pspDev.VoltV = Convert.ToDouble(dlg.VoltV);
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                            if (dlg.NegativeTQ != "")
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("loadline"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmLoad dlg;
                        if (pspDev != null)
                        {
                            dlg = new frmLoad(pspDev);
                        }
                        else
                        {
                            pspDev = new PSPDEV();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = element.GetAttribute("id");
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "loadline";

                            pspDev.Lable = "负荷支路";

                            Services.BaseService.Create<PSPDEV>(pspDev);
                            dlg = new frmLoad(pspDev);
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "loadline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;

                            pspDev.HuganLine3 = dlg.LoadSwitchState;
                            if (dlg.InPutP != "")
                                pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            if (dlg.InPutQ != "")
                                pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("串联电容电抗器"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmCapacity dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmCapacity(pspDev, pspDev.SvgUID);
                            dlg.SetEnable(true);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "串联电容电抗器";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;

                            // pspDev.HuganLine2 = dlg.LastNodeName;
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("并联电容电抗器"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmCapacity dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmCapacity(pspDev, pspDev.SvgUID);
                            dlg.SetEnable(false);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "并联电容电抗器";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }
                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            //pspDev.HuganLine2 = dlg.LastNodeName;
                            if (dlg.PositiveTQ != "")
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("transformerthirdzu"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmThridTra dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmThridTra(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "transformerthirdzu";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.IName;
                            pspDev.HuganLine2 = dlg.JName;
                            pspDev.HuganLine3 = dlg.ISwitchState;
                            pspDev.HuganLine4 = dlg.JSwitchState;
                            pspDev.LineLevel = dlg.IType;
                            pspDev.LineType = dlg.JType;
                            pspDev.LineStatus = dlg.KType;
                            pspDev.KName = dlg.KName;
                            pspDev.KSwitchStatus = dlg.KSwitchState;
                            if (dlg.IK != "")
                            {
                                pspDev.K = Convert.ToDouble(dlg.KK);
                            }
                            if (dlg.JK != "")
                            {
                                pspDev.G = Convert.ToDouble(dlg.JK);
                            }
                            if (dlg.KK != "")
                            {
                                pspDev.BigP = Convert.ToDouble(dlg.KK);
                            }
                            if (dlg.IR != "")
                            {
                                pspDev.HuganTQ1 = Convert.ToDouble(dlg.IR);
                            }
                            if (dlg.JR != "")
                            {
                                pspDev.HuganTQ2 = Convert.ToDouble(dlg.JR);
                            }
                            if (dlg.KR != "")
                            {
                                pspDev.HuganTQ3 = Convert.ToDouble(dlg.KR);
                            }
                            if (dlg.ITQ != "")
                            {
                                pspDev.HuganTQ4 = Convert.ToDouble(dlg.ITQ);
                            }
                            if (dlg.JTQ != "")
                            {
                                pspDev.HuganTQ5 = Convert.ToDouble(dlg.JTQ);
                            }
                            if (dlg.KTQ != "")
                            {
                                pspDev.SmallTQ = Convert.ToDouble(dlg.KTQ);
                            }
                            if (dlg.ZeroTQ != "")
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ);

                            if (dlg.NeutralNodeTQ != "")
                                pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("transformertwozu"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmTwoTra dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmTwoTra(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "transformertwozu";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.FirstName;
                            pspDev.HuganLine2 = dlg.LastName;
                            pspDev.HuganLine3 = dlg.FirstSwitchState;
                            pspDev.HuganLine4 = dlg.LastSwitchState;
                            pspDev.LineLevel = dlg.FirstType;
                            pspDev.LineType = dlg.LastType;

                            if (dlg.PositiveR != "")
                            {
                                pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR);
                            }
                            if (dlg.PositiveTQ != "")
                            {
                                pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                            }

                            if (dlg.ZeroR != "")
                            {
                                pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR);
                            }

                            if (dlg.ZeroTQ != "")
                            {
                                pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ);
                            }

                            if (dlg.K != "")
                                pspDev.K = Convert.ToDouble(dlg.K);

                            if (dlg.NeutralNodeTQ != "")
                                pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ);
                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("1/2母联开关"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmMuLian dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmMuLian(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "1/2母联开关";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.FirstNodeName;
                            pspDev.HuganLine2 = dlg.LastNodeName;
                            pspDev.HuganLine3 = dlg.SwitchStatus;

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }
                    else if (element.GetAttribute("xlink:href").Contains("2/3母联开关"))
                    {
                        PSPDEV pspDev = new PSPDEV();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                        frmMuLian2 dlg;

                        if (pspDev != null)
                        {
                            dlg = new frmMuLian2(pspDev, pspDev.SvgUID);
                        }
                        else
                        {
                            return;
                        }
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.Name == null)
                            {
                                MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlg.Name;
                            pspName.Type = "2/3母联开关";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            pspDev.Name = dlg.Name;
                            XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']");
                            if (text != null)
                            {
                                (text as Text).InnerText = dlg.Name;
                            }

                            pspDev.HuganLine1 = dlg.INodeName;
                            pspDev.HuganLine2 = dlg.JNodeName;
                            pspDev.HuganLine3 = dlg.ILineName;
                            pspDev.HuganLine4 = dlg.JLineName;
                            pspDev.KName = dlg.ILoadName;
                            pspDev.KSwitchStatus = dlg.JLoadName;
                            pspDev.LineLevel = dlg.SwitchStatus1;
                            pspDev.LineType = dlg.SwitchStatus2;
                            pspDev.LineStatus = dlg.SwitchStatus3;

                            Services.BaseService.Update<PSPDEV>(pspDev);
                        }
                    }

                }
                else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType == true)
                {

                    PSPDEV pspDev = new PSPDEV();
                    pspDev.EleID = element.GetAttribute("id");
                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);

                    frmLinenew dlg2;
                    if (pspDev != null)
                    {
                        dlg2 = new frmLinenew(pspDev);
                        dlg2.derefucelineflag = Reducelineflag;
                    }
                    else
                    {
                        pspDev = new PSPDEV();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = -1;
                        pspDev.Type = "Polyline";
                        pspDev.Lable = "支路";
                        Services.BaseService.Create<PSPDEV>(pspDev);
                        dlg2 = new frmLinenew(pspDev);
                        dlg2.derefucelineflag = Reducelineflag;
                    }
                    dlg2.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year");
                    dlg2.linevalue = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("linevalue");   //获得线路投资
                    if (dlg2.ShowDialog() == DialogResult.OK)
                    {
                        if (dlg2.Name == null)
                        {
                            MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlg2.Name;
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspName.Type = "Polyline";
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        pspDev.Name = dlg2.Name;
                        pspDev.LineLength = Convert.ToDouble(dlg2.LineLength);
                        pspDev.LineR = Convert.ToDouble(dlg2.LineR);
                        pspDev.LineTQ = Convert.ToDouble(dlg2.LineTQ);
                        pspDev.LineGNDC = Convert.ToDouble(dlg2.LineGNDC);
                        pspDev.LineLevel = dlg2.LineLevel;
                        pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt);
                        pspDev.LineType = dlg2.LineType;
                        pspDev.LineStatus = dlg2.LineStatus;
                        WireCategory wirewire = new WireCategory();
                        wirewire.WireType = dlg2.LineType;
                        if (dlg2.linevalue != "")
                        {
                            pspDev.BigP = Convert.ToDouble(dlg2.linevalue);
                        }
                        if (dlg2.ReferenceVolt != "")
                        {
                            pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt);
                        }
                        WireCategory wirewire2 = new WireCategory();
                        wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire);
                        //if (pspDev.LineR == 0)
                        //    pspDev.LineR = Convert.ToDouble(dlg2.LineLength)*wirewire2.WireR ;
                        //if (pspDev.LineTQ == 0)
                        //    pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireTQ;
                        //if (pspDev.LineGNDC == 0)
                        //    pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireGNDC;
                        if (wirewire2 != null)
                            pspDev.LineChange = (double)wirewire2.WireChange;
                        string tempp = dlg2.LineLev;
                        int tel = tempp.Length;
                        if (tempp.Contains("kV") || tempp.Contains("KV") || tempp.Contains("kv") || tempp.Contains("Kv"))
                        {
                            tempp = tempp.Substring(0, tel - 2);
                        }
                        pspDev.VoltR = Convert.ToDouble(tempp);
                        tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg2.TYear);
                        tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("linevalue", dlg2.linevalue);   //获得线路投资

                        //switch (dlg2.LineType)
                        //{
                        //    case "2*LGJ-400":
                        //        {
                        //            if (pspDev.LineR==0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.04;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.303;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.9;
                        //            pspDev.LineChange = 1690;
                        //        } break;
                        //    case "2*LGJ-300":
                        //        {
                        //            if (pspDev.LineR == 0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.054;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.308;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.7;
                        //            pspDev.LineChange = 1400;
                        //        } break;
                        //    case "2*LGJ-240":
                        //        {
                        //            if (pspDev.LineR == 0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.066;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.310;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.5;
                        //            pspDev.LineChange = 1220;
                        //        } break;
                        //    case "LGJ-400":
                        //        {
                        //            if (pspDev.LineR == 0)
                        //            pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.08;
                        //            if (pspDev.LineTQ == 0)
                        //            pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.417;
                        //            if (pspDev.LineGNDC == 0)
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 13.2;
                        //            pspDev.LineChange = 845;
                        //        } break;

                        //}
                        Services.BaseService.Update<PSPDEV>(pspDev);
                        Topology2();
                    }
                }
                else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType != true)
                {

                    PSPDEV pspDev = new PSPDEV();
                    pspDev.EleID = element.GetAttribute("id");
                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);

                    frmLine dlg;
                    if (pspDev != null)
                    {
                        dlg = new frmLine(pspDev);
                    }
                    else
                    {
                        pspDev = new PSPDEV();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = element.GetAttribute("id");
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = -1;
                        pspDev.Type = "Polyline";
                        pspDev.Lable = "支路";
                        Services.BaseService.Create<PSPDEV>(pspDev);
                        dlg = new frmLine(pspDev);
                    }

                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        if (dlg.Name == null)
                        {
                            MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlg.Name;
                        pspName.Type = "Polyline";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID))
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        pspDev.Name = dlg.Name;
                        pspDev.LineLength = Convert.ToDouble(dlg.LineLength);
                        pspDev.LineLevel = dlg.LineLevel;
                        pspDev.LineType = dlg.LineType;
                        pspDev.LineStatus = dlg.LineStatus;
                        pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR);
                        pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ);
                        pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR);
                        pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ);
                        if (dlg.HuganFirst == "是")
                            pspDev.HuganFirst = 1;
                        else
                            pspDev.HuganFirst = 0;
                        pspDev.HuganLine1 = dlg.HuganLine1;
                        pspDev.HuganLine2 = dlg.HuganLine2;
                        pspDev.HuganLine3 = dlg.HuganLine3;
                        pspDev.HuganLine4 = dlg.HuganLine4;
                        pspDev.HuganTQ1 = Convert.ToDouble(dlg.HuganTQ1);
                        pspDev.HuganTQ2 = Convert.ToDouble(dlg.HuganTQ2);
                        pspDev.HuganTQ3 = Convert.ToDouble(dlg.HuganTQ3);
                        pspDev.HuganTQ4 = Convert.ToDouble(dlg.HuganTQ4);
                        pspDev.HuganTQ5 = Convert.ToDouble(dlg.HuganTQ5);
                        string tempp = dlg.LineLev;
                        int tel = tempp.Length;
                        if (tel == 1)
                            pspDev.VoltR = 0;
                        else
                        {
                            if (tempp.Contains("kV") || tempp.Contains("KV") || tempp.Contains("kv") || tempp.Contains("Kv"))
                            {
                                tempp = tempp.Substring(0, tel - 2);
                            }
                            pspDev.VoltR = Convert.ToDouble(tempp);
                        }
                        //switch (dlg.LineType)
                        //{
                        //    case "2*LGJ-400":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.04;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.303;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.9;
                        //            pspDev.LineChange = 1690;
                        //        } break;
                        //    case "2*LGJ-300":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.054;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.308;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.7;
                        //            pspDev.LineChange = 1400;
                        //        } break;
                        //    case "2*LGJ-240":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.066;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.310;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.5;
                        //            pspDev.LineChange = 1220;
                        //        } break;
                        //    case "LGJ-400":
                        //        {
                        //            pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.08;
                        //            pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.417;
                        //            pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 13.2;
                        //            pspDev.LineChange = 845;
                        //        } break;

                        //}
                        Services.BaseService.Update<PSPDEV>(pspDev);
                        Topology2();
                    }
                }
            }
            tlVectorControl1.Operation = ToolOperation.Select;
            //contextMenuStrip1.Hide();
        }
Example #5
0
        /*public void ResetPoly()
        {
            SvgElementCollection col= tlVectorControl1.SVGDocument.SelectCollection;
            if(col.Count<1){
                return;
            }
            SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();
            foreach(SvgElement ele in col){
                if (ele.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                {
                    glebeProperty p=new glebeProperty();
                    p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    p.EleID = ((IGraph)ele).ID;
                    p = Services.BaseService.GetObject("SelectglebePropertyByEleID", p);
                    if(p!=null){
                        PointF[] tfArray1 = TLMath.getPolygonPoints(ele);
                        GraphicsPath selectAreaPath = new GraphicsPath();
                        selectAreaPath.AddLines(tfArray1);
                        selectAreaPath.CloseFigure();
                        Region region1 = new Region(selectAreaPath);
                        while (enumerator1.MoveNext())
                        {
                            IGraph graph1 = (IGraph)enumerator1.Current;
                            GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                            path1.Transform(graph1.GraphTransform.Matrix);
                            Region region2 = new Region(path1);
                            region2.Intersect(region1);
                            if (!region2.GetBounds(Graphics.FromHwnd(IntPtr.Zero)).IsEmpty)
                            {
                                glebeProperty p1 = new glebeProperty();
                                p1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                p1.EleID = graph1.ID;
                                p1 = Services.BaseService.GetObject("SelectglebePropertyByEleID", p1);
                                if(p1!=null){
                                    p1.ParentEleID = p.UID;
                                    Services.BaseService.Update("UpdateglebePropertyAreaAll", p1);
                                }
                            }
                        }
                    }
                }
            }
            MessageBox.Show("更新完成。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }*/
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try {
                if (e.ClickedItem.Text == "属性") {
                    XmlElement xml1 = (XmlElement)tlVectorControl2.SVGDocument.CurrentElement;
                    //PointF[] pf = TLMath.getPolygonPoints(xml1);

                    //((Polygon)xml1).Transform.Matrix.TransformPoints(pf);
                    // 规划
                    if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl2.SVGDocument.getLayerList())) {

                        if (xml1 == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请先选择规划区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl2.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            XmlNodeList n1 = tlVectorControl2.SVGDocument.GetElementsByTagName("use");
                            PointF[] tfArray1 = TLMath.getPolygonPoints(xml1);
                            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 < n1.Count; i++) {
                                float OffX = 0f;
                                float OffY = 0f;
                                Use use = (Use)n1[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);
                            }

                            glebeProperty _gle = new glebeProperty();
                            _gle.EleID = tlVectorControl2.SVGDocument.CurrentElement.ID;
                            _gle.SvgUID = tlVectorControl2.SVGDocument.SvgdataUid;

                            IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle);
                            if (UseProList.Count > 0) {
                                _gle = UseProList[0];
                                _gle.LayerID = SvgDocument.currentLayer;
                                frmMainProperty f = new frmMainProperty();

                                f.InitData(_gle, str220, str110,str66);

                                f.ShowDialog();

                            }
                            //}
                        }

                    }
                    if (getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl2.SVGDocument.getLayerList())) {

                        if (tlVectorControl2.SVGDocument.getRZBRatio() != "") {
                            rzb = tlVectorControl2.SVGDocument.getRZBRatio();
                        }

                        if (xml1 == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请先选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl2.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            string IsArea = ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).GetAttribute("IsArea");
                            if (IsArea != "") {
                                frmProperty f = new frmProperty();

                                f.InitData(xml1.GetAttribute("id"), tlVectorControl2.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer);
                                //f.ShowDialog();
                                if (progtype != "城市规划层") {
                                    f.IsReadonly = true;
                                }
                                if (f.ShowDialog() == DialogResult.OK) {
                                    if (f.gPro.ObligateField1 != "") {
                                        string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(f.gPro.ObligateField1)));
                                        color1 = "fill:" + color1 + ";";
                                        ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).SetAttribute("style", color1);
                                        tlVectorControl2.UpdateProperty();
                                    }

                                }
                            }
                        }
                    }

                    if (tlVectorControl2.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl2.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                        string lineWidth = "2";
                        string IsLead = ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).GetAttribute("IsLead");
                        if (IsLead != "") {
                            frmLineProperty fl = new frmLineProperty();
                            fl.InitData(tlVectorControl2.SVGDocument.CurrentElement.GetAttribute("id"), tlVectorControl2.SVGDocument.SvgdataUid, LineLen, SvgDocument.currentLayer);
                            if (fl.ShowDialog() == DialogResult.OK) {
                                //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;"
                                lineWidth = fl.LineWidth;
                                string styleValue = "";
                                if (fl.Line.ObligateField1 == "规划") {
                                    styleValue = "stroke-dasharray:6 1;stroke-width:" + lineWidth + ";";
                                } else {
                                    styleValue = "stroke-width:" + lineWidth + ";";
                                }
                                //string aa= ColorTranslator.ToHtml(Color.Black);
                                styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                                ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).RemoveAttribute("style");
                                ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).SetAttribute("style", styleValue);
                                // tlVectorControl1.UpdateProperty();
                                // xml1.SetAttribute("style", styleValue);

                            }
                        }
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("Substation")) {
                        string lab = xml1.GetAttribute("xlink:href");
                        frmSubstationProperty frmSub = new frmSubstationProperty();
                        frmSub.InitData(xml1.GetAttribute("id"), tlVectorControl2.SVGDocument.SvgdataUid, SvgDocument.currentLayer, lab);
                        frmSub.ShowDialog();
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("SB_GT")) {
                        string lineWidth = "2";

                        string Code = xltProcessor.GetCurrentLineCode();
                        string _len = xltProcessor.GetWholeLineLength(Code).ToString("#####.####");

                        frmLineProperty fl = new frmLineProperty();
                        fl.InitData(Code, tlVectorControl2.SVGDocument.SvgdataUid, _len, SvgDocument.currentLayer);
                        if (fl.ShowDialog() == DialogResult.OK) {
                            //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;"
                            lineWidth = fl.LineWidth;
                            string styleValue = "";
                            if (fl.Line.ObligateField1 == "规划") {
                                styleValue = "stroke-dasharray:4 4;stroke-width:" + lineWidth + ";";
                            } else {
                                styleValue = "stroke-width:" + lineWidth + ";";
                            }

                            styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                            ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).RemoveAttribute("style");
                            ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).SetAttribute("style", styleValue);

                            xltProcessor.SetWholeLineAttribute(Code, "style", styleValue);
                        }
                    }

                }
                if (e.ClickedItem.Text == "移动") {
                    if (tlVectorControl2.SVGDocument.CurrentElement == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    XmlElement xmln = (XmlElement)tlVectorControl2.SVGDocument.CurrentElement;
                    frmMove fm = new frmMove();
                    if (fm.ShowDialog() == DialogResult.OK) {
                        string strValue = fm.StrValue;
                        string[] str = strValue.Split(',');
                        string[] JWD1 = str[0].Split(' ');
                        Double J1 = Convert.ToDouble(JWD1[0]);
                        Double W1 = Convert.ToDouble(JWD1[1]);
                        Double D1 = Convert.ToDouble(JWD1[2]);
                        string[] JWD2 = str[1].Split(' ');
                        Double J2 = Convert.ToDouble(JWD2[0]);
                        Double W2 = Convert.ToDouble(JWD2[1]);
                        Double D2 = Convert.ToDouble(JWD2[2]);

                        Double JD = J1 + W1 / 60 + D1 / 3600;
                        Double WD = J2 + W2 / 60 + D2 / 3600;
                        IntXY xy = mapview.getXY(JD, WD);
                        PointF OffPoint = TLMath.getUseOffset(xmln.GetAttribute("xlink:href"));

                        xmln.RemoveAttribute("transform");
                        //xmln.RemoveAttribute("x");
                        xmln.SetAttribute("x", ((Double)(-xy.X / (Double)tlVectorControl2.ScaleRatio) - (Double)OffPoint.X).ToString("#####.####"));
                        // xmln.RemoveAttribute("y");
                        xmln.SetAttribute("y", ((Double)(-xy.Y / (Double)tlVectorControl2.ScaleRatio) - (Double)OffPoint.Y).ToString("#####.####"));
                        tlVectorControl2.Refresh();
                    }
                }
                if (e.ClickedItem.Text == "接线图") {
                    if (tlVectorControl2.SVGDocument.CurrentElement == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    ParentUID = tlVectorControl2.SVGDocument.SvgdataUid;
                    Save();
                    ParentUID = tlVectorControl2.SVGDocument.SvgdataUid;
                    SVGFILE svg_temp = new SVGFILE();
                    svg_temp.SUID = ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).GetAttribute("id");
                    svg_temp.FILENAME = ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).GetAttribute("info-name");
                    IList svglist = Services.BaseService.GetList("SelectSVGFILEByKey", svg_temp);
                    OpenJXT(svglist, svg_temp);
                    //frmlar.SymbolDoc = tlVectorControl2.SVGDocument;
                    //frmlar.Progtype = MapType;
                    //frmlar.InitData();
                    //JxtBar();
                }
                if (e.ClickedItem.Text == "打开") {
                    if (tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") {
                        MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRelating UseRel = new UseRelating();
                    UseRel.UseID = tlVectorControl2.SVGDocument.CurrentElement.ID;
                    IList<UseRelating> UseRelList = Services.BaseService.GetList<UseRelating>("SelectUseRelatingByUseID", UseRel);
                    if (UseRelList.Count < 1) {
                        MessageBox.Show("选择的地块还没有关联到其他地图,请先设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRel = UseRelList[0];
                    SVGFILE svgFile = new SVGFILE();
                    svgFile.SUID = UseRel.LinkUID;
                    IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile);
                    if (svgList.Count < 1) {
                        MessageBox.Show("被关联的地图已经被删除,请重新设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    svgFile = (SVGFILE)svgList[0];
                    //SvgDocument doc = new SvgDocument();

                    if (!string.IsNullOrEmpty(svgFile.SVGDATA)) {
                        //doc.LoadXml(svgFile.SVGDATA);
                        ctlfile_OnOpenSvgDocument(sender, svgFile.SUID);
                    }

                }
                if (e.ClickedItem.Text == "区域打印") {
                    PrintHelper ph = new PrintHelper(tlVectorControl2, mapview);
                    frmPrinter dlg = new frmPrinter();
                    dlg.printHelper = ph;
                    dlg.ShowDialog();
                    return;
                    ArrayList idlist = new ArrayList();
                    ArrayList symlist = new ArrayList();

                    SvgDocument _doc = new SvgDocument();

                    Graph poly1 = tlVectorControl2.SVGDocument.CurrentElement as Graph;
                    if (poly1 == null || poly1.GetAttribute("id") == "svg") {
                        return;
                    }
                    GraphicsPath gr1 = new GraphicsPath();
                    gr1.AddPolygon(TLMath.getPolygonPoints(poly1));
                    //gr1.CloseFigure();
                    gr1 = (GraphicsPath)poly1.GPath.Clone();

                    gr1.Transform((poly1 as IGraph).Transform.Matrix);

                    RectangleF ef1 = gr1.GetBounds();
                    ef1 = PathFunc.GetBounds(gr1);
                    StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">");

                    XmlNodeList nlist = tlVectorControl2.SVGDocument.GetElementsByTagName("defs");
                    if (nlist.Count > 0) {
                        XmlNode node = nlist[0];
                        svgtxt.AppendLine(node.OuterXml);
                    }
                    SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl2.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator();
                    while (enumerator1.MoveNext()) {
                        IGraph graph1 = (IGraph)enumerator1.Current;

                        GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                        //path1.Transform(graph1.GraphTransform.Matrix);
                        //path1.Transform(graph1.Transform.Matrix);
                        // RectangleF ef2 = path1.GetBounds();// PathFunc.GetBounds(path1);

                        //for (int n = 0; n < selCol.Count - 1; n++)
                        //{
                        //    //_doc.AppendChild((XmlNode)selCol[n]);
                        //    svgtxt = svgtxt + ((XmlElement)selCol[n]).OuterXml + "\r\n";
                        //}
                        if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue;

                        GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone();
                        path2.Transform(graph1.Transform.Matrix);
                        RectangleF ef2 = PathFunc.GetBounds(path2);

                        if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty) {

                            SvgElement ele = (SvgElement)graph1;
                            svgtxt.AppendLine(ele.OuterXml);
                            //tlVectorControl1.SVGDocument.AddSelectElement(graph1);
                            if (graph1 is Use) {
                                //PointF offset = TLMath.getUseOffset(((XmlElement)graph1).GetAttribute("xlink:href"));
                                //if (ef1.Contains(new PointF(((Use)graph1).X + offset.X, ((Use)graph1).Y + offset.Y))) {
                                    //SvgElement ele = (SvgElement)graph1;
                                    //svgtxt.AppendLine(ele.OuterXml);

                                    string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                                    if (!symlist.Contains(symid)) {
                                        symlist.Add(symid);
                                    }
                                //}
                            }
                            if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") {
                                string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                                if (IsLead != "") {
                                    if (ef1.Contains(ef2)) {
                                        idlist.Add(graph1.ID);
                                    }
                                }
                            }

                        }
                        //if (ef1.Contains(ef2)|| RectangleF.Intersect(ef1,ef2) !=RectangleF.Empty )
                        //{
                        //    SvgElement ele = (SvgElement)graph1;
                        //    svgtxt.AppendLine(ele.OuterXml);
                        //    //tlVectorControl1.SVGDocument.AddSelectElement(graph1);
                        //    if (graph1 is Use ) {
                        //        PointF offset = TLMath.getUseOffset(((XmlElement)graph1).GetAttribute("xlink:href"));
                        //        if (ef1.Contains(new PointF(((Use)graph1).X + offset.X, ((Use)graph1).Y + offset.Y))) {
                        //            //SvgElement ele = (SvgElement)graph1;
                        //            //svgtxt.AppendLine(ele.OuterXml);

                        //            string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                        //            if (!symlist.Contains(symid)) {
                        //                symlist.Add(symid);
                        //            }
                        //        }
                        //    }
                        //    if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") {
                        //        string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                        //        if (IsLead != "") {
                        //            if (ef1.Contains(ef2)) {
                        //                idlist.Add(graph1.ID);
                        //            }
                        //        }
                        //    }
                        //}

                    }
                    symlist = ResetList(symlist);
                    svgtxt.AppendLine("</svg>");
                    _doc.LoadXml(svgtxt.ToString());
                    _doc.SvgdataUid = tlVectorControl2.SVGDocument.SvgdataUid;
                    frmPrintF pri = new frmPrintF();
                    pri.Init(tlVectorControl2.SVGDocument.CurrentElement.ID, tlVectorControl2.SVGDocument.SvgdataUid);
                    if (pri.ShowDialog() == DialogResult.OK) {
                        frmSubPrint s = new frmSubPrint();
                        s.Vector = tlVectorControl2;
                        s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist);
                        s.Open(_doc, ef1);
                        s.Show();
                    }
                }
                if (e.ClickedItem.Text == "分类统计报表") {
                    if (tlVectorControl2.SVGDocument.CurrentElement == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    IGraph poly1 = (IGraph)tlVectorControl2.SVGDocument.CurrentElement;
                    frmPloyPrint p = new frmPloyPrint();

                    p.InitDate(poly1.ID, tlVectorControl2.SVGDocument.SvgdataUid);
                    p.ShowDialog();
                }
            } catch (Exception e1) {
                MessageBox.Show(e1.Message);
            }
        }