Example #1
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 #2
0
        void tlVectorControl1_LeftClick(object sender, SvgElementSelectedEventArgs e)
        {
            if (tlVectorControl1.Operation == ToolOperation.Text)
            {
                frmTextInput ft = new frmTextInput();
                if (ft.ShowDialog() == DialogResult.OK)
                {
                    string txt = ft.Content;
                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                    System.Drawing.Point point1 = tlVectorControl1.PointToView(new System.Drawing.Point(e.Mouse.X, e.Mouse.Y));
                    n1.SetAttribute("x", point1.X.ToString());
                    n1.SetAttribute("y", point1.Y.ToString());
                    n1.InnerText = txt;
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                    tlVectorControl1.Operation = ToolOperation.Select;
                }
            }
            else if (tlVectorControl1.Operation == ToolOperation.Symbol)
            {
                XmlElement temp = e.SvgElement as XmlElement;

                if (temp is Use && (temp.GetAttribute("xlink:href").Contains("Substation") || temp.GetAttribute("xlink:href").Contains("Power") || temp.GetAttribute("xlink:href").Contains("motherlinenode")))
                {
                    PSPDEV pspDev23 = new PSPDEV();
                    //pspDev.EleID = element.GetAttribute("id");
                    pspDev23.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (temp.GetAttribute("xlink:href").Contains("Substation"))
                    {
                        pspDev23.Lable = "变电站";
                    }
                    else if (temp.GetAttribute("xlink:href").Contains("motherlinenode"))
                    {
                        pspDev23.Lable = "母线节点";
                    }
                    else if (temp.GetAttribute("xlink:href").Contains("Power"))
                    {
                        pspDev23.Lable = "电厂";
                    }
                    frmSubstation dlg = new frmSubstation(pspDev23);
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {

                        //XmlElement temp = tlVectorControl1.SVGDocument.CurrentElement;
                        if (temp != null)
                        {
                            PSPDEV pspDev2 = new PSPDEV();
                            XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                            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 >= 1)
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }
                            if (true)
                            {

                                XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                if (temp is Polyline)
                                {
                                    double x1 = Convert.ToDouble(temp.GetAttribute("x1"));
                                    double y1 = Convert.ToDouble(temp.GetAttribute("y1"));
                                    double x2 = Convert.ToDouble(temp.GetAttribute("x2"));
                                    double y2 = Convert.ToDouble(temp.GetAttribute("y2"));

                                    tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                    n1.SetAttribute("x", Convert.ToString(x1 + (x2 - x1) / 2));
                                    n1.SetAttribute("y", Convert.ToString(y1 + (y2 - y1) / 2));

                                }
                                else
                                {
                                    n1.SetAttribute("x", temp.GetAttribute("x"));
                                    n1.SetAttribute("y", temp.GetAttribute("y"));
                                    RectangleF t = ((IGraph)temp).GetBounds();
                                    n1.SetAttribute("x", t.X.ToString());
                                    n1.SetAttribute("y", t.Y.ToString());
                                }

                                n1.InnerText = dlg.Name;
                                n1.SetAttribute("layer", SvgDocument.currentLayer);
                                n1.SetAttribute("ParentID", temp.GetAttribute("id"));
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                tlVectorControl1.Operation = ToolOperation.Select;
                            }
                            else
                            {
                                XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                if (temp is Polyline)
                                {
                                    double x1 = Convert.ToDouble(temp.GetAttribute("x1"));
                                    double y1 = Convert.ToDouble(temp.GetAttribute("y1"));
                                    double x2 = Convert.ToDouble(temp.GetAttribute("x2"));
                                    double y2 = Convert.ToDouble(temp.GetAttribute("y2"));

                                    tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                    n1.SetAttribute("x", Convert.ToString(x1 + (x2 - x1) / 2));
                                    n1.SetAttribute("y", Convert.ToString(y1 + (y2 - y1) / 2));
                                }
                                else
                                {
                                    RectangleF t = ((IGraph)temp).GetBounds();
                                    n1.SetAttribute("x", (t.X - 8).ToString());
                                    n1.SetAttribute("y", (t.Y - 8).ToString());
                                }

                                n1.InnerText = dlg.Name;
                                n1.SetAttribute("layer", SvgDocument.currentLayer);
                                n1.SetAttribute("ParentID", temp.GetAttribute("id"));
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                tlVectorControl1.Operation = ToolOperation.Select;

                            }
                            PSPDEV pspDev = new PSPDEV();
                            if (temp is Use)
                            {
                                RectangleF t = ((IGraph)temp).GetBounds();
                                pspDev.SUID = Guid.NewGuid().ToString();
                                pspDev.EleID = temp.GetAttribute("id");
                                pspDev.Name = dlg.Name;
                                pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                pspDev.X1 = t.X;
                                pspDev.Y1 = t.Y;
                                pspDev.Number = -1;
                                pspDev.FirstNode = -1;
                                pspDev.LastNode = -1;
                                pspDev.Type = "Use";
                                if (temp.GetAttribute("xlink:href").Contains("Substation"))
                                {
                                    pspDev.Lable = "变电站";
                                }
                                else if (temp.GetAttribute("xlink:href").Contains("motherlinenode"))
                                {
                                    pspDev.Lable = "母线节点";
                                }
                                else if (temp.GetAttribute("xlink:href").Contains("Power"))
                                {
                                    pspDev.Lable = "电厂";
                                }
                                if (dlg.VoltR != "")
                                    pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                                if (dlg.Burthen != "")
                                    pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);

                                //if (dlg.InPutP!="")
                                //    pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                                //if (dlg.InPutQ!="")
                                //    pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                                if (dlg.InPutP != "")
                                    pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                                if (dlg.InPutQ != "")
                                    pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                                if (dlg.OutP != "")
                                    pspDev.OutP = Convert.ToDouble(dlg.OutP);
                                if (dlg.OutQ != "")
                                    pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                                if (dlg.NodeType == "是")
                                {
                                    pspDev.NodeType = "0";
                                }
                                else
                                {
                                    pspDev.NodeType = "1";
                                }
                                Services.BaseService.Create<PSPDEV>(pspDev);
                            }
                            else if (temp is Polyline)
                            {
                                pspDev.SUID = Guid.NewGuid().ToString();
                                pspDev.EleID = temp.GetAttribute("id");
                                pspDev.Name = dlg.Name;
                                pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                pspDev.X1 = Convert.ToDouble(temp.GetAttribute("x1"));
                                pspDev.Y1 = Convert.ToDouble(temp.GetAttribute("y1"));
                                pspDev.X2 = Convert.ToDouble(temp.GetAttribute("x2"));
                                pspDev.Y2 = Convert.ToDouble(temp.GetAttribute("y2"));
                                pspDev.Number = -1;
                                pspDev.FirstNode = -1;
                                pspDev.LastNode = -1;
                                pspDev.Type = "Polyline";
                                Services.BaseService.Create<PSPDEV>(pspDev);
                            }
                        }

                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else
                {
                    if (temp is Use && (temp.GetAttribute("xlink:href").Contains("dynamotorline")))//接地支路
                    {
                        frmFadejie dlg = new frmFadejie(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        dlg.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        if (dlg.ShowDialog(this) == DialogResult.OK)
                        {

                            //XmlElement temp = tlVectorControl1.SVGDocument.CurrentElement;
                            if (temp != null)
                            {
                                PSPDEV pspDev2 = new PSPDEV();
                                XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                                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 >= 1)
                                {
                                    MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    tlVectorControl1.Delete();
                                    return;
                                }
                                if (true)
                                {
                                    tlVectorControl1.Operation = ToolOperation.Select;
                                    PSPDEV pspDev = new PSPDEV();
                                    tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                    RectangleF t = ((IGraph)temp).GetBounds();
                                    pspDev.SUID = Guid.NewGuid().ToString();
                                    pspDev.EleID = temp.GetAttribute("id");
                                    pspDev.Name = dlg.Name;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    pspDev.X1 = t.X;
                                    pspDev.Y1 = t.Y;
                                    pspDev.Number = -1;
                                    pspDev.FirstNode = -1;
                                    pspDev.LastNode = 0;
                                    pspDev.Type = "dynamotorline";
                                    if (temp.GetAttribute("xlink:href").Contains("dynamotorline"))
                                    {
                                        pspDev.Lable = "发电厂支路";
                                    }
                                    else if (temp.GetAttribute("xlink:href").Contains("gndline"))
                                    {
                                        pspDev.Lable = "接地支路";
                                    }

                                    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.Create<PSPDEV>(pspDev);
                                }
                            }
                        }
                        else
                        {
                            tlVectorControl1.Delete();
                        }
                    }
                    else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("gndline")))//接地支路
                    {
                        frmFadejie dlg = new frmFadejie(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        dlg.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        if (dlg.ShowDialog(this) == DialogResult.OK)
                        {

                            //XmlElement temp = tlVectorControl1.SVGDocument.CurrentElement;
                            if (temp != null)
                            {
                                PSPDEV pspDev2 = new PSPDEV();
                                XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                                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 >= 1)
                                {
                                    MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    tlVectorControl1.Delete();
                                    return;
                                }
                                if (true)
                                {
                                    tlVectorControl1.Operation = ToolOperation.Select;
                                    PSPDEV pspDev = new PSPDEV();
                                    tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                    RectangleF t = ((IGraph)temp).GetBounds();
                                    pspDev.SUID = Guid.NewGuid().ToString();
                                    pspDev.EleID = temp.GetAttribute("id");
                                    pspDev.Name = dlg.Name;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    pspDev.X1 = t.X;
                                    pspDev.Y1 = t.Y;
                                    pspDev.Number = -1;
                                    pspDev.FirstNode = -1;
                                    pspDev.LastNode = 0;
                                    pspDev.Type = "gndline";
                                    if (temp.GetAttribute("xlink:href").Contains("dynamotorline"))
                                    {
                                        pspDev.Lable = "发电厂支路";
                                    }
                                    else if (temp.GetAttribute("xlink:href").Contains("gndline"))
                                    {
                                        pspDev.Lable = "接地支路";
                                    }

                                    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.Create<PSPDEV>(pspDev);
                                }
                            }
                        }
                        else
                        {
                            tlVectorControl1.Delete();
                        }
                    }
                    else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("loadline")))
                    {
                        frmLoad dlgLoad = new frmLoad();
                        dlgLoad.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        if (dlgLoad.ShowDialog(this) == DialogResult.OK)
                        {
                            if (temp != null)
                            {
                                PSPDEV pspDev2 = new PSPDEV();
                                XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                                PSPDEV pspName = new PSPDEV();
                                pspName.Name = dlgLoad.Name;
                                pspName.Type = "loadline";
                                pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                                if (listName.Count >= 1)
                                {
                                    MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    tlVectorControl1.Delete();
                                    return;
                                }

                                tlVectorControl1.Operation = ToolOperation.Select;
                                PSPDEV pspDev = new PSPDEV();
                                tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                RectangleF t = ((IGraph)temp).GetBounds();
                                pspDev.SUID = Guid.NewGuid().ToString();
                                pspDev.EleID = temp.GetAttribute("id");
                                pspDev.Name = dlgLoad.Name;
                                pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                pspDev.X1 = t.X;
                                pspDev.Y1 = t.Y;
                                pspDev.Number = -1;
                                pspDev.FirstNode = -1;
                                pspDev.LastNode = 0;
                                pspDev.Type = "loadline";

                                pspDev.Lable = "负荷支路";

                                pspDev.HuganLine1 = dlgLoad.FirstNodeName;
                                if (dlgLoad.InPutP != "")
                                {
                                    pspDev.InPutP = Convert.ToDouble(dlgLoad.InPutP);
                                }
                                if (dlgLoad.InPutQ != "")
                                {
                                    pspDev.InPutQ = Convert.ToDouble(dlgLoad.InPutQ);
                                }
                                if (dlgLoad.VoltR != "")
                                {
                                    pspDev.VoltR = Convert.ToDouble(dlgLoad.VoltR);
                                }

                                pspDev.HuganLine3 = dlgLoad.LoadSwitchState;

                                Services.BaseService.Create<PSPDEV>(pspDev);
                            }
                        }
                        else
                        {
                            tlVectorControl1.Delete();
                        }
                    }
                    else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("transformertwozu")))
                    {
                        frmTwoTra dlgTra = new frmTwoTra(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        dlgTra.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        if (dlgTra.ShowDialog(this) == DialogResult.OK)
                        {
                            PSPDEV pspDev2 = new PSPDEV();
                            XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlgTra.Name;
                            pspName.Type = "transformertwozu";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 1)
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }

                            tlVectorControl1.Operation = ToolOperation.Select;
                            PSPDEV pspDev = new PSPDEV();
                            tlVectorControl1.ChangeLevel(LevelType.Bottom);
                            RectangleF t = ((IGraph)temp).GetBounds();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = temp.GetAttribute("id");
                            pspDev.Name = dlgTra.Name;
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.X1 = t.X;
                            pspDev.Y1 = t.Y;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "transformertwozu";

                            pspDev.Lable = "二绕组变压器";
                            pspDev.HuganLine1 = dlgTra.FirstName;
                            pspDev.HuganLine2 = dlgTra.LastName;
                            pspDev.HuganLine3 = dlgTra.FirstSwitchState;
                            pspDev.HuganLine4 = dlgTra.LastSwitchState;
                            pspDev.LineLevel = dlgTra.FirstType;
                            pspDev.LineType = dlgTra.LastType;

                            if (dlgTra.K != "")
                            {
                                pspDev.K = Convert.ToDouble(dlgTra.K);
                            }
                            if (dlgTra.PositiveR != "")
                            {
                                pspDev.PositiveR = Convert.ToDouble(dlgTra.PositiveR);
                            }
                            if (dlgTra.PositiveTQ != "")
                            {
                                pspDev.PositiveTQ = Convert.ToDouble(dlgTra.PositiveTQ);
                            }
                            if (dlgTra.ZeroR != "")
                            {
                                pspDev.ZeroR = Convert.ToDouble(dlgTra.ZeroR);
                            }
                            if (dlgTra.ZeroTQ != "")
                            {
                                pspDev.ZeroTQ = Convert.ToDouble(dlgTra.ZeroTQ);
                            }
                            if (dlgTra.NeutralNodeTQ != "")
                            {
                                pspDev.BigTQ = Convert.ToDouble(dlgTra.NeutralNodeTQ);
                            }

                            Services.BaseService.Create<PSPDEV>(pspDev);
                        }
                        else
                        {
                            tlVectorControl1.Delete();
                        }
                    }
                    else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("transformerthirdzu")))
                    {
                        frmThridTra dlgThridTra = new frmThridTra(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        dlgThridTra.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        if (dlgThridTra.ShowDialog(this) == DialogResult.OK)
                        {
                            PSPDEV pspDev2 = new PSPDEV();
                            XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlgThridTra.Name;
                            pspName.Type = "transformerthirdzu";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 1)
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }

                            tlVectorControl1.Operation = ToolOperation.Select;
                            PSPDEV pspDev = new PSPDEV();
                            tlVectorControl1.ChangeLevel(LevelType.Bottom);
                            RectangleF t = ((IGraph)temp).GetBounds();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = temp.GetAttribute("id");
                            pspDev.Name = dlgThridTra.Name;
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.X1 = t.X;
                            pspDev.Y1 = t.Y;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "transformerthirdzu";

                            pspDev.Lable = "三绕组变压器";
                            pspDev.HuganLine1 = dlgThridTra.IName;
                            pspDev.HuganLine2 = dlgThridTra.JName;
                            pspDev.HuganLine3 = dlgThridTra.ISwitchState;
                            pspDev.HuganLine4 = dlgThridTra.JSwitchState;
                            pspDev.LineLevel = dlgThridTra.IType;
                            pspDev.LineType = dlgThridTra.JType;
                            pspDev.LineStatus = dlgThridTra.KType;
                            pspDev.KName = dlgThridTra.KName;
                            pspDev.KSwitchStatus = dlgThridTra.KSwitchState;

                            if (dlgThridTra.IK != "")
                            {
                                pspDev.K = Convert.ToDouble(dlgThridTra.IK);
                            }
                            if (dlgThridTra.JK != "")
                            {
                                pspDev.G = Convert.ToDouble(dlgThridTra.JK);
                            }
                            if (dlgThridTra.KK != "")
                            {
                                pspDev.BigP = Convert.ToDouble(dlgThridTra.KK);
                            }
                            if (dlgThridTra.IR != "")
                            {
                                pspDev.HuganTQ1 = Convert.ToDouble(dlgThridTra.IR);
                            }
                            if (dlgThridTra.JR != "")
                            {
                                pspDev.HuganTQ2 = Convert.ToDouble(dlgThridTra.JR);
                            }
                            if (dlgThridTra.KR != "")
                            {
                                pspDev.HuganTQ3 = Convert.ToDouble(dlgThridTra.KR);
                            }
                            if (dlgThridTra.ITQ != "")
                            {
                                pspDev.HuganTQ4 = Convert.ToDouble(dlgThridTra.ITQ);
                            }
                            if (dlgThridTra.JTQ != "")
                            {
                                pspDev.HuganTQ5 = Convert.ToDouble(dlgThridTra.JTQ);
                            }
                            if (dlgThridTra.KTQ != "")
                            {
                                pspDev.SmallTQ = Convert.ToDouble(dlgThridTra.KTQ);
                            }
                            if (dlgThridTra.ZeroTQ != "")
                            {
                                pspDev.ZeroTQ = Convert.ToDouble(dlgThridTra.ZeroTQ);
                            }
                            if (dlgThridTra.NeutralNodeTQ != "")
                            {
                                pspDev.BigTQ = Convert.ToDouble(dlgThridTra.NeutralNodeTQ);
                            }

                            Services.BaseService.Create<PSPDEV>(pspDev);
                        }
                        else
                        {
                            tlVectorControl1.Delete();
                        }
                    }
                    else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("串联电容电抗器")))
                    {
                        frmCapacity dlgCapacity = new frmCapacity(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        dlgCapacity.SetEnable(true);
                        dlgCapacity.Text = "串联电容电抗器";
                        dlgCapacity.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        if (dlgCapacity.ShowDialog(this) == DialogResult.OK)
                        {
                            PSPDEV pspDev2 = new PSPDEV();
                            XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlgCapacity.Name;
                            pspName.Type = "串联电容电抗器";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 1)
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }

                            tlVectorControl1.Operation = ToolOperation.Select;
                            PSPDEV pspDev = new PSPDEV();
                            tlVectorControl1.ChangeLevel(LevelType.Bottom);
                            RectangleF t = ((IGraph)temp).GetBounds();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = temp.GetAttribute("id");
                            pspDev.Name = dlgCapacity.Name;
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.X1 = t.X;
                            pspDev.Y1 = t.Y;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "串联电容电抗器";

                            pspDev.Lable = dlgCapacity.Lable;

                            if (dlgCapacity.PositiveTQ != "")
                            {
                                pspDev.PositiveTQ = Convert.ToDouble(dlgCapacity.PositiveTQ);
                            }
                            pspDev.HuganLine1 = dlgCapacity.FirstNodeName;
                            //pspDev.HuganLine2 = dlgCapacity.LastNodeName;

                            Services.BaseService.Create<PSPDEV>(pspDev);
                        }
                        else
                        {
                            tlVectorControl1.Delete();
                        }

                    }
                    else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("并联电容电抗器")))
                    {
                        frmCapacity dlgCapacity = new frmCapacity(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        dlgCapacity.SetEnable(false);
                        dlgCapacity.Text = "并联电容电抗器";
                        dlgCapacity.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        if (dlgCapacity.ShowDialog(this) == DialogResult.OK)
                        {
                            PSPDEV pspDev2 = new PSPDEV();
                            XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlgCapacity.Name;
                            pspName.Type = "并联电容电抗器";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 1)
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }

                            tlVectorControl1.Operation = ToolOperation.Select;
                            PSPDEV pspDev = new PSPDEV();
                            tlVectorControl1.ChangeLevel(LevelType.Bottom);
                            RectangleF t = ((IGraph)temp).GetBounds();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = temp.GetAttribute("id");
                            pspDev.Name = dlgCapacity.Name;
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.X1 = t.X;
                            pspDev.Y1 = t.Y;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "并联电容电抗器";

                            pspDev.Lable = dlgCapacity.Lable;

                            if (dlgCapacity.PositiveTQ != "")
                            {
                                pspDev.PositiveTQ = Convert.ToDouble(dlgCapacity.PositiveTQ);
                            }
                            pspDev.HuganLine1 = dlgCapacity.FirstNodeName;
                            //pspDev.HuganLine2 = dlgCapacity.LastNodeName;

                            Services.BaseService.Create<PSPDEV>(pspDev);
                        }
                        else
                        {
                            tlVectorControl1.Delete();
                        }
                    }
                    else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("1/2母联开关")))
                    {
                        frmMuLian dlgmulian = new frmMuLian(tlVectorControl1.SVGDocument.CurrentLayer.ID);

                        dlgmulian.Text = "1/2母联开关";
                        dlgmulian.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        if (dlgmulian.ShowDialog(this) == DialogResult.OK)
                        {
                            PSPDEV pspDev2 = new PSPDEV();
                            XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlgmulian.Name;
                            pspName.Type = "1/2母联开关";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 1)
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }

                            tlVectorControl1.Operation = ToolOperation.Select;
                            PSPDEV pspDev = new PSPDEV();
                            tlVectorControl1.ChangeLevel(LevelType.Bottom);
                            RectangleF t = ((IGraph)temp).GetBounds();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = temp.GetAttribute("id");
                            pspDev.Name = dlgmulian.Name;
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.X1 = t.X;
                            pspDev.Y1 = t.Y;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "1/2母联开关";

                            pspDev.Lable = "1/2母联开关";

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

                            Services.BaseService.Create<PSPDEV>(pspDev);
                        }
                        else
                        {
                            tlVectorControl1.Delete();
                        }
                    }
                    else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("2/3母联开关")))
                    {
                        frmMuLian2 dlgmulian = new frmMuLian2(tlVectorControl1.SVGDocument.CurrentLayer.ID);

                        dlgmulian.Text = "2/3母联开关";
                        dlgmulian.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        if (dlgmulian.ShowDialog(this) == DialogResult.OK)
                        {
                            PSPDEV pspDev2 = new PSPDEV();
                            XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlgmulian.Name;
                            pspName.Type = "2/3母联开关";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 1)
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }

                            tlVectorControl1.Operation = ToolOperation.Select;
                            PSPDEV pspDev = new PSPDEV();
                            tlVectorControl1.ChangeLevel(LevelType.Bottom);
                            RectangleF t = ((IGraph)temp).GetBounds();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = temp.GetAttribute("id");
                            pspDev.Name = dlgmulian.Name;
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.X1 = t.X;
                            pspDev.Y1 = t.Y;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "2/3母联开关";

                            pspDev.Lable = "2/3母联开关";

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

                            Services.BaseService.Create<PSPDEV>(pspDev);
                        }
                        else
                        {
                            tlVectorControl1.Delete();
                        }
                    }
                    //temp.RemoveAll();
                }
            }
        }
Example #3
0
        void tlVectorControl1_AddElement(object sender, AddSvgElementEventArgs e)
        {
            //MessageBox.Show(e.SvgElement.ID);
            string larid = tlVectorControl1.SVGDocument.CurrentLayer.ID;

            if (!ChangeLayerList.Contains(larid))
            {
                ChangeLayerList.Add(larid);
            }
            XmlElement temp = e.SvgElement as XmlElement;
            if (temp is Polyline)
            {
                XmlNodeList list2 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline");
                foreach (XmlNode node in list2)
                {
                    PSPDEV dev = new PSPDEV();
                    //(node as Text).InnerText = dev.Name;
                    //XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");

                    PSPDEV dlg11 = new PSPDEV();
                    XmlElement element = node as XmlElement;
                    dev.EleID = element.GetAttribute("id");
                    PSPDEV psp = new PSPDEV();
                    dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    dlg11 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", dev);
                    if (dlg11 == null)
                    {
                        SvgElement element2 = node as SvgElement;
                        tlVectorControl1.SVGDocument.CurrentElement = element2;
                        tlVectorControl1.Delete();
                    }
                }
            }

            if (temp is Use && (temp.GetAttribute("xlink:href").Contains("Substation") || temp.GetAttribute("xlink:href").Contains("Power") || temp.GetAttribute("xlink:href").Contains("motherlinenode")))
            {
                PSPDEV pspDev22 = new PSPDEV();
                //pspDev.EleID = element.GetAttribute("id");
                str_power = getPower(temp.GetAttribute("xlink:href"));
                pspDev22.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                if (temp.GetAttribute("xlink:href").Contains("Substation"))
                {
                    pspDev22.Lable = "变电站";

                }
                else if (temp.GetAttribute("xlink:href").Contains("motherlinenode"))
                {
                    pspDev22.Lable = "母线节点";
                }
                else if (temp.GetAttribute("xlink:href").Contains("Power"))
                {
                    pspDev22.Lable = "电厂";
                }
                frmSubstation dlg = new frmSubstation(pspDev22);
                dlg.Str_Power = str_power;
                if (tlVectorControl1.SVGDocument.FileName.Length > 5)
                {
                    dlg.Str_year = tlVectorControl1.SVGDocument.FileName.Substring(0, 4);
                }

                if (dlg.ShowDialog(this) == DialogResult.OK)
                {

                    //XmlElement temp = tlVectorControl1.SVGDocument.CurrentElement;
                    if (temp != null)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        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 >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        //if (pspName.Name == "")
                        //{
                        //    MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        //    tlVectorControl1.Delete();
                        //    return;
                        //}
                        if (true)
                        {

                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            if (temp is Polyline)
                            {
                                double x1 = Convert.ToDouble(temp.GetAttribute("x1"));
                                double y1 = Convert.ToDouble(temp.GetAttribute("y1"));
                                double x2 = Convert.ToDouble(temp.GetAttribute("x2"));
                                double y2 = Convert.ToDouble(temp.GetAttribute("y2"));

                                tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                n1.SetAttribute("x", Convert.ToString(x1 + (x2 - x1) / 2));
                                n1.SetAttribute("y", Convert.ToString(y1 + (y2 - y1) / 2));

                            }
                            else
                            {
                                n1.SetAttribute("x", temp.GetAttribute("x"));
                                n1.SetAttribute("y", temp.GetAttribute("y"));
                                RectangleF t = ((IGraph)temp).GetBounds();
                                n1.SetAttribute("x", (t.X - 10).ToString());
                                n1.SetAttribute("y", (t.Y - 10).ToString());
                            }

                            n1.InnerText = dlg.Name;
                            n1.SetAttribute("layer", SvgDocument.currentLayer);
                            n1.SetAttribute("ParentID", temp.GetAttribute("id"));
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            tlVectorControl1.Operation = ToolOperation.Select;
                        }
                        else
                        {
                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            if (temp is Polyline)
                            {
                                double x1 = Convert.ToDouble(temp.GetAttribute("x1"));
                                double y1 = Convert.ToDouble(temp.GetAttribute("y1"));
                                double x2 = Convert.ToDouble(temp.GetAttribute("x2"));
                                double y2 = Convert.ToDouble(temp.GetAttribute("y2"));

                                tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                n1.SetAttribute("x", Convert.ToString(x1 + (x2 - x1) / 2));
                                n1.SetAttribute("y", Convert.ToString(y1 + (y2 - y1) / 2));
                            }
                            else
                            {
                                RectangleF t = ((IGraph)temp).GetBounds();
                                n1.SetAttribute("x", (t.X - 10).ToString());
                                n1.SetAttribute("y", (t.Y - 10).ToString());
                            }

                            n1.InnerText = dlg.Name;
                            n1.SetAttribute("print", dlg.IsTJ ? "no" : "yes");
                            n1.SetAttribute("layer", SvgDocument.currentLayer);
                            n1.SetAttribute("ParentID", temp.GetAttribute("id"));
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                            tlVectorControl1.Operation = ToolOperation.Select;

                        }
                        PSPDEV pspDev = new PSPDEV();
                        if (temp is Use)
                        {
                            RectangleF t = ((IGraph)temp).GetBounds();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = temp.GetAttribute("id");
                            pspDev.Name = dlg.Name;
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.X1 = t.X;
                            pspDev.Y1 = t.Y;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = -1;
                            pspDev.Type = "Use";
                            if (temp.GetAttribute("xlink:href").Contains("Substation"))
                            {
                                pspDev.Lable = "变电站";
                                temp.SetAttribute("print", dlg.IsTJ ? "no" : "yes");
                            }
                            else if (temp.GetAttribute("xlink:href").Contains("motherlinenode"))
                            {
                                pspDev.Lable = "母线节点";
                            }
                            else if (temp.GetAttribute("xlink:href").Contains("Power"))
                            {
                                pspDev.Lable = "电厂";
                            }
                            if (dlg.VoltR != "")
                                pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            if (dlg.Burthen != "")
                                pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);
                            if (dlg.ReferenceVolt != "")
                            {
                                pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);
                            }
                            //if ((dlg.InPutP == ""))
                            //{
                            //    PSPDEV powerfactor = new PSPDEV();
                            //    powerfactor.Type = "Power";
                            //    powerfactor.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            //    powerfactor = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDAndType", powerfactor);
                            //    pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                            //    pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);

                            //    //if (powerfactor!=null && (Convert.ToDecimal(dlg.Change)==2))
                            //    pspDev.InPutP = Convert.ToDouble(dlg.Burthen) * powerfactor.BigP;
                            //}

                            //if (pspDev.InPutP == 0 && dlg.Burthen!="")
                            //    pspDev.InPutP = Convert.ToDouble(dlg.Burthen) * 0.65;
                            if (dlg.InPutP != "")
                                pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                            if (dlg.InPutQ != "")
                                pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                            if (dlg.OutP != "")
                                pspDev.OutP = Convert.ToDouble(dlg.OutP);
                            if (dlg.OutQ != "")
                                pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                            if (dlg.NodeType == "是")
                            {
                                pspDev.NodeType = "0";
                            }
                            else
                            {
                                pspDev.NodeType = "1";
                            }
                            Services.BaseService.Create<PSPDEV>(pspDev);
                            tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg.TYear);

                        }
                        else if (temp is Polyline)
                        {
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = temp.GetAttribute("id");
                            pspDev.Name = dlg.Name;
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.X1 = Convert.ToDouble(temp.GetAttribute("x1"));
                            pspDev.Y1 = Convert.ToDouble(temp.GetAttribute("y1"));
                            pspDev.X2 = Convert.ToDouble(temp.GetAttribute("x2"));
                            pspDev.Y2 = Convert.ToDouble(temp.GetAttribute("y2"));
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = -1;
                            pspDev.Type = "Polyline";
                            Services.BaseService.Create<PSPDEV>(pspDev);
                        }
                    }
                    //*************
                    string fyear = tlVectorControl1.SVGDocument.FileName.Substring(0, 4);
                    LayerGrade lag = new LayerGrade();
                    lag.Name = fyear + "%";
                    IList laglist = Services.BaseService.GetList("SelectLayerGradeByYear", lag);
                    string power = getPower(temp.GetAttribute("xlink:href"));
                    if (laglist.Count > 0)
                    {
                        LineInfo line = new LineInfo();
                        line.LineName = " Voltage='" + power + "' and length<>'' and LayerID in (select SUID from SVG_LAYER where yearid='" + ((LayerGrade)laglist[0]).SUID + "') and ObligateField6 ='" + dlg.Name + "' order by LineName";
                        IList linList = Services.BaseService.GetList("SelectLineInfoByWhere", line);
                        for (int j = 0; j < linList.Count; j++)
                        {
                            if (((LineInfo)linList[j]).ObligateField7 != "")
                            {
                                PSPDEV p1 = new PSPDEV();
                                p1.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                p1.Name = ((LineInfo)linList[j]).ObligateField6;
                                p1.Type = "Use";
                                IList p1list = Services.BaseService.GetList("SelectPSPDEVByName", p1);
                                PSPDEV p2 = new PSPDEV();
                                p2.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                p2.Name = ((LineInfo)linList[j]).ObligateField7;
                                p2.Type = "Use";
                                IList p2list = Services.BaseService.GetList("SelectPSPDEVByName", p2);
                                if (p1list.Count > 0 && p2list.Count > 0)
                                {
                                    PointF TempPoint = TLMath.getUseOffset(temp.GetAttribute("xlink:href"));
                                    PointF[] ptt = new PointF[] { new PointF(((Use)temp).X + TempPoint.X, ((Use)temp).Y + TempPoint.Y) };
                                    Transf tran = (temp as Graph).Transform;
                                    tran.Matrix.TransformPoints(ptt);
                                    XmlNode n2 = tlVectorControl1.SVGDocument.SelectSingleNode("//*[@id='" + ((PSPDEV)p2list[0]).EleID + "']");
                                    PointF TempPoint2 = TLMath.getUseOffset(((XmlElement)n2).GetAttribute("xlink:href"));
                                    PointF[] ptt2 = new PointF[] { new PointF(((Use)n2).X + TempPoint2.X, ((Use)n2).Y + TempPoint2.Y) };
                                    Transf tran2 = (n2 as Graph).Transform;
                                    tran2.Matrix.TransformPoints(ptt2);
                                    XmlElement line1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                                    line1.SetAttribute("stroke", "#000000");
                                    line1.SetAttribute("layer", ((Layer)tlVectorControl1.SVGDocument.getLayerList()[0]).ID);
                                    line1.SetAttribute("points", ptt[0].X.ToString() + " " + ptt[0].Y.ToString() + "," + ptt2[0].X.ToString() + " " + ptt2[0].Y.ToString());
                                    line1.SetAttribute("FirstNode", ((PSPDEV)p1list[0]).EleID);
                                    line1.SetAttribute("LastNode", ((PSPDEV)p2list[0]).EleID);
                                    XmlNode fn = tlVectorControl1.SVGDocument.RootElement.AppendChild(line1);
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.SUID = Guid.NewGuid().ToString();
                                    pspDev.EleID = ((Polyline)fn).ID;
                                    pspDev.Name = ((LineInfo)linList[j]).LineName;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    pspDev.X1 = ptt[0].X;
                                    pspDev.Y1 = ptt[0].Y;
                                    pspDev.X2 = ptt2[0].X;
                                    pspDev.Y2 = ptt2[0].Y;
                                    pspDev.LineLength = Convert.ToDouble(((LineInfo)linList[j]).Length);
                                    pspDev.Number = -1;
                                    pspDev.FirstNode = -1;
                                    pspDev.LastNode = -1;
                                    pspDev.Type = "Polyline";
                                    pspDev.LineType = ((LineInfo)linList[j]).LineType;
                                    pspDev.VoltR = Convert.ToDouble(((LineInfo)linList[j]).Voltage);
                                    Services.BaseService.Create<PSPDEV>(pspDev);
                                    tlVectorControl1.SVGDocument.CurrentElement = n2 as SvgElement;
                                    tlVectorControl1.ChangeLevel(LevelType.Top);
                                }
                            }
                        }
                    }
                    if (laglist.Count > 0)
                    {
                        LineInfo line = new LineInfo();
                        line.LineName = " Voltage='" + power + "' and length<>'' and LayerID in (select SUID from SVG_LAYER where yearid='" + ((LayerGrade)laglist[0]).SUID + "') and ObligateField7 ='" + dlg.Name + "' order by LineName";
                        IList linList = Services.BaseService.GetList("SelectLineInfoByWhere", line);
                        for (int j = 0; j < linList.Count; j++)
                        {
                            if (((LineInfo)linList[j]).ObligateField6 != "")
                            {
                                PSPDEV p1 = new PSPDEV();
                                p1.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                p1.Name = ((LineInfo)linList[j]).ObligateField6;
                                p1.Type = "Use";
                                IList p1list = Services.BaseService.GetList("SelectPSPDEVByName", p1);
                                PSPDEV p2 = new PSPDEV();
                                p2.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                p2.Name = ((LineInfo)linList[j]).ObligateField7;
                                p2.Type = "Use";
                                IList p2list = Services.BaseService.GetList("SelectPSPDEVByName", p2);
                                if (p1list.Count > 0 && p2list.Count > 0)
                                {
                                    PointF TempPoint = TLMath.getUseOffset(temp.GetAttribute("xlink:href"));
                                    PointF[] ptt = new PointF[] { new PointF(((Use)temp).X + TempPoint.X, ((Use)temp).Y + TempPoint.Y) };
                                    Transf tran = (temp as Graph).Transform;
                                    tran.Matrix.TransformPoints(ptt);
                                    XmlNode n2 = tlVectorControl1.SVGDocument.SelectSingleNode("//*[@id='" + ((PSPDEV)p1list[0]).EleID + "']");
                                    PointF TempPoint2 = TLMath.getUseOffset(((XmlElement)n2).GetAttribute("xlink:href"));
                                    PointF[] ptt2 = new PointF[] { new PointF(((Use)n2).X + TempPoint2.X, ((Use)n2).Y + TempPoint2.Y) };
                                    Transf tran2 = (n2 as Graph).Transform;
                                    tran2.Matrix.TransformPoints(ptt2);
                                    XmlElement line1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                                    line1.SetAttribute("stroke", "#000000");
                                    line1.SetAttribute("layer", ((Layer)tlVectorControl1.SVGDocument.getLayerList()[0]).ID);
                                    line1.SetAttribute("points", ptt2[0].X.ToString() + " " + ptt2[0].Y.ToString() + "," + ptt[0].X.ToString() + " " + ptt[0].Y.ToString());
                                    line1.SetAttribute("FirstNode", ((PSPDEV)p2list[0]).EleID);
                                    line1.SetAttribute("LastNode", ((PSPDEV)p1list[0]).EleID);
                                    XmlNode fn = tlVectorControl1.SVGDocument.RootElement.AppendChild(line1);
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.SUID = Guid.NewGuid().ToString();
                                    pspDev.EleID = ((Polyline)fn).ID;
                                    pspDev.Name = ((LineInfo)linList[j]).LineName;
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    pspDev.X1 = ptt2[0].X;
                                    pspDev.Y1 = ptt2[0].Y;
                                    pspDev.X2 = ptt[0].X;
                                    pspDev.Y2 = ptt[0].Y;
                                    pspDev.LineLength = Convert.ToDouble(((LineInfo)linList[j]).Length);
                                    pspDev.Number = -1;
                                    pspDev.FirstNode = -1;
                                    pspDev.LastNode = -1;
                                    pspDev.Type = "Polyline";
                                    pspDev.LineType = ((LineInfo)linList[j]).LineType;
                                    pspDev.VoltR = Convert.ToDouble(((LineInfo)linList[j]).Voltage);
                                    Services.BaseService.Create<PSPDEV>(pspDev);
                                    tlVectorControl1.SVGDocument.CurrentElement = n2 as SvgElement;
                                    tlVectorControl1.ChangeLevel(LevelType.Top);
                                }
                            }
                        }

                    }
                    tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement;
                    tlVectorControl1.ChangeLevel(LevelType.Top);

                }
                else
                {
                    //tlVectorControl1.Delete();
                    //tlVectorControl1.Dispose();
                    //tlVectorControl1.Undo();
                    XmlNodeList list2 = tlVectorControl1.SVGDocument.SelectNodes("svg/use");
                    foreach (XmlNode node in list2)
                    {
                        PSPDEV dev = new PSPDEV();
                        //(node as Text).InnerText = dev.Name;
                        //XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");

                        PSPDEV dlg11 = new PSPDEV();
                        XmlElement element = node as XmlElement;
                        dev.EleID = element.GetAttribute("id");
                        PSPDEV psp = new PSPDEV();
                        dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        dlg11 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", dev);
                        if (dlg11 == null)
                        {
                            SvgElement element2 = node as SvgElement;
                            tlVectorControl1.SVGDocument.CurrentElement = element2;
                            tlVectorControl1.Delete();
                        }
                    }

                }
            }
            else
            {
                if (temp is Use && (temp.GetAttribute("xlink:href").Contains("dynamotorline")))//接地支路
                {
                    frmFadejie dlg = new frmFadejie(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                    dlg.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {

                        //XmlElement temp = tlVectorControl1.SVGDocument.CurrentElement;
                        if (temp != null)
                        {
                            PSPDEV pspDev2 = new PSPDEV();
                            XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                            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 >= 1)
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }
                            if (true)
                            {
                                tlVectorControl1.Operation = ToolOperation.Select;
                                PSPDEV pspDev = new PSPDEV();
                                tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                RectangleF t = ((IGraph)temp).GetBounds();
                                pspDev.SUID = Guid.NewGuid().ToString();
                                pspDev.EleID = temp.GetAttribute("id");
                                pspDev.Name = dlg.Name;
                                pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                pspDev.X1 = t.X;
                                pspDev.Y1 = t.Y;
                                pspDev.Number = -1;
                                pspDev.FirstNode = -1;
                                pspDev.LastNode = 0;
                                pspDev.Type = "dynamotorline";
                                if (temp.GetAttribute("xlink:href").Contains("dynamotorline"))
                                {
                                    pspDev.Lable = "发电厂支路";
                                }
                                else if (temp.GetAttribute("xlink:href").Contains("gndline"))
                                {
                                    pspDev.Lable = "接地支路";
                                }

                                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.Create<PSPDEV>(pspDev);
                            }
                        }
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("gndline")))//接地支路
                {
                    frmFadejie dlg = new frmFadejie(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                    dlg.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlg.ShowDialog(this) == DialogResult.OK)
                    {

                        //XmlElement temp = tlVectorControl1.SVGDocument.CurrentElement;
                        if (temp != null)
                        {
                            PSPDEV pspDev2 = new PSPDEV();
                            XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                            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 >= 1)
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }
                            if (true)
                            {
                                tlVectorControl1.Operation = ToolOperation.Select;
                                PSPDEV pspDev = new PSPDEV();
                                tlVectorControl1.ChangeLevel(LevelType.Bottom);
                                RectangleF t = ((IGraph)temp).GetBounds();
                                pspDev.SUID = Guid.NewGuid().ToString();
                                pspDev.EleID = temp.GetAttribute("id");
                                pspDev.Name = dlg.Name;
                                pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                pspDev.X1 = t.X;
                                pspDev.Y1 = t.Y;
                                pspDev.Number = -1;
                                pspDev.FirstNode = -1;
                                pspDev.LastNode = 0;
                                pspDev.Type = "gndline";
                                if (temp.GetAttribute("xlink:href").Contains("dynamotorline"))
                                {
                                    pspDev.Lable = "发电厂支路";
                                }
                                else if (temp.GetAttribute("xlink:href").Contains("gndline"))
                                {
                                    pspDev.Lable = "接地支路";
                                }

                                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.Create<PSPDEV>(pspDev);
                            }
                        }
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("loadline")))
                {
                    frmLoad dlgLoad = new frmLoad();
                    dlgLoad.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgLoad.ShowDialog(this) == DialogResult.OK)
                    {
                        if (temp != null)
                        {
                            PSPDEV pspDev2 = new PSPDEV();
                            XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                            PSPDEV pspName = new PSPDEV();
                            pspName.Name = dlgLoad.Name;
                            pspName.Type = "loadline";
                            pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                            if (listName.Count >= 1)
                            {
                                MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }

                            tlVectorControl1.Operation = ToolOperation.Select;
                            PSPDEV pspDev = new PSPDEV();
                            tlVectorControl1.ChangeLevel(LevelType.Bottom);
                            RectangleF t = ((IGraph)temp).GetBounds();
                            pspDev.SUID = Guid.NewGuid().ToString();
                            pspDev.EleID = temp.GetAttribute("id");
                            pspDev.Name = dlgLoad.Name;
                            pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            pspDev.X1 = t.X;
                            pspDev.Y1 = t.Y;
                            pspDev.Number = -1;
                            pspDev.FirstNode = -1;
                            pspDev.LastNode = 0;
                            pspDev.Type = "loadline";

                            pspDev.Lable = "负荷支路";

                            pspDev.HuganLine1 = dlgLoad.FirstNodeName;
                            if (dlgLoad.InPutP != "")
                            {
                                pspDev.InPutP = Convert.ToDouble(dlgLoad.InPutP);
                            }
                            if (dlgLoad.InPutQ != "")
                            {
                                pspDev.InPutQ = Convert.ToDouble(dlgLoad.InPutQ);
                            }
                            if (dlgLoad.VoltR != "")
                            {
                                pspDev.VoltR = Convert.ToDouble(dlgLoad.VoltR);
                            }

                            pspDev.HuganLine3 = dlgLoad.LoadSwitchState;

                            Services.BaseService.Create<PSPDEV>(pspDev);
                        }
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("transformertwozu")))
                {
                    frmTwoTra dlgTra = new frmTwoTra(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                    dlgTra.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgTra.ShowDialog(this) == DialogResult.OK)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlgTra.Name;
                        pspName.Type = "transformertwozu";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        tlVectorControl1.Operation = ToolOperation.Select;
                        PSPDEV pspDev = new PSPDEV();
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        RectangleF t = ((IGraph)temp).GetBounds();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = temp.GetAttribute("id");
                        pspDev.Name = dlgTra.Name;
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.X1 = t.X;
                        pspDev.Y1 = t.Y;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = 0;
                        pspDev.Type = "transformertwozu";

                        pspDev.Lable = "二绕组变压器";
                        pspDev.HuganLine1 = dlgTra.FirstName;
                        pspDev.HuganLine2 = dlgTra.LastName;
                        pspDev.HuganLine3 = dlgTra.FirstSwitchState;
                        pspDev.HuganLine4 = dlgTra.LastSwitchState;
                        pspDev.LineLevel = dlgTra.FirstType;
                        pspDev.LineType = dlgTra.LastType;

                        if (dlgTra.K != "")
                        {
                            pspDev.K = Convert.ToDouble(dlgTra.K);
                        }
                        if (dlgTra.PositiveR != "")
                        {
                            pspDev.PositiveR = Convert.ToDouble(dlgTra.PositiveR);
                        }
                        if (dlgTra.PositiveTQ != "")
                        {
                            pspDev.PositiveTQ = Convert.ToDouble(dlgTra.PositiveTQ);
                        }
                        if (dlgTra.ZeroR != "")
                        {
                            pspDev.ZeroR = Convert.ToDouble(dlgTra.ZeroR);
                        }
                        if (dlgTra.ZeroTQ != "")
                        {
                            pspDev.ZeroTQ = Convert.ToDouble(dlgTra.ZeroTQ);
                        }
                        if (dlgTra.NeutralNodeTQ != "")
                        {
                            pspDev.BigTQ = Convert.ToDouble(dlgTra.NeutralNodeTQ);
                        }

                        Services.BaseService.Create<PSPDEV>(pspDev);
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("transformerthirdzu")))
                {
                    frmThridTra dlgThridTra = new frmThridTra(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                    dlgThridTra.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgThridTra.ShowDialog(this) == DialogResult.OK)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlgThridTra.Name;
                        pspName.Type = "transformerthirdzu";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        tlVectorControl1.Operation = ToolOperation.Select;
                        PSPDEV pspDev = new PSPDEV();
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        RectangleF t = ((IGraph)temp).GetBounds();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = temp.GetAttribute("id");
                        pspDev.Name = dlgThridTra.Name;
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.X1 = t.X;
                        pspDev.Y1 = t.Y;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = 0;
                        pspDev.Type = "transformerthirdzu";

                        pspDev.Lable = "三绕组变压器";
                        pspDev.HuganLine1 = dlgThridTra.IName;
                        pspDev.HuganLine2 = dlgThridTra.JName;
                        pspDev.HuganLine3 = dlgThridTra.ISwitchState;
                        pspDev.HuganLine4 = dlgThridTra.JSwitchState;
                        pspDev.LineLevel = dlgThridTra.IType;
                        pspDev.LineType = dlgThridTra.JType;
                        pspDev.LineStatus = dlgThridTra.KType;
                        pspDev.KName = dlgThridTra.KName;
                        pspDev.KSwitchStatus = dlgThridTra.KSwitchState;

                        if (dlgThridTra.IK != "")
                        {
                            pspDev.K = Convert.ToDouble(dlgThridTra.IK);
                        }
                        if (dlgThridTra.JK != "")
                        {
                            pspDev.G = Convert.ToDouble(dlgThridTra.JK);
                        }
                        if (dlgThridTra.KK != "")
                        {
                            pspDev.BigP = Convert.ToDouble(dlgThridTra.KK);
                        }
                        if (dlgThridTra.IR != "")
                        {
                            pspDev.HuganTQ1 = Convert.ToDouble(dlgThridTra.IR);
                        }
                        if (dlgThridTra.JR != "")
                        {
                            pspDev.HuganTQ2 = Convert.ToDouble(dlgThridTra.JR);
                        }
                        if (dlgThridTra.KR != "")
                        {
                            pspDev.HuganTQ3 = Convert.ToDouble(dlgThridTra.KR);
                        }
                        if (dlgThridTra.ITQ != "")
                        {
                            pspDev.HuganTQ4 = Convert.ToDouble(dlgThridTra.ITQ);
                        }
                        if (dlgThridTra.JTQ != "")
                        {
                            pspDev.HuganTQ5 = Convert.ToDouble(dlgThridTra.JTQ);
                        }
                        if (dlgThridTra.KTQ != "")
                        {
                            pspDev.SmallTQ = Convert.ToDouble(dlgThridTra.KTQ);
                        }
                        if (dlgThridTra.ZeroTQ != "")
                        {
                            pspDev.ZeroTQ = Convert.ToDouble(dlgThridTra.ZeroTQ);
                        }
                        if (dlgThridTra.NeutralNodeTQ != "")
                        {
                            pspDev.BigTQ = Convert.ToDouble(dlgThridTra.NeutralNodeTQ);
                        }

                        Services.BaseService.Create<PSPDEV>(pspDev);
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("串联电容电抗器")))
                {
                    frmCapacity dlgCapacity = new frmCapacity(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                    dlgCapacity.SetEnable(true);
                    dlgCapacity.Text = "串联电容电抗器";
                    dlgCapacity.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgCapacity.ShowDialog(this) == DialogResult.OK)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlgCapacity.Name;
                        pspName.Type = "串联电容电抗器";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        tlVectorControl1.Operation = ToolOperation.Select;
                        PSPDEV pspDev = new PSPDEV();
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        RectangleF t = ((IGraph)temp).GetBounds();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = temp.GetAttribute("id");
                        pspDev.Name = dlgCapacity.Name;
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.X1 = t.X;
                        pspDev.Y1 = t.Y;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = 0;
                        pspDev.Type = "串联电容电抗器";

                        pspDev.Lable = dlgCapacity.Lable;

                        if (dlgCapacity.PositiveTQ != "")
                        {
                            pspDev.PositiveTQ = Convert.ToDouble(dlgCapacity.PositiveTQ);
                        }
                        pspDev.HuganLine1 = dlgCapacity.FirstNodeName;
                        //pspDev.HuganLine2 = dlgCapacity.LastNodeName;

                        Services.BaseService.Create<PSPDEV>(pspDev);
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }

                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("并联电容电抗器")))
                {
                    frmCapacity dlgCapacity = new frmCapacity(tlVectorControl1.SVGDocument.CurrentLayer.ID);
                    dlgCapacity.SetEnable(false);
                    dlgCapacity.Text = "并联电容电抗器";
                    dlgCapacity.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgCapacity.ShowDialog(this) == DialogResult.OK)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlgCapacity.Name;
                        pspName.Type = "并联电容电抗器";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        tlVectorControl1.Operation = ToolOperation.Select;
                        PSPDEV pspDev = new PSPDEV();
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        RectangleF t = ((IGraph)temp).GetBounds();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = temp.GetAttribute("id");
                        pspDev.Name = dlgCapacity.Name;
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.X1 = t.X;
                        pspDev.Y1 = t.Y;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = 0;
                        pspDev.Type = "并联电容电抗器";

                        pspDev.Lable = dlgCapacity.Lable;

                        if (dlgCapacity.PositiveTQ != "")
                        {
                            pspDev.PositiveTQ = Convert.ToDouble(dlgCapacity.PositiveTQ);
                        }
                        pspDev.HuganLine1 = dlgCapacity.FirstNodeName;
                        //pspDev.HuganLine2 = dlgCapacity.LastNodeName;

                        Services.BaseService.Create<PSPDEV>(pspDev);
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("1/2母联开关")))
                {
                    frmMuLian dlgmulian = new frmMuLian(tlVectorControl1.SVGDocument.CurrentLayer.ID);

                    dlgmulian.Text = "1/2母联开关";
                    dlgmulian.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgmulian.ShowDialog(this) == DialogResult.OK)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlgmulian.Name;
                        pspName.Type = "1/2母联开关";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        tlVectorControl1.Operation = ToolOperation.Select;
                        PSPDEV pspDev = new PSPDEV();
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        RectangleF t = ((IGraph)temp).GetBounds();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = temp.GetAttribute("id");
                        pspDev.Name = dlgmulian.Name;
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.X1 = t.X;
                        pspDev.Y1 = t.Y;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = 0;
                        pspDev.Type = "1/2母联开关";

                        pspDev.Lable = "1/2母联开关";

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

                        Services.BaseService.Create<PSPDEV>(pspDev);
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("2/3母联开关")))
                {
                    frmMuLian2 dlgmulian = new frmMuLian2(tlVectorControl1.SVGDocument.CurrentLayer.ID);

                    dlgmulian.Text = "2/3母联开关";
                    dlgmulian.svgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    if (dlgmulian.ShowDialog(this) == DialogResult.OK)
                    {
                        PSPDEV pspDev2 = new PSPDEV();
                        XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text");
                        PSPDEV pspName = new PSPDEV();
                        pspName.Name = dlgmulian.Name;
                        pspName.Type = "2/3母联开关";
                        pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName);
                        if (listName.Count >= 1)
                        {
                            MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tlVectorControl1.Delete();
                            return;
                        }

                        tlVectorControl1.Operation = ToolOperation.Select;
                        PSPDEV pspDev = new PSPDEV();
                        tlVectorControl1.ChangeLevel(LevelType.Bottom);
                        RectangleF t = ((IGraph)temp).GetBounds();
                        pspDev.SUID = Guid.NewGuid().ToString();
                        pspDev.EleID = temp.GetAttribute("id");
                        pspDev.Name = dlgmulian.Name;
                        pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspDev.X1 = t.X;
                        pspDev.Y1 = t.Y;
                        pspDev.Number = -1;
                        pspDev.FirstNode = -1;
                        pspDev.LastNode = 0;
                        pspDev.Type = "2/3母联开关";

                        pspDev.Lable = "2/3母联开关";

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

                        Services.BaseService.Create<PSPDEV>(pspDev);
                    }
                    else
                    {
                        tlVectorControl1.Delete();
                    }
                }
                //temp.RemoveAll();
            }
        }
Example #4
0
        //void DrawArea_OnMouseMove(object sender, MouseEventArgs e)
        //{
        //}
        void tlVectorControl1_DoubleLeftClick(object sender, SvgElementSelectedEventArgs e)
        {
            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"))
                {

                    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.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspName.Type = "Use";
                        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 powerfactor = new PSPDEV();
                        powerfactor.Type = "Power";
                        powerfactor.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        powerfactor = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDAndType", powerfactor);
                        pspDev.VoltR = Convert.ToDouble(dlg.VoltR);
                        pspDev.Burthen = Convert.ToDecimal(dlg.Burthen);

                        //if (powerfactor!=null && (Convert.ToDecimal(dlg.Change)==2))
                        //pspDev.InPutP = Convert.ToDouble(dlg.Burthen) * powerfactor.BigP;
                        //if (Convert.ToDecimal(dlg.Change)==1)
                        pspDev.InPutP = Convert.ToDouble(dlg.InPutP);
                        pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ);
                        pspDev.OutP = Convert.ToDouble(dlg.OutP);
                        pspDev.OutQ = Convert.ToDouble(dlg.OutQ);
                        pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt);

                        if (dlg.NodeType == "是")
                        {
                            pspDev.NodeType = "0";
                        }
                        else
                        {
                            pspDev.NodeType = "1";
                        }
                        Services.BaseService.Update<PSPDEV>(pspDev);
                    }
                }
                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.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                        pspName.Type = "Use";
                        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.LineType = dlg2.LineType;
                    pspDev.LineStatus = dlg2.LineStatus;
                    pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt);
                    if (dlg2.linevalue != "")
                    {
                        pspDev.BigP = Convert.ToDouble(dlg2.linevalue);
                    }
                    WireCategory wirewire = new WireCategory();
                    wirewire.WireType = dlg2.LineType;
                    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.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 = 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();
                }
            }
        }
Example #5
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();
        }