Пример #1
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();
                }
            }
        }
Пример #2
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();
            }
        }