public void AddElement(SvgElement path) { if (path != null) { this.picturePanel.AddElement(path); } if (OnAddElement != null) { AddSvgElementEventArgs e = new AddSvgElementEventArgs(path); OnAddElement(path,e); } }
void DrawArea_OnAddElement(object sender, AddSvgElementEventArgs e) { string larid = tlVectorControl1.SVGDocument.CurrentLayer.ID; if (!ChangeLayerList.Contains(larid)) { ChangeLayerList.Add(larid); } //MessageBox.Show(e.SvgElement.ID); if (XZ_bdz.Length > 5) { lb11: frmInputDialog2 input = new frmInputDialog2(); if (input.ShowDialog() == DialogResult.OK) { PSP_SubstationSelect s = new PSP_SubstationSelect(); s.SName = input.InputStr; s.SvgID = tlVectorControl1.SVGDocument.SvgdataUid; PSP_SubstationSelect ss1 = (PSP_SubstationSelect)Services.BaseService.GetObject("SelectPSP_SubstationSelectByName", s); if (ss1 != null) { MessageBox.Show("名称重复。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); goto lb11; } else { s.UID = Guid.NewGuid().ToString(); s.EleID = e.SvgElement.ID; s.SName = input.InputStr; s.Remark = input.strRemark; s.col2 = XZ_bdz; s.SvgID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<PSP_SubstationSelect>(s); } } else { tlVectorControl1.Delete(); } if (MessageBox.Show("是否继续选择新的变电站址?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { } else { XZ_bdz = ""; } } }
private void MouseAreaControl_DragDrop(object sender, DragEventArgs e) { object obj1 = e.Data.GetData("SvgElement"); if (obj1 is IGraph) { if (BeforeDragDrop!=null) BeforeDragDrop(obj1,e); if (e.Effect == DragDropEffects.None)return; IGraph graph1 = (IGraph) obj1; if (graph1 == this.SVGDocument.RootElement) { MessageBox.Show("���ܽ�����Ӧ�õ������"); } else { SvgDocument document1 = this.SVGDocument; if (graph1 is ConnectLine) { Point point2 = this.picturePanel.PointToView(base.PointToClient(new Point(e.X, e.Y))); ConnectLine connect =document1.ImportNode((SvgElement)graph1,true) as ConnectLine; #region delete // ConnectLine connect =document1.CreateElement("tonli","connectline",SvgDocument.TonliNamespace) as ConnectLine; // // foreach(XmlAttribute attribute in (graph1 as SvgElement).Attributes ) // { // if(attribute.LocalName!="id" && attribute.LocalName !="tonli") // { // AttributeFunc.SetAttributeValue(connect,attribute.LocalName,attribute.Value); // } // } #endregion connect.X1 += point2.X; connect.X2 += point2.X; connect.Y1 += point2.Y; connect.Y2 += point2.Y; this.picturePanel.AddElement(connect); } else { IGraph graph2; if (!document1.DefsElementContains((SvgElement) graph1,out graph2)) { if((graph1 as SvgElement).ParentNode is State) { State state =(graph1 as SvgElement).ParentNode.Clone() as State; foreach(SvgElement element1 in state.ChildList) { element1.Attributes.RemoveNamedItem("visibility");//ɾ�������е��������� } document1.AddDefsElement(state); } else { graph2 = document1.AddDefsElement((SvgElement) graph1) as IGraph; } } if (graph2!=null)graph1=graph2; Use use1 = (Use) document1.CreateElement(document1.Prefix, "use", document1.NamespaceURI); use1.GraphId = graph1.ID; Point point1 = this.picturePanel.PointToView(base.PointToClient(new Point(e.X, e.Y))); RectangleF ef1 = graph1.GPath.GetBounds(graph1.Transform.Matrix); float X = (point1.X - ef1.X) - (ef1.Width/2f); float Y = (point1.Y - ef1.Y) - (ef1.Height/2f); Transf tf = new Transf(); tf.Matrix.Translate(X, Y); use1.Transform = tf; use1.GraphBrush = this.picturePanel.FillBrush.Clone(); use1.GraphStroke = this.picturePanel.Stroke.Clone() as Stroke; this.picturePanel.AddElement(use1); if (OnAddElement!=null) { AddSvgElementEventArgs eTemp = new AddSvgElementEventArgs(use1); OnAddElement(use1,eTemp); } // this.picturePanel.InvalidateElement(use1); } } if(DragAndDrop!=null) { DragAndDrop(graph1,e); } } }
void DrawArea_BeforeAddSvgElement(object sender, AddSvgElementEventArgs e) { //MessageBox.Show( e.SvgElement.ID); }
void tlVectorControl1_AddElement(object sender, AddSvgElementEventArgs e) { XmlElement temp = e.SvgElement as XmlElement; intdata(tlVectorControl1.SVGDocument.SvgdataUid); if (temp is Use && (temp.GetAttribute("xlink:href").Contains("motherlinenode"))) { //frmSubstation dlgSubstation = new frmSubstation(); //dlgSubstation.ProjectID = this.ProjectUID; //dlgSubstation.InitData(); object subID = DeviceHelper.SelectProjectDevice("01", tlVectorControl1.SVGDocument.SvgdataUid,this.ProjectUID,buscol); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { temp.SetAttribute("Deviceid", ((PSPDEV)subID).SUID); temp.SetAttribute("Type", "01"); RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X - 10).ToString()); n1.SetAttribute("y", (t.Y - 10).ToString()); n1.InnerText = ((PSPDEV)subID).Name; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } foreach (eleclass ele in buscol) { if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag==true) { MessageBox.Show("已经选择此母线,请重新选择其他的母线!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == false) { buscol.Remove(ele); eleclass ele1 = new eleclass(((PSPDEV)subID).Name, ((PSPDEV)subID).SUID, ((PSPDEV)subID).Type, true); buscol.Add(ele1); AddLine(temp, ((PSPDEV)subID).SUID); } } } if (temp is Use && (temp.GetAttribute("xlink:href").Contains("transformertwozu"))) { //frmSubstation dlgSubstation = new frmSubstation(); //dlgSubstation.ProjectID = this.ProjectUID; //dlgSubstation.InitData(); object subID = DeviceHelper.SelectProjectDevice("02", tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID,trans2col); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { temp.SetAttribute("Deviceid", ((PSPDEV)subID).SUID); temp.SetAttribute("Type", "02"); RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X - 10).ToString()); n1.SetAttribute("y", (t.Y - 10).ToString()); n1.InnerText = ((PSPDEV)subID).Name; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } foreach (eleclass ele in trans2col) { if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == true) { MessageBox.Show("已经选择此变压器,请重新选择其他的变压器!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == false) { trans2col.Remove(ele); eleclass ele1 = new eleclass(((PSPDEV)subID).Name, ((PSPDEV)subID).SUID, ((PSPDEV)subID).Type, true); trans2col.Add(ele1); } } } if (temp is Use && (temp.GetAttribute("xlink:href").Contains("transformerthirdzu"))) { //frmSubstation dlgSubstation = new frmSubstation(); //dlgSubstation.ProjectID = this.ProjectUID; //dlgSubstation.InitData(); object subID = DeviceHelper.SelectProjectDevice("03", tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID,trans3col); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { temp.SetAttribute("Deviceid", ((PSPDEV)subID).SUID); temp.SetAttribute("Type", "03"); RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X - 10).ToString()); n1.SetAttribute("y", (t.Y - 10).ToString()); n1.InnerText = ((PSPDEV)subID).Name; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } foreach (eleclass ele in trans3col) { if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == true) { MessageBox.Show("已经选择此两绕组变压器,请重新选择其他的两绕组变压器!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == false) { trans3col.Remove(ele); eleclass ele1 = new eleclass(((PSPDEV)subID).Name, ((PSPDEV)subID).SUID, ((PSPDEV)subID).Type, true); trans3col.Add(ele1); } } } if (temp is Use && (temp.GetAttribute("xlink:href").Contains("loadline"))) { //frmSubstation dlgSubstation = new frmSubstation(); //dlgSubstation.ProjectID = this.ProjectUID; //dlgSubstation.InitData(); object subID = DeviceHelper.SelectProjectDevice("12", tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID,loadcol); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { temp.SetAttribute("Deviceid", ((PSPDEV)subID).SUID); temp.SetAttribute("Type", "12"); RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X - 10).ToString()); n1.SetAttribute("y", (t.Y - 10).ToString()); n1.InnerText = ((PSPDEV)subID).Name; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } foreach (eleclass ele in loadcol) { if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == true) { MessageBox.Show("已经选择此负荷,请重新选择其他的负荷!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == false) { loadcol.Remove(ele); eleclass ele1 = new eleclass(((PSPDEV)subID).Name, ((PSPDEV)subID).SUID, ((PSPDEV)subID).Type, true); loadcol.Add(ele1); } } } if (temp is Use && (temp.GetAttribute("xlink:href").Contains("dynamotorline"))) { //frmSubstation dlgSubstation = new frmSubstation(); //dlgSubstation.ProjectID = this.ProjectUID; //dlgSubstation.InitData(); object subID = DeviceHelper.SelectProjectDevice("04", tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID,gencol); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { temp.SetAttribute("Deviceid", ((PSPDEV)subID).SUID); temp.SetAttribute("Type", "04"); RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X - 10).ToString()); n1.SetAttribute("y", (t.Y - 10).ToString()); n1.InnerText = ((PSPDEV)subID).Name; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } foreach (eleclass ele in gencol) { if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == true) { MessageBox.Show("已经选择此发电厂,请重新选择其他的发电厂!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == false) { gencol.Remove(ele); eleclass ele1 = new eleclass(((PSPDEV)subID).Name, ((PSPDEV)subID).SUID, ((PSPDEV)subID).Type, true); gencol.Add(ele1); } } } if (temp is Use && (temp.GetAttribute("xlink:href").Contains("串联电抗器"))) { //frmSubstation dlgSubstation = new frmSubstation(); //dlgSubstation.ProjectID = this.ProjectUID; //dlgSubstation.InitData(); object subID = DeviceHelper.SelectProjectDevice("10", tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID,cldkcol); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { temp.SetAttribute("Deviceid", ((PSPDEV)subID).SUID); temp.SetAttribute("Type", "10"); RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X - 10).ToString()); n1.SetAttribute("y", (t.Y - 10).ToString()); n1.InnerText = ((PSPDEV)subID).Name; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } foreach (eleclass ele in cldkcol) { if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == true) { MessageBox.Show("已经选择此串联电抗器,请重新选择其他的串联电抗器!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == false) { cldkcol.Remove(ele); eleclass ele1 = new eleclass(((PSPDEV)subID).Name, ((PSPDEV)subID).SUID, ((PSPDEV)subID).Type, true); cldkcol.Add(ele1); } } } if (temp is Use && (temp.GetAttribute("xlink:href").Contains("串联电容器"))) { //frmSubstation dlgSubstation = new frmSubstation(); //dlgSubstation.ProjectID = this.ProjectUID; //dlgSubstation.InitData(); object subID = DeviceHelper.SelectProjectDevice("08", tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID,cldrcol); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { temp.SetAttribute("Deviceid", ((PSPDEV)subID).SUID); temp.SetAttribute("Type", "08"); RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X - 10).ToString()); n1.SetAttribute("y", (t.Y - 10).ToString()); n1.InnerText = ((PSPDEV)subID).Name; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } foreach (eleclass ele in cldrcol) { if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == true) { MessageBox.Show("已经选择此串联电容器,请重新选择其他的串联电容器!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == false) { cldrcol.Remove(ele); eleclass ele1 = new eleclass(((PSPDEV)subID).Name, ((PSPDEV)subID).SUID, ((PSPDEV)subID).Type, true); cldrcol.Add(ele1); } } } if (temp is Use && (temp.GetAttribute("xlink:href").Contains("并联电容器"))) { //frmSubstation dlgSubstation = new frmSubstation(); //dlgSubstation.ProjectID = this.ProjectUID; //dlgSubstation.InitData(); object subID = DeviceHelper.SelectProjectDevice("09", tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID,bldrcol); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { temp.SetAttribute("Deviceid", ((PSPDEV)subID).SUID); temp.SetAttribute("Type", "09"); RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X - 10).ToString()); n1.SetAttribute("y", (t.Y - 10).ToString()); n1.InnerText = ((PSPDEV)subID).Name; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } foreach (eleclass ele in bldrcol) { if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == true) { MessageBox.Show("已经选择此并联电容器,请重新选择其他的并联电容器!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == false) { bldrcol.Remove(ele); eleclass ele1 = new eleclass(((PSPDEV)subID).Name, ((PSPDEV)subID).SUID, ((PSPDEV)subID).Type, true); bldrcol.Add(ele1); } } } if (temp is Use && (temp.GetAttribute("xlink:href").Contains("并联电抗器"))) { //frmSubstation dlgSubstation = new frmSubstation(); //dlgSubstation.ProjectID = this.ProjectUID; //dlgSubstation.InitData(); object subID = DeviceHelper.SelectProjectDevice("11", tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID,bldkcol); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { temp.SetAttribute("Deviceid", ((PSPDEV)subID).SUID); temp.SetAttribute("Type", "11"); RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X - 10).ToString()); n1.SetAttribute("y", (t.Y - 10).ToString()); n1.InnerText = ((PSPDEV)subID).Name; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } foreach (eleclass ele in bldkcol) { if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == true) { MessageBox.Show("已经选择此并联电抗器,请重新选择其他的并联电抗器!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == false) { bldkcol.Remove(ele); eleclass ele1 = new eleclass(((PSPDEV)subID).Name, ((PSPDEV)subID).SUID, ((PSPDEV)subID).Type, true); bldkcol.Add(ele1); } } } if (temp is Use && (temp.GetAttribute("xlink:href").Contains("1/2母联开关"))) { //frmSubstation dlgSubstation = new frmSubstation(); //dlgSubstation.ProjectID = this.ProjectUID; //dlgSubstation.InitData(); object subID = DeviceHelper.SelectProjectDevice("13", tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID,MLcol); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { temp.SetAttribute("Deviceid", ((PSPDEV)subID).SUID); temp.SetAttribute("Type", "13"); RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X - 10).ToString()); n1.SetAttribute("y", (t.Y - 10).ToString()); n1.InnerText = ((PSPDEV)subID).Name; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } foreach (eleclass ele in MLcol) { if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == true) { MessageBox.Show("已经选择此1/2母联开关,请重新选择其他的1/2母联!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == false) { MLcol.Remove(ele); eleclass ele1 = new eleclass(((PSPDEV)subID).Name, ((PSPDEV)subID).SUID, ((PSPDEV)subID).Type, true); MLcol.Add(ele1); } } } if (temp is Use && (temp.GetAttribute("xlink:href").Contains("2/3母联开关"))) { //frmSubstation dlgSubstation = new frmSubstation(); //dlgSubstation.ProjectID = this.ProjectUID; //dlgSubstation.InitData(); object subID = DeviceHelper.SelectProjectDevice("14", tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID,ML2col); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { temp.SetAttribute("Deviceid", ((PSPDEV)subID).SUID); temp.SetAttribute("Type", "14"); RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X - 10).ToString()); n1.SetAttribute("y", (t.Y - 10).ToString()); n1.InnerText = ((PSPDEV)subID).Name; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } foreach (eleclass ele in ML2col) { if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == true) { MessageBox.Show("已经选择此3/2母联开关,请重新选择其他的3/2母联开关!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == false) { ML2col.Remove(ele); eleclass ele1 = new eleclass(((PSPDEV)subID).Name, ((PSPDEV)subID).SUID, ((PSPDEV)subID).Type, true); ML2col.Add(ele1); } } } if (temp is Use && (temp.GetAttribute("xlink:href").Contains("线路互感"))) { //frmSubstation dlgSubstation = new frmSubstation(); //dlgSubstation.ProjectID = this.ProjectUID; //dlgSubstation.InitData(); object subID = DeviceHelper.SelectProjectDevice("15", tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID,HGcol); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { temp.SetAttribute("Deviceid", ((PSPDEV)subID).SUID); temp.SetAttribute("Type", "15"); RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X - 10).ToString()); n1.SetAttribute("y", (t.Y - 10).ToString()); n1.InnerText = ((PSPDEV)subID).Name; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } foreach (eleclass ele in HGcol) { if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == true) { MessageBox.Show("已经选择此线路互感,请重新选择其他的线路互感!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSPDEV)subID).SUID && ele.selectflag == false) { HGcol.Remove(ele); eleclass ele1 = new eleclass(((PSPDEV)subID).Name, ((PSPDEV)subID).SUID, ((PSPDEV)subID).Type, true); HGcol.Add(ele1); } } } }
void tlVectorControl1_AddElement(object sender, AddSvgElementEventArgs e) { XmlElement temp = e.SvgElement as XmlElement; intdata(tlVectorControl1.SVGDocument.SvgdataUid); if (temp is Use && (temp.GetAttribute("xlink:href").Contains("Substation"))) { //frmSubstation dlgSubstation = new frmSubstation(); //dlgSubstation.ProjectID = this.ProjectUID; //dlgSubstation.InitData(); XmlNodeList listUSE = tlVectorControl1.SVGDocument.GetElementsByTagName("use"); IList<object> listID = new List<object>(); foreach (XmlNode node in listUSE) { string str = ((XmlElement)node).GetAttribute("Deviceid"); PSP_Substation_Info obj = DeviceHelper.GetDevice<PSP_Substation_Info>(str); if (obj != null) { listID.Add((object)obj); } } DeviceHelper.pspflag = true; object subID = DeviceHelper.SelectDevice("20", tlVectorControl1.SVGDocument.SvgdataUid, listID); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X + t.Width + 10).ToString()); n1.SetAttribute("y", (t.Y + t.Height / 2).ToString()); n1.InnerText = ((PSP_Substation_Info)subID).Title; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("Deviceid", ((PSP_Substation_Info)subID).UID); temp.SetAttribute("Deviceid", ((PSP_Substation_Info)subID).UID); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; //PSP_ElcDevice elcDEV = new PSP_ElcDevice(); //elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid; //elcDEV.DeviceSUID = ((PSP_Substation_Info)subID).UID; //Services.BaseService.Create<PSP_ElcDevice>(elcDEV); //AddLine(temp, elcDEV.DeviceSUID); } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); return; } bool projectexitflag = false; //检验此变电站是否在项目中 foreach (eleclass ele in Subcol) { if (ele.suid == ((PSP_Substation_Info)subID).UID && ele.selectflag == true) { projectexitflag = true; MessageBox.Show("已经选择此变电站,请重新选择其他的变电站!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSP_Substation_Info)subID).UID && ele.selectflag == false) { projectexitflag = true; Subcol.Remove(ele); eleclass ele1 = new eleclass(((PSP_Substation_Info)subID).Title, ((PSP_Substation_Info)subID).UID, "20", true); Subcol.Add(ele1); PSP_ElcDevice elcDEV = new PSP_ElcDevice(); elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid; elcDEV.DeviceSUID = ((PSP_Substation_Info)subID).UID; Services.BaseService.Create<PSP_ElcDevice>(elcDEV); AddLine(temp, elcDEV.DeviceSUID); } } if (!projectexitflag) { MessageBox.Show("你所选择的项目中不包括此变电站!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } } else if (temp is Use && (temp.GetAttribute("xlink:href").Contains("Power"))) { XmlNodeList listUSE = tlVectorControl1.SVGDocument.GetElementsByTagName("use"); IList<object> listID = new List<object>(); foreach (XmlNode node in listUSE) { string str = ((XmlElement)node).GetAttribute("Deviceid"); PSP_PowerSubstation_Info obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(str); if (obj != null) { listID.Add((object)obj); } } DeviceHelper.pspflag = true; object subID = DeviceHelper.SelectDevice("30", tlVectorControl1.SVGDocument.SvgdataUid, listID); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (subID != null) { RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X + t.Width + 10).ToString()); n1.SetAttribute("y", (t.Y + t.Height / 2).ToString()); n1.InnerText = ((PSP_PowerSubstation_Info)subID).Title; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("Deviceid", ((PSP_PowerSubstation_Info)subID).UID); temp.SetAttribute("Deviceid", ((PSP_PowerSubstation_Info)subID).UID); n1.SetAttribute("ParentID", temp.GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; //PSP_ElcDevice elcDEV = new PSP_ElcDevice(); //elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid; //elcDEV.DeviceSUID = ((PSP_PowerSubstation_Info)subID).UID; //Services.BaseService.Create<PSP_ElcDevice>(elcDEV); //AddLine(temp, elcDEV.DeviceSUID); } else { tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); return; } bool projectexitflag = false; //检验此变电站是否在项目中 foreach (eleclass ele in Powcol) { if (ele.suid == ((PSP_PowerSubstation_Info)subID).UID && ele.selectflag == true) { projectexitflag = true; MessageBox.Show("已经选择此发电厂,请重新选择其他的发电厂!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } else if (ele.suid == ((PSP_PowerSubstation_Info)subID).UID && ele.selectflag == false) { projectexitflag = true; Subcol.Remove(ele); eleclass ele1 = new eleclass(((PSP_PowerSubstation_Info)subID).Title, ((PSP_PowerSubstation_Info)subID).UID, "30", true); Subcol.Add(ele1); PSP_ElcDevice elcDEV = new PSP_ElcDevice(); elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid; elcDEV.DeviceSUID = ((PSP_PowerSubstation_Info)subID).UID; Services.BaseService.Create<PSP_ElcDevice>(elcDEV); AddLine(temp, elcDEV.DeviceSUID); } } if (!projectexitflag) { MessageBox.Show("你所选择的项目中不包括此发电厂!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.CurrentElement = temp as SvgElement; tlVectorControl1.Delete(); tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; tlVectorControl1.Delete(); } } }
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(); } }
void mouseAreaControl_OnAddElement(object sender, AddSvgElementEventArgs e) { if (OnAddElement!=null) { OnAddElement(sender,e); } }