public void InitData(string useid,string svguid,string Area,string str_rzb,string layID) { //gPro.UID = useid; layerID = layID; rzb = str_rzb; if (Area == "") { Area = "0"; } try { gPro.EleID = useid; gPro.SvgUID = svguid; IList svglist = Services.BaseService.GetList("SelectglebePropertyByEleID", gPro); if (svglist.Count > 0) { gPro = (glebeProperty)svglist[0]; IsCreate = false; } else { IsCreate = true; gPro.Area = Convert.ToDecimal(Area); gPro.UID = Guid.NewGuid().ToString(); gPro.ObligateField11 = "是"; gPro.LayerID = layerID; } bh.DataBindings.Add("Text", gPro, "UseID"); lx.DataBindings.Add("EditValue", gPro, "TypeUID"); mj.DataBindings.Add("Text", gPro, "Area"); fh.DataBindings.Add("Text", gPro, "Burthen"); dl.DataBindings.Add("Text", gPro, "Number"); xyxs.DataBindings.Add("Text", gPro, "ObligateField11"); remark.DataBindings.Add("Text", gPro, "Remark"); if (string.IsNullOrEmpty(gPro.ObligateField16)) { checkEdit1.Checked = false; } else { if (gPro.ObligateField16=="True") { checkEdit1.Checked =true; } else checkEdit1.Checked = false; } comboBoxEdit1.EditValue = gPro.ObligateField7; // comboBoxEdit1.DataBindings.Add("EditValue", gPro, "ObligateField7"); } catch(Exception e){ MessageBox.Show(e.Message); } }
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { FrmAddspatialarea FA = new FrmAddspatialarea(); FA.init(); if (FA.ShowDialog()==DialogResult.OK) { foreach (DataRow dr in dataTable.Rows) { if (dr["Title"]==FA.Areatitle) { MessageBox.Show("已经存在此地区!请重新选。"); return; } } glebeProperty gp = new glebeProperty(); gp.ParentEleID = "0"; gp.SvgUID = "c5ec3bc7-9706-4cbd-9b8b-632d3606f933"; gp.ObligateField16 = FA.Areatitle; IList<glebeProperty> svglist = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByObligateField16", gp); if (svglist.Count>0) { frmMainProperty f = new frmMainProperty(); f.IsReadonly = true; f.InitData(svglist[0], "", "",""); if (f.ShowDialog()==DialogResult.OK) { Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); psp_Type.ID = Guid.NewGuid().ToString(); psp_Type.Forecast = type; psp_Type.ForecastID = forecastReport.ID; psp_Type.Title = FA.Areatitle; glebeYearValue gy = new glebeYearValue(); IList<glebeYearValue> yearlist = Services.BaseService.GetList<glebeYearValue>("SelectglebeYearValueBywhere", "ParentID='" + svglist[0].UID + "'"); for (int i = 0; i < yearlist.Count;i++ ) { string y = "y" + yearlist[i].Year.ToString(); psp_Type.GetType().GetProperty(y).SetValue(psp_Type, yearlist[i].Burthen, null); } object obj = Services.BaseService.GetObject("SelectPs_Forecast_MathMaxID", null); if (obj != null) psp_Type.Sort = ((int)obj) + 1; else psp_Type.Sort = 1; try { Common.Services.BaseService.Create<Ps_Forecast_Math>(psp_Type); //psp_Type.ID = (int)Common.Services.BaseService.Create("InsertPSP_P_Types", psp_Type); dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow())); } catch (Exception ex) { MsgBox.Show("增加区域出错:" + ex.Message); } RefreshChart(); } } else { Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); psp_Type.ID = Guid.NewGuid().ToString(); psp_Type.Forecast = type; psp_Type.ForecastID = forecastReport.ID; psp_Type.Title = FA.Areatitle; //glebeYearValue gy = new glebeYearValue(); //IList<glebeYearValue> yearlist = Services.BaseService.GetList<glebeYearValue>("SelectglebeYearValueBywhere", "ParentID='" + svglist[0].UID + "'"); //for (int i = 0; i < yearlist.Count; i++) { // string y = "y" + yearlist[i].Year.ToString(); // psp_Type.GetType().GetProperty(y).SetValue(psp_Type, y, null); //} object obj = Services.BaseService.GetObject("SelectPs_Forecast_MathMaxID", null); if (obj != null) psp_Type.Sort = ((int)obj) + 1; else psp_Type.Sort = 1; try { Common.Services.BaseService.Create<Ps_Forecast_Math>(psp_Type); //psp_Type.ID = (int)Common.Services.BaseService.Create("InsertPSP_P_Types", psp_Type); dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow())); } catch (Exception ex) { MsgBox.Show("增加区域出错:" + ex.Message); } RefreshChart(); } } }
void tlVectorControl1_RightClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e) { if (MapType == "接线图") { tip.Hide(); contextMenuStrip1.Show(e.Mouse.X, e.Mouse.Y); if (getlayer(SvgDocument.currentLayer, "背景层", tlVectorControl1.SVGDocument.getLayerList())) { contextMenuStrip1.Enabled = false; } else { contextMenuStrip1.Enabled = true; } if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() != "ItopVector.Core.Figure.Use") { jxtMenuItem.Visible = false; } else { if (tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("xlink:href").Contains("Substation")) { jxtMenuItem.Visible = true; } } if (tlVectorControl1.Operation == ToolOperation.InterEnclosure) { System.Collections.SortedList list = new SortedList(); glebeProperty gPro = new glebeProperty(); decimal s = 0; ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection; if (selCol.Count > 1) { decimal ViewScale = 1; string str_Scale = tlVectorControl1.SVGDocument.getViewScale(); if (str_Scale != "") { ViewScale = Convert.ToDecimal(str_Scale); } string str_remark = ""; string str_selArea = ""; //string Elements = ""; Hashtable SelAreaCol = new Hashtable(); this.Cursor = Cursors.WaitCursor; int t = 0; Lab001: t = t + 1; XmlElement poly1 = (XmlElement)selCol[selCol.Count - t]; if (poly1.GetType().FullName != "ItopVector.Core.Figure.Polygon") { // selCol.Remove(selCol[selCol.Count-1]); goto Lab001; } frmWaiting wait = new frmWaiting(); wait.Show(this); wait.Refresh(); GraphicsPath gr1 = new GraphicsPath(); //gr1.AddRectangle(TLMath.getRectangle(poly1)); gr1.AddPolygon(TLMath.getPolygonPoints(poly1)); gr1.CloseFigure(); for (int i = 0; i < selCol.Count - 1; i++) { if (selCol[i].GetType().FullName == "ItopVector.Core.Figure.Polygon") { string IsArea = ((XmlElement)selCol[i]).GetAttribute("IsArea"); if (IsArea != "") { XmlElement polyn = (XmlElement)selCol[i]; GraphicsPath gr2 = new GraphicsPath(); //gr2.AddRectangle(TLMath.getRectangle(polyn)); gr2.AddPolygon(TLMath.getPolygonPoints(polyn)); gr2.CloseFigure(); Region region = new Region(gr1); region.Intersect(gr2); RectangleF rect = new RectangleF(); rect = tlVectorControl1.SelectedRectangle(region); decimal sub_s = TLMath.getInterPolygonArea(region, rect, ViewScale); sub_s = TLMath.getNumber2(sub_s, tlVectorControl1.ScaleRatio); SelAreaCol.Add(polyn.GetAttribute("id"), sub_s); glebeProperty _gleProp = new glebeProperty(); _gleProp.EleID = polyn.GetAttribute("id"); _gleProp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList gList = Services.BaseService.GetList("SelectglebePropertyByEleID", _gleProp); if (gList.Count > 0) { _gleProp = (glebeProperty)gList[0]; list.Add(_gleProp.UseID, sub_s.ToString("#####.####")); str_selArea = str_selArea + _gleProp.EleID + "," + sub_s.ToString("#####.####") + ";"; //str_remark = str_remark + "地块" + _gleProp.UseID + "选中面积为:" + sub_s.ToString() + "\r\n"; s += sub_s; } } } //if (selCol[i].GetType().FullName == "ItopVector.Core.Figure.Use") //{ // XmlElement e1 = (XmlElement)selCol[i]; // string str_id = e1.GetAttribute("id"); // substation _sub1 = new substation(); // _sub1.EleID = str_id; // _sub1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; // _sub1 = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub1); // if (_sub1 != null) // { // _sub1.glebeEleID = guid; // Services.BaseService.Update("Updatesubstation", _sub1); // } //} } decimal nullpoly = TLMath.getNumber2(TLMath.getPolygonArea(TLMath.getPolygonPoints(poly1), 1), tlVectorControl1.ScaleRatio) - s; for (int j = 0; j < list.Count; j++) { if (Convert.ToString(list.GetByIndex(j)) != "") { if (Convert.ToDecimal(list.GetByIndex(j)) < 1) { str_remark = str_remark + "地块" + list.GetKey(j).ToString() + "选中面积为:" + "0" + list.GetByIndex(j).ToString() + "(KM²)\r\n"; } else { str_remark = str_remark + "地块" + list.GetKey(j).ToString() + "选中面积为:" + list.GetByIndex(j).ToString() + "(KM²)\r\n"; } } } XmlElement x1 = poly1;// (XmlElement)selCol[selCol.Count - 1]; gPro.UID = Guid.NewGuid().ToString(); gPro.EleID = x1.GetAttribute("id"); gPro.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; gPro.ParentEleID = "0"; if (s != 0) { gPro.Area = Convert.ToDecimal(s.ToString("#####.####")); } else { gPro.Area = 0; } gPro.SelSonArea = str_selArea; if (nullpoly < 1) { gPro.ObligateField10 = "0" + nullpoly.ToString("#####.####"); } else { gPro.ObligateField10 = nullpoly.ToString("#####.####"); } str_remark = str_remark + "\r\n 空白区域面积" + gPro.ObligateField10 + "(KM²)\r\n"; if (str_remark != "") { str_remark = str_remark.Substring(0, str_remark.Length - 2); } gPro.Remark = str_remark; wait.Close(); this.Cursor = Cursors.Default; if (s < 1) { MessageBox.Show("选中区域面积:" + "0" + s.ToString("#####.####") + "(KM²)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("选中区域面积:" + s.ToString("#####.####") + "(KM²)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } Services.BaseService.Create<glebeProperty>(gPro); IDictionaryEnumerator ISelList = SelAreaCol.GetEnumerator(); while (ISelList.MoveNext()) { glebeProperty sub_gle = new glebeProperty(); sub_gle.EleID = ISelList.Key.ToString(); sub_gle.ParentEleID = gPro.EleID; sub_gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Update("UpdateglebePropertySelArea", sub_gle); } tlVectorControl1.SVGDocument.SelectCollection.Clear(); tlVectorControl1.SVGDocument.CurrentElement = (SvgElement)x1; } // SubPrint = false; } } else { contextMenuStrip1.Enabled = false; } }
void tlVectorControl1_RightClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e) { sel_sym = ""; sel_start_point = ""; try { if (csOperation == CustomOperation.OP_MeasureDistance) { tlVectorControl1.Operation = ToolOperation.Select; contextMenuStrip1.Hide(); return; } //tlVectorControl1.DocumentSize = new SizeF(3170f, 2540f); //MessageBox.Show(MapType); tmLineConnect.Visible = false; SvgElementCollection elements = tlVectorControl1.SVGDocument.SelectCollection; if (elements.Count == 2) { Polyline pl1 = elements[0] as Polyline; Polyline pl2 = elements[1] as Polyline; if (pl1 != null && pl2 != null && pl1.GetAttribute("IsLead") != "" && pl2.GetAttribute("IsLead") != "") { tmLineConnect.Visible = true; } } if (MapType == "接线图") { tip.Hide(); if (getlayer(SvgDocument.currentLayer, "背景层", tlVectorControl1.SVGDocument.getLayerList())) { contextMenuStrip1.Enabled = false; } else { contextMenuStrip1.Enabled = true; } if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() != "ItopVector.Core.Figure.Use") { moveMenuItem.Visible = false; jxtToolStripMenuItem.Visible = false; w3MenuItem.Visible = false; } else { if (tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("xlink:href").Contains("Substation")) { moveMenuItem.Visible = true; jxtToolStripMenuItem.Visible = true; w3MenuItem.Visible = true; } } if (show3d == 0) { w3MenuItem.Visible = false; } if (tlVectorControl1.SVGDocument.CurrentElement == null && tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() != "ItopVector.Core.Figure.RectangleElement" && tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() != "ItopVector.Core.Figure.Polygon") { printToolStripMenuItem.Visible = false; toolDel.Visible = false; SubToolStripMenuItem.Visible = false; } else { printToolStripMenuItem.Visible = true; toolDel.Visible = true; SubToolStripMenuItem.Visible = false; saveImg.Visible=true; } if (tlVectorControl1.SVGDocument.CurrentElement != null && tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") { mUpdateMenuItem.Visible = true; } else { mUpdateMenuItem.Visible = false; } string guid = Guid.NewGuid().ToString(); if (tlVectorControl1.Operation == ToolOperation.LeadLine && linekey != "") { string str = ""; LineList1 line1 = new LineList1(); line1.UID = Guid.NewGuid().ToString(); line1.LineEleID = tlVectorControl1.SVGDocument.CurrentElement.ID; line1.PointNum = ((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)).Points.Length - 2; line1.Coefficient = (decimal)(1.02); line1.Length = TLMath.getPolylineLength(((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)), Convert.ToDecimal(tlVectorControl1.ScaleRatio)); line1.Length2 = TLMath.getPolylineLength(((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)), Convert.ToDecimal(tlVectorControl1.ScaleRatio)) * Convert.ToDecimal(1.02); PointF[] pnt = ((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)).Points; if (pnt.Length < 3) return; for (int i = 0; i < pnt.Length; i++) { double ang = TLMath.getLineAngle(pnt[i], pnt[i + 1], pnt[i + 2]); if (ang * 57.3 > 60) { MessageBox.Show("线路转角不能大于60度。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.Delete(); return; } str = str + "第" + (i + 1) + "转角:" + Convert.ToDouble(ang * 57.3).ToString("##.##") + "度。\r\n"; if (i == pnt.Length - 3) { break; } } line1.TurnAngle = str; line1.col1 = linekey; frmInputDialog input = new frmInputDialog(); if (input.ShowDialog() == DialogResult.OK) { line1.LineName = input.InputStr; Services.BaseService.Create<LineList1>(line1); } else { tlVectorControl1.Delete(); } linekey = ""; } if (tlVectorControl1.Operation == ToolOperation.InterEnclosure && !SubPrint) { System.Collections.SortedList list = new SortedList(); decimal s = 0; ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection; if (selCol.Count > 1) { decimal ViewScale = 1; string str_Scale = tlVectorControl1.SVGDocument.getViewScale(); if (str_Scale != "") { ViewScale = Convert.ToDecimal(str_Scale); } string str_remark = ""; string str_selArea = ""; //string Elements = ""; Hashtable SelAreaCol = new Hashtable(); this.Cursor = Cursors.WaitCursor; int t = 0; Lab001: t = t + 1; XmlElement poly1 = (XmlElement)selCol[selCol.Count - t]; if (poly1.GetType().FullName != "ItopVector.Core.Figure.Polygon") { // selCol.Remove(selCol[selCol.Count-1]); goto Lab001; } frmWaiting wait = new frmWaiting(); wait.Show(this); wait.Refresh(); GraphicsPath gr1 = new GraphicsPath(); //gr1.AddRectangle(TLMath.getRectangle(poly1)); gr1.AddPolygon(TLMath.getPolygonPoints(poly1)); gr1.CloseFigure(); for (int i = 0; i < selCol.Count - 1; i++) { if (selCol[i].GetType().FullName == "ItopVector.Core.Figure.Polygon") { string IsArea = ((XmlElement)selCol[i]).GetAttribute("IsArea"); if (IsArea != "") { XmlElement polyn = (XmlElement)selCol[i]; GraphicsPath gr2 = new GraphicsPath(); //gr2.AddRectangle(TLMath.getRectangle(polyn)); gr2.AddPolygon(TLMath.getPolygonPoints(polyn)); gr2.CloseFigure(); Region region = new Region(gr1); region.Intersect(gr2); RectangleF rect = new RectangleF(); rect = tlVectorControl1.SelectedRectangle(region); decimal sub_s = TLMath.getInterPolygonArea(region, rect, ViewScale); sub_s = TLMath.getNumber2(sub_s, tlVectorControl1.ScaleRatio); SelAreaCol.Add(polyn.GetAttribute("id"), sub_s); glebeProperty _gleProp = new glebeProperty(); _gleProp.EleID = polyn.GetAttribute("id"); _gleProp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList gList = Services.BaseService.GetList("SelectglebePropertyByEleID", _gleProp); if (gList.Count > 0) { _gleProp = (glebeProperty)gList[0]; list.Add(_gleProp.UseID, sub_s.ToString("#####.####")); str_selArea = str_selArea + _gleProp.EleID + "," + sub_s.ToString("#####.####") + ";"; //str_remark = str_remark + "地块" + _gleProp.UseID + "选中面积为:" + sub_s.ToString() + "\r\n"; s += sub_s; } } } if (selCol[i].GetType().FullName == "ItopVector.Core.Figure.Use") { XmlElement e1 = (XmlElement)selCol[i]; string str_id = e1.GetAttribute("id"); substation _sub1 = new substation(); _sub1.EleID = str_id; _sub1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _sub1 = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub1); if (_sub1 != null) { _sub1.glebeEleID = guid; Services.BaseService.Update("Updatesubstation", _sub1); } } } decimal nullpoly = TLMath.getNumber2(TLMath.getPolygonArea(TLMath.getPolygonPoints(poly1), 1), tlVectorControl1.ScaleRatio) - s; for (int j = 0; j < list.Count; j++) { if (Convert.ToString(list.GetByIndex(j)) != "") { if (Convert.ToDecimal(list.GetByIndex(j)) < 1) { str_remark = str_remark + "地块" + list.GetKey(j).ToString() + "选中面积为:" + "0" + list.GetByIndex(j).ToString() + "(KM²)\r\n"; } else { str_remark = str_remark + "地块" + list.GetKey(j).ToString() + "选中面积为:" + list.GetByIndex(j).ToString() + "(KM²)\r\n"; } } } XmlElement x1 = poly1;// (XmlElement)selCol[selCol.Count - 1]; gPro.UID = guid; gPro.EleID = x1.GetAttribute("id"); gPro.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; gPro.ParentEleID = "0"; if (s != 0) { gPro.Area = Convert.ToDecimal(s.ToString("#####.####")); } else { gPro.Area = 0; } gPro.SelSonArea = str_selArea; if (nullpoly < 1) { gPro.ObligateField10 = "0" + nullpoly.ToString("#####.####"); } else { gPro.ObligateField10 = nullpoly.ToString("#####.####"); } str_remark = str_remark + "\r\n 空白区域面积" + gPro.ObligateField10 + "(KM²)\r\n"; if (str_remark != "") { str_remark = str_remark.Substring(0, str_remark.Length - 2); } gPro.Remark = str_remark; wait.Close(); this.Cursor = Cursors.Default; if (s < 1) { MessageBox.Show("选中区域面积:" + "0" + s.ToString("#####.####") + "(KM²)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("选中区域面积:" + s.ToString("#####.####") + "(KM²)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } Services.BaseService.Create<glebeProperty>(gPro); IDictionaryEnumerator ISelList = SelAreaCol.GetEnumerator(); while (ISelList.MoveNext()) { glebeProperty sub_gle = new glebeProperty(); sub_gle.EleID = ISelList.Key.ToString(); sub_gle.ParentEleID = gPro.EleID; sub_gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Update("UpdateglebePropertySelArea", sub_gle); } tlVectorControl1.SVGDocument.SelectCollection.Clear(); tlVectorControl1.SVGDocument.CurrentElement = (SvgElement)x1; } SubPrint = false; } if (tlVectorControl1.CurrentOperation == ToolOperation.InterEnclosure && SubPrint) { //ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection; //if(selCol.Count>2){ // XmlElement selArea = (SvgElement)selCol[selCol.Count - 1]; // GraphicsPath gr1 = new GraphicsPath(); // gr1.AddPolygon(TLMath.getPolygonPoints(selArea)); // gr1.CloseFigure(); // RectangleF rect= gr1.GetBounds(); // SvgDocument _doc = new SvgDocument(); // string svgtxt = "<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\""+rect.Width+"\" height=\""+rect.Height+"\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">"; // for (int n = 0; n < selCol.Count-1;n++ ) // { // //_doc.AppendChild((XmlNode)selCol[n]); // svgtxt=svgtxt+((XmlElement)selCol[n]).OuterXml+"\r\n"; // } // svgtxt = svgtxt + "</svg>"; // _doc.LoadXml(svgtxt); // frmSubPrint s = new frmSubPrint(); // s.Show(); // s.Open(_doc, rect); ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection; XmlElement x1 = (XmlElement)selCol[selCol.Count - 1]; tlVectorControl1.SVGDocument.SelectCollection.Clear(); tlVectorControl1.SVGDocument.CurrentElement = (SvgElement)x1; SubPrint = false; //} } if (tlVectorControl1.Operation == ToolOperation.Enclosure) { string Elements = ""; ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection; for (int i = 0; i < selCol.Count - 1; i++) { XmlElement e1 = (XmlElement)selCol[i]; Elements = Elements + "'" + e1.GetAttribute("id") + "',"; } if (Elements.Length > 0) { Elements = Elements.Substring(0, Elements.Length - 1); } XmlElement x1 = (XmlElement)selCol[selCol.Count - 1]; gPro.UID = Guid.NewGuid().ToString(); gPro.EleID = x1.GetAttribute("id"); gPro.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; gPro.SonUid = Elements; Services.BaseService.Create<glebeProperty>(gPro); tlVectorControl1.SVGDocument.SelectCollection.Clear(); tlVectorControl1.SVGDocument.CurrentElement = (SvgElement)x1; } if (tlVectorControl1.CurrentOperation == ToolOperation.LeadLine) { sgt1.Visible = false; } } } catch (Exception e1) { MessageBox.Show(e1.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.SelectCollection.Clear(); } finally { tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.FreeTransform; } }
private void PasteWithProperty() { DataFormats.Format format1 = DataFormats.GetFormat("SvgElement"); IDataObject obj1 = Clipboard.GetDataObject(); try { if (!obj1.GetDataPresent(format1.Name)) { return; } object obj2 = obj1.GetData(format1.Name); if (!(obj2 is CopyData)) { return; } string text1 = ((CopyData)obj2).XmlStr; SvgDocument document1 = tlVectorControl1.DrawArea.SVGDocument; bool flag1 = document1.AcceptChanges; document1.AcceptChanges = false; XmlDocumentFragment fragment1 = document1.CreateDocumentFragment(); bool flag2 = document1.firstload; document1.firstload = true; fragment1.InnerXml = text1; //document1.DealLast(); document1.firstload = flag2; XmlNode node1 = fragment1.FirstChild; document1.AcceptChanges = true; if (!(node1 is SVG)) { return; } document1.NumberOfUndoOperations = (2 * node1.ChildNodes.Count) + 200; DateTime dt1 = DateTime.Now; tlVectorControl1.DrawArea.BeginInsert(); // for (int num1 = 0; num1 < node1.ChildNodes.Count; num1++) // { // XmlNode node2 = node1.ChildNodes[num1]; // if (node2 is IGraph) // {此方法count在减少,内部XML功能,不好控制,所以撇了 // this.picturePanel.AddElement((SvgElement) node2); // num1--; // } // } foreach (XmlNode node2 in node1.ChildNodes) { if (node2 is IGraph) { SvgElement element = node2 as SvgElement; SvgElement temp = node2.CloneNode(true) as SvgElement; tlVectorControl1.DrawArea.AddElement(temp); LineInfo _line = new LineInfo(); _line.EleID = element.ID; _line.SvgUID = tlVectorControl1.DrawArea.SVGDocument.SvgdataUid; IList lineInfoList = Services.BaseService.GetList("SelectLineInfoByEleID", _line); foreach (LineInfo line in lineInfoList) { line.UID = Guid.NewGuid().ToString(); line.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; line.EleID = temp.ID; Services.BaseService.Create<LineInfo>(line); } glebeProperty gle = new glebeProperty(); gle.EleID = element.ID; gle.SvgUID = tlVectorControl1.DrawArea.SVGDocument.SvgdataUid; IList gleProList = Services.BaseService.GetList("SelectglebePropertyByEleID", gle); foreach (glebeProperty gleP in gleProList) { gleP.UID = Guid.NewGuid().ToString(); gleP.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; gleP.EleID = temp.ID; Services.BaseService.Create<glebeProperty>(gleP); } substation _sub = new substation(); _sub.EleID = element.ID; _sub.SvgUID = tlVectorControl1.DrawArea.SVGDocument.SvgdataUid; IList substationList = Services.BaseService.GetList("SelectsubstationByEleID", _sub); foreach (substation sub in substationList) { sub.UID = Guid.NewGuid().ToString(); sub.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; sub.EleID = temp.ID; Services.BaseService.Create<substation>(sub); } } } tlVectorControl1.DrawArea.EndInsert(); document1.AcceptChanges = flag1; document1.NotifyUndo(); // DateTime dt2=DateTime.Now; // TimeSpan tsp=dt2 -dt1; // this.picturePanel.ToolTip(tsp.ToString()+tsp.Milliseconds.ToString(),1); } catch (Exception e) { MessageBox.Show("粘贴对象失败!"); } }
private void dotNetBarManager1_ItemClick(object sender, EventArgs e) { DevComponents.DotNetBar.ButtonItem btItem = sender as DevComponents.DotNetBar.ButtonItem; //Layer layer1 = (Layer)LayerBox.ComboBoxEx.SelectedItem; if (btItem != null) { if (btItem.Name == "mRoam") { frmlar.Hide(); } else { frmlar.Show(); } switch (btItem.Name) { #region 文件操作 case "mNew": tlVectorControl1.NewFile(); break; case "mOpen": break; case "mImport": ExportImage(); //ImportDxf(); break; case "ImportDxf": ImportDxf(); break; case "btExSymbol": tlVectorControl1.ExportSymbol(); break; case "mSave": SaveButton(); break; case "mSaveSVG": tlVectorControl1.SaveAs(); break; case "mExit": //XmlElement s= (XmlElement)tlVectorControl1.SVGDocument.SelectCollection[0]; //Polygon p = (Polygon)s; //tlVectorControl1.SymbolSelector = this.symbolSelector; //tlVectorControl1.ExportSymbol(); //tlVectorControl1.CurrentOperation = ToolOperation.WindowZoom; //frmLayerList ff = new frmLayerList(); //ff.InitData(tlVectorControl1.SVGDocument.getLayerList()); //ff.Show(); //string aa = tlVectorControl1.SVGDocument.SvgdataUid; ////tlVectorControl1.NewFile(); //tlVectorControl1.OpenFile("d:\\2.svg"); //tlVectorControl1.SVGDocument.SvgdataUid = aa; //IList<LineInfo> list = Services.BaseService.GetList<LineInfo>("SelectLineInfoBySvgIDAll", line); this.Close(); //frmAddLine ff = new frmAddLine(); //ff.Show(); //tlVectorControl1.ExportSymbol(); //XmlNodeList n1111 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1']"); //for (int i = 0; i < n1111.Count; i++) //{ // XmlNode n1 = n1111[i]; // string na = ((XmlElement)n1).GetAttribute("info-name"); // string la = ((XmlElement)n1).GetAttribute("layer"); // string id = ((XmlElement)n1).GetAttribute("id"); // LineInfo ll = new LineInfo(); // ll.LineName = " LineName='" + na + "' and LayerID='" + la + "' and SvgUID='" + tlVectorControl1.SVGDocument.SvgdataUid + "'"; // ll = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByWhere", ll); // if (ll != null) // { // ll.EleID = id; // if (ll.Length == "") // { // ll.Length = "0"; // } // Services.BaseService.Update<LineInfo>(ll); // } //} //XmlNodeList list1 = tlVectorControl1.SVGDocument.SelectNodes("//*[@href=\"#实心杆塔0\"]"); //XmlNodeList list2 = tlVectorControl1.SVGDocument.SelectNodes("//*[@href=\"#实心杆塔1\"]"); //for (int i = 0; i < list1.Count; i++) //{ // tlVectorControl1.SVGDocument.RootElement.RemoveChild(list1[i]); //} //for (int j = 0; j < list2.Count; j++) //{ // tlVectorControl1.SVGDocument.RootElement.RemoveChild(list2[j]); //} //InitTK(); //XmlElement a = tlVectorControl1.SVGDocument.RootElement; //a.SetAttribute("height","3000"); //tlVectorControl1.Refresh(); //XmlElement b = tlVectorControl1.SVGDocument.GetElementById("circle49171"); //string a = tlVectorControl1.SVGDocument.OuterXml; //Hashtable hs = new Hashtable(); //XmlNodeList list = tlVectorControl1.SVGDocument.GetElementsByTagName("symbol"); //for (int i = 0; i < list.Count; i++) //{ // XmlNode node = list[i]; // hs.Add(i, node); // //((XmlElement)node).SetAttribute("id", "xxx" + i.ToString()); //} break; case "bt1": InitTK(); break; case "callCAD": try { //Autodesk.AutoCAD.Interop. if (MessageBox.Show("此操作需要花费较长时间,确认导出么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { CAD cad = new CAD(); cad.tlVectorControl1 = tlVectorControl1; cad.WriteDwg("ALL"); } } catch { MessageBox.Show("请安装AutoCAD2006或以上版本。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "callCADSub": try { //Autodesk.AutoCAD.Interop.AcadApplicationClass a = new Autodesk.AutoCAD.Interop.AcadApplicationClass(); if (MessageBox.Show("此操作需要花费较长时间,确认导出么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { CAD cad = new CAD(); cad.tlVectorControl1 = tlVectorControl1; string strlar = frmlar.getSelectedLayer(); cad.WriteDwg(strlar); } } catch { MessageBox.Show("请安装AutoCAD2006或以上版本。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "mPriSet": tlVectorControl1.PaperSetup(); break; case "mPrint": tlVectorControl1.Print(); break; case "mView": //frmSvgView fView = new frmSvgView(); //fView.Open(tlVectorControl1.SVGDocument.SvgdataUid); //fView.Show(); break; case "mViewScale": if (img != null) { frmtempViewScale fscale1 = new frmtempViewScale(); fscale1.ShowDialog(); } else { frmViewScale fScale = new frmViewScale(); string viewScale = tlVectorControl1.SVGDocument.getViewScale(); if (viewScale != "") { fScale.InitData(viewScale); } if (fScale.ShowDialog() == DialogResult.OK) { //viewScale = fScale.ViewScale; string _viewScale = fScale.ViewScale; tlVectorControl1.SVGDocument.setViewScale(_viewScale); if (viewScale == "") { viewScale = "1"; } Recalculate(Convert.ToDecimal(_viewScale) / Convert.ToDecimal(viewScale)); } } break; //case "mIncreaseView": // tlVectorControl1.Operation = ToolOperation.IncreaseView; // break; case "mRzb": frmRatio fRat = new frmRatio(); string viewRat = tlVectorControl1.SVGDocument.getRZBRatio(); if (viewRat != "") { fRat.InitData(viewRat); } if (fRat.ShowDialog() == DialogResult.OK) { viewRat = fRat.ViewScale; tlVectorControl1.SVGDocument.setRZBRatio(viewRat); } break; case "mEdit": if (MapType == "所内接线图") { Save(); dotNetBarManager1.Bars["mainmenu"].GetItem("ImportDxf").Visible = false; svg.SUID = ParentUID; IList svglist = Services.BaseService.GetList("SelectSVGFILEByKey", svg); svg = (SVGFILE)svglist[0]; sdoc = null; sdoc = new SvgDocument(); sdoc.LoadXml(svg.SVGDATA); tlVectorControl1.SVGDocument = sdoc; tlVectorControl1.SVGDocument.SvgdataUid = svg.SUID; MapType = "接线图"; CtrlSvgView.MapType = "接线图"; LoadShape("symbol_3.xml"); Init(progtype); //ButtonEnb(true); frmlar.SymbolDoc = tlVectorControl1.SVGDocument; frmlar.Progtype = progtype; frmlar.InitData(); dotNetBarManager1.Bars["mainmenu"].GetItem("ButtonItem2").Enabled = true; dotNetBarManager1.Bars["mainmenu"].GetItem("ButtonItem7").Enabled = true; bk1.Enabled = true; LoadImage = true; tlVectorControl1.Refresh(); } tlVectorControl1.ContextMenuStrip = contextMenuStrip1; MapType = "接线图"; break; case "mAbout": frmAbout frma = new frmAbout(); frma.ShowDialog(); break; //基础操作 case "mFreeTransform": tlVectorControl1.Operation = ToolOperation.FreeTransform; break; case "mRoam1": tlVectorControl1.Operation = ToolOperation.Roam; break; case "mShapeTransform1": tlVectorControl1.Operation = ToolOperation.Custom11; break; case "mShapeTransform2": tlVectorControl1.Operation = ToolOperation.Custom12; break; case "mShapeTransform3": tlVectorControl1.Operation = ToolOperation.Custom13; break; case "mShapeTransform4": tlVectorControl1.Operation = ToolOperation.Custom15; break; case "mShapeTransform5": tlVectorControl1.Operation = ToolOperation.Custom14; break; case "m_ljxl": ConnLine(); break; case "mAngleRectangle1": tlVectorControl1.Operation = ToolOperation.AngleRectangle; break; case "mSelect1": case "mSel1": //tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.FreeTransform; break; case "mLine1": tlVectorControl1.Operation = ToolOperation.Line; break; case "mPolyline1": tlVectorControl1.Operation = ToolOperation.PolyLine; break; case "mImage1": tlVectorControl1.Operation = ToolOperation.Image; break; case "mText1": tlVectorControl1.Operation = ToolOperation.Text; break; case "mEllipse1": tlVectorControl1.Operation = ToolOperation.Ellipse; break; case "mBezier1": tlVectorControl1.Operation = ToolOperation.Bezier; break; //图元操作 case "mCopy1": tlVectorControl1.Copy(); break; case "mCut1": tlVectorControl1.Cut(); break; case "mPaste1": PasteWithProperty(); break; case "mDelete1": if (tlVectorControl1.SVGDocument.CurrentElement != null && tlVectorControl1.SVGDocument.CurrentElement.ID != "svg") { frmMessageBox msg = new frmMessageBox(); if (msg.ShowDialog() == DialogResult.OK) { if (msg.ck) { // if(MessageBox.Show("确认删除么?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Information)==DialogResult.Yes){ for (int i = 0; i < tlVectorControl1.SVGDocument.SelectCollection.Count; i++) { if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polygon") { glebeProperty gle = new glebeProperty(); gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; gle.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; Services.BaseService.Update("DeleteglebePropertyByEleID", gle); } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line") { LineInfo _line = new LineInfo(); _line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _line.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; LineInfo temp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _line); if (temp != null) { Services.BaseService.Update("DeleteLinePropertyByEleID", _line); Services.BaseService.Update("DeleteLine_InfoByCode", temp.UID); } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use") { string str_name = ((XmlElement)(tlVectorControl1.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href"); if (str_name.Contains("Substation")) { substation _sub = new substation(); _sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _sub.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; substation temp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub); if (temp != null) { Services.BaseService.Update("DeletesubstationByEleID", _sub); Services.BaseService.Update("DeleteSubstation_InfoByCode", temp.UID); } } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") { ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.SelectCollection[i]; if (cline.StartGraph != null) { SvgElement ele = (SvgElement)cline.StartGraph; if (!ele.GetAttribute("xlink:href").Contains("Substation")) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.StartGraph); } } if (cline.EndGraph != null) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.EndGraph); } } } } else { for (int i = 0; i < tlVectorControl1.SVGDocument.SelectCollection.Count; i++) { if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line") { LineInfo _line = new LineInfo(); _line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _line.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; LineInfo linetemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _line); if (linetemp != null) { PowerProTypes temp = (PowerProTypes)Services.BaseService.GetObject("SelectPowerProTypesByCode", linetemp.UID); if (temp != null) { linetemp.EleID = ""; Services.BaseService.Update<LineInfo>(linetemp); } else { Services.BaseService.Update("DeleteLineInfo", linetemp); } } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use") { string str_name = ((XmlElement)(tlVectorControl1.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href"); if (str_name.Contains("Substation")) { substation _sub = new substation(); _sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _sub.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; substation subtemp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub); if (subtemp != null) { PowerProTypes temp = (PowerProTypes)Services.BaseService.GetObject("SelectPowerProTypesByCode", subtemp.UID); if (temp != null) { subtemp.EleID = ""; Services.BaseService.Update<substation>(subtemp); } else { Services.BaseService.Update("Deletesubstation", subtemp); } } } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") { ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.SelectCollection[i]; if (cline.StartGraph != null) { SvgElement ele = (SvgElement)cline.StartGraph; if (!ele.GetAttribute("xlink:href").Contains("Substation")) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.StartGraph); } } if (cline.EndGraph != null) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.EndGraph); } } } } tlVectorControl1.Delete(); } } //tlVectorControl1.Operation = ToolOperation.Select; break; case "mUodo1": tlVectorControl1.Undo(); break; case "mRedo1": tlVectorControl1.Redo(); break; case "mAlign1": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.Align(AlignType.Left); } else { tlVectorControl1.Align(AlignType.Left); } tlVectorControl1.Refresh(); break; case "mAlignLeft1": tlVectorControl1.Align(AlignType.Left); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignRight1": tlVectorControl1.Align(AlignType.Right); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignTop1": tlVectorControl1.Align(AlignType.Top); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignBottom1": tlVectorControl1.Align(AlignType.Bottom); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignHorizontalCenter1": tlVectorControl1.Align(AlignType.HorizontalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignVerticalCenter1": tlVectorControl1.Align(AlignType.VerticalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mOrder1": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.ChangeLevel(LevelType.Top); } else { tlVectorControl1.ChangeLevel(LevelType.Top); } break; case "mGoTop1": tlVectorControl1.ChangeLevel(LevelType.Top); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoUp1": tlVectorControl1.ChangeLevel(LevelType.Up); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoDown1": tlVectorControl1.ChangeLevel(LevelType.Down); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoBottom1": tlVectorControl1.ChangeLevel(LevelType.Bottom); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mRotate1": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.FlipX(); } else { tlVectorControl1.FlipX(); } break; case "mToH1": tlVectorControl1.FlipX(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToV1": tlVectorControl1.FlipY(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToLeft1": tlVectorControl1.RotateSelection(-90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToRight1": tlVectorControl1.RotateSelection(90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; //图形操作 case "mLeadLine1": //tlVectorControl1.DrawArea.BackgroundImage = System.Drawing.Image.FromFile("f:\\back11.jpg"); //tlVectorControl1.DrawArea.BackgroundImageLayout = ImageLayout.Center; if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("电网规划层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // sgt1.Visible = true; tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.LeadLine; break; case "mAreaPoly1": if (!getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("城市规划层")) { MessageBox.Show("请选择城市规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.AreaPolygon; break; case "mFzzj1": //放置注记 if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //LayerBox.ComboBoxEx.SelectedIndex = 2; tlVectorControl1.Operation = ToolOperation.Select; MapType = "规划统计"; break; case "mPriQu1": SubPrint = true; tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint; break; case "mReCompute1": if (MessageBox.Show("确认要重新计算全图的电量和负荷么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string scale = tlVectorControl1.SVGDocument.getViewScale(); if (scale != "") { Recalculate(Convert.ToDecimal(scale)); } else { Recalculate(1); } MessageBox.Show("重新计算完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "mFhbz1": if (MessageBox.Show("是否生成负荷标注?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Fhbz(); } break; case "mCJ": tlVectorControl1.Operation = ToolOperation.PolyLine; csOperation = CustomOperation.OP_MeasureDistance; break; #endregion #region 基础图元 case "mDecreaseView": tlVectorControl1.Operation = ToolOperation.DecreaseView; break; case "mIncreaseView": tlVectorControl1.Operation = ToolOperation.IncreaseView; break; case "mRoam": tlVectorControl1.Operation = ToolOperation.Roam; break; case "mSelect": case "mSel": //tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.FreeTransform; sel_sym = ""; sel_start_point = ""; break; //case "mFreeTransform": // tlVectorControl1.Operation = ToolOperation.FreeTransform; // break; case "mFreeLines"://锁套 tlVectorControl1.Operation = ToolOperation.FreeLines; break; case "mFreePath": tlVectorControl1.Operation = ToolOperation.FreePath; break; case "mShapeTransform": tlVectorControl1.Operation = ToolOperation.ShapeTransform; break; case "mAngleRectangle": tlVectorControl1.Operation = ToolOperation.AngleRectangle; break; case "mEllipse": tlVectorControl1.Operation = ToolOperation.Ellipse; break; case "mLine": tlVectorControl1.Operation = ToolOperation.Line; break; case "mPolyline": tlVectorControl1.Operation = ToolOperation.PolyLine; break; case "mPolygon": tlVectorControl1.Operation = ToolOperation.Polygon; break; case "mImage": tlVectorControl1.Operation = ToolOperation.Image; break; case "mText": tlVectorControl1.Operation = ToolOperation.Text; break; case "mBezier": tlVectorControl1.Operation = ToolOperation.Bezier; break; case "mEnclosure": tlVectorControl1.Operation = ToolOperation.Enclosure; break; case "mGroup": tlVectorControl1.Group(); break; case "mUnGroup": tlVectorControl1.UnGroup(); break; case "mlinelx": tlVectorControl1.Operation = ToolOperation.ConnectLine_Line; break; case "mzxlx": tlVectorControl1.Operation = ToolOperation.ConnectLine_Rightangle; break; case "mqxlx": tlVectorControl1.Operation = ToolOperation.ConnectLine_Spline; break; case "mqzlx": tlVectorControl1.Operation = ToolOperation.ConnectLine_Polyline; break; case "mCJ1": tlVectorControl1.Operation = ToolOperation.PolyLine; csOperation = CustomOperation.OP_MeasureDistance; break; #endregion #region 视图 case "mOption": tlVectorControl1.SetOption(); break; case "mLayer": LayerManagerShow(); //tlVectorControl1.LayerManager(); break; case "mAirscape": frmAirscape fAir = new frmAirscape(); fAir.InitData(tlVectorControl1); fAir.Owner = this; fAir.ShowInTaskbar = false; fAir.Top = Screen.PrimaryScreen.WorkingArea.Height - 250; fAir.Left = Screen.PrimaryScreen.WorkingArea.Width - 300; fAir.Show(); break; case "btTL": frmGlebeTypeList fgle = new frmGlebeTypeList(); fgle.Show(); break; case "mMapOpacity"://地图透明度 frmMapSetup dlg = new frmMapSetup(); dlg.MapOpacity = this.MapOpacity; if (dlg.ShowDialog() == DialogResult.OK) { this.MapOpacity = dlg.MapOpacity; } break; #endregion #region 查看 case "mDklb": //SaveAllLayer(); frmLayerList lay = new frmLayerList(); lay.InitData(tlVectorControl1.SVGDocument.getLayerList(), "1"); if (lay.ShowDialog() == DialogResult.OK) { frmglebePropertyList flist1 = new frmglebePropertyList(); flist1.InitDataSub(tlVectorControl1.SVGDocument.SvgdataUid, lay.str_sid); flist1.Show(); } break; case "m_dktj": frmLayerList layn = new frmLayerList(); layn.InitData(tlVectorControl1.SVGDocument.getLayerList(), "1"); if (layn.ShowDialog() == DialogResult.OK) { frmglebePropertyZHList flist1 = new frmglebePropertyZHList(); flist1.InitDataSub(tlVectorControl1.SVGDocument.SvgdataUid, layn.str_sid); flist1.Show(); } break; case "mGhlb": frmLayerList lay2 = new frmLayerList(); lay2.InitData(tlVectorControl1.SVGDocument.getLayerList(), "2"); if (lay2.ShowDialog() == DialogResult.OK) { frmglebePropertyList flist2 = new frmglebePropertyList(); flist2.InitData(tlVectorControl1.SVGDocument.SvgdataUid, lay2.str_sid); flist2.Show(); } break; case "mLineList": frmLayerList lay3 = new frmLayerList(); lay3.InitData(tlVectorControl1.SVGDocument.getLayerList(), "2"); if (lay3.ShowDialog() == DialogResult.OK) { frmLinePropertyList flist3 = new frmLinePropertyList(); flist3.InitData(tlVectorControl1.SVGDocument.SvgdataUid, lay3.str_sid); flist3.Show(); } break; case "mDlph": frmLayerList lay4 = new frmLayerList(); lay4.InitData(tlVectorControl1.SVGDocument.getLayerList(), "3"); if (lay4.ShowDialog() == DialogResult.OK) { frmSubstationPropertyList fSub = new frmSubstationPropertyList(); fSub.InitData(tlVectorControl1.SVGDocument.SvgdataUid, lay4.str_sid); fSub.Show(); } break; case "ButtonJXT": if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg" || (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString()) != "ItopVector.Core.Figure.Use") { MessageBox.Show("没有选择变电站!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ParentUID = tlVectorControl1.SVGDocument.SvgdataUid; Save(); ParentUID = tlVectorControl1.SVGDocument.SvgdataUid; SVGFILE svg_temp = new SVGFILE(); svg_temp.SUID = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("id"); svg_temp.FILENAME = getBdzName(svg_temp.SUID);// IList svglist1 = Services.BaseService.GetList("SelectSVGFILEByKey", svg_temp); OpenJXT(svglist1, svg_temp); //frmlar.SymbolDoc = tlVectorControl1.SVGDocument; //frmlar.Progtype = MapType; //frmlar.InitData(); //JxtBar(); break; #endregion #region 布局,对齐,顺序 case "mRotate": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.FlipX(); } else { tlVectorControl1.FlipX(); } break; case "mToH": tlVectorControl1.FlipX(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToV": tlVectorControl1.FlipY(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToLeft": tlVectorControl1.RotateSelection(-90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToRight": tlVectorControl1.RotateSelection(90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mAlign": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.Align(AlignType.Left); } else { tlVectorControl1.Align(AlignType.Left); } tlVectorControl1.Refresh(); break; case "mAlignLeft": tlVectorControl1.Align(AlignType.Left); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignRight": tlVectorControl1.Align(AlignType.Right); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignTop": tlVectorControl1.Align(AlignType.Top); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignBottom": tlVectorControl1.Align(AlignType.Bottom); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignHorizontalCenter": tlVectorControl1.Align(AlignType.HorizontalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignVerticalCenter": tlVectorControl1.Align(AlignType.VerticalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mOrder": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.ChangeLevel(LevelType.Top); } else { tlVectorControl1.ChangeLevel(LevelType.Top); } break; case "mGoTop": tlVectorControl1.ChangeLevel(LevelType.Top); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoUp": tlVectorControl1.ChangeLevel(LevelType.Up); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoDown": tlVectorControl1.ChangeLevel(LevelType.Down); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoBottom": tlVectorControl1.ChangeLevel(LevelType.Bottom); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; #endregion #region 图元操作 case "mCopy": tlVectorControl1.Copy(); break; case "mCut": tlVectorControl1.Cut(); break; case "mPaste": //tlVectorControl1.Paste(); PasteWithProperty(); break; case "mDelete": Delete(); //tlVectorControl1.Operation = ToolOperation.Select; break; case "mUodo": tlVectorControl1.Undo(); break; case "mRedo": tlVectorControl1.Redo(); break; #endregion #region 业务操作 case "m_line1": //线路走廊优化 frmPlanList f = new frmPlanList(); if (f.ShowDialog() == DialogResult.Yes) { linekey = f.Key; tlVectorControl1.Operation = ToolOperation.Select; //tlVectorControl1.Operation = ToolOperation.LeadLine; } break; case "m_subxz": //变电站选址 frmSubstationManager mng = new frmSubstationManager(); DialogResult dia = mng.ShowDialog(); if (dia == DialogResult.OK) { XZ_bdz = mng.code; MessageBox.Show("请选择变电站拖放置到希望的位置。"); } if (dia == DialogResult.Ignore) { string keyid = mng.KeyID; string suid = mng.SUID; PSP_SubstationUserNum n1 = new PSP_SubstationUserNum(); n1.col2 = keyid; IList<PSP_SubstationUserNum> list1 = Services.BaseService.GetList<PSP_SubstationUserNum>("SelectPSP_SubstationNum2", n1); for (int i = 0; i < list1.Count; i++) { if (suid != list1[i].SubStationID) { PSP_SubstationSelect s = new PSP_SubstationSelect(); s.UID = list1[i].SubStationID; s.EleID = list1[i].userID; XmlNodeList nnn1 = tlVectorControl1.SVGDocument.SelectNodes("//* [@id='" + s.EleID + "']"); foreach (XmlNode node1 in nnn1) { tlVectorControl1.SVGDocument.RootElement.RemoveChild(node1); } Services.BaseService.Update("DeletePSP_SubstationSelect", s); } } tlVectorControl1.Refresh(); } break; case "mSubPrint": //tlVectorControl1.CurrentOperation = ToolOperation.InterEnclosure; //SubPrint = true; //frmSubPrint s = new frmSubPrint(); ////s.Open(tlVectorControl1.SVGDocument); //s.Show(); Hashtable HashTable1 = new Hashtable(); HashTable1.Add("SUID", tlVectorControl1.SVGDocument.SvgdataUid); Services.BaseService.Update("UpdateGlebePropertyAll", HashTable1); break; case "ORP": OpenProject orp = new OpenProject(); orp.ProjectID = Itop.Client.MIS.ProgUID; orp.Initdata(false); if (orp.ShowDialog() == DialogResult.OK) { if (orp.FileSUID != null) { ElectricLoadCal elcORP = new ElectricLoadCal(); elcORP.ORP(orp.FileSUID, 100); } } break; case "mJQLeadLine": tlVectorControl1.Operation = ToolOperation.Select; frmAddLine aLine = new frmAddLine(); if (aLine.ShowDialog() == DialogResult.OK) { string points = ""; ArrayList list = aLine.list; LineInfo line = aLine.line; string lineWidth = aLine.LineWidth; //ICollection Ilist = list.Values; //IEnumerator IEnum=Ilist.GetEnumerator(); for (int n = 0; n < list.Count; n++) { //while (IEnum.MoveNext()) //{ string[] str = ((string)list[n]).Split(','); //string[] str = ((string)IEnum.Current).Split(','); string[] JWD1 = str[0].Split(' '); Double J1 = Convert.ToDouble(JWD1[0]); Double W1 = Convert.ToDouble(JWD1[1]); Double D1 = Convert.ToDouble(JWD1[2]); string[] JWD2 = str[1].Split(' '); Double J2 = Convert.ToDouble(JWD2[0]); Double W2 = Convert.ToDouble(JWD2[1]); Double D2 = Convert.ToDouble(JWD2[2]); Double JD = J1 + W1 / 60 + D1 / 3600; Double WD = J2 + W2 / 60 + D2 / 3600; IntXY xy = mapview.getXY(JD, WD); points = points + (-xy.X / (Double)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (Double)tlVectorControl1.ScaleRatio) + ","; //} } if (points.Length > 1) { points = points.Substring(0, points.Length - 1); } //string styleValue = ""; //if (line.ObligateField1 == "规划") //{ // styleValue = "stroke-dasharray:4 4;stroke-width:" + lineWidth + ";"; //} //else //{ // styleValue = "stroke-width:" + lineWidth + ";"; //} //styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(line.ObligateField2))); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; n1.SetAttribute("IsLead", "1"); n1.SetAttribute("points", points); n1.SetAttribute("layer", SvgDocument.currentLayer); // n1.SetAttribute("style", styleValue); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); line.UID = Guid.NewGuid().ToString(); line.EleID = n1.GetAttribute("id"); line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<LineInfo>(line); } break; case "mLeadLine": //tlVectorControl1.DrawArea.BackgroundImage = System.Drawing.Image.FromFile("f:\\back11.jpg"); //tlVectorControl1.DrawArea.BackgroundImageLayout = ImageLayout.Center; if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("电网规划层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // sgt1.Visible = true; tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.LeadLine; break; case "mAreaPoly": if (!getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("城市规划层")) { MessageBox.Show("请选择城市规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.AreaPolygon; break; case "mFx": SubPrint = false; bool ck = false; CheckedListBox.CheckedItemCollection ckcol = frmlar.checkedListBox1.CheckedItems; for (int i = 0; i < ckcol.Count; i++) { Layer _lar = ckcol[i] as Layer; if (_lar.GetAttribute("layerType") == "城市规划层") { ck = true; } } if (!ck) { MessageBox.Show("请打开城市规划层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.InterEnclosure; MapType = "接线图"; break; case "mGhfx": if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl1.Operation = ToolOperation.Enclosure; // SvgDocument.currentLayer = getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID; MapType = "接线图"; //bar2.Visible = false; break; //case "mEdit": // //bar2.Visible = true; // SvgDocument.currentLayer = "layer97052"; // MapType = "接线图"; // break; case "mFzzj": //放置注记 if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //LayerBox.ComboBoxEx.SelectedIndex = 2; tlVectorControl1.Operation = ToolOperation.Select; MapType = "规划统计"; break; case "mDkwh": //地块维护 frmPropertyClass frmProp = new frmPropertyClass(); frmProp.ShowDialog(); break; case "mDkfl": //地块分类 if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } frmUsePropertySelect frmUseSel = new frmUsePropertySelect(); frmUseSel.InitData(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid); frmUseSel.ShowDialog(); break; case "mGldt": //关联地图 if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } frmFileSelect frmSel = new frmFileSelect(); frmSel.InitData(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid, true); frmSel.ShowDialog(); break; case "mPriQu": SubPrint = true; tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint; break; case "mReCompute": if (MessageBox.Show("确认要重新计算全图的电量和负荷么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string scale = tlVectorControl1.SVGDocument.getViewScale(); if (scale != "") { Recalculate(Convert.ToDecimal(scale)); } else { Recalculate(1); } MessageBox.Show("重新计算完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "mXLine": tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.XPolyLine; break; case "mYLine": tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.YPolyLine; break; case "mFhbz": if (MessageBox.Show("是否生成负荷标注?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Fhbz(); } break; case "mSaveGroup": if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1) { string content = "<svg>"; SvgElementCollection col = tlVectorControl1.SVGDocument.SelectCollection; for (int i = 0; i < col.Count; i++) { SvgElement _e = (SvgElement)col[i]; if (_e.ID != "svg") { content = content + _e.OuterXml; } } RectangleF rect = tlVectorControl1.DrawArea.viewer.SelectedViewRectangle; content = content + "</svg>"; frmSaveGroup fm = new frmSaveGroup(); fm.rect = rect; fm.Content = content; fm.ShowDialog(); } else { MessageBox.Show("请至少选择2个图元。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } break; case "mInsert": frmUseGroup fg = new frmUseGroup(); if (fg.ShowDialog() == DialogResult.OK) { UseGroup u = fg.SelectedUseGroup; if (u != null) { frmXY xy = new frmXY(); if (xy.ShowDialog() == DialogResult.OK) { decimal x = xy.GetX(); decimal y = xy.GetY(); string content = u.Content; XmlDocument doc = new XmlDocument(); doc.LoadXml(u.Content); XmlNodeList list = doc.ChildNodes; XmlNode _node = list[0]; XmlNodeList sonlist = _node.ChildNodes; XmlElement ele = tlVectorControl1.SVGDocument.CreateElement("g"); ele.SetAttribute("layer", SvgDocument.currentLayer); for (int i = 0; i < sonlist.Count; i++) { XmlNode _sonnode = sonlist[i]; //string str = _sonnode.OuterXml; if (_sonnode.Name == "use") { string sid = ((XmlElement)_sonnode).GetAttribute("xlink:href"); XmlNode _snode = symbolSelector.SymbolDoc.SelectSingleNode("//*[@id='" + sid.Substring(1) + "']"); tlVectorControl1.SVGDocument.AddDefsElement((SvgElement)_snode); } ele.AppendChild(_sonnode); string ss = ele.OuterXml; } //RectangleF r=((Group)ele).GetBounds(); string tr = "matrix(1,0,0,1,"; tr = tr + Convert.ToString(x - Convert.ToDecimal(u.X)) + ","; tr = tr + Convert.ToString(y - Convert.ToDecimal(u.Y)) + ")"; ele.SetAttribute("transform", tr); // transform="matrix(1,0,0,1,2558.82,-352.94)" tlVectorControl1.SVGDocument.RootElement.AppendChild(ele); tlVectorControl1.SVGDocument.SelectCollection.Clear(); tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)ele); tlVectorControl1.UnGroup(); // tlVectorControl1.Refresh(); } } } break; case "m_tp": frmImgManager frm = new frmImgManager(); frm.StrName = ""; frm.StrRemark = ""; frm.ShowDialog(); break; case "m_reDraw": string svguid = tlVectorControl1.SVGDocument.SvgdataUid; XmlNodeList nn1 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1']"); LineType lt = new LineType(); IList tpList = Services.BaseService.GetList("SelectLineTypeList", lt); Hashtable dkHs = new Hashtable(); for (int i = 0; i < tpList.Count; i++) { LineType _gle = (LineType)tpList[i]; dkHs.Add(_gle.TypeName, _gle.Color); } bool bo = tlVectorControl1.SVGDocument.Update; tlVectorControl1.SVGDocument.Update = false; for (int j = 0; j < nn1.Count; j++) { XmlElement _node1 = (XmlElement)nn1.Item(j); LineInfo line = new LineInfo(); line.SvgUID = svguid; line.EleID = _node1.GetAttribute("id"); line = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", line); if (line != null) { string t = (string)dkHs[line.Voltage + "kV"]; string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(t))); ItopVector.Core.Func.AttributeFunc.SetAttributeValue(_node1, "stroke", color1); } } tlVectorControl1.SVGDocument.Update = bo; break; case "m_subColor": string svguid1 = tlVectorControl1.SVGDocument.SvgdataUid; XmlNodeList nn2 = tlVectorControl1.SVGDocument.SelectNodes("svg/defs/symbol"); LineType lt1 = new LineType(); IList tpList1 = Services.BaseService.GetList("SelectLineTypeList", lt1); Hashtable dkHs1 = new Hashtable(); for (int i = 0; i < tpList1.Count; i++) { LineType _gle = (LineType)tpList1[i]; dkHs1.Add(_gle.TypeName.ToLower(), _gle.Color); } bool bo1 = tlVectorControl1.SVGDocument.Update; tlVectorControl1.SVGDocument.Update = false; Regex regex = new Regex(@"\d{2,3}(?=kv)"); foreach (Symbol _node1 in nn2) { string subName = _node1.GetAttribute("label").ToLower(); Match match1 = regex.Match(subName); if (match1.Success) { try { string t = (string)dkHs1[match1.Value + "kv"]; //if (match1.Value == "220") //{ // t = t; //} string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(t))); foreach (SvgElement element in _node1.GraphList) { if (element.SvgAttributes.ContainsKey("stroke") && element.SvgAttributes["stroke"].ToString() != "#FFFFFF") { ItopVector.Core.Func.AttributeFunc.SetAttributeValue(element, "stroke", color1); } if (element.SvgAttributes.ContainsKey("fill") && element.SvgAttributes["fill"].ToString() != "#FFFFFF") { ItopVector.Core.Func.AttributeFunc.SetAttributeValue(element, "fill", color1); } if (element.SvgAttributes.ContainsKey("hatch-color") && element.SvgAttributes["hatch-color"].ToString() != "#FFFFFF") { ItopVector.Core.Func.AttributeFunc.SetAttributeValue(element, "hatch-color", color1); } } } catch { } } //XmlElement _node1 = (XmlElement)nn2.Item(j); //substation line = new substation(); //line.SvgUID = svguid1; //line.EleID = _node1.GetAttribute("id"); //line = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", line); //if (line != null) //{ // string t = (string)dkHs1[line.ObligateField1 + "kV"]; // string ut = _node1.GetAttribute("usestyle"); // string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(t))); // ItopVector.Core.Func.AttributeFunc.SetAttributeValue(_node1, "stroke", color1); // if (ut != "true") // { // ItopVector.Core.Func.AttributeFunc.SetAttributeValue(_node1, "usestyle", "true"); // } // else // { // ItopVector.Core.Func.AttributeFunc.SetAttributeValue(_node1, "usestyle", "false"); // } //} } tlVectorControl1.SVGDocument.Update = bo1; break; #endregion #region 图层操作 case "layerImport": tlVectorControl1.Operation = ToolOperation.FreePath; layerImport(); break; case "layerExport": layerExport(); break; case "m_kbsText": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[12]); WD = Convert.ToDecimal(r1[13]); PointF fnt = mapview.ParseToPoint(JD, WD); XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t1.SetAttribute("x", Convert.ToString(fnt.X / (float)tlVectorControl1.ScaleRatio + 8)); t1.SetAttribute("y", Convert.ToString(fnt.Y / (float)tlVectorControl1.ScaleRatio)); t1.SetAttribute("layer", SvgDocument.currentLayer); t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t1.SetAttribute("font-famliy", "宋体"); t1.SetAttribute("font-size", "6"); t1.InnerText = r1[2].ToString(); tlVectorControl1.SVGDocument.RootElement.AppendChild(t1); } } tlVectorControl1.Refresh(); } break; case "m_fText": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[9]); WD = Convert.ToDecimal(r1[10]); PointF fnt = mapview.ParseToPoint(JD, WD); XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t1.SetAttribute("x", Convert.ToString(fnt.X / (float)tlVectorControl1.ScaleRatio + 8)); t1.SetAttribute("y", Convert.ToString(fnt.Y / (float)tlVectorControl1.ScaleRatio)); t1.SetAttribute("layer", SvgDocument.currentLayer); t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t1.SetAttribute("font-famliy", "宋体"); t1.SetAttribute("font-size", "6"); t1.InnerText = r1[1].ToString(); tlVectorControl1.SVGDocument.RootElement.AppendChild(t1); } } tlVectorControl1.Refresh(); } break; case "m_inkbs": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[12]); WD = Convert.ToDecimal(r1[13]); //IntXY xy = mapview.getXY(JD, WD); PointF fnt = mapview.ParseToPoint(JD, WD); if (r1[7].ToString() == "运行") { ele = tlVectorControl1.CreateBySymbolID("kbs-111", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } else { ele = tlVectorControl1.CreateBySymbolID("kbs-112", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } ele = tlVectorControl1.AddShape(ele, Point.Empty); ele.SetAttribute("layer", tlVectorControl1.SVGDocument.CurrentLayer.ID); //points = points + (-xy.X / (decimal)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (decimal)tlVectorControl1.ScaleRatio) + ","; PSP_Gra_item item = new PSP_Gra_item(); item.UID = Guid.NewGuid().ToString(); item.EleKeyID = r1[1].ToString(); item.EleName = r1[2].ToString(); item.EleID = ele.ID; item.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; item.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; item.col1 = r1[7].ToString(); item.col2 = r1[3].ToString(); item.col3 = r1[4].ToString(); item.col4 = r1[5].ToString(); item.col5 = r1[6].ToString(); item.col6 = r1[8].ToString(); item.col7 = r1[9].ToString(); item.col8 = "kbs"; Services.BaseService.Create<PSP_Gra_item>(item); } } } break; case "m_infjx": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[9]); WD = Convert.ToDecimal(r1[10]); //IntXY xy = mapview.getXY(JD, WD); PointF fnt = mapview.ParseToPoint(JD, WD); if (r1[4].ToString() == "运行") { ele = tlVectorControl1.CreateBySymbolID("fjx-111", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } else { ele = tlVectorControl1.CreateBySymbolID("fjx-112", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } ele = tlVectorControl1.AddShape(ele, Point.Empty); ele.SetAttribute("layer", tlVectorControl1.SVGDocument.CurrentLayer.ID); //points = points + (-xy.X / (decimal)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (decimal)tlVectorControl1.ScaleRatio) + ","; PSP_Gra_item item = new PSP_Gra_item(); item.UID = Guid.NewGuid().ToString(); item.EleKeyID = r1[2].ToString(); item.EleName = r1[1].ToString(); item.EleID = ele.ID; item.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; item.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; item.col1 = r1[4].ToString(); item.col2 = r1[3].ToString(); item.col3 = r1[5].ToString(); item.col4 = r1[6].ToString(); //item.col5 = r1[6].ToString(); //item.col6 = r1[8].ToString(); //item.col7 = r1[9].ToString(); item.col8 = "fjx"; Services.BaseService.Create<PSP_Gra_item>(item); } } } break; case "m_inbyq": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[9]); WD = Convert.ToDecimal(r1[10]); //IntXY xy = mapview.getXY(JD, WD); PointF fnt = mapview.ParseToPoint(JD, WD); if (r1[4].ToString() == "运行") { ele = tlVectorControl1.CreateBySymbolID("byq-111", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } else { ele = tlVectorControl1.CreateBySymbolID("byq-112", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } ele = tlVectorControl1.AddShape(ele, Point.Empty); ele.SetAttribute("layer", tlVectorControl1.SVGDocument.CurrentLayer.ID); //points = points + (-xy.X / (decimal)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (decimal)tlVectorControl1.ScaleRatio) + ","; PSP_Gra_item item = new PSP_Gra_item(); item.UID = Guid.NewGuid().ToString(); item.EleKeyID = r1[2].ToString(); item.EleName = r1[1].ToString(); item.EleID = ele.ID; item.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; item.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; item.col1 = r1[4].ToString(); item.col2 = r1[3].ToString(); item.col3 = r1[5].ToString(); item.col4 = r1[6].ToString(); item.col8 = "byq"; Services.BaseService.Create<PSP_Gra_item>(item); } } } break; #endregion #region 未来联动 case "m_bxz": //tlVectorControl1.GoLocation(); Gh_BXZ(); break; case "m_jp": tlVectorControl1.ClipScreen(true); break; case "m_ld": if (SvgDocument.currentLayer == "") { MessageBox.Show("请选择图层", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBox.Show("确认要以当前选中年份为准调整以后年度的变电站及线路位置么?", "请确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Linkage(); } break; case "m_fz": if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择图元", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } CopyEle(); break; case "m_cx": xltProcessor.GoLocation(tlVectorControl1.SVGDocument.SvgdataUid, frmlar.getSelectedLayer()); //XmlNodeList n1111 = tlVectorControl1.SVGDocument.SelectNodes("svg/polygon [@IsArea='1']"); //string a = "1"; break; #endregion #region 线路优选 case "bt_edit": break; case "bt_start": if (linekey == "") { MessageBox.Show("请选择线路所属的方案。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } sel_sym = "bt_start"; tlVectorControl1.Operation = ToolOperation.Symbol; break; case "bt_end": if (sel_start_point == "") { MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } sel_sym = "bt_end"; tlVectorControl1.Operation = ToolOperation.Symbol; break; case "bt_must": if (sel_start_point == "") { MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } sel_sym = "bt_must"; tlVectorControl1.Operation = ToolOperation.Symbol; break; case "bt_point": if (sel_start_point == "") { MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } sel_sym = "bt_point"; tlVectorControl1.Operation = ToolOperation.Symbol; break; case "bt_make": if (sel_start_point == "") { MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } frmInputDialog frm_input = new frmInputDialog(); if (frm_input.ShowDialog() == DialogResult.OK) { SortedList orderlist = new SortedList(); XmlNodeList XLlist = tlVectorControl1.SVGDocument.SelectNodes("//*[@start_point=\"" + sel_start_point + "\"]"); try { for (int i = 0; i < XLlist.Count; i++) { XmlElement node = (XmlElement)XLlist[i]; orderlist.Add(Convert.ToInt32(node.GetAttribute("order")), node); } } catch (Exception ex1) { MessageBox.Show("存在相同的节点顺序号,请修改。\n\r" + ex1.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PointF[] _points = new PointF[XLlist.Count]; for (int i = 0; i < orderlist.Count; i++) { PointF[] f1 = new PointF[1] { new PointF(((Use)orderlist.GetByIndex(i)).X + 6, ((Use)orderlist.GetByIndex(i)).Y + 6) }; ((Use)orderlist.GetByIndex(i)).Transform.Matrix.TransformPoints(f1); _points[i] = f1[0]; } string str_points = ""; for (int i = 0; i < _points.Length; i++) { str_points = str_points + _points[i].X + " " + _points[i].Y + ","; } if (str_points.Length > 1) { str_points = str_points.Substring(0, str_points.Length - 1); } XmlElement _templine = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; _templine.SetAttribute("IsLead", "1"); _templine.SetAttribute("points", str_points); _templine.SetAttribute("layer", SvgDocument.currentLayer); Random dom = new Random(); int int_d = dom.Next(99999); string styleValue = "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(int_d)); _templine.SetAttribute("style", styleValue); XmlNode tt_node = tlVectorControl1.SVGDocument.RootElement.AppendChild(_templine); LineInfo gh_line = new LineInfo(); gh_line.UID = Guid.NewGuid().ToString(); gh_line.EleID = _templine.GetAttribute("id"); gh_line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<LineInfo>(gh_line); tlVectorControl1.Refresh(); if (MessageBox.Show("是否删除该线路的参考点?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { tlVectorControl1.SVGDocument.SelectCollection.Clear(); for (int i = 0; i < XLlist.Count; i++) { if (((SvgElement)XLlist[i]).GetAttribute("xlink:href").Contains("XL_GT_4") || ((SvgElement)XLlist[i]).GetAttribute("xlink:href").Contains("XL_GT_3")) { tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)XLlist[i]); } } tlVectorControl1.Delete(); } string str = ""; LineList1 line1 = new LineList1(); line1.UID = Guid.NewGuid().ToString(); //line1.LineEleID = tlVectorControl1.SVGDocument.CurrentElement.ID; line1.PointNum = ((Polyline)(tt_node)).Points.Length - 2; line1.Coefficient = (decimal)(1.02); line1.Length = TLMath.getPolylineLength(((Polyline)(tt_node)), Convert.ToDecimal(tlVectorControl1.ScaleRatio)); line1.Length2 = TLMath.getPolylineLength(((Polyline)(tt_node)), Convert.ToDecimal(tlVectorControl1.ScaleRatio)) * Convert.ToDecimal(1.02); PointF[] pnt = ((Polyline)(tt_node)).Points; if (pnt.Length < 3) return; for (int i = 0; i < pnt.Length; i++) { double ang = TLMath.getLineAngle(pnt[i], pnt[i + 1], pnt[i + 2]); if (ang * 57.3 > 60) { MessageBox.Show("线路转角不能大于60度。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.Delete(); return; } str = str + "第" + (i + 1) + "转角:" + Convert.ToDouble(ang * 57.3).ToString("##.##") + "度。\r\n"; if (i == pnt.Length - 3) { break; } } line1.TurnAngle = str; line1.col1 = linekey; line1.LineName = frm_input.InputStr; line1.LineEleID = ((SvgElement)tt_node).ID; Services.BaseService.Create<LineList1>(line1); sel_start_point = ""; tlVectorControl1.Operation = ToolOperation.Select; } break; case "Niula": OpenProject op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { ElectricLoadCal elc = new ElectricLoadCal(); elc.LFC(op.FileSUID, 1, 100); ShowResult(0, op.FileSUID,op.FileName); } } break; case "pq": op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { ElectricLoadCal elcPQ = new ElectricLoadCal(); elcPQ.LFC(op.FileSUID, 2, 100); ShowResult(1, op.FileSUID,op.FileName); } } break; case "GausSeidel": op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { ElectricLoadCal elcGS = new ElectricLoadCal(); elcGS.LFC(op.FileSUID, 3, 100); ShowResult(2, op.FileSUID,op.FileName); } } break; case "N_RZYz": op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { ElectricLoadCal elcN_RZYz = new ElectricLoadCal(); elcN_RZYz.LFC(op.FileSUID, 4, 100); ShowResult(3, op.FileSUID,op.FileName); } } break; #endregion } } }
private void dotNetBarManager1_ItemClick(object sender, EventArgs e) { DevComponents.DotNetBar.ButtonItem btItem = sender as DevComponents.DotNetBar.ButtonItem; //Layer layer1 = (Layer)LayerBox.ComboBoxEx.SelectedItem; if (btItem != null) { if (btItem.Name == "mRoam") { frmlar.Hide(); } else { frmlar.Show(); } switch (btItem.Name) { #region 文件操作 case "mNew": tlVectorControl1.NewFile(); break; case "mOpen": break; case "mImport": ExportImage(); //ImportDxf(); break; case "ImportDxf": ImportDxf(); break; case "btExSymbol": tlVectorControl1.ExportSymbol(); break; case "mSave": SaveButton(); break; case "mSaveSVG": tlVectorControl1.SaveAs(); break; case "mExit": this.Close(); //System.Data.OleDb.OleDbConnection c = new OleDbConnection("Provider=SQLOLEDB;Data source=192.168.0.30;initial catalog=tlpsp_tzkq;user id=sa;password=sa"); //OleDbCommand cmd = c.CreateCommand(); break; case "bt1": InitTK(); break; case "callCAD": try { //Autodesk.AutoCAD.Interop. if (MessageBox.Show("此操作需要花费较长时间,确认导出么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { CAD cad = new CAD(); cad.tlVectorControl1 = tlVectorControl1; cad.WriteDwg("ALL"); } } catch { MessageBox.Show("请安装AutoCAD2006或以上版本。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "callCADSub": try { //Autodesk.AutoCAD.Interop.AcadApplicationClass a = new Autodesk.AutoCAD.Interop.AcadApplicationClass(); if (MessageBox.Show("此操作需要花费较长时间,确认导出么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { CAD cad = new CAD(); cad.tlVectorControl1 = tlVectorControl1; string strlar = frmlar.getSelectedLayer(); cad.WriteDwg(strlar); } } catch { MessageBox.Show("请安装AutoCAD2006或以上版本。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "mPriSet": tlVectorControl1.PaperSetup(); break; case "mPrint": tlVectorControl1.Print(); break; case "mView": //frmSvgView fView = new frmSvgView(); //fView.Open(tlVectorControl1.SVGDocument.SvgdataUid); //fView.Show(); break; case "mViewScale": if (img != null) { frmtempViewScale fscale1 = new frmtempViewScale(); fscale1.ShowDialog(); } else { frmViewScale fScale = new frmViewScale(); string viewScale = tlVectorControl1.SVGDocument.getViewScale(); if (viewScale != "") { fScale.InitData(viewScale); } if (fScale.ShowDialog() == DialogResult.OK) { //viewScale = fScale.ViewScale; string _viewScale = fScale.ViewScale; tlVectorControl1.SVGDocument.setViewScale(_viewScale); if (viewScale == "") { viewScale = "1"; } Recalculate(Convert.ToDecimal(_viewScale) / Convert.ToDecimal(viewScale)); } } break; //case "mIncreaseView": // tlVectorControl1.Operation = ToolOperation.IncreaseView; // break; case "mRzb": frmRatio fRat = new frmRatio(); string viewRat = tlVectorControl1.SVGDocument.getRZBRatio(); if (viewRat != "") { fRat.InitData(viewRat); } if (fRat.ShowDialog() == DialogResult.OK) { viewRat = fRat.ViewScale; tlVectorControl1.SVGDocument.setRZBRatio(viewRat); } break; case "mEdit": if (MapType == "所内接线图") { Save(); dotNetBarManager1.Bars["mainmenu"].GetItem("ImportDxf").Visible = false; svg.SUID = ParentUID; IList svglist = Services.BaseService.GetList("SelectSVGFILEByKey", svg); svg = (SVGFILE)svglist[0]; sdoc = null; sdoc = new SvgDocument(); sdoc.LoadXml(svg.SVGDATA); tlVectorControl1.SVGDocument = sdoc; tlVectorControl1.SVGDocument.SvgdataUid = svg.SUID; MapType = "接线图"; CtrlSvgView.MapType = "接线图"; LoadShape("symbol_3.xml"); Init(progtype); //ButtonEnb(true); frmlar.SymbolDoc = tlVectorControl1.SVGDocument; frmlar.Progtype = progtype; frmlar.InitData(); dotNetBarManager1.Bars["mainmenu"].GetItem("ButtonItem2").Enabled = true; dotNetBarManager1.Bars["mainmenu"].GetItem("ButtonItem7").Enabled = true; bk1.Enabled = true; LoadImage = true; tlVectorControl1.Refresh(); } tlVectorControl1.ContextMenuStrip = contextMenuStrip1; MapType = "接线图"; break; case "mAbout": frmAbout frma = new frmAbout(); frma.ShowDialog(); break; //基础操作 case "mFreeTransform": tlVectorControl1.Operation = ToolOperation.FreeTransform; break; case "mRoam1": tlVectorControl1.Operation = ToolOperation.Roam; break; case "mShapeTransform1": tlVectorControl1.Operation = ToolOperation.Custom11; break; case "mShapeTransform2": tlVectorControl1.Operation = ToolOperation.Custom12; break; case "mShapeTransform3": tlVectorControl1.Operation = ToolOperation.Custom13; break; case "mShapeTransform4": tlVectorControl1.Operation = ToolOperation.Custom15; break; case "mShapeTransform5": tlVectorControl1.Operation = ToolOperation.Custom14; break; case "m_ljxl": ConnLine(); break; case "mAngleRectangle1": tlVectorControl1.Operation = ToolOperation.AngleRectangle; break; case "mSelect1": case "mSel1": //tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.FreeTransform; break; case "mLine1": tlVectorControl1.Operation = ToolOperation.Line; break; case "mPolyline1": tlVectorControl1.Operation = ToolOperation.PolyLine; break; case "mImage1": tlVectorControl1.Operation = ToolOperation.Image; break; case "mText1": tlVectorControl1.Operation = ToolOperation.Text; break; case "mEllipse1": tlVectorControl1.Operation = ToolOperation.Ellipse; break; case "mBezier1": tlVectorControl1.Operation = ToolOperation.Bezier; break; //图元操作 case "mCopy1": tlVectorControl1.Copy(); break; case "mCut1": tlVectorControl1.Cut(); break; case "mPaste1": PasteWithProperty(); break; case "mDelete1": if (tlVectorControl1.SVGDocument.CurrentElement != null && tlVectorControl1.SVGDocument.CurrentElement.ID != "svg") { frmMessageBox msg = new frmMessageBox(); if (msg.ShowDialog() == DialogResult.OK) { if (msg.ck) { // if(MessageBox.Show("确认删除么?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Information)==DialogResult.Yes){ for (int i = 0; i < tlVectorControl1.SVGDocument.SelectCollection.Count; i++) { if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polygon") { glebeProperty gle = new glebeProperty(); gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; gle.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; Services.BaseService.Update("DeleteglebePropertyByEleID", gle); } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line") { LineInfo _line = new LineInfo(); _line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _line.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; LineInfo temp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _line); if (temp != null) { Services.BaseService.Update("DeleteLinePropertyByEleID", _line); Services.BaseService.Update("DeleteLine_InfoByCode", temp.UID); } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use") { string str_name = ((XmlElement)(tlVectorControl1.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href"); if (str_name.Contains("Substation")) { substation _sub = new substation(); _sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _sub.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; substation temp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub); if (temp != null) { Services.BaseService.Update("DeletesubstationByEleID", _sub); Services.BaseService.Update("DeleteSubstation_InfoByCode", temp.UID); } } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") { ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.SelectCollection[i]; if (cline.StartGraph != null) { SvgElement ele = (SvgElement)cline.StartGraph; if (!ele.GetAttribute("xlink:href").Contains("Substation")) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.StartGraph); } } if (cline.EndGraph != null) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.EndGraph); } } } } else { for (int i = 0; i < tlVectorControl1.SVGDocument.SelectCollection.Count; i++) { if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line") { LineInfo _line = new LineInfo(); _line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _line.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; LineInfo linetemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _line); if (linetemp != null) { PowerProTypes temp = (PowerProTypes)Services.BaseService.GetObject("SelectPowerProTypesByCode", linetemp.UID); if (temp != null) { linetemp.EleID = ""; Services.BaseService.Update<LineInfo>(linetemp); } else { Services.BaseService.Update("DeleteLineInfo", linetemp); } } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use") { string str_name = ((XmlElement)(tlVectorControl1.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href"); if (str_name.Contains("Substation")) { substation _sub = new substation(); _sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _sub.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; substation subtemp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub); if (subtemp != null) { PowerProTypes temp = (PowerProTypes)Services.BaseService.GetObject("SelectPowerProTypesByCode", subtemp.UID); if (temp != null) { subtemp.EleID = ""; Services.BaseService.Update<substation>(subtemp); } else { Services.BaseService.Update("Deletesubstation", subtemp); } } } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") { ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.SelectCollection[i]; if (cline.StartGraph != null) { SvgElement ele = (SvgElement)cline.StartGraph; if (!ele.GetAttribute("xlink:href").Contains("Substation")) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.StartGraph); } } if (cline.EndGraph != null) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.EndGraph); } } } } tlVectorControl1.Delete(); } } //tlVectorControl1.Operation = ToolOperation.Select; break; case "mUodo1": tlVectorControl1.Undo(); break; case "mRedo1": tlVectorControl1.Redo(); break; case "mAlign1": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.Align(AlignType.Left); } else { tlVectorControl1.Align(AlignType.Left); } tlVectorControl1.Refresh(); break; case "mAlignLeft1": tlVectorControl1.Align(AlignType.Left); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignRight1": tlVectorControl1.Align(AlignType.Right); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignTop1": tlVectorControl1.Align(AlignType.Top); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignBottom1": tlVectorControl1.Align(AlignType.Bottom); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignHorizontalCenter1": tlVectorControl1.Align(AlignType.HorizontalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignVerticalCenter1": tlVectorControl1.Align(AlignType.VerticalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mOrder1": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.ChangeLevel(LevelType.Top); } else { tlVectorControl1.ChangeLevel(LevelType.Top); } break; case "mGoTop1": tlVectorControl1.ChangeLevel(LevelType.Top); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoUp1": tlVectorControl1.ChangeLevel(LevelType.Up); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoDown1": tlVectorControl1.ChangeLevel(LevelType.Down); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoBottom1": tlVectorControl1.ChangeLevel(LevelType.Bottom); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mRotate1": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.FlipX(); } else { tlVectorControl1.FlipX(); } break; case "mToH1": tlVectorControl1.FlipX(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToV1": tlVectorControl1.FlipY(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToLeft1": tlVectorControl1.RotateSelection(-90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToRight1": tlVectorControl1.RotateSelection(90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; //图形操作 case "mLeadLine1": if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("电网规划层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // sgt1.Visible = true; tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.LeadLine; break; case "mAreaPoly1": if (!getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("城市规划层")) { MessageBox.Show("请选择城市规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.AreaPolygon; break; case "mFzzj1": //放置注记 if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //LayerBox.ComboBoxEx.SelectedIndex = 2; tlVectorControl1.Operation = ToolOperation.Select; MapType = "规划统计"; break; case "mPriQu1": SubPrint = true; tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint; break; case "mReCompute1": if (MessageBox.Show("确认要重新计算全图的电量和负荷么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string scale = tlVectorControl1.SVGDocument.getViewScale(); if (scale != "") { Recalculate(Convert.ToDecimal(scale)); } else { Recalculate(1); } MessageBox.Show("重新计算完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "mFhbz1": if (MessageBox.Show("是否生成负荷标注?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Fhbz(); } break; case "mCJ": tlVectorControl1.Operation = ToolOperation.PolyLine; csOperation = CustomOperation.OP_MeasureDistance; break; #endregion #region 基础图元 case "mDecreaseView": tlVectorControl1.Operation = ToolOperation.DecreaseView; break; case "mIncreaseView": tlVectorControl1.Operation = ToolOperation.IncreaseView; break; case "mRoam": tlVectorControl1.Operation = ToolOperation.Roam; break; case "mSelect": case "mSel": //tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.FreeTransform; sel_sym = ""; sel_start_point = ""; break; //case "mFreeTransform": // tlVectorControl1.Operation = ToolOperation.FreeTransform; // break; case "mFreeLines"://锁套 tlVectorControl1.Operation = ToolOperation.FreeLines; break; case "mFreePath": tlVectorControl1.Operation = ToolOperation.FreePath; break; case "mShapeTransform": tlVectorControl1.Operation = ToolOperation.ShapeTransform; break; case "mAngleRectangle": tlVectorControl1.Operation = ToolOperation.AngleRectangle; break; case "mEllipse": tlVectorControl1.Operation = ToolOperation.Ellipse; break; case "mLine": tlVectorControl1.Operation = ToolOperation.Line; break; case "mPolyline": tlVectorControl1.Operation = ToolOperation.PolyLine; break; case "mPolygon": tlVectorControl1.Operation = ToolOperation.Polygon; break; case "mImage": tlVectorControl1.Operation = ToolOperation.Image; break; case "mText": tlVectorControl1.Operation = ToolOperation.Text; break; case "mBezier": tlVectorControl1.Operation = ToolOperation.Bezier; break; case "mEnclosure": tlVectorControl1.Operation = ToolOperation.Enclosure; break; case "mGroup": tlVectorControl1.Group(); break; case "mUnGroup": tlVectorControl1.UnGroup(); break; case "mlinelx": tlVectorControl1.Operation = ToolOperation.ConnectLine_Line; break; case "mzxlx": tlVectorControl1.Operation = ToolOperation.ConnectLine_Rightangle; break; case "mqxlx": tlVectorControl1.Operation = ToolOperation.ConnectLine_Spline; break; case "mqzlx": tlVectorControl1.Operation = ToolOperation.ConnectLine_Polyline; break; case "mCJ1": tlVectorControl1.Operation = ToolOperation.PolyLine; csOperation = CustomOperation.OP_MeasureDistance; break; #endregion #region 视图 case "mOption": tlVectorControl1.SetOption(); break; case "mLayer": LayerManagerShow(); //tlVectorControl1.LayerManager(); break; case "mAirscape": frmAirscape fAir = new frmAirscape(); fAir.InitData(tlVectorControl1); fAir.Owner = this; fAir.ShowInTaskbar = false; fAir.Top = Screen.PrimaryScreen.WorkingArea.Height - 250; fAir.Left = Screen.PrimaryScreen.WorkingArea.Width - 300; fAir.Show(); break; case "btTL": frmGlebeTypeList fgle = new frmGlebeTypeList(); fgle.Show(); break; case "mMapOpacity"://地图透明度 frmMapSetup dlg = new frmMapSetup(); dlg.MapOpacity = this.MapOpacity; if (dlg.ShowDialog() == DialogResult.OK) { this.MapOpacity = dlg.MapOpacity; } break; #endregion #region 查看 case "mDklb": //SaveAllLayer(); frmLayerList lay = new frmLayerList(); lay.InitData(tlVectorControl1.SVGDocument.getLayerList(), "1"); if (lay.ShowDialog() == DialogResult.OK) { frmglebePropertyList flist1 = new frmglebePropertyList(); flist1.InitDataSub(tlVectorControl1.SVGDocument.SvgdataUid, lay.str_sid); flist1.Show(); } break; case "m_dktj": frmLayerList layn = new frmLayerList(); layn.InitData(tlVectorControl1.SVGDocument.getLayerList(), "1"); if (layn.ShowDialog() == DialogResult.OK) { frmglebePropertyZHList flist1 = new frmglebePropertyZHList(); flist1.InitDataSub(tlVectorControl1.SVGDocument.SvgdataUid, layn.str_sid); flist1.Show(); } break; case "mGhlb": frmLayerList lay2 = new frmLayerList(); lay2.InitData(tlVectorControl1.SVGDocument.getLayerList(), "2"); if (lay2.ShowDialog() == DialogResult.OK) { frmglebePropertyList flist2 = new frmglebePropertyList(); flist2.InitData(tlVectorControl1.SVGDocument.SvgdataUid, lay2.str_sid); flist2.Show(); } break; case "mLineList": frmLayerList lay3 = new frmLayerList(); lay3.InitData(tlVectorControl1.SVGDocument.getLayerList(), "2"); if (lay3.ShowDialog() == DialogResult.OK) { frmLinePropertyList flist3 = new frmLinePropertyList(); flist3.InitData(tlVectorControl1.SVGDocument.SvgdataUid, lay3.str_sid); flist3.Show(); } break; case "mDlph": frmLayerList lay4 = new frmLayerList(); lay4.InitData(tlVectorControl1.SVGDocument.getLayerList(), "3"); if (lay4.ShowDialog() == DialogResult.OK) { frmSubstationPropertyList fSub = new frmSubstationPropertyList(); fSub.InitData(tlVectorControl1.SVGDocument.SvgdataUid, lay4.str_sid); fSub.Show(); } break; case "ButtonJXT": if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg" || (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString()) != "ItopVector.Core.Figure.Use") { MessageBox.Show("没有选择变电站!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ParentUID = tlVectorControl1.SVGDocument.SvgdataUid; Save(); ParentUID = tlVectorControl1.SVGDocument.SvgdataUid; SVGFILE svg_temp = new SVGFILE(); svg_temp.SUID = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("id"); svg_temp.FILENAME = getBdzName(svg_temp.SUID);// IList svglist1 = Services.BaseService.GetList("SelectSVGFILEByKey", svg_temp); OpenJXT(svglist1, svg_temp); break; #endregion #region 布局,对齐,顺序 case "mRotate": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.FlipX(); } else { tlVectorControl1.FlipX(); } break; case "mToH": tlVectorControl1.FlipX(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToV": tlVectorControl1.FlipY(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToLeft": tlVectorControl1.RotateSelection(-90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToRight": tlVectorControl1.RotateSelection(90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mAlign": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.Align(AlignType.Left); } else { tlVectorControl1.Align(AlignType.Left); } tlVectorControl1.Refresh(); break; case "mAlignLeft": tlVectorControl1.Align(AlignType.Left); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignRight": tlVectorControl1.Align(AlignType.Right); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignTop": tlVectorControl1.Align(AlignType.Top); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignBottom": tlVectorControl1.Align(AlignType.Bottom); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignHorizontalCenter": tlVectorControl1.Align(AlignType.HorizontalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignVerticalCenter": tlVectorControl1.Align(AlignType.VerticalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mOrder": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.ChangeLevel(LevelType.Top); } else { tlVectorControl1.ChangeLevel(LevelType.Top); } break; case "mGoTop": tlVectorControl1.ChangeLevel(LevelType.Top); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoUp": tlVectorControl1.ChangeLevel(LevelType.Up); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoDown": tlVectorControl1.ChangeLevel(LevelType.Down); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoBottom": tlVectorControl1.ChangeLevel(LevelType.Bottom); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; #endregion #region 图元操作 case "mCopy": tlVectorControl1.Copy(); break; case "mCut": tlVectorControl1.Cut(); break; case "mPaste": //tlVectorControl1.Paste(); PasteWithProperty(); break; case "mDelete": Delete(); //tlVectorControl1.Operation = ToolOperation.Select; break; case "mUodo": tlVectorControl1.Undo(); break; case "mRedo": tlVectorControl1.Redo(); break; #endregion #region 业务操作 case "m_line1": //线路走廊优化 Wjghboolflag = false; frmPlanList f = new frmPlanList(); if (f.ShowDialog() == DialogResult.Yes) { linekey = f.Key; tlVectorControl1.Operation = ToolOperation.Select; //tlVectorControl1.Operation = ToolOperation.LeadLine; } break; case "m_subxz": //变电站选址 Wjghboolflag = false; Services.BaseService.GetList<PSP_SubstationSelect>(); frmSubstationManager mng = new frmSubstationManager(); mng.OnOpen += new OnOpenSubhandler(mng_OnOpen); DialogResult dia = mng.ShowDialog(); if (dia == DialogResult.OK) { XZ_bdz = mng.code; MessageBox.Show("请选择变电站拖放置到希望的位置或者进行变电站自动选址。"); PSP_SubstationSelect sel = new PSP_SubstationSelect(); sel.col2 = XZ_bdz; IList<PSP_SubstationSelect> _plist = Services.BaseService.GetList<PSP_SubstationSelect>("SelectPSP_SubstationSelectList", sel); for (int n = 0; n < _plist.Count; n++) { XmlNodeList _nlist = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@id='" + _plist[n].EleID + "']"); if (_nlist.Count < 1) { Services.BaseService.Delete<PSP_SubstationSelect>(_plist[n]); } } } if (dia == DialogResult.Ignore) { string keyid = mng.KeyID; string suid = mng.SUID; PSP_SubstationUserNum n1 = new PSP_SubstationUserNum(); n1.col2 = keyid; IList<PSP_SubstationUserNum> list1 = Services.BaseService.GetList<PSP_SubstationUserNum>("SelectPSP_SubstationNum2", n1); for (int i = 0; i < list1.Count; i++) { if (suid == list1[i].SubStationID) { PSP_SubstationSelect s = new PSP_SubstationSelect(); s.UID = list1[i].SubStationID; s.EleID = list1[i].userID; XmlNodeList nnn1 = tlVectorControl1.SVGDocument.SelectNodes("//* [@id='" + s.EleID + "']"); foreach (XmlNode node1 in nnn1) { tlVectorControl1.SVGDocument.RootElement.RemoveChild(node1); } Services.BaseService.Update("DeletePSP_SubstationSelect", s); } } tlVectorControl1.Refresh(); } break; case "mSubPrint": Hashtable HashTable1 = new Hashtable(); HashTable1.Add("SUID", tlVectorControl1.SVGDocument.SvgdataUid); Services.BaseService.Update("UpdateGlebePropertyAll", HashTable1); break; case "mJQLeadLine": tlVectorControl1.Operation = ToolOperation.Select; frmAddLine aLine = new frmAddLine(); if (aLine.ShowDialog() == DialogResult.OK) { string points = ""; StringBuilder bpts = new StringBuilder(); ArrayList list = aLine.list; LineInfo line = aLine.line; string lineWidth = aLine.LineWidth; //ICollection Ilist = list.Values; //IEnumerator IEnum=Ilist.GetEnumerator(); for (int n = 0; n < list.Count; n++) { //while (IEnum.MoveNext()) //{ string[] str = ((string)list[n]).Split(','); //string[] str = ((string)IEnum.Current).Split(','); string[] JWD1 = str[0].Split(' '); double J1 = Convert.ToDouble(JWD1[0]); Double W1 = Convert.ToDouble(JWD1[1]); Double D1 = Convert.ToDouble(JWD1[2]); string[] JWD2 = str[1].Split(' '); Double J2 = Convert.ToDouble(JWD2[0]); Double W2 = Convert.ToDouble(JWD2[1]); Double D2 = Convert.ToDouble(JWD2[2]); Double JD = J1 + W1 / 60 + D1 / 3600; Double WD = J2 + W2 / 60 + D2 / 3600; IntXY xy = mapview.getXY(JD, WD); if (mapview is MapViewGoogle) bpts.Append(xy.X + " " + xy.Y + ","); else bpts.Append((-xy.X / (double)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (double)tlVectorControl1.ScaleRatio) + ","); //} } if (bpts.Length > 0) points = bpts.ToString(0, bpts.Length - 1); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; n1.SetAttribute("IsLead", "1"); n1.SetAttribute("points", points); n1.SetAttribute("layer", SvgDocument.currentLayer); // n1.SetAttribute("style", styleValue); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); line.UID = Guid.NewGuid().ToString(); line.EleID = n1.GetAttribute("id"); line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<LineInfo>(line); } break; case "mLeadLine": if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("电网规划层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // sgt1.Visible = true; tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.LeadLine; break; case "m_dhx": if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("电网规划层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // sgt1.Visible = true; str_dhx = "1"; tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.LeadLine; break; case "mAreaPoly": #if(!CITY) if (!getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("城市规划层")) { MessageBox.Show("请选择城市规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } #endif tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.AreaPolygon; break; case "sjsz": frmCS cs = new frmCS(); cs.ShowDialog(); break; case "shjg": GHWPG(); break; case "mFx": SubPrint = false; bool ck = false; ArrayList listlayers = frmlar.GetSelectLayers(); //CheckedListBox.CheckedItemCollection ckcol = frmlar.checkedListBox1.CheckedItems; for (int i = 0; i < listlayers.Count; i++) { Layer _lar = listlayers[i] as Layer; if (_lar.GetAttribute("layerType") == "城市规划层") { ck = true; } } if (!ck) { MessageBox.Show("请打开城市规划层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.InterEnclosure; MapType = "接线图"; break; case "mGhfx": if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl1.Operation = ToolOperation.Enclosure; // SvgDocument.currentLayer = getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID; MapType = "接线图"; //bar2.Visible = false; break; //case "mEdit": // //bar2.Visible = true; // SvgDocument.currentLayer = "layer97052"; // MapType = "接线图"; // break; case "mFzzj": //放置注记 if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //LayerBox.ComboBoxEx.SelectedIndex = 2; tlVectorControl1.Operation = ToolOperation.Select; MapType = "规划统计"; break; case "mDkwh": //地块维护 frmPropertyClass frmProp = new frmPropertyClass(); frmProp.ShowDialog(); break; case "mDkfl": //地块分类 if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } frmUsePropertySelect frmUseSel = new frmUsePropertySelect(); frmUseSel.InitData(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid); frmUseSel.ShowDialog(); break; case "mGldt": //关联地图 if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } frmFileSelect frmSel = new frmFileSelect(); frmSel.InitData(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid, true); frmSel.ShowDialog(); break; case "mPriQu": SubPrint = true; tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint; break; case "m_djcl": tlVectorControl1.Operation = ToolOperation.Select; str_djcl = "1"; MessageBox.Show("请选择线路进行档距测量。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; case "m_inxljwd": frmInJWD f_in = new frmInJWD(); if (f_in.ShowDialog() == DialogResult.OK) { InputFile(f_in.GetFileName(), f_in.GetCheck()); } break; case "m_inbdzjwd": frmInJWD f_in2 = new frmInJWD(); if (f_in2.ShowDialog() == DialogResult.OK) { InputBDZFile(f_in2.GetFileName(), f_in2.GetCheck()); } break; case "m_outsubjwd": if (MessageBox.Show("确定要导出当前图层所有变电站坐标吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { string str_dy = ""; XmlNodeList nn0 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + SvgDocument.currentLayer + "']"); string lab = tlVectorControl1.SVGDocument.CurrentLayer.Label; Excel.Application ex = new Excel.Application(); Excel.Workbook workBook = ex.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet); //workBook.Worksheets.Add(Type.Missing, workBook.ActiveSheet, 1, Type.Missing); Excel.Worksheet xSheet1 = (Excel.Worksheet)ex.Worksheets[1]; int c = xSheet1.Columns.Count; int r = xSheet1.Rows.Count; ((Excel.Range)xSheet1.Cells[1, 1]).Value2 = "序号"; ((Excel.Range)xSheet1.Cells[1, 2]).Value2 = "变电站名称"; ((Excel.Range)xSheet1.Cells[1, 3]).Value2 = "电压等级"; ((Excel.Range)xSheet1.Cells[1, 4]).Value2 = "经度"; ((Excel.Range)xSheet1.Cells[1, 5]).Value2 = "纬度"; for (int n = 0; n < nn0.Count; n++) { XmlElement _xele = (XmlElement)nn0[n]; string jwd_info = _xele.GetAttribute("jwd-info"); string infoname = _xele.GetAttribute("info-name"); string dyinfo = _xele.GetAttribute("xlink:href"); dyinfo = getDY(dyinfo); if (jwd_info != "") { string[] jwd = jwd_info.Split(",".ToCharArray()); ((Excel.Range)xSheet1.Cells[n + 2, 1]).Value2 = n + 1; ((Excel.Range)xSheet1.Cells[n + 2, 2]).Value2 = infoname; ((Excel.Range)xSheet1.Cells[n + 2, 3]).Value2 = dyinfo; ((Excel.Range)xSheet1.Cells[n + 2, 4]).Value2 = jwd[0].Trim(); ((Excel.Range)xSheet1.Cells[n + 2, 5]).Value2 = jwd[1].Trim(); } else { // LongLat lat = mapview.ParseToLongLat(((Use)_xele).CenterPoint.X, ((Use)_xele).CenterPoint.Y); LongLat lat = mapview.OffSetZero(-(int)(Convert.ToInt32(((Use)_xele).CenterPoint.X) * tlVectorControl1.ScaleRatio), -(int)(Convert.ToInt32(((Use)_xele).CenterPoint.Y) * tlVectorControl1.ScaleRatio)); ((Excel.Range)xSheet1.Cells[n + 2, 1]).Value2 = n + 1; ((Excel.Range)xSheet1.Cells[n + 2, 2]).Value2 = infoname; ((Excel.Range)xSheet1.Cells[n + 2, 3]).Value2 = dyinfo; ((Excel.Range)xSheet1.Cells[n + 2, 4]).Value2 = lat.Longitude; ((Excel.Range)xSheet1.Cells[n + 2, 5]).Value2 = lat.Latitude; } } ex.Visible = true; } break; case "m_outxljwd": tlVectorControl1.Operation = ToolOperation.Select; bool ckright = true; if (MessageBox.Show("确定要导出当前图层所有线路坐标吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { string str_dy = ""; XmlNodeList nn0 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@layer='" + SvgDocument.currentLayer + "']"); string lab = tlVectorControl1.SVGDocument.CurrentLayer.Label; for (int n = 0; n < nn0.Count; n++) { str_dy = ""; XmlElement x = nn0[n] as XmlElement; str_dy = x.GetAttribute("dy-info"); string devid = x.GetAttribute("Deviceid"); if (str_dy == "") { if (devid != "") { PSPDEV dev = Services.BaseService.GetOneByKey<PSPDEV>(devid); if (dev != null) { if (dev.RateVolt != 0) { str_dy = dev.RateVolt.ToString("###"); ckright = true; break; } } } } } if (str_dy == "") { if (MessageBox.Show("选择图层线路不包含电压等级信息,是否继续导出?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { ckright = true; } else { ckright = false; } } if (ckright) { Excel.Application ex = new Excel.Application(); Excel.Workbook workBook = ex.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet); for (int n = 0; n < nn0.Count; n++) { XmlElement _xele = (XmlElement)nn0[n]; workBook.Worksheets.Add(Type.Missing, workBook.ActiveSheet, 1, Type.Missing); Excel.Worksheet xSheet1 = (Excel.Worksheet)ex.Worksheets[n + 1]; int c = xSheet1.Columns.Count; int r = xSheet1.Rows.Count; ((Excel.Range)xSheet1.Cells[1, 1]).Value2 = "杆塔号"; ((Excel.Range)xSheet1.Cells[1, 2]).Value2 = "电压等级"; ((Excel.Range)xSheet1.Cells[1, 3]).Value2 = "经度"; ((Excel.Range)xSheet1.Cells[1, 4]).Value2 = "纬度"; string jwd_info = _xele.GetAttribute("jwd-info"); string gt_info = _xele.GetAttribute("gt-info"); if (jwd_info != "") { string[] gt = gt_info.Split(",".ToCharArray()); string[] jwd = jwd_info.Split(";".ToCharArray()); for (int m = 0; m < jwd.Length; m++) { string[] jw_str = jwd[m].Split(",".ToCharArray()); ((Excel.Range)xSheet1.Cells[m + 2, 1]).Value2 = gt[m]; ((Excel.Range)xSheet1.Cells[m + 2, 2]).Value2 = str_dy; ((Excel.Range)xSheet1.Cells[m + 2, 3]).Value2 = jw_str[0].Trim(); ((Excel.Range)xSheet1.Cells[m + 2, 4]).Value2 = jw_str[1].Trim(); } } else { PointF[] pt = TLMath.getPolygonPoints(_xele); for (int k = 0; k < pt.Length; k++) { LongLat lat = mapview.OffSetZero(-(int)(Convert.ToInt32(pt[k].X) * tlVectorControl1.ScaleRatio), -(int)(Convert.ToInt32(pt[k].Y) * tlVectorControl1.ScaleRatio)); //LongLat lat= mapview.ParseToLongLat(pt[k].X, pt[k].Y); ((Excel.Range)xSheet1.Cells[k + 2, 1]).Value2 = Convert.ToString(k + 1); ((Excel.Range)xSheet1.Cells[k + 2, 2]).Value2 = str_dy; ((Excel.Range)xSheet1.Cells[k + 2, 3]).Value2 = lat.Longitude; ((Excel.Range)xSheet1.Cells[k + 2, 4]).Value2 = lat.Latitude; } } string info_name = _xele.GetAttribute("info-name"); if (info_name != "") { for (int k = 1; k < workBook.Worksheets.Count; k++) { if (((Excel.Worksheet)workBook.Worksheets[k]).Name == info_name) { info_name = info_name + k.ToString(); break; } } xSheet1.Name = info_name; } } Excel.Worksheet xSheett = (Excel.Worksheet)ex.Worksheets[ex.Worksheets.Count]; xSheett.Activate(); xSheett.Delete(); ex.Visible = true; } } break; case "m_unsel": string bdzwhere = " UID not in ("; string xlwhere = " where SUID not in ("; PSPDEV obj = new PSPDEV(); DeviceHelper.pspflag = false; DeviceHelper.Wjghflag = false; string[] deviceType = new string[] { "05", "20" }; XmlNodeList lslist = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@Deviceid!='']"); XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@Deviceid!='']"); //XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use [contains(use,'Sub')]"); for (int x1 = 0; x1 < lslist.Count; x1++) { XmlElement _node = lslist[x1] as XmlElement; xlwhere = xlwhere + "'" + _node.GetAttribute("Deviceid") + "',"; } for (int x2 = 0; x2 < useList.Count; x2++) { XmlElement _node = useList[x2] as XmlElement; bdzwhere = bdzwhere + "'" + _node.GetAttribute("Deviceid") + "',"; } if (bdzwhere.Length > 15) { bdzwhere = bdzwhere.Substring(0, bdzwhere.Length - 1); } if (xlwhere.Length > 15) { xlwhere = xlwhere.Substring(0, xlwhere.Length - 1); } bdzwhere = bdzwhere + ") and "; xlwhere = xlwhere + ") and "; DeviceHelper.bdzwhere = bdzwhere; DeviceHelper.xlwhere = xlwhere; DeviceHelper.SelectDeviceDLG(Itop.Client.MIS.ProgUID, deviceType); DeviceHelper.bdzwhere = ""; DeviceHelper.xlwhere = ""; break; case "ORP": OpenProject orp = new OpenProject(); orp.ProjectID = Itop.Client.MIS.ProgUID; orp.Initdata(false); if (orp.ShowDialog() == DialogResult.OK) { if (orp.FileSUID != null) { ElectricLoadCal elcORP = new ElectricLoadCal(); elcORP.ORP(orp.FileSUID, 100); } } break; case "mReCompute": if (MessageBox.Show("确认要重新计算全图的电量和负荷么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string scale = tlVectorControl1.SVGDocument.getViewScale(); if (scale != "") { Recalculate(Convert.ToDecimal(scale)); } else { Recalculate(1); } MessageBox.Show("重新计算完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "mXLine": tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.XPolyLine; break; case "mYLine": tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.YPolyLine; break; case "mFhbz": //if (MessageBox.Show("是否生成负荷标注?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) //{ // Fhbz(); //} //FrmSet f_set = new FrmSet(); //if (f_set.ShowDialog()==DialogResult.OK) //{ if (XZ_bdz == "") { MessageBox.Show("请选择一个变电站选址方案。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.InterEnclosure; bdz_xz = "yes"; // str_dy = f_set.Str_dj; // str_num = f_set.Str_num; // str_jj = f_set.Str_jj; //} break; case "mSaveGroup": if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1) { string content = "<svg>"; SvgElementCollection col = tlVectorControl1.SVGDocument.SelectCollection; for (int i = 0; i < col.Count; i++) { SvgElement _e = (SvgElement)col[i]; if (_e.ID != "svg") { content = content + _e.OuterXml; } } RectangleF rect = tlVectorControl1.DrawArea.viewer.SelectedViewRectangle; content = content + "</svg>"; frmSaveGroup fm = new frmSaveGroup(); fm.rect = rect; fm.Content = content; fm.ShowDialog(); } else { MessageBox.Show("请至少选择2个图元。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } break; case "mInsert": frmUseGroup fg = new frmUseGroup(); if (fg.ShowDialog() == DialogResult.OK) { UseGroup u = fg.SelectedUseGroup; if (u != null) { frmXY xy = new frmXY(); if (xy.ShowDialog() == DialogResult.OK) { decimal x = xy.GetX(); decimal y = xy.GetY(); string content = u.Content; XmlDocument doc = new XmlDocument(); doc.LoadXml(u.Content); XmlNodeList list = doc.ChildNodes; XmlNode _node = list[0]; XmlNodeList sonlist = _node.ChildNodes; XmlElement ele = tlVectorControl1.SVGDocument.CreateElement("g"); ele.SetAttribute("layer", SvgDocument.currentLayer); for (int i = 0; i < sonlist.Count; i++) { XmlNode _sonnode = sonlist[i]; //string str = _sonnode.OuterXml; if (_sonnode.Name == "use") { string sid = ((XmlElement)_sonnode).GetAttribute("xlink:href"); XmlNode _snode = symbolSelector.SymbolDoc.SelectSingleNode("//*[@id='" + sid.Substring(1) + "']"); tlVectorControl1.SVGDocument.AddDefsElement((SvgElement)_snode); } ele.AppendChild(_sonnode); string ss = ele.OuterXml; } //RectangleF r=((Group)ele).GetBounds(); string tr = "matrix(1,0,0,1,"; tr = tr + Convert.ToString(x - Convert.ToDecimal(u.X)) + ","; tr = tr + Convert.ToString(y - Convert.ToDecimal(u.Y)) + ")"; ele.SetAttribute("transform", tr); // transform="matrix(1,0,0,1,2558.82,-352.94)" tlVectorControl1.SVGDocument.RootElement.AppendChild(ele); tlVectorControl1.SVGDocument.SelectCollection.Clear(); tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)ele); tlVectorControl1.UnGroup(); // tlVectorControl1.Refresh(); } } } break; case "m_tp": frmImgManager frm = new frmImgManager(); frm.StrName = ""; frm.StrRemark = ""; frm.ShowDialog(); break; case "m_reDraw": string svguid = tlVectorControl1.SVGDocument.SvgdataUid; XmlNodeList nn1 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1']"); LineType lt = new LineType(); IList tpList = Services.BaseService.GetList("SelectLineTypeList", lt); Hashtable dkHs = new Hashtable(); for (int i = 0; i < tpList.Count; i++) { LineType _gle = (LineType)tpList[i]; dkHs.Add(_gle.TypeName, _gle.Color); } bool bo = tlVectorControl1.SVGDocument.Update; tlVectorControl1.SVGDocument.Update = false; for (int j = 0; j < nn1.Count; j++) { XmlElement _node1 = (XmlElement)nn1.Item(j); LineInfo line = new LineInfo(); line.SvgUID = svguid; line.EleID = _node1.GetAttribute("id"); line = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", line); if (line != null) { string t = (string)dkHs[line.Voltage + "kV"]; string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(t))); ItopVector.Core.Func.AttributeFunc.SetAttributeValue(_node1, "stroke", color1); } } tlVectorControl1.SVGDocument.Update = bo; break; case "m_subColor": string svguid1 = tlVectorControl1.SVGDocument.SvgdataUid; XmlNodeList nn2 = tlVectorControl1.SVGDocument.SelectNodes("svg/defs/symbol"); LineType lt1 = new LineType(); IList tpList1 = Services.BaseService.GetList("SelectLineTypeList", lt1); Hashtable dkHs1 = new Hashtable(); for (int i = 0; i < tpList1.Count; i++) { LineType _gle = (LineType)tpList1[i]; dkHs1.Add(_gle.TypeName.ToLower(), _gle.Color); } bool bo1 = tlVectorControl1.SVGDocument.Update; tlVectorControl1.SVGDocument.Update = false; Regex regex = new Regex(@"\d{2,3}(?=kv)"); foreach (Symbol _node1 in nn2) { string subName = _node1.GetAttribute("label").ToLower(); Match match1 = regex.Match(subName); if (match1.Success) { try { string t = (string)dkHs1[match1.Value + "kv"]; //if (match1.Value == "220") //{ // t = t; //} string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(t))); foreach (SvgElement element in _node1.GraphList) { if (element.SvgAttributes.ContainsKey("stroke") && element.SvgAttributes["stroke"].ToString() != "#FFFFFF") { ItopVector.Core.Func.AttributeFunc.SetAttributeValue(element, "stroke", color1); } if (element.SvgAttributes.ContainsKey("fill") && element.SvgAttributes["fill"].ToString() != "#FFFFFF") { ItopVector.Core.Func.AttributeFunc.SetAttributeValue(element, "fill", color1); } if (element.SvgAttributes.ContainsKey("hatch-color") && element.SvgAttributes["hatch-color"].ToString() != "#FFFFFF") { ItopVector.Core.Func.AttributeFunc.SetAttributeValue(element, "hatch-color", color1); } } } catch { } } } tlVectorControl1.SVGDocument.Update = bo1; break; #endregion #region 图层操作 case "layerImport": tlVectorControl1.Operation = ToolOperation.FreePath; layerImport(); break; case "layerExport": layerExport(); break; case "m_kbsText": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[12]); WD = Convert.ToDecimal(r1[13]); PointF fnt = mapview.ParseToPoint(JD, WD); XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t1.SetAttribute("x", Convert.ToString(fnt.X / (float)tlVectorControl1.ScaleRatio + 8)); t1.SetAttribute("y", Convert.ToString(fnt.Y / (float)tlVectorControl1.ScaleRatio)); t1.SetAttribute("layer", SvgDocument.currentLayer); t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t1.SetAttribute("font-famliy", "宋体"); t1.SetAttribute("font-size", "6"); t1.InnerText = r1[2].ToString(); tlVectorControl1.SVGDocument.RootElement.AppendChild(t1); } } tlVectorControl1.Refresh(); } break; case "m_fText": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[9]); WD = Convert.ToDecimal(r1[10]); PointF fnt = mapview.ParseToPoint(JD, WD); XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t1.SetAttribute("x", Convert.ToString(fnt.X / (float)tlVectorControl1.ScaleRatio + 8)); t1.SetAttribute("y", Convert.ToString(fnt.Y / (float)tlVectorControl1.ScaleRatio)); t1.SetAttribute("layer", SvgDocument.currentLayer); t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t1.SetAttribute("font-famliy", "宋体"); t1.SetAttribute("font-size", "6"); t1.InnerText = r1[1].ToString(); tlVectorControl1.SVGDocument.RootElement.AppendChild(t1); } } tlVectorControl1.Refresh(); } break; case "m_inkbs": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[12]); WD = Convert.ToDecimal(r1[13]); //IntXY xy = mapview.getXY(JD, WD); PointF fnt = mapview.ParseToPoint(JD, WD); if (r1[7].ToString() == "运行") { ele = tlVectorControl1.CreateBySymbolID("kbs-111", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } else { ele = tlVectorControl1.CreateBySymbolID("kbs-112", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } ele = tlVectorControl1.AddShape(ele, Point.Empty); ele.SetAttribute("layer", tlVectorControl1.SVGDocument.CurrentLayer.ID); //points = points + (-xy.X / (decimal)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (decimal)tlVectorControl1.ScaleRatio) + ","; PSP_Gra_item item = new PSP_Gra_item(); item.UID = Guid.NewGuid().ToString(); item.EleKeyID = r1[1].ToString(); item.EleName = r1[2].ToString(); item.EleID = ele.ID; item.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; item.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; item.col1 = r1[7].ToString(); item.col2 = r1[3].ToString(); item.col3 = r1[4].ToString(); item.col4 = r1[5].ToString(); item.col5 = r1[6].ToString(); item.col6 = r1[8].ToString(); item.col7 = r1[9].ToString(); item.col8 = "kbs"; Services.BaseService.Create<PSP_Gra_item>(item); } } } break; case "m_infjx": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[9]); WD = Convert.ToDecimal(r1[10]); //IntXY xy = mapview.getXY(JD, WD); PointF fnt = mapview.ParseToPoint(JD, WD); if (r1[4].ToString() == "运行") { ele = tlVectorControl1.CreateBySymbolID("fjx-111", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } else { ele = tlVectorControl1.CreateBySymbolID("fjx-112", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } ele = tlVectorControl1.AddShape(ele, Point.Empty); ele.SetAttribute("layer", tlVectorControl1.SVGDocument.CurrentLayer.ID); //points = points + (-xy.X / (decimal)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (decimal)tlVectorControl1.ScaleRatio) + ","; PSP_Gra_item item = new PSP_Gra_item(); item.UID = Guid.NewGuid().ToString(); item.EleKeyID = r1[2].ToString(); item.EleName = r1[1].ToString(); item.EleID = ele.ID; item.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; item.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; item.col1 = r1[4].ToString(); item.col2 = r1[3].ToString(); item.col3 = r1[5].ToString(); item.col4 = r1[6].ToString(); //item.col5 = r1[6].ToString(); //item.col6 = r1[8].ToString(); //item.col7 = r1[9].ToString(); item.col8 = "fjx"; Services.BaseService.Create<PSP_Gra_item>(item); } } } break; case "m_inbyq": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[9]); WD = Convert.ToDecimal(r1[10]); //IntXY xy = mapview.getXY(JD, WD); PointF fnt = mapview.ParseToPoint(JD, WD); if (r1[4].ToString() == "运行") { ele = tlVectorControl1.CreateBySymbolID("byq-111", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } else { ele = tlVectorControl1.CreateBySymbolID("byq-112", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } ele = tlVectorControl1.AddShape(ele, Point.Empty); ele.SetAttribute("layer", tlVectorControl1.SVGDocument.CurrentLayer.ID); //points = points + (-xy.X / (decimal)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (decimal)tlVectorControl1.ScaleRatio) + ","; PSP_Gra_item item = new PSP_Gra_item(); item.UID = Guid.NewGuid().ToString(); item.EleKeyID = r1[2].ToString(); item.EleName = r1[1].ToString(); item.EleID = ele.ID; item.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; item.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; item.col1 = r1[4].ToString(); item.col2 = r1[3].ToString(); item.col3 = r1[5].ToString(); item.col4 = r1[6].ToString(); item.col8 = "byq"; Services.BaseService.Create<PSP_Gra_item>(item); } } } break; #endregion #region 未来联动 case "m_bxz": //tlVectorControl1.GoLocation(); Gh_BXZ(); break; case "m_jp": tlVectorControl1.ClipScreen(true); break; case "m_ld": if (SvgDocument.currentLayer == "") { MessageBox.Show("请选择图层", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBox.Show("确认要以当前选中年份为准调整以后年度的变电站及线路位置么?", "请确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Linkage(); } break; case "m_fz": if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择图元", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } CopyEle(); break; case "m_cx": xltProcessor.GoLocation(tlVectorControl1.SVGDocument.SvgdataUid, frmlar.getSelectedLayer()); //XmlNodeList n1111 = tlVectorControl1.SVGDocument.SelectNodes("svg/polygon [@IsArea='1']"); //string a = "1"; break; #endregion #region 网架优化 case "OpenWJ": ff = new frmGProg(); if (ff.ShowDialog() == DialogResult.OK) { Wjghboolflag = true; checkwjghelement(); dotNetBarManager1.Bars["mainmenu"].GetItem("YHoperator").Enabled = true; dotNetBarManager1.Bars["mainmenu"].GetItem("YHresult").Enabled = true; dotNetBarManager1.Bars["mainmenu"].GetItem("ZTBut").Enabled = true; dotNetBarManager1.Bars["mainmenu"].GetItem("JQBut").Enabled = false; dotNetBarManager1.Bars["mainmenu"].GetItem("ZQBut").Enabled = false; dotNetBarManager1.Bars["mainmenu"].GetItem("YQBut").Enabled = false; } else { Wjghboolflag = false; } break; case "YHoperator": break; case "ghwj": GHWPG(); break; case "ZTBut": dotNetBarManager1.Bars["mainmenu"].GetItem("ZTBut").Enabled = false; dotNetBarManager1.Bars["mainmenu"].GetItem("JQBut").Enabled = true; ElectricWjgh wjgh = new ElectricWjgh(); wjgh.initdat(ff.Key); //恢复数据的原来面貌 WaitDialogForm wait = null; try { wait = new WaitDialogForm("", "正在处理数据, 请稍候..."); wjgh.jianxiancheck(ff.Key, 1, 100); wait.Close(); MessageBox.Show("整体数据优化成功。"); string con = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + ff.Key + "'and type='线路')"; IList list1 = Services.BaseService.GetList("SelectPSPDEVByCondition", con); foreach (PSPDEV dev in list1) { PSP_GprogElevice pg = new PSP_GprogElevice(); pg.GprogUID = ff.Key; pg.DeviceSUID = dev.SUID; //先找到再修改 pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg); if (pg != null) { if (dev.LineStatus == "运行") { pg.ZTstatus = "运行"; pg.JQstatus = "运行"; pg.ZQstatus = "运行"; pg.YQstatus = "运行"; Services.BaseService.Update<PSP_GprogElevice>(pg); } else if (dev.LineStatus == "等待") { pg.ZTstatus = "等待"; pg.JQstatus = "等待"; pg.ZQstatus = "等待"; pg.YQstatus = "等待"; Services.BaseService.Update<PSP_GprogElevice>(pg); } else if (dev.LineStatus == "待选") { pg.ZTstatus = "待选"; Services.BaseService.Update<PSP_GprogElevice>(pg); } } } wjghmapview(1); } catch (Exception exc) { MessageBox.Show("数据存在问题,请检查后再继续!"); wait.Close(); return; } break; case "JQBut": dotNetBarManager1.Bars["mainmenu"].GetItem("JQBut").Enabled = false; dotNetBarManager1.Bars["mainmenu"].GetItem("ZQBut").Enabled = true; wjgh = new ElectricWjgh(); wjgh.JDlinecheck(ff.Key, 2); JorJform selectmethod = new JorJform(); selectmethod.Text = "近期网架优化方法"; if (selectmethod.ShowDialog() == DialogResult.OK) { wait = new WaitDialogForm("", "正在处理数据, 请稍候..."); if (selectmethod.Mathindex == 0) { wjgh.jianxiancheck(ff.Key, 2, 100); MessageBox.Show("近期数据减线优化成功。"); } else if (selectmethod.Mathindex == 1) { wjgh.addlinecheck(ff.Key, 2, 100); wjgh.addrightcheck(ff.Key, 2, 100); for (int i = 0; i < wjgh.ercilinedengdai.Count; i++) { wjgh.ercilinedengdai[i].LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(wjgh.ercilinedengdai[i]); } for (int i = 0; i < wjgh.lineyiyou.Count; i++) { wjgh.lineyiyou[i].LineStatus = "待选"; Services.BaseService.Update<PSPDEV>(wjgh.lineyiyou[i]); } MessageBox.Show("近期数据加线成功。"); } wait.Close(); //此处写项目jq变化状况 string conjq = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + ff.Key + "'and type='线路'and ZTstatus in('待选'))"; IList list1jq = Services.BaseService.GetList("SelectPSPDEVByCondition", conjq); foreach (PSPDEV dev in list1jq) { PSP_GprogElevice pg = new PSP_GprogElevice(); pg.GprogUID = ff.Key; pg.DeviceSUID = dev.SUID; //先找到再修改 pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg); if (pg != null) { if (dev.LineStatus == "等待") { pg.JQstatus = "待选"; Services.BaseService.Update<PSP_GprogElevice>(pg); //dev.LineStatus = "待选"; //Services.BaseService.Update<PSPDEV>(dev); } else if (dev.LineStatus == "待选") { bool flag = false; foreach (eleclass el in wjgh.JDlinecol) { if (dev.SUID == el.suid) { flag = true; dev.LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(dev); } } if (flag) { pg.JQstatus = "投放"; pg.ZQstatus = "运行"; pg.YQstatus = "运行"; } else { pg.JQstatus = "待选"; } Services.BaseService.Update<PSP_GprogElevice>(pg); } } } wjghmapview(2); } break; case "ZQBut": dotNetBarManager1.Bars["mainmenu"].GetItem("ZQBut").Enabled = false; dotNetBarManager1.Bars["mainmenu"].GetItem("YQBut").Enabled = true; wjgh = new ElectricWjgh(); wjgh.JDlinecheck(ff.Key, 3); selectmethod = new JorJform(); selectmethod.Text = "中期网架优化方法"; if (selectmethod.ShowDialog() == DialogResult.OK) { wjghmapview(5); wait = new WaitDialogForm("", "正在处理数据, 请稍候..."); if (selectmethod.Mathindex == 0) { wjgh.jianxiancheck(ff.Key, 3, 100); MessageBox.Show("中期数据减线优化成功。"); } else if (selectmethod.Mathindex == 1) { wjgh.addlinecheck(ff.Key, 3, 100); wjgh.addrightcheck(ff.Key, 3, 100); for (int i = 0; i < wjgh.ercilinedengdai.Count; i++) { wjgh.ercilinedengdai[i].LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(wjgh.ercilinedengdai[i]); } for (int i = 0; i < wjgh.lineyiyou.Count; i++) { wjgh.lineyiyou[i].LineStatus = "待选"; Services.BaseService.Update<PSPDEV>(wjgh.lineyiyou[i]); } MessageBox.Show("中期数据加线成功。"); } wait.Close(); //此处写项目jq变化状况 string conzq = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + ff.Key + "'and type='线路'and JQstatus in('待选'))"; IList list1zq = Services.BaseService.GetList("SelectPSPDEVByCondition", conzq); foreach (PSPDEV dev in list1zq) { PSP_GprogElevice pg = new PSP_GprogElevice(); pg.GprogUID = ff.Key; pg.DeviceSUID = dev.SUID; //先找到再修改 pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg); if (pg != null) { if (dev.LineStatus == "等待") { pg.ZQstatus = "待选"; Services.BaseService.Update<PSP_GprogElevice>(pg); //dev.LineStatus = "待选"; //Services.BaseService.Update<PSPDEV>(dev); } else if (dev.LineStatus == "待选") { bool flag = false; foreach (eleclass el in wjgh.JDlinecol) { if (el.suid == dev.SUID) { flag = true; dev.LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(dev); } } if (flag) { pg.ZQstatus = "投放"; pg.YQstatus = "运行"; } else pg.ZQstatus = "待选"; Services.BaseService.Update<PSP_GprogElevice>(pg); } } } wjghmapview(3); } break; case "YQBut": dotNetBarManager1.Bars["mainmenu"].GetItem("YQBut").Enabled = false; dotNetBarManager1.Bars["mainmenu"].GetItem("ZTBut").Enabled = true; wjgh = new ElectricWjgh(); wjgh.JDlinecheck(ff.Key, 4); wjghmapview(6); selectmethod = new JorJform(); selectmethod.Text = "远期网架优化方法"; if (selectmethod.ShowDialog() == DialogResult.OK) { wait = new WaitDialogForm("", "正在处理数据, 请稍候..."); if (selectmethod.Mathindex == 0) { wjgh.jianxiancheck(ff.Key, 4, 100); MessageBox.Show("远期数据减线优化成功。"); } else if (selectmethod.Mathindex == 1) { wjgh.addlinecheck(ff.Key, 4, 100); wjgh.addrightcheck(ff.Key, 4, 100); for (int i = 0; i < wjgh.ercilinedengdai.Count; i++) { wjgh.ercilinedengdai[i].LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(wjgh.ercilinedengdai[i]); } for (int i = 0; i < wjgh.lineyiyou.Count; i++) { wjgh.lineyiyou[i].LineStatus = "待选"; Services.BaseService.Update<PSPDEV>(wjgh.lineyiyou[i]); } MessageBox.Show("远期数据加线成功。"); } wait.Close(); //此处写项目jq变化状况 string conyq = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + ff.Key + "'and type='线路'and ZQstatus in('待选'))"; IList list1yq = Services.BaseService.GetList("SelectPSPDEVByCondition", conyq); // wjgh = new ElectricWjgh(); foreach (PSPDEV dev in list1yq) { PSP_GprogElevice pg = new PSP_GprogElevice(); pg.GprogUID = ff.Key; pg.DeviceSUID = dev.SUID; //先找到再修改 pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg); if (pg != null) { if (dev.LineStatus == "等待") { bool flag = false; foreach (eleclass el in wjgh.JDlinecol) { if (el.suid == dev.SUID) { flag = true; dev.LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(dev); } } if (flag) pg.YQstatus = "投放"; else pg.YQstatus = "待选"; Services.BaseService.Update<PSP_GprogElevice>(pg); //pg.YQstatus = "待选"; //Services.BaseService.Update<PSP_GprogElevice>(pg); } else if (dev.LineStatus == "待选") { bool flag = false; foreach (eleclass el in wjgh.JDlinecol) { if (el.suid == dev.SUID) { flag = true; dev.LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(dev); } } if (flag) pg.YQstatus = "投放"; else pg.YQstatus = "待选"; Services.BaseService.Update<PSP_GprogElevice>(pg); } } } wjghmapview(4); } break; case "YHresult": wjgh = new ElectricWjgh(); frmGProList p1 = new frmGProList(); p1.Show(); p1.LoadData(wjgh.LoadData(ff.Key)); break; #endregion #region 线路优选 case "bt_edit": break; case "bt_start": if (linekey == "") { MessageBox.Show("请选择线路所属的方案。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } sel_sym = "bt_start"; tlVectorControl1.Operation = ToolOperation.Symbol; break; case "bt_end": if (sel_start_point == "") { MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } sel_sym = "bt_end"; tlVectorControl1.Operation = ToolOperation.Symbol; break; case "bt_must": if (sel_start_point == "") { MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } sel_sym = "bt_must"; tlVectorControl1.Operation = ToolOperation.Symbol; break; case "bt_point": if (sel_start_point == "") { MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } sel_sym = "bt_point"; tlVectorControl1.Operation = ToolOperation.Symbol; break; case "bt_make": if (sel_start_point == "") { MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } frmInputDialog frm_input = new frmInputDialog(); if (frm_input.ShowDialog() == DialogResult.OK) { SortedList orderlist = new SortedList(); XmlNodeList XLlist = tlVectorControl1.SVGDocument.SelectNodes("//*[@start_point=\"" + sel_start_point + "\"]"); try { for (int i = 0; i < XLlist.Count; i++) { XmlElement node = (XmlElement)XLlist[i]; orderlist.Add(Convert.ToInt32(node.GetAttribute("order")), node); } } catch (Exception ex1) { MessageBox.Show("存在相同的节点顺序号,请修改。\n\r" + ex1.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PointF[] _points = new PointF[XLlist.Count]; for (int i = 0; i < orderlist.Count; i++) { PointF[] f1 = new PointF[1] { new PointF(((Use)orderlist.GetByIndex(i)).X + 6, ((Use)orderlist.GetByIndex(i)).Y + 6) }; ((Use)orderlist.GetByIndex(i)).Transform.Matrix.TransformPoints(f1); _points[i] = f1[0]; } string str_points = ""; for (int i = 0; i < _points.Length; i++) { str_points = str_points + _points[i].X + " " + _points[i].Y + ","; } if (str_points.Length > 1) { str_points = str_points.Substring(0, str_points.Length - 1); } XmlElement _templine = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; _templine.SetAttribute("IsLead", "1"); _templine.SetAttribute("points", str_points); _templine.SetAttribute("layer", SvgDocument.currentLayer); Random dom = new Random(); int int_d = dom.Next(99999); string styleValue = "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(int_d)); _templine.SetAttribute("style", styleValue); XmlNode tt_node = tlVectorControl1.SVGDocument.RootElement.AppendChild(_templine); LineInfo gh_line = new LineInfo(); gh_line.UID = Guid.NewGuid().ToString(); gh_line.EleID = _templine.GetAttribute("id"); gh_line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<LineInfo>(gh_line); tlVectorControl1.Refresh(); if (MessageBox.Show("是否删除该线路的参考点?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { tlVectorControl1.SVGDocument.SelectCollection.Clear(); for (int i = 0; i < XLlist.Count; i++) { if (((SvgElement)XLlist[i]).GetAttribute("xlink:href").Contains("XL_GT_4") || ((SvgElement)XLlist[i]).GetAttribute("xlink:href").Contains("XL_GT_3")) { tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)XLlist[i]); } } tlVectorControl1.Delete(); } string str = ""; LineList1 line1 = new LineList1(); line1.UID = Guid.NewGuid().ToString(); //line1.LineEleID = tlVectorControl1.SVGDocument.CurrentElement.ID; line1.PointNum = ((Polyline)(tt_node)).Points.Length - 2; line1.Coefficient = (decimal)(1.02); line1.Length = TLMath.getPolylineLength(((Polyline)(tt_node)), Convert.ToDecimal(tlVectorControl1.ScaleRatio)); line1.Length2 = TLMath.getPolylineLength(((Polyline)(tt_node)), Convert.ToDecimal(tlVectorControl1.ScaleRatio)) * Convert.ToDecimal(1.02); PointF[] pnt = ((Polyline)(tt_node)).Points; if (pnt.Length < 3) return; for (int i = 0; i < pnt.Length; i++) { double ang = TLMath.getLineAngle(pnt[i], pnt[i + 1], pnt[i + 2]); if (ang * 57.3 > 60) { MessageBox.Show("线路转角不能大于60度。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.Delete(); return; } str = str + "第" + (i + 1) + "转角:" + Convert.ToDouble(ang * 57.3).ToString("##.##") + "度。\r\n"; if (i == pnt.Length - 3) { break; } } line1.TurnAngle = str; line1.col1 = linekey; line1.LineName = frm_input.InputStr; line1.LineEleID = ((SvgElement)tt_node).ID; Services.BaseService.Create<LineList1>(line1); sel_start_point = ""; tlVectorControl1.Operation = ToolOperation.Select; } break; case "Niula": Wjghboolflag = false; OpenProject op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { Psptypeform pt = new Psptypeform(); if (pt.ShowDialog() == DialogResult.OK) { frnReport wFrom = new frnReport(); wFrom.Owner = this; wFrom.Show(); wFrom.Text = this.Text + "—牛拉法潮流计算"; wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString(); ElectricLoadCal elc = new ElectricLoadCal(); elc.LFC(op.FileSUID, 1, 100, wFrom); ShowResult(0, op.FileSUID, op.FileName, pt.PspOuttype, wFrom); } } } break; case "pq": Wjghboolflag = false; op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { Psptypeform pt = new Psptypeform(); if (pt.ShowDialog() == DialogResult.OK) { frnReport wFrom = new frnReport(); wFrom.Owner = this; wFrom.Show(); wFrom.Text = this.Text + "—PQ法潮流计算"; wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString(); ElectricLoadCal elc = new ElectricLoadCal(); ElectricLoadCal elcPQ = new ElectricLoadCal(); elcPQ.LFC(op.FileSUID, 2, 100, wFrom); // elcPQ.LFCER(op.FileSUID, 2, 100); ShowResult(1, op.FileSUID, op.FileName, pt.PspOuttype, wFrom); } } } break; case "GausSeidel": Wjghboolflag = false; op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { Psptypeform pt = new Psptypeform(); if (pt.ShowDialog() == DialogResult.OK) { frnReport wFrom = new frnReport(); wFrom.Owner = this; wFrom.Show(); wFrom.Text = this.Text + "—高斯赛德尔迭代法潮流计算"; wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString(); ElectricLoadCal elc = new ElectricLoadCal(); ElectricLoadCal elcGS = new ElectricLoadCal(); elcGS.LFC(op.FileSUID, 3, 100, wFrom); ShowResult(2, op.FileSUID, op.FileName, pt.PspOuttype, wFrom); } } } break; case "N_RZYz": Wjghboolflag = false; op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { Psptypeform pt = new Psptypeform(); if (pt.ShowDialog() == DialogResult.OK) { frnReport wFromZYZ = new frnReport(); wFromZYZ.Owner = this; wFromZYZ.Show(); wFromZYZ.Text = this.Text + "—最有乘子法潮流计算"; wFromZYZ.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString(); ElectricLoadCal elcN_RZYz = new ElectricLoadCal(); elcN_RZYz.LFC(op.FileSUID, 4, 100, wFromZYZ); ShowResult(3, op.FileSUID, op.FileName, pt.PspOuttype, wFromZYZ); } } } break; case "NLnFH": Wjghboolflag = false; op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { Psptypeform pt = new Psptypeform(); if (pt.ShowDialog() == DialogResult.OK) { frnReport wFromZYZ = new frnReport(); wFromZYZ.Owner = this; wFromZYZ.Show(); wFromZYZ.Text = this.Text + "—最有乘子法潮流计算"; wFromZYZ.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString(); ElectricLoadCal elcN_RZYz = new ElectricLoadCal(); elcN_RZYz.LFCS(op.FileSUID, 4, 100); ShowResult(3, op.FileSUID, op.FileName, pt.PspOuttype, wFromZYZ); } } } break; #endregion } } }
public void InitData(glebeProperty gp,string _sub220,string _sub110,string _sub66) { try { str220 = _sub220; str110 = _sub110; str66 = _sub66; gPro.EleID = gp.EleID; gPro.SvgUID = gp.SvgUID; layerID = gp.LayerID; IList svglist = Services.BaseService.GetList("SelectglebePropertyByEleID", gPro); if (svglist.Count > 0) { gPro = (glebeProperty)svglist[0]; IsCreate = false; if (gPro.SonUid=="") { gPro.SonUid = "2"; } } else { IsCreate = true; gPro.LayerID = layerID; } glebeType g = new glebeType(); g.UID = "6ab9af7b-3d97-4e6c-8ed7-87b76950b90b"; g = (glebeType)Services.BaseService.GetObject("SelectglebeTypeByKey", g); if (gPro.ObligateField10 == "") { gPro.ObligateField10 = "0"; } gPro.ObligateField10 = gPro.ObligateField10.Replace("-",""); if (gPro.ObligateField10 != "0") { nullvalue = Convert.ToDecimal(gPro.ObligateField10) * Convert.ToDecimal(g.TypeStyle); } bh.DataBindings.Add("Text", gPro, "UseID"); lx.DataBindings.Add("EditValue", gPro, "TypeUID"); mj.DataBindings.Add("Text", gPro, "Area"); fh.DataBindings.Add("Text", gPro, "Burthen"); dl.DataBindings.Add("Text", gPro, "Number"); rzb.DataBindings.Add("Text", gPro, "SonUid"); remark.DataBindings.Add("Text", gPro, "Remark"); yk1.DataBindings.Add("Text", gPro, "ObligateField2"); jc1.DataBindings.Add("Text", gPro, "ObligateField3"); nl1.DataBindings.Add("Text", gPro, "ObligateField4"); yk2.DataBindings.Add("Text", gPro, "ObligateField5"); jc2.DataBindings.Add("Text", gPro, "ObligateField6"); nl2.DataBindings.Add("Text", gPro, "ObligateField7"); ph1.DataBindings.Add("Text", gPro, "ObligateField8"); ph2.DataBindings.Add("Text", gPro, "ObligateField9"); yk3.DataBindings.Add("Text", gPro, "ObligateField12"); jc3.DataBindings.Add("Text", gPro, "ObligateField13"); nl3.DataBindings.Add("Text", gPro, "ObligateField14"); ph3.DataBindings.Add("Text", gPro, "ObligateField15"); comboBoxEdit1.DataBindings.Add("Text", gPro, "ObligateField16"); Hashtable hs = new Hashtable(); hs.Add("ParentEleID", gPro.EleID); hs.Add("SvgUID", gPro.SvgUID); sondt = Itop.Common.DataConverter.ToDataTable(Services.BaseService.GetList("SelectglebePropertParentID", hs), typeof(glebeProperty)); gridControl.DataSource = sondt; //添加负荷预测数据 ctrlglebeYearValue1.ParentObj = gPro; string temp = ""; foreach (DataRow row in sondt.Rows) { if (temp!=row["TypeUID"].ToString()){ temp=row["TypeUID"].ToString(); if (!typelist.Contains(row["TypeUID"])) { typelist.Add(row["TypeUID"]); } } } //if (gPro.Number==0 || gPro.Burthen==0) //{ Hashtable hs1 = new Hashtable(); if(gPro.SelSonArea!=""){ string[] selArea = gPro.SelSonArea.Split(";".ToCharArray()); for (int i = 0; i < selArea.Length;i++ ) { if(selArea[i]!=""){ string[] _SonArea = selArea[i].Split(",".ToCharArray()); hs1.Add(_SonArea[0], _SonArea[1]); } } } IEnumerator Ilist= sondt.Rows.GetEnumerator(); while(Ilist.MoveNext()){ DataRow row= (DataRow)Ilist.Current; string eleid = (string)hs1[row["EleID"]]; if (eleid!="") { dou_fh = dou_fh + (Convert.ToDouble(hs1[row["EleID"]]) / Convert.ToDouble(row["Area"])) * Convert.ToDouble(row["Burthen"]); } } gPro.Burthen = Convert.ToDecimal(dou_fh)+nullvalue; fh.Text = gPro.Burthen.ToString("#####.####"); //gPro.Number = Convert.ToDecimal( dou_dl.ToString("#####.##")); //} if (fh.Text == "") { fh.Text = "0"; } if (dl.Text == "") { dl.Text = "0"; } gPro.Burthen = Convert.ToDecimal(fh.Text); if (gPro.Area == 0) { return; } pjfh.Text = Convert.ToDecimal(Convert.ToDecimal(fh.Text) / (Convert.ToDecimal(gPro.Area)+Convert.ToDecimal(gPro.ObligateField10))).ToString("#####.####"); //辅助决策 if ((gPro.ObligateField2 == "" || gPro.ObligateField2 == null) && (gPro.ObligateField5 == "" || gPro.ObligateField5==null)) { Reload(); } if(strID==""){ return; } string sql = " where SUID in ( " +strID+ ")"; IList<PSPDEV> l22= Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", sql); gridControl1.DataSource = l22; } catch(Exception e1) { MessageBox.Show(e1.Message); } }
/*public void ResetPoly() { SvgElementCollection col= tlVectorControl1.SVGDocument.SelectCollection; if(col.Count<1){ return; } SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator(); foreach(SvgElement ele in col){ if (ele.GetType().ToString() == "ItopVector.Core.Figure.Polygon") { glebeProperty p=new glebeProperty(); p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; p.EleID = ((IGraph)ele).ID; p = Services.BaseService.GetObject("SelectglebePropertyByEleID", p); if(p!=null){ PointF[] tfArray1 = TLMath.getPolygonPoints(ele); GraphicsPath selectAreaPath = new GraphicsPath(); selectAreaPath.AddLines(tfArray1); selectAreaPath.CloseFigure(); Region region1 = new Region(selectAreaPath); while (enumerator1.MoveNext()) { IGraph graph1 = (IGraph)enumerator1.Current; GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone(); path1.Transform(graph1.GraphTransform.Matrix); Region region2 = new Region(path1); region2.Intersect(region1); if (!region2.GetBounds(Graphics.FromHwnd(IntPtr.Zero)).IsEmpty) { glebeProperty p1 = new glebeProperty(); p1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; p1.EleID = graph1.ID; p1 = Services.BaseService.GetObject("SelectglebePropertyByEleID", p1); if(p1!=null){ p1.ParentEleID = p.UID; Services.BaseService.Update("UpdateglebePropertyAreaAll", p1); } } } } } } MessageBox.Show("更新完成。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information); }*/ private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { try { if (e.ClickedItem.Text == "可靠性分析") { XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement; if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") { string deviceid = xml1.GetAttribute("Deviceid"); if (!string.IsNullOrEmpty(deviceid)) { DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid; DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID; DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID; PSPDEV obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid); if (obj != null && obj.Type == "73") { //更换为元件可靠性 Itop.TLPSP.DEVICE.FrmpdrelProject xf = new Itop.TLPSP.DEVICE.FrmpdrelProject(); xf.init(obj); xf.ShowDialog(); } } } } if (e.ClickedItem.Text == "属性") { XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement; //PointF[] pf = TLMath.getPolygonPoints(xml1); DeviceHelper.xml1 = xml1; //((Polygon)xml1).Transform.Matrix.TransformPoints(pf); // 规划 if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) { if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请先选择规划区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") { //frmImgManager frm = new frmImgManager(); //frm.Show(); } if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") { XmlNodeList n1 = tlVectorControl1.SVGDocument.GetElementsByTagName("use"); PointF[] tfArray1 = TLMath.getPolygonPoints(xml1); string str220 = ""; string str110 = ""; string str66 = ""; string str_id = ""; GraphicsPath selectAreaPath = new GraphicsPath(); selectAreaPath.AddLines(tfArray1); selectAreaPath.CloseFigure(); //Matrix x=new Matrix( //Region region1 = new Region(selectAreaPath); for (int i = 0; i < n1.Count; i++) { float OffX = 0f; float OffY = 0f; bool ck = false; Use use = (Use)n1[i]; if (use.GetAttribute("xlink:href").Contains("byq") || use.GetAttribute("xlink:href").Contains("pds")) { if (selectAreaPath.IsVisible(use.CenterPoint)) { if (use.GetAttribute("Deviceid") != "") { str_id = str_id + "'" + use.GetAttribute("Deviceid") + "',"; } } } if (use.GetAttribute("xlink:href").Contains("Substation")) { //string strMatrix = use.GetAttribute("transform"); //if (strMatrix != "") //{ // strMatrix = strMatrix.Replace("matrix(", ""); // strMatrix = strMatrix.Replace(")", ""); // string[] mat = strMatrix.Split(','); // if (mat.Length > 5) // { // OffX = Convert.ToSingle(mat[4]); // OffY = Convert.ToSingle(mat[5]); // } //} //if (frmlar.getSelectedLayer().Contains(use.GetAttribute("layer"))) { // ck = true; //} for (int j= 0; j< frmlar.GetSelectLayers().Count;j++ ) { if ((frmlar.GetSelectLayers()[j] as Layer).ID==use.GetAttribute("layer")) { ck = true; } } PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href")); //if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY) && ck) if (selectAreaPath.IsVisible(use.CenterPoint) && ck) { if (use.GetAttribute("xlink:href").Contains("220")) { str220 = str220 + "'" + use.GetAttribute("Deviceid") + "',"; } if (use.GetAttribute("xlink:href").Contains("110")) { str110 = str110 + "'" + use.GetAttribute("Deviceid") + "',"; } if (use.GetAttribute("xlink:href").Contains("66")) { str66 = str66 + "'" + use.GetAttribute("Deviceid") + "',"; } } } } if (str220.Length > 1) { str220 = str220.Substring(0, str220.Length - 1); } if (str110.Length > 1) { str110 = str110.Substring(0, str110.Length - 1); } if (str66.Length > 1) { str66 = str66.Substring(0, str66.Length - 1); } if (str_id.Length > 1) { str_id = str_id.Substring(0, str_id.Length - 1); } glebeProperty _gle = new glebeProperty(); _gle.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID; _gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle); if (UseProList.Count > 0) { _gle = UseProList[0]; _gle.LayerID = SvgDocument.currentLayer; frmMainProperty f = new frmMainProperty(); f.strID = str_id; f.InitData(_gle, str220, str110, str66); PointF[] pn = (PointF[])((Polygon)xml1).Points.Clone(); ((Polygon)xml1).Transform.Matrix.TransformPoints(pn); string s1 = ""; for (int p = 0; p < pn.Length; p++) { s1 = s1 + pn[p].X.ToString() + " " + pn[p].Y.ToString() + ","; } f.Str = s1; f.ShowDialog(); if (f.checkBox1.Checked == false) { tlVectorControl1.SVGDocument.RootElement.RemoveChild(tlVectorControl1.SVGDocument.CurrentElement); } //tlVectorControl1.Refresh(); } else { _gle = new glebeProperty(); _gle.LayerID = SvgDocument.currentLayer; frmMainProperty f = new frmMainProperty(); f.strID = str_id; f.InitData(_gle, str220, str110, str66); PointF[] pn = (PointF[])((Polygon)xml1).Points.Clone(); ((Polygon)xml1).Transform.Matrix.TransformPoints(pn); string s1 = ""; for (int p = 0; p < pn.Length; p++) { s1 = s1 + pn[p].X.ToString() + " " + pn[p].Y.ToString() + ","; } f.Str = s1; f.ShowDialog(); } //} } } if (getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())) { if (tlVectorControl1.SVGDocument.getRZBRatio() != "") { rzb = tlVectorControl1.SVGDocument.getRZBRatio(); } if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请先选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") { string IsArea = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsArea"); if (IsArea != "") { frmProperty f = new frmProperty();//地块属性 if (SelUseArea == "") { SelUseArea = "0"; } f.XZ_bdz = XZ_bdz; f.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer); //f.ShowDialog(); #if(!CITY) //将其中心点保存在XML中 PointF p = TLMath.polyCentriod((XmlElement)tlVectorControl1.SVGDocument.CurrentElement); string title = p.X.ToString() + "," + p.Y.ToString(); ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("centrpoint", title); if (progtype != "城市规划层") { f.IsReadonly = true; } #endif if (f.ShowDialog() == DialogResult.OK) { SVG_ENTITY ent = new SVG_ENTITY(); if (f.IsCreate) { ent.SUID = Guid.NewGuid().ToString(); ent.EleID = f.gPro.EleID; ent.layerID = f.gPro.LayerID; ent.MDATE = System.DateTime.Now; ent.NAME = f.gPro.UseID; ent.svgID = f.gPro.SvgUID; ent.TYPE = "polygon-dk"; //ent.voltage = f.gPro.Voltage; Services.BaseService.Create<SVG_ENTITY>(ent); } else { ent.NAME = f.gPro.UseID; ent.layerID = f.gPro.LayerID; ent.MDATE = System.DateTime.Now; //ent.voltage = fl.Line.Voltage; Services.BaseService.Update<SVG_ENTITY>(ent); } if (f.gPro.ObligateField1 != "") { string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(f.gPro.ObligateField1))); color1 = "fill:" + color1 + ";"; ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", color1); tlVectorControl1.UpdateProperty(); } if (xzwcflag == "1" && f.bdzflag) { if (extsublist.Count > 0 && subandfhlist.Count > 0) { bool sfsflag=false; for(int m=0;m<polylist.Count;m++) { if((polylist[m] as XmlElement).GetAttribute("id")==f.gPro.EleID) { sfsflag=true; break; } } if (!sfsflag) { MessageBox.Show("地块非选址的地块中 请重新选址!"); return; } try { List<Layer> layercol= getxzxllayers(tlVectorControl1.SVGDocument.getLayerList()); if (layercol.Count>0) { FrmSelxzlayer frm=new FrmSelxzlayer(); frm.Layercol=layercol; if (frm.ShowDialog()==DialogResult.OK) { string layerid=frm.sellayerid; RebdzxzResult1(subandfhlist, extsublist, f.gPro, f.bdzzqname,layerid); } else RebdzxzResult(subandfhlist, extsublist, f.gPro, f.bdzzqname); } // RebdzxzResult(subandfhlist, extsublist, f.gPro, f.bdzzqname); } catch (System.Exception ex) { MessageBox.Show("请计算有问题 请重新计算!"); return; } } else { MessageBox.Show("选址变电站没有数据 请重新选址!"); return; } } else { MessageBox.Show("请重新选址!"); return; } } } } } if (!Wjghboolflag) { if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") { string lineWidth = "2"; string IsLead = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsLead"); //if (IsLead != "") //原先导线的属性添加情况 if (IsLead != "") //修改后的导线的属性添加情况 { XmlNodeList n11 = tlVectorControl1.SVGDocument.SelectNodes("svg/polygon [@IsArea='1']"); using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) { List<glebeProperty> glist = new List<glebeProperty>(); for (int i = 0; i < n11.Count; i++) { IGraph graph1 = (IGraph)n11[i]; GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone(); //path1.Transform(graph1.GraphTransform.Matrix); Region ef1 = new Region(path1); Polyline line = tlVectorControl1.SVGDocument.CurrentElement as Polyline; GraphicsPath gr2 = new GraphicsPath(); //gr2.AddLines(pfs); gr2.AddPath(line.GPath, true); gr2.CloseFigure(); Region region = new Region(gr2); ef1.Intersect(region); if (!ef1.GetBounds(g).IsEmpty) { glebeProperty gy = new glebeProperty(); gy.EleID = graph1.ID; gy.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; gy = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", gy); if (gy != null) { glebeType gt = new glebeType(); gt.UID = gy.TypeUID; gt = (glebeType)Services.BaseService.GetObject("SelectglebeTypeByKey", gt); gy.TypeUID = gt.TypeName; glist.Add(gy); } } } DeviceHelper.glist = glist; } string dhx = xml1.GetAttribute("dhx_key"); if (dhx == "1" && checkEdit2.Checked == false) { frmDHXdlg d = new frmDHXdlg(); d.uid = xml1.GetAttribute("id"); d.Show(); return; } PSPDEV obj = new PSPDEV(); string deviceid = xml1.GetAttribute("Deviceid"); DeviceHelper.pspflag = false; DeviceHelper.Wjghflag = false; if (string.IsNullOrEmpty(deviceid)) { string[] deviceType = new string[] { "05", "73", "75" }; string xlwhere = " where SUID not in ("; XmlNodeList lslist = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@Deviceid!=''] [@layer='" + SvgDocument.currentLayer + "']"); for (int x1 = 0; x1 < lslist.Count; x1++) { XmlElement _node = lslist[x1] as XmlElement; xlwhere = xlwhere + "'" + _node.GetAttribute("Deviceid") + "',"; } if (xlwhere.Length > 20) { xlwhere = xlwhere.Substring(0, xlwhere.Length - 1); xlwhere = xlwhere + ") and "; } else { xlwhere = ""; } DeviceHelper.xlwhere = xlwhere; obj = (PSPDEV)DeviceHelper.SelectDevice(Itop.Client.MIS.ProgUID, deviceType); DeviceHelper.xlwhere = ""; if (obj is PSPDEV) { deviceid = ((PSPDEV)obj).SUID; xml1.SetAttribute("Deviceid", deviceid); obj.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; obj.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; obj.EleID = ((SvgElement)xml1).ID; Services.BaseService.Update<PSPDEV>(obj); //将其设备加入到计算方案中 //获得方案名称 PSP_ELCPROJECT pd = new PSP_ELCPROJECT(); pd.ID = frmlar.FAID; pd = Services.BaseService.GetOneByKey<PSP_ELCPROJECT>(pd); if (pd != null) { bool operflag = false, dataflag = false; if (!string.IsNullOrEmpty(((PSPDEV)obj).OperationYear) && ((PSPDEV)obj).OperationYear.Length == 4 && pd.BelongYear.Length == 4) { if (Convert.ToInt32(((PSPDEV)obj).OperationYear) < Convert.ToInt32(pd.BelongYear)) { operflag = true; } } if (!string.IsNullOrEmpty(((PSPDEV)obj).Date2) && ((PSPDEV)obj).Date2.Length == 4 && pd.BelongYear.Length == 4) { if (Convert.ToInt32(((PSPDEV)obj).Date2) > Convert.ToInt32(pd.BelongYear)) { dataflag = true; } } if (operflag && dataflag) { PSP_ElcDevice elcDevice = new PSP_ElcDevice(); elcDevice.DeviceSUID = deviceid; elcDevice.ProjectSUID = frmlar.FAID; elcDevice = UCDeviceBase.DataService.GetOneByKey<PSP_ElcDevice>(elcDevice); if (elcDevice == null) { elcDevice = new PSP_ElcDevice(); elcDevice.DeviceSUID = deviceid; elcDevice.ProjectSUID = frmlar.FAID; UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice); } } } } } if (!string.IsNullOrEmpty(deviceid)) { DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid; DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID; DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID; obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid); if (obj != null)//------------wwwMX { xml1.SetAttribute("info-name", ((PSPDEV)obj).Name); if (obj.Type == "05") { DeviceHelper.ShowDeviceDlg(DeviceType.XL, deviceid, false); } if (obj.Type == "01") { DeviceHelper.ShowDeviceDlg(DeviceType.MX, deviceid, false); } if (obj.Type == "73") { DeviceHelper.ShowDeviceDlg(DeviceType.PDXL, deviceid, false); } if (obj.Type == "75") { DeviceHelper.ShowDeviceDlg(DeviceType.LUX, deviceid, false); } } //***** ********添加FistNode和LastNode XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use"); foreach (XmlNode element in useList) { if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid"))) { string con = "WHERE SvgUID='" + (element as XmlElement).GetAttribute("Deviceid") + "'AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='01'"; IList pspMX = Services.BaseService.GetList("SelectPSPDEVByCondition", con); if (pspMX != null) { foreach (PSPDEV pspmx in pspMX) { if (obj.IName == pspmx.Name) { (xml1 as XmlElement).SetAttribute("FirstNode", (element as XmlElement).GetAttribute("id")); } else if (obj.JName == pspmx.Name) { (xml1 as XmlElement).SetAttribute("LastNode", (element as XmlElement).GetAttribute("id")); } } } } } } //** } } if (xml1.GetAttribute("xlink:href").Contains("Substation") || xml1.GetAttribute("xlink:href").Contains("Power")) {//变电站属性 string lab = xml1.GetAttribute("xlink:href"); float x = 0f; float y = 0f; //判断电压等级 int dyinfo = Convert.ToInt32(getDY(lab)); x = ((Use)xml1).X; y = ((Use)xml1).Y; PointF p1 = new PointF(x, y); PointF[] pnt = new PointF[1]; pnt[0] = p1; Use temp = xml1.Clone() as Use; temp.Transform.Matrix.TransformPoints(pnt); LongLat templat = mapview.OffSetZero(-(int)(pnt[0].X * tlVectorControl1.ScaleRatio), -(int)(pnt[0].Y * tlVectorControl1.ScaleRatio)); string[] jd = templat.Longitude.ToString("####.####").Split('.'); int d1 = Convert.ToInt32(jd[0]); string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.'); int f1 = Convert.ToInt32(df1[0]); decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60; string[] wd = templat.Latitude.ToString("####.####").Split('.'); int d2 = Convert.ToInt32(wd[0]); string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.'); int f2 = Convert.ToInt32(df2[0]); decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60; string strjwd = "经纬度: " + d1.ToString() + "°" + f1.ToString() + "′" + m1.ToString("##.#") + "″," + d2.ToString() + "°" + f2.ToString() + "′" + m2.ToString("##.#") + "″"; object obj = null; string deviceid = xml1.GetAttribute("Deviceid"); DeviceHelper.pspflag = false; DeviceHelper.Wjghflag = false; if (dyinfo >= 66) { DeviceHelper.subflag = false; } else DeviceHelper.subflag = true; Lab1://变电站、电源属性 if (string.IsNullOrEmpty(deviceid)) { //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (xml1.GetAttribute("xlink:href").Contains("Power")) { obj = DeviceHelper.SelectDevice(DeviceType.DY, Itop.Client.MIS.ProgUID); //if (obj == null) //{ // tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement; // tlVectorControl1.Delete(); //} if (obj is PSP_PowerSubstation_Info) { deviceid = ((PSP_PowerSubstation_Info)obj).UID; ((PSP_PowerSubstation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; //((PSP_PowerSubstation_Info)obj). = tlVectorControl1.SVGDocument.CurrentLayer.ID; Services.BaseService.Update<PSP_PowerSubstation_Info>(((PSP_PowerSubstation_Info)obj)); xml1.SetAttribute("Deviceid", deviceid); xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title); //获得方案名称 PSP_ELCPROJECT pd = new PSP_ELCPROJECT(); pd.ID = frmlar.FAID; pd = Services.BaseService.GetOneByKey<PSP_ELCPROJECT>(pd); if (pd != null) { string where = "where projectid='" + Itop.Client.MIS.ProgUID + "'and SvgUID='" + ((PSP_PowerSubstation_Info)obj).UID + "'"; IList<PSPDEV> list = Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", where); //根据年份进行筛选 if (!string.IsNullOrEmpty(pd.BelongYear)) //根据参与计算设备属于那一年先进行一次筛选 { for (int i = 0; i < list.Count; i++) { if (!string.IsNullOrEmpty((list[i] as PSPDEV).OperationYear) && (list[i] as PSPDEV).OperationYear.Length == 4 && pd.BelongYear.Length == 4) { if (Convert.ToInt32((list[i] as PSPDEV).OperationYear) > Convert.ToInt32(pd.BelongYear)) { list.RemoveAt(i); i--; continue; } } if (!string.IsNullOrEmpty((list[i] as PSPDEV).Date2) && (list[i] as PSPDEV).Date2.Length == 4 && pd.BelongYear.Length == 4) { if (Convert.ToInt32((list[i] as PSPDEV).Date2) < Convert.ToInt32(pd.BelongYear)) { list.RemoveAt(i); i--; continue; } } } } foreach (PSPDEV pv in list) { //将其设备加入到计算方案中 PSP_ElcDevice elcDevice = new PSP_ElcDevice(); elcDevice.DeviceSUID = pv.SUID; elcDevice.ProjectSUID = frmlar.FAID; elcDevice = UCDeviceBase.DataService.GetOneByKey<PSP_ElcDevice>(elcDevice); if (elcDevice == null) { elcDevice = new PSP_ElcDevice(); elcDevice.DeviceSUID = pv.SUID; elcDevice.ProjectSUID = frmlar.FAID; UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice); } } } } substation sb = new substation(); sb.UID = ((PSP_PowerSubstation_Info)obj).UID; sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb); if (sb != null) { sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; sb.EleID = xml1.GetAttribute("id"); if (((PSP_PowerSubstation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Update<substation>(sb); } else { sb = new substation(); sb.UID = ((PSP_PowerSubstation_Info)obj).UID; sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.EleID = xml1.GetAttribute("id"); sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; if (((PSP_PowerSubstation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Create<substation>(sb); } } else { DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid; DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID; DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID; //wwww string bdzwhere = " UID not in ("; XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@Deviceid!=''] [@layer='" + SvgDocument.currentLayer + "']"); for (int x2 = 0; x2 < useList.Count; x2++) { XmlElement _node = useList[x2] as XmlElement; bdzwhere = bdzwhere + "'" + _node.GetAttribute("Deviceid") + "',"; } if (bdzwhere.Length > 13) { bdzwhere = bdzwhere.Substring(0, bdzwhere.Length - 1); bdzwhere = bdzwhere + ") and "; } else { bdzwhere = ""; } DeviceHelper.bdzwhere = bdzwhere; obj = DeviceHelper.SelectDevice(DeviceType.BDZ, Itop.Client.MIS.ProgUID); DeviceHelper.bdzwhere = ""; //if (obj == null) //{ // tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement; // tlVectorControl1.Delete(); //} if (obj is PSP_Substation_Info) { deviceid = ((PSP_Substation_Info)obj).UID; ((PSP_Substation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; ((PSP_Substation_Info)obj).EleID = tlVectorControl1.SVGDocument.CurrentElement.ID; ((PSP_Substation_Info)obj).AreaID = Itop.Client.MIS.ProgUID; Services.BaseService.Update<PSP_Substation_Info>(((PSP_Substation_Info)obj)); xml1.SetAttribute("Deviceid", deviceid); xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title); //获得方案名称 PSP_ELCPROJECT pd = new PSP_ELCPROJECT(); pd.ID = frmlar.FAID; pd = Services.BaseService.GetOneByKey<PSP_ELCPROJECT>(pd); if (pd != null) { string where = "where projectid='" + Itop.Client.MIS.ProgUID + "'and SvgUID='" + ((PSP_Substation_Info)obj).UID + "'"; IList<PSPDEV> list = Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", where); //根据年份进行筛选 if (!string.IsNullOrEmpty(pd.BelongYear)) //根据参与计算设备属于那一年先进行一次筛选 { for (int i = 0; i < list.Count; i++) { if (!string.IsNullOrEmpty((list[i] as PSPDEV).OperationYear) && (list[i] as PSPDEV).OperationYear.Length == 4 && pd.BelongYear.Length == 4) { if (Convert.ToInt32((list[i] as PSPDEV).OperationYear) > Convert.ToInt32(pd.BelongYear)) { list.RemoveAt(i); i--; continue; } } if (!string.IsNullOrEmpty((list[i] as PSPDEV).Date2) && (list[i] as PSPDEV).Date2.Length == 4 && pd.BelongYear.Length == 4) { if (Convert.ToInt32((list[i] as PSPDEV).Date2) < Convert.ToInt32(pd.BelongYear)) { list.RemoveAt(i); i--; continue; } } } } foreach (PSPDEV pv in list) { //将其设备加入到计算方案中 PSP_ElcDevice elcDevice = new PSP_ElcDevice(); elcDevice.DeviceSUID = pv.SUID; elcDevice.ProjectSUID = frmlar.FAID; elcDevice = UCDeviceBase.DataService.GetOneByKey<PSP_ElcDevice>(elcDevice); if (elcDevice == null) { elcDevice = new PSP_ElcDevice(); elcDevice.DeviceSUID = pv.SUID; elcDevice.ProjectSUID = frmlar.FAID; UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice); } } } //return; //根据变站创建线路 createLine(xml1, deviceid); } /* substation sb = new substation(); sb.UID = ((PSP_Substation_Info)obj).UID; sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb); if (sb != null) { sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; sb.EleID = xml1.GetAttribute("id"); if (((PSP_Substation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_Substation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Update<substation>(sb); } else { sb = new substation(); sb.UID = ((PSP_Substation_Info)obj).UID; sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.EleID = xml1.GetAttribute("id"); sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; if (((PSP_Substation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_Substation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Create<substation>(sb); }*/ } } if (!string.IsNullOrEmpty(deviceid)) { if (xml1.GetAttribute("xlink:href").Contains("Power")) { DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid; DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID; DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID; obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid); if (obj != null) { DeviceHelper.StartYear = startyear; //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']"); if (DeviceHelper.ShowDeviceDlg(DeviceType.DY, deviceid, false)) { obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid); xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title); } } else { deviceid = ""; goto Lab1; } // re substation sb = new substation(); sb.UID = ((PSP_PowerSubstation_Info)obj).UID; sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb); if (sb != null) { sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; sb.EleID = xml1.GetAttribute("id"); if (((PSP_PowerSubstation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Update<substation>(sb); } else { sb = new substation(); sb.UID = ((PSP_PowerSubstation_Info)obj).UID; sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; sb.EleID = xml1.GetAttribute("id"); if (((PSP_PowerSubstation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Create<substation>(sb); } } else { obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid); if (obj != null) { DeviceHelper.StartYear = startyear; //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']"); if (DeviceHelper.ShowDeviceDlg(DeviceType.BDZ, deviceid, false)) { obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid); xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title); } } else { deviceid = ""; goto Lab1; } substation sb = new substation(); sb.UID = ((PSP_Substation_Info)obj).UID; sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb); if (sb != null) { sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; sb.EleID = xml1.GetAttribute("id"); if (((PSP_Substation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_Substation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Update<substation>(sb); } else { sb = new substation(); sb.UID = ((PSP_Substation_Info)obj).UID; sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.EleID = xml1.GetAttribute("id"); sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; if (((PSP_Substation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_Substation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Create<substation>(sb); } } } } if (xml1.GetAttribute("xlink:href").Contains("XL_GT_3") || xml1.GetAttribute("xlink:href").Contains("XL_GT_4")) { frmInputNum num = new frmInputNum(); num.InputStr = xml1.GetAttribute("order"); num.ShowDialog(); xml1.SetAttribute("order", num.InputStrSEL); } if (xml1.GetAttribute("xlink:href").Contains("hwg") || xml1.GetAttribute("xlink:href").Contains("pds") || xml1.GetAttribute("xlink:href").Contains("fjx") || xml1.GetAttribute("xlink:href").Contains("kbs") || xml1.GetAttribute("xlink:href").Contains("byq") || xml1.GetAttribute("xlink:href").Contains("kg") || xml1.GetAttribute("xlink:href").Contains("gt")) { //frmInputDialog n1 = new frmInputDialog(); //n1.InputStr = xml1.GetAttribute("info-name").ToString(); //if (n1.ShowDialog() == DialogResult.OK) //{ // xml1.SetAttribute("info-name", n1.InputStr); //} PSPDEV obj = new PSPDEV(); string deviceid = xml1.GetAttribute("Deviceid"); DeviceHelper.pspflag = false; DeviceHelper.Wjghflag = false; if (string.IsNullOrEmpty(deviceid)) { if (xml1.GetAttribute("xlink:href").Contains("kbs")) { obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.KBS, Itop.Client.MIS.ProgUID); } if (xml1.GetAttribute("xlink:href").Contains("fjx")) { obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.FZX, Itop.Client.MIS.ProgUID); } if (xml1.GetAttribute("xlink:href").Contains("hwg")) { obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.HWG, Itop.Client.MIS.ProgUID); } if (xml1.GetAttribute("xlink:href").Contains("kg")) { obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.ZSKG, Itop.Client.MIS.ProgUID); } if (xml1.GetAttribute("xlink:href").Contains("pds")) { obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.PDS, Itop.Client.MIS.ProgUID); } if (xml1.GetAttribute("xlink:href").Contains("byq")) { obj = (PSPDEV)DeviceHelper.SelectDevice(Itop.Client.MIS.ProgUID, "51", "52"); } //if (xml1.GetAttribute("xlink:href").Contains("gt")) //{ // obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.GT, Itop.Client.MIS.ProgUID); //} if (obj is PSPDEV) { deviceid = ((PSPDEV)obj).SUID; xml1.SetAttribute("Deviceid", deviceid); obj.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; obj.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; // obj.EleID = ((SvgElement)xml1).ID; Services.BaseService.Update<PSPDEV>(obj); } } if (!string.IsNullOrEmpty(deviceid)) { DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid; DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID; DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID; obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid); if (obj != null)//------------wwwMX { xml1.SetAttribute("info-name", ((PSPDEV)obj).Name); DeviceHelper.ShowDeviceDlg((DeviceType)int.Parse(obj.Type), deviceid, false); //if (obj.Type == "54") //{ // DeviceHelper.ShowDeviceDlg(DeviceType.KBS, deviceid, false); //} //if (obj.Type == "56") //{ // DeviceHelper.ShowDeviceDlg(DeviceType.HWG, deviceid, false); //} //if (obj.Type == "58") //{ // DeviceHelper.ShowDeviceDlg(DeviceType.FZX, deviceid, false); //} //if (obj.Type == "51" ) //{ // DeviceHelper.ShowDeviceDlg(DeviceType.FZX, deviceid, false); //} //if (obj.Type == "52") //{ // DeviceHelper.ShowDeviceDlg(DeviceType.FZX, deviceid, false); //} } } } /* if (xml1.GetAttribute("xlink:href").Contains("kbs") || xml1.GetAttribute("xlink:href").Contains("hwg")) { //frmkbsProperty num = new frmkbsProperty(); //num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID); //num.ShowDialog(); } if (xml1.GetAttribute("xlink:href").Contains("fjx")) { frmfjxProperty num = new frmfjxProperty(); num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID); num.ShowDialog(); } if (xml1.GetAttribute("xlink:href").Contains("byq")) { frmbyqProperty num = new frmbyqProperty(); num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID); num.ShowDialog(); } */ if (xml1.GetAttribute("xlink:href").Contains("SB_GT")) { string lineWidth = "2"; string Code = xltProcessor.GetCurrentLineCode(); string _len = xltProcessor.GetWholeLineLength(Code).ToString("#####.####"); frmLineProperty fl = new frmLineProperty(); fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement; fl.InitData(Code, tlVectorControl1.SVGDocument.SvgdataUid, _len, SvgDocument.currentLayer); if (fl.ShowDialog() == DialogResult.OK) { //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;" lineWidth = fl.LineWidth; string styleValue = ""; if (fl.Line.ObligateField1 == "规划") { styleValue = "stroke-dasharray:4 4;stroke-width:" + lineWidth + ";"; } else { styleValue = "stroke-width:" + lineWidth + ";"; } styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2))); ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("style"); ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", styleValue); xltProcessor.SetWholeLineAttribute(Code, "style", styleValue); } } } #region 网架优化的属性输入 if (Wjghboolflag) { checkwjghelement(); if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") { string lineWidth = "2"; string IsLead = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsLead"); if (IsLead != "") //修改后的导线的属性添加情况 { PSPDEV obj = new PSPDEV(); string deviceid = xml1.GetAttribute("Deviceid"); DeviceHelper.pspflag = false; DeviceHelper.Wjghflag = true; DeviceHelper.wjghuid = ff.Key; if (string.IsNullOrEmpty(deviceid)) { obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.XL, Itop.Client.MIS.ProgUID); if (obj == null) { tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement; tlVectorControl1.Delete(); } if (obj is PSPDEV) { deviceid = ((PSPDEV)obj).SUID; xml1.SetAttribute("Deviceid", deviceid); obj.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; obj.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; obj.EleID = ((SvgElement)xml1).ID; Services.BaseService.Update<PSPDEV>((PSPDEV)obj); } } if (!string.IsNullOrEmpty(deviceid)) { obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid); if (obj != null) { xml1.SetAttribute("info-name", ((PSPDEV)obj).Name); DeviceHelper.ShowDeviceDlg(DeviceType.XL, deviceid, false); } LineInfo li = new LineInfo(); li.UID = obj.SUID; li = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByKey", li); if (li != null) { li.LayerID = SvgDocument.currentLayer; li.EleID = xml1.GetAttribute("id"); li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; LineType lt = new LineType(); lt.TypeName = li.Voltage.ToString() + "kV"; lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt); li.ObligateField3 = obj.OperationYear; li.ObligateField2 = lt.Color; lineWidth = lt.ObligateField1; if (!string.IsNullOrEmpty(li.ObligateField3)) { if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) { li.ObligateField1 = "规划"; } else li.ObligateField1 = "运行"; } Services.BaseService.Update<LineInfo>(li); } else { li = new LineInfo(); li.UID = obj.SUID; li.LineName = obj.Name; li.Length = obj.LineLength.ToString(); li.LineType = obj.LineType; li.Voltage = obj.ReferenceVolt.ToString(); li.EleID = xml1.GetAttribute("id"); li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; LineType lt = new LineType(); lt.TypeName = obj.ReferenceVolt.ToString() + "kV"; lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt); li.ObligateField3 = obj.OperationYear; li.ObligateField2 = lt.Color; lineWidth = lt.ObligateField1; if (!string.IsNullOrEmpty(li.ObligateField3)) { if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) { li.ObligateField1 = "规划"; } else li.ObligateField1 = "运行"; } Services.BaseService.Create<LineInfo>(li); } string styleValue = ""; if (li.ObligateField1 == "规划") { styleValue = "stroke-dasharray:" + ghType + ";stroke-width:" + lineWidth + ";"; } else { styleValue = "stroke-width:" + lineWidth + ";"; } //string aa= ColorTranslator.ToHtml(Color.Black); styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(li.ObligateField2))); SvgElement se = tlVectorControl1.SVGDocument.CurrentElement; se.RemoveAttribute("style"); se.SetAttribute("style", styleValue); se.SetAttribute("info-name", li.LineName); //***** ********添加FistNode和LastNode XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use"); foreach (XmlNode element in useList) { if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid"))) { string con = "WHERE SvgUID='" + (element as XmlElement).GetAttribute("Deviceid") + "'AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='01'"; IList pspMX = Services.BaseService.GetList("SelectPSPDEVByCondition", con); if (pspMX != null) { foreach (PSPDEV pspmx in pspMX) { if (obj.IName == pspmx.Name) { (xml1 as XmlElement).SetAttribute("FirstNode", (element as XmlElement).GetAttribute("id")); } else if (obj.JName == pspmx.Name) { (xml1 as XmlElement).SetAttribute("LastNode", (element as XmlElement).GetAttribute("id")); } } } } } } //** } } if (xml1.GetAttribute("xlink:href").Contains("Substation") || xml1.GetAttribute("xlink:href").Contains("Power")) { string lab = xml1.GetAttribute("xlink:href"); float x = 0f; float y = 0f; x = ((Use)xml1).X; y = ((Use)xml1).Y; PointF p1 = new PointF(x, y); PointF[] pnt = new PointF[1]; pnt[0] = p1; Use temp = xml1.Clone() as Use; temp.Transform.Matrix.TransformPoints(pnt); LongLat templat = mapview.OffSetZero(-(int)(pnt[0].X * tlVectorControl1.ScaleRatio), -(int)(pnt[0].Y * tlVectorControl1.ScaleRatio)); string[] jd = templat.Longitude.ToString("####.####").Split('.'); int d1 = Convert.ToInt32(jd[0]); string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.'); int f1 = Convert.ToInt32(df1[0]); decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60; string[] wd = templat.Latitude.ToString("####.####").Split('.'); int d2 = Convert.ToInt32(wd[0]); string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.'); int f2 = Convert.ToInt32(df2[0]); decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60; string strjwd = "经纬度: " + d1.ToString() + "°" + f1.ToString() + "′" + m1.ToString("##.#") + "″," + d2.ToString() + "°" + f2.ToString() + "′" + m2.ToString("##.#") + "″"; object obj = null; string deviceid = xml1.GetAttribute("Deviceid"); DeviceHelper.pspflag = false; DeviceHelper.Wjghflag = true; if (string.IsNullOrEmpty(deviceid)) { //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (xml1.GetAttribute("xlink:href").Contains("Power")) { obj = DeviceHelper.SelectDevice(DeviceType.DY, Itop.Client.MIS.ProgUID); if (obj == null) { tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement; tlVectorControl1.Delete(); } if (obj is PSP_PowerSubstation_Info) { deviceid = ((PSP_PowerSubstation_Info)obj).UID; ((PSP_PowerSubstation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; Services.BaseService.Update<PSP_PowerSubstation_Info>(((PSP_PowerSubstation_Info)obj)); xml1.SetAttribute("Deviceid", deviceid); } substation sb = new substation(); sb.UID = ((PSP_PowerSubstation_Info)obj).UID; sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb); if (sb != null) { sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; sb.EleID = xml1.GetAttribute("id"); if (((PSP_PowerSubstation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Update<substation>(sb); } else { sb = new substation(); sb.UID = ((PSP_PowerSubstation_Info)obj).UID; sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.EleID = xml1.GetAttribute("id"); sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; if (((PSP_PowerSubstation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Create<substation>(sb); } } else { obj = DeviceHelper.SelectDevice(DeviceType.BDZ, Itop.Client.MIS.ProgUID); if (obj == null) { tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement; tlVectorControl1.Delete(); } if (obj is PSP_Substation_Info) { deviceid = ((PSP_Substation_Info)obj).UID; ((PSP_Substation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; ((PSP_Substation_Info)obj).EleID = tlVectorControl1.SVGDocument.CurrentElement.ID; Services.BaseService.Update<PSP_Substation_Info>(((PSP_Substation_Info)obj)); xml1.SetAttribute("Deviceid", deviceid); } substation sb = new substation(); sb.UID = ((PSP_Substation_Info)obj).UID; sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb); if (sb != null) { sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; sb.EleID = xml1.GetAttribute("id"); if (((PSP_Substation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_Substation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Update<substation>(sb); } else { sb = new substation(); sb.UID = ((PSP_Substation_Info)obj).UID; sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.EleID = xml1.GetAttribute("id"); sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; if (((PSP_Substation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_Substation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Create<substation>(sb); } } } if (!string.IsNullOrEmpty(deviceid)) { if (xml1.GetAttribute("xlink:href").Contains("Power")) { obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid); if (obj != null) { xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title); //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']"); DeviceHelper.ShowDeviceDlg(DeviceType.DY, deviceid, false); } } else { obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid); if (obj != null) { xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title); //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']"); DeviceHelper.ShowDeviceDlg(DeviceType.BDZ, deviceid, false); } } } } if (xml1.GetAttribute("xlink:href").Contains("XL_GT_3") || xml1.GetAttribute("xlink:href").Contains("XL_GT_4")) { frmInputNum num = new frmInputNum(); num.InputStr = xml1.GetAttribute("order"); num.ShowDialog(); xml1.SetAttribute("order", num.InputStrSEL); } //if (xml1.GetAttribute("xlink:href").Contains("kbs") || xml1.GetAttribute("xlink:href").Contains("hwg")) //{ // frmkbsProperty num = new frmkbsProperty(); // num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID); // num.ShowDialog(); //} //if (xml1.GetAttribute("xlink:href").Contains("fjx")) //{ // frmfjxProperty num = new frmfjxProperty(); // num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID); // num.ShowDialog(); //} //if (xml1.GetAttribute("xlink:href").Contains("byq")) //{ // frmbyqProperty num = new frmbyqProperty(); // num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID); // num.ShowDialog(); //} if (xml1.GetAttribute("xlink:href").Contains("SB_GT")) { string lineWidth = "2"; string Code = xltProcessor.GetCurrentLineCode(); string _len = xltProcessor.GetWholeLineLength(Code).ToString("#####.####"); frmLineProperty fl = new frmLineProperty(); fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement; fl.InitData(Code, tlVectorControl1.SVGDocument.SvgdataUid, _len, SvgDocument.currentLayer); if (fl.ShowDialog() == DialogResult.OK) { //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;" lineWidth = fl.LineWidth; string styleValue = ""; if (fl.Line.ObligateField1 == "规划") { styleValue = "stroke-dasharray:4 4;stroke-width:" + lineWidth + ";"; } else { styleValue = "stroke-width:" + lineWidth + ";"; } styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2))); ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("style"); ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", styleValue); xltProcessor.SetWholeLineAttribute(Code, "style", styleValue); } } } #endregion } if (e.ClickedItem.Text == "移动") { if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { return; } XmlElement xmln = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement; frmMove fm = new frmMove(); PointF pf11 = ((Use)xmln).CenterPoint; LongLat temp = mapview.ParseToLongLat((int)pf11.X, (int)pf11.Y); string[] jd = temp.Longitude.ToString("####.####").Split('.'); int d1 = Convert.ToInt32(jd[0]); string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.'); int f1 = Convert.ToInt32(df1[0]); decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60; string[] wd = temp.Latitude.ToString("####.####").Split('.'); int d2 = Convert.ToInt32(wd[0]); string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.'); int f2 = Convert.ToInt32(df2[0]); decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60; strj1 = d1.ToString(); strw1 = f1.ToString(); strd1 = m1.ToString(); strj2 = d2.ToString(); strw2 = f2.ToString(); strd2 = m2.ToString(); fm.Init(strj1, strw1, strd1, strj2, strw2, strd2); if (fm.ShowDialog() == DialogResult.OK) { string strValue = fm.StrValue; string[] str = strValue.Split(','); string[] JWD1 = str[0].Split(' '); decimal J1 = Convert.ToDecimal(JWD1[0]); decimal W1 = Convert.ToDecimal(JWD1[1]); decimal D1 = Convert.ToDecimal(JWD1[2]); string[] JWD2 = str[1].Split(' '); decimal J2 = Convert.ToDecimal(JWD2[0]); decimal W2 = Convert.ToDecimal(JWD2[1]); decimal D2 = Convert.ToDecimal(JWD2[2]); decimal JD = J1 + W1 / 60 + D1 / 3600; decimal WD = J2 + W2 / 60 + D2 / 3600; PointF pf1 = mapview.ParseToPoint(JD, WD); PointF p1 = ((Use)xmln).CenterPoint; SvgElement e1 = xmln as SvgElement; Matrix matrix2 = ((IGraph)e1).GraphTransform.Matrix.Clone(); Matrix matrix3 = tlVectorControl1.DrawArea.CoordTransform.Clone(); matrix3.Invert(); matrix2.Multiply(matrix3, MatrixOrder.Append); matrix2.Invert(); PointF[] pfArray1 = new PointF[] { new PointF(pf1.X / tlVectorControl1.ScaleRatio, pf1.Y / tlVectorControl1.ScaleRatio), p1 }; matrix2.TransformPoints(pfArray1); float single1 = pfArray1[0].X - pfArray1[1].X; float single2 = pfArray1[0].Y - pfArray1[1].Y; Matrix matrix6 = ((IGraph)e1).Transform.Matrix.Clone(); if (e1.SvgAttributes.ContainsKey("transform")) { Matrix matrix7 = ((Matrix)e1.SvgAttributes["transform"]).Clone(); matrix7.Invert(); matrix6.Multiply(matrix7, MatrixOrder.Append); } Matrix matrix5 = new Matrix(); matrix5.Translate(single1, single2); Matrix matrix8 = ((IGraph)e1).Transform.Matrix.Clone(); matrix8.Multiply(matrix5); matrix6.Invert(); matrix6.Multiply(matrix8, MatrixOrder.Append); Transf tf = new Transf(); tf.setMatrix(matrix6); (xmln as Use).Transform = tf; } } if (e.ClickedItem.Text == "接线图") { if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { return; } ParentUID = tlVectorControl1.SVGDocument.SvgdataUid; Save(); ParentUID = tlVectorControl1.SVGDocument.SvgdataUid; SVGFILE svg_temp = new SVGFILE(); //XmlElement xml1 = ((XmlElement)(e.Elements[0]));xml1.GetAttribute("id"); svg_temp.SUID = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("id"); svg_temp.FILENAME = getBdzName(svg_temp.SUID);// ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("info-name"); string strWhere = string.Format("suid='{0}' or filename='{1}' ", svg_temp.SUID, svg_temp.FILENAME); IList svglist = Services.BaseService.GetList("SelectSVGFILEByWhere", strWhere); OpenJXT(svglist, svg_temp); //frmlar.SymbolDoc = tlVectorControl1.SVGDocument; //frmlar.Progtype = MapType; //frmlar.InitData(); //JxtBar(); } if (e.ClickedItem.Text == "打开") { if (tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } UseRelating UseRel = new UseRelating(); UseRel.UseID = tlVectorControl1.SVGDocument.CurrentElement.ID; IList<UseRelating> UseRelList = Services.BaseService.GetList<UseRelating>("SelectUseRelatingByUseID", UseRel); if (UseRelList.Count < 1) { MessageBox.Show("选择的地块还没有关联到其他地图,请先设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } UseRel = UseRelList[0]; SVGFILE svgFile = new SVGFILE(); svgFile.SUID = UseRel.LinkUID; IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile); if (svgList.Count < 1) { MessageBox.Show("被关联的地图已经被删除,请重新设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } svgFile = (SVGFILE)svgList[0]; //SvgDocument doc = new SvgDocument(); if (!string.IsNullOrEmpty(svgFile.SVGDATA)) { //doc.LoadXml(svgFile.SVGDATA); ctlfile_OnOpenSvgDocument(sender, svgFile.SUID); } } if (e.ClickedItem.Text == "区域打印") { PrintHelper ph = new PrintHelper(tlVectorControl1, mapview); frmPrinter dlg = new frmPrinter(); dlg.printHelper = ph; dlg.ShowDialog(); return; ArrayList idlist = new ArrayList(); ArrayList symlist = new ArrayList(); SvgDocument _doc = new SvgDocument(); Graph poly1 = tlVectorControl1.SVGDocument.CurrentElement as Graph; if (poly1 == null || poly1.GetAttribute("id") == "svg") { return; } GraphicsPath gr1 = new GraphicsPath(); //gr1.AddRectangle(TLMath.getRectangle(poly1)); gr1.AddPolygon(TLMath.getPolygonPoints(poly1)); //gr1.CloseFigure(); gr1 = (GraphicsPath)poly1.GPath.Clone(); gr1.Transform((poly1 as IGraph).Transform.Matrix); RectangleF ef1 = gr1.GetBounds(); ef1 = PathFunc.GetBounds(gr1); StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">"); XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("defs"); if (nlist.Count > 0) { XmlNode node = nlist[0]; svgtxt.AppendLine(node.OuterXml); } SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator(); while (enumerator1.MoveNext()) { IGraph graph1 = (IGraph)enumerator1.Current; GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone(); //path1.Transform(graph1.GraphTransform.Matrix); //path1.Transform(graph1.Transform.Matrix); // RectangleF ef2 = path1.GetBounds();// PathFunc.GetBounds(path1); //for (int n = 0; n < selCol.Count - 1; n++) //{ // //_doc.AppendChild((XmlNode)selCol[n]); // svgtxt = svgtxt + ((XmlElement)selCol[n]).OuterXml + "\r\n"; //} if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue; GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone(); path2.Transform(graph1.Transform.Matrix); RectangleF ef2 = PathFunc.GetBounds(path2); if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty) { SvgElement ele = (SvgElement)graph1; svgtxt.AppendLine(ele.OuterXml); //tlVectorControl1.SVGDocument.AddSelectElement(graph1); if (graph1 is Use) { //PointF offset = TLMath.getUseOffset(((XmlElement)graph1).GetAttribute("xlink:href")); //if (ef1.Contains(new PointF(((Use)graph1).X + offset.X, ((Use)graph1).Y + offset.Y))) { //SvgElement ele = (SvgElement)graph1; //svgtxt.AppendLine(ele.OuterXml); string symid = ((XmlElement)graph1).GetAttribute("xlink:href"); if (!symlist.Contains(symid)) { symlist.Add(symid); } //} } if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") { string IsLead = ((XmlElement)graph1).GetAttribute("IsLead"); if (IsLead != "") { if (ef1.Contains(ef2)) { idlist.Add(graph1.ID); } } } } } symlist = ResetList(symlist); svgtxt.AppendLine("</svg>"); _doc.LoadXml(svgtxt.ToString()); _doc.SvgdataUid = tlVectorControl1.SVGDocument.SvgdataUid; frmPrintF pri = new frmPrintF(); pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid); if (pri.ShowDialog() == DialogResult.OK) { frmSubPrint s = new frmSubPrint(); s.Vector = tlVectorControl1; s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist); s.Open(_doc, ef1); s.Show(); } } if (e.ClickedItem.Text == "分类统计报表") { if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { return; } IGraph poly1 = (IGraph)tlVectorControl1.SVGDocument.CurrentElement; frmPloyPrint p = new frmPloyPrint(); p.InitDate(poly1.ID, tlVectorControl1.SVGDocument.SvgdataUid); p.ShowDialog(); } if (e.ClickedItem.Text == "保存图片") { if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") { PrintHelper ph = new PrintHelper(tlVectorControl1, mapview); frmImgManager frm = new frmImgManager(); frm.Pic = ph.getImage(); frm.ShowDialog(); } } } catch (Exception e1) { //MessageBox.Show(e1.Message); } if (e.ClickedItem.Text == "三维变电站") { try { string strid = tlVectorControl1.SVGDocument.CurrentElement.ID; substation s = new substation(); s.EleID = strid; s.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; s = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", s); ProcessStartInfo p = new ProcessStartInfo(); p.FileName = Application.StartupPath + "\\" + s.EleName + "\\bdz.exe"; p.WorkingDirectory = Application.StartupPath + "\\" + s.EleName; Process.Start(p); } catch (Exception e1) { } } if (e.ClickedItem.Text == "清除关联") { ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("Deviceid"); } if (e.ClickedItem.Text == "更新关联变电站") { UpdateLine(); } if (e.ClickedItem.Text == "删除") { Delete(); } }
private Layer CopyLayer(Layer layer) { Layer layer2 = Layer.CreateNew(layer.Label + " ����", this.SymbolDoc); //foreach (SvgElement g in layer.GraphList) //{ // layer2.GraphList.Add(g); //} this.SymbolDoc.NumberOfUndoOperations = (2 * layer2.GraphList.Count) + 200; SvgElementCollection sc = layer.GraphList; for (int i = layer.GraphList.Count - 1; i >= 0; i--) { SvgElement element = sc[i] as SvgElement; SvgElement temp = element.Clone() as SvgElement; //if (temp.Name=="use"){ if (temp.GetAttribute("CopyOf") == "") { temp.SetAttribute("CopyOf", temp.ID); } IGraph graph = (IGraph)layer2.AddElement(temp); graph.Layer = layer2; LineInfo _line = new LineInfo(); _line.EleID = element.ID; _line.SvgUID = this.SymbolDoc.SvgdataUid; IList lineInfoList = Services.BaseService.GetList("SelectLineInfoByEleID", _line); foreach (LineInfo line in lineInfoList) { line.UID = Guid.NewGuid().ToString(); line.LayerID = layer2.ID; line.EleID = temp.ID; Services.BaseService.Create<LineInfo>(line); } glebeProperty gle = new glebeProperty(); gle.EleID = element.ID; gle.SvgUID = this.SymbolDoc.SvgdataUid; IList gleProList = Services.BaseService.GetList("SelectglebePropertyByEleID", gle); foreach (glebeProperty gleP in gleProList) { gleP.UID = Guid.NewGuid().ToString(); gleP.LayerID = layer2.ID; gleP.EleID = temp.ID; Services.BaseService.Create<glebeProperty>(gleP); } substation _sub = new substation(); _sub.EleID = element.ID; _sub.SvgUID = this.SymbolDoc.SvgdataUid; IList substationList = Services.BaseService.GetList("SelectsubstationByEleID", _sub); foreach (substation sub in substationList) { sub.UID = Guid.NewGuid().ToString(); sub.LayerID = layer2.ID; sub.EleID = temp.ID; Services.BaseService.Create<substation>(sub); } } this.SymbolDoc.NotifyUndo(); return layer2; }
public void ReLoadViewData(glebeProperty gp, string _sub220, string _sub110,string _sub66) { double dou_fh1 = 0; try { str220 = _sub220; str110 = _sub110; str66 = _sub66; gPro.EleID = gp.EleID; gPro.SvgUID = gp.SvgUID; layerID = gp.LayerID; IList svglist = Services.BaseService.GetList("SelectglebePropertyByEleID", gPro); if (svglist.Count > 0) { gPro = (glebeProperty)svglist[0]; IsCreate = false; if (gPro.SonUid == "") { gPro.SonUid = "2"; } } else { IsCreate = true; gPro.LayerID = layerID; } glebeType g = new glebeType(); g.UID = "6ab9af7b-3d97-4e6c-8ed7-87b76950b90b"; g = (glebeType)Services.BaseService.GetObject("SelectglebeTypeByKey", g); if (gPro.ObligateField10 == "") { gPro.ObligateField10 = "0"; } nullvalue = Convert.ToDecimal(gPro.ObligateField10) * Convert.ToDecimal(g.TypeStyle); //空间负荷进行自动的刷新 ctrlglebeYearValue1.ParentObj = gPro; ctrlglebeYearValue1.Refresh(); //bh.DataBindings.Add("Text", gPro, "UseID"); //lx.DataBindings.Add("EditValue", gPro, "TypeUID"); //mj.DataBindings.Add("Text", gPro, "Area"); //fh.DataBindings.Add("Text", gPro, "Burthen"); //dl.DataBindings.Add("Text", gPro, "Number"); //rzb.DataBindings.Add("Text", gPro, "SonUid"); //remark.DataBindings.Add("Text", gPro, "Remark"); //yk1.DataBindings.Add("Text", gPro, "ObligateField2"); //jc1.DataBindings.Add("Text", gPro, "ObligateField3"); //nl1.DataBindings.Add("Text", gPro, "ObligateField4"); //yk2.DataBindings.Add("Text", gPro, "ObligateField5"); //jc2.DataBindings.Add("Text", gPro, "ObligateField6"); //nl2.DataBindings.Add("Text", gPro, "ObligateField7"); //ph1.DataBindings.Add("Text", gPro, "ObligateField8"); //ph2.DataBindings.Add("Text", gPro, "ObligateField9"); //Hashtable hs = new Hashtable(); //hs.Add("ParentEleID", gPro.EleID); //hs.Add("SvgUID", gPro.SvgUID); //sondt = Itop.Common.DataConverter.ToDataTable(Services.BaseService.GetList("SelectglebePropertParentID", hs), typeof(glebeProperty)); //gridControl.DataSource = sondt; //string temp = ""; //foreach (DataRow row in sondt.Rows) //{ // if (temp != row["TypeUID"].ToString()) // { // temp = row["TypeUID"].ToString(); // typelist.Add(row["TypeUID"]); // } //} //if (gPro.Number==0 || gPro.Burthen==0) //{ Hashtable hs1 = new Hashtable(); if (gPro.SelSonArea != "") { string[] selArea = gPro.SelSonArea.Split(";".ToCharArray()); for (int i = 0; i < selArea.Length; i++) { if (selArea[i] != "") { string[] _SonArea = selArea[i].Split(",".ToCharArray()); hs1.Add(_SonArea[0], _SonArea[1]); } } } IEnumerator Ilist = sondt.Rows.GetEnumerator(); while (Ilist.MoveNext()) { DataRow row = (DataRow)Ilist.Current; string eleid = (string)hs1[row["EleID"]]; if (eleid != "") { dou_fh1 = dou_fh1 + (Convert.ToDouble(hs1[row["EleID"]]) / Convert.ToDouble(row["Area"])) * Convert.ToDouble(row["Burthen"]); } } gPro.Burthen = Convert.ToDecimal(dou_fh1) + nullvalue; fh.Text = gPro.Burthen.ToString("#####.####"); //gPro.Number = Convert.ToDecimal( dou_dl.ToString("#####.##")); //} if (fh.Text == "") { fh.Text = "0"; } if (dl.Text == "") { dl.Text = "0"; } gPro.Burthen = Convert.ToDecimal(fh.Text); pjfh.Text = Convert.ToDecimal(Convert.ToDecimal(fh.Text) / (Convert.ToDecimal(gPro.Area)+Convert.ToDecimal(gPro.ObligateField10))).ToString("#####.####"); //辅助决策 //if ((gPro.ObligateField2 == "" || gPro.ObligateField2 == null) && (gPro.ObligateField5 == "" || gPro.ObligateField5 == null)) //{ // Reload(); //} } catch (Exception e1) { MessageBox.Show(e1.Message); } }
private Layer CopyLayer2(Layer layer,string textname) { string layerlabelf = layer.Label.Substring(4); string layer2name = textname + layerlabelf; int j=0; for (int i = 0; i < checkedListBox1.Items.Count; i++) { if (checkedListBox1.Items[i].ToString() == layer2name) j = 1; //else // j = 0; } Layer layer2=null; if (j == 0) { layer2= Layer.CreateNew(textname + layerlabelf, this.SymbolDoc); this.SymbolDoc.NumberOfUndoOperations = (2 * layer2.GraphList.Count) + 200; SvgElementCollection sc = layer.GraphList; for (int i = layer.GraphList.Count - 1; i >= 0; i--) { SvgElement element = sc[i] as SvgElement; SvgElement temp = element.Clone() as SvgElement; if (temp.GetAttribute("CopyOf") == "") { temp.SetAttribute("CopyOf", temp.ID); } IGraph graph = (IGraph)layer2.AddElement(temp); graph.Layer = layer2; //LineInfo _line = new LineInfo(); //_line.EleID = element.ID; //_line.SvgUID = this.SymbolDoc.SvgdataUid; //IList lineInfoList = Services.BaseService.GetList("SelectLineInfoByEleID", _line); PSPDEV _line = new PSPDEV(); _line.EleID = element.ID; _line.SvgUID = this.SymbolDoc.SvgdataUid; IList lineInfoList = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandEleID", _line); foreach (PSPDEV line in lineInfoList) { line.SUID = Guid.NewGuid().ToString(); line.LayerID = layer2.ID; line.EleID = temp.ID; Services.BaseService.Create<PSPDEV>(line); } glebeProperty gle = new glebeProperty(); gle.EleID = element.ID; gle.SvgUID = this.SymbolDoc.SvgdataUid; IList gleProList = Services.BaseService.GetList("SelectglebePropertyByEleID", gle); foreach (glebeProperty gleP in gleProList) { gleP.UID = Guid.NewGuid().ToString(); gleP.LayerID = layer2.ID; gleP.EleID = temp.ID; Services.BaseService.Create<glebeProperty>(gleP); } substation _sub = new substation(); _sub.EleID = element.ID; _sub.SvgUID = this.SymbolDoc.SvgdataUid; IList substationList = Services.BaseService.GetList("SelectsubstationByEleID", _sub); foreach (substation sub in substationList) { sub.UID = Guid.NewGuid().ToString(); sub.LayerID = layer2.ID; sub.EleID = temp.ID; Services.BaseService.Create<substation>(sub); } } } this.SymbolDoc.NotifyUndo(); return layer2; }
public void UpdateSpatataldata(string TypeTitle) { TreeListNode row = this.treeList1.FocusedNode; if (row == null) { return; } glebeProperty gp = new glebeProperty(); gp.ParentEleID = "0"; gp.SvgUID = "c5ec3bc7-9706-4cbd-9b8b-632d3606f933"; gp.ObligateField16 = TypeTitle; IList<glebeProperty> svglist = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByObligateField16", gp); //重新对选中的数据进行更新 Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); ForecastClass1.TreeNodeToDataObject<Ps_Forecast_Math>(psp_Type, row); IList<glebeYearValue> yearlist = Services.BaseService.GetList<glebeYearValue>("SelectglebeYearValueBywhere", "ParentID='" + svglist[0].UID + "'"); for (int i = 0; i < yearlist.Count; i++) { string y = "y" + yearlist[i].Year.ToString(); psp_Type.GetType().GetProperty(y).SetValue(psp_Type, yearlist[i].Burthen, null); } try { Common.Services.BaseService.Update<Ps_Forecast_Math>(psp_Type); //psp_Type.ID = (int)Common.Services.BaseService.Create("InsertPSP_P_Types", psp_Type); //dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow())); LoadData(); //treeList1.EndUpdate(); RefreshChart(); } catch (Exception ex) { } }
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { TreeListNode row = this.treeList1.FocusedNode; if (row == null) { return; } string parentid = row["ParentID"].ToString(); // FormTypeTitle frm = new FormTypeTitle(); string TypeTitle = row["Title"].ToString(); frmMain_Spatial fmain = new frmMain_Spatial(); frmMain_Spatial.MapType = "接线图"; frmMain_Spatial.progtype = "城市规划层"; string pid = ""; fmain.Show(); string progtype = "城市规划层"; //if (progtype == "地理信息层") { // fmain.ViewMenu(); //} if (pid == "") { fmain.Open("c5ec3bc7-9706-4cbd-9b8b-632d3606f933",""); } else { fmain.Open("c5ec3bc7-9706-4cbd-9b8b-632d3606f933", pid); } // LoadImage = true; fmain.InitShape(); fmain.Init(progtype); fmain.InitScaleRatio(); fmain.LayerManagerShow(); fmain.OpenGHQYpropetty(TypeTitle); if (fmain.DialogResult == DialogResult.OK) { glebeProperty gp = new glebeProperty(); gp.ParentEleID = "0"; gp.SvgUID = "c5ec3bc7-9706-4cbd-9b8b-632d3606f933"; gp.ObligateField16 = TypeTitle; IList<glebeProperty> svglist = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByObligateField16", gp); //重新对选中的数据进行更新 Ps_Forecast_Math psp_Type = new Ps_Forecast_Math(); ForecastClass1.TreeNodeToDataObject<Ps_Forecast_Math>(psp_Type, row); IList<glebeYearValue> yearlist = Services.BaseService.GetList<glebeYearValue>("SelectglebeYearValueBywhere", "ParentID='" + svglist[0].UID + "'"); for (int i = 0; i < yearlist.Count; i++) { string y = "y" + yearlist[i].Year.ToString(); psp_Type.GetType().GetProperty(y).SetValue(psp_Type, yearlist[i].Burthen, null); } try { Common.Services.BaseService.Update<Ps_Forecast_Math>(psp_Type); //psp_Type.ID = (int)Common.Services.BaseService.Create("InsertPSP_P_Types", psp_Type); //dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow())); LoadData(); //treeList1.EndUpdate(); RefreshChart(); } catch (Exception ex) { } } else { //MsgBox.Show("在规划地块中,没有圈选此区域,请在规划地块模块中圈选此地块再点击编辑!"); fmain.Owner = this; } }
void tlVectorControl1_RightClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e) { str_outjwd = ""; str_djcl = ""; sel_sym = ""; sel_start_point = ""; if (mapview is MapViewGoogle) mapMenu.Visible = true; try { if (csOperation == CustomOperation.OP_MeasureDistance) { tlVectorControl1.Operation = ToolOperation.Select; contextMenuStrip1.Hide(); return; } if (tlVectorControl1.Operation == ToolOperation.LeadLine && str_dhx == "1") { SvgElement _x = tlVectorControl1.SVGDocument.CurrentElement; _x.SetAttribute("dhx_key", "1"); } //tlVectorControl1.DocumentSize = new SizeF(3170f, 2540f); //MessageBox.Show(MapType); tmLineConnect.Visible = false; SvgElementCollection elements = tlVectorControl1.SVGDocument.SelectCollection; if (elements.Count == 2) { Polyline pl1 = elements[0] as Polyline; Polyline pl2 = elements[1] as Polyline; if (pl1 != null && pl2 != null && pl1.GetAttribute("IsLead") != "" && pl2.GetAttribute("IsLead") != "") { tmLineConnect.Visible = true; } } if (MapType == "接线图") { tip.Hide(); if (getlayer(SvgDocument.currentLayer, "背景层", tlVectorControl1.SVGDocument.getLayerList())) { contextMenuStrip1.Enabled = false; } else { contextMenuStrip1.Enabled = true; } if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() != "ItopVector.Core.Figure.Use") { moveMenuItem.Visible = false; jxtToolStripMenuItem.Visible = false; w3MenuItem.Visible = false; } else { if (tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("xlink:href").Contains("Substation")) { moveMenuItem.Visible = true; jxtToolStripMenuItem.Visible = true; w3MenuItem.Visible = true; } } if (show3d == 0) { w3MenuItem.Visible = false; } if (tlVectorControl1.SVGDocument.CurrentElement != null && tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() != "ItopVector.Core.Figure.RectangleElement" && tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() != "ItopVector.Core.Figure.Polygon") { printToolStripMenuItem.Visible = false; toolDel.Visible = false; SubToolStripMenuItem.Visible = false; } else { printToolStripMenuItem.Visible = true; toolDel.Visible = true; SubToolStripMenuItem.Visible = false; saveImg.Visible = true; } if (tlVectorControl1.SVGDocument.CurrentElement != null && tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") { mUpdateMenuItem.Visible = true; tmloctaionjxt.Visible = true; } else { mUpdateMenuItem.Visible = false; tmloctaionjxt.Visible = false; } string guid = Guid.NewGuid().ToString(); if (tlVectorControl1.Operation == ToolOperation.LeadLine && linekey != "") { string str = ""; LineList1 line1 = new LineList1(); line1.UID = Guid.NewGuid().ToString(); line1.LineEleID = tlVectorControl1.SVGDocument.CurrentElement.ID; line1.PointNum = ((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)).Points.Length - 2; line1.Coefficient = (decimal)(1.02); line1.Length = TLMath.getPolylineLength(((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)), Convert.ToDecimal(tlVectorControl1.ScaleRatio)); line1.Length2 = TLMath.getPolylineLength(((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)), Convert.ToDecimal(tlVectorControl1.ScaleRatio)) * Convert.ToDecimal(1.02); PointF[] pnt = ((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)).Points; if (pnt.Length < 3) return; for (int i = 0; i < pnt.Length; i++) { double ang = TLMath.getLineAngle(pnt[i], pnt[i + 1], pnt[i + 2]); if (ang * 57.3 > 60) { MessageBox.Show("线路转角不能大于60度。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.Delete(); return; } str = str + "第" + (i + 1) + "转角:" + Convert.ToDouble(ang * 57.3).ToString("##.##") + "度。\r\n"; if (i == pnt.Length - 3) { break; } } line1.TurnAngle = str; line1.col1 = linekey; frmInputDialog input = new frmInputDialog(); if (input.ShowDialog() == DialogResult.OK) { line1.LineName = input.InputStr; Services.BaseService.Create<LineList1>(line1); } else { tlVectorControl1.Delete(); } linekey = ""; } if (tlVectorControl1.Operation == ToolOperation.InterEnclosure && bdz_xz == "yes") { D_TIN.Clear(); ArrayList polylist = new ArrayList(); ArrayList useList = new ArrayList(); System.Collections.SortedList list = new SortedList(); ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection; int t = 0; Lab009: t = t + 1; XmlElement poly1 = (XmlElement)selCol[selCol.Count - t]; if (poly1.GetType().FullName != "ItopVector.Core.Figure.Polygon") { goto Lab009; } SvgElement se = null; for (int i = 0; i < selCol.Count; i++) { string tem = selCol[i].GetType().FullName; if (tem == "ItopVector.Core.Figure.Polygon") { string IsArea = ((XmlElement)selCol[i]).GetAttribute("IsArea"); if (IsArea == "") { se = (SvgElement)selCol[i]; //大范围 } else { polylist.Add((SvgElement)selCol[i]); } } if (tem == "ItopVector.Core.Figure.Use") { useList.Add((SvgElement)selCol[i]); } } decimal sumss = 0; for (int m = 0; m < polylist.Count; m++) { XmlElement _x = (XmlElement)polylist[m]; string sid = _x.GetAttribute("id"); glebeProperty pl = new glebeProperty(); pl.EleID = sid; pl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; pl = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", pl); if (pl != null) { sumss = sumss + pl.Burthen;//区域负荷 } } double sumSub = 0; for (int m = 0; m < useList.Count; m++) { XmlElement _x = (XmlElement)useList[m]; string sid = _x.GetAttribute("Deviceid"); PSP_Substation_Info pl = new PSP_Substation_Info(); pl.UID = sid; //pl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; pl = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", pl); if (pl != null) { sumSub = sumSub + pl.L2; //现有的容量 } } FrmSet f_set = new FrmSet(); f_set.s = sumss; f_set.sub_s = sumSub; if (f_set.ShowDialog() == DialogResult.OK) { str_dy = f_set.Str_dj; //电压等级 str_num = f_set.Str_num; //所需建的数目 str_jj = f_set.Str_jj;//变电站最小距离 tlVectorControl1.SVGDocument.SelectCollection.Clear(); if (Convert.ToDecimal(str_num) < 0) { MessageBox.Show("区域内供电满足要求,不需要新建变电站。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Polygon pp = se as Polygon; if (useList.Count < 3) { for (int i = 0; i < pp.Points.Length; i++) { //加点 D_TIN.DS.Vertex[D_TIN.DS.VerticesNum].x = (long)pp.Points[i].X; D_TIN.DS.Vertex[D_TIN.DS.VerticesNum].y = (long)pp.Points[i].Y; D_TIN.DS.Vertex[D_TIN.DS.VerticesNum].ID = D_TIN.DS.VerticesNum; D_TIN.DS.vetexboundary[D_TIN.DS.VerticesNum].pointid = D_TIN.DS.VerticesNum;//填写各个节点泰森多边形影响区域 D_TIN.DS.VerticesNum++; } } else { for (int m = 0; m < useList.Count; m++) { Use _p = useList[m] as Use; string str_t = _p.GetAttribute("xlink:href"); PointF of = TLMath.getUseOffset(str_t); PointF p1 = new PointF(_p.X, _p.Y); PointF[] pnt = new PointF[1]; pnt[0] = p1; _p.Transform.Matrix.TransformPoints(pnt); D_TIN.DS.Vertex[D_TIN.DS.VerticesNum].x = (long)pnt[0].X + (long)of.X; D_TIN.DS.Vertex[D_TIN.DS.VerticesNum].y = (long)pnt[0].Y + (long)of.Y; D_TIN.DS.Vertex[D_TIN.DS.VerticesNum].ID = D_TIN.DS.VerticesNum; D_TIN.DS.vetexboundary[D_TIN.DS.VerticesNum].pointid = D_TIN.DS.VerticesNum;//填写各个节点泰森多边形影响区域 D_TIN.DS.VerticesNum++; } } if ((Convert.ToInt32(str_num) > 1) && (sumss == 0) && (useList.Count > Convert.ToInt32(str_num) + 2)) { if ((MessageBox.Show("区域内负荷为0,无法进行负荷分布自动选址。\r\n 是否进行最小覆盖圆自动选址?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) == DialogResult.Yes) { int n = D_TIN.DS.VerticesNum; D_TIN.DS.set_cnt = D_TIN.DS.VerticesNum; D_TIN.DS.pos_cnt = 0; for (int i = 0; i < n; i++) D_TIN.DS.curset[i] = i; D_TIN.mindisk(); Pen p2 = new Pen(Color.Red, 2); Rectangle rec = new Rectangle((int)(D_TIN.DS.maxcic.x - D_TIN.DS.radius), (int)(D_TIN.DS.maxcic.y - D_TIN.DS.radius), (int)(2 * D_TIN.DS.radius), (int)(2 * D_TIN.DS.radius)); string str_sub = getSubName(str_dy); PointF pf = getOff(str_dy); XmlElement e0 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement; e0.SetAttribute("x", Convert.ToString(D_TIN.DS.maxcic.x - pf.X)); e0.SetAttribute("y", Convert.ToString(D_TIN.DS.maxcic.y - pf.Y)); e0.SetAttribute("xzflag", "1"); e0.SetAttribute("xlink:href", str_sub); e0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); e0.SetAttribute("layer", SvgDocument.currentLayer); tlVectorControl1.SVGDocument.RootElement.AppendChild(e0); tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e0); //获得此变电站的最小半径的圆 生成辐射线 XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle; n1.SetAttribute("cx", e0.GetAttribute("x").ToString()); n1.SetAttribute("cy", e0.GetAttribute("y").ToString()); n1.SetAttribute("r", (TLMath.getdcNumber(Convert.ToDecimal(str_jj), tlVectorControl1.ScaleRatio)).ToString()); n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;"); SubandFHcollect sf = new SubandFHcollect(GetsubFhk((Circle)n1, polylist), e0); CreateSubline(sf); // XmlElement t0 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t0.SetAttribute("x", Convert.ToString(D_TIN.DS.maxcic.x)); t0.SetAttribute("y", Convert.ToString(D_TIN.DS.maxcic.y)); t0.SetAttribute("layer", SvgDocument.currentLayer); t0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t0.SetAttribute("font-famliy", "宋体"); t0.SetAttribute("font-size", "48"); t0.InnerText = "1号"; tlVectorControl1.SVGDocument.RootElement.AppendChild(t0); PSP_SubstationSelect s = new PSP_SubstationSelect(); s.UID = Guid.NewGuid().ToString(); s.EleID = e0.GetAttribute("id"); s.SName = "1号"; s.Remark = ""; s.col2 = XZ_bdz; s.SvgID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<PSP_SubstationSelect>(s); decimal c = 360 / (Convert.ToInt32(str_num)); for (int k = 2; k <= Convert.ToInt32(str_num); k++) { decimal x = Convert.ToDecimal(D_TIN.DS.maxcic.x + D_TIN.DS.radius * Math.Cos(Convert.ToDouble(c * k) * Math.PI / 180)); decimal y = Convert.ToDecimal(D_TIN.DS.maxcic.y + D_TIN.DS.radius * Math.Sin(Convert.ToDouble(c * k) * Math.PI / 180)); XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement; e1.SetAttribute("x", Convert.ToString(Convert.ToSingle(x) - pf.X)); e1.SetAttribute("y", Convert.ToString(Convert.ToSingle(y) - pf.Y)); e1.SetAttribute("xzflag", "1"); e1.SetAttribute("xlink:href", str_sub); e1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); e1.SetAttribute("layer", SvgDocument.currentLayer); tlVectorControl1.SVGDocument.RootElement.AppendChild(e1); tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e1); //获得此变电站的最小半径的圆 生成辐射线 n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle; n1.SetAttribute("cx", e1.GetAttribute("x").ToString()); n1.SetAttribute("cy", e1.GetAttribute("y").ToString()); n1.SetAttribute("r", (TLMath.getdcNumber(Convert.ToDecimal(str_jj), tlVectorControl1.ScaleRatio)).ToString()); n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;"); sf = new SubandFHcollect(GetsubFhk((Circle)n1, polylist), e1); CreateSubline(sf); // PSP_SubstationSelect s2 = new PSP_SubstationSelect(); s2.UID = Guid.NewGuid().ToString(); s2.EleID = e1.GetAttribute("id"); s2.SName = Convert.ToString((k)) + "号"; s2.Remark = ""; s2.col2 = XZ_bdz; s2.SvgID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<PSP_SubstationSelect>(s2); XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t1.SetAttribute("x", Convert.ToString(x)); t1.SetAttribute("y", Convert.ToString(y)); t1.SetAttribute("layer", SvgDocument.currentLayer); t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t1.SetAttribute("font-famliy", "宋体"); t1.SetAttribute("font-size", "54"); t1.InnerText = Convert.ToString((k)) + "号"; tlVectorControl1.SVGDocument.RootElement.AppendChild(t1); } return; } } if ((Convert.ToInt32(str_num) > 1) && (useList.Count < Convert.ToInt32(str_num) + 2)) { if ((MessageBox.Show("当自动选址变电站个数等于" + str_num + "时,区域内必须至少有" + Convert.ToString(Convert.ToInt32(str_num) + 2) + "座已有变电站,否则无法进行负荷分布自动选址。\r\n 是否进行最小覆盖圆自动选址?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) == DialogResult.Yes) { int n = D_TIN.DS.VerticesNum; D_TIN.DS.set_cnt = D_TIN.DS.VerticesNum; D_TIN.DS.pos_cnt = 0; for (int i = 0; i < n; i++) D_TIN.DS.curset[i] = i; D_TIN.mindisk(); Pen p2 = new Pen(Color.Red, 2); Rectangle rec = new Rectangle((int)(D_TIN.DS.maxcic.x - D_TIN.DS.radius), (int)(D_TIN.DS.maxcic.y - D_TIN.DS.radius), (int)(2 * D_TIN.DS.radius), (int)(2 * D_TIN.DS.radius)); string str_sub = getSubName(str_dy); //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle; //// Point point1 = tlVectorControl1.PointToView(new Point((int)D_TIN.DS.maxcic.x, (int)D_TIN.DS.maxcic.y)); //n1.SetAttribute("cx", D_TIN.DS.maxcic.x.ToString()); //n1.SetAttribute("cy", D_TIN.DS.maxcic.y.ToString()); //n1.SetAttribute("r", D_TIN.DS.radius.ToString()); //n1.SetAttribute("r", D_TIN.DS.radius.ToString()); //n1.SetAttribute("layer", SvgDocument.currentLayer); //n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;"); //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); //str_sub = getSubName(str_dy); PointF pf = getOff(str_dy); XmlElement e0 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement; e0.SetAttribute("x", Convert.ToString(D_TIN.DS.maxcic.x - pf.X)); e0.SetAttribute("y", Convert.ToString(D_TIN.DS.maxcic.y - pf.Y)); e0.SetAttribute("xzflag", "1"); e0.SetAttribute("xlink:href", str_sub); e0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); e0.SetAttribute("layer", SvgDocument.currentLayer); tlVectorControl1.SVGDocument.RootElement.AppendChild(e0); tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e0); //获得此变电站的最小半径的圆 生成辐射线 XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle; n1.SetAttribute("cx", e0.GetAttribute("x").ToString()); n1.SetAttribute("cy", e0.GetAttribute("y").ToString()); n1.SetAttribute("r", (TLMath.getdcNumber(Convert.ToDecimal(str_jj), tlVectorControl1.ScaleRatio)).ToString()); n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;"); SubandFHcollect sf = new SubandFHcollect(GetsubFhk((Circle)n1, polylist), e0); CreateSubline(sf); // XmlElement t0 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t0.SetAttribute("x", Convert.ToString(D_TIN.DS.maxcic.x)); t0.SetAttribute("y", Convert.ToString(D_TIN.DS.maxcic.y)); t0.SetAttribute("layer", SvgDocument.currentLayer); t0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t0.SetAttribute("font-famliy", "宋体"); t0.SetAttribute("font-size", "48"); t0.InnerText = "1号"; tlVectorControl1.SVGDocument.RootElement.AppendChild(t0); PSP_SubstationSelect s = new PSP_SubstationSelect(); s.UID = Guid.NewGuid().ToString(); s.EleID = e0.GetAttribute("id"); s.SName = "1号"; s.Remark = ""; s.col2 = XZ_bdz; s.SvgID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<PSP_SubstationSelect>(s); decimal c = 360 / (Convert.ToInt32(str_num)); for (int k = 2; k <= Convert.ToInt32(str_num); k++) { decimal x = Convert.ToDecimal(D_TIN.DS.maxcic.x + D_TIN.DS.radius * Math.Cos(Convert.ToDouble(c * k) * Math.PI / 180)); decimal y = Convert.ToDecimal(D_TIN.DS.maxcic.y + D_TIN.DS.radius * Math.Sin(Convert.ToDouble(c * k) * Math.PI / 180)); XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement; e1.SetAttribute("x", Convert.ToString(Convert.ToSingle(x) - pf.X)); e1.SetAttribute("y", Convert.ToString(Convert.ToSingle(y) - pf.Y)); e1.SetAttribute("xzflag", "1"); e1.SetAttribute("xlink:href", str_sub); e1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); e1.SetAttribute("layer", SvgDocument.currentLayer); tlVectorControl1.SVGDocument.RootElement.AppendChild(e1); tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e1); //获得此变电站的最小半径的圆 生成辐射线 n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle; n1.SetAttribute("cx", e1.GetAttribute("x").ToString()); n1.SetAttribute("cy", e1.GetAttribute("y").ToString()); n1.SetAttribute("r", (TLMath.getdcNumber(Convert.ToDecimal(str_jj), tlVectorControl1.ScaleRatio)).ToString()); n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;"); sf = new SubandFHcollect(GetsubFhk((Circle)n1, polylist), e1); CreateSubline(sf); // PSP_SubstationSelect s2 = new PSP_SubstationSelect(); s2.UID = Guid.NewGuid().ToString(); s2.EleID = e1.GetAttribute("id"); s2.SName = Convert.ToString((k)) + "号"; s2.Remark = ""; s2.col2 = XZ_bdz; s2.SvgID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<PSP_SubstationSelect>(s2); XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t1.SetAttribute("x", Convert.ToString(x)); t1.SetAttribute("y", Convert.ToString(y)); t1.SetAttribute("layer", SvgDocument.currentLayer); t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t1.SetAttribute("font-famliy", "宋体"); t1.SetAttribute("font-size", "54"); t1.InnerText = Convert.ToString((k)) + "号"; tlVectorControl1.SVGDocument.RootElement.AppendChild(t1); } return; } else { bdz_xz = ""; return; } } if (str_num == "1" && useList.Count < 3) { int n = D_TIN.DS.VerticesNum; D_TIN.DS.set_cnt = D_TIN.DS.VerticesNum; D_TIN.DS.pos_cnt = 0; for (int i = 0; i < n; i++) D_TIN.DS.curset[i] = i; D_TIN.mindisk(); Pen p2 = new Pen(Color.Red, 2); Rectangle rec = new Rectangle((int)(D_TIN.DS.maxcic.x - D_TIN.DS.radius), (int)(D_TIN.DS.maxcic.y - D_TIN.DS.radius), (int)(2 * D_TIN.DS.radius), (int)(2 * D_TIN.DS.radius)); // g.DrawEllipse(p2, rec); //string ele_uid = ""; string str_sub = getSubName(str_dy); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle; // Point point1 = tlVectorControl1.PointToView(new Point((int)D_TIN.DS.maxcic.x, (int)D_TIN.DS.maxcic.y)); n1.SetAttribute("cx", D_TIN.DS.maxcic.x.ToString()); n1.SetAttribute("cy", D_TIN.DS.maxcic.y.ToString()); n1.SetAttribute("r", D_TIN.DS.radius.ToString()); n1.SetAttribute("r", D_TIN.DS.radius.ToString()); n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); PointF pf = getOff(str_dy); XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement; e1.SetAttribute("x", Convert.ToString(D_TIN.DS.maxcic.x - pf.X)); e1.SetAttribute("y", Convert.ToString(D_TIN.DS.maxcic.y - pf.Y)); e1.SetAttribute("xzflag", "1"); e1.SetAttribute("xlink:href", str_sub); e1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); e1.SetAttribute("layer", SvgDocument.currentLayer); tlVectorControl1.SVGDocument.RootElement.AppendChild(e1); tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e1); //获得此变电站的最小半径的圆 生成辐射线 SubandFHcollect sf = new SubandFHcollect(GetsubFhk((Circle)n1, polylist), e1); CreateSubline(sf); // PSP_SubstationSelect s2 = new PSP_SubstationSelect(); s2.UID = Guid.NewGuid().ToString(); s2.EleID = e1.GetAttribute("id"); s2.SName = "1号"; s2.Remark = ""; s2.col2 = XZ_bdz; s2.SvgID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<PSP_SubstationSelect>(s2); tlVectorControl1.Refresh(); // Thread.Sleep(3); tlVectorControl1.SVGDocument.RootElement.RemoveChild(n1); XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t1.SetAttribute("x", Convert.ToString(D_TIN.DS.maxcic.x)); t1.SetAttribute("y", Convert.ToString(D_TIN.DS.maxcic.y)); t1.SetAttribute("layer", SvgDocument.currentLayer); t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t1.SetAttribute("font-famliy", "宋体"); t1.SetAttribute("font-size", "54"); t1.InnerText = "1号"; tlVectorControl1.SVGDocument.RootElement.AppendChild(t1); bdz_xz = ""; return; } else { // ShowTriangle(polylist, poly1); //王哥写的 ShowTriangle1(polylist, poly1); bdz_xz = ""; return; } } else { bdz_xz = ""; return; } } if (tlVectorControl1.Operation == ToolOperation.InterEnclosure && !SubPrint) { System.Collections.SortedList list = new SortedList(); decimal s = 0; ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection; if (selCol.Count > 1) { decimal ViewScale = 1; string str_Scale = Convert.ToString(tlVectorControl1.ScaleRatio);//SVGDocument.getViewScale(); if (str_Scale != "") { ViewScale = Convert.ToDecimal(str_Scale); } string str_remark = ""; string str_selArea = ""; //string Elements = ""; Hashtable SelAreaCol = new Hashtable(); this.Cursor = Cursors.WaitCursor; int t = 0; Lab001: t = t + 1; XmlElement poly1 = (XmlElement)selCol[selCol.Count - t]; if (poly1.GetType().FullName != "ItopVector.Core.Figure.Polygon") { // selCol.Remove(selCol[selCol.Count-1]); goto Lab001; } frmWaiting wait = new frmWaiting(); wait.Show(this); wait.Refresh(); GraphicsPath gr1 = new GraphicsPath(); //gr1.AddRectangle(TLMath.getRectangle(poly1)); gr1.AddPolygon(TLMath.getPolygonPoints(poly1)); gr1.CloseFigure(); for (int i = 0; i < selCol.Count - 1; i++) { if (selCol[i].GetType().FullName == "ItopVector.Core.Figure.Polygon") { string IsArea = ((XmlElement)selCol[i]).GetAttribute("IsArea"); if (IsArea != "") { XmlElement polyn = (XmlElement)selCol[i]; GraphicsPath gr2 = new GraphicsPath(); //gr2.AddRectangle(TLMath.getRectangle(polyn)); gr2.AddPolygon(TLMath.getPolygonPoints(polyn)); gr2.CloseFigure(); Region region = new Region(gr1); region.Intersect(gr2); RectangleF rect = new RectangleF(); rect = tlVectorControl1.SelectedRectangle(region); decimal sub_s = TLMath.getInterPolygonArea(region, rect, 1); sub_s = TLMath.getNumber2(sub_s, tlVectorControl1.ScaleRatio) / Convert.ToDecimal(areaoption); SelAreaCol.Add(polyn.GetAttribute("id"), sub_s); glebeProperty _gleProp = new glebeProperty(); _gleProp.EleID = polyn.GetAttribute("id"); _gleProp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList gList = Services.BaseService.GetList("SelectglebePropertyByEleID", _gleProp); if (gList.Count > 0) { _gleProp = (glebeProperty)gList[0]; list.Add(_gleProp.UseID, sub_s.ToString("#####.####")); str_selArea = str_selArea + _gleProp.EleID + "," + sub_s.ToString("#####.####") + ";"; //str_remark = str_remark + "地块" + _gleProp.UseID + "选中面积为:" + sub_s.ToString() + "\r\n"; s += sub_s; } } } if (selCol[i].GetType().FullName == "ItopVector.Core.Figure.Use") { XmlElement e1 = (XmlElement)selCol[i]; string str_id = e1.GetAttribute("id"); // PSP_Substation_Info _sub1 = new PSP_Substation_Info(); //// substation _sub1 = new substation(); // _sub1.EleID = str_id; // _sub1.AreaID = tlVectorControl1.SVGDocument.SvgdataUid; // _sub1 = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoListByEleID", _sub1); // if (_sub1 != null) // { // _sub1.glebeEleID = guid; // Services.BaseService.Update<PSP_Substation_Info>( _sub1); // } } } decimal nullpoly = TLMath.getNumber2(TLMath.getPolygonArea(TLMath.getPolygonPoints(poly1), 1), tlVectorControl1.ScaleRatio) / Convert.ToDecimal(areaoption) - s; for (int j = 0; j < list.Count; j++) { if (Convert.ToString(list.GetByIndex(j)) != "") { if (Convert.ToDecimal(list.GetByIndex(j)) < 1) { str_remark = str_remark + "地块" + list.GetKey(j).ToString() + "选中面积为:" + "0" + list.GetByIndex(j).ToString() + "(KM²)\r\n"; } else { str_remark = str_remark + "地块" + list.GetKey(j).ToString() + "选中面积为:" + list.GetByIndex(j).ToString() + "(KM²)\r\n"; } } } XmlElement x1 = poly1;// (XmlElement)selCol[selCol.Count - 1]; gPro.UID = guid; gPro.EleID = x1.GetAttribute("id"); gPro.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; gPro.ParentEleID = "0"; if (s != 0) { gPro.Area = Convert.ToDecimal(s.ToString("#####.####")); } else { gPro.Area = 0; } gPro.SelSonArea = str_selArea; if (nullpoly < 1) { gPro.ObligateField10 = "0" + nullpoly.ToString("#####.####"); } else { gPro.ObligateField10 = nullpoly.ToString("#####.####"); } str_remark = str_remark + "\r\n 空白区域面积" + gPro.ObligateField10 + "(KM²)\r\n"; if (str_remark != "") { str_remark = str_remark.Substring(0, str_remark.Length - 2); } gPro.Remark = str_remark; wait.Close(); this.Cursor = Cursors.Default; if (s < 1) { MessageBox.Show("选中区域面积:" + "0" + s.ToString("#####.####") + "(KM²)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("选中区域面积:" + s.ToString("#####.####") + "(KM²)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } Services.BaseService.Create<glebeProperty>(gPro); IDictionaryEnumerator ISelList = SelAreaCol.GetEnumerator(); while (ISelList.MoveNext()) { glebeProperty sub_gle = new glebeProperty(); sub_gle.EleID = ISelList.Key.ToString(); sub_gle.ParentEleID = gPro.EleID; sub_gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Update("UpdateglebePropertySelArea", sub_gle); } tlVectorControl1.SVGDocument.SelectCollection.Clear(); tlVectorControl1.SVGDocument.CurrentElement = (SvgElement)x1; } SubPrint = false; } if (tlVectorControl1.CurrentOperation == ToolOperation.InterEnclosure && SubPrint) { //ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection; //if(selCol.Count>2){ // XmlElement selArea = (SvgElement)selCol[selCol.Count - 1]; // GraphicsPath gr1 = new GraphicsPath(); // gr1.AddPolygon(TLMath.getPolygonPoints(selArea)); // gr1.CloseFigure(); // RectangleF rect= gr1.GetBounds(); // SvgDocument _doc = new SvgDocument(); // string svgtxt = "<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\""+rect.Width+"\" height=\""+rect.Height+"\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">"; // for (int n = 0; n < selCol.Count-1;n++ ) // { // //_doc.AppendChild((XmlNode)selCol[n]); // svgtxt=svgtxt+((XmlElement)selCol[n]).OuterXml+"\r\n"; // } // svgtxt = svgtxt + "</svg>"; // _doc.LoadXml(svgtxt); // frmSubPrint s = new frmSubPrint(); // s.Show(); // s.Open(_doc, rect); ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection; XmlElement x1 = (XmlElement)selCol[selCol.Count - 1]; tlVectorControl1.SVGDocument.SelectCollection.Clear(); tlVectorControl1.SVGDocument.CurrentElement = (SvgElement)x1; SubPrint = false; //} } if (tlVectorControl1.Operation == ToolOperation.Enclosure) { string Elements = ""; ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection; for (int i = 0; i < selCol.Count - 1; i++) { XmlElement e1 = (XmlElement)selCol[i]; Elements = Elements + "'" + e1.GetAttribute("id") + "',"; } if (Elements.Length > 0) { Elements = Elements.Substring(0, Elements.Length - 1); } XmlElement x1 = (XmlElement)selCol[selCol.Count - 1]; gPro.UID = Guid.NewGuid().ToString(); gPro.EleID = x1.GetAttribute("id"); gPro.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; gPro.SonUid = Elements; Services.BaseService.Create<glebeProperty>(gPro); tlVectorControl1.SVGDocument.SelectCollection.Clear(); tlVectorControl1.SVGDocument.CurrentElement = (SvgElement)x1; } if (tlVectorControl1.CurrentOperation == ToolOperation.LeadLine) { sgt1.Visible = false; } } } catch (Exception e1) { MessageBox.Show(e1.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.SVGDocument.SelectCollection.Clear(); } finally { tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.FreeTransform; } }
private void CreateSubline(SubandFHcollect _subandfh, bool flag) { XmlElement sub = _subandfh.Sub; foreach (KeyValuePair<XmlElement, PointF> kv in _subandfh.FHcollect) { XmlElement _x = kv.Key; //if (!flag) //{ // if (_x.GetAttribute("xz")=="1") // { // return; // } //} PointF pf = kv.Value; PointF _f = TLMath.polyCentriod(_x); XmlNode xnode = tlVectorControl1.SVGDocument.SelectSingleNode("svg/polyline[@xz='1' and FirstNode='" + sub.GetAttribute("id").ToString() + "'and LastNode='" + _x.GetAttribute("id").ToString() + "']"); if (xnode != null) { tlVectorControl1.SVGDocument.RootElement.RemoveChild(xnode); } string temp = ""; if (!flag) { temp = sub.GetAttribute("cx").ToString() + " " + sub.GetAttribute("cy").ToString() + "," + _f.X.ToString() + " " + _f.Y.ToString(); } else temp = sub.GetAttribute("x").ToString() + " " + sub.GetAttribute("y").ToString() + "," + _f.X.ToString() + " " + _f.Y.ToString(); glebeProperty pl = new glebeProperty(); pl.EleID = _x.GetAttribute("id"); pl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; pl = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", pl); if (pl != null) { string sname = sub.GetAttribute("subname"); if (!string.IsNullOrEmpty(sname)) { if (_x.GetAttribute("xz") == "0") { pl.ObligateField7 = sname; Services.BaseService.Update<glebeProperty>(pl); } } } XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; n1.SetAttribute("points", temp); //如果是规划 if (flag) { _x.SetAttribute("xz", "1"); n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#990033;stroke-opacity:1;"); } else { if (_x.GetAttribute("xz") != "1") { _x.SetAttribute("xz", "0"); } n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#330099;stroke-opacity:1;"); } n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("IsLead", "1"); n1.SetAttribute("FirstNode", sub.GetAttribute("id").ToString()); n1.SetAttribute("LastNode", _x.GetAttribute("id").ToString()); n1.SetAttribute("xz", "1"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)n1); } // XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement; // e1.SetAttribute("x", Convert.ToString(X)); // e1.SetAttribute("y", Convert.ToString(Y)); // e1.SetAttribute("xlink:href", str_sub); // e1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); // e1.SetAttribute("layer", SvgDocument.currentLayer); // SubandFHcollect _subandfh = new SubandFHcollect(FHandPointF, e1); // tlVectorControl1.SVGDocument.RootElement.AppendChild(e1); // tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e1); }
public void OpenGHQYpropetty(string areatitle) { glebeProperty gp = new glebeProperty(); gp.ParentEleID = "0"; gp.SvgUID = "c5ec3bc7-9706-4cbd-9b8b-632d3606f933"; gp.ObligateField16 = areatitle; IList<glebeProperty> svglist = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByObligateField16", gp); if (svglist.Count > 0) { XmlElement temp = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + svglist[0].EleID + "']") as XmlElement; Layer lar = getlayer1(temp.GetAttribute("layer"), "电网规划层", tlVectorControl1.SVGDocument.getLayerList()); if (lar != null) { SvgDocument.currentLayer = lar.ID; lar.Visible = true; tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)temp); #region //显示属性数据 XmlNodeList n1 = tlVectorControl1.SVGDocument.GetElementsByTagName("use"); PointF[] tfArray1 = TLMath.getPolygonPoints(temp); string str220 = ""; string str110 = ""; string str66 = ""; string str_id = ""; GraphicsPath selectAreaPath = new GraphicsPath(); selectAreaPath.AddLines(tfArray1); selectAreaPath.CloseFigure(); //Matrix x=new Matrix( //Region region1 = new Region(selectAreaPath); for (int i = 0; i < n1.Count; i++) { float OffX = 0f; float OffY = 0f; bool ck = false; Use use = (Use)n1[i]; if (use.GetAttribute("xlink:href").Contains("byq") || use.GetAttribute("xlink:href").Contains("pds")) { if (selectAreaPath.IsVisible(use.CenterPoint)) { if (use.GetAttribute("Deviceid") != "") { str_id = str_id + "'" + use.GetAttribute("Deviceid") + "',"; } } } if (use.GetAttribute("xlink:href").Contains("Substation")) { //string strMatrix = use.GetAttribute("transform"); //if (strMatrix != "") //{ // strMatrix = strMatrix.Replace("matrix(", ""); // strMatrix = strMatrix.Replace(")", ""); // string[] mat = strMatrix.Split(','); // if (mat.Length > 5) // { // OffX = Convert.ToSingle(mat[4]); // OffY = Convert.ToSingle(mat[5]); // } //} if (frmlar.getSelectedLayer().Contains(use.GetAttribute("layer"))) { ck = true; } PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href")); //if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY) && ck) if (selectAreaPath.IsVisible(use.CenterPoint) && ck) { if (use.GetAttribute("xlink:href").Contains("220")) { str220 = str220 + "'" + use.GetAttribute("Deviceid") + "',"; } if (use.GetAttribute("xlink:href").Contains("110")) { str110 = str110 + "'" + use.GetAttribute("Deviceid") + "',"; } if (use.GetAttribute("xlink:href").Contains("66")) { str66 = str66 + "'" + use.GetAttribute("Deviceid") + "',"; } } } } if (str220.Length > 1) { str220 = str220.Substring(0, str220.Length - 1); } if (str110.Length > 1) { str110 = str110.Substring(0, str110.Length - 1); } if (str66.Length > 1) { str66 = str66.Substring(0, str66.Length - 1); } if (str_id.Length > 1) { str_id = str_id.Substring(0, str_id.Length - 1); } glebeProperty _gle = new glebeProperty(); _gle.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID; _gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle); if (UseProList.Count > 0) { _gle = UseProList[0]; _gle.LayerID = SvgDocument.currentLayer; frmMainProperty f = new frmMainProperty(); f.strID = str_id; f.InitData(_gle, str220, str110, str66); PointF[] pn = (PointF[])((Polygon)temp).Points.Clone(); ((Polygon)temp).Transform.Matrix.TransformPoints(pn); string s1 = ""; for (int p = 0; p < pn.Length; p++) { s1 = s1 + pn[p].X.ToString() + " " + pn[p].Y.ToString() + ","; } f.Str = s1; f.ShowDialog(); if (f.checkBox1.Checked == false) { tlVectorControl1.SVGDocument.RootElement.RemoveChild(tlVectorControl1.SVGDocument.CurrentElement); } if (f.DialogResult == DialogResult.OK) { //this.Close(); frmlar.Visible = false; this.Visible = false; this.DialogResult = DialogResult.OK; } else if (f.DialogResult == DialogResult.Cancel) { frmlar.Visible = false; ; this.Visible = false; this.DialogResult = DialogResult.OK; } //tlVectorControl1.Refresh(); } else { _gle = new glebeProperty(); _gle.LayerID = SvgDocument.currentLayer; frmMainProperty f = new frmMainProperty(); f.strID = str_id; f.InitData(_gle, str220, str110, str66); PointF[] pn = (PointF[])((Polygon)temp).Points.Clone(); ((Polygon)temp).Transform.Matrix.TransformPoints(pn); string s1 = ""; for (int p = 0; p < pn.Length; p++) { s1 = s1 + pn[p].X.ToString() + " " + pn[p].Y.ToString() + ","; } f.Str = s1; f.ShowDialog(); if (f.DialogResult == DialogResult.OK) { frmlar.Visible = false; ; this.Visible = false; this.DialogResult = DialogResult.OK; } else if (f.DialogResult == DialogResult.Cancel) { frmlar.Visible = false; ; this.Visible = false; this.DialogResult = DialogResult.OK; } } //} } #endregion else { MessageBox.Show("没有找到对应的图层,请检查数据后再进行此操作!"); } } }
//flag 为false时为已有变电站 //flag为ture时变电站为规划的 private void CreateSubline1(SubandFHcollect _subandfh, bool flag, Layer lay) { XmlElement sub = _subandfh.Sub; double subrl = 0; double yfcrl = 0; if (!string.IsNullOrEmpty(sub.GetAttribute("rl"))) { subrl = Convert.ToDouble(sub.GetAttribute("rl")); } double sumrl = 0; string fhdk = ""; foreach (KeyValuePair<XmlElement, PointF> kv in _subandfh.FHcollect) { XmlElement _x = kv.Key; PointF pf = kv.Value; PointF _f = TLMath.polyCentriod(_x); //XmlNode xnode = tlVectorControl1.SVGDocument.SelectSingleNode("svg/polyline[@layer='" + lay.ID + "'and @FirstNode='" + sub.GetAttribute("id").ToString() + "'and @LastNode='" + _x.GetAttribute("id").ToString() + "']"); //if (xnode != null) { // tlVectorControl1.SVGDocument.RootElement.RemoveChild(xnode); //} XmlNodeList nodelist = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline[@layer='" + lay.ID + "'and @xz='1']"); foreach(XmlNode xnode in nodelist) { tlVectorControl1.SVGDocument.RootElement.RemoveChild(xnode); } glebeProperty pl = new glebeProperty(); pl.EleID = _x.GetAttribute("id"); pl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; pl = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", pl); double dkrl = 0; string ygdflag = "0"; //0表示还没有供电,1表示完全有已知的变电站供,2表示部分符合已有供并且写上变电站供给了多少 if (!string.IsNullOrEmpty(_x.GetAttribute("ygdflag"))) { ygdflag = _x.GetAttribute("ygdflag"); } if (!string.IsNullOrEmpty(_x.GetAttribute("Burthen"))) { dkrl = Convert.ToDouble(_x.GetAttribute("Burthen")) * dbl_rzb; } //查找此地块离所有变电站中是否离此变电站最近 //地块负荷供应情况 string bdzandlenth= _x.GetAttribute("bdzandlenth"); string[] dkqk=null; int minnumber = 0; if (!string.IsNullOrEmpty(bdzandlenth)) { double minlenth = 1000000; dkqk = (bdzandlenth.Substring(0, bdzandlenth.LastIndexOf(";"))).Split(';'); for (int j = 0; j < dkqk.Length; j++) { string[] dk = dkqk[j].Split(','); if (Convert.ToDouble(dk[1])<minlenth) { minlenth = Convert.ToDouble(dk[1]); minnumber = j; } } if (!dkqk[minnumber].Contains(sub.GetAttribute("subname"))) { continue; } } // sumrl += dkrl; //改进后的不能有部分剩余了 能供则供 不能供则选择其他的变电站来供 if (ygdflag == "0") //说明还没有供给的 { if (subrl * 1.5 >= sumrl) { fhdk += _x.GetAttribute("id") + "," + dkrl.ToString() + ";"; _x.SetAttribute("ygdflag", "1"); yfcrl = sumrl; } else { //去掉此地块的信息 在其他变电站重新寻找供给 bdzandlenth = ""; for (int j = 0; j < dkqk.Length; j++) { if (j!=minnumber) { bdzandlenth += dkqk[j] + ";"; } } _x.SetAttribute("bdzandlenth",bdzandlenth); continue; } //else if (subrl * 1.5< sumrl && subrl >= (sumrl - dkrl)) { // double gyrl = ((subrl * 1.5 + dkrl) - sumrl); // double syrl = sumrl - subrl * 1.5; // fhdk += _x.GetAttribute("id") + "," + gyrl.ToString() + ";"; // _x.SetAttribute("ygdflag", "2"); // _x.SetAttribute("syrl", syrl.ToString()); // yfcrl = subrl * 1.5; //} } //else if (ygdflag == "2") //有一部分剩余的还需要来供 //{ // double syrl = 0; // if (!string.IsNullOrEmpty(_x.GetAttribute("syrl"))) { // syrl = Convert.ToDouble(_x.GetAttribute("syrl")); // } // if ((subrl * 1.5- yfcrl) > syrl) { // fhdk += _x.GetAttribute("id") + "," + syrl.ToString() + ";"; // _x.SetAttribute("ygdflag", "1"); // _x.SetAttribute("syrl", "0"); // yfcrl = sumrl; // } else { // syrl = syrl - (subrl * 1.5 - yfcrl); // fhdk += _x.GetAttribute("id") + "," + (subrl * 1.5 - yfcrl).ToString() + ";"; // _x.SetAttribute("ygdflag", "2"); // _x.SetAttribute("syrl", syrl.ToString()); // yfcrl = subrl * 1.5; // } //} else if (ygdflag == "1") //已经有供应的了 { continue; } if (pl != null) { string sname = sub.GetAttribute("subname"); if (!string.IsNullOrEmpty(sname)) { //if (_x.GetAttribute("xz") == "0") //{ // pl.ObligateField7 = sname; // Services.BaseService.Update<glebeProperty>(pl); //} if (sname.Contains("号")) //为规划的变电站 自动为true { flag = true; } if (string.IsNullOrEmpty(pl.ObligateField7)) { pl.ObligateField7 = sname; } else { if (!pl.ObligateField7.Contains(sname)) { pl.ObligateField7 += "," + sname; } } Services.BaseService.Update<glebeProperty>(pl); } } //if (!flag) //{ // if (_x.GetAttribute("xz")=="1") // { // return; // } //} string temp = ""; if (!flag) { temp = sub.GetAttribute("cx").ToString() + " " + sub.GetAttribute("cy").ToString() + "," + _f.X.ToString() + " " + _f.Y.ToString(); } else temp = sub.GetAttribute("x").ToString() + " " + sub.GetAttribute("y").ToString() + "," + _f.X.ToString() + " " + _f.Y.ToString(); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; n1.SetAttribute("points", temp); //如果是规划 if (flag) { _x.SetAttribute("xz", "1"); n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#990033;stroke-opacity:1;"); } else { if (_x.GetAttribute("xz") != "1") { _x.SetAttribute("xz", "0"); } n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#330099;stroke-opacity:1;"); } n1.SetAttribute("layer", lay.ID); n1.SetAttribute("IsLead", "1"); n1.SetAttribute("FirstNode", sub.GetAttribute("id").ToString()); n1.SetAttribute("LastNode", _x.GetAttribute("id").ToString()); n1.SetAttribute("xz", "1"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)n1); } sub.SetAttribute("fhdk", fhdk); if (yfcrl != 0) { sub.SetAttribute("yfcrzb", (subrl / ((yfcrl / dbl_rzb))).ToString()); } else { sub.SetAttribute("yfcrzb", (dbl_rzb).ToString()); } }
private string GetSpatiallayerid() { string layerid = " or SUID in ("; glebeProperty gp = new glebeProperty(); gp.ParentEleID = "0"; gp.SvgUID = "c5ec3bc7-9706-4cbd-9b8b-632d3606f933"; IList<glebeProperty> svglist = Services.BaseService.GetList<glebeProperty>("SelectglebePropertParentIDTopAll", gp); StringBuilder st = new StringBuilder(); int i = 0; int max = 0; foreach (glebeProperty gpr in svglist) { if (!string.IsNullOrEmpty(gpr.LayerID)) { st.Append("'" + gpr.LayerID + "',"); max=i; } if (i == svglist.Count - 1) { st.Append("'" + svglist[max].LayerID + "')"); } i++; } if (max!=0) { return layerid += st.ToString(); } return ""; }
private void Extbdzreport(ArrayList extsublist1) { ExcelAccess ex = new ExcelAccess(); try { string fname = Application.StartupPath + "\\xls\\tempt.xls"; ex.Open(fname); //ex.ActiveSheet(1); ex.SetCellValue("变电站名称", 1, 1); ex.SetCellValue("容量", 1, 2); ex.SetCellValue("容载比", 1, 3); ex.AlignmentCells(1, 1, 1, 3, ExcelStyle.ExcelHAlign.居中, ExcelStyle.ExcelVAlign.居中); ex.SetFontStyle(1, 1, 1, 3, true, false, ExcelStyle.UnderlineStyle.无下划线); ex.CellsBackColor(1, 1, 1, 3, ExcelStyle.ColorIndex.黄色); //输出地块负荷情况 ex.SetCellValue("变电站供应负荷情况", 3 + extsublist1.Count, 1); ex.UnitCells(3 + extsublist.Count, 1, 3 + extsublist1.Count, 3); ex.SetCellValue("变电站名称", 4 + extsublist1.Count, 1); ex.SetCellValue("地块编号", 4 + extsublist1.Count, 2); ex.SetCellValue("供应负荷", 4 + extsublist1.Count, 3); ex.AlignmentCells(3 + extsublist1.Count, 1, 4 + extsublist.Count, 3, ExcelStyle.ExcelHAlign.居中, ExcelStyle.ExcelVAlign.居中); ex.SetFontStyle(3 + extsublist1.Count, 1, 4 + extsublist.Count, 3, true, false, ExcelStyle.UnderlineStyle.无下划线); ex.CellsBackColor(3 + extsublist1.Count, 1, 4 + extsublist.Count, 3, ExcelStyle.ColorIndex.黄色); int rowcount = 0; for (int i = 0; i < extsublist1.Count; i++) { XmlElement xe = extsublist1[i] as XmlElement; if (!string.IsNullOrEmpty(xe.GetAttribute("subname"))) { ex.SetCellValue(xe.GetAttribute("subname"), 2 + i, 1); ex.AlignmentCells(2 + i, 1, 2 + i, 1, ExcelStyle.ExcelHAlign.居中, ExcelStyle.ExcelVAlign.居中); ex.SetFontStyle(2 + i, 1, 2 + i, 1, true, false, ExcelStyle.UnderlineStyle.无下划线); ex.CellsBackColor(2 + i, 1, 2 + i, 1, ExcelStyle.ColorIndex.绿色); } if (!string.IsNullOrEmpty(xe.GetAttribute("rl"))) { ex.SetCellValue(xe.GetAttribute("rl"), 2 + i, 2); ex.AlignmentCells(2 + i, 2, 2 + i, 2, ExcelStyle.ExcelHAlign.居中, ExcelStyle.ExcelVAlign.居中); ex.SetFontStyle(2 + i, 2, 2 + i, 2, true, false, ExcelStyle.UnderlineStyle.无下划线); } if (!string.IsNullOrEmpty(xe.GetAttribute("yfcrzb"))) { ex.SetCellValue(xe.GetAttribute("yfcrzb"), 2 + i, 3); ex.AlignmentCells(2 + i, 3, 2 + i, 3, ExcelStyle.ExcelHAlign.居中, ExcelStyle.ExcelVAlign.居中); ex.SetFontStyle(2 + i, 3, 2 + i, 3, true, false, ExcelStyle.UnderlineStyle.无下划线); } //地块负荷供应情况 string fhdk = xe.GetAttribute("fhdk"); if (!string.IsNullOrEmpty(fhdk)) { string[] dkqk = (fhdk.Substring(0, fhdk.LastIndexOf(";"))).Split(';'); for (int j = 0; j < dkqk.Length; j++) { string[] dk = dkqk[j].Split(','); if (!string.IsNullOrEmpty(xe.GetAttribute("subname"))) { ex.SetCellValue(xe.GetAttribute("subname"), 5 + extsublist1.Count + rowcount, 1); ex.AlignmentCells(5 + extsublist1.Count + rowcount, 1, 5 + extsublist1.Count + rowcount, 1, ExcelStyle.ExcelHAlign.居中, ExcelStyle.ExcelVAlign.居中); ex.SetFontStyle(5 + extsublist1.Count + rowcount, 1, 5 + extsublist1.Count + rowcount, 1, true, false, ExcelStyle.UnderlineStyle.无下划线); ex.CellsBackColor(5 + extsublist1.Count + rowcount, 1, 5 + extsublist1.Count + rowcount, 1, ExcelStyle.ColorIndex.绿色); } if (dk.Length > 0) { glebeProperty pl = new glebeProperty(); pl.EleID = dk[0]; pl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; pl = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", pl); ex.SetCellValue(pl.UseID, 5 + extsublist1.Count + rowcount, 2); ex.SetCellValue((Convert.ToDouble(dk[1]) / dbl_rzb).ToString("N2"), 5 + extsublist1.Count + rowcount, 3); ex.AlignmentCells(5 + extsublist1.Count + rowcount, 2, 5 + extsublist1.Count + rowcount, 3, ExcelStyle.ExcelHAlign.居中, ExcelStyle.ExcelVAlign.居中); ex.SetFontStyle(5 + extsublist1.Count + rowcount, 2, 5 + extsublist1.Count + rowcount, 3, true, false, ExcelStyle.UnderlineStyle.无下划线); } rowcount++; } } } ex.ShowExcel(); } catch (System.Exception e) { ex.DisPoseExcel(); } }
/*public void ResetPoly() { SvgElementCollection col= tlVectorControl1.SVGDocument.SelectCollection; if(col.Count<1){ return; } SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator(); foreach(SvgElement ele in col){ if (ele.GetType().ToString() == "ItopVector.Core.Figure.Polygon") { glebeProperty p=new glebeProperty(); p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; p.EleID = ((IGraph)ele).ID; p = Services.BaseService.GetObject("SelectglebePropertyByEleID", p); if(p!=null){ PointF[] tfArray1 = TLMath.getPolygonPoints(ele); GraphicsPath selectAreaPath = new GraphicsPath(); selectAreaPath.AddLines(tfArray1); selectAreaPath.CloseFigure(); Region region1 = new Region(selectAreaPath); while (enumerator1.MoveNext()) { IGraph graph1 = (IGraph)enumerator1.Current; GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone(); path1.Transform(graph1.GraphTransform.Matrix); Region region2 = new Region(path1); region2.Intersect(region1); if (!region2.GetBounds(Graphics.FromHwnd(IntPtr.Zero)).IsEmpty) { glebeProperty p1 = new glebeProperty(); p1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; p1.EleID = graph1.ID; p1 = Services.BaseService.GetObject("SelectglebePropertyByEleID", p1); if(p1!=null){ p1.ParentEleID = p.UID; Services.BaseService.Update("UpdateglebePropertyAreaAll", p1); } } } } } } MessageBox.Show("更新完成。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information); }*/ private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { try { if (e.ClickedItem.Text == "属性") { XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement; //PointF[] pf = TLMath.getPolygonPoints(xml1); //((Polygon)xml1).Transform.Matrix.TransformPoints(pf); // 规划 if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) { if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请先选择规划区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") { //frmImgManager frm = new frmImgManager(); //frm.Show(); } if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") { XmlNodeList n1 = tlVectorControl1.SVGDocument.GetElementsByTagName("use"); PointF[] tfArray1 = TLMath.getPolygonPoints(xml1); string str220 = ""; string str110 = ""; string str66 = ""; GraphicsPath selectAreaPath = new GraphicsPath(); selectAreaPath.AddLines(tfArray1); selectAreaPath.CloseFigure(); //Matrix x=new Matrix( //Region region1 = new Region(selectAreaPath); for (int i = 0; i < n1.Count; i++) { float OffX = 0f; float OffY = 0f; bool ck = false; Use use = (Use)n1[i]; if (use.GetAttribute("xlink:href").Contains("Substation")) { string strMatrix = use.GetAttribute("transform"); if (strMatrix != "") { strMatrix = strMatrix.Replace("matrix(", ""); strMatrix = strMatrix.Replace(")", ""); string[] mat = strMatrix.Split(','); if (mat.Length > 5) { OffX = Convert.ToSingle(mat[4]); OffY = Convert.ToSingle(mat[5]); } } if (frmlar.getSelectedLayer().Contains(use.GetAttribute("layer"))) { ck = true; } PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href")); if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY) && ck) { if (use.GetAttribute("xlink:href").Contains("220")) { str220 = str220 + "'" + use.GetAttribute("id") + "',"; } if (use.GetAttribute("xlink:href").Contains("110")) { str110 = str110 + "'" + use.GetAttribute("id") + "',"; } if (use.GetAttribute("xlink:href").Contains("66")) { str66 = str66 + "'" + use.GetAttribute("id") + "',"; } } } } if (str220.Length > 1) { str220 = str220.Substring(0, str220.Length - 1); } if (str110.Length > 1) { str110 = str110.Substring(0, str110.Length - 1); } if (str66.Length > 1) { str66 = str66.Substring(0, str66.Length - 1); } glebeProperty _gle = new glebeProperty(); _gle.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID; _gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle); if (UseProList.Count > 0) { _gle = UseProList[0]; _gle.LayerID = SvgDocument.currentLayer; frmMainProperty f = new frmMainProperty(); f.InitData(_gle, str220, str110, str66); f.ShowDialog(); if (f.checkBox1.Checked == false) { tlVectorControl1.SVGDocument.RootElement.RemoveChild(tlVectorControl1.SVGDocument.CurrentElement); } //tlVectorControl1.Refresh(); } //} } } if (getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())) { if (tlVectorControl1.SVGDocument.getRZBRatio() != "") { rzb = tlVectorControl1.SVGDocument.getRZBRatio(); } if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请先选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") { string IsArea = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsArea"); if (IsArea != "") { frmProperty f = new frmProperty(); if (SelUseArea == "") { SelUseArea = "0"; } f.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer); //f.ShowDialog(); if (progtype != "城市规划层") { f.IsReadonly = true; } if (f.ShowDialog() == DialogResult.OK) { SVG_ENTITY ent = new SVG_ENTITY(); if (f.IsCreate) { ent.SUID = Guid.NewGuid().ToString(); ent.EleID = f.gPro.EleID; ent.layerID = f.gPro.LayerID; ent.MDATE = System.DateTime.Now; ent.NAME = f.gPro.UseID; ent.svgID = f.gPro.SvgUID; ent.TYPE = "polygon-dk"; //ent.voltage = f.gPro.Voltage; Services.BaseService.Create<SVG_ENTITY>(ent); } else { ent.NAME = f.gPro.UseID; ent.layerID = f.gPro.LayerID; ent.MDATE = System.DateTime.Now; //ent.voltage = fl.Line.Voltage; Services.BaseService.Update<SVG_ENTITY>(ent); } if (f.gPro.ObligateField1 != "") { string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(f.gPro.ObligateField1))); color1 = "fill:" + color1 + ";"; ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", color1); tlVectorControl1.UpdateProperty(); } } } } } if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") { string lineWidth = "2"; string IsLead = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsLead"); //if (IsLead != "") //原先导线的属性添加情况 //{ // frmLineProperty fl = new frmLineProperty(); // fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement; // fl.InitData(tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, LineLen, SvgDocument.currentLayer); // if (fl.ShowDialog() == DialogResult.OK) // { // SVG_ENTITY ent = new SVG_ENTITY(); // if (fl.IsCreate) // { // ent.SUID = Guid.NewGuid().ToString(); // ent.EleID = fl.Line.EleID; // ent.layerID = fl.Line.LayerID; // ent.MDATE = System.DateTime.Now; // ent.NAME = fl.Line.LineName; // ent.svgID = fl.Line.SvgUID; // ent.TYPE = "line"; // ent.voltage =Convert.ToInt32(fl.Line.Voltage); // Services.BaseService.Create<SVG_ENTITY>(ent); // } // else // { // ent.NAME = fl.Line.LineName; // ent.layerID = fl.Line.LayerID; // ent.MDATE = System.DateTime.Now; // ent.voltage =Convert.ToInt32( fl.Line.Voltage); // Services.BaseService.Update<SVG_ENTITY>(ent); // } // lineWidth = fl.LineWidth; // string styleValue = ""; // if (fl.Line.ObligateField1 == "规划") // { // styleValue = "stroke-dasharray:" + ghType + ";stroke-width:" + lineWidth + ";"; // } // else // { // styleValue = "stroke-width:" + lineWidth + ";"; // } // //string aa= ColorTranslator.ToHtml(Color.Black); // styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2))); // SvgElement se = tlVectorControl1.SVGDocument.CurrentElement; // se.RemoveAttribute("style"); // se.SetAttribute("style", styleValue); // se.SetAttribute("info-name", fl.Line.LineName); // } //} if (IsLead != "") //修改后的导线的属性添加情况 { PSPDEV obj = new PSPDEV(); string deviceid = xml1.GetAttribute("Deviceid"); if (string.IsNullOrEmpty(deviceid)) { obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.XL, Itop.Client.MIS.ProgUID); if (obj==null) { tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement; tlVectorControl1.Delete(); } if ( obj is PSPDEV) { deviceid = ((PSPDEV)obj).SUID; xml1.SetAttribute("Deviceid", deviceid); } } if (!string.IsNullOrEmpty(deviceid)) { obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid); if (obj != null) { xml1.SetAttribute("info-name", ((PSPDEV)obj).Name); DeviceHelper.ShowDeviceDlg(DeviceType.XL, deviceid, false); } LineInfo li = new LineInfo(); li.UID = obj.SUID; li = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByKey", li); if (li != null) { li.LayerID = SvgDocument.currentLayer; li.EleID = xml1.GetAttribute("id"); li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; LineType lt = new LineType(); lt.TypeName = li.Voltage.ToString() + "kV"; lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt); li.ObligateField3 = obj.OperationYear; if (lt != null) { li.ObligateField2 = lt.Color; lineWidth = lt.ObligateField1; } if (!string.IsNullOrEmpty(li.ObligateField3)) { if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) { li.ObligateField1 = "规划"; } else li.ObligateField1 = "运行"; } Services.BaseService.Update<LineInfo>(li); } else { li = new LineInfo(); li.UID = obj.SUID; li.LineName = obj.Name; li.Length = obj.LineLength.ToString(); li.LineType = obj.LineType; li.Voltage = obj.ReferenceVolt.ToString(); li.EleID = xml1.GetAttribute("id"); li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; LineType lt = new LineType(); lt.TypeName = obj.ReferenceVolt.ToString() + "kV"; lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt); li.ObligateField3 = obj.OperationYear; if (lt != null) { li.ObligateField2 = lt.Color; lineWidth = lt.ObligateField1; } if (!string.IsNullOrEmpty(li.ObligateField3)) { if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) { li.ObligateField1 = "规划"; } else li.ObligateField1 = "运行"; } Services.BaseService.Create<LineInfo>(li); } string styleValue = ""; if (li.ObligateField1 == "规划") { styleValue = "stroke-dasharray:" + ghType + ";stroke-width:" + lineWidth + ";"; } else { styleValue = "stroke-width:" + lineWidth + ";"; } //string aa= ColorTranslator.ToHtml(Color.Black); styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(li.ObligateField2))); SvgElement se = tlVectorControl1.SVGDocument.CurrentElement; se.RemoveAttribute("style"); se.SetAttribute("style", styleValue); se.SetAttribute("info-name", li.LineName); //***** ********添加FistNode和LastNode XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use"); foreach (XmlNode element in useList) { if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid"))) { string con = "WHERE SvgUID='" + (element as XmlElement).GetAttribute("Deviceid") + "'AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='01'"; IList pspMX = Services.BaseService.GetList("SelectPSPDEVByCondition", con); if (pspMX != null) { foreach (PSPDEV pspmx in pspMX) { if (obj.IName == pspmx.Name) { (xml1 as XmlElement).SetAttribute("FirstNode", (element as XmlElement).GetAttribute("id")); } else if (obj.JName == pspmx.Name) { (xml1 as XmlElement).SetAttribute("LastNode", (element as XmlElement).GetAttribute("id")); } } } } } } //** } } if (xml1.GetAttribute("xlink:href").Contains("Substation") || xml1.GetAttribute("xlink:href").Contains("Power")) { string lab = xml1.GetAttribute("xlink:href"); float x = 0f; float y = 0f; x = ((Use)xml1).X; y = ((Use)xml1).Y; PointF p1 = new PointF(x, y); PointF[] pnt = new PointF[1]; pnt[0] = p1; Use temp = xml1.Clone() as Use; temp.Transform.Matrix.TransformPoints(pnt); LongLat templat = mapview.OffSetZero(-(int)(pnt[0].X * tlVectorControl1.ScaleRatio), -(int)(pnt[0].Y * tlVectorControl1.ScaleRatio)); string[] jd = templat.Longitude.ToString("####.####").Split('.'); int d1 = Convert.ToInt32(jd[0]); string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.'); int f1 = Convert.ToInt32(df1[0]); decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60; string[] wd = templat.Latitude.ToString("####.####").Split('.'); int d2 = Convert.ToInt32(wd[0]); string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.'); int f2 = Convert.ToInt32(df2[0]); decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60; string strjwd = "经纬度: " + d1.ToString() + "°" + f1.ToString() + "′" + m1.ToString("##.#") + "″," + d2.ToString() + "°" + f2.ToString() + "′" + m2.ToString("##.#") + "″"; object obj = null; string deviceid = xml1.GetAttribute("Deviceid"); if (string.IsNullOrEmpty(deviceid)) { //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; if (xml1.GetAttribute("xlink:href").Contains("Power")) { obj = DeviceHelper.SelectDevice(DeviceType.DY, Itop.Client.MIS.ProgUID); if (obj == null) { tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement; tlVectorControl1.Delete(); } if (obj is PSP_PowerSubstation_Info) { deviceid = ((PSP_PowerSubstation_Info)obj).UID; xml1.SetAttribute("Deviceid", deviceid); } substation sb = new substation(); sb.UID = ((PSP_PowerSubstation_Info)obj).UID; sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb); if (sb != null) { sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; sb.EleID = xml1.GetAttribute("id"); if (((PSP_PowerSubstation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Update<substation>(sb); } else { sb = new substation(); sb.UID = ((PSP_PowerSubstation_Info)obj).UID; sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.EleID = xml1.GetAttribute("id"); sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; if (((PSP_PowerSubstation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Create<substation>(sb); } } else { obj = DeviceHelper.SelectDevice(DeviceType.BDZ, Itop.Client.MIS.ProgUID); if (obj == null) { tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement; tlVectorControl1.Delete(); } if (obj is PSP_Substation_Info) { deviceid = ((PSP_Substation_Info)obj).UID; xml1.SetAttribute("Deviceid", deviceid); //RectangleF t = ((IGraph)xml1).GetBounds(); //n1.SetAttribute("x", (t.X - 30).ToString()); //n1.SetAttribute("y", (t.Y - 30).ToString()); //n1.SetAttribute("font-size", "24"); //n1.InnerText = ((PSP_Substation_Info)obj).Title; //n1.SetAttribute("layer", SvgDocument.currentLayer); //n1.SetAttribute("ParentID", temp.GetAttribute("id")); //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); //tlVectorControl1.Operation = ToolOperation.Select; } substation sb = new substation(); sb.UID = ((PSP_Substation_Info)obj).UID; sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb); if (sb != null) { sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; sb.EleID = xml1.GetAttribute("id"); if (((PSP_Substation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_Substation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Update<substation>(sb); } else { sb = new substation(); sb.UID = ((PSP_Substation_Info)obj).UID; sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.EleID = xml1.GetAttribute("id"); sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; if (((PSP_Substation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_Substation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Create<substation>(sb); } } } if (!string.IsNullOrEmpty(deviceid)) { if (xml1.GetAttribute("xlink:href").Contains("Power")) { obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid); if (obj != null) { xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title); //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']"); DeviceHelper.ShowDeviceDlg(DeviceType.DY, deviceid, false); } substation sb = new substation(); sb.UID = ((PSP_PowerSubstation_Info)obj).UID; sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb); if (sb != null) { sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; sb.EleID = xml1.GetAttribute("id"); if (((PSP_PowerSubstation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Update<substation>(sb); } else { sb = new substation(); sb.UID = ((PSP_PowerSubstation_Info)obj).UID; sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; sb.EleID = xml1.GetAttribute("id"); if (((PSP_PowerSubstation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Create<substation>(sb); } } else { obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid); if (obj != null) { xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title); //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']"); DeviceHelper.ShowDeviceDlg(DeviceType.BDZ, deviceid, false); } substation sb = new substation(); sb.UID = ((PSP_Substation_Info)obj).UID; sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb); if (sb != null) { sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; sb.EleID = xml1.GetAttribute("id"); if (((PSP_Substation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_Substation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Update<substation>(sb); } else { sb = new substation(); sb.UID = ((PSP_Substation_Info)obj).UID; sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sb.EleID = xml1.GetAttribute("id"); sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; if (((PSP_Substation_Info)obj).Flag == "2") { sb.ObligateField3 = "规划"; } else if (((PSP_Substation_Info)obj).Flag == "1") { sb.ObligateField3 = "现行"; } Services.BaseService.Create<substation>(sb); } } } //frmSubstationProperty frmSub = new frmSubstationProperty(); //frmSub.jwstr = strjwd; //frmSub.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SvgDocument.currentLayer, lab); //if (frmSub.ShowDialog() == DialogResult.OK) //{ // xml1.SetAttribute("info-name", frmSub.Sub.EleName); // SVG_ENTITY ent = new SVG_ENTITY(); // if (frmSub.IsCreate) // { // ent.SUID = Guid.NewGuid().ToString(); // ent.EleID = frmSub.Sub.EleID; // ent.layerID = frmSub.Sub.LayerID; // ent.MDATE = System.DateTime.Now; // ent.NAME = frmSub.Sub.EleName; // ent.svgID = frmSub.Sub.SvgUID; // ent.TYPE = "substation"; // ent.voltage = Convert.ToInt32(frmSub.Sub.ObligateField1); // Services.BaseService.Create<SVG_ENTITY>(ent); // } // else // { // ent.NAME = frmSub.Sub.EleName; // ent.layerID = frmSub.Sub.LayerID; // ent.MDATE = System.DateTime.Now; // //ent.voltage = fl.Line.Voltage; // Services.BaseService.Update<SVG_ENTITY>(ent); // } //} } if (xml1.GetAttribute("xlink:href").Contains("XL_GT_3") || xml1.GetAttribute("xlink:href").Contains("XL_GT_4")) { frmInputNum num = new frmInputNum(); num.InputStr = xml1.GetAttribute("order"); num.ShowDialog(); xml1.SetAttribute("order", num.InputStrSEL); } //if (xml1.GetAttribute("xlink:href").Contains("bdz") || xml1.GetAttribute("xlink:href").Contains("hwg") || // xml1.GetAttribute("xlink:href").Contains("fjx") || xml1.GetAttribute("xlink:href").Contains("kbs") || // xml1.GetAttribute("xlink:href").Contains("byq") || xml1.GetAttribute("xlink:href").Contains("kg")) //{ // frmInputDialog n1 = new frmInputDialog(); // n1.InputStr = xml1.GetAttribute("info-name").ToString(); // if (n1.ShowDialog() == DialogResult.OK) // { // xml1.SetAttribute("info-name",n1.InputStr); // } //} if (xml1.GetAttribute("xlink:href").Contains("kbs") || xml1.GetAttribute("xlink:href").Contains("hwg")) { frmkbsProperty num = new frmkbsProperty(); num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID); num.ShowDialog(); } if (xml1.GetAttribute("xlink:href").Contains("fjx")) { frmfjxProperty num = new frmfjxProperty(); num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID); num.ShowDialog(); } if (xml1.GetAttribute("xlink:href").Contains("byq")) { frmbyqProperty num = new frmbyqProperty(); num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID); num.ShowDialog(); } if (xml1.GetAttribute("xlink:href").Contains("SB_GT")) { string lineWidth = "2"; string Code = xltProcessor.GetCurrentLineCode(); string _len = xltProcessor.GetWholeLineLength(Code).ToString("#####.####"); frmLineProperty fl = new frmLineProperty(); fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement; fl.InitData(Code, tlVectorControl1.SVGDocument.SvgdataUid, _len, SvgDocument.currentLayer); if (fl.ShowDialog() == DialogResult.OK) { //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;" lineWidth = fl.LineWidth; string styleValue = ""; if (fl.Line.ObligateField1 == "规划") { styleValue = "stroke-dasharray:4 4;stroke-width:" + lineWidth + ";"; } else { styleValue = "stroke-width:" + lineWidth + ";"; } styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2))); ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("style"); ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", styleValue); xltProcessor.SetWholeLineAttribute(Code, "style", styleValue); } } } if (e.ClickedItem.Text == "移动") { if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { return; } XmlElement xmln = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement; frmMove fm = new frmMove(); PointF pf11 = ((Use)xmln).CenterPoint; LongLat temp = mapview.ParseToLongLat((int)pf11.X, (int)pf11.Y); string[] jd = temp.Longitude.ToString("####.####").Split('.'); int d1 = Convert.ToInt32(jd[0]); string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.'); int f1 = Convert.ToInt32(df1[0]); decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60; string[] wd = temp.Latitude.ToString("####.####").Split('.'); int d2 = Convert.ToInt32(wd[0]); string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.'); int f2 = Convert.ToInt32(df2[0]); decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60; strj1 = d1.ToString(); strw1 = f1.ToString(); strd1 = m1.ToString(); strj2 = d2.ToString(); strw2 = f2.ToString(); strd2 = m2.ToString(); fm.Init(strj1, strw1, strd1, strj2, strw2, strd2); if (fm.ShowDialog() == DialogResult.OK) { string strValue = fm.StrValue; string[] str = strValue.Split(','); string[] JWD1 = str[0].Split(' '); decimal J1 = Convert.ToDecimal(JWD1[0]); decimal W1 = Convert.ToDecimal(JWD1[1]); decimal D1 = Convert.ToDecimal(JWD1[2]); string[] JWD2 = str[1].Split(' '); decimal J2 = Convert.ToDecimal(JWD2[0]); decimal W2 = Convert.ToDecimal(JWD2[1]); decimal D2 = Convert.ToDecimal(JWD2[2]); decimal JD = J1 + W1 / 60 + D1 / 3600; decimal WD = J2 + W2 / 60 + D2 / 3600; PointF pf1 = mapview.ParseToPoint(JD, WD); PointF p1 = ((Use)xmln).CenterPoint; SvgElement e1 = xmln as SvgElement; Matrix matrix2 = ((IGraph)e1).GraphTransform.Matrix.Clone(); Matrix matrix3 = tlVectorControl1.DrawArea.CoordTransform.Clone(); matrix3.Invert(); matrix2.Multiply(matrix3, MatrixOrder.Append); matrix2.Invert(); PointF[] pfArray1 = new PointF[] { new PointF(pf1.X / tlVectorControl1.ScaleRatio, pf1.Y / tlVectorControl1.ScaleRatio), p1 }; matrix2.TransformPoints(pfArray1); float single1 = pfArray1[0].X - pfArray1[1].X; float single2 = pfArray1[0].Y - pfArray1[1].Y; Matrix matrix6 = ((IGraph)e1).Transform.Matrix.Clone(); if (e1.SvgAttributes.ContainsKey("transform")) { Matrix matrix7 = ((Matrix)e1.SvgAttributes["transform"]).Clone(); matrix7.Invert(); matrix6.Multiply(matrix7, MatrixOrder.Append); } Matrix matrix5 = new Matrix(); matrix5.Translate(single1, single2); Matrix matrix8 = ((IGraph)e1).Transform.Matrix.Clone(); matrix8.Multiply(matrix5); matrix6.Invert(); matrix6.Multiply(matrix8, MatrixOrder.Append); Transf tf = new Transf(); tf.setMatrix(matrix6); (xmln as Use).Transform = tf; } } if (e.ClickedItem.Text == "接线图") { if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { return; } ParentUID = tlVectorControl1.SVGDocument.SvgdataUid; Save(); ParentUID = tlVectorControl1.SVGDocument.SvgdataUid; SVGFILE svg_temp = new SVGFILE(); //XmlElement xml1 = ((XmlElement)(e.Elements[0]));xml1.GetAttribute("id"); svg_temp.SUID = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("id"); svg_temp.FILENAME = getBdzName(svg_temp.SUID);// ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("info-name"); string strWhere = string.Format("suid='{0}' or filename='{1}' ", svg_temp.SUID, svg_temp.FILENAME); IList svglist = Services.BaseService.GetList("SelectSVGFILEByWhere", strWhere); OpenJXT(svglist, svg_temp); //frmlar.SymbolDoc = tlVectorControl1.SVGDocument; //frmlar.Progtype = MapType; //frmlar.InitData(); //JxtBar(); } if (e.ClickedItem.Text == "打开") { if (tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } UseRelating UseRel = new UseRelating(); UseRel.UseID = tlVectorControl1.SVGDocument.CurrentElement.ID; IList<UseRelating> UseRelList = Services.BaseService.GetList<UseRelating>("SelectUseRelatingByUseID", UseRel); if (UseRelList.Count < 1) { MessageBox.Show("选择的地块还没有关联到其他地图,请先设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } UseRel = UseRelList[0]; SVGFILE svgFile = new SVGFILE(); svgFile.SUID = UseRel.LinkUID; IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile); if (svgList.Count < 1) { MessageBox.Show("被关联的地图已经被删除,请重新设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } svgFile = (SVGFILE)svgList[0]; //SvgDocument doc = new SvgDocument(); if (!string.IsNullOrEmpty(svgFile.SVGDATA)) { //doc.LoadXml(svgFile.SVGDATA); ctlfile_OnOpenSvgDocument(sender, svgFile.SUID); } } if (e.ClickedItem.Text == "区域打印") { PrintHelper ph = new PrintHelper(tlVectorControl1, mapview); frmPrinter dlg = new frmPrinter(); dlg.printHelper = ph; dlg.ShowDialog(); return; ArrayList idlist = new ArrayList(); ArrayList symlist = new ArrayList(); SvgDocument _doc = new SvgDocument(); Graph poly1 = tlVectorControl1.SVGDocument.CurrentElement as Graph; if (poly1 == null || poly1.GetAttribute("id") == "svg") { return; } GraphicsPath gr1 = new GraphicsPath(); //gr1.AddRectangle(TLMath.getRectangle(poly1)); gr1.AddPolygon(TLMath.getPolygonPoints(poly1)); //gr1.CloseFigure(); gr1 = (GraphicsPath)poly1.GPath.Clone(); gr1.Transform((poly1 as IGraph).Transform.Matrix); RectangleF ef1 = gr1.GetBounds(); ef1 = PathFunc.GetBounds(gr1); StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">"); XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("defs"); if (nlist.Count > 0) { XmlNode node = nlist[0]; svgtxt.AppendLine(node.OuterXml); } SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator(); while (enumerator1.MoveNext()) { IGraph graph1 = (IGraph)enumerator1.Current; GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone(); //path1.Transform(graph1.GraphTransform.Matrix); //path1.Transform(graph1.Transform.Matrix); // RectangleF ef2 = path1.GetBounds();// PathFunc.GetBounds(path1); //for (int n = 0; n < selCol.Count - 1; n++) //{ // //_doc.AppendChild((XmlNode)selCol[n]); // svgtxt = svgtxt + ((XmlElement)selCol[n]).OuterXml + "\r\n"; //} if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue; GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone(); path2.Transform(graph1.Transform.Matrix); RectangleF ef2 = PathFunc.GetBounds(path2); if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty) { SvgElement ele = (SvgElement)graph1; svgtxt.AppendLine(ele.OuterXml); //tlVectorControl1.SVGDocument.AddSelectElement(graph1); if (graph1 is Use) { //PointF offset = TLMath.getUseOffset(((XmlElement)graph1).GetAttribute("xlink:href")); //if (ef1.Contains(new PointF(((Use)graph1).X + offset.X, ((Use)graph1).Y + offset.Y))) { //SvgElement ele = (SvgElement)graph1; //svgtxt.AppendLine(ele.OuterXml); string symid = ((XmlElement)graph1).GetAttribute("xlink:href"); if (!symlist.Contains(symid)) { symlist.Add(symid); } //} } if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") { string IsLead = ((XmlElement)graph1).GetAttribute("IsLead"); if (IsLead != "") { if (ef1.Contains(ef2)) { idlist.Add(graph1.ID); } } } } //if (ef1.Contains(ef2)|| RectangleF.Intersect(ef1,ef2) !=RectangleF.Empty ) //{ // SvgElement ele = (SvgElement)graph1; // svgtxt.AppendLine(ele.OuterXml); // //tlVectorControl1.SVGDocument.AddSelectElement(graph1); // if (graph1 is Use ) { // PointF offset = TLMath.getUseOffset(((XmlElement)graph1).GetAttribute("xlink:href")); // if (ef1.Contains(new PointF(((Use)graph1).X + offset.X, ((Use)graph1).Y + offset.Y))) { // //SvgElement ele = (SvgElement)graph1; // //svgtxt.AppendLine(ele.OuterXml); // string symid = ((XmlElement)graph1).GetAttribute("xlink:href"); // if (!symlist.Contains(symid)) { // symlist.Add(symid); // } // } // } // if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") { // string IsLead = ((XmlElement)graph1).GetAttribute("IsLead"); // if (IsLead != "") { // if (ef1.Contains(ef2)) { // idlist.Add(graph1.ID); // } // } // } //} } symlist = ResetList(symlist); svgtxt.AppendLine("</svg>"); _doc.LoadXml(svgtxt.ToString()); _doc.SvgdataUid = tlVectorControl1.SVGDocument.SvgdataUid; frmPrintF pri = new frmPrintF(); pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid); if (pri.ShowDialog() == DialogResult.OK) { frmSubPrint s = new frmSubPrint(); s.Vector = tlVectorControl1; s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist); s.Open(_doc, ef1); s.Show(); } } if (e.ClickedItem.Text == "分类统计报表") { if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { return; } IGraph poly1 = (IGraph)tlVectorControl1.SVGDocument.CurrentElement; frmPloyPrint p = new frmPloyPrint(); p.InitDate(poly1.ID, tlVectorControl1.SVGDocument.SvgdataUid); p.ShowDialog(); } if (e.ClickedItem.Text == "保存图片") { if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") { //frmImgInfoInput finput = new frmImgInfoInput(); //if (finput.ShowDialog() == DialogResult.OK) //{ PrintHelper ph = new PrintHelper(tlVectorControl1, mapview); frmImgManager frm = new frmImgManager(); //frm.StrName = finput.StrName; //frm.StrRemark = finput.StrRemark; frm.Pic = ph.getImage(); frm.ShowDialog(); //} } } } catch (Exception e1) { //MessageBox.Show(e1.Message); } if (e.ClickedItem.Text == "三维变电站") { try { string strid = tlVectorControl1.SVGDocument.CurrentElement.ID; substation s = new substation(); s.EleID = strid; s.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; s = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", s); ProcessStartInfo p = new ProcessStartInfo(); p.FileName = Application.StartupPath + "\\" + s.EleName + "\\bdz.exe"; p.WorkingDirectory = Application.StartupPath + "\\" + s.EleName; Process.Start(p); } catch (Exception e1) { } } if (e.ClickedItem.Text == "更新关联变电站") { UpdateLine(); } if (e.ClickedItem.Text == "删除") { Delete(); } }
private void RebdzxzResult1(List<SubandFHcollect> subandfhlist1, ArrayList extsublist1, glebeProperty gp, string befordbzname,string layid) { ////寻找选址的图层 // Layer lar = null; // string FileName = "变电站地块连接线"; // if (Layer.CkLayerExist(FileName, tlVectorControl1.SVGDocument)) { // ArrayList layercol = tlVectorControl1.SVGDocument.getLayerList(); // for (int i = 0; i < layercol.Count; i++) { // if (FileName == (layercol[i] as Layer).GetAttribute("label")) { // lar = (Layer)layercol[i]; // break; // } // } // } else { // lar = Layer.CreateNew(FileName, tlVectorControl1.SVGDocument); // lar.SetAttribute("layerType", progtype); // lar.SetAttribute("ParentID", SaveID[0].ToString()); // //this.frmlar.checkedListBox1.SelectedIndex = -1; // frmlar.AddLayer(lar, true); // } //判断选择变电站是否在选择的变电站内 bool flag=false; string newfhdk=""; string dkrl=""; for(int i=0;i<extsublist.Count;i++) { XmlElement _x=extsublist[i] as XmlElement; string subname=_x.GetAttribute("subname"); string yfcrzb=_x.GetAttribute("yfcrzb"); double subrl=subrl = Convert.ToDouble(_x.GetAttribute("rl")); string fhdk=_x.GetAttribute("fhdk"); if(!string.IsNullOrEmpty(fhdk)) { if(fhdk.Contains(gp.EleID)) { double newyfcrzb=dbl_rzb; //找到原来的线路删掉 XmlNode xnode = tlVectorControl1.SVGDocument.SelectSingleNode("svg/polyline[@layer='"+layid+"'and @FirstNode='" + _x.GetAttribute("id").ToString() + "'and @LastNode='" + gp.EleID + "']"); if (xnode != null) { tlVectorControl1.SVGDocument.RootElement.RemoveChild(xnode); } string[] dkqk = (fhdk.Substring(0, fhdk.LastIndexOf(";"))).Split(';'); for (int j = 0; j < dkqk.Length; j++) { string[] dk = dkqk[j].Split(','); if(dk[0]==gp.EleID) { dkrl=dk[1]; newyfcrzb= subrl /((((subrl/Convert.ToDouble(yfcrzb))*dbl_rzb-Convert.ToDouble(dkrl))/dbl_rzb)); continue; } newfhdk+=dkqk[j]+";"; } _x.SetAttribute("fhdk", newfhdk); _x.SetAttribute("yfcrzb", newyfcrzb.ToString()); } } //对新的变电站进行改造 if (subname == gp.ObligateField7) { //添加线路 XmlElement dk = (XmlElement)tlVectorControl1.SVGDocument.SelectSingleNode("svg/polygon [@IsArea='1'and @id='" + gp.EleID + "']"); if (dk != null) { PointF _f = TLMath.polyCentriod(dk); string temp = _x.GetAttribute("cx").ToString() + " " + _x.GetAttribute("cy").ToString() + "," + _f.X.ToString() + " " + _f.Y.ToString(); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; n1.SetAttribute("points", temp); //如果是规划 if (flag) { _x.SetAttribute("xz", "1"); n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#990033;stroke-opacity:1;"); } else { if (_x.GetAttribute("xz") != "1") { _x.SetAttribute("xz", "0"); } n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#330099;stroke-opacity:1;"); } n1.SetAttribute("layer", layid); n1.SetAttribute("IsLead", "1"); n1.SetAttribute("FirstNode", _x.GetAttribute("id").ToString()); n1.SetAttribute("LastNode", dk.GetAttribute("id").ToString()); n1.SetAttribute("xz", "1"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); fhdk += gp.EleID + "," + (Convert.ToDouble(gp.Burthen) * dbl_rzb).ToString() + ";"; _x.SetAttribute("fhdk", fhdk); _x.SetAttribute("yfcrzb", (subrl / ((subrl / Convert.ToDouble(yfcrzb)) + Convert.ToDouble(gp.Burthen))).ToString()); } flag = true; } } if(!flag) { MessageBox.Show("选择的变电站不在选址范围内 请重新操作!"); return; } Extbdzreport(extsublist); //首先找出原来变电站和地块的关系 }
public void Delete() { if (tlVectorControl1.SVGDocument.CurrentElement != null && tlVectorControl1.SVGDocument.CurrentElement.ID != "svg") { frmMessageBox msg = new frmMessageBox(); if (msg.ShowDialog() == DialogResult.OK) { //if (msg.ck) //{ // if(MessageBox.Show("确认删除么?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Information)==DialogResult.Yes){ for (int i = 0; i < tlVectorControl1.SVGDocument.SelectCollection.Count; i++) { string larid = ""; larid = ((SvgElement)tlVectorControl1.SVGDocument.SelectCollection[i]).GetAttribute("layer"); if (!ChangeLayerList.Contains(larid)) { ChangeLayerList.Add(larid); } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Image") { SVG_IMAGE s_img = new SVG_IMAGE(); s_img.SUID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; Services.BaseService.Delete<SVG_IMAGE>(s_img); } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polygon") { glebeProperty gle = new glebeProperty(); gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; gle.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; Services.BaseService.Update("DeleteglebePropertyByEleID", gle); SVG_ENTITY pro = new SVG_ENTITY(); pro.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; pro.svgID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Update("DeleteSVG_ENTITYByEleID", pro); } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line") { LineInfo _line = new LineInfo(); _line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _line.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; LineInfo temp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _line); if (temp != null) { Services.BaseService.Update("DeleteLinePropertyByEleID", _line); Services.BaseService.Update("DeleteLine_InfoByCode", temp.UID); } SVG_ENTITY pro = new SVG_ENTITY(); pro.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; pro.svgID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Update("DeleteSVG_ENTITYByEleID", pro); } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use") { string str_name = ((XmlElement)(tlVectorControl1.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href"); if (str_name.Contains("Substation")) { substation _sub = new substation(); _sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _sub.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; substation temp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub); if (temp != null) { Services.BaseService.Update("DeletesubstationByEleID", _sub); Services.BaseService.Update("DeleteSubstation_InfoByCode", temp.UID); } SVG_ENTITY pro = new SVG_ENTITY(); pro.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; pro.svgID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Update("DeleteSVG_ENTITYByEleID", pro); substation p = new substation(); p.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Update("DeletesubstationByEleID", p); PSP_SubstationSelect sel = new PSP_SubstationSelect(); sel.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; sel.SvgID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Update("DeletePSP_SubstationByEleID", sel); } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") { ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.SelectCollection[i]; if (cline.StartGraph != null) { SvgElement ele = (SvgElement)cline.StartGraph; if (!ele.GetAttribute("xlink:href").Contains("Substation")) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.StartGraph); } } if (cline.EndGraph != null) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.EndGraph); } } } //} /* else { for (int i = 0; i < tlVectorControl1.SVGDocument.SelectCollection.Count; i++) { string larid = ""; larid = ((SvgElement)tlVectorControl1.SVGDocument.SelectCollection[i]).GetAttribute("layer"); if (!ChangeLayerList.Contains(larid)) { ChangeLayerList.Add(larid); } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Image") { SVG_IMAGE s_img = new SVG_IMAGE(); s_img.SUID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; Services.BaseService.Delete<SVG_IMAGE>(s_img); } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line") { LineInfo _line = new LineInfo(); _line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _line.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; LineInfo linetemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _line); if (linetemp != null) { PowerProTypes temp = (PowerProTypes)Services.BaseService.GetObject("SelectPowerProTypesByCode", linetemp.UID); if (temp != null) { linetemp.EleID = ""; Services.BaseService.Update<LineInfo>(linetemp); } else { Services.BaseService.Update("DeleteLineInfo", linetemp); } } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use") { string str_name = ((XmlElement)(tlVectorControl1.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href"); if (str_name.Contains("Substation")) { substation _sub = new substation(); _sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _sub.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; substation subtemp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub); if (subtemp != null) { PowerProTypes temp = (PowerProTypes)Services.BaseService.GetObject("SelectPowerProTypesByCode", subtemp.UID); if (temp != null) { subtemp.EleID = ""; Services.BaseService.Update<substation>(subtemp); } else { Services.BaseService.Update("Deletesubstation", subtemp); } } } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") { ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.SelectCollection[i]; if (cline.StartGraph != null) { SvgElement ele = (SvgElement)cline.StartGraph; if (!ele.GetAttribute("xlink:href").Contains("Substation")) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.StartGraph); } } if (cline.EndGraph != null) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.EndGraph); } } } }*/ tlVectorControl1.Delete(); } } }
private void bbtdellayer_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (treeList1.FocusedNode != null) { TreeListNode treenode = treeList1.FocusedNode; if (treenode["SUID"].ToString().Contains("FA")) { return; } if (treenode.HasChildren) { MessageBox.Show("���ӽڵ�ʱ����ɾ����", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Layer layer = symbolDoc.Layers[treenode["SUID"].ToString()] as Layer; if (!CkRight(layer)) { MessageBox.Show("����ͼ�㲻�ܸ�����ɾ����", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBox.Show("ɾ��ͼ���ʹ��ǰͼ�����������ݶ�ʧ���Ҳ��ɻָ���ȷ��Ҫɾ����", "��ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { // return; //} //if (MessageBox.Show(this, "�Ƿ�ɾ��ͼ�㣺" + layer.Label + "?", "��ȷ��", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) //{ XmlNode node = this.SymbolDoc.SelectSingleNode("//*[@layer='" + layer.ID + "']"); if (node != null) { if ((MessageBox.Show(this, "��ͼ������ͼԪ,�Ƿ�ɾ��ͼ�㣺" + layer.Label + "?", "��ȷ��", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)) { //PSPDEV _line = new PSPDEV(); //_line.LayerID = layer.ID; //Services.BaseService.Update("DeletePSPDEVbyLayerID", _line); glebeProperty gle = new glebeProperty(); gle.LayerID = layer.ID; Services.BaseService.Update("DeleteglebePropertyByLayerID", gle); //PSP_Substation_Info _sub = new PSP_Substation_Info(); //_sub.LayerID = layer.ID; //Services.BaseService.Update("DeletePSP_Substation_InfoByLayerID", _sub); SVG_LAYER lar = new SVG_LAYER(); lar.SUID = layer.ID; Services.BaseService.Update("DeleteSVG_LAYER", lar); XmlNodeList list = this.SymbolDoc.SelectNodes("//*[@layer='" + layer.ID + "']"); foreach (XmlNode elNode in list) { this.SymbolDoc.RootElement.RemoveChild(elNode); } // Services.BaseService.Update("UpdateGraPowerRelationByLayerID", layer.ID); //���ĵ����Ƴ� layer.Remove(); //���б����Ƴ� if (treenode.ParentNode != null) treenode.ParentNode.Nodes.Remove(treenode); else treeList1.Nodes.Remove(treenode); layer = null; LayerName = ""; } //layer.Attributes.RemoveAll(); } else { // Services.BaseService.Update("UpdateGraPowerRelationByLayerID", layer.ID); //���ĵ����Ƴ� SVG_LAYER lar = new SVG_LAYER(); lar.SUID = layer.ID; Services.BaseService.Update("DeleteSVG_LAYER", lar); try { layer.Remove(); } catch { } //���б����Ƴ� if (treenode.ParentNode != null) treenode.ParentNode.Nodes.Remove(treenode); else treeList1.Nodes.Remove(treenode); layer = null; LayerName = ""; } } //if(this.checkedListBox1.Items.Count<1){ if (OnDeleteLayer != null) { OnDeleteLayer(sender); } //} } }
void tlVectorControl1_LeftClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e) { //SvgElement ele2 = tlVectorControl1.CreateBySymbolID("kbs-8", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location))); //ele2 = tlVectorControl1.AddShape(ele2, Point.Empty); if (tlVectorControl1.SVGDocument.CurrentElement != null && tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("xlink:href").Contains("XL_GT_1")) { sel_start_point = tlVectorControl1.SVGDocument.CurrentElement.ID; } if (sel_sym == "bt_start") { SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_1", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location))); ele = tlVectorControl1.AddShape(ele, Point.Empty); ele.SetAttribute("order", "0"); ele.SetAttribute("start_point", ele.ID); } if (sel_sym == "bt_end") { SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_2", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location))); ele.SetAttribute("start_point", sel_start_point); ele.SetAttribute("order", "999"); tlVectorControl1.AddShape(ele, Point.Empty); } if (sel_sym == "bt_must") { SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_3", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location))); ele.SetAttribute("start_point", sel_start_point); tlVectorControl1.AddShape(ele, Point.Empty); frmInputNum num = new frmInputNum(); num.ShowDialog(); ele.SetAttribute("order", num.InputStrSEL); } if (sel_sym == "bt_point") { SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_4", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location))); ele.SetAttribute("start_point", sel_start_point); tlVectorControl1.AddShape(ele, Point.Empty); frmInputNum num = new frmInputNum(); num.ShowDialog(); ele.SetAttribute("order", num.InputStrSEL); } //if (sel_sym != "" && sel_start_point!="") //{ // XmlNodeList il= tlVectorControl1.SVGDocument.SelectNodes("svg/use [@start_point='" + sel_start_point + "']"); // if (il.Count < 3) // { // return; // } // for (int i = 0; i < il.Count;i++ ) // { // Use u = (Use)il[i]; // PointF f = u.CenterPoint; // } // //PointF[] pnt = ((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)).Points; // //if (pnt.Length < 3) return; // for (int i = 0; i < il.Count; i++) // { // double ang = TLMath.getLineAngle(((Use)il[i]).CenterPoint, ((Use)il[i + 1]).CenterPoint, ((Use)il[i + 2]).CenterPoint); // if (ang * 57.3 > 60) // { // MessageBox.Show("线路转角不能大于60度。\r\n "+"第" + (i + 1) + "转角:" + Convert.ToDouble(ang * 57.3).ToString("##.##") + "度。\r\n", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // // tlVectorControl1.Delete(); // return; // } // if (i == il.Count - 3) // { // break; // } // } //} if (csOperation == CustomOperation.OP_MeasureDistance) { Polyline pl = tlVectorControl1.SVGDocument.CurrentElement as Polyline; if (pl.Points.Length > 1) { double d = 0; for (int i = 1; i < pl.Points.Length; i++) { d += this.mapview.CountLength(pl.Points[i - 1], pl.Points[i]); } label1.Text = d + "公里"; Point pt = new Point(e.Mouse.X, e.Mouse.Y); pt = PointToClient(tlVectorControl1.PointToScreen(pt)); //tlVectorControl1.SetToolTip(label1.Text); label1.Left = pt.X; label1.Top = pt.Y; label1.Visible = true; } return; } //System.IO.FileInfo ff = new System.IO.FileInfo("c:\\1111.txt"); //System.IO.StreamWriter wt= ff.CreateText(); //wt.Write(tlVectorControl1.SVGDocument.OuterXml); //wt.Close(); //SortedList l = new SortedList(); //l.Add("1", "aaa"); //l.Add("5", "bbb"); //l.Add("2", "ccc"); //if (tlVectorControl1.ScaleRatio < 0.1f) { // tlVectorControl1.ScaleRatio = 0.1f; // scaleBox.ComboBoxEx.Text = ""; // scaleBox.SelectedText = "10%"; //} tip.Hide(); fInfo.Hide(); 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; Point point1 = tlVectorControl1.PointToView(new 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; } } if (MapType == "规划统计") { try { if (e.SvgElement.ID == "svg") { MapType = "接线图"; return; } if (((Polygon)e.SvgElement) == null) return; XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle; Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y)); n1.SetAttribute("cx", point1.X.ToString()); n1.SetAttribute("cy", point1.Y.ToString()); n1.SetAttribute("r", "42.5"); n1.SetAttribute("r", "42.5"); //n1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID); n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); frmMainProperty fmain = new frmMainProperty(); glebeProperty gp = new glebeProperty(); gp.EleID = ((XmlElement)e.SvgElement).GetAttribute("id"); gp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; //fmain.InitData(gp); /////////////////////////////////// XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("use"); PointF[] tfArray1 = TLMath.getPolygonPoints((XmlElement)e.SvgElement); string str220 = ""; string str110 = ""; string str66 = ""; GraphicsPath selectAreaPath = new GraphicsPath(); selectAreaPath.AddLines(tfArray1); selectAreaPath.CloseFigure(); //Matrix x=new Matrix( //Region region1 = new Region(selectAreaPath); for (int i = 0; i < nlist.Count; i++) { float OffX = 0f; float OffY = 0f; Use use = (Use)nlist[i]; if (use.GetAttribute("xlink:href").Contains("Substation")) { string strMatrix = use.GetAttribute("transform"); if (strMatrix != "") { strMatrix = strMatrix.Replace("matrix(", ""); strMatrix = strMatrix.Replace(")", ""); string[] mat = strMatrix.Split(','); if (mat.Length > 5) { OffX = Convert.ToSingle(mat[4]); OffY = Convert.ToSingle(mat[5]); } } PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href")); if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY)) { if (use.GetAttribute("xlink:href").Contains("220")) { str220 = str220 + "'" + use.GetAttribute("id") + "',"; } if (use.GetAttribute("xlink:href").Contains("110")) { str110 = str110 + "'" + use.GetAttribute("id") + "',"; } if (use.GetAttribute("xlink:href").Contains("66")) { str66 = str66 + "'" + use.GetAttribute("id") + "',"; } } } } if (str220.Length > 1) { str220 = str220.Substring(0, str220.Length - 1); } if (str110.Length > 1) { str110 = str110.Substring(0, str110.Length - 1); } if (str66.Length > 1) { str66 = str66.Substring(0, str66.Length - 1); } fmain.InitData(gp, str220, str110, str66); XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; Point point2 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y)); t1.SetAttribute("x", Convert.ToString(point2.X - 20)); t1.SetAttribute("y", Convert.ToString(point2.Y - 10)); // t1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID); t1.SetAttribute("layer", SvgDocument.currentLayer); t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t1.SetAttribute("font-famliy", "宋体"); t1.SetAttribute("font-size", "14"); t1.InnerText = fmain.glebeProp.Area + "\r\n" + fmain.glebeProp.Burthen; //+"\r\n" + fmain.glebeProp.Number; tlVectorControl1.SVGDocument.RootElement.AppendChild(t1); tlVectorControl1.Refresh(); fmain.Dispose(); MapType = "接线图"; } catch (Exception e2) { MapType = "接线图"; } } if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1) { return; } decimal ViewScale = 1; string str_Scale = tlVectorControl1.SVGDocument.getViewScale(); if (str_Scale != "") { ViewScale = Convert.ToDecimal(str_Scale); } if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") { string IsArea = ((XmlElement)e.SvgElement).GetAttribute("IsArea"); if (IsArea != "") { XmlElement n1 = (XmlElement)e.SvgElement; string str_points = n1.GetAttribute("points"); string[] points = str_points.Split(",".ToCharArray()); PointF[] pnts = new PointF[points.Length]; for (int i = 0; i < points.Length; i++) { string[] pointsXY = points[i].Split(" ".ToCharArray()); pnts[i].X = Convert.ToSingle(pointsXY[0]); pnts[i].Y = Convert.ToSingle(pointsXY[1]); } decimal temp1 = TLMath.getPolygonArea(pnts, 1); temp1 = TLMath.getNumber2(temp1, tlVectorControl1.ScaleRatio); SelUseArea = temp1.ToString("#####.####"); //tip.Text = "区域面积:" + SelUseArea; if (SelUseArea != "") { if (Convert.ToDecimal(SelUseArea) >= 1) { fInfo.Info = "区域面积:" + SelUseArea + "(KM²)"; } else { fInfo.Info = "区域面积: 0" + SelUseArea + "(KM²)"; } } fInfo.Top = e.Mouse.Y; fInfo.Left = e.Mouse.X; fInfo.Width = (fInfo.Info.Length) * 12; if (SelUseArea != "") { fInfo.Show(); } //tip.ShowToolTip(); } } if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Line") { string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead"); if (IsLead != "") { Line line = (Line)e.SvgElement; decimal temp1 = TLMath.getLineLength(line, 1); temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio); string len = temp1.ToString("#####.####"); LineLen = len; LineInfo lineInfo = new LineInfo(); lineInfo.EleID = e.SvgElement.ID; lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; LineInfo _lineTemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", lineInfo); if ((len != "") && (_lineTemp != null)) { if (Convert.ToDecimal(len) >= 1) { fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3; } else { fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3; } } else if (len != "") { if (Convert.ToDecimal(len) >= 1) { fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " "; } else { fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " "; } } fInfo.Top = e.Mouse.Y; fInfo.Left = e.Mouse.X; fInfo.Width = (fInfo.Info.Length) * 7; fInfo.Height = 50; if (len != "") { fInfo.Show(); } } } if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") { string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead"); if (IsLead != "") { Polyline polyline = (Polyline)e.SvgElement; decimal temp1 = TLMath.getPolylineLength(polyline, 1); temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio); string len = temp1.ToString("#####.####"); LineLen = len; LineInfo lineInfo = new LineInfo(); lineInfo.EleID = e.SvgElement.ID; lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; LineInfo _lineTemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", lineInfo); if ((len != "") && (_lineTemp != null)) { if (Convert.ToDecimal(len) >= 1) { fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3; } else { fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3; } } else if (len != "") { if (Convert.ToDecimal(len) >= 1) { fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " "; } else { fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " "; } } fInfo.Top = e.Mouse.Y; fInfo.Left = e.Mouse.X; fInfo.Width = (fInfo.Info.Length) * 7; fInfo.Height = 50; //fInfo.Right = fInfo.Left+fInfo.Info.Length*10; if (len != "") { fInfo.Show(); } } } if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Use") { string aaa = ((Use)e.SvgElement).RefElement.ID; //if (!aaa.Contains("Substation")) //{ // return; //} string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead"); if (aaa.Contains("Substation")) { substation sub = new substation(); sub.EleID = e.SvgElement.ID; sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; substation _subTemp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", sub); if (_subTemp != null) { fInfo.Info = "变电站名称:" + _subTemp.EleName + " 容量:" + _subTemp.Number + "MVA\r\n" + " 电压等级:" + _subTemp.ObligateField1 + "kV 最大负荷:" + _subTemp.Burthen + "MW \r\n 负荷率:" + _subTemp.ObligateField2 + " 投产年限:" + _subTemp.ObligateField5; } else { fInfo.Info = "变电站名称:" + " " + " 容量:0" + "MVA" + "\r\n 电压等级: 最大负荷: \r\n 负荷率: 投产年限:"; } fInfo.Top = e.Mouse.Y; fInfo.Left = e.Mouse.X; fInfo.Width = (fInfo.Info.Length) * 5; fInfo.Height = 60; fInfo.Show(); } if (aaa.Contains("kbs") || aaa.Contains("fjx") || aaa.Contains("byq")) { string s_name = ""; if (aaa.Contains("kbs")) { s_name = "开闭所"; } if (aaa.Contains("fjx")) { s_name = "分接箱"; } if (aaa.Contains("byq")) { s_name = "变压器"; } PSP_Gra_item sub = new PSP_Gra_item(); sub.EleID = e.SvgElement.ID; sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; sub.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; PSP_Gra_item _subTemp = (PSP_Gra_item)Services.BaseService.GetObject("SelectPSP_Gra_itemByEleIDKey", sub); if (_subTemp != null) { fInfo.Info = s_name + "编号:" + _subTemp.EleKeyID + "\r\n 名称:" + _subTemp.EleName; } else { fInfo.Info = s_name + "编号: \r\n 名称: "; } fInfo.Top = e.Mouse.Y; fInfo.Left = e.Mouse.X; fInfo.Width = (fInfo.Info.Length) * 8; fInfo.Height = 60; fInfo.Show(); } } if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") { ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.CurrentElement; if (cline.StartGraph != null) { string code = ((XmlElement)cline.StartGraph).GetAttribute("devxldm"); if (code != "") { xltProcessor.SelectLine(code); tlVectorControl1.CurrentOperation = ToolOperation.Select; } } } /* if (tlVectorControl1.Operation == ToolOperation.LeadLine) { string gt = sgt1.Text; XmlElement u1 = tlVectorControl1.SVGDocument.CreateElement("use") as Use; Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y)); u1.SetAttribute("xlink:href", "#" + gt + "0"); u1.SetAttribute("x", point1.X.ToString()); u1.SetAttribute("y", point1.Y.ToString()); u1.SetAttribute("layer", SvgDocument.currentLayer); u1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); tlVectorControl1.SVGDocument.RootElement.AppendChild(u1); }*/ //tlVectorControl1.SVGDocument.CurrentElement = null; }
private void ShowTriangle1(ArrayList _polylist, XmlElement _poly) { try { Dictionary<XmlElement, PointF> fhkcollect = new Dictionary<XmlElement, PointF>(); PointF fhcenter = new PointF(); string aaa = yearID; if (D_TIN.DS.VerticesNum > 2) //构建三角网 D_TIN.CreateTIN(); //输出三角形 for (int i = 0; i < D_TIN.DS.TriangleNum; i++) { Point point1 = new Point(Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V1Index].x), Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V1Index].y)); Point point2 = new Point(Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V2Index].x), Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V2Index].y)); Point point3 = new Point(Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V3Index].x), Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V3Index].y)); string str_points = ""; str_points = point1.X.ToString() + " " + point1.Y.ToString() + "," + point2.X.ToString() + " " + point2.Y.ToString() + "," + point3.X.ToString() + " " + point3.Y.ToString(); //XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as XmlElement; //e1.SetAttribute("points", str_points); //e1.SetAttribute("style", "stroke-width:1;stroke:#0000FF;stroke-opacity:1;"); //e1.SetAttribute("IsTin", "1"); //e1.SetAttribute("layer", SvgDocument.currentLayer); //tlVectorControl1.SVGDocument.RootElement.AppendChild(e1); } D_TIN.CalculateBC(); D_TIN.CreateVoronoi(); ArrayList CirList = new ArrayList(); ArrayList polyCentriodList = new ArrayList(); for (int n = 0; n < D_TIN.DS.Barycenters.Length; n++) { Barycenter bar = D_TIN.DS.Barycenters[n]; if (bar.X == 0 && bar.Y == 0) { break; } Triangle tri = D_TIN.DS.Triangle[n]; Vertex ver = D_TIN.DS.Vertex[tri.V1Index]; Vertex ver2 = D_TIN.DS.Vertex[tri.V2Index]; Vertex ver3 = D_TIN.DS.Vertex[tri.V3Index]; Decimal r = Convert.ToDecimal(Math.Abs(Math.Sqrt(Math.Pow(Convert.ToDouble(ver.x - bar.X), 2.0) + Math.Pow(Convert.ToDouble(ver.y - bar.Y), 2.0)))); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle; n1.SetAttribute("cx", bar.X.ToString()); n1.SetAttribute("cy", bar.Y.ToString()); n1.SetAttribute("r", r.ToString()); n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;"); //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); CirList.Add(n1); PointF[] Flist = new PointF[3]; Flist[0] = new PointF(ver.x, ver.y); Flist[1] = new PointF(ver2.x, ver2.y); Flist[2] = new PointF(ver3.x, ver3.y); polyCentriodList.Add(TLMath.polyCentriod(Flist)); } System.Collections.SortedList clist = new SortedList(); System.Collections.SortedList CtoFHlist = new SortedList(); decimal sum = 0; for (int n = 0; n < CirList.Count; n++) { fhkcollect = new Dictionary<XmlElement, PointF>(); int k = 0; Circle cir = (Circle)CirList[n]; GraphicsPath gr1 = new GraphicsPath(); gr1.AddPath(cir.GPath, true); gr1.CloseFigure(); for (int m = 0; m < _polylist.Count; m++) { XmlElement _x = (XmlElement)_polylist[m]; PointF _f = TLMath.polyCentriod(_x); if (gr1.IsVisible(_f)) //外接圆包括那些负荷中心点 { k = k + 1; //求和的过程 string sid = _x.GetAttribute("id"); glebeProperty pl = new glebeProperty(); pl.EleID = sid; pl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; pl = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", pl); if (pl != null) { sum = sum + pl.Burthen; } fhkcollect.Add(_x, _f);//记录外包圆相交的负荷块 } } clist.Add(sum + n, cir); CtoFHlist.Add(sum + n, fhkcollect); string aa = ""; } string str_sub = getSubName(str_dy); for (int k = 0; k < Convert.ToInt32(str_num); k++) { GraphicsPath gr1 = new GraphicsPath(); gr1.AddPolygon(TLMath.getPolygonPoints(_poly)); gr1.CloseFigure(); Circle c1 = clist.GetByIndex(k) as Circle; Dictionary<XmlElement, PointF> FHandPointF = CtoFHlist.GetByIndex(k) as Dictionary<XmlElement, PointF>; PointF pf = TLMath.getUseOffset(str_sub); float X = 0f; float Y = 0f; float ox = 0f; float oy = 0f; if (gr1.IsVisible(new PointF(c1.CX, c1.CY))) { X = c1.CenterPoint.X - pf.X; Y = c1.CenterPoint.Y - pf.Y; ox = c1.CenterPoint.X + 8; oy = c1.CenterPoint.Y; } else { X = ((PointF)polyCentriodList[k]).X - pf.X; Y = ((PointF)polyCentriodList[k]).Y - pf.Y; ox = ((PointF)polyCentriodList[k]).X + 8; oy = ((PointF)polyCentriodList[k]).Y; } XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement; e1.SetAttribute("x", Convert.ToString(X)); e1.SetAttribute("y", Convert.ToString(Y)); e1.SetAttribute("xzflag", "1"); e1.SetAttribute("xlink:href", str_sub); e1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); e1.SetAttribute("layer", SvgDocument.currentLayer); SubandFHcollect _subandfh = new SubandFHcollect(FHandPointF, e1); tlVectorControl1.SVGDocument.RootElement.AppendChild(e1); tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e1); XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t1.SetAttribute("x", Convert.ToString(ox)); t1.SetAttribute("y", Convert.ToString(oy)); t1.SetAttribute("layer", SvgDocument.currentLayer); t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t1.SetAttribute("font-famliy", "宋体"); t1.SetAttribute("font-size", "54"); t1.InnerText = Convert.ToString(k + 1) + "号"; tlVectorControl1.SVGDocument.RootElement.AppendChild(t1); decimal temp1 = TLMath.getNumber((decimal)c1.R, tlVectorControl1.ScaleRatio); //MessageBox.Show(temp1.ToString()); if (Convert.ToDecimal(str_jj) > temp1) { MessageBox.Show(Convert.ToString(k + 1) + "号变电站候选站址小于最小供电半径,请手动进行调整。"); } PSP_SubstationSelect s = new PSP_SubstationSelect(); s.UID = Guid.NewGuid().ToString(); s.EleID = t1.GetAttribute("id"); s.SName = Convert.ToString(k + 1) + "号"; s.Remark = ""; s.col2 = XZ_bdz; s.SvgID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<PSP_SubstationSelect>(s); CreateSubline(_subandfh); //生成负荷中心与变电站的连接线 } } catch (Exception e1) { } }
public void Fhbz() { XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("//*[@IsArea=\"1\"]"); Layer oldLar = getlayer("负荷标注", tlVectorControl1.SVGDocument.getLayerList()); if (oldLar != null) { XmlNodeList oldList = tlVectorControl1.SVGDocument.SelectNodes("//*[@layer=\"" + oldLar.ID + "\"]"); for (int i = 0; i < oldList.Count; i++) { tlVectorControl1.SVGDocument.RootElement.RemoveChild((SvgElement)oldList[i]); } tlVectorControl1.SVGDocument.GetElementsByTagName("defs")[0].RemoveChild(oldLar); //tlVectorControl1.SVGDocument.RootElement.RemoveChild(oldLar); } Layer zjLar = Layer.CreateNew("负荷标注", tlVectorControl1.SVGDocument); zjLar.SetAttribute("layerType", "城市规划层"); for (int i = 0; i < list.Count; i++) { IGraph graph1 = (IGraph)list[i]; RectangleF rect = graph1.GetBounds(); glebeProperty gle = new glebeProperty(); gle.EleID = graph1.ID; gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; gle = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", gle); if (gle != null) { XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; //Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y)); n1.SetAttribute("x", Convert.ToString(rect.X + rect.Width / 2)); n1.SetAttribute("y", Convert.ToString(rect.Y + rect.Height / 2)); n1.SetAttribute("font-famliy", "宋体"); n1.SetAttribute("font-size", "14"); n1.InnerText = gle.Burthen.ToString(); n1.SetAttribute("layer", zjLar.ID); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); } } frmlar.SymbolDoc = tlVectorControl1.SVGDocument; frmlar.InitData(); tlVectorControl1.Refresh(); }
void tlVectorControl1_LeftClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e) { //SvgElement ele2 = tlVectorControl1.CreateBySymbolID("kbs-8", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location))); //ele2 = tlVectorControl1.AddShape(ele2, Point.Empty); if (tlVectorControl1.SVGDocument.CurrentElement != null && tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("xlink:href").Contains("XL_GT_1")) { sel_start_point = tlVectorControl1.SVGDocument.CurrentElement.ID; } if (sel_sym == "bt_start") { SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_1", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location))); ele = tlVectorControl1.AddShape(ele, Point.Empty); ele.SetAttribute("order", "0"); ele.SetAttribute("start_point", ele.ID); } if (sel_sym == "bt_end") { SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_2", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location))); ele.SetAttribute("start_point", sel_start_point); ele.SetAttribute("order", "999"); tlVectorControl1.AddShape(ele, Point.Empty); } if (sel_sym == "bt_must") { SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_3", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location))); ele.SetAttribute("start_point", sel_start_point); tlVectorControl1.AddShape(ele, Point.Empty); frmInputNum num = new frmInputNum(); num.ShowDialog(); ele.SetAttribute("order", num.InputStrSEL); } if (sel_sym == "bt_point") { SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_4", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location))); ele.SetAttribute("start_point", sel_start_point); tlVectorControl1.AddShape(ele, Point.Empty); frmInputNum num = new frmInputNum(); num.ShowDialog(); ele.SetAttribute("order", num.InputStrSEL); } //if (sel_sym != "" && sel_start_point!="") //{ // XmlNodeList il= tlVectorControl1.SVGDocument.SelectNodes("svg/use [@start_point='" + sel_start_point + "']"); // if (il.Count < 3) // { // return; // } // for (int i = 0; i < il.Count;i++ ) // { // Use u = (Use)il[i]; // PointF f = u.CenterPoint; // } // //PointF[] pnt = ((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)).Points; // //if (pnt.Length < 3) return; // for (int i = 0; i < il.Count; i++) // { // double ang = TLMath.getLineAngle(((Use)il[i]).CenterPoint, ((Use)il[i + 1]).CenterPoint, ((Use)il[i + 2]).CenterPoint); // if (ang * 57.3 > 60) // { // MessageBox.Show("线路转角不能大于60度。\r\n "+"第" + (i + 1) + "转角:" + Convert.ToDouble(ang * 57.3).ToString("##.##") + "度。\r\n", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // // tlVectorControl1.Delete(); // return; // } // if (i == il.Count - 3) // { // break; // } // } //} if (csOperation == CustomOperation.OP_MeasureDistance) { Polyline pl = tlVectorControl1.SVGDocument.CurrentElement as Polyline; if (pl.Points.Length > 1) { double d = 0; for (int i = 1; i < pl.Points.Length; i++) { d += this.mapview.CountLength(pl.Points[i - 1], pl.Points[i]); } label1.Text = Math.Round(d, 3) + "公里"; Point pt = new Point(e.Mouse.X, e.Mouse.Y); pt = PointToClient(tlVectorControl1.PointToScreen(pt)); //tlVectorControl1.SetToolTip(label1.Text); label1.Left = pt.X; label1.Top = pt.Y; label1.Visible = true; } return; } tip.Hide(); fInfo.Hide(); 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; Point point1 = tlVectorControl1.PointToView(new 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; } } if (MapType == "规划统计") { try { if (e.SvgElement.ID == "svg") { MapType = "接线图"; return; } if (((Polygon)e.SvgElement) == null) return; XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle; Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y)); n1.SetAttribute("cx", point1.X.ToString()); n1.SetAttribute("cy", point1.Y.ToString()); n1.SetAttribute("r", "42.5"); n1.SetAttribute("r", "42.5"); //n1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID); n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); frmMainProperty fmain = new frmMainProperty(); glebeProperty gp = new glebeProperty(); gp.EleID = ((XmlElement)e.SvgElement).GetAttribute("id"); gp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; //fmain.InitData(gp); /////////////////////////////////// XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("use"); PointF[] tfArray1 = TLMath.getPolygonPoints((XmlElement)e.SvgElement); string str220 = ""; string str110 = ""; string str66 = ""; GraphicsPath selectAreaPath = new GraphicsPath(); selectAreaPath.AddLines(tfArray1); selectAreaPath.CloseFigure(); //Matrix x=new Matrix( //Region region1 = new Region(selectAreaPath); for (int i = 0; i < nlist.Count; i++) { float OffX = 0f; float OffY = 0f; Use use = (Use)nlist[i]; if (use.GetAttribute("xlink:href").Contains("Substation")) { string strMatrix = use.GetAttribute("transform"); if (strMatrix != "") { strMatrix = strMatrix.Replace("matrix(", ""); strMatrix = strMatrix.Replace(")", ""); string[] mat = strMatrix.Split(','); if (mat.Length > 5) { OffX = Convert.ToSingle(mat[4]); OffY = Convert.ToSingle(mat[5]); } } PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href")); if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY)) { if (use.GetAttribute("xlink:href").Contains("220")) { str220 = str220 + "'" + use.GetAttribute("id") + "',"; } if (use.GetAttribute("xlink:href").Contains("110")) { str110 = str110 + "'" + use.GetAttribute("id") + "',"; } if (use.GetAttribute("xlink:href").Contains("66")) { str66 = str66 + "'" + use.GetAttribute("id") + "',"; } } } } if (str220.Length > 1) { str220 = str220.Substring(0, str220.Length - 1); } if (str110.Length > 1) { str110 = str110.Substring(0, str110.Length - 1); } if (str66.Length > 1) { str66 = str66.Substring(0, str66.Length - 1); } fmain.InitData(gp, str220, str110, str66); XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; Point point2 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y)); t1.SetAttribute("x", Convert.ToString(point2.X - 20)); t1.SetAttribute("y", Convert.ToString(point2.Y - 10)); // t1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID); t1.SetAttribute("layer", SvgDocument.currentLayer); t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t1.SetAttribute("font-famliy", "宋体"); t1.SetAttribute("font-size", "14"); t1.InnerText = fmain.glebeProp.Area + "\r\n" + fmain.glebeProp.Burthen; //+"\r\n" + fmain.glebeProp.Number; tlVectorControl1.SVGDocument.RootElement.AppendChild(t1); tlVectorControl1.Refresh(); fmain.Dispose(); MapType = "接线图"; } catch (Exception e2) { MapType = "接线图"; } } if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1) { return; } decimal ViewScale = 1; string str_Scale = tlVectorControl1.SVGDocument.getViewScale(); if (str_Scale != "") { ViewScale = Convert.ToDecimal(str_Scale); } if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Text") { string showlineflag = ((XmlElement)e.SvgElement).GetAttribute("Showline"); if (showlineflag == "1") { XmlElement n1 = (XmlElement)e.SvgElement; string suid = n1.GetAttribute("ParentID"); PSPDEV psp = new PSPDEV(); psp.SUID = suid; psp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", psp); if (psp != null) { fInfo.Info = "线路名称:" + psp.Name; } fInfo.Top = e.Mouse.Y; fInfo.Left = e.Mouse.X; fInfo.Width = (fInfo.Info.Length) * 20; fInfo.Show(); } } if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") { string IsArea = ((XmlElement)e.SvgElement).GetAttribute("IsArea"); if (IsArea != "") { SelUseArea = ""; //XmlElement n1 = (XmlElement)e.SvgElement; PointF[] pnts = ((Polygon)e.SvgElement).Points.Clone() as PointF[]; ((Polygon)e.SvgElement).Transform.Matrix.TransformPoints(pnts); decimal temp1 = TLMath.getPolygonArea(pnts, 1); temp1 = TLMath.getNumber2(temp1, tlVectorControl1.ScaleRatio) / Convert.ToDecimal(areaoption); SelUseArea = temp1.ToString("#####.####"); //tip.Text = "区域面积:" + SelUseArea; if (SelUseArea != "") { if (Convert.ToDecimal(SelUseArea) >= 1) { fInfo.Info = "区域面积:" + SelUseArea + "(KM²)"; } else { fInfo.Info = "区域面积: 0" + SelUseArea + "(KM²)"; } } fInfo.Top = e.Mouse.Y; fInfo.Left = e.Mouse.X; fInfo.Width = (fInfo.Info.Length) * 12; if (SelUseArea != "") { fInfo.Show(); } //tip.ShowToolTip(); } } if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Line") { string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead"); if (IsLead != "") { Line line = (Line)e.SvgElement; decimal temp1 = TLMath.getLineLength(line, 1); temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio); string len = temp1.ToString("#####.####"); LineLen = len; LineInfo lineInfo = new LineInfo(); lineInfo.EleID = e.SvgElement.ID; lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; LineInfo _lineTemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", lineInfo); if ((len != "") && (_lineTemp != null)) { if (Convert.ToDecimal(len) >= 1) { fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3; } else { fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3; } } else if (len != "") { if (Convert.ToDecimal(len) >= 1) { fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " "; } else { fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " "; } } fInfo.Top = e.Mouse.Y; fInfo.Left = e.Mouse.X; fInfo.Width = (fInfo.Info.Length) * 7; fInfo.Height = 50; if (len != "") { fInfo.Show(); } } } if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline" && str_outjwd == "1") { PointF[] pf = ((Polyline)e.SvgElement).Points; ((Polyline)e.SvgElement).Transform.Matrix.TransformPoints(pf); string strM = ""; for (int i = 0; i < pf.Length; i++) { strM = strM + getJWD(mapview.ParseToLongLat(pf[i].X, pf[i].Y)); } System.IO.FileInfo ff = new System.IO.FileInfo("c:\\temp.txt"); System.IO.StreamWriter wt = ff.CreateText(); wt.Write(strM); wt.Close(); System.Diagnostics.Process.Start("c:\\temp.txt"); } if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline" && str_djcl == "1") { Layer lar = null; Layer lar2 = null; bool create = true; int TempObjRadius = Convert.ToInt32(ConfigurationSettings.AppSettings.Get("TempObjRadius")); int TempTextSize = Convert.ToInt32(ConfigurationSettings.AppSettings.Get("TempTextSize")); for (int n = 0; n < tlVectorControl1.SVGDocument.Layers.Count; n++) { Layer l = tlVectorControl1.SVGDocument.Layers[n] as Layer; if (l.Label == "临时显示层-杆塔号") { lar = l; } if (l.Label == "临时显示层-公里数") { lar2 = l; } } if (!Layer.CkLayerExist("临时显示层-杆塔号", tlVectorControl1.SVGDocument)) { lar = Layer.CreateNew("临时显示层-杆塔号", tlVectorControl1.SVGDocument); lar.SetAttribute("layerType", progtype); lar.SetAttribute("ParentID", tlVectorControl1.SVGDocument.CurrentLayer.GetAttribute("ParentID")); this.frmlar.checkedListBox1.SelectedIndex = -1; this.frmlar.checkedListBox1.Items.Add(lar, true); lar2 = Layer.CreateNew("临时显示层-公里数", tlVectorControl1.SVGDocument); lar2.SetAttribute("layerType", progtype); lar2.SetAttribute("ParentID", tlVectorControl1.SVGDocument.CurrentLayer.GetAttribute("ParentID")); this.frmlar.checkedListBox1.SelectedIndex = -1; this.frmlar.checkedListBox1.Items.Add(lar2, true); } string gt = ((XmlElement)e.SvgElement).GetAttribute("gt-info"); string _gtxh = ((XmlElement)e.SvgElement).GetAttribute("gtxh-info"); string[] gtid = gt.Split(",".ToCharArray()); string[] strgtxh = _gtxh.Split(",".ToCharArray()); XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("//* [@layer='" + lar.ID + "'] [@parentobj='" + ((Polyline)e.SvgElement).ID + "']"); for (int kk = 0; kk < useList.Count; kk++) { tlVectorControl1.SVGDocument.RootElement.RemoveChild(useList[kk]); } PointF[] pf = ((Polyline)e.SvgElement).Points; ((Polyline)e.SvgElement).Transform.Matrix.TransformPoints(pf); if (create) { for (int i = 0; i < pf.Length; i++) { if (_gtxh == "") { XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle; n1.SetAttribute("cx", Convert.ToString(pf[i].X)); n1.SetAttribute("cy", Convert.ToString(pf[i].Y)); n1.SetAttribute("r", TempObjRadius.ToString()); n1.SetAttribute("layer", lar.ID); n1.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID); n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); } else { if (strgtxh.Length > i) { if (strgtxh[i] == "0") { XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle; n1.SetAttribute("cx", Convert.ToString(pf[i].X)); n1.SetAttribute("cy", Convert.ToString(pf[i].Y)); n1.SetAttribute("r", TempObjRadius.ToString()); n1.SetAttribute("layer", lar.ID); n1.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID); n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); } else { XmlElement tk = tlVectorControl1.SVGDocument.CreateElement("rect") as RectangleElement; tk.SetAttribute("x", Convert.ToString(pf[i].X - 10)); tk.SetAttribute("y", Convert.ToString(pf[i].Y - 10)); tk.SetAttribute("width", Convert.ToString(TempObjRadius * 2)); tk.SetAttribute("height", Convert.ToString(TempObjRadius * 2)); tk.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID); tk.SetAttribute("style", "fill:#FFFFC0;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); tk.SetAttribute("layer", lar.ID); tlVectorControl1.SVGDocument.RootElement.AppendChild(tk); } } } XmlElement t0 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t0.SetAttribute("x", Convert.ToString(pf[i].X)); t0.SetAttribute("y", Convert.ToString(pf[i].Y)); t0.SetAttribute("layer", lar.ID); t0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t0.SetAttribute("font-famliy", "宋体"); t0.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID); t0.SetAttribute("font-size", TempTextSize.ToString()); if (gtid.Length > i) { t0.InnerText = gtid[i] + "号"; } else { t0.InnerText = Convert.ToString(i + 1) + "号"; } tlVectorControl1.SVGDocument.RootElement.AppendChild(t0); } for (int i = 0; i < pf.Length - 1; i++) { double s = this.mapview.CountLength(pf[i], pf[i + 1]); // TLMath.getLength(pf[i], pf[i + 1], (decimal)tlVectorControl1.ScaleRatio); XmlElement t0 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t0.SetAttribute("x", Convert.ToString((pf[i].X + pf[i + 1].X) / 2)); t0.SetAttribute("y", Convert.ToString((pf[i].Y + pf[i + 1].Y) / 2)); t0.SetAttribute("layer", lar2.ID); t0.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID); t0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t0.SetAttribute("font-famliy", "宋体"); t0.SetAttribute("font-size", TempTextSize.ToString()); t0.InnerText = s.ToString("0.##") + "km"; tlVectorControl1.SVGDocument.RootElement.AppendChild(t0); } } str_djcl = ""; } if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") { string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead"); if (IsLead != "") { Polyline polyline = (Polyline)e.SvgElement; double temp1 = 0; for (int i = 1; i < polyline.Points.Length; i++) { temp1 += this.mapview.CountLength(polyline.Points[i - 1], polyline.Points[i]); } //decimal temp1 = TLMath.getPolylineLength(polyline, 1); //temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio); string len = temp1.ToString("#####.####"); LineLen = len; PSPDEV lineInfo = new PSPDEV(); lineInfo.SUID = ((XmlElement)e.SvgElement).GetAttribute("Deviceid"); // lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; PSPDEV _lineTemp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", lineInfo); if ((len != "") && (_lineTemp != null)) { if (Convert.ToDecimal(len) >= 1) { fInfo.Info = "线路名称:" + _lineTemp.Name + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.RateVolt.ToString() + "kV 投产年限:" + _lineTemp.OperationYear; } else { fInfo.Info = "线路名称:" + _lineTemp.Name + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.RateVolt.ToString() + "kV 投产年限:" + _lineTemp.OperationYear; } } else if (len != "") { if (Convert.ToDecimal(len) >= 1) { fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " "; } else { fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " "; } } fInfo.Top = e.Mouse.Y; fInfo.Left = e.Mouse.X; fInfo.Width = (fInfo.Info.Length) * 7; fInfo.Height = 50; //fInfo.Right = fInfo.Left+fInfo.Info.Length*10; if (len != "") { fInfo.Show(); } } } if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Use") { string aaa = ((Use)e.SvgElement).RefElement.ID; //if (!aaa.Contains("Substation")) //{ // return; //} string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead"); if (aaa.Contains("Substation")) { PSP_Substation_Info sub = new PSP_Substation_Info(); string deviceid = ((XmlElement)e.SvgElement).GetAttribute("Deviceid"); //sub.AreaID = tlVectorControl1.SVGDocument.SvgdataUid; PSP_Substation_Info _subTemp = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid); // PSP_Substation_Info _subTemp = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoListByEleID", sub); if (_subTemp != null) { fInfo.Info = "变电站名称:" + _subTemp.Title + " 容量:" + _subTemp.L2.ToString("##.##") + "MVA\r\n" + " 电压等级:" + _subTemp.L1.ToString("##.##") + "kV 最大负荷:" + _subTemp.L9.ToString("##.##") + "MW \r\n 投产年限:" + _subTemp.S2; } else { fInfo.Info = "变电站名称:" + " " + " 容量:0" + "MVA" + "\r\n 电压等级: 最大负荷: \r\n 负荷率: 投产年限:"; } fInfo.Top = e.Mouse.Y; fInfo.Left = e.Mouse.X; fInfo.Width = (fInfo.Info.Length) * 5; fInfo.Height = 60; fInfo.Show(); } if (aaa.Contains("kbs") || aaa.Contains("fjx") || aaa.Contains("pds") || aaa.Contains("byq") || aaa.Contains("hwg") || aaa.Contains("kg")) { string deviceid = ((XmlElement)e.SvgElement).GetAttribute("Deviceid"); string s_name = ""; if (aaa.Contains("kbs")) { s_name = "开闭所"; } if (aaa.Contains("fjx")) { s_name = "分接箱"; } if (aaa.Contains("byq")) { s_name = "变压器"; } if (aaa.Contains("hwg")) { s_name = "环网柜"; } if (aaa.Contains("kg")) { s_name = "柱上开关"; } if (aaa.Contains("pds")) { s_name = "配电室"; } PSPDEV _subTemp = new PSPDEV(); _subTemp.SUID = deviceid; _subTemp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", _subTemp); //PSP_Gra_item sub = new PSP_Gra_item(); //sub.EleID = e.SvgElement.ID; //sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; //sub.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; //PSP_Gra_item _subTemp = (PSP_Gra_item)Services.BaseService.GetObject("SelectPSP_Gra_itemByEleIDKey", sub); if (_subTemp != null) { fInfo.Info = s_name + " 编号:" + _subTemp.EleID + " 名称:" + _subTemp.Name + " 电压等级:" + _subTemp.RateVolt + "kV"; } else { fInfo.Info = s_name; // +"编号: \r\n 名称: "; } fInfo.Top = e.Mouse.Y; fInfo.Left = e.Mouse.X; fInfo.Width = (fInfo.Info.Length) * 15; fInfo.Height = 60; fInfo.Show(); } } if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") { ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.CurrentElement; if (cline.StartGraph != null) { string code = ((XmlElement)cline.StartGraph).GetAttribute("devxldm"); if (code != "") { xltProcessor.SelectLine(code); tlVectorControl1.CurrentOperation = ToolOperation.Select; } } } /* if (tlVectorControl1.Operation == ToolOperation.LeadLine) { string gt = sgt1.Text; XmlElement u1 = tlVectorControl1.SVGDocument.CreateElement("use") as Use; Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y)); u1.SetAttribute("xlink:href", "#" + gt + "0"); u1.SetAttribute("x", point1.X.ToString()); u1.SetAttribute("y", point1.Y.ToString()); u1.SetAttribute("layer", SvgDocument.currentLayer); u1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); tlVectorControl1.SVGDocument.RootElement.AppendChild(u1); }*/ //tlVectorControl1.SVGDocument.CurrentElement = null; }
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (tlVectorControl1.SVGDocument.RootElement == null) { return; } XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement; if (xml1 != null) { if (e.ClickedItem.Text == "属性") { if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList()/*"layer24288"*/)) { if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } /* if (xml1.GetType().ToString() == "ItopVector.Core.Figure.Polygon") { //string IsArea = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsArea"); //if (IsArea != "") //{ glebeProperty _gle = new glebeProperty(); _gle.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID; _gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle); if (UseProList.Count > 0) { _gle = UseProList[0]; frmMainProperty f = new frmMainProperty(); XmlNodeList n1 = tlVectorControl1.SVGDocument.GetElementsByTagName("use"); PointF[] tfArray1 = TLMath.getPolygonPoints(xml1); string str220 = ""; string str110 = ""; string str66 = ""; GraphicsPath selectAreaPath = new GraphicsPath(); selectAreaPath.AddLines(tfArray1); selectAreaPath.CloseFigure(); //Matrix x=new Matrix( //Region region1 = new Region(selectAreaPath); for (int i = 0; i < n1.Count; i++) { float OffX = 0f; float OffY = 0f; bool ck = false; Use use = (Use)n1[i]; if (use.GetAttribute("xlink:href").Contains("Substation")) { string strMatrix = use.GetAttribute("transform"); if (strMatrix != "") { strMatrix = strMatrix.Replace("matrix(", ""); strMatrix = strMatrix.Replace(")", ""); string[] mat = strMatrix.Split(','); if (mat.Length > 5) { OffX = Convert.ToSingle(mat[4]); OffY = Convert.ToSingle(mat[5]); } } if (frmlar.getSelectedLayer().Contains(use.GetAttribute("layer"))) { ck = true; } PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href")); if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY) && ck) { if (use.GetAttribute("xlink:href").Contains("220")) { str220 = str220 + "'" + use.GetAttribute("id") + "',"; } if (use.GetAttribute("xlink:href").Contains("110")) { str110 = str110 + "'" + use.GetAttribute("id") + "',"; } if (use.GetAttribute("xlink:href").Contains("66")) { str66 = str66 + "'" + use.GetAttribute("id") + "',"; } } } } if (str220.Length > 1) { str220 = str220.Substring(0, str220.Length - 1); } if (str110.Length > 1) { str110 = str110.Substring(0, str110.Length - 1); } if (str66.Length > 1) { str66 = str66.Substring(0, str66.Length - 1); } f.InitData(_gle, str220, str110, str66); //////////////////////////////////////////////////// f.IsReadonly = true; f.ShowDialog(); } //} }*/ } if (getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())/*"layer97052"*/) { if (tlVectorControl1.SVGDocument.getRZBRatio() != "") { rzb = tlVectorControl1.SVGDocument.getRZBRatio(); } if (xml1.GetType().ToString() == "ItopVector.Core.Figure.Polygon") { string IsArea = xml1.GetAttribute("IsArea"); if (IsArea != "") { frmProperty f = new frmProperty(); f.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer); f.IsReadonly = true; f.ShowDialog(); } } } if (xml1 == null) return; if (xml1.GetType().ToString() == "ItopVector.Core.Figure.Line" || xml1.GetType().ToString() == "ItopVector.Core.Figure.Polyline") { string IsLead = xml1.GetAttribute("IsLead"); if (IsLead != "") { frmLineProperty fl = new frmLineProperty(); fl.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, LineLen, SvgDocument.currentLayer); fl.IsReadonly = true; fl.ShowDialog(); } } if (xml1.GetAttribute("xlink:href").Contains("Substation")) { string lab = xml1.GetAttribute("xlink:href"); frmSubstationProperty frmSub = new frmSubstationProperty(); frmSub.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SvgDocument.currentLayer, lab); frmSub.IsReadonly = true; frmSub.ShowDialog(); } if (tlVectorControl1.Operation == ToolOperation.InterEnclosure) { if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") { XmlNodeList n1 = tlVectorControl1.SVGDocument.GetElementsByTagName("use"); PointF[] tfArray1 = TLMath.getPolygonPoints(xml1); string str220 = ""; string str110 = ""; string str66 = ""; GraphicsPath selectAreaPath = new GraphicsPath(); selectAreaPath.AddLines(tfArray1); selectAreaPath.CloseFigure(); //Matrix x=new Matrix( //Region region1 = new Region(selectAreaPath); for (int i = 0; i < n1.Count; i++) { float OffX = 0f; float OffY = 0f; bool ck = false; Use use = (Use)n1[i]; if (use.GetAttribute("xlink:href").Contains("Substation")) { string strMatrix = use.GetAttribute("transform"); if (strMatrix != "") { strMatrix = strMatrix.Replace("matrix(", ""); strMatrix = strMatrix.Replace(")", ""); string[] mat = strMatrix.Split(','); if (mat.Length > 5) { OffX = Convert.ToSingle(mat[4]); OffY = Convert.ToSingle(mat[5]); } } if (frmlar.getSelectedLayer().Contains(use.GetAttribute("layer"))) { ck = true; } PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href")); if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY) && ck) { if (use.GetAttribute("xlink:href").Contains("220")) { str220 = str220 + "'" + use.GetAttribute("id") + "',"; } if (use.GetAttribute("xlink:href").Contains("110")) { str110 = str110 + "'" + use.GetAttribute("id") + "',"; } if (use.GetAttribute("xlink:href").Contains("66")) { str66 = str66 + "'" + use.GetAttribute("id") + "',"; } } } } if (str220.Length > 1) { str220 = str220.Substring(0, str220.Length - 1); } if (str110.Length > 1) { str110 = str110.Substring(0, str110.Length - 1); } if (str66.Length > 1) { str66 = str66.Substring(0, str66.Length - 1); } glebeProperty _gle = new glebeProperty(); _gle.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID; _gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle); if (UseProList.Count > 0) { _gle = UseProList[0]; _gle.LayerID = SvgDocument.currentLayer; frmMainProperty f = new frmMainProperty(); f.simpleButton4.Visible = false; f.InitData(_gle, str220, str110, str66); //f.InitData(_gle, str220, str110, str66); //////////////////////////////////////////////////// f.IsReadonly = true; f.ShowDialog(); //if (f.checkBox1.Checked == false) //{ tlVectorControl1.SVGDocument.RootElement.RemoveChild(tlVectorControl1.SVGDocument.CurrentElement); //} //tlVectorControl1.Refresh(); } //} } } tlVectorControl1.SVGDocument.CurrentElement = null; } if (e.ClickedItem.Text == "接线图") { pid = tlVectorControl1.SVGDocument.SvgdataUid; SVGFILE svg_temp = new SVGFILE(); svg_temp.SUID = xml1.GetAttribute("id"); IList svglist = Services.BaseService.GetList("SelectSVGFILEByKey", svg_temp); if (svglist.Count > 0) { svg_temp = (SVGFILE)svglist[0]; SvgDocument sdoc = new SvgDocument(); sdoc.LoadXml(svg_temp.SVGDATA); tlVectorControl1.SVGDocument = sdoc; tlVectorControl1.SVGDocument.SvgdataUid = svg_temp.SUID; MapType = "所内接线图"; } else { tlVectorControl1.NewFile(); tlVectorControl1.IsPasteGrid = false; tlVectorControl1.IsShowGrid = false; tlVectorControl1.IsShowRule = false; tlVectorControl1.IsShowTip = false; tlVectorControl1.SVGDocument.SvgdataUid = svg_temp.SUID; MapType = "所内接线图"; } if (tlVectorControl1.SVGDocument.getLayerList().Count == 0) { Layer _lar = ItopVector.Core.Figure.Layer.CreateNew("接线图", tlVectorControl1.SVGDocument); _lar.SetAttribute("layerType", "所内接线图"); _lar.Visible = true; SvgDocument.currentLayer = ((Layer)tlVectorControl1.SVGDocument.getLayerList()[0]).ID; } CreateComboBox(); ButtonEnb(true); LoadImage = false; bk1.Visible = false; selLar = ""; tlVectorControl1.Refresh(); } } }
private void simpleButton4_Click(object sender, EventArgs e) { int index = this.checkedListBox1.SelectedIndex; if (index > 0) { ArrayList layerlist1 = this.SymbolDoc.getLayerList(); string str1 = null; string str2 = null; foreach (Layer l in layerlist1) { if (l.Visible) { str1 += l.Label; str2 += l.Label + "��"; } } if (MessageBox.Show(this, "�˲������ϲ��ɼ�ͼ�㣺" + str2 + "���Ҳ��ɻָ����Ƿ������", "��ȷ��", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Layer layer = this.checkedListBox1.Items[index] as Layer; string str = layer.GetAttribute("layerType"); Layer layer2 = Layer.CreateNew(str1, this.SymbolDoc); if (ilist.Count > 0) { layer2.SetAttribute("ParentID", ilist[0].ToString()); } foreach (Layer layer1 in layerlist1) { if (layer1.Visible) { //foreach (SvgElement g in layer1.GraphList) //{ // layer2.GraphList.Add(g); //} this.SymbolDoc.NumberOfUndoOperations = (2 * layer1.GraphList.Count) + 200; SvgElementCollection sc = layer1.GraphList; for (int i = layer1.GraphList.Count - 1; i >= 0; i--) { SvgElement element = sc[i] as SvgElement; SvgElement temp = element.Clone() as SvgElement; IGraph graph = (IGraph)layer2.AddElement(temp); graph.Layer = layer2; PSPDEV _line = new PSPDEV(); _line.EleID = element.ID; _line.SvgUID = this.SymbolDoc.SvgdataUid; IList lineInfoList = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandEleID", _line); foreach (PSPDEV line in lineInfoList) { line.LayerID = layer2.ID; line.EleID = temp.ID; Services.BaseService.Update<PSPDEV>(line); } glebeProperty gle = new glebeProperty(); gle.EleID = element.ID; gle.SvgUID = this.SymbolDoc.SvgdataUid; IList gleProList = Services.BaseService.GetList("SelectglebePropertyByEleID", gle); foreach (glebeProperty gleP in gleProList) { gleP.LayerID = layer2.ID; gleP.EleID = temp.ID; Services.BaseService.Update("UpdateglebeProperty", gle); } PSP_Substation_Info _sub = new PSP_Substation_Info(); _sub.EleID = element.ID; _sub.AreaID = this.SymbolDoc.SvgdataUid; IList substationList = Services.BaseService.GetList("SelectPSP_Substation_InfoListByEleID", _sub); foreach (PSP_Substation_Info sub in substationList) { sub.LayerID = layer2.ID; sub.EleID = temp.ID; Services.BaseService.Update<PSP_Substation_Info>(sub); } } } } this.SymbolDoc.NotifyUndo(); layer2.SetAttribute("layerType", str); //layer2.Label = str1; this.checkedListBox1.Items.Add(layer2); layer2.Visible = false; foreach (Layer layer3 in layerlist1) { if (layer3.Visible) { DeleteLayer(layer3); } } } } }