void tlVectorControl1_RightClick(object sender, SvgElementSelectedEventArgs e) { if ((tlVectorControl1.SVGDocument.CurrentElement is Use || tlVectorControl1.SVGDocument.CurrentElement is Polyline) && tlVectorControl1.Operation != ToolOperation.PolyLine) { contextMenuStrip1.Show(); //if (fileType == true) //{ // moveMenuItem.Enabled = false; //} //else //{ // moveMenuItem.Enabled = true; //} if (fileType == true) { printToolStripMenuItem.Visible = false; moveMenuItem.Visible = false; Duluqi.Visible = false; } else { printToolStripMenuItem.Visible = false; moveMenuItem.Visible = true; } //if (tlVectorControl1.SVGDocument.CurrentElement XmlElement temp = tlVectorControl1.SVGDocument.CurrentElement as XmlElement; if (temp.GetAttribute("xlink:href").Contains("motherlinenode")) { Ssubstation.Visible = false; Duluqi.Visible = false; } if (temp.GetAttribute("xlink:href").Contains("Polyline") || temp.GetAttribute("xlink:href").Contains("dynamotorline") || temp.GetAttribute("xlink:href").Contains("gndline") || temp.GetAttribute("xlink:href").Contains("loadline") || temp.GetAttribute("xlink:href").Contains("串联电容电抗器") || temp.GetAttribute("xlink:href").Contains("并联电容电抗器") || temp.GetAttribute("xlink:href").Contains("transformerthirdzu") || temp.GetAttribute("xlink:href").Contains("transformertwozu") || temp.GetAttribute("xlink:href").Contains("1/2母联开关") || temp.GetAttribute("xlink:href").Contains("2/3母联开关")) { moveMenuItem.Visible = false; Duluqi.Visible = false; Ssubstation.Visible = false; } } }
void tlVectorControl1_DoubleLeftClick(object sender, SvgElementSelectedEventArgs e) { elementProperty(); }
void tlVectorControl1_LeftClick(object sender, SvgElementSelectedEventArgs e) { }
private void drawArea1_RightClick(object sender, SvgElementSelectedEventArgs e) { if(this.RightClick!=null) { RightClick(this,e); } }
void tlVectorControl1_RightClick(object sender, SvgElementSelectedEventArgs e) { if (tlVectorControl1.SVGDocument.CurrentElement is Use) { contextMenuStrip1.Show(); } else if (tlVectorControl1.SVGDocument.CurrentElement is Polyline) { contextMenuStrip1.Hide(); tlVectorControl1.Operation = ToolOperation.Select; } else if (tlVectorControl1.SVGDocument.CurrentElement is RectangleElement) { printToolStripMenuItem.Visible = true; } }
private void drawArea1_DoubleLeftClick(object sender, SvgElementSelectedEventArgs e) { if(this.DoubleLeftClick!=null) { DoubleLeftClick(this,e); } }
private void drawArea1_MoveOver(object sender, SvgElementSelectedEventArgs e) { if(this.MoveOver!=null) { MoveOver(this,e); } }
void tlVectorControl1_RightClick(object sender, SvgElementSelectedEventArgs e) { if (Operateflag && tlVectorControl1.CurrentOperation == ToolOperation.AreaSelect) { DelLinenum.Clear(); DelTransnum.Clear(); contextMenuStrip1.Visible = false; SvgElementCollection svgelcollect = tlVectorControl1.SVGDocument.SelectCollection; if (svgelcollect.Count == 0) { MessageBox.Show("请选择区域!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } PSPDEV psp = new PSPDEV(); psp.Type = "Polyline"; psp.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; int n = 0; for (int j = 0; j < svgelcollect.Count; j++) //记录要进行断开的线路 { if (svgelcollect[j].GetType().FullName == "ItopVector.Core.Figure.Polyline") { XmlElement e1 = (XmlElement)svgelcollect[j]; string str_id = e1.GetAttribute("id"); psp.EleID = str_id; PSPDEV dlg11 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", psp); if (dlg11 != null) { if (dlg11.LineStatus == "运行") { DelLinenum.Add(dlg11.Number); } n++; } } if (svgelcollect[j].GetType().FullName == "ItopVector.Core.Figure.TransformLine") { XmlElement e1 = (XmlElement)svgelcollect[j]; string str_id = e1.GetAttribute("id"); psp.EleID = str_id; PSPDEV dlg11 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", psp); if (dlg11 != null) { DelTransnum.Add(dlg11.Number); n++; } } } if (n == 0) { MessageBox.Show("你所选择的区域没有你要断开的线路", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.CurrentOperation = ToolOperation.Select; return; } else { DelLinenum.Sort(); DelTransnum.Sort(); //进行区域N-1检验 QyRelanalyst(); tlVectorControl1.CurrentOperation = ToolOperation.Select; return; } } if ((tlVectorControl1.SVGDocument.CurrentElement is Use || tlVectorControl1.SVGDocument.CurrentElement is Polyline) && tlVectorControl1.Operation != ToolOperation.PolyLine) { contextMenuStrip1.Show(); //if (fileType == true) //{ // moveMenuItem.Enabled = false; //} //else //{ // moveMenuItem.Enabled = true; //} if (fileType == true) { printToolStripMenuItem.Visible = false; moveMenuItem.Visible = false; } else { printToolStripMenuItem.Visible = false; moveMenuItem.Visible = true; } //if (tlVectorControl1.SVGDocument.CurrentElement } else { //contextMenuStrip1.Hide(); if ((tlVectorControl1.SVGDocument.CurrentElement is RectangleElement)) { contextMenuStrip1.Show(); printToolStripMenuItem.Visible = true; moveMenuItem.Visible = false; } } if (tlVectorControl1.Operation == ToolOperation.PolyLine && tlVectorControl1.SVGDocument.CurrentElement is Polyline && fileType == true) { tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.ChangeLevel(LevelType.Bottom); PointF[] t = (tlVectorControl1.SVGDocument.CurrentElement as Polyline).Pt; PSPDEV pspDev = new PSPDEV(); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.Type = "Polyline"; pspDev.FirstNode = -1; pspDev.LastNode = -1; frmLinenew dlg = new frmLinenew(pspDev); dlg.derefucelineflag = Reducelineflag; if (dlg.ShowDialog(this) == DialogResult.OK) { XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text"); PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Polyline"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.Delete(); return; } //if (element.Count > 0) //{ // foreach (XmlNode node in element) // { // if (node.InnerText == dlg.TextInput) // { // MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // tlVectorControl1.Delete(); // return; // } // } //} pspDev.Name = dlg.Name; pspDev.Number = -1; pspDev.Type = "Polyline"; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID; pspDev.SUID = Guid.NewGuid().ToString(); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.X1 = t[0].X; pspDev.Y1 = t[0].Y; pspDev.X2 = t[1].X; pspDev.Y2 = t[1].Y; pspDev.Lable = "支路"; if (dlg.LineLength != "") pspDev.LineLength = Convert.ToDouble(dlg.LineLength); string tempp = dlg.LineLev; int tel = tempp.Length; //tempp = tempp.Substring(0, tel - 2); pspDev.VoltR = Convert.ToDouble(tempp); if (dlg.LineR != "") pspDev.LineR = Convert.ToDouble(dlg.LineR); if (dlg.LineTQ != "") pspDev.LineTQ = Convert.ToDouble(dlg.LineTQ); if (dlg.LineGNDC != "") pspDev.LineGNDC = Convert.ToDouble(dlg.LineGNDC); if (dlg.LineLevel != "") pspDev.LineLevel = dlg.LineLevel; if (dlg.LineType != "") pspDev.LineType = dlg.LineType; if (dlg.LineStatus != "") pspDev.LineStatus = dlg.LineStatus; if (dlg.linevalue != "") { pspDev.BigP = Convert.ToDouble(dlg.linevalue); } if (dlg.ReferenceVolt != "") { pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); } if (dlg.LineType != "") { WireCategory wirewire = new WireCategory(); wirewire.WireType = dlg.LineType; WireCategory wirewire2 = new WireCategory(); wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); if (wirewire2 != null) pspDev.LineChange = (double)wirewire2.WireChange; //switch (dlg.LineType) //{ // case "2*LGJ-400": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.04; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.303; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.054; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.308; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.066; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.310; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.08; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.417; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} } Services.BaseService.Create<PSPDEV>(pspDev); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg.TYear); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("linevalue", dlg.linevalue); Topology2(); } else { tlVectorControl1.Delete(); } return; } if (tlVectorControl1.Operation == ToolOperation.PolyLine && tlVectorControl1.SVGDocument.CurrentElement is Polyline && fileType != true) { tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.ChangeLevel(LevelType.Bottom); PointF[] t = (tlVectorControl1.SVGDocument.CurrentElement as Polyline).Pt; PSPDEV pspDev = new PSPDEV(); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.Type = "Polyline"; pspDev.FirstNode = -1; pspDev.LastNode = -1; frmLine dlg = new frmLine(pspDev); if (dlg.ShowDialog(this) == DialogResult.OK) { XmlNodeList element = tlVectorControl1.SVGDocument.GetElementsByTagName("text"); PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Polyline"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.Delete(); return; } //if (element.Count > 0) //{ // foreach (XmlNode node in element) // { // if (node.InnerText == dlg.TextInput) // { // MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // tlVectorControl1.Delete(); // return; // } // } //} pspDev.Name = dlg.Name; pspDev.Number = -1; pspDev.Type = "Polyline"; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID; pspDev.SUID = Guid.NewGuid().ToString(); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.X1 = t[0].X; pspDev.Y1 = t[0].Y; pspDev.X2 = t[1].X; pspDev.Y2 = t[1].Y; pspDev.Lable = "支路"; if (dlg.LineLength != "") pspDev.LineLength = Convert.ToDouble(dlg.LineLength); if (dlg.LineLevel != "") pspDev.LineLevel = dlg.LineLevel; if (dlg.LineType != "") pspDev.LineType = dlg.LineType; if (dlg.LineStatus != "") pspDev.LineStatus = dlg.LineStatus; if (dlg.PositiveR != "") pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR); if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); if (dlg.PositiveES != "") { pspDev.SmallTQ = Convert.ToDouble(dlg.PositiveES); } if (dlg.ZeroR != "") pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR); if (dlg.ZeroTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); if (dlg.ZeroES != "") { pspDev.BigTQ = Convert.ToDouble(dlg.ZeroES); } if (dlg.HuganFirst == "是") pspDev.HuganFirst = 1; else pspDev.HuganFirst = 0; if (dlg.HuganLine1 != "") pspDev.HuganLine1 = dlg.HuganLine1; if (dlg.HuganLine2 != "") pspDev.HuganLine2 = dlg.HuganLine2; if (dlg.HuganLine3 != "") pspDev.HuganLine3 = dlg.HuganLine3; if (dlg.HuganLine4 != "") pspDev.HuganLine4 = dlg.HuganLine4; if (dlg.HuganTQ1 != "") pspDev.HuganTQ1 = Convert.ToDouble(dlg.HuganTQ1); if (dlg.HuganTQ2 != "") pspDev.HuganTQ2 = Convert.ToDouble(dlg.HuganTQ2); if (dlg.HuganTQ3 != "") pspDev.HuganTQ3 = Convert.ToDouble(dlg.HuganTQ3); if (dlg.HuganTQ4 != "") pspDev.HuganTQ4 = Convert.ToDouble(dlg.HuganTQ4); if (dlg.HuganTQ5 != "") pspDev.HuganTQ5 = Convert.ToDouble(dlg.HuganTQ5); pspDev.KName = dlg.ISwitchStatus; pspDev.KSwitchStatus = dlg.JSwitchStatus; if (dlg.LineType != "") { WireCategory wirewire = new WireCategory(); wirewire.WireType = dlg.LineType; WireCategory wirewire2 = new WireCategory(); wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); if (wirewire2 != null) pspDev.LineChange = (double)wirewire2.WireChange; //switch (dlg.LineType) //{ // case "2*LGJ-400": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.04; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.303; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.054; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.308; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.066; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.310; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // if (pspDev.LineR == 0 && dlg.LineLength != "") // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.08; // if (pspDev.LineTQ == 0 && dlg.LineLength != "") // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.417; // if (pspDev.LineGNDC == 0 && dlg.LineLength != "") // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} } string tempp = dlg.LineLev; int tel = tempp.Length; if (tel == 1) pspDev.VoltR = 0; else { // tempp = tempp.Substring(0, tel - 2); pspDev.VoltR = Convert.ToDouble(tempp); } if (pspDev.PositiveTQ == 0) pspDev.PositiveTQ = pspDev.LineTQ; Services.BaseService.Create<PSPDEV>(pspDev); Topology2(); } else { tlVectorControl1.Delete(); } return; } }
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(); } } }
//void DrawArea_OnMouseMove(object sender, MouseEventArgs e) //{ //} void tlVectorControl1_DoubleLeftClick(object sender, SvgElementSelectedEventArgs e) { if (!Check()) { return; } XmlElement element = tlVectorControl1.SVGDocument.CurrentElement; if (element is Use) { if (element.GetAttribute("xlink:href").Contains("Substation") || element.GetAttribute("xlink:href").Contains("motherlinenode")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmSubstation dlg; if (pspDev != null) { dlg = new frmSubstation(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Use"; if (element.GetAttribute("xlink:href").Contains("Substation")) { pspDev.Lable = "变电站"; } else if (element.GetAttribute("xlink:href").Contains("motherlinenode")) { pspDev.Lable = "母线节点"; } else if (element.GetAttribute("xlink:href").Contains("Power")) { pspDev.Lable = "电厂"; } //Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmSubstation(pspDev); } dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Use"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } PSPDEV powerfactor = new PSPDEV(); powerfactor.Type = "Power"; powerfactor.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; powerfactor = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDAndType", powerfactor); pspDev.VoltR = Convert.ToDouble(dlg.VoltR); pspDev.Burthen = Convert.ToDecimal(dlg.Burthen); //if (powerfactor!=null && (Convert.ToDecimal(dlg.Change)==2)) //pspDev.InPutP = Convert.ToDouble(dlg.Burthen) * powerfactor.BigP; //if (Convert.ToDecimal(dlg.Change)==1) pspDev.InPutP = Convert.ToDouble(dlg.InPutP); pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); pspDev.OutP = Convert.ToDouble(dlg.OutP); pspDev.OutQ = Convert.ToDouble(dlg.OutQ); pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); if (dlg.NodeType == "是") { pspDev.NodeType = "0"; } else { pspDev.NodeType = "1"; } Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("Power")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmSubstation dlg; if (pspDev != null) { dlg = new frmSubstation(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Use"; if (element.GetAttribute("xlink:href").Contains("Substation")) { pspDev.Lable = "变电站"; } else if (element.GetAttribute("xlink:href").Contains("motherlinenode")) { pspDev.Lable = "母线节点"; } else if (element.GetAttribute("xlink:href").Contains("Power")) { pspDev.Lable = "电厂"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmSubstation(pspDev); dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Use"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.VoltR = Convert.ToDouble(dlg.VoltR); pspDev.Burthen = Convert.ToDecimal(dlg.Burthen); pspDev.OutP = Convert.ToDouble(dlg.OutP); pspDev.OutQ = Convert.ToDouble(dlg.OutQ); pspDev.InPutP = Convert.ToDouble(dlg.InPutP); pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); if (dlg.NodeType == "是") { pspDev.NodeType = "0"; } else { pspDev.NodeType = "2"; } Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmFadejie dlg; if (pspDev != null) { dlg = new frmFadejie(pspDev, pspDev.SvgUID); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "dynamotorline"; if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { pspDev.Lable = "发电厂支路"; } else if (element.GetAttribute("xlink:href").Contains("gndline")) { pspDev.Lable = "接地支路"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmFadejie(pspDev, pspDev.SvgUID); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "dynamotorline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; if (dlg.OutP != "") pspDev.OutP = Convert.ToDouble(dlg.OutP); if (dlg.OutQ != "") pspDev.OutQ = Convert.ToDouble(dlg.OutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); if (dlg.VoltV != "") pspDev.VoltV = Convert.ToDouble(dlg.VoltV); if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); if (dlg.NegativeTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("gndline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmFadejie dlg; if (pspDev != null) { dlg = new frmFadejie(pspDev, pspDev.SvgUID); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "gndline"; if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { pspDev.Lable = "发电厂支路"; } else if (element.GetAttribute("xlink:href").Contains("gndline")) { pspDev.Lable = "接地支路"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmFadejie(pspDev, pspDev.SvgUID); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "gndline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; if (dlg.OutP != "") pspDev.OutP = Convert.ToDouble(dlg.OutP); if (dlg.OutQ != "") pspDev.OutQ = Convert.ToDouble(dlg.OutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); if (dlg.VoltV != "") pspDev.VoltV = Convert.ToDouble(dlg.VoltV); if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); if (dlg.NegativeTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("loadline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLoad dlg; if (pspDev != null) { dlg = new frmLoad(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "loadline"; pspDev.Lable = "负荷支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmLoad(pspDev); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "loadline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.LoadSwitchState; if (dlg.InPutP != "") pspDev.InPutP = Convert.ToDouble(dlg.InPutP); if (dlg.InPutQ != "") pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("串联电容电抗器")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmCapacity dlg; if (pspDev != null) { dlg = new frmCapacity(pspDev, pspDev.SvgUID); dlg.SetEnable(true); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "串联电容电抗器"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; // pspDev.HuganLine2 = dlg.LastNodeName; if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("并联电容电抗器")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmCapacity dlg; if (pspDev != null) { dlg = new frmCapacity(pspDev, pspDev.SvgUID); dlg.SetEnable(false); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "并联电容电抗器"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; // pspDev.HuganLine2 = dlg.LastNodeName; if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("transformerthirdzu")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmThridTra dlg; if (pspDev != null) { dlg = new frmThridTra(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "transformerthirdzu"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.IName; pspDev.HuganLine2 = dlg.JName; pspDev.HuganLine3 = dlg.ISwitchState; pspDev.HuganLine4 = dlg.JSwitchState; pspDev.LineLevel = dlg.IType; pspDev.LineType = dlg.JType; pspDev.LineStatus = dlg.KType; pspDev.KName = dlg.KName; pspDev.KSwitchStatus = dlg.KSwitchState; if (dlg.IK != "") { pspDev.K = Convert.ToDouble(dlg.KK); } if (dlg.JK != "") { pspDev.G = Convert.ToDouble(dlg.JK); } if (dlg.KK != "") { pspDev.BigP = Convert.ToDouble(dlg.KK); } if (dlg.IR != "") { pspDev.HuganTQ1 = Convert.ToDouble(dlg.IR); } if (dlg.JR != "") { pspDev.HuganTQ2 = Convert.ToDouble(dlg.JR); } if (dlg.KR != "") { pspDev.HuganTQ3 = Convert.ToDouble(dlg.KR); } if (dlg.ITQ != "") { pspDev.HuganTQ4 = Convert.ToDouble(dlg.ITQ); } if (dlg.JTQ != "") { pspDev.HuganTQ5 = Convert.ToDouble(dlg.JTQ); } if (dlg.KTQ != "") { pspDev.SmallTQ = Convert.ToDouble(dlg.KTQ); } if (dlg.ZeroTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); if (dlg.NeutralNodeTQ != "") pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("transformertwozu")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmTwoTra dlg; if (pspDev != null) { dlg = new frmTwoTra(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "transformertwozu"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstName; pspDev.HuganLine2 = dlg.LastName; pspDev.HuganLine3 = dlg.FirstSwitchState; pspDev.HuganLine4 = dlg.LastSwitchState; pspDev.LineLevel = dlg.FirstType; pspDev.LineType = dlg.LastType; if (dlg.PositiveR != "") { pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR); } if (dlg.PositiveTQ != "") { pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); } if (dlg.ZeroR != "") { pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR); } if (dlg.ZeroTQ != "") { pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); } if (dlg.K != "") pspDev.K = Convert.ToDouble(dlg.K); if (dlg.NeutralNodeTQ != "") pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("1/2母联开关")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmMuLian dlg; if (pspDev != null) { dlg = new frmMuLian(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "1/2母联开关"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine2 = dlg.LastNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("2/3母联开关")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmMuLian2 dlg; if (pspDev != null) { dlg = new frmMuLian2(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "2/3母联开关"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.INodeName; pspDev.HuganLine2 = dlg.JNodeName; pspDev.HuganLine3 = dlg.ILineName; pspDev.HuganLine4 = dlg.JLineName; pspDev.KName = dlg.ILoadName; pspDev.KSwitchStatus = dlg.JLoadName; pspDev.LineLevel = dlg.SwitchStatus1; pspDev.LineType = dlg.SwitchStatus2; pspDev.LineStatus = dlg.SwitchStatus3; Services.BaseService.Update<PSPDEV>(pspDev); } } } else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType == true)//潮流下线路 { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLinenew dlg2; if (pspDev != null) { dlg2 = new frmLinenew(pspDev); dlg2.derefucelineflag = Reducelineflag; } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Polyline"; pspDev.Lable = "支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg2 = new frmLinenew(pspDev); dlg2.derefucelineflag = Reducelineflag; } dlg2.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); dlg2.linevalue = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("linevalue"); //获得线路投资 if (dlg2.ShowDialog() == DialogResult.OK) { if (dlg2.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg2.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Polyline"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg2.Name; pspDev.LineLength = Convert.ToDouble(dlg2.LineLength); pspDev.LineR = Convert.ToDouble(dlg2.LineR); pspDev.LineTQ = Convert.ToDouble(dlg2.LineTQ); pspDev.LineGNDC = Convert.ToDouble(dlg2.LineGNDC); pspDev.LineLevel = dlg2.LineLevel; pspDev.LineType = dlg2.LineType; pspDev.LineStatus = dlg2.LineStatus; pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt); if (dlg2.linevalue != "") { pspDev.BigP = Convert.ToDouble(dlg2.linevalue); } WireCategory wirewire = new WireCategory(); wirewire.WireType = dlg2.LineType; WireCategory wirewire2 = new WireCategory(); wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); //if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength)*wirewire2.WireR ; //if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireTQ; //if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireGNDC; if (wirewire2 != null) pspDev.LineChange =(double) wirewire2.WireChange; string tempp = dlg2.LineLev; int tel = tempp.Length; // tempp = tempp.Substring(0, tel - 2); pspDev.VoltR = Convert.ToDouble(tempp); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg2.TYear); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("linevalue", dlg2.linevalue); //获得线路投资 //switch (dlg2.LineType) //{ // case "2*LGJ-400": // { // if (pspDev.LineR==0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.04; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.303; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.054; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.308; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.066; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.310; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.08; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.417; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} Services.BaseService.Update<PSPDEV>(pspDev); Topology2(); } } else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType != true)//短路下线路 { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLine dlg; if (pspDev != null) { dlg = new frmLine(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Polyline"; pspDev.Lable = "支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmLine(pspDev); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Polyline"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; pspDev.LineLength = Convert.ToDouble(dlg.LineLength); pspDev.LineLevel = dlg.LineLevel; pspDev.LineType = dlg.LineType; pspDev.LineStatus = dlg.LineStatus; pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR); pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR); pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); if (dlg.HuganFirst == "是") pspDev.HuganFirst = 1; else pspDev.HuganFirst = 0; pspDev.HuganLine1 = dlg.HuganLine1; pspDev.HuganLine2 = dlg.HuganLine2; pspDev.HuganLine3 = dlg.HuganLine3; pspDev.HuganLine4 = dlg.HuganLine4; pspDev.HuganTQ1 = Convert.ToDouble(dlg.HuganTQ1); pspDev.HuganTQ2 = Convert.ToDouble(dlg.HuganTQ2); pspDev.HuganTQ3 = Convert.ToDouble(dlg.HuganTQ3); pspDev.HuganTQ4 = Convert.ToDouble(dlg.HuganTQ4); pspDev.HuganTQ5 = Convert.ToDouble(dlg.HuganTQ5); string tempp = dlg.LineLev; int tel = tempp.Length; if (tel == 1) pspDev.VoltR = 0; else { //tempp = tempp.Substring(0, tel - 2); pspDev.VoltR = Convert.ToDouble(tempp); } //switch (dlg.LineType) //{ // case "2*LGJ-400": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.04; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.303; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.054; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.308; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.066; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.310; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.08; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.417; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} Services.BaseService.Update<PSPDEV>(pspDev); Topology2(); } } }
internal void OnMoveOver(ISvgElement element, MouseEventArgs e) { SvgElementSelectedEventArgs args =new SvgElementSelectedEventArgs(element); args.Mouse=e; if (MoveOver!=null) { MoveOver(this,args); } }
/**/ [Browsable(false)] public ToolOperation CurrentOperation { get { return this.Operation; } set { this.Operation = value; } } [Browsable(false)] public Color DocumentbgColor { get { // TODO: ��� ItopVectorControl.DocumentbgColor getter ʵ�� return new Color(); } set { // TODO: ��� ItopVectorControl.DocumentbgColor setter ʵ�� } } [Browsable(false)] public SizeF DocumentSize { get { return Size.Round(this.viewSize); } set { if(this.svgDocument==null)return; ItopVector.Core.Figure.SVG svg =this.SVGDocument.RootElement as ItopVector.Core.Figure.SVG; SizeF size1=value; if(svg !=null) { svg.Width = size1.Width; svg.Height = size1.Height; this.FitWindow(); } } } [Browsable(false)] public Size DocumentSizeEx { get { return Size.Round(this.viewSize); } } public DrawModeType DrawMode { get{return drawMode;} set{drawMode =value;} } public SvgElementCollection ElementList { get { if (this.viewer == null) { return new SvgElementCollection(); } return this.viewer.ElementList; } } [Browsable(false)] public SolidColor Fill { get { return (SolidColor) this.FillBrush; } set { if (value == null || this.FillBrush == value) return; this.FillBrush = value; if(this.svgDocument!=null && this.preGraph!=null) { this.svgDocument.AcceptChanges=false; ((IGraphPath) preGraph).GraphBrush = this.FillBrush.Clone(); } } } [Browsable(false)] public bool FreeSelect { get{return freeSelect;} set{freeSelect =value; if(this.mouseAreaControl.SelectOperation!=null) this.mouseAreaControl.SelectOperation.FreeSelect =value; } } public bool FullDrawMode { set { this.fullDrawMode=value; } get { return this.fullDrawMode; } } public SizeF GridSize { get { return this.gridSize; } set { if (this.gridSize != value) { this.gridSize = value; base.Invalidate(); } } } public float Indent { get{return this.indent;} set { if(value<0.05f || value>1f)return; this.indent = value; if(this.operation==ToolOperation.EqualPolygon) { (preGraph as Polygon).Indent = indent; } } } public bool IsModified { get { return !this.svgDocument.Update; } set { this.svgDocument.Update = !value; } } public bool IsPasteGrid { get { return this.SnapToGrid; } set { this.SnapToGrid = value; } } public bool IsShowGrid { get { return this.ShowGrid; } set { this.ShowGrid = value; } } public bool IsShowRule { get { return this.ShowRule; } set { this.ShowRule = value; } } public bool IsShowTip { get { // TODO: ��� ItopVectorControl.IsShowTip getter ʵ�� return false; } set { // TODO: ��� ItopVectorControl.IsShowTip setter ʵ�� } } public int LineCount { get{return this.lineCount;} set { if(value<3 || value>20)return; this.lineCount = value; if(this.operation==ToolOperation.EqualPolygon) { (preGraph as Polygon).LineCount = lineCount; } } } public ToolOperation Operation { get { return this.operation; } set { if (this.operation != value) { this.operation = value; CreatePreGraph(); this.mouseAreaControl.CurrentOperation = value; this.viewer.Invalidate(); if (this.OperationChanged != null) { this.OperationChanged(this, new EventArgs()); } } } } public IGraph PreGraph { get { return this.preGraph; } set { if (value is Symbol) { this.Operation = ToolOperation.Symbol; } if (this.preGraph != value) { this.preGraph = value; if (value != null) { value.GraphTransform.Matrix.Reset(); value.GraphTransform.setMatrix(this.coordTransform); } if (this.GraphChanged != null) { this.GraphChanged(this, new EventArgs()); } } } } [Browsable(false)] public PropertyGrid PropertyGrid { get { return propertyGrid; } set { if (propertyGrid != null) { // propertyGrid.PropertyValueChanged-=new PropertyValueChangedEventHandler(propertyGrid_PropertyValueChanged); } if (propertyGrid == value) return; propertyGrid = value; if (propertyGrid != null) { // propertyGrid.PropertyValueChanged+=new PropertyValueChangedEventHandler(propertyGrid_PropertyValueChanged); propertyGrid.SelectedObjects = null; } } } public Struct.TextStyle RatFont { get { return this.RatTextStyle; } set { this.RatTextStyle = value; } } [Browsable(false)] public float ScaleRatio { get { return this.ScaleUnit; } set { this.ScaleUnit = value; } } public float ScaleUnit { get { return this.scale; } set { float single1 = value; if ((single1 >= 2000f) || (single1 < 0.0025f)) { if ((this.Operation == ToolOperation.IncreaseView) || ((this.Operation == ToolOperation.DecreaseView) && (this.svgDocument != null))) { this.mouseAreaControl.Cursor = SpecialCursors.NoViewChangeCursor; } single1 = (single1 >= 2000f) ? 200f : 0.0025f; } if (single1 !=0.0025f) single1 = (float) Math.Round((double) single1, 8); if (this.scale != single1) { this.oldScale = this.scale; this.scale = single1; if(this.operation!=ToolOperation.WindowZoom) { this.SetScroll(); } //base.Invalidate(); this.hRule.Invalidate(); this.vRule.Invalidate(); this.viewer.ScaleUnit = single1; if (this.ScaleChanged != null) { this.ScaleChanged(this, new EventArgs()); } } } } [Browsable(false)] public bool Scrollable { get { // TODO: ��� ItopVectorControl.Scrollable getter ʵ�� return false; } set { // TODO: ��� ItopVectorControl.Scrollable setter ʵ�� } } public bool SelectChanged { set { this.viewer.selectChanged = true; } } public RectangleF SelectedRectangle { get{return viewer.SelectedRectangle;} } public Matrix SelectMatrix { get { if (this.viewer != null) { return this.viewer.SelectMatrix.Clone(); } return new Matrix(); } } public GraphicsPath SelectPath { get { if (this.viewer != null) { return (GraphicsPath) this.viewer.SelectPath.Clone(); } return new GraphicsPath(); } } public bool ShowGrid { get { return this.showGrid; } set { if (this.showGrid != value) { this.showGrid = value; base.Invalidate(); } } } public bool ShowGuides { get { return this.showGuides; } set { if (this.showGuides != value) { this.showGuides = value; } } } public bool ShowRule { get { return this.showRule; } set { bool flag1; bool flag2; this.showRule = value; this.label2.Visible = flag1 = value; this.vRule.Visible = flag2 = flag1; this.hRule.Visible = flag2; } } [Browsable(false)] public System.Drawing.Drawing2D.SmoothingMode SmoothingMode { get { return this.svgDocument.SmoothingMode; } set { this.svgDocument.SmoothingMode = value; } } [Browsable(false)] public Stroke Stroke { get { return this.stroke; } set { if (value == null || this.stroke == value) return; this.stroke = value; if(this.svgDocument!=null && this.preGraph!=null) { this.svgDocument.AcceptChanges=false; ((IGraphPath) preGraph).GraphStroke = this.stroke.Clone() as Stroke; } } } public SvgDocument SVGDocument { get { return this.svgDocument; } set { if (this.svgDocument != value) { if (this.svgDocument!=null) { svgDocument=null; GC.Collect(); } SvgDocument document1; this.svgDocument = document1 = value; this.viewer.SVGDocument = document1; base.Invalidate(); this.viewer.Invalidate(); if (value != null) { value.SelectCollection.OnCollectionChangedEvent += new OnCollectionChangedEventHandler(this.ChangeSelect); } } } } [Browsable(false)] public ItopVector.Selector.SymbolSelector SymbolSelector { get{return this.symbolSelector;} set { if(value==null || value==this.symbolSelector)return; this.symbolSelector=value; } } public Graphics tempGraphics { get{return viewer.tempGra();} } public Pen TempPen { set{viewer.TempPen=value;} } [Browsable(false)] public Struct.TextStyle TextFont { get { return this.RatFont; } set { this.RatTextStyle = value; } } [Browsable(false)] public Struct.TextStyle TextStyle { get { return this.RatTextStyle; } set { this.RatTextStyle = value; } } [Browsable(false)] public Size ViewMargin { get {return this.margin;} set { this.margin =value; this.viewer.margin = value; } } public SizeF ViewSize { get { if (this.svgDocument != null) { if (this.svgDocument.OnlyShowCurrent) { IViewportElement element1 = this.svgDocument.RootElement.ViewportElement; if (element1 != null) { this.viewSize = new SizeF(element1.ViewPort.Width, element1.ViewPort.Height); } } else { SVG svg1 = (SVG) this.svgDocument.DocumentElement; if(svg1 !=null) this.viewSize = new SizeF(svg1.Width, svg1.Height); } } return this.viewSize; } } public float VirtualLeft { get { return this.virtualLeft; } set { if (this.virtualLeft != value) { this.virtualLeft = Math.Max(0, value); base.Invalidate(); this.viewer.VirtualLeft = value; } } } public float VirtualTop { get { return this.virtualTop; } set { if (this.virtualTop != value) { this.virtualTop = Math.Max(0, value); base.Invalidate(); this.viewer.VirtualTop = value; } } } internal PageSettings PageSettings { get { return this.pageSetting; } set { if(value==null)return; this.pageSetting = value; } } #endregion Properties #region Methods public SvgElement AddElement(ISvgElement mypath) { if (BeforeAddSvgElement!=null) { AddSvgElementEventArgs e = new AddSvgElementEventArgs(mypath); BeforeAddSvgElement(this,e); if (e.Cancel)return null; } AttributeFunc.SetAttributeValue((XmlElement)mypath,"layer",SvgDocument.currentLayer); XmlNode node1 = this.svgDocument.RootElement; XmlNode newNode =null; if (!this.svgDocument.OnlyShowCurrent) { node1 = this.svgDocument.DocumentElement; } if (!(node1 is ContainerElement)) { MessageBox.Show(DrawAreaConfig.GetLabelForName("addelement").Trim()); } else { if (this.svgDocument.SelectCollection.Count > 0) { SvgElement element1 = (SvgElement) this.svgDocument.SelectCollection[0]; if (this.svgDocument.FlowChilds.IndexOf(element1) >= 0) { for (node1 = element1; (!(node1 is ItopVector.Core.Interface.IContainer) || (node1 is Text)) && (node1 != null); node1 = node1.ParentNode) { } } } if (node1 == null) { node1 = this.svgDocument.RootElement; } Matrix matrix1 = new Matrix(); if (node1 is IGraph) { matrix1 = ((IGraph) node1).GraphTransform.Matrix.Clone(); Matrix matrix2 = this.coordTransform.Clone(); matrix2.Invert(); matrix1.Multiply(matrix2, MatrixOrder.Append); } matrix1.Invert(); matrix1 = TransformFunc.RoundMatrix(matrix1, 2); bool flag1 = this.svgDocument.AcceptChanges; // this.SVGDocument.AcceptChanges = false; this.svgDocument.AcceptChanges = true; if (mypath is IGraphPath) { ISvgBrush brush1 = ((IGraphPath) mypath).GraphBrush; if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null)) { bool flag2 = this.svgDocument.AcceptChanges; this.svgDocument.AcceptChanges = true; this.svgDocument.NumberOfUndoOperations++; XmlNode node2 = this.SVGDocument.AddDefsElement((SvgElement) brush1); this.svgDocument.AcceptChanges = false; if (node2 is ITransformBrush) { string text1 = ((SvgElement) node2).ID; AttributeFunc.SetAttributeValue((SvgElement) mypath, "fill", "url(#" + text1 + ")"); } this.svgDocument.AcceptChanges = flag2; } brush1 = ((IGraphPath) mypath).GraphStroke.Brush; if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null)) { bool flag3 = this.svgDocument.AcceptChanges; this.svgDocument.AcceptChanges = true; this.svgDocument.NumberOfUndoOperations++; XmlNode node3 = this.SVGDocument.AddDefsElement((SvgElement) brush1); this.svgDocument.AcceptChanges = false; if (node3 is ITransformBrush) { string text2 = ((SvgElement) node3).ID; AttributeFunc.SetAttributeValue((SvgElement) mypath, "stroke", "url(#" + text2 + ")"); } this.svgDocument.AcceptChanges = flag3; } } if (!matrix1.IsIdentity && (mypath is IGraph)) { bool flag4 = this.svgDocument.AcceptChanges; this.svgDocument.AcceptChanges = false; Matrix matrix3 = ((IGraph) mypath).Transform.Matrix.Clone(); matrix1.Multiply(matrix3); Transf transf1 = new Transf(); transf1.setMatrix(matrix1); AttributeFunc.SetAttributeValue((SvgElement) mypath, "transform", transf1.ToString()); this.svgDocument.AcceptChanges = flag4; } if (((SvgElement) mypath).ParentNode != node1) { if (((ContainerElement) node1).IsValidChild((SvgElement) mypath)) { // node1.AppendChild((SvgElement) mypath); SvgElement element1 =(SvgElement) mypath;//(SvgElement)this.svgDocument.ImportNode((SvgElement) mypath,true); newNode = node1.AppendChild(element1); this.svgDocument.Render(element1); if(this.inserting) { this.addedElements.Add(element1); if(OnAddElement!=null) { AddSvgElementEventArgs e = new AddSvgElementEventArgs(element1); OnAddElement(element1,e); } } else { this.svgDocument.CurrentElement = element1; } } else { MessageBox.Show(DrawAreaConfig.GetLabelForName("addelement").Trim()); } } this.SVGDocument.AcceptChanges = flag1; } return newNode!=null?newNode as SvgElement:null; } /// <summary> /// ��������Ԥ����Symbol /// </summary> /// <param name="element"></param> /// <param name="p1"></param> public void AddSymbol(SvgElement element,Point p1) { SvgDocument document1 = this.SVGDocument; IGraph graph1 =(IGraph)element; if (graph1==null)return; if (graph1 is ConnectLine) { Point point2 = p1; ConnectLine connect =document1.ImportNode((SvgElement)graph1,true) as ConnectLine; connect.X1 += point2.X; connect.X2 += point2.X; connect.Y1 += point2.Y; connect.Y2 += point2.Y; this.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 = p1; 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.X = (point1.X - ef1.X) - (ef1.Width / 2f); //use1.Y = (point1.Y - ef1.Y) - (ef1.Height/2f); use1.GraphBrush = this.FillBrush.Clone(); use1.GraphStroke = this.Stroke.Clone() as Stroke; this.AddElement(use1); } } /// <summary> /// ���� /// </summary> /// <param name="align"></param> public void Align(AlignType align) { if (this.svgDocument.SelectCollection.Count<2)return; SvgElementCollection.ISvgElementEnumerator enumerator1=this.svgDocument.SelectCollection.GetEnumerator(); IGraph firstgraph=null; RectangleF rf1=RectangleF.Empty; switch(align) { case AlignType.Left: while(enumerator1.MoveNext()) { SvgElement element1 =enumerator1.Current as SvgElement; if(firstgraph==null) { firstgraph =element1 as IGraph; using (GraphicsPath path1= firstgraph.GPath.Clone() as GraphicsPath) { path1.Transform(getMatrix(firstgraph)); rf1 =path1.GetBounds(); } continue; } IGraph graph1 =element1 as IGraph; if(graph1 !=null) { using(GraphicsPath path2 = graph1.GPath.Clone() as GraphicsPath) { path2.Transform(getMatrix(graph1)); RectangleF rf2=path2.GetBounds(); Transf transf = new Transf(getMatrix(graph1)); transf.Matrix.Translate(rf1.Left - rf2.Left,0,MatrixOrder.Append); graph1.Transform = transf; } } } break; case AlignType.Right: while(enumerator1.MoveNext()) { SvgElement element1 =enumerator1.Current as SvgElement; if(firstgraph==null) { firstgraph =element1 as IGraph; using (GraphicsPath path1= firstgraph.GPath.Clone() as GraphicsPath) { path1.Transform(getMatrix(firstgraph)); rf1 =path1.GetBounds(); } continue; } IGraph graph1 =element1 as IGraph; if(graph1 !=null) { using(GraphicsPath path2 = graph1.GPath.Clone() as GraphicsPath) { path2.Transform(getMatrix(graph1)); RectangleF rf2=path2.GetBounds(); Transf transf=new Transf(getMatrix(graph1)); transf.Matrix.Translate(rf1.Right - rf2.Right,0,MatrixOrder.Append); graph1.Transform = transf; } } } break; case AlignType.Top: while(enumerator1.MoveNext()) { SvgElement element1 =enumerator1.Current as SvgElement; if(firstgraph==null) { firstgraph =element1 as IGraph; using (GraphicsPath path1= firstgraph.GPath.Clone() as GraphicsPath) { path1.Transform(getMatrix(firstgraph)); rf1 =path1.GetBounds(); } continue; } IGraph graph1 =element1 as IGraph; if(graph1 !=null) { using(GraphicsPath path2 = graph1.GPath.Clone() as GraphicsPath) { path2.Transform(getMatrix(graph1)); RectangleF rf2=path2.GetBounds(); Transf transf=new Transf(getMatrix(graph1)); transf.Matrix.Translate(0,rf1.Top - rf2.Top,MatrixOrder.Append); graph1.Transform = transf; } } } break; case AlignType.Bottom: while(enumerator1.MoveNext()) { SvgElement element1 =enumerator1.Current as SvgElement; if(firstgraph==null) { firstgraph =element1 as IGraph; using (GraphicsPath path1= firstgraph.GPath.Clone() as GraphicsPath) { path1.Transform(getMatrix(firstgraph)); rf1 =path1.GetBounds(); } continue; } IGraph graph1 =element1 as IGraph; if(graph1 !=null) { using(GraphicsPath path2 = graph1.GPath.Clone() as GraphicsPath) { path2.Transform(getMatrix(graph1)); RectangleF rf2=path2.GetBounds(); Transf transf=new Transf(getMatrix(graph1)); transf.Matrix.Translate(0,rf1.Bottom - rf2.Bottom,MatrixOrder.Append); graph1.Transform = transf; } } } break; case AlignType.VerticalCenter: float centerx = 0f; while(enumerator1.MoveNext()) { SvgElement element1 =enumerator1.Current as SvgElement; if(firstgraph==null) { firstgraph =element1 as IGraph; using (GraphicsPath path1= firstgraph.GPath.Clone() as GraphicsPath) { path1.Transform(getMatrix(firstgraph)); rf1 =path1.GetBounds(); centerx = rf1.X + rf1.Width /2; } continue; } IGraph graph1 =element1 as IGraph; if(graph1 !=null) { using(GraphicsPath path2 = graph1.GPath.Clone() as GraphicsPath) { path2.Transform(getMatrix(graph1)); RectangleF rf2=path2.GetBounds(); float ft1=rf2.X + rf2.Width / 2; Transf transf=new Transf(getMatrix(graph1)); transf.Matrix.Translate(centerx - ft1,0,MatrixOrder.Append); graph1.Transform = transf; } } } break; case AlignType.HorizontalCenter: float centery = 0f; while(enumerator1.MoveNext()) { SvgElement element1 =enumerator1.Current as SvgElement; if(firstgraph==null) { firstgraph =element1 as IGraph; using (GraphicsPath path1= firstgraph.GPath.Clone() as GraphicsPath) { path1.Transform(getMatrix(firstgraph)); rf1 =path1.GetBounds(); centery = rf1.Y + rf1.Height /2; } continue; } IGraph graph1 =element1 as IGraph; if(graph1 !=null) { using(GraphicsPath path2 = graph1.GPath.Clone() as GraphicsPath) { path2.Transform(getMatrix(graph1)); RectangleF rf2=path2.GetBounds(); float ft1=rf2.Y + rf2.Height / 2; Transf transf=new Transf(getMatrix(graph1)); transf.Matrix.Translate(0,centery - ft1,MatrixOrder.Append); graph1.Transform = transf; } } } break; } this.svgDocument.NotifyUndo(); } public void AttachProperty() { if (File.Exists(Application.StartupPath + @"\Preference\preference.xml")) { try { XmlDocument document1 = new XmlDocument(); document1.Load(Application.StartupPath + @"\Preference\preference.xml"); XmlNode node1 = document1.DocumentElement.SelectSingleNode("//*[@id='ShowRule']"); if (node1 != null) { this.ShowRule = node1.Attributes["Value"].Value == "true"; } node1 = document1.DocumentElement.SelectSingleNode("//*[@id='HighQuality']"); if (node1 != null) { svgDocument.SmoothingMode = (node1.Attributes["Value"].Value.Trim() == "true") ? SmoothingMode.HighQuality : SmoothingMode.HighSpeed; } node1 = document1.DocumentElement.SelectSingleNode("//*[@id='ConnectPoints']"); if (node1 != null) { svgDocument.ShowConnectPoints = node1.Attributes["Value"].Value.Trim() == "true"; } node1 = document1.DocumentElement.SelectSingleNode("//*[@id='ShowGrid']"); if (node1 != null) { this.ShowGrid = node1.Attributes["Value"].Value == "true"; } node1 = document1.DocumentElement.SelectSingleNode("//*[@id='SnapToGrid']"); if (node1 != null) { string text1 = node1.Attributes["Value"].Value.Trim(); this.SnapToGrid = text1 == "true"; } node1 = document1.DocumentElement.SelectSingleNode("//*[@id='ShowGuide']"); if (node1 != null) { this.ShowGuides = node1.Attributes["Value"].Value == "true"; } node1 = document1.DocumentElement.SelectSingleNode("//*[@id='LockGuide']"); if (node1 != null) { this.lockGuides = node1.Attributes["Value"].Value == "true"; } node1 = document1.DocumentElement.SelectSingleNode("//*[@id='GridHeight']"); if (node1 != null) { try { float single1 = ItopVector.Core.Func.Number.parseToFloat(node1.Attributes["Value"].Value, null, ItopVector.Core.Func.SvgLengthDirection.Horizontal); this.gridSize.Height = single1; } catch (Exception) { } } node1 = document1.DocumentElement.SelectSingleNode("//*[@id='GridWidth']"); if (node1 != null) { try { float single2 = ItopVector.Core.Func.Number.parseToFloat(node1.Attributes["Value"].Value, null, ItopVector.Core.Func.SvgLengthDirection.Horizontal); this.gridSize.Width = single2; } catch (Exception) { } } } catch (Exception) { } } base.Invalidate(); } public void BeginInsert() { this.inserting=true; } public void ChangeElementMatrix(float scalex, float scaley, float rotate, float skewx, float skewy) { PointF tf1 = this.mouseAreaControl.CenterPoint; scalex = (float) Math.Round((double) scalex, 2); scaley = (float) Math.Round((double) scaley, 2); rotate = (float) Math.Round((double) rotate, 2); skewx = (float) Math.Round((double) skewx, 2); skewy = (float) Math.Round((double) skewy, 2); bool flag1 = this.svgDocument.AcceptChanges; this.svgDocument.AcceptChanges = true; this.svgDocument.NumberOfUndoOperations = this.svgDocument.SelectCollection.Count*40; if (this.svgDocument.RecordAnim) { } else { Transf transf1 = new Transf(); tf1 = this.PointToView(this.mouseAreaControl.CenterPoint); transf1.setTranslate(tf1.X, tf1.Y); transf1.setScale(scalex, scaley); transf1.setRotate(rotate); transf1.setSkewX(skewx); transf1.setSkewX(skewy); transf1.setTranslate(-tf1.X, -tf1.Y); Matrix matrix2 = transf1.Matrix; SvgElementCollection.ISvgElementEnumerator enumerator2 = this.svgDocument.SelectCollection.GetEnumerator(); while (enumerator2.MoveNext()) { SvgElement element2 = (SvgElement) enumerator2.Current; if (element2 is IGraph) { IGraph graph1 = (IGraph) element2; Matrix matrix3 = graph1.Transform.Matrix.Clone(); matrix3.Multiply(matrix2, MatrixOrder.Append); Transf transf2 = new Transf(); transf2.setMatrix(matrix3); AttributeFunc.SetAttributeValue(element2, "transform", transf2.ToString()); } } } SvgElementCollection collection1 = this.svgDocument.SelectCollection.Clone(); this.svgDocument.SelectCollection.Clear(); this.svgDocument.SelectCollection.AddRange(collection1); this.svgDocument.NotifyUndo(); this.svgDocument.AcceptChanges = flag1; } public void ChangeLevel(LevelType level) { SvgElementCollection col= svgDocument.SelectCollection; for(int i=0;i<col.Count;i++) { SvgElement svgele=(SvgElement)col[i]; switch (level) { case LevelType.Top: //this.mouseAreaControl.GoTop(this.svgDocument.CurrentElement); this.mouseAreaControl.GoTop(svgele); break; case LevelType.Up: //this.mouseAreaControl.GoUp(this.svgDocument.CurrentElement); this.mouseAreaControl.GoUp(svgele); break; case LevelType.Down: //this.mouseAreaControl.GoDown(this.svgDocument.CurrentElement); this.mouseAreaControl.GoDown(svgele); break; case LevelType.Bottom: //this.mouseAreaControl.GoBottom(this.svgDocument.CurrentElement); this.mouseAreaControl.GoBottom(svgele); break; } } } public void ChangeLevel(string SymbolTagName,LevelType type) { XmlNodeList list=this.svgDocument.SelectNodes("svg/"+SymbolTagName); //foreach(XmlNode node in list) for(int i=0;i<list.Count;i++) { XmlNode node=list[i]; switch (type) { case LevelType.Top: this.mouseAreaControl.GoTop((SvgElement)node); break; case LevelType.Up: this.mouseAreaControl.GoUp((SvgElement)node); break; case LevelType.Down: this.mouseAreaControl.GoDown((SvgElement)node); break; case LevelType.Bottom: this.mouseAreaControl.GoBottom((SvgElement)node); break; } } } public void Clear() { this.svgDocument.Clear(); } public void ClearBuffer() { this.svgDocument.ClearUndos(); } public void ConvertToPath(SvgElement element,StringBuilder builder) { SvgElement element1 = element; builder.Append( PathFunc.GetPathString(((IGraph) element1).GPath)); } public void Copy() { this.mouseAreaControl.Copy(); } /// <summary> /// /// </summary> public void CreatePreGraph() { switch (this.Operation) { case ToolOperation.InterEnclosurePrint: case ToolOperation.Rectangle: case ToolOperation.AngleRectangle: { if (!(this.prepreGraph is ItopVector.Core.Figure.RectangleElement)) { this.preGraph = (ItopVector.Core.Figure.RectangleElement)this.svgDocument.CreateElement(this.svgDocument.Prefix, "rect", this.svgDocument.NamespaceURI); break; } this.preGraph = this.prepreGraph; break; } case ToolOperation.Circle: { if (!(this.prepreGraph is Circle)) { this.preGraph = (Circle) this.svgDocument.CreateElement(this.svgDocument.Prefix, "circle", this.svgDocument.NamespaceURI); goto Label_042D; } this.preGraph = this.prepreGraph; goto Label_042D; } case ToolOperation.Ellipse: { if (!(this.prepreGraph is Ellips)) { this.preGraph = (Ellips) this.svgDocument.CreateElement(this.svgDocument.Prefix, "ellipse", this.svgDocument.NamespaceURI); goto Label_042D; } this.preGraph = this.prepreGraph; goto Label_042D; } case ToolOperation.Line: { if (!(this.prepreGraph is Line)) { this.preGraph = (Graph) this.svgDocument.CreateElement(this.svgDocument.Prefix, "line", this.svgDocument.NamespaceURI); goto Label_042D; } this.preGraph = this.prepreGraph; goto Label_042D; } case ToolOperation.ConnectLine://������ { if (!(this.prepreGraph is ConnectLine)) { this.preGraph = (Graph) this.svgDocument.CreateElement(this.svgDocument.Prefix, "connectline", this.svgDocument.NamespaceURI); (this.preGraph as Graph).SetAttribute("type","line"); goto Label_042D; } this.preGraph = this.prepreGraph; goto Label_042D; } case ToolOperation.PolyLine: case ToolOperation.XPolyLine: case ToolOperation.YPolyLine: case ToolOperation.LeadLine: case ToolOperation.FreeLines: case ToolOperation.Confines_GuoJie: case ToolOperation.Confines_ShengJie: case ToolOperation.Confines_ShiJie: case ToolOperation.Confines_XianJie: case ToolOperation.Confines_XiangJie: case ToolOperation.Railroad: { if (!(this.prepreGraph is Polyline)) { this.preGraph = (Graph) this.svgDocument.CreateElement(this.svgDocument.Prefix, "polyline", this.svgDocument.NamespaceURI); goto Label_042D; } this.preGraph = this.prepreGraph; goto Label_042D; } case ToolOperation.Polygon: case ToolOperation.Enclosure: case ToolOperation.InterEnclosure: case ToolOperation.AreaPolygon: { if (!(this.prepreGraph is Polygon)) { this.preGraph = (Graph) this.svgDocument.CreateElement(this.svgDocument.Prefix, "polygon", this.SVGDocument.NamespaceURI); goto Label_042D; } this.preGraph = this.prepreGraph; goto Label_042D; } case ToolOperation.EqualPolygon: { this.preGraph = (Graph) this.svgDocument.CreateElement(this.svgDocument.Prefix, "polygon", this.svgDocument.NamespaceURI); ((Polygon) this.preGraph).LineCount = LineCount; // (int) this.LinesUpDown.Value; ((Polygon) this.preGraph).Indent = Indent; //(float) this.indentUpDown1.Value; goto Label_042D; } case ToolOperation.Bezier: case ToolOperation.Pie: case ToolOperation.Arc: { bool flag1 = false; if (((this.prepreGraph is GraphPath)) && (((SvgElement) this.prepreGraph).Name == "path")) { this.preGraph = this.prepreGraph; flag1 = true; } if (!flag1) { this.preGraph = (Graph) this.svgDocument.CreateElement(this.svgDocument.Prefix, "path", this.svgDocument.NamespaceURI); } goto Label_042D; } case ToolOperation.Text: { if (!(this.prepreGraph is Text)) { this.preGraph = (Text) this.svgDocument.CreateElement(this.svgDocument.Prefix, "text", this.svgDocument.NamespaceURI); goto Label_042D; } this.preGraph = this.prepreGraph; goto Label_042D; } case ToolOperation.Image: { this.preGraph = (Graph) this.svgDocument.CreateElement(this.svgDocument.Prefix, "image", this.svgDocument.NamespaceURI); goto Label_042D; } case ToolOperation.PreShape: { if (this.svgDocument != null) { this.preGraph = new GraphPath("", "path", "", this.svgDocument); ((GraphPath) this.preGraph).SetAttribute("d", this.shapePathString); } goto Label_042D; } default: { this.preGraph = null; goto Label_042D; } } Label_042D: this.prepreGraph = this.preGraph; if (this.preGraph is IGraphPath) { this.svgDocument.AcceptChanges=false; if(this.Operation==ToolOperation.AreaPolygon) { AttributeFunc.SetAttributeValue((XmlElement)preGraph,"IsArea","1"); return; } if(this.Operation==ToolOperation.LeadLine) { AttributeFunc.SetAttributeValue((XmlElement)preGraph,"IsLead","1"); return; } if(this.Operation==ToolOperation.XPolyLine || this.Operation==ToolOperation.YPolyLine) { AttributeFunc.SetAttributeValue((XmlElement)preGraph,"style","fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;stroke-width:4;"); return; } if(this.Operation==ToolOperation.Enclosure|| this.Operation==ToolOperation.InterEnclosure ||this.operation==ToolOperation.InterEnclosurePrint) { // ((IGraphPath) preGraph).GraphBrush =new SolidColor(Color.Empty); //((IGraphPath) preGraph).GraphStroke.StrokeColor=Color.Red; //AttributeFunc.SetAttributeValue((XmlElement)preGraph,"stroke","#FF8081"); //AttributeFunc.SetAttributeValue((XmlElement)preGraph,"stroke-width","2"); AttributeFunc.SetAttributeValue((XmlElement)preGraph,"style", "fill:#C0C0FF;fill-opacity:0.3;stroke:#000000;stroke-opacity:1;"); return; } if(Operation== ToolOperation.Confines_GuoJie) { ((IGraphPath) preGraph).GraphBrush =new SolidColor(Color.Empty); AttributeFunc.SetAttributeValue((XmlElement)preGraph,"style","fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;stroke-width:4;stroke-dasharray:10 3 3 3;"); return; } if(Operation== ToolOperation.Confines_ShengJie) { ((IGraphPath) preGraph).GraphBrush =new SolidColor(Color.Empty); AttributeFunc.SetAttributeValue((XmlElement)preGraph,"style","fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;stroke-dasharray:10 3 3 3;stroke-width:3;"); return; } if(Operation== ToolOperation.Confines_ShiJie) { ((IGraphPath) preGraph).GraphBrush =new SolidColor(Color.Empty); AttributeFunc.SetAttributeValue((XmlElement)preGraph,"style","fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;stroke-width:3;stroke-dasharray:8 3 8 ;"); return; } if(Operation== ToolOperation.Confines_XianJie) { ((IGraphPath) preGraph).GraphBrush =new SolidColor(Color.Empty); AttributeFunc.SetAttributeValue((XmlElement)preGraph,"style","fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;stroke-width:2.5;stroke-dasharray:10 3 3 3;"); return; } if(Operation== ToolOperation.Confines_XiangJie) { ((IGraphPath) preGraph).GraphBrush =new SolidColor(Color.Empty); AttributeFunc.SetAttributeValue((XmlElement)preGraph,"style","fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;stroke-width:2;stroke-dasharray:6 2 6;"); return; } if(Operation== ToolOperation.Railroad) { ((IGraphPath) preGraph).GraphBrush =new SolidColor(Color.Empty); AttributeFunc.SetAttributeValue((XmlElement)preGraph,"style","fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;stroke-width:3;stroke-dasharray:5 5;"); return; } else { ((IGraphPath) preGraph).GraphBrush = this.FillBrush.Clone(); ((IGraphPath) preGraph).GraphStroke = this.Stroke.Clone() as Stroke; } } if (this.preGraph is Text) { // ((Text)this.preGraph).FontName=this.RatTextStyle.FontName; // ((Text)this.preGraph).Size=this.RatTextStyle.Size; this.svgDocument.AcceptChanges=false; AttributeFunc.SetAttributeValue((SvgElement) preGraph, "font-family", this.RatTextStyle.FontName); AttributeFunc.SetAttributeValue((SvgElement) preGraph, "font-size", this.RatTextStyle.Size.ToString()); if (this.RatTextStyle.Bold) AttributeFunc.SetAttributeValue((SvgElement) preGraph, "font-weight", "bold"); if (this.RatTextStyle.Italic) AttributeFunc.SetAttributeValue((SvgElement) preGraph, "font-style", "italic"); if (this.RatTextStyle.Underline) AttributeFunc.SetAttributeValue((SvgElement) preGraph, "text-decoration", "underline"); } // if(svgDocument!=null) // { //// svgDocument.CurrentElement=(SvgElement)preGraph; // svgDocument.SelectCollection.Clear(); // svgDocument.SelectCollection.Add(preGraph); // } } public void CreateRef(Point screen, bool hori, bool post) { if (!post) { Win32 win1 = this.mouseAreaControl.win32; win1.hdc = win1.W32GetDC(this.mouseAreaControl.Handle); win1.W32SetROP2(7); GraphicsPath path1 = new GraphicsPath(); if (hori) { path1.AddLine(0, this.oldpoint.Y, base.Width, this.oldpoint.Y); } else { path1.AddLine(this.oldpoint.X, 0, this.oldpoint.X, base.Height); } win1.W32PolyDraw(path1); Point point1 = this.PointToView(this.mouseAreaControl.PointToClient(screen)); if (this.SnapToGrid) { int num1 = (int) ((point1.X + (this.gridSize.Width/2f))/this.gridSize.Width); int num2 = (int) ((point1.Y + (this.gridSize.Height/2f))/this.gridSize.Height); point1 = new Point((int) (num1*this.gridSize.Width), (int) (this.gridSize.Height*num2)); } this.oldpoint = Point.Round(this.PointToSystem(new PointF((float) point1.X, (float) point1.Y))); path1.Reset(); if (hori) { path1.AddLine(0, this.oldpoint.Y, base.Width, this.oldpoint.Y); } else { path1.AddLine(this.oldpoint.X, 0, this.oldpoint.X, base.Height); } win1.W32PolyDraw(path1); win1.ReleaseDC(); path1.Dispose(); } else { RefLine line1; GraphicsPath path2 = new GraphicsPath(); if (hori) { path2.AddLine(0, this.oldpoint.Y, base.Width, this.oldpoint.Y); } else { path2.AddLine(this.oldpoint.X, 0, this.oldpoint.X, base.Height); } Win32 win2 = this.mouseAreaControl.win32; win2.hdc = win2.W32GetDC(this.mouseAreaControl.Handle); win2.W32SetROP2(7); win2.W32PolyDraw(path2); win2.ReleaseDC(); path2.Dispose(); this.oldpoint = Point.Empty; Point point2 = this.PointToView(this.mouseAreaControl.PointToClient(screen)); if (this.SnapToGrid) { int num3 = (int) ((point2.X + (this.gridSize.Width/2f))/this.gridSize.Width); int num4 = (int) ((point2.Y + (this.gridSize.Height/2f))/this.gridSize.Height); point2 = new Point((int) (num3*this.gridSize.Width), (int) (this.gridSize.Height*num4)); } point2 = Point.Round(this.PointToSystem(new PointF((float) point2.X, (float) point2.Y))); if (hori) { base.Invalidate(new System.Drawing.Rectangle(0, point2.Y - 2, base.Width, 4)); } else { base.Invalidate(new System.Drawing.Rectangle(point2.X - 2, 0, 4, base.Height)); } if ((hori && (point2.Y >= 0)) && (point2.Y <= base.Height)) { base.Invalidate(new System.Drawing.Rectangle(0, point2.Y - 1, base.Width, 2)); point2 = this.PointToView(point2); line1 = new RefLine(point2.Y, hori); this.RefLines.Add(line1); } else if ((point2.X >= 0) && (point2.X <= base.Width)) { base.Invalidate(new System.Drawing.Rectangle(point2.X - 1, 0, 2, base.Height)); point2 = this.PointToView(point2); line1 = new RefLine(point2.X, hori); this.RefLines.Add(line1); } } } public void Cut() { this.mouseAreaControl.Cut(); } public void Delete() { this.mouseAreaControl.Delete(); } public void Distribute(DistributeType type) { // TODO: ��� ItopVectorControl.Distribute ʵ�� } // public void MouseDown(object sender, MouseEventArgs e) // { // // TODO: ��� ItopVectorControl.MouseDown ʵ�� // } // // public void MouseUp(object sender, MouseEventArgs e) // { // // TODO: ��� ItopVectorControl.MouseUp ʵ�� // } // // public void MouseMove(object sender, MouseEventArgs e) // { // // TODO: ��� ItopVectorControl.MouseMove ʵ�� // } // // public void MouseEnter(object sender, EventArgs e) // { // // TODO: ��� ItopVectorControl.MouseEnter ʵ�� // } // // public void MouseLeave(object sender, EventArgs e) // { // // TODO: ��� ItopVectorControl.MouseLeave ʵ�� // } public void DocumentChanged(object sender, EventArgs e) { // TODO: ��� ItopVectorControl.DocumentChanged ʵ�� } public void EndInsert() { this.inserting=false; this.svgDocument.SelectCollection.Clear(); this.svgDocument.SelectCollection.AddRange(this.addedElements); this.addedElements.Clear(); } public bool ExportImage(string filename, ImageFormat filetype,ExportType type) { getBmp(type).Save(filename, filetype); return true; } public bool ExportImage(string filename, ImageFormat filetype) { return ExportImage(filename,filetype,ExportType.All); } public void ExportImage() { ExportImageDialog dlg =new ExportImageDialog(this); dlg.ShowDialog(this); } public byte[] ExportImageToBinary(ExportType type) { Bitmap bmp = getBmp(type); MemoryStream ms =new MemoryStream(); bmp.Save(ms,ImageFormat.Png); return ms.ToArray(); } public bool ExportImageToClipboard(ExportType type) { Bitmap bmp =getBmp(type); // Rectangle rect = new Rectangle(Point.Empty,bmp.Size); // // Bitmap TheClippedBmp = new Bitmap((int) rect.Width,(int) rect.Height) ; // Graphics Gra = Graphics.FromImage(TheClippedBmp); //// Gra.FillRectangle(this.backColor, 0,0,(int) rect.Width,(int) rect.Height); // Gra.DrawImage(bmp, new Rectangle(0, 0,(int) rect.Width,(int) rect.Height), rect, GraphicsUnit.Pixel) ; if (bmp !=null) { DataObject data = new DataObject(DataFormats.Bitmap,bmp); Clipboard.SetDataObject(data,true); } return true; } public String ExportSymbol(bool wholecontent, bool exportshape, bool createdocument, string id) { // TODO: ��� ItopVectorControl.ExportSymbol ʵ�� return null; } public void FitWindow() { float single1 = this.ViewSize.Height; float single2 = this.ViewSize.Width; if (single1 == 0f) { single1 = base.Height; } if (single2 == 0f) { single2 = base.Width; } if (fullDrawMode) { SetScroll(); } else { float single3 = ((float) (base.Height - 50))/single1; single3 = Math.Min(single3, ((float) (base.Width - 50))/single2); this.ScaleUnit = single3; } if (this.firstload || !fullDrawMode) { int num1 =Math.Max(this.vScrollBar1.Minimum ,(this.vScrollBar1.Maximum - this.vScrollBar1.LargeChange)/2); int num2 =Math.Max(this.hScrollBar1.Minimum ,(this.hScrollBar1.Maximum - this.hScrollBar1.LargeChange)/2); this.vScrollBar1.Value = num1; this.hScrollBar1.Value = num2; } } public void FlipX() { this.SelectMenuItem("flipx"); } public void FlipY() { this.SelectMenuItem("flipy"); } public Bitmap GetBmp(ExportType type) { return getBmp(type); } public PointF GetCenterPoint() { return this.GetCenterPoint(this.scale); } public void GoLocation(float x, float y) { PointF center = GetCenterPoint(); float num1 = (center.X - x) * this.ScaleRatio; float num2 = (center.Y - y) * this.ScaleRatio; this.MovePicture(this.VirtualLeft - num1, this.VirtualTop - num2,true); this.SetScrollDelta(-(int)(num1), -(int)(num2)); } public void Group() { this.mouseAreaControl.Group(this.svgDocument.SelectCollection); } public void InvadatePosLine() { } public void InvadateRect(System.Drawing.Rectangle rect) { this.viewer.Invalidate(rect); } public void InvalidateElement(SvgElement element) { this.viewer.InvalidateElement(element); } public void InvalidateRule() { this.hRule.Invalidate(); this.vRule.Invalidate(); } void ItopVector.IItopVector.OperationChanged(object sender, EventArgs e) { // TODO: ��� ItopVectorControl.ItopVector.IItopVector.OperationChanged ʵ�� } void ItopVector.IItopVector.Redo() { this.svgDocument.Redo(); } bool ItopVector.IItopVector.Save(string filename) { this.svgDocument.FilePath=filename; return this.save(false); } void ItopVector.IItopVector.Undo() { this.svgDocument.Undo(); } public void MakeSameSize(SizeType type) { // TODO: ��� ItopVectorControl.MakeSameSize ʵ�� } /// <summary> /// �任ѡ�ж��� /// </summary> /// <param name="matrix"></param> public void MatrixSelection(Matrix matrix) { this.MatrixSelectionEx(matrix); } /// <summary> /// �任ѡ�ж��� /// </summary> /// <param name="matrix"></param> public void MatrixSelectionEx(Matrix matrix) { bool flag1 = this.svgDocument.AcceptChanges; this.svgDocument.AcceptChanges = true; this.svgDocument.NumberOfUndoOperations = 10*this.svgDocument.SelectCollection.Count; SvgElementCollection.ISvgElementEnumerator enumerator1 = this.svgDocument.SelectCollection.GetEnumerator(); while (enumerator1.MoveNext()) { SvgElement element1 = (SvgElement) enumerator1.Current; if (element1 is IGraph) { IGraph graph1 = element1 as IGraph; Matrix matrix3 =new Matrix(); if(graph1.LimitSize && graph1 is Use) { Use use1 =graph1 as Use; using (Matrix matrix1=this.coordTransform.Clone()) { float f1 = 1/matrix1.Elements[0]; matrix3.Scale(f1,f1,MatrixOrder.Prepend); Symbol symbol = use1.RefElement as Symbol; RectangleF rf =symbol.GPath.GetBounds(symbol.Transform.Matrix); float f2 = (use1.X+rf.X+(rf.Width)/2)*(matrix1.Elements[0] -1); float f3 = (use1.Y+rf.Y+(rf.Height)/2)*(matrix1.Elements[0] -1); matrix3.Translate(f2,f3,MatrixOrder.Prepend); matrix3.Invert(); } } Matrix matrix2 = ((IGraph) element1).Transform.Matrix.Clone(); matrix2.Multiply(matrix3); matrix2.Multiply(matrix, MatrixOrder.Append); Transf transf1 = new Transf(); transf1.setMatrix(matrix2); AttributeFunc.SetAttributeValue(element1, "transform", transf1.ToString()); } } this.svgDocument.NotifyUndo(); this.svgDocument.AcceptChanges = flag1; } public void MovePicture(float left,float top,bool move) { this.virtualLeft =Math.Max(0, Math.Min(left,this.hScrollBar1.Maximum - this.hScrollBar1.LargeChange)); this.virtualTop = Math.Max(0, Math.Min(top,this.vScrollBar1.Maximum - this.vScrollBar1.LargeChange)); // this.viewer.MovePicture(this.virtualLeft,this.virtualTop,move); } public SvgDocument NewFile() { float width =400; float height =500; SizeF size = new SizeF(width,height); try { width = this.pageSetting.PaperSize.Width*0.9f; height = this.pageSetting.PaperSize.Height*0.9f; if (this.pageSetting.Landscape) { size = new SizeF(height, width); } else { size = new SizeF(width, height); } } catch{} this.SVGDocument = SvgDocumentFactory.CreateDocument(size); this.AttachProperty(); return this.svgDocument; } public void NotifyContextMenu(Point p) { if (this.OnTrackPopup != null) { this.OnTrackPopup(this, p); } } public bool Open(string filename) { return this.OpenFile(filename); } public bool OpenFile(string fileName) { this.Cursor = Cursors.WaitCursor; this.SVGDocument = SvgDocumentFactory.CreateDocumentFromFile(fileName); this.AttachProperty(); this.Cursor = Cursors.Default; return (this.SVGDocument != null); } public void PaperSetup() { if (pageSetupDlg1.ShowDialog(this) == DialogResult.OK) { this.pageSetting = pageSetupDlg1.PageSettings; } } public void Paste() { this.mouseAreaControl.Paste(); } public PointF PointToSystem(PointF point) { PointF[] tfArray2 = new PointF[1] {point}; PointF[] tfArray1 = tfArray2; this.coordTransform.TransformPoints(tfArray1); return tfArray1[0]; } public void PointToSystem(PointF[] points) { this.coordTransform.TransformPoints(points); } public Point PointToView(Point point) { Point[] pointArray1 = new Point[1] {point}; Matrix matrix1 = this.coordTransform.Clone(); matrix1.Invert(); matrix1.TransformPoints(pointArray1); return pointArray1[0]; } public void PointToView(PointF[] points) { Matrix matrix1 = this.coordTransform.Clone(); matrix1.Invert(); matrix1.TransformPoints(points); } public PointF PointToView(PointF point) { PointF[] tfArray1 = new PointF[1] {point}; Matrix matrix1 = this.coordTransform.Clone(); matrix1.Invert(); matrix1.TransformPoints(tfArray1); return tfArray1[0]; } public void PostBrush(ISvgBrush brush) { if (this.PostBrushEvent != null) { this.PostBrushEvent(this, brush); } } public void Print() { try { ItopVector.Dialog.PrintDialog dialog1 = new ItopVector.Dialog.PrintDialog(this); dialog1.ShowDialog(this); } catch (Exception exception1) { MessageBox.Show(exception1.Message); } } public void PrintPreview() { } public bool Redo() { if (this.SVGDocument.CanRedo) { this.SVGDocument.Redo(); } return this.SVGDocument.CanRedo; } public void RenderTo(Graphics g) { if ((g != null) && ((this.svgDocument != null) && (this.svgDocument.DocumentElement != null))) { SVG svg1 = this.svgDocument.DocumentElement as SVG; try { SmoothingMode mode1=this.svgDocument.SmoothingMode; this.svgDocument.SmoothingMode =g.SmoothingMode; if (OnBeforeRenderTo!=null) { Rectangle bounds = new Rectangle(0,0,this.DocumentSizeEx.Width,this.DocumentSizeEx.Height); OnBeforeRenderTo(this,new PaintMapEventArgs(g,new PointF(bounds.Width/2,bounds.Height/2),bounds)); } svg1.Draw(g, this.svgDocument.ControlTime); this.svgDocument.SmoothingMode = mode1; } catch { } } } public void RotateSelection(float angle) { using (System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix()) { PointF tf1 = this.PointToView(this.mouseAreaControl.CenterPoint); matrix.Translate(tf1.X, tf1.Y); matrix.Rotate(angle); matrix.Translate(-tf1.X, -tf1.Y); this.MatrixSelection(matrix); } } public void RotateSelection(float angle,PointF center) { using (System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix()) { PointF tf1 = this.PointToView(this.mouseAreaControl.CenterPoint); matrix.Translate(center.X, center.Y); matrix.Rotate(angle); matrix.Translate(-center.X, -center.Y); this.MatrixSelection(matrix); } } public bool Save() { return save(false); } public bool SaveAs() { return save(true); } public void SelectAll() { this.SelectMenuItem("selectall"); } public bool SelectMenuItem(object sender) { //////////////////////////////////////////////////////// MenuItem command1 = new MenuItem(); string text1 = sender.ToString(); bool flag1 = false; switch (text1) { case "rule": { this.ShowRule = !this.showRule; command1.Checked = this.showRule; return true; } case "showgrid": { this.ShowGrid = !this.showGrid; command1.Checked = this.showGrid; return true; } case "snaptogrid": { this.SnapToGrid = !this.SnapToGrid; command1.Checked = this.SnapToGrid; return true; } case "showguides": { bool flag2 = !this.showGuides; this.ShowGuides = flag2; command1.Checked = this.showGuides; return true; } case "snaptoguides": { this.SnapToGuides = !this.SnapToGuides; command1.Checked = this.SnapToGuides; return true; } case "lockguides": { this.lockGuides = !this.lockGuides; command1.Checked = this.lockGuides; return true; } case "clearguides": { foreach (RefLine line1 in this.RefLines) { if (line1.Hori) { PointF tf1 = new PointF(0f, (float) line1.Pos); tf1 = this.PointToSystem(tf1); this.viewer.Invalidate(new System.Drawing.Rectangle(0, (int) tf1.Y, base.Width, 2)); continue; } PointF tf2 = new PointF((float) line1.Pos, 0f); tf2 = this.PointToSystem(tf2); this.viewer.Invalidate(new System.Drawing.Rectangle((int) tf2.X, 0, 2, base.Height)); } this.RefLines.Clear(); return flag1; } case "fast": { if (this.svgDocument.SmoothingMode != SmoothingMode.HighSpeed) { this.svgDocument.SmoothingMode = SmoothingMode.HighSpeed; this.viewer.Invalidate(); } return true; } case "highquality": { if (this.svgDocument.SmoothingMode != SmoothingMode.HighQuality) { this.svgDocument.SmoothingMode = SmoothingMode.HighQuality; this.viewer.Invalidate(); } return true; } case "antialiastext": { if (this.svgDocument.TextRenderingHint != TextRenderingHint.AntiAlias) { this.svgDocument.TextRenderingHint = TextRenderingHint.AntiAlias; this.viewer.Invalidate(); } return true; } case "converttopath": { this.mouseAreaControl.ConvertToPath(); return true; } case "converttosymbol": { this.mouseAreaControl.ConvertToSymbol(this.svgDocument.CurrentElement); return true; } case "gotop": { this.mouseAreaControl.GoTop(this.svgDocument.CurrentElement); return true; } case "goup": { this.mouseAreaControl.GoUp(this.svgDocument.CurrentElement); return true; } case "godown": { this.mouseAreaControl.GoDown(this.svgDocument.CurrentElement); return true; } case "gobottom": { this.mouseAreaControl.GoBottom(this.svgDocument.CurrentElement); return true; } case "group": { this.mouseAreaControl.Group(this.svgDocument.SelectCollection); return true; } case "ungroup": { this.mouseAreaControl.UnGroup((Group) this.svgDocument.CurrentElement); return true; } case "copy": { this.mouseAreaControl.Copy(); return true; } case "paste": { this.mouseAreaControl.Paste(); return true; } case "cut": { this.mouseAreaControl.Cut(); return true; } case "delete": { this.mouseAreaControl.Delete(); return true; } case "selectall": { this.mouseAreaControl.SelectAll(); return true; } case "selectcurrentlay": { this.mouseAreaControl.SelectCurrentLay(); return true; } case "clearselects": { this.mouseAreaControl.ClearSelection(); return true; } case "zoomin": { this.ScaleUnit = 2f*this.scale; return true; } case "zoomout": { this.ScaleUnit = this.scale/2f; return true; } case "editgrid": { GridWindow window1 = new GridWindow(); window1.SizeValue = this.gridSize; if (window1.ShowDialog(this) == DialogResult.OK) { this.GridSize = window1.SizeValue; } return true; } case "undo": { if (!this.mouseAreaControl.Undo()) { this.svgDocument.Undo(); } return true; } case "redo": { if (!this.mouseAreaControl.Redo()) { this.svgDocument.Redo(); } return true; } case "break": { this.Break(this.svgDocument.SelectCollection); return true; } case "flipx": { this.Flip(false); return flag1; } case "flipy": { this.Flip(true); return flag1; } case "rotate90": { this.RotateSelection(90); return flag1; } case "rotate_90": { this.RotateSelection(-90); return flag1; } case "link": { this.mouseAreaControl.Link(); return flag1; } case "unlink": { this.mouseAreaControl.UnLink(); return flag1; } } return flag1; } public void SelectNone() { this.SelectMenuItem("clearselects"); } public void SetOption() { ItopVector.Dialog.PreferenceWindow dlg = new ItopVector.Dialog.PreferenceWindow(); if (dlg.ShowDialog(this) == DialogResult.OK) this.AttachProperty(); } public void SetScroll() { PointF offset =PointF.Empty; if (oldScale!=scale) { PointF pf1 = GetCenterPoint(oldScale); float f1 = (scale -oldScale); offset = new PointF((pf1.X*f1),(pf1.Y*f1)); oldScale =scale; } int num2=30; int num3=50; float single1 = ((float) (this.vScrollBar1.Value - this.vScrollBar1.Minimum))/((float) (this.vScrollBar1.Maximum - this.vScrollBar1.Minimum)); float single2 = ((float) (this.hScrollBar1.Value - this.hScrollBar1.Minimum))/((float) (this.hScrollBar1.Maximum - this.hScrollBar1.Minimum)); if (float.IsNaN(single1))single1=0f; if (float.IsNaN(single2))single2=0f; this.vScrollBar1.Minimum = 0; SizeF ef1 = this.ViewSize; float single3 = ef1.Height; float single4 = ef1.Width; if (single3 == 0f) { single3 = base.Height; } if (single4 == 0f) { single4 = base.Width; } num3 = Math.Max(50,this.Height -32); int num1 = (this.margin.Height-16)*2 + (int) (single3*this.scale); if(num1>0) { this.vScrollBar1.Enabled=true; this.vScrollBar1.Maximum = num1; this.vScrollBar1.SmallChange = num2 ; this.vScrollBar1.LargeChange = num3; // this.vScrollBar1.Value = this.vScrollBar1.Minimum + ((int) (single1*(this.vScrollBar1.Maximum - this.vScrollBar1.Minimum))); } else { this.vScrollBar1.Maximum=0; this.vScrollBar1.Value =0; this.vScrollBar1.Enabled=false; } this.hScrollBar1.Minimum = 0; num3= Math.Max(50,this.Width-32); num1 = (((this.margin.Width -16)*2) + ((int) (single4*this.scale))); if(num1>0) { this.hScrollBar1.Enabled=true; this.hScrollBar1.Maximum = num1; this.hScrollBar1.SmallChange = num2; this.hScrollBar1.LargeChange = num3; // this.hScrollBar1.Value = this.hScrollBar1.Minimum + ((int) (single2*(this.hScrollBar1.Maximum - this.hScrollBar1.Minimum))); } else { this.hScrollBar1.Value =0; this.hScrollBar1.Maximum = 0; this.hScrollBar1.Enabled=false; } if(offset !=PointF.Empty) SetScrollDelta((int)offset.X,(int)offset.Y); } public void SetScrollDelta(int x, int y) { int num1 = this.hScrollBar1.Value + x; int num2 = this.vScrollBar1.Value + y; num1 = Math.Max(this.hScrollBar1.Minimum, Math.Min(num1, this.hScrollBar1.Maximum -this.hScrollBar1.LargeChange)); num2 = Math.Max(this.vScrollBar1.Minimum, Math.Min(num2, this.vScrollBar1.Maximum -this.vScrollBar1.LargeChange)); this.hScrollBar1.Value = num1; this.vScrollBar1.Value = num2; } /// <summary> /// ��״�ı� /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void shapeSelector_SelectedChanged(object sender, EventArgs e) { ItopVector.Selector.ShapeSelector shapeselector = sender as ItopVector.Selector.ShapeSelector; if (shapeselector != null) { this.shapePathString = shapeselector.SelectedShape.PathString; if (this.operation == ToolOperation.PreShape) { this.CreatePreGraph(); } else { this.Operation = ToolOperation.PreShape; } //MessageBox.Show(str); } } public void ShowAll() { if ((this.svgDocument != null) && (this.svgDocument.DocumentElement is SVG)) { RectangleF ef1 = ((SVG) this.svgDocument.DocumentElement).GetBounds(); SizeF ef2 = this.ViewSize; float single1 = Math.Max(ef2.Width, ef1.Width); float single2 = Math.Max(ef2.Height, ef1.Height); if ((ef1.Width != 0f) && (ef1.Height != 0f)) { float single3 = ((float) (base.Height - 50))/single2; single3 = Math.Min(single3, ((float) (base.Width - 50))/single1); this.ScaleUnit = single3; this.vScrollBar1.Value = this.vScrollBar1.Maximum/2; this.hScrollBar1.Value = this.hScrollBar1.Maximum/2; } } } public void ShowExportSymbolDialog(string filefilter) { // TODO: ��� ItopVectorControl.ShowExportSymbolDialog ʵ�� } public void ToolTip(string tooltip, byte tiptype) { if (this.OnTipEvent != null) { this.OnTipEvent(this, tooltip, tiptype); } } public bool Undo() { if (this.SVGDocument.CanUndo) { this.SVGDocument.Undo(); } return this.SVGDocument.CanUndo; } public void UnGroup() { if (this.svgDocument.CurrentElement is Group) { this.mouseAreaControl.UnGroup((Group) this.svgDocument.CurrentElement); } } public bool UpdateMenuItem(object sender) { object obj1; MenuItem command1 = sender as MenuItem; string text1 = string.Empty; // if (!(command1.Tag is XmlElement)) // { // return false; // } // text1 = ((XmlElement) command1.Tag).GetAttribute("Method").Trim().ToLower(); bool flag1 = false; if (((obj1 = text1) != null) && ((obj1 = command1.MenuItems.IndexOf(command1)) != null)) { obj1 = 0; switch (((int) obj1)) { case 0: { command1.Enabled = this.svgDocument.SelectCollection.Count > 0; return flag1; } case 1: { command1.Checked = this.showRule; return true; } case 2: { command1.Checked = this.showGrid; return true; } case 3: { command1.Checked = this.SnapToGrid; return true; } case 4: { command1.Checked = this.showGuides; return true; } case 5: { command1.Checked = this.SnapToGuides; return true; } case 6: { command1.Checked = this.lockGuides; return true; } case 7: { command1.Checked = this.svgDocument.SmoothingMode == SmoothingMode.HighSpeed; return true; } case 8: { command1.Checked = this.svgDocument.SmoothingMode == SmoothingMode.HighQuality; return true; } case 9: { command1.Checked = this.svgDocument.TextRenderingHint == TextRenderingHint.AntiAlias; return true; } case 10: { command1.Enabled = this.scale <= 2800f; return true; } case 11: { command1.Enabled = this.scale > 0.05; return true; } case 12: { command1.Enabled = this.svgDocument.CanUndo; if (this.mouseAreaControl.editingOperation != null) { command1.Enabled = command1.Enabled || this.mouseAreaControl.editingOperation.CanUndo; } return true; } case 13: { command1.Enabled = this.svgDocument.CanRedo; if (this.mouseAreaControl.editingOperation != null) { command1.Enabled = command1.Enabled || this.mouseAreaControl.editingOperation.CanRedo; } return true; } case 14: { command1.Enabled = false; SvgElementCollection.ISvgElementEnumerator enumerator1 = this.svgDocument.SelectCollection.GetEnumerator(); while (enumerator1.MoveNext()) { SvgElement element1 = (SvgElement) enumerator1.Current; if (element1 is Group) { command1.Enabled = true; return true; } } return true; } case 15: case 0x10: case 0x11: case 0x12: case 0x13: case 20: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: { bool flag2 = false; if (this.svgDocument == null) { command1.Enabled = false; return flag1; } if (this.svgDocument.SelectCollection.Count > 0) { flag2 = (this.svgDocument.CurrentElement is IGraph) && (this.svgDocument.CurrentElement != this.svgDocument.DocumentElement); if ((text1 != "align") && (text1 != "group")) { if (text1 == "ungroup") { flag2 = (flag2 && (this.svgDocument.SelectCollection.Count == 1)) && (this.svgDocument.CurrentElement is Group); } } else { flag2 = flag2 && (this.svgDocument.SelectCollection.Count > 1); } } command1.Enabled = flag2; return flag1; } case 30: { if (this.svgDocument == null) { command1.Enabled = false; return flag1; } if (this.svgDocument.SelectCollection.Count != 1) { command1.Enabled = false; return flag1; } if (!(this.svgDocument.CurrentElement is ItopVector.Core.Figure.Link)) { command1.Enabled = false; return flag1; } command1.Enabled = true; return flag1; } case 0x1f: case 0x20: { command1.Enabled = (this.svgDocument.CurrentElement is IGraph) && (this.svgDocument.CurrentElement != this.svgDocument.DocumentElement); return flag1; } } } return flag1; } public void UpdateRegion() { this.viewer.Update(); } public void UpdateToolBar(object sender) { ToolBarButton button1 = sender as ToolBarButton; string text1 = string.Empty; if (button1.Tag is XmlElement) { string text2; text1 = ((XmlElement) button1.Tag).GetAttribute("Method").Trim().ToLower(); if ((text2 = text1) == null) { return; } text2 = string.IsInterned(text2); if (((text2 != "copy") && (text2 != "cut")) && (text2 != "delete")) { if (text2 == "rule") { button1.Pushed = this.ShowRule; } else if (text2 == "showgrid") { button1.Pushed = this.showGrid; } else if (text2 == "undo") { bool flag1 = this.svgDocument.CanUndo; if (this.mouseAreaControl.editingOperation != null) { flag1 = this.mouseAreaControl.editingOperation.CanUndo || flag1; } flag1 = flag1; button1.Enabled = flag1; } else if (text2 == "redo") { bool flag2 = this.svgDocument.CanRedo; if (this.mouseAreaControl.editingOperation != null) { flag2 = this.mouseAreaControl.editingOperation.CanRedo || flag2; } button1.Enabled = flag2; } } else { SvgElementCollection.ISvgElementEnumerator enumerator1 = this.svgDocument.SelectCollection.GetEnumerator(); while (enumerator1.MoveNext()) { SvgElement element1 = (SvgElement) enumerator1.Current; if (element1 is IGraph) { button1.Enabled = true; return; } } button1.Enabled = false; } } } internal SvgElement CreateSymbol(bool isall, bool isshape, bool isdocument) { if ((this.svgDocument == null) || this.ElementList.Count==0) { return null; } bool flag1 = this.svgDocument.AcceptChanges; this.svgDocument.AcceptChanges = false; SvgElement facbce1 = null; if (isshape) { facbce1 = this.svgDocument.CreateElement(this.svgDocument.Prefix, "path", this.svgDocument.NamespaceURI) as SvgElement; SvgElementCollection collection1 = (this.svgDocument.RootElement as SVG).GraphList; if (!isall) { collection1 = this.svgDocument.SelectCollection; } StringBuilder builder1 = new StringBuilder(1000); for (int num1 = 0; num1 < collection1.Count; num1++) { this.ConvertToPath((collection1[num1] as SvgElement).Clone() as SvgElement, builder1); } facbce1.SetAttribute("d", builder1.ToString()); builder1 = null; } else { facbce1 = this.svgDocument.CreateElement(this.svgDocument.Prefix, "symbol", this.svgDocument.NamespaceURI) as SvgElement; SvgElementCollection collection2 = new SvgElementCollection(); if (!isall) { collection2 = this.svgDocument.SelectCollection; } else { collection2 = (this.svgDocument.RootElement as SVG).GraphList; } SvgElementCollection collection3 = new SvgElementCollection(); foreach(SvgElement element in collection2) { addChild(element,facbce1 as Symbol); } if (collection3.Count > 0) { SvgElement facbce2 = this.svgDocument.CreateElement(this.svgDocument.Prefix, "defs", this.svgDocument.NamespaceURI) as SvgElement; facbce1.PrependChild(facbce2); facbce1.PrependChild(this.svgDocument.CreateTextNode("\n")); facbce1.InsertAfter(this.svgDocument.CreateTextNode("\n"), facbce2); facbce2.AppendChild(this.svgDocument.CreateTextNode("\n")); for (int num3 = 0; num3 < collection3.Count; num3++) { SvgElement facbce3 = collection3[num3] as SvgElement; facbce3 = facbce3.Clone() as SvgElement; facbce2.AppendChild(facbce3); facbce2.AppendChild(this.svgDocument.CreateTextNode("\n")); } } //facbce1.SetAttribute("overflow", "visible"); } if (isdocument) { SvgElement facbce4 = (this.svgDocument.RootElement as SvgElement).CloneNode(false) as SvgElement; if (facbce1 != null) { facbce4.AppendChild(this.svgDocument.CreateTextNode("\n")); facbce4.AppendChild(facbce1); facbce4.AppendChild(this.svgDocument.CreateTextNode("\n")); } facbce1 = facbce4; } this.svgDocument.AcceptChanges = flag1; return facbce1; } internal void OnDragDrop(ISvgElement element, DragEventArgs e) { if (DragAndDrop!=null) { DragAndDrop(element,e); } } /* private void ChangeSelectEx(object sender, CollectionChangedEventArgs e) { SvgElement element1 = this.svgDocument.CurrentElement; if (this.propertyGrid != null) { if (this.SVGDocument.SelectCollection.Count == 1) { if (this.svgDocument.CurrentElement is ItopVector.Core.Figure.SVG) { this.propertyGrid.SelectedObject = null; } else { switch (this.svgDocument.CurrentElement.LocalName) { case "line": case "polyline": this.propertyGrid.SelectedObject = new ItopVector.Property.PropertyLineMarker(this.svgDocument.CurrentElement); break; case "text": this.propertyGrid.SelectedObject = new ItopVector.Property.PropertyText(this.svgDocument.CurrentElement); break; case "use": case "g": this.propertyGrid.SelectedObject = new ItopVector.Property.PropertyUse(this.svgDocument.CurrentElement); break; case "image": this.propertyGrid.SelectedObject = new ItopVector.Property.PropertyImage(this.svgDocument.CurrentElement); break; case "rect": this.propertyGrid.SelectedObject = new ItopVector.Property.PropertyRoundRect(this.svgDocument.CurrentElement); break; default: this.propertyGrid.SelectedObject = new ItopVector.Property.PropertyFill(this.svgDocument.CurrentElement); break; } } } else if (this.svgDocument.SelectCollection.Count == 0) { this.propertyGrid.SelectedObject = null; } else { object[] list1 = new object[this.svgDocument.SelectCollection.Count]; for (int i = 0; i < this.svgDocument.SelectCollection.Count; i++) { SvgElement element2 = (SvgElement) this.svgDocument.SelectCollection[i]; ItopVector.Property.PropertyBase propertybase = null; switch (element2.LocalName) { case "line": case "polyline": propertybase = new ItopVector.Property.PropertyLineMarker(element2); break; case "text": propertybase = new ItopVector.Property.PropertyText(element2); break; case "use": case "g": propertybase = new ItopVector.Property.PropertyUse(element2); break; case "image": propertybase = new ItopVector.Property.PropertyImage(element2); break; case "rect": propertybase = new ItopVector.Property.PropertyRoundRect(element2); break; default: propertybase = new ItopVector.Property.PropertyFill(element2); break; } list1[i] = propertybase; } this.propertyGrid.SelectedObjects = list1; } } } */ /// <summary> /// ����Mouseclick�¼� /// </summary> /// <param name="element"></param> /// <param name="e"></param> internal void OnMouseDownEvent(ISvgElement element, MouseEventArgs e) { SvgElementSelectedEventArgs args =new SvgElementSelectedEventArgs(element); args.Mouse=e; // SvgElement[] elements =new SvgElement[svgDocument.SelectCollection.Count]; // svgDocument.SelectCollection.CopyTo(elements,0); // args.Elements = elements; switch(e.Button) { case MouseButtons.Left: if (e.Clicks==1 && LeftClick!=null) { LeftClick(this,args); } else if(e.Clicks>1 && DoubleLeftClick!=null) { DoubleLeftClick(this,args); } break; case MouseButtons.Right: if (e.Clicks==1 && RightClick!=null) { if (element is SVG) { RightClick(this,args); } else { foreach(SvgElement element2 in this.svgDocument.SelectCollection) { IGraph graph2 = (IGraph)element2; using(GraphicsPath path4 = (GraphicsPath) graph2.GPath.Clone()) { RectangleF rf = path4.GetBounds(graph2.Transform.Matrix); Point pt1 = this.PointToView(new Point(e.X,e.Y)); if(rf.Contains(pt1)) { RightClick(this,args); return; } } } args.SvgElement = this.svgDocument.RootElement; RightClick(this,args); } } else if(e.Clicks>1 && DoubleRightClick!=null) { DoubleRightClick(this,args); } break; } }