// Methods public ArrowSelector() { this.endArrow = false; try { base.Items.Add("нч"); SvgDocument fadde1=new SvgDocument(); string filename = Path.GetDirectoryName(Assembly.GetAssembly(base.GetType()).Location)+"\\symbol\\arrow.xml"; if (File.Exists(filename)) { fadde1 = SvgDocumentFactory.CreateDocumentFromFile(filename); } else { ResourceManager manager1 = new ResourceManager(base.GetType()); fadde1.LoadXml(manager1.GetString("arrow")); } XmlNodeList list1 = fadde1.GetElementsByTagName("marker"); for (int num1 = 0; num1 < list1.Count; num1++) { XmlElement element1 = list1[num1] as XmlElement; if (element1 != null) { base.Items.Add(new Arrow((SvgElement)element1)); } } } catch (Exception exception1) { Console.Write(exception1.Message); } this.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; base.BorderStyle = BorderStyle.None; this.ItemHeight = 16; }
// Methods public ListViewEx() { this.endArrow = false; try { base.Items.Add("нч"); SvgDocument fadde1=new SvgDocument(); ResourceManager manager1 = new ResourceManager(base.GetType()); string text1 = manager1.GetString("arrow"); fadde1.LoadXml(text1); XmlNodeList list1 = fadde1.GetElementsByTagName("marker"); for (int num1 = 0; num1 < list1.Count; num1++) { XmlElement element1 = list1[num1] as XmlElement; if (element1 != null) { // base.Items.Add(new Arrow((SvgElement)element1)); } } text1 = null; } catch (Exception exception1) { Console.Write(exception1.Message); } this.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; base.BorderStyle = BorderStyle.None; // this.ItemHeight = 16; }
public static SvgDocument CreateDocument(SizeF size) { SvgDocument document1 = new SvgDocument(); string[] textArray1 = new string[9]; textArray1[0] = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"; // textArray1[1] = "\n<!--"+ItopVector.Core.Config.Config.GetLabelForName("createdstr")+"-->"; textArray1[2] = "\n<svg id=\"svg\" width=\""; int num1 = (int) size.Width; textArray1[3] = num1.ToString(); textArray1[4] = "\" height=\""; int num2 = (int) size.Height; textArray1[5] = num2.ToString(); textArray1[6] = "\" xmlns:xlink=\""+SvgDocument.XLinkNamespace; textArray1[7] = "\" xmlns:tonli=\""+SvgDocument.TonliNamespace; textArray1[8] = "\" >\n</svg>";//xml:space=\"preserve\" string text1 = string.Concat(textArray1); document1.PreserveWhitespace = true; document1.LoadXml(text1); return document1; }
public void Open(string _SvgUID) { try { SVGFILE svgFile = new SVGFILE(); svgFile.SUID = _SvgUID; SvgDocument document = new SvgDocument(); if (document != null) { IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile); if (svgList.Count > 0) { svgFile = (SVGFILE)svgList[0]; } document = new SvgDocument(); if (!string.IsNullOrEmpty(svgFile.SVGDATA)) { document.LoadXml(svgFile.SVGDATA); } document.FileName = svgFile.FILENAME; document.SvgdataUid = svgFile.SUID; } SVGUID = document.SvgdataUid; //this.Text = document.FileName; if (document.RootElement == null) { tlVectorControl1.NewFile(); tlVectorControl1.SVGDocument.SvgdataUid = _SvgUID; SvgDocument.currentLayer = Layer.CreateNew("默认层", tlVectorControl1.SVGDocument).ID; Layer la = tlVectorControl1.SVGDocument.GetLayerByID(SvgDocument.currentLayer); la.SetAttribute("layerType", "电网规划层"); } else { tlVectorControl1.SVGDocument = document; tlVectorControl1.SVGDocument.CurrentLayer = ((tlVectorControl1.SVGDocument.getLayerList()[0]) as ItopVector.Core.Figure.Layer); } tlVectorControl1.SVGDocument.SvgdataUid = SVGUID; tlVectorControl1.SVGDocument.FileName = this.Text; tlVectorControl1.DocumentbgColor = Color.White; tlVectorControl1.BackColor = Color.White; //XmlNodeList listUse = tlVectorControl1.SVGDocument.SelectNodes("svg/use"); //foreach (XmlNode node in listUse) //{ // PSP_ElcDevice elcDev = new PSP_ElcDevice(); // elcDev.DeviceSUID = (node as XmlElement).GetAttribute("Deviceid"); // elcDev.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid; // elcDev = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDev); // if(elcDev==null) // { // tlVectorControl1.SVGDocument.CurrentElement = node as SvgElement; // tlVectorControl1.Delete(); // XmlNodeList listFirstNode = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@FirstNode='" + (node as XmlElement).GetAttribute("id") + "']"); // XmlNodeList listLastNode = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@LastNode='" + (node as XmlElement).GetAttribute("id") + "']"); // foreach (XmlNode line in listFirstNode) // { // tlVectorControl1.SVGDocument.CurrentElement = line as SvgElement; // tlVectorControl1.Delete(); // } // foreach (XmlNode line in listLastNode) // { // tlVectorControl1.SVGDocument.CurrentElement = line as SvgElement; // tlVectorControl1.Delete(); // } // XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + (node as XmlElement).GetAttribute("id") + "']"); // tlVectorControl1.SVGDocument.CurrentElement = text as SvgElement; // tlVectorControl1.Delete(); // } //} try { string strCon = ",PSP_Substation_Info WHERE PSP_Substation_Info.UID=PSP_ELCDEVICE.DeviceSUID AND ProjectSUID ='" + tlVectorControl1.SVGDocument.SvgdataUid + "'"; //elcDev.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid; IList list = Services.BaseService.GetList("SelectPSP_ElcDeviceByCondition", strCon); foreach (PSP_ElcDevice elcDev in list) { XmlNode useDEV = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@SubstationID='" + elcDev.DeviceSUID + "']"); if (useDEV == null) { Services.BaseService.Delete<PSP_ElcDevice>(elcDev); } } } catch (System.Exception ex) { } } catch (Exception e) { MessageBox.Show(e.Message); } }
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": tlVectorControl2.NewFile(); break; case "mOpen": break; case "mImport": ExportImage(); //ImportDxf(); break; case "ImportDxf": ImportDxf(); break; case "btExSymbol": tlVectorControl2.ExportSymbol(); break; case "mSave": Save(); 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("C:\\a1.svg"); //tlVectorControl1.SVGDocument.SvgdataUid = aa; this.Close(); //frmAddLine ff = new frmAddLine(); //ff.Show(); //tlVectorControl1.ExportSymbol(); //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 "bt2": break; case "mPriSet": tlVectorControl2.PaperSetup(); break; case "mPrint": tlVectorControl2.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 = tlVectorControl2.SVGDocument.getViewScale(); if (viewScale != "") { fScale.InitData(viewScale); } if (fScale.ShowDialog() == DialogResult.OK) { //viewScale = fScale.ViewScale; string _viewScale = fScale.ViewScale; tlVectorControl2.SVGDocument.setViewScale(_viewScale); if (viewScale == "") { viewScale = "1"; } Recalculate(Convert.ToDecimal(_viewScale) / Convert.ToDecimal(viewScale)); } } break; case "mRzb": frmRatio fRat = new frmRatio(); string viewRat = tlVectorControl2.SVGDocument.getRZBRatio(); if (viewRat != "") { fRat.InitData(viewRat); } if (fRat.ShowDialog() == DialogResult.OK) { viewRat = fRat.ViewScale; tlVectorControl2.SVGDocument.setRZBRatio(viewRat); } break; case "mEdit": if (MapType == "所内接线图") { Save(); svg.SUID = ParentUID; IList svglist = Services.BaseService.GetList("SelectSVGFILEByKey", svg); svg = (SVGFILE)svglist[0]; sdoc = null; sdoc = new SvgDocument(); sdoc.LoadXml(svg.SVGDATA); tlVectorControl2.SVGDocument = sdoc; tlVectorControl2.SVGDocument.SvgdataUid = svg.SUID; MapType = "接线图"; CtrlSvgView.MapType = "接线图"; LoadShape("symbol_3.xml"); Init(progtype); //ButtonEnb(true); //frmlar.SymbolDoc = tlVectorControl2.SVGDocument; //frmlar.Progtype = progtype; //frmlar.InitData(); bk1.Enabled = true; LoadImage = true; tlVectorControl2.Refresh(); } //tlVectorControl1.ContextMenuStrip = contextMenuStrip1; MapType = "接线图"; break; case "mAbout": frmAbout frma = new frmAbout(); frma.ShowDialog(); break; #endregion #region 基础图元 case "mDecreaseView": tlVectorControl2.Operation = ToolOperation.DecreaseView; break; case "mIncreaseView": tlVectorControl2.Operation = ToolOperation.IncreaseView; break; case "mRoam": tlVectorControl2.Operation = ToolOperation.Roam; break; case "mSelect": case "mSel": //tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl2.Operation = ToolOperation.FreeTransform; break; case "mFreeTransform": tlVectorControl2.Operation = ToolOperation.FreeTransform; break; case "mFreeLines"://锁套 tlVectorControl2.Operation = ToolOperation.FreeLines; break; case "mFreePath": tlVectorControl2.Operation = ToolOperation.FreePath; break; case "mShapeTransform": tlVectorControl2.Operation = ToolOperation.ShapeTransform; break; case "mShapeTransform1": //截断 tlVectorControl2.Operation = ToolOperation.Custom11; break; case "mShapeTransform2": //延长(e) tlVectorControl2.Operation = ToolOperation.Custom12; break; case "mShapeTransform3": //延长(b) tlVectorControl2.Operation = ToolOperation.Custom13; break; case "mShapeTransform4": //增加 tlVectorControl2.Operation = ToolOperation.Custom15; break; case "mShapeTransform5": //删除 tlVectorControl2.Operation = ToolOperation.Custom14; break; case "mAngleRectangle": tlVectorControl2.Operation = ToolOperation.AngleRectangle; break; case "mEllipse": tlVectorControl2.Operation = ToolOperation.Ellipse; break; case "mLine": tlVectorControl2.Operation = ToolOperation.Line; break; case "mPolyline": tlVectorControl2.Operation = ToolOperation.PolyLine; break; case "mPolygon": tlVectorControl2.Operation = ToolOperation.Polygon; break; case "mImage": tlVectorControl2.Operation = ToolOperation.Image; break; case "mText": tlVectorControl2.Operation = ToolOperation.Text; break; case "mBezier": tlVectorControl2.Operation = ToolOperation.Bezier; break; case "mEnclosure": tlVectorControl2.Operation = ToolOperation.Enclosure; break; case "mGroup": tlVectorControl2.Group(); break; case "mUnGroup": tlVectorControl2.UnGroup(); break; case "mlinelx": tlVectorControl2.Operation = ToolOperation.ConnectLine_Line; break; case "mzxlx": tlVectorControl2.Operation = ToolOperation.ConnectLine_Rightangle; break; case "mqxlx": tlVectorControl2.Operation = ToolOperation.ConnectLine_Spline; break; case "mqzlx": tlVectorControl2.Operation = ToolOperation.ConnectLine_Polyline; break; case "mCJ": tlVectorControl2.Operation = ToolOperation.PolyLine; csOperation = CustomOperation.OP_MeasureDistance; break; #endregion #region 视图 case "mOption": tlVectorControl2.SetOption(); break; case "mLayer": LayerManagerShow(); //tlVectorControl1.LayerManager(); break; case "mAirscape": frmAirscape fAir = new frmAirscape(); fAir.InitData(tlVectorControl2); 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; #endregion #region 查看 case "mDklb": frmLayerList lay = new frmLayerList(); lay.InitData(tlVectorControl2.SVGDocument.getLayerList(), "1"); if (lay.ShowDialog() == DialogResult.OK) { frmglebePropertyList flist1 = new frmglebePropertyList(); flist1.InitDataSub(tlVectorControl2.SVGDocument.SvgdataUid, lay.str_sid); flist1.Show(); } break; case "mGhlb": frmLayerList lay2 = new frmLayerList(); lay2.InitData(tlVectorControl2.SVGDocument.getLayerList(), "2"); if (lay2.ShowDialog() == DialogResult.OK) { frmglebePropertyList flist2 = new frmglebePropertyList(); flist2.InitData(tlVectorControl2.SVGDocument.SvgdataUid, lay2.str_sid); flist2.Show(); } break; case "mLineList": frmLayerList lay3 = new frmLayerList(); lay3.InitData(tlVectorControl2.SVGDocument.getLayerList(), "2"); if (lay3.ShowDialog() == DialogResult.OK) { frmLinePropertyList flist3 = new frmLinePropertyList(); flist3.InitData(tlVectorControl2.SVGDocument.SvgdataUid, lay3.str_sid); flist3.Show(); } break; case "mDlph": frmLayerList lay4 = new frmLayerList(); lay4.InitData(tlVectorControl2.SVGDocument.getLayerList(), "3"); if (lay4.ShowDialog() == DialogResult.OK) { frmSubstationPropertyList fSub = new frmSubstationPropertyList(); fSub.InitData(tlVectorControl2.SVGDocument.SvgdataUid, lay4.str_sid); fSub.Show(); } break; #endregion #region 布局,对齐,顺序 case "mRotate": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl2.FlipX(); } else { tlVectorControl2.FlipX(); } break; case "mToH": tlVectorControl2.FlipX(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToV": tlVectorControl2.FlipY(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToLeft": tlVectorControl2.RotateSelection(-90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToRight": tlVectorControl2.RotateSelection(90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mAlign": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl2.Align(AlignType.Left); } else { tlVectorControl2.Align(AlignType.Left); } tlVectorControl2.Refresh(); break; case "mAlignLeft": tlVectorControl2.Align(AlignType.Left); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl2.Refresh(); break; case "mAlignRight": tlVectorControl2.Align(AlignType.Right); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl2.Refresh(); break; case "mAlignTop": tlVectorControl2.Align(AlignType.Top); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl2.Refresh(); break; case "mAlignBottom": tlVectorControl2.Align(AlignType.Bottom); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl2.Refresh(); break; case "mAlignHorizontalCenter": tlVectorControl2.Align(AlignType.HorizontalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl2.Refresh(); break; case "mAlignVerticalCenter": tlVectorControl2.Align(AlignType.VerticalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl2.Refresh(); break; case "mOrder": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl2.ChangeLevel(LevelType.Top); } else { tlVectorControl2.ChangeLevel(LevelType.Top); } break; case "mGoTop": tlVectorControl2.ChangeLevel(LevelType.Top); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoUp": tlVectorControl2.ChangeLevel(LevelType.Up); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoDown": tlVectorControl2.ChangeLevel(LevelType.Down); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoBottom": tlVectorControl2.ChangeLevel(LevelType.Bottom); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; #endregion #region 图元操作 case "mCopy": tlVectorControl2.Copy(); break; case "mCut": tlVectorControl2.Cut(); break; case "mPaste": tlVectorControl2.Paste(); break; case "mDelete": if (tlVectorControl2.SVGDocument.CurrentElement != null && tlVectorControl2.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 < tlVectorControl2.SVGDocument.SelectCollection.Count; i++) { if (tlVectorControl2.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polygon") { glebeProperty gle = new glebeProperty(); gle.SvgUID = tlVectorControl2.SVGDocument.SvgdataUid; gle.EleID = tlVectorControl2.SVGDocument.SelectCollection[i].ID; Services.BaseService.Update("DeleteglebePropertyByEleID", gle); } if (tlVectorControl2.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl2.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line") { LineInfo _line = new LineInfo(); _line.SvgUID = tlVectorControl2.SVGDocument.SvgdataUid; _line.EleID = tlVectorControl2.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 (tlVectorControl2.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use") { string str_name = ((XmlElement)(tlVectorControl2.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href"); if (str_name.Contains("Substation")) { substation _sub = new substation(); _sub.SvgUID = tlVectorControl2.SVGDocument.SvgdataUid; _sub.EleID = tlVectorControl2.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 (tlVectorControl2.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") { ConnectLine cline = (ConnectLine)tlVectorControl2.SVGDocument.SelectCollection[i]; if (cline.StartGraph != null) { SvgElement ele = (SvgElement)cline.StartGraph; if (!ele.GetAttribute("xlink:href").Contains("Substation")) { tlVectorControl2.SVGDocument.SelectCollection.Add(cline.StartGraph); } } if (cline.EndGraph != null) { tlVectorControl2.SVGDocument.SelectCollection.Add(cline.EndGraph); } } } } else { for (int i = 0; i < tlVectorControl2.SVGDocument.SelectCollection.Count; i++) { if (tlVectorControl2.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl2.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line") { LineInfo _line = new LineInfo(); _line.SvgUID = tlVectorControl2.SVGDocument.SvgdataUid; _line.EleID = tlVectorControl2.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 (tlVectorControl2.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use") { string str_name = ((XmlElement)(tlVectorControl2.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href"); if (str_name.Contains("Substation")) { substation _sub = new substation(); _sub.SvgUID = tlVectorControl2.SVGDocument.SvgdataUid; _sub.EleID = tlVectorControl2.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 (tlVectorControl2.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") { ConnectLine cline = (ConnectLine)tlVectorControl2.SVGDocument.SelectCollection[i]; if (cline.StartGraph != null) { SvgElement ele = (SvgElement)cline.StartGraph; if (!ele.GetAttribute("xlink:href").Contains("Substation")) { tlVectorControl2.SVGDocument.SelectCollection.Add(cline.StartGraph); } } if (cline.EndGraph != null) { tlVectorControl2.SVGDocument.SelectCollection.Add(cline.EndGraph); } } } } tlVectorControl2.Delete(); } } //tlVectorControl1.Operation = ToolOperation.Select; break; case "mUodo": tlVectorControl2.Undo(); break; case "mRedo": tlVectorControl2.Redo(); break; #endregion #region 业务操作 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", tlVectorControl2.SVGDocument.SvgdataUid); Services.BaseService.Update("UpdateGlebePropertyAll", HashTable1); break; case "mJQLeadLine": tlVectorControl2.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)tlVectorControl2.ScaleRatio) + " " + (-xy.Y / (Double)tlVectorControl2.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 = tlVectorControl2.SVGDocument.CreateElement("polyline") as Polyline; n1.SetAttribute("IsLead", "1"); n1.SetAttribute("points", points); n1.SetAttribute("layer", SvgDocument.currentLayer); // n1.SetAttribute("style", styleValue); tlVectorControl2.SVGDocument.RootElement.AppendChild(n1); line.UID = Guid.NewGuid().ToString(); line.EleID = n1.GetAttribute("id"); line.SvgUID = tlVectorControl2.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, "电网规划层", tlVectorControl2.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("电网规划层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // sgt1.Visible = true; tlVectorControl2.Operation = ToolOperation.Select; tlVectorControl2.Operation = ToolOperation.LeadLine; break; case "mAreaPoly": if (!getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl2.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("城市规划层")) { MessageBox.Show("请选择城市规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl2.Operation = ToolOperation.Select; tlVectorControl2.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, "电网规划层", tlVectorControl2.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl2.Operation = ToolOperation.Select; tlVectorControl2.Operation = ToolOperation.InterEnclosure; MapType = "接线图"; break; case "mGhfx": if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl2.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl2.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, "电网规划层", tlVectorControl2.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //LayerBox.ComboBoxEx.SelectedIndex = 2; tlVectorControl2.Operation = ToolOperation.Select; MapType = "规划统计"; break; case "mDkwh": //地块维护 frmPropertyClass frmProp = new frmPropertyClass(); frmProp.ShowDialog(); break; case "mDkfl": //地块分类 if (tlVectorControl2.SVGDocument.CurrentElement == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } frmUsePropertySelect frmUseSel = new frmUsePropertySelect(); frmUseSel.InitData(tlVectorControl2.SVGDocument.CurrentElement.ID, tlVectorControl2.SVGDocument.SvgdataUid); frmUseSel.ShowDialog(); break; case "mGldt": //关联地图 if (tlVectorControl2.SVGDocument.CurrentElement == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } frmFileSelect frmSel = new frmFileSelect(); frmSel.InitData(tlVectorControl2.SVGDocument.CurrentElement.ID, tlVectorControl2.SVGDocument.SvgdataUid, true); frmSel.ShowDialog(); break; case "mPriQu": SubPrint = true; tlVectorControl2.Operation = ToolOperation.InterEnclosure; break; case "mReCompute": if (MessageBox.Show("确认要重新计算全图的电量和负荷么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string scale = tlVectorControl2.SVGDocument.getViewScale(); if (scale != "") { Recalculate(Convert.ToDecimal(scale)); } else { Recalculate(1); } MessageBox.Show("重新计算完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "mXLine": tlVectorControl2.Operation = ToolOperation.Select; tlVectorControl2.Operation = ToolOperation.XPolyLine; break; case "mYLine": tlVectorControl2.Operation = ToolOperation.Select; tlVectorControl2.Operation = ToolOperation.YPolyLine; break; case "mFhbz": if (MessageBox.Show("是否生成负荷标注?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Fhbz(); } break; case "mSaveGroup": if (tlVectorControl2.SVGDocument.SelectCollection.Count > 1) { string content = "<svg>"; SvgElementCollection col = tlVectorControl2.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 = tlVectorControl2.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 = tlVectorControl2.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) + "']"); tlVectorControl2.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)" tlVectorControl2.SVGDocument.RootElement.AppendChild(ele); tlVectorControl2.SVGDocument.SelectCollection.Clear(); tlVectorControl2.SVGDocument.SelectCollection.Add((SvgElement)ele); tlVectorControl2.UnGroup(); // tlVectorControl1.Refresh(); } } } break; #endregion } } }
void tlVectorControl1_DoubleLeftClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e) { XmlElement xml1 = ((XmlElement)(e.Elements[0])); string str_name = xml1.GetAttribute("xlink:href"); if (MapType == "接线图") { SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; if (str_name.Contains("Substation")) { 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.ScaleRatio = 1f; tlVectorControl1.Refresh(); } } }
private SvgDocument LoadXMLToCtrl(string strXML) { SvgDocument x = new SvgDocument(); x.LoadXml(strXML); return x; //symbolDoc.NodeInserted += new System.Xml.XmlNodeChangedEventHandler(SVGDocument_NodeInserted); }
/*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(); } }
public void Open2(string _SvgUID, string yearID) { try { string uid = ConfigurationSettings.AppSettings.Get("SvgID"); StringBuilder txt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"1500\" height=\"1000\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\" transform=\"matrix(1 0 0 1 0 1)\"><defs>"); string svgdefs = ""; string layertxt = ""; StringBuilder content = new StringBuilder(); if (string.IsNullOrEmpty(_SvgUID)) return; SVG_LAYER lar = new SVG_LAYER(); lar.svgID = uid; lar.YearID = "'" + yearID + "'"; IList<SVG_LAYER> larlist = Services.BaseService.GetList<SVG_LAYER>("SelectSVG_LAYERByYearID", lar); foreach (SVG_LAYER _lar in larlist) { //layertxt = layertxt + "<layer id=\"" + _lar.SUID + "\" label=\"" + _lar.NAME + "\" layerType=\"" + _lar.layerType + "\" visibility=\"" + _lar.visibility + "\" ParentID=\"" + _lar.YearID + "\" IsSelect=\"" + _lar.IsSelect + "\" />"; content.Append(_lar.XML); } txt.Append("<layer id=\"layer6666\" label=\"默认层\" />"); txt.Append(layertxt); SVG_SYMBOL sym = new SVG_SYMBOL(); sym.svgID = uid; IList<SVG_SYMBOL> symlist = Services.BaseService.GetList<SVG_SYMBOL>("SelectSVG_SYMBOLBySvgID", sym); foreach (SVG_SYMBOL _sym in symlist) { svgdefs = svgdefs + _sym.XML; } txt.Append(svgdefs + "</defs>"); txt.Append(content.ToString() + "</svg>"); SvgDocument document = new SvgDocument(); document.LoadXml(txt.ToString()); //document.FileName = SvgName; document.SvgdataUid = _SvgUID; SVGUID = _SvgUID; this.Text = document.FileName; if (document.RootElement == null) { tlVectorControl1.NewFile(); Layer.CreateNew("背景层", tlVectorControl1.SVGDocument); Layer.CreateNew("城市规划层", tlVectorControl1.SVGDocument); Layer.CreateNew("供电区域层", tlVectorControl1.SVGDocument); } else { tlVectorControl1.SVGDocument = document; } tlVectorControl1.SVGDocument.SvgdataUid = SVGUID; tlVectorControl1.SVGDocument.FileName = this.Text; tlVectorControl1.DocumentbgColor = Color.White; tlVectorControl1.BackColor = Color.White; foreach (XmlElement ele in document.RootElement.ChildNodes) { ele.SetAttribute("layer", "layer6666"); if (((SvgElement)ele).LocalName == "polyline") { ele.SetAttribute("flag", "1"); } } SvgDocument.currentLayer = "layer6666"; } catch (Exception e) { MessageBox.Show(e.Message); } //tlVectorControl1.SVGDocument.SvgdataUid = ""; }
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem.Text == "短路计算") { } if (e.ClickedItem.Text == "区域打印") { PrintHelper ph = new PrintHelper(tlVectorControl1, mapview); frmPrinter dlg = new frmPrinter(); dlg.printHelper = ph; dlg.ShowDialog(); return; ArrayList idlist = new ArrayList(); ArrayList symlist = new ArrayList(); SvgDocument _doc = new SvgDocument(); Graph poly1 = tlVectorControl1.SVGDocument.CurrentElement as Graph; if (poly1 == null || poly1.GetAttribute("id") == "svg") { return; } GraphicsPath gr1 = new GraphicsPath(); gr1.AddPolygon(TLMath.getPolygonPoints(poly1)); gr1 = (GraphicsPath)poly1.GPath.Clone(); gr1.Transform((poly1 as IGraph).Transform.Matrix); RectangleF ef1 = gr1.GetBounds(); ef1 = PathFunc.GetBounds(gr1); StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">"); XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("defs"); if (nlist.Count > 0) { XmlNode node = nlist[0]; svgtxt.AppendLine(node.OuterXml); } SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator(); while (enumerator1.MoveNext()) { IGraph graph1 = (IGraph)enumerator1.Current; GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone(); if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue; GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone(); path2.Transform(graph1.Transform.Matrix); RectangleF ef2 = PathFunc.GetBounds(path2); if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty) { SvgElement ele = (SvgElement)graph1; svgtxt.AppendLine(ele.OuterXml); if (graph1 is Use) { string symid = ((XmlElement)graph1).GetAttribute("xlink:href"); if (!symlist.Contains(symid)) { symlist.Add(symid); } } if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") { string IsLead = ((XmlElement)graph1).GetAttribute("IsLead"); if (IsLead != "") { if (ef1.Contains(ef2)) { idlist.Add(graph1.ID); } } } } } //symlist = ResetList(symlist); svgtxt.AppendLine("</svg>"); _doc.LoadXml(svgtxt.ToString()); _doc.SvgdataUid = tlVectorControl1.SVGDocument.CurrentLayer.ID; frmPrintF pri = new frmPrintF(); pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.CurrentLayer.ID); if (pri.ShowDialog() == DialogResult.OK) { frmSubPrint s = new frmSubPrint(); s.Vector = tlVectorControl1; s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist); s.Open(_doc, ef1); s.Show(); } } if (e.ClickedItem.Text == "属性") { //if (!Check()) //{ // return; //} XmlElement element = tlVectorControl1.SVGDocument.CurrentElement; if (element is Use) { if (element.GetAttribute("xlink:href").Contains("Substation") || element.GetAttribute("xlink:href").Contains("motherlinenode")) { string str_power = getPower(element.GetAttribute("xlink:href")); PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmSubstation dlg; if (pspDev != null) { dlg = new frmSubstation(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Use"; if (element.GetAttribute("xlink:href").Contains("Substation")) { pspDev.Lable = "变电站"; } else if (element.GetAttribute("xlink:href").Contains("motherlinenode")) { pspDev.Lable = "母线节点"; } else if (element.GetAttribute("xlink:href").Contains("Power")) { pspDev.Lable = "电厂"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmSubstation(pspDev); } dlg.Str_Power = str_power; dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "Use"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; (text as Text).SetAttribute("print", dlg.IsTJ ? "no" : "yes"); } pspDev.VoltR = Convert.ToDouble(dlg.VoltR); pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); pspDev.Burthen = Convert.ToDecimal(dlg.Burthen); element.SetAttribute("print", dlg.IsTJ ? "no" : "yes"); pspDev.OutP = Convert.ToDouble(dlg.OutP); pspDev.OutQ = Convert.ToDouble(dlg.OutQ); ; //if (pspDev.InPutP==0) pspDev.InPutP = Convert.ToDouble(dlg.InPutP); pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); if (dlg.NodeType == "是") { pspDev.NodeType = "0"; } else { pspDev.NodeType = "1"; } Services.BaseService.Update<PSPDEV>(pspDev); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg.TYear); } } else if (element.GetAttribute("xlink:href").Contains("Power")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmSubstation dlg; if (pspDev != null) { dlg = new frmSubstation(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Use"; if (element.GetAttribute("xlink:href").Contains("Substation")) { pspDev.Lable = "变电站"; } else if (element.GetAttribute("xlink:href").Contains("motherlinenode")) { pspDev.Lable = "母线节点"; } else if (element.GetAttribute("xlink:href").Contains("Power")) { pspDev.Lable = "电厂"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmSubstation(pspDev); dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "Use"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.VoltR = Convert.ToDouble(dlg.VoltR); pspDev.Burthen = Convert.ToDecimal(dlg.Burthen); pspDev.OutP = Convert.ToDouble(dlg.OutP); pspDev.OutQ = Convert.ToDouble(dlg.OutQ); pspDev.InPutP = Convert.ToDouble(dlg.InPutP); pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); if (dlg.NodeType == "是") { pspDev.NodeType = "0"; } else { pspDev.NodeType = "2"; } Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmFadejie dlg; if (pspDev != null) { dlg = new frmFadejie(pspDev, pspDev.SvgUID); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "dynamotorline"; if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { pspDev.Lable = "发电厂支路"; } else if (element.GetAttribute("xlink:href").Contains("gndline")) { pspDev.Lable = "接地支路"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmFadejie(pspDev, pspDev.SvgUID); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "dynamotorline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; if (dlg.OutP != "") pspDev.OutP = Convert.ToDouble(dlg.OutP); if (dlg.OutQ != "") pspDev.OutQ = Convert.ToDouble(dlg.OutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); if (dlg.VoltV != "") pspDev.VoltV = Convert.ToDouble(dlg.VoltV); if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); if (dlg.NegativeTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("gndline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmFadejie dlg; if (pspDev != null) { dlg = new frmFadejie(pspDev, pspDev.SvgUID); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "gndline"; if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { pspDev.Lable = "发电厂支路"; } else if (element.GetAttribute("xlink:href").Contains("gndline")) { pspDev.Lable = "接地支路"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmFadejie(pspDev, pspDev.SvgUID); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "gndline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; if (dlg.OutP != "") pspDev.OutP = Convert.ToDouble(dlg.OutP); if (dlg.OutQ != "") pspDev.OutQ = Convert.ToDouble(dlg.OutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); if (dlg.VoltV != "") pspDev.VoltV = Convert.ToDouble(dlg.VoltV); if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); if (dlg.NegativeTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("loadline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLoad dlg; if (pspDev != null) { dlg = new frmLoad(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "loadline"; pspDev.Lable = "负荷支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmLoad(pspDev); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "loadline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.LoadSwitchState; if (dlg.InPutP != "") pspDev.InPutP = Convert.ToDouble(dlg.InPutP); if (dlg.InPutQ != "") pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("串联电容电抗器")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmCapacity dlg; if (pspDev != null) { dlg = new frmCapacity(pspDev, pspDev.SvgUID); dlg.SetEnable(true); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "串联电容电抗器"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; // pspDev.HuganLine2 = dlg.LastNodeName; if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("并联电容电抗器")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmCapacity dlg; if (pspDev != null) { dlg = new frmCapacity(pspDev, pspDev.SvgUID); dlg.SetEnable(false); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "并联电容电抗器"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; //pspDev.HuganLine2 = dlg.LastNodeName; if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("transformerthirdzu")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmThridTra dlg; if (pspDev != null) { dlg = new frmThridTra(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "transformerthirdzu"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.IName; pspDev.HuganLine2 = dlg.JName; pspDev.HuganLine3 = dlg.ISwitchState; pspDev.HuganLine4 = dlg.JSwitchState; pspDev.LineLevel = dlg.IType; pspDev.LineType = dlg.JType; pspDev.LineStatus = dlg.KType; pspDev.KName = dlg.KName; pspDev.KSwitchStatus = dlg.KSwitchState; if (dlg.IK != "") { pspDev.K = Convert.ToDouble(dlg.KK); } if (dlg.JK != "") { pspDev.G = Convert.ToDouble(dlg.JK); } if (dlg.KK != "") { pspDev.BigP = Convert.ToDouble(dlg.KK); } if (dlg.IR != "") { pspDev.HuganTQ1 = Convert.ToDouble(dlg.IR); } if (dlg.JR != "") { pspDev.HuganTQ2 = Convert.ToDouble(dlg.JR); } if (dlg.KR != "") { pspDev.HuganTQ3 = Convert.ToDouble(dlg.KR); } if (dlg.ITQ != "") { pspDev.HuganTQ4 = Convert.ToDouble(dlg.ITQ); } if (dlg.JTQ != "") { pspDev.HuganTQ5 = Convert.ToDouble(dlg.JTQ); } if (dlg.KTQ != "") { pspDev.SmallTQ = Convert.ToDouble(dlg.KTQ); } if (dlg.ZeroTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); if (dlg.NeutralNodeTQ != "") pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("transformertwozu")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmTwoTra dlg; if (pspDev != null) { dlg = new frmTwoTra(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "transformertwozu"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstName; pspDev.HuganLine2 = dlg.LastName; pspDev.HuganLine3 = dlg.FirstSwitchState; pspDev.HuganLine4 = dlg.LastSwitchState; pspDev.LineLevel = dlg.FirstType; pspDev.LineType = dlg.LastType; if (dlg.PositiveR != "") { pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR); } if (dlg.PositiveTQ != "") { pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); } if (dlg.ZeroR != "") { pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR); } if (dlg.ZeroTQ != "") { pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); } if (dlg.K != "") pspDev.K = Convert.ToDouble(dlg.K); if (dlg.NeutralNodeTQ != "") pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("1/2母联开关")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmMuLian dlg; if (pspDev != null) { dlg = new frmMuLian(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "1/2母联开关"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine2 = dlg.LastNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("2/3母联开关")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmMuLian2 dlg; if (pspDev != null) { dlg = new frmMuLian2(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "2/3母联开关"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.INodeName; pspDev.HuganLine2 = dlg.JNodeName; pspDev.HuganLine3 = dlg.ILineName; pspDev.HuganLine4 = dlg.JLineName; pspDev.KName = dlg.ILoadName; pspDev.KSwitchStatus = dlg.JLoadName; pspDev.LineLevel = dlg.SwitchStatus1; pspDev.LineType = dlg.SwitchStatus2; pspDev.LineStatus = dlg.SwitchStatus3; Services.BaseService.Update<PSPDEV>(pspDev); } } } else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType == true) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLinenew dlg2; if (pspDev != null) { dlg2 = new frmLinenew(pspDev); dlg2.derefucelineflag = Reducelineflag; } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Polyline"; pspDev.Lable = "支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg2 = new frmLinenew(pspDev); dlg2.derefucelineflag = Reducelineflag; } dlg2.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); dlg2.linevalue = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("linevalue"); //获得线路投资 if (dlg2.ShowDialog() == DialogResult.OK) { if (dlg2.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg2.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Polyline"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg2.Name; pspDev.LineLength = Convert.ToDouble(dlg2.LineLength); pspDev.LineR = Convert.ToDouble(dlg2.LineR); pspDev.LineTQ = Convert.ToDouble(dlg2.LineTQ); pspDev.LineGNDC = Convert.ToDouble(dlg2.LineGNDC); pspDev.LineLevel = dlg2.LineLevel; pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt); pspDev.LineType = dlg2.LineType; pspDev.LineStatus = dlg2.LineStatus; WireCategory wirewire = new WireCategory(); wirewire.WireType = dlg2.LineType; if (dlg2.linevalue != "") { pspDev.BigP = Convert.ToDouble(dlg2.linevalue); } if (dlg2.ReferenceVolt != "") { pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt); } WireCategory wirewire2 = new WireCategory(); wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); //if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength)*wirewire2.WireR ; //if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireTQ; //if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireGNDC; if (wirewire2 != null) pspDev.LineChange = (double)wirewire2.WireChange; string tempp = dlg2.LineLev; int tel = tempp.Length; if (tempp.Contains("kV") || tempp.Contains("KV") || tempp.Contains("kv") || tempp.Contains("Kv")) { tempp = tempp.Substring(0, tel - 2); } pspDev.VoltR = Convert.ToDouble(tempp); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg2.TYear); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("linevalue", dlg2.linevalue); //获得线路投资 //switch (dlg2.LineType) //{ // case "2*LGJ-400": // { // if (pspDev.LineR==0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.04; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.303; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.054; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.308; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.066; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.310; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.08; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.417; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} Services.BaseService.Update<PSPDEV>(pspDev); Topology2(); } } else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType != true) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLine dlg; if (pspDev != null) { dlg = new frmLine(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Polyline"; pspDev.Lable = "支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmLine(pspDev); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "Polyline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; pspDev.LineLength = Convert.ToDouble(dlg.LineLength); pspDev.LineLevel = dlg.LineLevel; pspDev.LineType = dlg.LineType; pspDev.LineStatus = dlg.LineStatus; pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR); pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR); pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); if (dlg.HuganFirst == "是") pspDev.HuganFirst = 1; else pspDev.HuganFirst = 0; pspDev.HuganLine1 = dlg.HuganLine1; pspDev.HuganLine2 = dlg.HuganLine2; pspDev.HuganLine3 = dlg.HuganLine3; pspDev.HuganLine4 = dlg.HuganLine4; pspDev.HuganTQ1 = Convert.ToDouble(dlg.HuganTQ1); pspDev.HuganTQ2 = Convert.ToDouble(dlg.HuganTQ2); pspDev.HuganTQ3 = Convert.ToDouble(dlg.HuganTQ3); pspDev.HuganTQ4 = Convert.ToDouble(dlg.HuganTQ4); pspDev.HuganTQ5 = Convert.ToDouble(dlg.HuganTQ5); string tempp = dlg.LineLev; int tel = tempp.Length; if (tel == 1) pspDev.VoltR = 0; else { if (tempp.Contains("kV") || tempp.Contains("KV") || tempp.Contains("kv") || tempp.Contains("Kv")) { tempp = tempp.Substring(0, tel - 2); } pspDev.VoltR = Convert.ToDouble(tempp); } //switch (dlg.LineType) //{ // case "2*LGJ-400": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.04; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.303; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.054; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.308; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.066; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.310; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.08; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.417; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} Services.BaseService.Update<PSPDEV>(pspDev); Topology2(); } } } tlVectorControl1.Operation = ToolOperation.Select; //contextMenuStrip1.Hide(); }
/*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 void dotNetBarManager1_ItemClick(object sender, System.EventArgs e) { DevComponents.DotNetBar.ButtonItem btItem = sender as DevComponents.DotNetBar.ButtonItem; frmDocument frm =this.ActiveMdiChild as frmDocument; if (btItem !=null ) { // DevComponents.DotNetBar.ButtonItem btItem =btItem2.Clone() as ButtonItem; bool flag=false; bool flag2=false; switch(btItem.Name) { case "mNewFile": NewFile(); flag=true; break; case "mOpen": OpenFile(); flag=true; break; case "mExit": this.Close(); break; case "mAbout": this.symbolSelector.SelectIndex(2); string str =frm.documentControl1.SelectToDoc(); frm=new frmDocument(); frm.MdiParent=this; //frm.Bounds=this.ClientRectangle; frm.Bounds = new Rectangle(0,0,this.Width-this.barLeftDockSite.Width-10,this.Height - this.barTopDockSite.Height -50); frm.Show(); SvgDocument doc =new SvgDocument(); doc.LoadXml(str); frm.documentControl1.SVGDocument=doc; frm.documentControl1.ScaleChanged+=new EventHandler(documentControl1_ScaleChanged); frm.documentControl1.OnTipEvent+=new ItopVector.Core.Interface.OnTipEventHandler(ShowStatusInfo); frm.documentControl1.OnTrackPopup +=new ItopVector.Core.Interface.TrackPopupEventHandler(documentControl1_OnTrackPopup); // frm.documentControl1.AddShape( symbolSelector.SelectedItem,new Point(0,0)); // Form1 f=new Form1(); // f.Owner=this; // f.miniatureView1.VectorControl=frm.documentControl1; // // f.Show(); // ArrayList list=frm.documentControl1.SVGDocument.getLayerList(); // IEnumerator It=list.GetEnumerator(); // while(It.MoveNext()) // { // ItopVector.Core.Figure.Layer l=It.Current as ItopVector.Core.Figure.Layer; // } //frm.documentControl1.Operation=ToolOperation.AreaPolygon; //frm.documentControl1.ClipScreen(true); //frm.documentControl1.FitWindow(); //frm.documentControl1.CurrentOperation=ToolOperation.ConnectLine_Rightangle; // frmAbout dlg=new frmAbout(); // dlg.ShowDialog(); // ItopVector.Core.SvgElement s= frm.documentControl1.SVGDocument.RootElement; // System.Xml.XmlNodeList l1= frm.documentControl1.SVGDocument.SelectNodes("svg/*"); // IEnumerator eum= l1.GetEnumerator(); // while(eum.MoveNext()){ // XmlNode node=(XmlNode)eum.Current; // System.Xml.XmlElement e1=(System.Xml.XmlElement)node; // e1.SetAttribute("layer","layer00001"); // } //frm.documentControl1.Operation=ToolOperation.WindowZoom; break; case "mInDxf": this.ImportDxf(); break; case "mShapeManager": ItopVector.Dialog.SymbolManagerDialog dlg2 =new ItopVector.Dialog.SymbolManagerDialog(); dlg2.SymbolSelector = this.symbolSelector; dlg2.ShowDialog(this); break; } if (flag) { if (this.MdiChildren.Length==1) { frm =this.ActiveMdiChild as frmDocument; if (frm==null)return; frm.documentControl1.PropertyGrid=this.propertyGrid; this.miniatureView.VectorControl = frm.documentControl1; frm.documentControl1.TextStyle =this.ratFont; UpdateToolBottom(frm.documentControl1.Operation); } } if (frm==null)return; Lable_switch: flag2=false; switch(btItem.Name) { #region �ļ� case "mSave": Save( frm); break; case "mSaveAll": SaveAll(); break; case "mSaveAs": frm.documentControl1.SaveAs(); frm.Text=frm.documentControl1.SVGDocument.FileName; break; case "mOutImage": frm.documentControl1.ExportImage(); // ItopVectorControl tl=new ItopVectorControl(); // tl.OpenFile(frm.documentControl1.SVGDocument.FilePath); // tl.ExportImage(); break; case "mOutSymbol": frm.documentControl1.SymbolSelector = this.symbolSelector; frm.documentControl1.ExportSymbol(/*false,true,false,"symbol"*/); break; case "mClose": frm.Close(); break; case "mCloseAll": this.CloseAll(); break; case "mSetup": frm.documentControl1.PaperSetup(); break; case "mPrint": frm.documentControl1.Print(); break; #endregion #region �༭ case "mUndo": frm.documentControl1.Undo(); break; case"mRedo": frm.documentControl1.Redo(); break; case "mCopy": frm.documentControl1.Copy(); break; case "mCut": frm.documentControl1.Cut(); break; case "mPaste": frm.documentControl1.Paste(); break; case "mDelete": frm.documentControl1.Delete(); break; case"mSelectAll": frm.documentControl1.SelectCuurentLay(); break; case "mClearSelects": frm.documentControl1.SelectNone(); break; case "mLink": frm.documentControl1.Link(); break; #endregion #region View case "mLayerManager": frm.documentControl1.LayerManager(); break; #endregion case "mGroup": frm.documentControl1.Group(); break; case "mUnGroup": frm.documentControl1.UnGroup(); break; case "mShowRule": frm.documentControl1.IsShowRule=!frm.documentControl1.IsShowRule; break; case"mShowGrid": frm.documentControl1.IsShowGrid=!frm.documentControl1.IsShowGrid; break; case"mPasteGrid": frm.documentControl1.IsPasteGrid=!frm.documentControl1.IsPasteGrid; break; #region ˳�� case "mOrder": if(btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; flag2=true; } else { frm.documentControl1.ChangeLevel(LevelType.Top); } break; case"mGoTop": frm.documentControl1.ChangeLevel(LevelType.Top); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case"mGoUp": frm.documentControl1.ChangeLevel(LevelType.Up); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case"mGoDown": frm.documentControl1.ChangeLevel(LevelType.Down); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case"mGoBottom": frm.documentControl1.ChangeLevel(LevelType.Bottom); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; #endregion #region ���� case "mDecreaseView": frm.documentControl1.Operation=ToolOperation.DecreaseView; UpdateToolBottom(btItem); break; case "mIncreaseView": frm.documentControl1.Operation=ToolOperation.IncreaseView; UpdateToolBottom(btItem); break; case "mRoam": frm.documentControl1.Operation=ToolOperation.Roam; UpdateToolBottom(btItem); break; case "mSelect": frm.documentControl1.Operation=ToolOperation.Select; UpdateToolBottom(btItem); break; case "mFreeTransform": frm.documentControl1.Operation=ToolOperation.FreeTransform; UpdateToolBottom(btItem); break; case "mFreeLines"://���� frm.documentControl1.Operation=ToolOperation.FreeLines; UpdateToolBottom(btItem); break; case "mFreePath": frm.documentControl1.Operation=ToolOperation.FreePath; UpdateToolBottom(btItem); break; case "mShapeTransform": frm.documentControl1.Operation=ToolOperation.ShapeTransform; UpdateToolBottom(btItem); break; case "mAngleRectangle": frm.documentControl1.Operation=ToolOperation.AngleRectangle; UpdateToolBottom(btItem); break; case "mEllipse": frm.documentControl1.Operation=ToolOperation.Ellipse; UpdateToolBottom(btItem); break; case "mLine": frm.documentControl1.Operation=ToolOperation.Line; UpdateToolBottom(btItem); break; case "mConnectLine": frm.documentControl1.Operation=ToolOperation.ConnectLine; UpdateToolBottom(btItem); break; case "mPolyline": frm.documentControl1.Operation=ToolOperation.PolyLine; UpdateToolBottom(btItem); break; case "mPolygon": frm.documentControl1.Operation=ToolOperation.Polygon; UpdateToolBottom(btItem); break; case "mImage": frm.documentControl1.Operation=ToolOperation.Image; UpdateToolBottom(btItem); break; case "mText": frm.documentControl1.Operation=ToolOperation.Text; UpdateToolBottom(btItem); break; case "mBezier": frm.documentControl1.Operation=ToolOperation.Bezier; UpdateToolBottom(btItem); break; case "mEnclosure": frm.documentControl1.Operation=ToolOperation.Enclosure; UpdateToolBottom(btItem); break; case "mPie": frm.documentControl1.Operation=ToolOperation.Pie; UpdateToolBottom(btItem); break; case "mArc": frm.documentControl1.Operation=ToolOperation.Arc; UpdateToolBottom(btItem); break; case "mStar"://�ȱ��� frm.documentControl1.Operation=ToolOperation.EqualPolygon; UpdateToolBottom(btItem); break; #endregion #region ���� case "mBold": btItem.Checked =!btItem.Checked; this.ratFont.Bold =btItem.Checked; frm.documentControl1.TextStyle =this.ratFont; break; case "mItalic": btItem.Checked =!btItem.Checked; this.ratFont.Italic =btItem.Checked; frm.documentControl1.TextStyle =this.ratFont; break; case "mUnderline": btItem.Checked =!btItem.Checked; this.ratFont.Underline =btItem.Checked; frm.documentControl1.TextStyle =this.ratFont; break; #endregion case "FontFamily": break; case "mOption"://ѡ�� frm.documentControl1.SetOption(); break; case "mFormManager": this.ManagerMdiChildren(); break; #region ��ת case "mRotate": if(btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; flag2=true; } else { frm.documentControl1.FlipX(); } break; case "mToH": frm.documentControl1.FlipX(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToV": frm.documentControl1.FlipY(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToLeft": frm.documentControl1.RotateSelection(-90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToRight": frm.documentControl1.RotateSelection(90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; #endregion #region ���� case "mAlign": if(btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; flag2=true; } else { frm.documentControl1.Align(AlignType.Left); } break; case "mAlignLeft": frm.documentControl1.Align(AlignType.Left); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag =btItem; break; case "mAlignRight": frm.documentControl1.Align(AlignType.Right); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag =btItem; break; case "mAlignTop": frm.documentControl1.Align(AlignType.Top); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag =btItem; break; case "mAlignBottom": frm.documentControl1.Align(AlignType.Bottom); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag =btItem; break; case "mAlignHorizontalCenter": frm.documentControl1.Align(AlignType.HorizontalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag =btItem; break; case "mAlignVerticalCenter": frm.documentControl1.Align(AlignType.VerticalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag =btItem; break; #endregion default: break; } if(flag2) { goto Lable_switch; } } }
public void OpenJXT(IList svglist, SVGFILE svg) { SVGFILE svg_temp = new SVGFILE(); string eleid = svg.SUID; string filename = svg.FILENAME; if (svglist.Count > 0) { svg_temp = (SVGFILE)svglist[0]; sdoc = null; sdoc = new SvgDocument(); sdoc.LoadXml(svg_temp.SVGDATA); tlVectorControl2.SVGDocument = sdoc; tlVectorControl2.SVGDocument.SvgdataUid = svg_temp.SUID; MapType = "所内接线图"; } else { tlVectorControl2.NewFile(); tlVectorControl2.SVGDocument.SvgdataUid = eleid; //InitGroup(); MapType = "所内接线图"; } substation _s = new substation(); _s.EleID = eleid; _s.SvgUID = ParentUID; substation _s1 = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _s); if (_s1 != null) { tlVectorControl2.SVGDocument.FileName = _s1.EleName;// +"主接线图"; this.Text = _s1.EleName + "主接线图"; } else { tlVectorControl2.SVGDocument.FileName = filename; this.Text =filename+ "主接线图"; } ArrayList a = tlVectorControl2.SVGDocument.getLayerList(); if (tlVectorControl2.SVGDocument.getLayerList().Count == 0) { Layer _lar = ItopVector.Core.Figure.Layer.CreateNew("接线图", tlVectorControl2.SVGDocument); _lar.SetAttribute("layerType", "所内接线图"); _lar.Visible = true; SvgDocument.currentLayer = ((Layer)tlVectorControl2.SVGDocument.getLayerList()[0]).ID; } tlVectorControl2.ContextMenuStrip = null; CreateComboBox(); InitJXT(); LoadShape("symbol4.xml"); LoadImage = false; bk1.Enabled = false; tlVectorControl2.ScaleRatio = 0.1F; tlVectorControl2.Refresh(); // ButtonEnb(false); }
public void Open(string _SvgUID) { try { if (_SvgUID.Length < 20) { JxtBar(); tlVectorControl2.ContextMenuStrip = null; } SVGFILE svgFile = new SVGFILE(); svgFile.SUID = _SvgUID; SvgDocument document =CtrlSvgView.CashSvgDocument; if (document == null) { IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile); if (svgList.Count > 0) { svgFile = (SVGFILE)svgList[0]; } document = new SvgDocument(); if (!string.IsNullOrEmpty(svgFile.SVGDATA)) { document.LoadXml(svgFile.SVGDATA); } document.FileName = svgFile.FILENAME; document.SvgdataUid = svgFile.SUID; } SVGUID = document.SvgdataUid; img = document.SelectSingleNode("//*[@TLGH=\"1\"]"); if (img != null) { ((XmlElement)img).SetAttribute("xlink:href", " "); } this.Text = document.FileName; if (document.RootElement == null) { tlVectorControl2.NewFile(); Layer.CreateNew("背景层", tlVectorControl2.SVGDocument); Layer.CreateNew("城市规划层", tlVectorControl2.SVGDocument); Layer.CreateNew("供电区域层", tlVectorControl2.SVGDocument); } else { tlVectorControl2.SVGDocument = document; } tlVectorControl2.SVGDocument.SvgdataUid = SVGUID; tlVectorControl2.SVGDocument.FileName = this.Text; tlVectorControl2.DocumentbgColor = Color.White; tlVectorControl2.BackColor = Color.White; //tlVectorControl1.ForeColor = Color.White; CreateComboBox(); xltProcessor = new XLTProcessor(tlVectorControl2); xltProcessor.MapView = mapview; xltProcessor.OnNewLine += new NewLineDelegate(xltProcessor_OnNewLine); } catch (Exception e) { MessageBox.Show(e.Message); } }
public void InitData(IList svglist) { //svg.SUID = "1"; //IList svglist = Services.BaseService.GetList("SelectSVGFILEByKey", svg); svg = (SVGFILE)svglist[0]; sdoc = null; sdoc = new SvgDocument(); // sdoc.LoadXml(svg_temp.SVGDATA); sdoc.LoadXml(svg.SVGDATA); tlVectorControl2.SVGDocument = sdoc; ItopVector.SpecialCursors.LoadCursors(); tlVectorControl2.PropertyGrid = propertyGrid; tlVectorControl2.SVGDocument.SvgdataUid = svg.SUID; // LoadShape("symbol2.xml"); }
public void Open(string _SvgUID) { try { SVGFILE svgFile = new SVGFILE(); svgFile.SUID = _SvgUID; SvgDocument document = new SvgDocument(); if (document != null) { IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile); if (svgList.Count > 0) { svgFile = (SVGFILE)svgList[0]; } else { PSP_ELCPROJECT pr = new PSP_ELCPROJECT(); pr.ID= _SvgUID; pr = (PSP_ELCPROJECT)Services.BaseService.GetObject("SelectPSP_ELCPROJECTByKey", pr); svgFile.FILENAME = pr.Name; svgFile.SUID = _SvgUID; Services.BaseService.Create<SVGFILE>(svgFile); } document = new SvgDocument(); if (!string.IsNullOrEmpty(svgFile.SVGDATA)) { document.LoadXml(svgFile.SVGDATA); } document.FileName = svgFile.FILENAME; document.SvgdataUid = svgFile.SUID; } SVGUID = document.SvgdataUid; this.Text = document.FileName; if (document.RootElement == null) { tlVectorControl1.NewFile(); tlVectorControl1.SVGDocument.SvgdataUid = _SvgUID; SvgDocument.currentLayer = Layer.CreateNew("默认层", tlVectorControl1.SVGDocument).ID; } else { tlVectorControl1.SVGDocument = document; tlVectorControl1.SVGDocument.CurrentLayer = ((tlVectorControl1.SVGDocument.getLayerList()[0]) as ItopVector.Core.Figure.Layer); } tlVectorControl1.SVGDocument.SvgdataUid = SVGUID; tlVectorControl1.SVGDocument.FileName = this.Text; tlVectorControl1.DocumentbgColor = Color.White; tlVectorControl1.BackColor = Color.White; } catch (Exception e) { MessageBox.Show(e.Message); } }
public static string Union(string svgdata1,params string[] svgdata) { if (svgdata.Length==0)return svgdata1; SvgDocument doc1 =new SvgDocument(); doc1.PreserveWhitespace =true; doc1.LoadXml(svgdata1); string head=doc1.DocumentElement.CloneNode(false).OuterXml; StringBuilder sb = new StringBuilder(); StringBuilder sbHead = new StringBuilder(); StringBuilder sbDefs = new StringBuilder(); sbHead.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); sbHead.Append("\n"); sbHead.Append(head.Replace("</svg>","")); sbHead.Append("\n"); IList idList = new ArrayList(); IList graphList =new ArrayList(); foreach(XmlNode node in doc1.DocumentElement.ChildNodes) { if (node is Defs) { sbDefs.Append(node.OuterXml.Replace("</defs>","")); sbDefs.Append("\n"); foreach(XmlNode node2 in node.ChildNodes) { if (node2 is XmlElement) { idList.Add( (node2 as XmlElement).GetAttribute("id")); } } } if (node is IGraph) { graphList.Add((node as XmlElement).GetAttribute("id")); sb.Append(node.OuterXml); sb.Append("\n"); } } for(int i=0;i<svgdata.Length;i++) { SvgDocument doc2 =new SvgDocument(); doc2.PreserveWhitespace=true; doc2.LoadXml(svgdata[0]); foreach(XmlNode node in doc2.DocumentElement.ChildNodes) { if (node is Defs) { foreach(XmlNode node2 in node.ChildNodes) { if (node2 is XmlElement ) { XmlElement element = node2 as XmlElement; Layer layer=element as Layer; if(layer!=null && layer.GraphList.Count==0 ) { continue; } string id =element.GetAttribute("id"); if (idList.IndexOf(id)>=0)continue; idList.Add(id); sbDefs.Append(element.OuterXml); sbDefs.Append("\n"); } if (node2 is Layer) { string id = ((Layer)node2).ID; if (idList.IndexOf(id) >= 0) continue; idList.Add(id); sbDefs.Append(node2.OuterXml); sbDefs.Append("\n"); } } } if (node is IGraph) { string id = (node as XmlElement).GetAttribute("id"); if (id !=string.Empty && id!=null && graphList.IndexOf(id)>=0)continue; graphList.Add(id); sb.Append(node.OuterXml); sb.Append("\n"); } } doc2.Dispose(); } doc1.Dispose(); sbDefs.Append("</defs>"); sbDefs.Append("\n"); sb.Insert(0,sbDefs.ToString()); sb.Insert(0,sbHead.ToString()); sb.Append("</svg>"); return sb.ToString(); }
private void Import(IList larlist) { try { bdzlist.Clear(); linelist.Clear(); string uid = ConfigurationManager.AppSettings["SvgID"];//����ͼ���ļ�ID fileid = uid; StringBuilder svgxml = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"1500\" height=\"1000\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\" >"); svgxml.AppendLine("<defs>"); svgxml.AppendLine("<layer id=\"layer0\" label=\"Ĭ�ϲ�\" />"); SVG_SYMBOL sym = new SVG_SYMBOL(); sym.svgID = uid; IList<SVG_SYMBOL> symlist = Services.BaseService.GetList<SVG_SYMBOL>("SelectSVG_SYMBOLBySvgID", sym); foreach (SVG_SYMBOL _sym in symlist) { svgxml.AppendLine(_sym.XML); } svgxml.AppendLine("</defs>"); foreach (SVG_LAYER _lar in larlist) { svgxml.AppendLine(_lar.XML); } svgxml.AppendLine("</svg>"); SvgDocument document = new SvgDocument(); document.LoadXml(svgxml.ToString()); string SVGUID = svgid; if (document.RootElement == null) { MessageBox.Show("����ʧ�ܣ�"); return; } document.FileName = tlVectorControl1.SVGDocument.FileName; tlVectorControl1.SVGDocument = document; tlVectorControl1.SVGDocument.SvgdataUid = SVGUID; tlVectorControl1.DocumentbgColor = Color.White; tlVectorControl1.BackColor = Color.White; SVG svg =document.RootElement as SVG; Layer layer = document.GetLayerByID("layer0"); document.CurrentLayer = layer; tlVectorControl1.DrawArea.RenderTo(tlVectorControl1.CreateGraphics()); bool flag1 = document.AcceptChanges; document.AcceptChanges = false; //������·�ͱ��վ foreach (SvgElement ele in svg.ChildList) { IGraph g = ele as IGraph; g.Layer = layer; if (ele.LocalName == "polyline") { if (ele.GetAttribute("IsLead") == "1") {//��· linelist.Add(ele.ID, ele); } } else if(ele is Use){// (ele.GetAttribute("xlink:href").Contains("Substation")) {//�ڵ� bdzlist.Add(ele.ID, ele); } } List<SvgElement> list1 = new List<SvgElement>(); #region ������·��β�ڵ� foreach (Polyline pl in linelist.Values) { PointF[] ps = new PointF[2]; getNode(pl); string s1 = pl.GetAttribute("FirstNode"); string s2 = pl.GetAttribute("LastNode"); bool b1 = pl.GetAttribute("ftj") == "true";//�ڵ�T�� bool b2 = pl.GetAttribute("ltj") == "true";//β�ڵ�T�� if (!((!string.IsNullOrEmpty(s1)||b1) && (!string.IsNullOrEmpty(s2)||b2))) { pl.ParentNode.RemoveChild(pl); continue; } Use use1 = bdzlist[s1] as Use; Use use2 = bdzlist[s2] as Use; ps[0] = pl.Points[0]; ps[1] = pl.Points[pl.Points.Length - 1]; pl.Points = ps; list1.Add(pl); //pl.Transform.Matrix.TransformPoints(ps); if (b1) { //createT(pl); } else if (use1 != null) { //ps[0] = use1.CenterPoint; list1.Add(use1); } if (b2) { //createT(pl); } else if (use2 != null) { //ps[1] = use2.CenterPoint; list1.Add(use2); } } #endregion #region �Ƴ�û��Graph for (int i=svg.ChildList.Count-1;i>=0;i--){ SvgElement graph = svg.ChildList[i] as SvgElement; if (!list1.Contains(graph) ) { graph.ParentNode.RemoveChild(graph); } } #endregion #region debug //StreamWriter sw = new StreamWriter("c:\\importjxt.txt"); //sw.Write(ItopVector.Core.Func.CodeFunc.FormatXmlDocumentString(document)); //sw.Flush(); //sw.Close(); #endregion Matrix mx = getMatrix(list1);//��ȡ���ž��� #region ���ű��վ�ڵ� foreach (IGraph graph in svg.ChildList) { if (graph is Use) { bool flag = graph.LimitSize; if (flag) graph.LimitSize = false; using (Matrix matrix1 = graph.Transform.Matrix.Clone()) { Use use = graph as Use; PointF p1 = graph.CenterPoint; PointF p2 = (use.RefElement as IGraph).CenterPoint; PointF[] pts = new PointF[1] { p1}; mx.TransformPoints(pts); p1 = pts[0]; use.X = 0; use.Y = 0; matrix1.Reset(); matrix1.Translate(p1.X - p2.X, p1.Y - p2.Y); graph.Transform = new ItopVector.Core.Types.Transf(matrix1); graph.GPath.Reset(); } graph.LimitSize = flag; //createName(document, graph); } } #endregion #region ������· foreach (IGraph graph in svg.ChildList) { if (graph is Polyline) { using (Matrix matrix1 = graph.Transform.Matrix.Clone()) { Polyline pl = graph as Polyline; PointF[] ps = pl.Points.Clone() as PointF[]; string s1 = pl.GetAttribute("FirstNode"); string s2 = pl.GetAttribute("LastNode"); bool b1 = pl.GetAttribute("ftj")=="true";//�ڵ�T�� bool b2 = pl.GetAttribute("ltj") == "true";//β�ڵ�T�� Use use1 = bdzlist[s1] as Use; Use use2 = bdzlist[s2] as Use; ps[0] = pl.Points[0]; ps[1] = pl.Points[pl.Points.Length - 1]; matrix1.Multiply(mx,MatrixOrder.Append); matrix1.TransformPoints(ps); if (use1 != null && !b1) { ps[0] = use1.CenterPoint; } if (use2 != null && !b2) { ps[1] = use2.CenterPoint; } pl.Points = ps; pl.RemoveAttribute("transform"); } } } #endregion #region ����T�� foreach (SvgElement e in list1) { if (e is Polyline) { Polyline pl = e as Polyline; bool b1 = pl.GetAttribute("ftj") == "true";//�ڵ�T�� bool b2 = pl.GetAttribute("ltj") == "true";//β�ڵ�T�� //����T��,����T�ڵ� if (b1) { SvgElement se = createT(pl, 0); if (se != null) { pl.SetAttribute("FirstNode", se.ID); //createsub(se); } } if (b2) { SvgElement se = createT(pl, 1); if (se != null) { pl.SetAttribute("LastNode", se.ID); //createsub(se); } } //PSPDEV dev = createline(e); } else { //createsub(e); createName(document, e as IGraph); } } #endregion document.AcceptChanges = flag1; #region debug //StreamWriter sw2 = new StreamWriter("c:\\importjxt2.txt"); //sw2.Write(ItopVector.Core.Func.CodeFunc.FormatXmlDocumentString(document)); //sw2.Flush(); //sw2.Close(); #endregion } catch (Exception e) { MessageBox.Show(e.Message); } }
public void OpenSvgFile() { try { Cursor = Cursors.WaitCursor; svgFile.SUID = ((SVGFILE)CurTreeNode.Tag).SUID; IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile); svgFile=(SVGFILE)svgList[0]; SvgDocument doc = new SvgDocument(); if(!string.IsNullOrEmpty(svgFile.SVGDATA)){ if (svgFile.SUID == "ccd27085-ddb6-445b-8e00-44d784f0932c") { SvgDocument.BkImageLoad = true; } else { SvgDocument.BkImageLoad = false; } doc.LoadXml(svgFile.SVGDATA); } doc.FileName = svgFile.FILENAME; doc.SvgdataUid = svgFile.SUID; if (this.OnOpenSvgDocument != null) { OnOpenSvgDocument(this, svgFile.SUID); } } catch (Exception e) { MessageBox.Show(e.Message, "打开失败"); } finally { Cursor = Cursors.Default; } }
/* public void Open(string _SvgUID) { try { if (_SvgUID.Length < 20) { JxtBar(); tlVectorControl1.ContextMenuStrip = null; } SVGFILE svgFile = new SVGFILE(); svgFile.SUID = _SvgUID; SvgDocument document = CtrlSvgView.CashSvgDocument; if (document == null) { IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile); if (svgList.Count > 0) { svgFile = (SVGFILE)svgList[0]; } document = new SvgDocument(); if (!string.IsNullOrEmpty(svgFile.SVGDATA)) { document.LoadXml(svgFile.SVGDATA); } document.FileName = svgFile.FILENAME; document.SvgdataUid = svgFile.SUID; } SVGUID = document.SvgdataUid; img = document.SelectSingleNode("//*[@TLGH=\"1\"]"); if (img != null) { ((XmlElement)img).SetAttribute("xlink:href", " "); } this.Text = document.FileName; if (document.RootElement == null) { tlVectorControl1.NewFile(); Layer.CreateNew("背景层", tlVectorControl1.SVGDocument); Layer.CreateNew("城市规划层", tlVectorControl1.SVGDocument); Layer.CreateNew("供电区域层", tlVectorControl1.SVGDocument); } else { tlVectorControl1.SVGDocument = document; } tlVectorControl1.SVGDocument.SvgdataUid = SVGUID; tlVectorControl1.SVGDocument.FileName = this.Text; tlVectorControl1.DocumentbgColor = Color.White; tlVectorControl1.BackColor = Color.White; //tlVectorControl1.ForeColor = Color.White; CreateComboBox(); xltProcessor = new XLTProcessor(tlVectorControl1); xltProcessor.MapView = mapview; xltProcessor.OnNewLine += new NewLineDelegate(xltProcessor_OnNewLine); } catch (Exception e) { MessageBox.Show(e.Message); } }*/ public void Open2(string _SvgUID) { StringBuilder txt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"1500\" height=\"1000\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\" transform=\"matrix(1 0 0 1 0 1)\"><defs>"); string svgdefs = ""; string layertxt = ""; StringBuilder content = new StringBuilder(); string where = ""; if (string.IsNullOrEmpty(_SvgUID)) return; try { if (progtype == "城市规划层") { where = " (layerType = '城市规划层') OR (layerType = '地理信息层') "; } else { where = " (layerType = '地理信息层') "; } SVGFILE svgFile = new SVGFILE(); svgFile.SUID = _SvgUID; svgFile = (SVGFILE)Services.BaseService.GetObject("SelectSVGFILEByKey", svgFile); //SvgDocument document = CashSvgDocument; //if (document == null) { SVG_LAYER lar = new SVG_LAYER(); lar.svgID = _SvgUID; lar.YearID = where; IList<SVG_LAYER> larlist = Services.BaseService.GetList<SVG_LAYER>("SelectSVG_LAYERByWhere", lar); foreach (SVG_LAYER _lar in larlist) { layertxt = layertxt + "<layer id=\"" + _lar.SUID + "\" label=\"" + _lar.NAME + "\" layerType=\"" + _lar.layerType + "\" visibility=\"" + _lar.visibility + "\" ParentID=\"" + _lar.YearID + "\" IsSelect=\"" + _lar.IsSelect + "\" />"; content.Append(_lar.XML); } txt.Append(layertxt); SVG_SYMBOL sym = new SVG_SYMBOL(); sym.svgID = _SvgUID; IList<SVG_SYMBOL> symlist = Services.BaseService.GetList<SVG_SYMBOL>("SelectSVG_SYMBOLBySvgID", sym); foreach (SVG_SYMBOL _sym in symlist) { svgdefs = svgdefs + _sym.XML; } txt.Append(svgdefs + "</defs>"); txt.Append(content.ToString() + "</svg>"); SvgDocument document = new SvgDocument(); document.LoadXml(txt.ToString()); document.FileName = SvgName; document.SvgdataUid = _SvgUID; SVGUID = _SvgUID; this.Text = document.FileName; if (document.RootElement == null) { tlVectorControl1.NewFile(); Layer.CreateNew("背景层", tlVectorControl1.SVGDocument); Layer.CreateNew("城市规划层", tlVectorControl1.SVGDocument); Layer.CreateNew("供电区域层", tlVectorControl1.SVGDocument); } else { tlVectorControl1.SVGDocument = document; } tlVectorControl1.SVGDocument.SvgdataUid = _SvgUID; tlVectorControl1.SVGDocument.FileName = this.Text; tlVectorControl1.DocumentbgColor = Color.White; tlVectorControl1.BackColor = Color.White; //tlVectorControl1.ForeColor = Color.White; CreateComboBox(); xltProcessor = new XLTProcessor(tlVectorControl1); xltProcessor.MapView = mapview; xltProcessor.OnNewLine += new NewLineDelegate(xltProcessor_OnNewLine); } catch (Exception e) { MessageBox.Show(e.Message); } }
public void Open(string _SvgUID) { try { //dotNetBarManager1.Bars["mainmenu"].GetItem("WJYHBut").Visible = false; //为版本用 if (_SvgUID.Length < 20) { JxtBar(); tlVectorControl1.ContextMenuStrip = null; } StringBuilder txt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"1500\" height=\"1000\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\" transform=\"matrix(1 0 0 1 0 1)\"><defs>"); string svgdefs = ""; string layertxt = ""; StringBuilder content = new StringBuilder(); if (string.IsNullOrEmpty(_SvgUID)) return; SVG_LAYER lar = new SVG_LAYER(); lar.svgID = _SvgUID; lar.YearID = yearID; IList<SVG_LAYER> larlist = Services.BaseService.GetList<SVG_LAYER>("SelectSVG_LAYERByYearID", lar); foreach (SVG_LAYER _lar in larlist) { layertxt = layertxt + "<layer id=\"" + _lar.SUID + "\" label=\"" + _lar.NAME + "\" layerType=\"" + _lar.layerType + "\" visibility=\"" + _lar.visibility + "\" ParentID=\"" + _lar.YearID + "\" IsSelect=\"" + _lar.IsSelect + "\" />"; content.Append(_lar.XML); } txt.Append(layertxt); SVG_SYMBOL sym = new SVG_SYMBOL(); sym.svgID = _SvgUID; IList<SVG_SYMBOL> symlist = Services.BaseService.GetList<SVG_SYMBOL>("SelectSVG_SYMBOLBySvgID", sym); foreach (SVG_SYMBOL _sym in symlist) { svgdefs = svgdefs + _sym.XML; } txt.Append(svgdefs + "</defs>"); txt.Append(content.ToString() + "</svg>"); SvgDocument document = new SvgDocument(); document.LoadXml(txt.ToString()); document.FileName = SvgName; document.SvgdataUid = _SvgUID; SVGUID = _SvgUID; this.Text = document.FileName; if (document.RootElement == null) { tlVectorControl1.NewFile(); Layer.CreateNew("背景层", tlVectorControl1.SVGDocument); Layer.CreateNew("城市规划层", tlVectorControl1.SVGDocument); Layer.CreateNew("供电区域层", tlVectorControl1.SVGDocument); } else { tlVectorControl1.SVGDocument = document; } tlVectorControl1.SVGDocument.SvgdataUid = SVGUID; tlVectorControl1.SVGDocument.FileName = this.Text; tlVectorControl1.DocumentbgColor = Color.White; tlVectorControl1.BackColor = Color.White; //tlVectorControl1.ForeColor = Color.White; CreateComboBox(); xltProcessor = new XLTProcessor(tlVectorControl1); xltProcessor.MapView = mapview; xltProcessor.OnNewLine += new NewLineDelegate(xltProcessor_OnNewLine); } catch (Exception e) { MessageBox.Show(e.Message); } //tlVectorControl1.SVGDocument.SvgdataUid = ""; }
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 } } }
private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem.Text == "短路计算") { int tuxing = 0; int baobiao = 0; PSPDEV pspDuanlu = new PSPDEV(); pspDuanlu.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; XmlElement element = tlVectorControl1.SVGDocument.CurrentElement; pspDuanlu.EleID = element.GetAttribute("id"); pspDuanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDuanlu); if (pspDuanlu == null) return; if (pspDuanlu.Type == "Polyline" && pspDuanlu.Lable != "支路") return; frmDuanlu dudu = new frmDuanlu(pspDuanlu); PSPDEV Duanlu = new PSPDEV(); Duanlu.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; int n11 = 0, n2 = 0, n3 = 0, n4 = 0; if (dudu.ShowDialog() == DialogResult.OK) { //int bigsmall=Convert.ToInt32(dudu.DuanluBigsmall); CheckDL(); string nodeType; if (dudu.DuanluBaobiao == "是") baobiao = 1; if (dudu.DuanluTuxing == "所有故障点短路电流") tuxing = 1; if (dudu.DuanluTuxing == "指定故障点短路电流") tuxing = 2; //Duanlu.Name = dudu.DuanluPoint; //Duanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", Duanlu); n4 = Convert.ToInt32(dudu.hscool); nodeType = pspDuanlu.Type; if (pspDuanlu.Type == "Use") { n11 = 0; n2 = pspDuanlu.Number; switch (dudu.DuanluType) { case "单相接地": n3 = 1; break; case "两相接地": n3 = 3; break; case "两相故障": n3 = 2; break; case "三相故障": n3 = 0; break; default: n3 = 1; break; } string dlr = null; dlr = "0" + " " + n3.ToString() + " " + pspDuanlu.Number + " " + "-1" + " " + "-1" + n4; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt"); } FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate); StreamWriter str11 = new StreamWriter(VK); str11.Write(dlr); str11.Close(); n4 = 0; } else if (pspDuanlu.Type == "Polyline") { //n11 = pspDuanlu.FirstNode; //n2 = pspDuanlu.LastNode; n11 = pspDuanlu.Number; n2 = n11; switch (dudu.DuanluType) { case "单相接地": n3 = 1; break; case "两相接地": n3 = 3; break; case "两相故障": n3 = 2; break; case "三相故障": n3 = 0; break; default: n3 = 1; break; } string dlr = null; dlr = "0" + " " + n3.ToString() + " " + pspDuanlu.Number + " " + pspDuanlu.FirstNode + " " + pspDuanlu.LastNode + " " + n4; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt"); } FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate); StreamWriter str11 = new StreamWriter(VK); str11.Write(dlr); str11.Close(); } else { return; } XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']"); foreach (XmlNode node in list) { SvgElement elementde = node as SvgElement; tlVectorControl1.SVGDocument.CurrentElement = elementde; tlVectorControl1.Delete(); } shortcir shortCutCal = new shortcir(); shortCutCal.Show_shortcir(0,0); string duanResult = null; duanResult += "短路电流简表" + "\r\n" + "\r\n"; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt")) { } else { return; } FileStream shorcuit = new FileStream(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt", FileMode.Open); StreamReader readLineGU = new StreamReader(shorcuit, System.Text.Encoding.Default); string strLineGU; string[] arrayGU; char[] charSplitGU = new char[] { ' ' }; strLineGU = readLineGU.ReadLine(); while (strLineGU != null) { arrayGU = strLineGU.Split(charSplitGU); int i = 0; string[] dev = new string[9]; dev.Initialize(); foreach (string str in arrayGU) { if (str != "") { dev[i++] = str; } } if (tuxing == 2) { PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; CR.Name = dev[1]; CR.Type = nodeType; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null) { if (CR.Type != "Polyline") { XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement; if (elementdl != null) { RectangleF bound = ((IGraph)elementdl).GetBounds(); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; n1.SetAttribute("x", Convert.ToString(bound.X)); n1.SetAttribute("y", Convert.ToString(bound.Y - 20)); n1.InnerText = (Convert.ToDouble(dev[3])).ToString("N4"); n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("flag", "1"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Refresh(); } } else { XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement; if (elementdl != null) { PointF[] t = ((Polyline)elementdl).Points; PointF[] t2 = ((Polyline)elementdl).FirstTwoPoint; t = t2; PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2)); float angel = 0f; angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI); string l3 = Convert.ToString(midt.X); string l4 = Convert.ToString(midt.Y); string tran = ((Polyline)elementdl).Transform.ToString(); PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2)); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; XmlElement n2dl = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180))); PSPDEV psp = new PSPDEV(); psp.FirstNode = CR.FirstNode; psp.LastNode = CR.LastNode; psp.SvgUID = CR.SvgUID; PSPDEV tempss = new PSPDEV(); IList listParallel = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandFirstOrLastNode", psp); foreach (PSPDEV devP in listParallel) { if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350)) { if (((devP.X1) > (CR.X1))) { pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180))); } } else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90)) { if (((devP.Y1) > (CR.Y1))) { pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180))); } } else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180)) { if (((devP.Y1) > (CR.Y1))) { pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180))); } } } PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel))); n1.SetAttribute("x", Convert.ToString(pStart.X)); n1.SetAttribute("y", Convert.ToString(pStart.Y)); //if (Convert.ToDouble(dev[4]) >= 0) //{ n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4"); //} //else //{ // n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4"); //} n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("flag", "1"); //if (Convert.ToDouble(dev[5]) == 1) // n1.SetAttribute("stroke", "#FF0000"); PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 25) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 25) * Math.PI / 180))); PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 335) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 335) * Math.PI / 180))); if (Convert.ToDouble(dev[3]) < 0) { p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 155) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 155) * Math.PI / 180))); p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 205) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 205) * Math.PI / 180))); } string l1 = Convert.ToString(p1.X); string l2 = Convert.ToString(p1.Y); string l5 = Convert.ToString(p2.X); string l6 = Convert.ToString(p2.Y); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; RectangleF ttt = ((Polyline)elementdl).GetBounds(); tlVectorControl1.RotateSelection(angel, pStart); if (Math.Abs(angel) > 90) tlVectorControl1.RotateSelection(180, pStart); PointF newp = new PointF(center.X + 10, center.Y + 10); tlVectorControl1.Refresh(); } } } } duanResult += dev[0] + "," + dev[1] + "," + dev[3] + "\r\n"; strLineGU = readLineGU.ReadLine(); } string dianYaResult = null; dianYaResult += "母线电压结果" + "\r\n" + "\r\n"; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt")) { } else { return; } FileStream dianYa = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt", FileMode.Open); StreamReader readLineDY = new StreamReader(dianYa, System.Text.Encoding.Default); string strLineDY; string[] arrayDY; char[] charSplitDY = new char[] { ' ' }; strLineDY = readLineDY.ReadLine(); while (strLineDY != null) { arrayDY = strLineDY.Split(charSplitDY); int i = 0; string[] dev = new string[14]; dev.Initialize(); foreach (string str in arrayDY) { if (str != "") { dev[i++] = str; } } PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; CR.Name = dev[1]; CR.Type = nodeType; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (tuxing == 1) { XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement; if (elementdl != null) { RectangleF bound = ((IGraph)elementdl).GetBounds(); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; XmlElement n22 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; XmlElement n33 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; n1.SetAttribute("x", Convert.ToString(bound.X)); n1.SetAttribute("y", Convert.ToString(bound.Y - 60)); n1.InnerText = "A相:" + (Convert.ToDouble(dev[8])).ToString("N4") + "Kv/" + (Convert.ToDouble(dev[9])).ToString("N4") + "°"; n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("flag", "1"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Refresh(); n22.SetAttribute("x", Convert.ToString(bound.X)); n22.SetAttribute("y", Convert.ToString(bound.Y - 40)); n22.InnerText = "B相:" + (Convert.ToDouble(dev[10])).ToString("N4") + "Kv/" + (Convert.ToDouble(dev[11])).ToString("N4") + "°"; n22.SetAttribute("layer", SvgDocument.currentLayer); n22.SetAttribute("flag", "1"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n22); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Refresh(); n33.SetAttribute("x", Convert.ToString(bound.X)); n33.SetAttribute("y", Convert.ToString(bound.Y - 20)); n33.InnerText = "C相:" + (Convert.ToDouble(dev[12])).ToString("N4") + "Kv/" + (Convert.ToDouble(dev[13])).ToString("N4") + "°"; n33.SetAttribute("layer", SvgDocument.currentLayer); n33.SetAttribute("flag", "1"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n33); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Refresh(); } } dianYaResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," + dev[9] + "," + dev[10] + "," + dev[11] + "," + dev[12] + "," + dev[13] + "\r\n"; strLineDY = readLineDY.ReadLine(); } string dianLiuResult = null; dianLiuResult += "支路电流结果" + "\r\n" + "\r\n"; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt")) { } else { return; } FileStream dianLiu = new FileStream(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt", FileMode.Open); StreamReader readLineDL = new StreamReader(dianLiu, System.Text.Encoding.Default); string strLineDL; string[] arrayDL; char[] charSplitDL = new char[] { ' ' }; strLineDL = readLineDL.ReadLine(); while (strLineDL != null) { arrayDL = strLineDL.Split(charSplitDL); int i = 0; string[] dev = new string[15]; dev.Initialize(); foreach (string str in arrayDL) { if (str != "") { dev[i++] = str; } } PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; CR.Name = dev[1]; CR.Type = nodeType; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (tuxing == 1) { XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + CR.EleID + "']") as XmlElement; if (elementdl != null) { PointF[] t = ((Polyline)elementdl).Points; PointF[] t2 = ((Polyline)elementdl).FirstTwoPoint; t = t2; PointF midt = new PointF((float)((t2[0].X + t2[1].X) / 2), (float)((t2[0].Y + t2[1].Y) / 2)); float angel = 0f; angel = (float)(180 * Math.Atan2((t2[1].Y - t2[0].Y), (t2[1].X - t2[0].X)) / Math.PI); string l3 = Convert.ToString(midt.X); string l4 = Convert.ToString(midt.Y); string tran = ((Polyline)elementdl).Transform.ToString(); PointF center = new PointF((float)(t[0].X + (t[1].X - t[0].X) / 2), (float)(t[0].Y + (t[1].Y - t[0].Y) / 2)); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; XmlElement n2dl = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180))); PSPDEV psp = new PSPDEV(); psp.FirstNode = CR.FirstNode; psp.LastNode = CR.LastNode; psp.SvgUID = CR.SvgUID; PSPDEV tempss = new PSPDEV(); IList listParallel = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandFirstOrLastNode", psp); foreach (PSPDEV devP in listParallel) { if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350)) { if (((devP.X1) > (CR.X1))) { pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180))); } } else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90)) { if (((devP.Y1) > (CR.Y1))) { pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180))); } } else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180)) { if (((devP.Y1) > (CR.Y1))) { pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180))); } } } PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel))); n1.SetAttribute("x", Convert.ToString(pStart.X)); n1.SetAttribute("y", Convert.ToString(pStart.Y)); //if (Convert.ToDouble(dev[4]) >= 0) //{ n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4"); //} //else //{ // n1.InnerText = (Math.Abs(Convert.ToDouble(dev[3]))).ToString("N4"); //} n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("flag", "1"); //if (Convert.ToDouble(dev[3]) == 1) // n1.SetAttribute("stroke", "#FF0000"); PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 25) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 25) * Math.PI / 180))); PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 335) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 335) * Math.PI / 180))); if (Convert.ToDouble(dev[3]) < 0) { p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 155) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 155) * Math.PI / 180))); p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 205) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 205) * Math.PI / 180))); } string l1 = Convert.ToString(p1.X); string l2 = Convert.ToString(p1.Y); string l5 = Convert.ToString(p2.X); string l6 = Convert.ToString(p2.Y); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement; RectangleF ttt = ((Polyline)elementdl).GetBounds(); tlVectorControl1.RotateSelection(angel, pStart); if (Math.Abs(angel) > 90) tlVectorControl1.RotateSelection(180, pStart); PointF newp = new PointF(center.X + 10, center.Y + 10); tlVectorControl1.Refresh(); } } dianLiuResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," + dev[9] + "," + dev[10] + "," + dev[11] + dev[12] + "," + dev[13] + "," + dev[14] + "\r\n"; strLineDL = readLineDL.ReadLine(); } if (baobiao == 1) { if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv"); } FileStream tempGU = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate); StreamWriter strGU = new StreamWriter(tempGU, Encoding.GetEncoding("GB2312")); strGU.Write(duanResult); strGU.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); } FileStream tempDY = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate); StreamWriter strDY = new StreamWriter(tempDY, Encoding.GetEncoding("GB2312")); strDY.Write(dianYaResult); strDY.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result2.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result2.csv"); } FileStream tempDL = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result2.csv"), FileMode.OpenOrCreate); StreamWriter strDL = new StreamWriter(tempDL, Encoding.GetEncoding("GB2312")); strDL.Write(dianLiuResult); strDL.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + "短路计算结果.xls")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + "短路计算结果.xls"); } Excel.Application ex; Excel.Worksheet xSheet; Excel.Application result1; Excel.Application result2; Excel.Worksheet tempSheet; Excel.Worksheet tempSheet1; Excel.Worksheet newWorksheet; Excel.Worksheet newWorkSheet1; object oMissing = System.Reflection.Missing.Value; ex = new Excel.Application(); ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv"); xSheet = (Excel.Worksheet)ex.Worksheets[1]; ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value); xSheet = (Excel.Worksheet)ex.Worksheets[2]; ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value); xSheet = (Excel.Worksheet)ex.Worksheets[1]; result1 = new Excel.Application(); result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); result2 = new Excel.Application(); result2.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result2.csv"); tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1); tempSheet1 = (Excel.Worksheet)result2.Worksheets.get_Item(1); newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2); newWorkSheet1 = (Excel.Worksheet)ex.Worksheets.get_Item(3); newWorksheet.Name = "母线电压"; newWorkSheet1.Name = "支路电流"; xSheet.Name = "短路电流"; ex.Visible = true; tempSheet.Cells.Select(); tempSheet.Cells.Copy(System.Reflection.Missing.Value); newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value); tempSheet1.Cells.Select(); tempSheet1.Cells.Copy(System.Reflection.Missing.Value); newWorkSheet1.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value); xSheet.Rows.AutoFit(); xSheet.Columns.AutoFit(); newWorksheet.Rows.AutoFit(); newWorksheet.Columns.AutoFit(); newWorkSheet1.Rows.AutoFit(); newWorkSheet1.Columns.AutoFit(); xSheet.UsedRange.Font.Name = "楷体_GB2312"; newWorksheet.UsedRange.Font.Name = "楷体_GB2312"; newWorkSheet1.UsedRange.Font.Name = "楷体_GB2312"; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 3]).MergeCells = true; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体"; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[3, 3]).Interior.ColorIndex = 45; xSheet.get_Range(xSheet.Cells[4, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; xSheet.get_Range(xSheet.Cells[4, 3], xSheet.Cells[xSheet.UsedRange.Rows.Count, 13]).NumberFormat = "0.0000_ "; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 14]).MergeCells = true; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体"; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[3, 14]).Interior.ColorIndex = 45; newWorksheet.get_Range(newWorksheet.Cells[4, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; newWorksheet.get_Range(newWorksheet.Cells[4, 3], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 14]).NumberFormat = "0.0000_ "; newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 15]).MergeCells = true; newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Size = 20; newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).Font.Name = "黑体"; newWorkSheet1.get_Range(newWorkSheet1.Cells[1, 1], newWorkSheet1.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; newWorkSheet1.get_Range(newWorkSheet1.Cells[3, 1], newWorkSheet1.Cells[3, 14]).Interior.ColorIndex = 45; newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 1], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 2], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 2]).Interior.ColorIndex = 6; newWorkSheet1.get_Range(newWorkSheet1.Cells[4, 4], newWorkSheet1.Cells[newWorkSheet1.UsedRange.Rows.Count, 14]).NumberFormat = "0.0000_ "; newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + "短路计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null); System.Windows.Forms.Clipboard.Clear(); result1.Workbooks.Close(); result1.Quit(); result2.Workbooks.Close(); result2.Quit(); } } } if (e.ClickedItem.Text == "区域打印") { PrintHelper ph = new PrintHelper(tlVectorControl1, mapview); frmPrinter dlg = new frmPrinter(); dlg.printHelper = ph; dlg.ShowDialog(); return; ArrayList idlist = new ArrayList(); ArrayList symlist = new ArrayList(); SvgDocument _doc = new SvgDocument(); Graph poly1 = tlVectorControl1.SVGDocument.CurrentElement as Graph; if (poly1 == null || poly1.GetAttribute("id") == "svg") { return; } GraphicsPath gr1 = new GraphicsPath(); gr1.AddPolygon(TLMath.getPolygonPoints(poly1)); gr1 = (GraphicsPath)poly1.GPath.Clone(); gr1.Transform((poly1 as IGraph).Transform.Matrix); RectangleF ef1 = gr1.GetBounds(); ef1 = PathFunc.GetBounds(gr1); StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">"); XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("defs"); if (nlist.Count > 0) { XmlNode node = nlist[0]; svgtxt.AppendLine(node.OuterXml); } SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator(); while (enumerator1.MoveNext()) { IGraph graph1 = (IGraph)enumerator1.Current; GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone(); if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue; GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone(); path2.Transform(graph1.Transform.Matrix); RectangleF ef2 = PathFunc.GetBounds(path2); if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty) { SvgElement ele = (SvgElement)graph1; svgtxt.AppendLine(ele.OuterXml); if (graph1 is Use) { string symid = ((XmlElement)graph1).GetAttribute("xlink:href"); if (!symlist.Contains(symid)) { symlist.Add(symid); } } if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") { string IsLead = ((XmlElement)graph1).GetAttribute("IsLead"); if (IsLead != "") { if (ef1.Contains(ef2)) { idlist.Add(graph1.ID); } } } } } //symlist = ResetList(symlist); svgtxt.AppendLine("</svg>"); _doc.LoadXml(svgtxt.ToString()); _doc.SvgdataUid = tlVectorControl1.SVGDocument.CurrentLayer.ID; frmPrintF pri = new frmPrintF(); pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.CurrentLayer.ID); if (pri.ShowDialog() == DialogResult.OK) { frmSubPrint s = new frmSubPrint(); s.Vector = tlVectorControl1; s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist); s.Open(_doc, ef1); s.Show(); } } if (e.ClickedItem.Text == "属性") { //if (!Check()) //{ // return; //} XmlElement element = tlVectorControl1.SVGDocument.CurrentElement; if (element is Use) { if (element.GetAttribute("xlink:href").Contains("Substation") || element.GetAttribute("xlink:href").Contains("motherlinenode")) { string str_power = getPower(element.GetAttribute("xlink:href")); PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmSubstation dlg; if (pspDev != null) { dlg = new frmSubstation(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Use"; if (element.GetAttribute("xlink:href").Contains("Substation")) { pspDev.Lable = "变电站"; } else if (element.GetAttribute("xlink:href").Contains("motherlinenode")) { pspDev.Lable = "母线节点"; } else if (element.GetAttribute("xlink:href").Contains("Power")) { pspDev.Lable = "电厂"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmSubstation(pspDev); } dlg.Str_Power = str_power; dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "Use"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; (text as Text).SetAttribute("print", dlg.IsTJ ? "no" : "yes"); } pspDev.VoltR = Convert.ToDouble(dlg.VoltR); pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); pspDev.Burthen = Convert.ToDecimal(dlg.Burthen); element.SetAttribute("print", dlg.IsTJ ? "no" : "yes"); pspDev.OutP = Convert.ToDouble(dlg.OutP); pspDev.OutQ = Convert.ToDouble(dlg.OutQ); ; //if (pspDev.InPutP==0) pspDev.InPutP = Convert.ToDouble(dlg.InPutP); pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); if (dlg.NodeType == "是") { pspDev.NodeType = "0"; } else { pspDev.NodeType = "1"; } Services.BaseService.Update<PSPDEV>(pspDev); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg.TYear); } } else if (element.GetAttribute("xlink:href").Contains("Power")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmSubstation dlg; if (pspDev != null) { dlg = new frmSubstation(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Use"; if (element.GetAttribute("xlink:href").Contains("Substation")) { pspDev.Lable = "变电站"; } else if (element.GetAttribute("xlink:href").Contains("motherlinenode")) { pspDev.Lable = "母线节点"; } else if (element.GetAttribute("xlink:href").Contains("Power")) { pspDev.Lable = "电厂"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmSubstation(pspDev); dlg.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "Use"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.VoltR = Convert.ToDouble(dlg.VoltR); pspDev.Burthen = Convert.ToDecimal(dlg.Burthen); pspDev.OutP = Convert.ToDouble(dlg.OutP); pspDev.OutQ = Convert.ToDouble(dlg.OutQ); pspDev.InPutP = Convert.ToDouble(dlg.InPutP); pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); pspDev.ReferenceVolt = Convert.ToDouble(dlg.ReferenceVolt); if (dlg.NodeType == "是") { pspDev.NodeType = "0"; } else { pspDev.NodeType = "2"; } Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmFadejie dlg; if (pspDev != null) { dlg = new frmFadejie(pspDev, pspDev.SvgUID); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "dynamotorline"; if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { pspDev.Lable = "发电厂支路"; } else if (element.GetAttribute("xlink:href").Contains("gndline")) { pspDev.Lable = "接地支路"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmFadejie(pspDev, pspDev.SvgUID); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "dynamotorline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; if (dlg.OutP != "") pspDev.OutP = Convert.ToDouble(dlg.OutP); if (dlg.OutQ != "") pspDev.OutQ = Convert.ToDouble(dlg.OutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); if (dlg.VoltV != "") pspDev.VoltV = Convert.ToDouble(dlg.VoltV); if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); if (dlg.NegativeTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("gndline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmFadejie dlg; if (pspDev != null) { dlg = new frmFadejie(pspDev, pspDev.SvgUID); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "gndline"; if (element.GetAttribute("xlink:href").Contains("dynamotorline")) { pspDev.Lable = "发电厂支路"; } else if (element.GetAttribute("xlink:href").Contains("gndline")) { pspDev.Lable = "接地支路"; } Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmFadejie(pspDev, pspDev.SvgUID); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "gndline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; if (dlg.OutP != "") pspDev.OutP = Convert.ToDouble(dlg.OutP); if (dlg.OutQ != "") pspDev.OutQ = Convert.ToDouble(dlg.OutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); if (dlg.VoltV != "") pspDev.VoltV = Convert.ToDouble(dlg.VoltV); if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); if (dlg.NegativeTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.NegativeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("loadline")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLoad dlg; if (pspDev != null) { dlg = new frmLoad(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = 0; pspDev.Type = "loadline"; pspDev.Lable = "负荷支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmLoad(pspDev); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "loadline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine3 = dlg.LoadSwitchState; if (dlg.InPutP != "") pspDev.InPutP = Convert.ToDouble(dlg.InPutP); if (dlg.InPutQ != "") pspDev.InPutQ = Convert.ToDouble(dlg.InPutQ); if (dlg.VoltR != "") pspDev.VoltR = Convert.ToDouble(dlg.VoltR); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("串联电容电抗器")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmCapacity dlg; if (pspDev != null) { dlg = new frmCapacity(pspDev, pspDev.SvgUID); dlg.SetEnable(true); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "串联电容电抗器"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; // pspDev.HuganLine2 = dlg.LastNodeName; if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("并联电容电抗器")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmCapacity dlg; if (pspDev != null) { dlg = new frmCapacity(pspDev, pspDev.SvgUID); dlg.SetEnable(false); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "并联电容电抗器"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; //pspDev.HuganLine2 = dlg.LastNodeName; if (dlg.PositiveTQ != "") pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("transformerthirdzu")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmThridTra dlg; if (pspDev != null) { dlg = new frmThridTra(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "transformerthirdzu"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.IName; pspDev.HuganLine2 = dlg.JName; pspDev.HuganLine3 = dlg.ISwitchState; pspDev.HuganLine4 = dlg.JSwitchState; pspDev.LineLevel = dlg.IType; pspDev.LineType = dlg.JType; pspDev.LineStatus = dlg.KType; pspDev.KName = dlg.KName; pspDev.KSwitchStatus = dlg.KSwitchState; if (dlg.IK != "") { pspDev.K = Convert.ToDouble(dlg.KK); } if (dlg.JK != "") { pspDev.G = Convert.ToDouble(dlg.JK); } if (dlg.KK != "") { pspDev.BigP = Convert.ToDouble(dlg.KK); } if (dlg.IR != "") { pspDev.HuganTQ1 = Convert.ToDouble(dlg.IR); } if (dlg.JR != "") { pspDev.HuganTQ2 = Convert.ToDouble(dlg.JR); } if (dlg.KR != "") { pspDev.HuganTQ3 = Convert.ToDouble(dlg.KR); } if (dlg.ITQ != "") { pspDev.HuganTQ4 = Convert.ToDouble(dlg.ITQ); } if (dlg.JTQ != "") { pspDev.HuganTQ5 = Convert.ToDouble(dlg.JTQ); } if (dlg.KTQ != "") { pspDev.SmallTQ = Convert.ToDouble(dlg.KTQ); } if (dlg.ZeroTQ != "") pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); if (dlg.NeutralNodeTQ != "") pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("transformertwozu")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmTwoTra dlg; if (pspDev != null) { dlg = new frmTwoTra(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "transformertwozu"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstName; pspDev.HuganLine2 = dlg.LastName; pspDev.HuganLine3 = dlg.FirstSwitchState; pspDev.HuganLine4 = dlg.LastSwitchState; pspDev.LineLevel = dlg.FirstType; pspDev.LineType = dlg.LastType; if (dlg.PositiveR != "") { pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR); } if (dlg.PositiveTQ != "") { pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); } if (dlg.ZeroR != "") { pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR); } if (dlg.ZeroTQ != "") { pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); } if (dlg.K != "") pspDev.K = Convert.ToDouble(dlg.K); if (dlg.NeutralNodeTQ != "") pspDev.BigTQ = Convert.ToDouble(dlg.NeutralNodeTQ); Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("1/2母联开关")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmMuLian dlg; if (pspDev != null) { dlg = new frmMuLian(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "1/2母联开关"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.FirstNodeName; pspDev.HuganLine2 = dlg.LastNodeName; pspDev.HuganLine3 = dlg.SwitchStatus; Services.BaseService.Update<PSPDEV>(pspDev); } } else if (element.GetAttribute("xlink:href").Contains("2/3母联开关")) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmMuLian2 dlg; if (pspDev != null) { dlg = new frmMuLian2(pspDev, pspDev.SvgUID); } else { return; } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "2/3母联开关"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + pspDev.EleID + "']"); if (text != null) { (text as Text).InnerText = dlg.Name; } pspDev.HuganLine1 = dlg.INodeName; pspDev.HuganLine2 = dlg.JNodeName; pspDev.HuganLine3 = dlg.ILineName; pspDev.HuganLine4 = dlg.JLineName; pspDev.KName = dlg.ILoadName; pspDev.KSwitchStatus = dlg.JLoadName; pspDev.LineLevel = dlg.SwitchStatus1; pspDev.LineType = dlg.SwitchStatus2; pspDev.LineStatus = dlg.SwitchStatus3; Services.BaseService.Update<PSPDEV>(pspDev); } } } else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType == true) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLinenew dlg2; if (pspDev != null) { dlg2 = new frmLinenew(pspDev); dlg2.derefucelineflag = Reducelineflag; } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Polyline"; pspDev.Lable = "支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg2 = new frmLinenew(pspDev); dlg2.derefucelineflag = Reducelineflag; } dlg2.TYear = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("year"); dlg2.linevalue = tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("linevalue"); //获得线路投资 if (dlg2.ShowDialog() == DialogResult.OK) { if (dlg2.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg2.Name; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspName.Type = "Polyline"; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg2.Name; pspDev.LineLength = Convert.ToDouble(dlg2.LineLength); pspDev.LineR = Convert.ToDouble(dlg2.LineR); pspDev.LineTQ = Convert.ToDouble(dlg2.LineTQ); pspDev.LineGNDC = Convert.ToDouble(dlg2.LineGNDC); pspDev.LineLevel = dlg2.LineLevel; pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt); pspDev.LineType = dlg2.LineType; pspDev.LineStatus = dlg2.LineStatus; WireCategory wirewire = new WireCategory(); wirewire.WireType = dlg2.LineType; if (dlg2.linevalue != "") { pspDev.BigP = Convert.ToDouble(dlg2.linevalue); } if (dlg2.ReferenceVolt != "") { pspDev.ReferenceVolt = Convert.ToDouble(dlg2.ReferenceVolt); } WireCategory wirewire2 = new WireCategory(); wirewire2 = (WireCategory)Services.BaseService.GetObject("SelectWireCategoryByKey", wirewire); //if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength)*wirewire2.WireR ; //if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireTQ; //if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * wirewire2.WireGNDC; if (wirewire2 != null) pspDev.LineChange = (double)wirewire2.WireChange; string tempp = dlg2.LineLev; int tel = tempp.Length; //tempp = tempp.Substring(0, tel - 2); pspDev.VoltR = Convert.ToDouble(tempp); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("year", dlg2.TYear); tlVectorControl1.SVGDocument.CurrentElement.SetAttribute("linevalue", dlg2.linevalue); //获得线路投资 //switch (dlg2.LineType) //{ // case "2*LGJ-400": // { // if (pspDev.LineR==0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.04; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.303; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.054; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.308; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.066; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.310; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // if (pspDev.LineR == 0) // pspDev.LineR = Convert.ToDouble(dlg2.LineLength) * 0.08; // if (pspDev.LineTQ == 0) // pspDev.LineTQ = Convert.ToDouble(dlg2.LineLength) * 0.417; // if (pspDev.LineGNDC == 0) // pspDev.LineGNDC = Convert.ToDouble(dlg2.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} Services.BaseService.Update<PSPDEV>(pspDev); Topology2(); } } else if ((element is Polyline) && element.GetAttribute("flag") != "1" && fileType != true) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); frmLine dlg; if (pspDev != null) { dlg = new frmLine(pspDev); } else { pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Polyline"; pspDev.Lable = "支路"; Services.BaseService.Create<PSPDEV>(pspDev); dlg = new frmLine(pspDev); } if (dlg.ShowDialog() == DialogResult.OK) { if (dlg.Name == null) { MessageBox.Show("名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PSPDEV pspName = new PSPDEV(); pspName.Name = dlg.Name; pspName.Type = "Polyline"; pspName.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList listName = Services.BaseService.GetList("SelectPSPDEVByName", pspName); if (listName.Count >= 2 || (listName.Count == 1 && (listName[0] as PSPDEV).EleID != pspDev.EleID)) { MessageBox.Show("名称已存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } pspDev.Name = dlg.Name; pspDev.LineLength = Convert.ToDouble(dlg.LineLength); pspDev.LineLevel = dlg.LineLevel; pspDev.LineType = dlg.LineType; pspDev.LineStatus = dlg.LineStatus; pspDev.PositiveR = Convert.ToDouble(dlg.PositiveR); pspDev.PositiveTQ = Convert.ToDouble(dlg.PositiveTQ); pspDev.ZeroR = Convert.ToDouble(dlg.ZeroR); pspDev.ZeroTQ = Convert.ToDouble(dlg.ZeroTQ); if (dlg.HuganFirst == "是") pspDev.HuganFirst = 1; else pspDev.HuganFirst = 0; pspDev.HuganLine1 = dlg.HuganLine1; pspDev.HuganLine2 = dlg.HuganLine2; pspDev.HuganLine3 = dlg.HuganLine3; pspDev.HuganLine4 = dlg.HuganLine4; pspDev.HuganTQ1 = Convert.ToDouble(dlg.HuganTQ1); pspDev.HuganTQ2 = Convert.ToDouble(dlg.HuganTQ2); pspDev.HuganTQ3 = Convert.ToDouble(dlg.HuganTQ3); pspDev.HuganTQ4 = Convert.ToDouble(dlg.HuganTQ4); pspDev.HuganTQ5 = Convert.ToDouble(dlg.HuganTQ5); string tempp = dlg.LineLev; int tel = tempp.Length; if (tel == 1) pspDev.VoltR = 0; else { //tempp = tempp.Substring(0, tel - 2); pspDev.VoltR = Convert.ToDouble(tempp); } //switch (dlg.LineType) //{ // case "2*LGJ-400": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.04; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.303; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.9; // pspDev.LineChange = 1690; // } break; // case "2*LGJ-300": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.054; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.308; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.7; // pspDev.LineChange = 1400; // } break; // case "2*LGJ-240": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.066; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.310; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 17.5; // pspDev.LineChange = 1220; // } break; // case "LGJ-400": // { // pspDev.LineR = Convert.ToDouble(dlg.LineLength) * 0.08; // pspDev.LineTQ = Convert.ToDouble(dlg.LineLength) * 0.417; // pspDev.LineGNDC = Convert.ToDouble(dlg.LineLength) * 13.2; // pspDev.LineChange = 845; // } break; //} Services.BaseService.Update<PSPDEV>(pspDev); Topology2(); } } } tlVectorControl1.Operation = ToolOperation.Select; //contextMenuStrip1.Hide(); }
private void dotNetBarManager1_ItemClick(object sender, EventArgs e) { FileStream dh; StreamReader readLine; char[] charSplit; string strLine; string[] array1; string output = null; string[] array2; string strLine2; char[] charSplit2 = new char[] { ' ' }; FileStream op; StreamWriter str1; FileStream dh2; StreamReader readLine2; Excel.Application ex; Excel.Worksheet xSheet; Excel.Application result1; Excel.Worksheet tempSheet; Excel.Worksheet newWorksheet; DevComponents.DotNetBar.ButtonItem btItem = sender as DevComponents.DotNetBar.ButtonItem; //Layer layer1 = (Layer)LayerBox.ComboBoxEx.SelectedItem; if (btItem != null) { switch (btItem.Name) { #region 文件操作 case "mNew": try { //{ XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@layer='" + tlVectorControl1.SVGDocument.CurrentLayer.ID + "']"); for (int i = 0; i < list.Count; i++) { SvgElement ele = (SvgElement)list[i]; if (ele.LocalName == "polyline") { PSPDEV _dev = new PSPDEV(); _dev.EleID = ele.ID; _dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; _dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", _dev); if (_dev == null) { LineInfo _pl = new LineInfo(); _pl.EleID = ele.ID; _pl.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; _pl = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _pl); if (_pl != null) { PSPDEV pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = ele.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Polyline"; pspDev.Lable = "支路"; pspDev.Name = _pl.LineName; pspDev.LineLength = Convert.ToDouble(_pl.Length); pspDev.LineLevel = _pl.Voltage; pspDev.LineType = _pl.LineType; pspDev.LineStatus = "运行"; Services.BaseService.Create<PSPDEV>(pspDev); } } } if (ele.LocalName == "use") { PSPDEV _dev = new PSPDEV(); _dev.EleID = ele.ID; _dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; _dev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", _dev); if (_dev == null) { substation _pl = new substation(); _pl.EleID = ele.ID; _pl.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; _pl = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _pl); if (_pl != null) { PSPDEV pspDev = new PSPDEV(); pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = ele.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev.Number = -1; pspDev.FirstNode = -1; pspDev.LastNode = -1; pspDev.Type = "Use"; pspDev.Lable = "变电站"; pspDev.Name = _pl.EleName; pspDev.VoltR = Convert.ToDouble(_pl.ObligateField1); pspDev.Burthen = _pl.Number; Services.BaseService.Create<PSPDEV>(pspDev); } } } } PSPDEV pppp = new PSPDEV(); pppp.Type = "power"; pppp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList listpp = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", pppp); if (listpp == null || listpp.Count == 0) { if (MessageBox.Show("新建的潮流计算,需要设置基准值,是否立即设置??", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { PSPDEV pspDev2 = new PSPDEV(); //pspDev2.SUID = Guid.NewGuid().ToString(); pspDev2.Type = "Power"; pspDev2.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; pspDev2 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDAndType", pspDev2); if (pspDev2 != null) { } else { pspDev2 = new PSPDEV(); pspDev2.SUID = Guid.NewGuid().ToString(); pspDev2.Type = "Power"; pspDev2.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<PSPDEV>(pspDev2); } powerf pp = new powerf(pspDev2); if (pp.ShowDialog() == DialogResult.OK) { pspDev2.PowerFactor = Convert.ToDouble(pp.powerfactor); pspDev2.StandardVolt = Convert.ToDouble(pp.standardvolt); pspDev2.StandardCurrent = Convert.ToDouble(pp.standardcurrent); pspDev2.BigP = Convert.ToDouble(pp.bigP); Services.BaseService.Update<PSPDEV>(pspDev2); //PSPDEV voltall = new PSPDEV(); //voltall.Type = "Use"; //voltall.Lable = "电厂"; //voltall.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; //IList allvolt = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandLableandType", voltall); //foreach (PSPDEV dev in allvolt) //{ // dev.OutP = Convert.ToDouble(dev.Burthen) * pspDev2.BigP; // //dev.InPutP=dev.Burthen*pspDev2.BigP; // dev.OutQ = dev.OutP * Math.Tan(Math.Acos(pspDev2.PowerFactor)); // Services.BaseService.Update<PSPDEV>(dev); //} //voltall.Lable = "变电站"; //allvolt = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandLableandType", voltall); //foreach (PSPDEV dev in allvolt) //{ // dev.InPutP = Convert.ToDouble(dev.Burthen) * pspDev2.BigP; // //dev.InPutP=dev.Burthen*pspDev2.BigP; // dev.InPutQ = dev.InPutP * pspDev2.BigP * Math.Tan(Math.Acos(pspDev2.PowerFactor)); // Services.BaseService.Update<PSPDEV>(dev); //} } //powerf pf=new powerf() } } if (!Check()) { return; } NIULA pspniula = new NIULA(); pspniula.CurrentCal(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "牛拉法计算结果.xls")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "牛拉法计算结果.xls"); //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls"); } double yinzi = 0, capability = 0, volt = 0, current = 0, Rad_to_Deg = 57.29577951; PSPDEV benchmark = new PSPDEV(); benchmark.Type = "power"; benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark); if (list3 == null) { MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (PSPDEV dev in list3) { yinzi = Convert.ToDouble(dev.PowerFactor); capability = Convert.ToDouble(dev.StandardCurrent); volt = Convert.ToDouble(dev.StandardVolt); if (dev.PowerFactor == 0) { yinzi = 1; } if (dev.StandardCurrent == 0) { capability = 1; } if (dev.StandardVolt == 0) { volt = 1; } current = capability / (Math.Sqrt(3) * volt); } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF1.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF1.txt", FileMode.Open); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); output += ("全网母线(发电、负荷)结果报表 " + "\r\n" + "\r\n"); output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n"); output += ("母线名" + "," + "电压幅值" + "," + "电压相角" + "," + "有功发电" + "," + "无功发电" + "," + "有功负荷" + "," + "无功负荷" + "," + "越限标志" + "," + "过载标志" + "\r\n"); int count = 0; while (strLine != null && strLine != "") { array1 = strLine.Split(charSplit); string[] dev = new string[9]; dev.Initialize(); int i = 0; count++; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } CR.Number = Convert.ToInt32(dev[0]); CR.Type = "Use"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR); double vTemp = Convert.ToDouble(dev[1]) * volt; double vTemp1 = volt * 95 / 100; double vTemp2 = volt * 105 / 100; if (vTemp >= vTemp1 && vTemp <= vTemp2) { dev[5] = "0"; } else { dev[5] = "1"; } if (Convert.ToDouble(dev[3]) * capability > Convert.ToDouble(CR.Burthen)) { dev[6] = "1"; } else { dev[6] = "0"; } if (Convert.ToDouble(dev[3]) < 0) { output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + "0" + "," + "0" + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + dev[5] + "," + dev[6] + "\r\n"; } else { output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + "0" + "," + "0" + "," + dev[5] + "," + dev[6] + "\r\n"; } strLine = readLine.ReadLine(); } PSPDEV ct = new PSPDEV(); ct.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; ct.Type = "Use"; IList cont = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", ct); if (count < cont.Count) { MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); readLine.Close(); return; } readLine.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv"); } op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(output); str1.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt")) { } else { return; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open); dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH1.txt", FileMode.Open); readLine2 = new StreamReader(dh2); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); strLine2 = readLine2.ReadLine(); output = null; output += ("全网交流线结果报表" + "\r\n" + "\r\n"); output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n"); output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "," + "\r\n"); while (strLine != null && strLine2 != null && strLine != "" && strLine2 != "") { array1 = strLine.Split(charSplit); array2 = strLine2.Split(charSplit2); string[] dev = new string[20]; dev.Initialize(); int i = 0; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (i == 0) { dev[i++] = str.ToString(); } else { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } } i = 7; for (int j = 3; j < 5; j++) { if (array2[j] != "") { if (array2[j] != "NaN") { dev[i++] = Convert.ToDouble(array2[j]).ToString(); } else { dev[i++] = array2[j]; } } } CR.Name = dev[0]; CR.Type = "Polyline"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null) { if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange) { dev[11] = "1"; } else { dev[11] = "0"; } output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n"; } else { CR = new PSPDEV(); CR.Name = dev[0]; CR.Type = "TransformLine"; CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null) { if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange) { dev[11] = "1"; } else { dev[11] = "0"; } output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n"; } } strLine = readLine.ReadLine(); strLine2 = readLine2.ReadLine(); } readLine.Close(); readLine2.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); } op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(output); str1.Close(); ex = new Excel.Application(); ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv"); xSheet = (Excel.Worksheet)ex.Worksheets[1]; ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value); result1 = new Excel.Application(); result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1); newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2); newWorksheet.Name = "线路电流"; xSheet.Name = "母线潮流"; ex.Visible = true; tempSheet.Cells.Select(); tempSheet.Cells.Copy(System.Reflection.Missing.Value); newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value); xSheet.Rows.AutoFit(); xSheet.Columns.AutoFit(); newWorksheet.Rows.AutoFit(); newWorksheet.Columns.AutoFit(); xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 9]).MergeCells = true; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体"; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; xSheet.get_Range(xSheet.Cells[5, 1], xSheet.Cells[5, 9]).Interior.ColorIndex = 45; xSheet.get_Range(xSheet.Cells[6, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; xSheet.get_Range(xSheet.Cells[6, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ "; xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312"; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 9]).MergeCells = true; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体"; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; newWorksheet.get_Range(newWorksheet.Cells[5, 1], newWorksheet.Cells[5, 8]).Interior.ColorIndex = 45; newWorksheet.get_Range(newWorksheet.Cells[6, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; newWorksheet.get_Range(newWorksheet.Cells[6, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ "; newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312"; //op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fck.excel"), FileMode.OpenOrCreate); //str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); string fn = tlVectorControl1.SVGDocument.FileName; //result1.Save(System.Windows.Forms.Application.StartupPath + "\\fck.xls"); newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + fn + "牛拉法计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null); //str1.Write(); //op.Close(); System.Windows.Forms.Clipboard.Clear(); result1.Workbooks.Close(); result1.Quit(); } catch (System.Exception e1) { MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } //} break; case "mOpen": if (tlVectorControl1.IsModified == true) { DialogResult a; a = MessageBox.Show("图形已修改,是否保存?", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); if (a == DialogResult.Yes) { Save(); } else if (a == DialogResult.No) { } else if (a == DialogResult.Cancel) { return; } } Open(); break; case "btExSymbol": tlVectorControl1.ExportSymbol(); break; case "mjxt"://导入接线图 string _svguid = ConfigurationSettings.AppSettings.Get("SvgID"); frmYear f = new frmYear(); f.uid = _svguid; f.Show(); //ImportJxt jxt = new ImportJxt(tlVectorControl1); //jxt.Import(); break; case "mSave": SaveAllLayer(); break; case "mExit": this.Close(); break; case "bt1": //InitTK(); break; case "mFin": frmGProList p = new frmGProList(); p.Show(); p.LoadData(LoadData()); break; case "bt2": break; case "mPriSet": this.tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint; break; case "mPrint": tlVectorControl1.Print(); break; case "mImport": ExportImage(); break; case "mView": //frmSvgView fView = new frmSvgView(); //fView.Open(tlVectorControl1.SVGDocument.CurrentLayer.ID); //fView.Show(); 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 "mAbout": frmAbout frma = new frmAbout(); frma.ShowDialog(); break; case "ButtonItem10": int temp411 = 10; frmConvert frmc = new frmConvert(); frmc.ShowDialog(); temp411++; break; //基础操作 case "mFreeTransform": tlVectorControl1.Operation = ToolOperation.FreeTransform; break; case "mCJ": tlVectorControl1.Operation = ToolOperation.PolyLine; csOperation = CustomOperation.OP_MeasureDistance; break; //case "ButtonItem2": // 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": tlVectorControl1.Operation = ToolOperation.Select; break; case "mSel": tlVectorControl1.Operation = ToolOperation.FreeTransform; 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.ConnectLine_Polyline; break; case "mPolyline": tlVectorControl1.Operation = ToolOperation.PolyLine; break; case "mConnectLine": tlVectorControl1.Operation = ToolOperation.ConnectLine; 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 "ButtonItem2": fileType = true; if (fileType == true) { LoadShape("symbol20.xml"); //jxtbar(1); } else { LoadShape("symbol21.xml"); //jxtbar(0); } tlVectorControl1.SVGDocument.CurrentLayer.ID = Guid.NewGuid().ToString(); SvgDocument.currentLayer = Layer.CreateNew("默认层", tlVectorControl1.SVGDocument).ID; tlVectorControl1.IsModified = false; frmElementName dlgnew2 = new frmElementName(); dlgnew2.TextInput = tlVectorControl1.SVGDocument.FileName; if (dlgnew2.ShowDialog() == DialogResult.OK) { tlVectorControl1.SVGDocument.FileName = dlgnew2.TextInput; Save(); } //NewFile(fileType); break; case "ButtonItem8": fileType = false; //NewFile(fileType); tlVectorControl1.NewFile(); if (fileType == true) { LoadShape("symbol20.xml"); //jxtbar(1); } else { LoadShape("symbol21.xml"); //jxtbar(0); } tlVectorControl1.SVGDocument.CurrentLayer.ID = Guid.NewGuid().ToString(); SvgDocument.currentLayer = Layer.CreateNew("默认层", tlVectorControl1.SVGDocument).ID; tlVectorControl1.IsModified = false; frmElementName dlgnew3 = new frmElementName(); dlgnew3.TextInput = tlVectorControl1.SVGDocument.FileName; if (dlgnew3.ShowDialog() == DialogResult.OK) { tlVectorControl1.SVGDocument.FileName = dlgnew3.TextInput; Save(); } break; case "mCheck": Check(); break; case "niula": //MessageBox.Show(Directory.GetCurrentDirectory()); //frmTLpsp el = new frmTLpsp(); PspNIULA(); //oThread = new Thread(new ThreadStart(el.PspNIULA)); //oThread.Start(); //try //{ // time = new System.Threading.Timer(new TimerCallback(method), null, 50000, 60000); //} //catch { } break; case "pq": //frmTLpsp e2 = new frmTLpsp(); PspPQ(); break; //case "ShortCut": // ShortCutCheck(); // break; case "GaussSeidel": PspGaussSeidel(); break; case "PowerLossCal": PspPowerLossCal(); break; case "N_RZYz": PspN_RZYz(); break; case "WebRela": //进行网络N-1检验 WebCalAndPrint(); break; case "TransRela": //进行变压器N-1检验 break; case "DuanluResult": //ShortCutCheck(); //PSPDEV pspDuanlu = new PSPDEV(); //pspDuanlu.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; //frmDuanlu dudu = new frmDuanlu(pspDuanlu); //PSPDEV Duanlu = new PSPDEV(); //Duanlu.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; //if (dudu.ShowDialog() == DialogResult.OK) //{ // Duanlu = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", Duanlu); // n4 = Convert.ToInt32(dudu.hscool); // if (Duanlu.Type == "Use") // { // n1 = Duanlu.Number; // n2 = Duanlu.Number; // string dlr=n1.ToString(); // if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\dlb.txt")) // { // File.Delete(System.Windows.Forms.Application.StartupPath+"\\dlb.txt"); // } // FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath+"\\data.txt"), FileMode.OpenOrCreate); // StreamWriter str11 = new StreamWriter(VK); // str11.Write(dlr); // str11.Close(); // n4 = 0; // } // if (Duanlu.Type == "Polyline") // { // n1 = Duanlu.FirstNode; // n2 = Duanlu.LastNode; // } // switch (dudu.DuanluType){ // case "单相接地": // n3 = 1; // break; // case "两相接地": // n3 = 3; // break; // case "两相故障": // n3 = 2; // break; // case "三相故障": // n3 = 0; // break; // default: // n3 = 1; // break; // } // duanlu.myshort(n1, n2, n3, n4); // } break; //case "DuanluResult": // il = 1; // break; case "dd": //SubPrint = true; tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint; break; case "NiulaResult": try { //{ if (!Check()) { return; } NIULA pspniula = new NIULA(); pspniula.CurrentCal(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "牛拉法计算结果.xls")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "牛拉法计算结果.xls"); //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls"); } double yinzi = 0, capability = 0, volt = 0, current = 0, standvolt = 0, Rad_to_Deg = 57.29577951; PSPDEV benchmark = new PSPDEV(); benchmark.Type = "power"; benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark); if (list3 == null) { MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (PSPDEV dev in list3) { yinzi = Convert.ToDouble(dev.PowerFactor); capability = Convert.ToDouble(dev.StandardCurrent); volt = Convert.ToDouble(dev.StandardVolt); if (dev.PowerFactor == 0) { yinzi = 1; } if (dev.StandardCurrent == 0) { capability = 1; } if (dev.StandardVolt == 0) { volt = 1; } standvolt = volt; current = capability / (Math.Sqrt(3) * volt); } capability = 100; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF1.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF1.txt", FileMode.Open); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); output += ("全网母线(发电、负荷)结果报表 " + "\r\n" + "\r\n"); output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n"); output += ("母线名" + "," + "电压幅值" + "," + "电压相角" + "," + "有功发电" + "," + "无功发电" + "," + "有功负荷" + "," + "无功负荷" + "," + "越限标志" + "," + "过载标志" + "\r\n"); int count = 0; while (strLine != null && strLine != "") { array1 = strLine.Split(charSplit); string[] dev = new string[9]; dev.Initialize(); int i = 0; count++; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } CR.Number = Convert.ToInt32(dev[0]); CR.Type = "Use"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR); if (CR.ReferenceVolt != null && CR.ReferenceVolt != 0) { volt = CR.ReferenceVolt; } else volt = standvolt; current = capability / (Math.Sqrt(3) * volt); double vTemp = Convert.ToDouble(dev[1]) * volt; double vTemp1 = volt * 95 / 100; double vTemp2 = volt * 105 / 100; if (vTemp >= vTemp1 && vTemp <= vTemp2) { dev[5] = "0"; } else { dev[5] = "1"; } if (Convert.ToDouble(dev[3]) * capability > Convert.ToDouble(CR.Burthen)) { dev[6] = "1"; } else { dev[6] = "0"; } if (Convert.ToDouble(dev[3]) < 0) { output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + "0" + "," + "0" + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + dev[5] + "," + dev[6] + "\r\n"; } else { output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + "0" + "," + "0" + "," + dev[5] + "," + dev[6] + "\r\n"; } strLine = readLine.ReadLine(); } PSPDEV ct = new PSPDEV(); ct.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; ct.Type = "Use"; IList cont = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", ct); if (count < cont.Count) { MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); readLine.Close(); return; } readLine.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv"); } op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(output); str1.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt")) { } else { return; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open); dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH1.txt", FileMode.Open); readLine2 = new StreamReader(dh2); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); strLine2 = readLine2.ReadLine(); output = null; output += ("全网交流线结果报表" + "\r\n" + "\r\n"); output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n"); output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "," + "\r\n"); while (strLine != null && strLine2 != null && strLine != "" && strLine2 != "") { array1 = strLine.Split(charSplit); array2 = strLine2.Split(charSplit2); string[] dev = new string[20]; dev.Initialize(); int i = 0; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (i == 0) { dev[i++] = str.ToString(); } else { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } } i = 7; for (int j = 3; j < 5; j++) { if (array2[j] != "") { if (array2[j] != "NaN") { dev[i++] = Convert.ToDouble(array2[j]).ToString(); } else { dev[i++] = array2[j]; } } } CR.Name = dev[0]; CR.Type = "Polyline"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR.ReferenceVolt != null && CR.ReferenceVolt != 0) { volt = CR.ReferenceVolt; } else volt = standvolt; current = capability / (Math.Sqrt(3) * volt); if (CR != null) { if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange) { dev[11] = "1"; } else { dev[11] = "0"; } output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n"; } else { CR = new PSPDEV(); CR.Name = dev[0]; CR.Type = "TransformLine"; CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null) { if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange) { dev[11] = "1"; } else { dev[11] = "0"; } output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n"; } } strLine = readLine.ReadLine(); strLine2 = readLine2.ReadLine(); } readLine.Close(); readLine2.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); } op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(output); str1.Close(); ex = new Excel.Application(); ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv"); xSheet = (Excel.Worksheet)ex.Worksheets[1]; ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value); result1 = new Excel.Application(); result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1); newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2); newWorksheet.Name = "线路电流"; xSheet.Name = "母线潮流"; ex.Visible = true; tempSheet.Cells.Select(); tempSheet.Cells.Copy(System.Reflection.Missing.Value); newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value); xSheet.Rows.AutoFit(); xSheet.Columns.AutoFit(); newWorksheet.Rows.AutoFit(); newWorksheet.Columns.AutoFit(); xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 9]).MergeCells = true; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体"; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; xSheet.get_Range(xSheet.Cells[5, 1], xSheet.Cells[5, 9]).Interior.ColorIndex = 45; xSheet.get_Range(xSheet.Cells[6, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; xSheet.get_Range(xSheet.Cells[6, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ "; xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312"; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 9]).MergeCells = true; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体"; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; newWorksheet.get_Range(newWorksheet.Cells[5, 1], newWorksheet.Cells[5, 8]).Interior.ColorIndex = 45; newWorksheet.get_Range(newWorksheet.Cells[6, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; newWorksheet.get_Range(newWorksheet.Cells[6, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ "; newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312"; //op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fck.excel"), FileMode.OpenOrCreate); //str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); string fn = tlVectorControl1.SVGDocument.FileName; //result1.Save(System.Windows.Forms.Application.StartupPath + "\\fck.xls"); newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + fn + "牛拉法计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null); //str1.Write(); //op.Close(); System.Windows.Forms.Clipboard.Clear(); result1.Workbooks.Close(); result1.Quit(); } catch (System.Exception e1) { MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } //} break; case "GaussSeidelResult": try { if (!Check()) { return; } Gauss pspgauss = new Gauss(); pspgauss.CurrentCal(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "高斯-赛德尔计算结果.xls")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "高斯-赛德尔计算结果.xls"); //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls"); } double yinzi = 0, capability = 0, volt = 0, current = 0, Rad_to_Deg = 57.29577951; PSPDEV benchmark = new PSPDEV(); benchmark.Type = "power"; benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark); if (list3 == null) { MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (PSPDEV dev in list3) { yinzi = Convert.ToDouble(dev.PowerFactor); capability = Convert.ToDouble(dev.StandardCurrent); volt = Convert.ToDouble(dev.StandardVolt); if (dev.PowerFactor == 0) { yinzi = 1; } if (dev.StandardCurrent == 0) { capability = 1; } if (dev.StandardVolt == 0) { volt = 1; } current = capability / (Math.Sqrt(3) * volt); }; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF3.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF3.txt", FileMode.Open); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); output += ("全网母线(发电、负荷)结果报表 " + "\r\n" + "\r\n"); output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n"); output += ("母线名" + "," + "电压幅值" + "," + "电压相角" + "," + "有功发电" + "," + "无功发电" + "," + "有功负荷" + "," + "无功负荷" + "," + "越限标志" + "," + "过载标志" + "\r\n"); int count = 0; while (strLine != null && strLine != "") { array1 = strLine.Split(charSplit); string[] dev = new string[9]; dev.Initialize(); int i = 0; count++; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } CR.Number = Convert.ToInt32(dev[0]); CR.Type = "Use"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR); double vTemp = Convert.ToDouble(dev[1]) * volt; double vTemp1 = volt * 95 / 100; double vTemp2 = volt * 105 / 100; if (vTemp >= vTemp1 && vTemp <= vTemp2) { dev[5] = "0"; } else { dev[5] = "1"; } if (Convert.ToDouble(dev[3]) * capability > Convert.ToDouble(CR.Burthen)) { dev[6] = "1"; } else { dev[6] = "0"; } if (Convert.ToDouble(dev[3]) < 0) { output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + "0" + "," + "0" + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + dev[5] + "," + dev[6] + "\r\n"; } else { output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + "0" + "," + "0" + "," + dev[5] + "," + dev[6] + "\r\n"; } strLine = readLine.ReadLine(); } PSPDEV ct = new PSPDEV(); ct.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; ct.Type = "Use"; IList cont = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", ct); if (count < cont.Count) { MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); readLine.Close(); return; } readLine.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv"); } op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(output); str1.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH3.txt")) { } else { return; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH3.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH3.txt", FileMode.Open); dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH3.txt", FileMode.Open); readLine2 = new StreamReader(dh2); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); strLine2 = readLine2.ReadLine(); output = null; output += ("全网交流线结果报表" + "\r\n" + "\r\n"); output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n"); output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "," + "\r\n"); while (strLine != null && strLine2 != null && strLine != "" && strLine2 != "") { array1 = strLine.Split(charSplit); array2 = strLine2.Split(charSplit2); string[] dev = new string[20]; dev.Initialize(); int i = 0; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (i == 0) { dev[i++] = str.ToString(); } else { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } } i = 7; for (int j = 3; j < 5; j++) { if (array2[j] != "") { if (array2[j] != "NaN") { dev[i++] = Convert.ToDouble(array2[j]).ToString(); } else { dev[i++] = array2[j]; } } } CR.Name = dev[0]; CR.Type = "Polyline"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null) { if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange) { dev[11] = "1"; } else { dev[11] = "0"; } output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n"; } else { CR = new PSPDEV(); CR.Name = dev[0]; CR.Type = "TransformLine"; CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null) { if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange) { dev[11] = "1"; } else { dev[11] = "0"; } output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n"; } } strLine = readLine.ReadLine(); strLine2 = readLine2.ReadLine(); } readLine.Close(); readLine2.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); } op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(output); str1.Close(); ex = new Excel.Application(); ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv"); xSheet = (Excel.Worksheet)ex.Worksheets[1]; ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value); result1 = new Excel.Application(); result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1); newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2); newWorksheet.Name = "线路电流"; xSheet.Name = "母线潮流"; ex.Visible = true; tempSheet.Cells.Select(); tempSheet.Cells.Copy(System.Reflection.Missing.Value); newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value); xSheet.Rows.AutoFit(); xSheet.Columns.AutoFit(); newWorksheet.Rows.AutoFit(); newWorksheet.Columns.AutoFit(); xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 9]).MergeCells = true; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体"; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; xSheet.get_Range(xSheet.Cells[5, 1], xSheet.Cells[5, 9]).Interior.ColorIndex = 45; xSheet.get_Range(xSheet.Cells[6, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; xSheet.get_Range(xSheet.Cells[6, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ "; xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312"; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 9]).MergeCells = true; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体"; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; newWorksheet.get_Range(newWorksheet.Cells[5, 1], newWorksheet.Cells[5, 8]).Interior.ColorIndex = 45; newWorksheet.get_Range(newWorksheet.Cells[6, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; newWorksheet.get_Range(newWorksheet.Cells[6, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ "; newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312"; //op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fck.excel"), FileMode.OpenOrCreate); //str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); string fn = tlVectorControl1.SVGDocument.FileName; //result1.Save(System.Windows.Forms.Application.StartupPath + "\\fck.xls"); newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + fn + "高斯-赛德尔计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null); //str1.Write(); //op.Close(); System.Windows.Forms.Clipboard.Clear(); result1.Workbooks.Close(); result1.Quit(); } catch (System.Exception e1) { MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "N_RZYzResult": try { if (!Check()) { return; } ZYZ zyz = new ZYZ(); zyz.CurrentCal(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "最优乘子法计算结果.xls")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "最优乘子法计算结果.xls"); //OpenRead(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + ".xls"); } double yinzi = 0, capability = 0, volt = 0, current = 0, Rad_to_Deg = 57.29577951; PSPDEV benchmark = new PSPDEV(); benchmark.Type = "power"; benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark); if (list3 == null) { MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (PSPDEV dev in list3) { yinzi = Convert.ToDouble(dev.PowerFactor); capability = Convert.ToDouble(dev.StandardCurrent); volt = Convert.ToDouble(dev.StandardVolt); if (dev.PowerFactor == 0) { yinzi = 1; } if (dev.StandardCurrent == 0) { capability = 1; } if (dev.StandardVolt == 0) { volt = 1; } current = capability / (Math.Sqrt(3) * volt); } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF4.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF4.txt", FileMode.Open); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); output += ("全网母线(发电、负荷)结果报表 " + "\r\n" + "\r\n"); output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n"); output += ("母线名" + "," + "电压幅值" + "," + "电压相角" + "," + "有功发电" + "," + "无功发电" + "," + "有功负荷" + "," + "无功负荷" + "," + "越限标志" + "," + "过载标志" + "\r\n"); int count = 0; while (strLine != null && strLine != "") { array1 = strLine.Split(charSplit); string[] dev = new string[9]; dev.Initialize(); int i = 0; count++; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } CR.Number = Convert.ToInt32(dev[0]); CR.Type = "Use"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR); double vTemp = Convert.ToDouble(dev[1]) * volt; double vTemp1 = volt * 95 / 100; double vTemp2 = volt * 105 / 100; if (vTemp >= vTemp1 && vTemp <= vTemp2) { dev[5] = "0"; } else { dev[5] = "1"; } if (Convert.ToDouble(dev[3]) * capability > Convert.ToDouble(CR.Burthen)) { dev[6] = "1"; } else { dev[6] = "0"; } if (Convert.ToDouble(dev[3]) < 0) { output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + "0" + "," + "0" + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + dev[5] + "," + dev[6] + "\r\n"; } else { output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2]) * Rad_to_Deg).ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + "0" + "," + "0" + "," + dev[5] + "," + dev[6] + "\r\n"; } strLine = readLine.ReadLine(); } PSPDEV ct = new PSPDEV(); ct.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; ct.Type = "Use"; IList cont = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", ct); if (count < cont.Count) { MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); readLine.Close(); return; } readLine.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv"); } op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(output); str1.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH4.txt")) { } else { return; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH4.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH4.txt", FileMode.Open); dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH4.txt", FileMode.Open); readLine2 = new StreamReader(dh2); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); strLine2 = readLine2.ReadLine(); output = null; output += ("全网交流线结果报表" + "\r\n" + "\r\n"); output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n"); output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "," + "\r\n"); while (strLine != null && strLine2 != null && strLine != "" && strLine2 != "") { array1 = strLine.Split(charSplit); array2 = strLine2.Split(charSplit2); string[] dev = new string[20]; dev.Initialize(); int i = 0; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (i == 0) { dev[i++] = str.ToString(); } else { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } } i = 7; for (int j = 3; j < 5; j++) { if (array2[j] != "") { if (array2[j] != "NaN") { dev[i++] = Convert.ToDouble(array2[j]).ToString(); } else { dev[i++] = array2[j]; } } } CR.Name = dev[0]; CR.Type = "Polyline"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null) { if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange) { dev[11] = "1"; } else { dev[11] = "0"; } output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n"; } else { CR = new PSPDEV(); CR.Name = dev[0]; CR.Type = "TransformLine"; CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null) { if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange) { dev[11] = "1"; } else { dev[11] = "0"; } output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n"; } } strLine = readLine.ReadLine(); strLine2 = readLine2.ReadLine(); } readLine.Close(); readLine2.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); } op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(output); str1.Close(); ex = new Excel.Application(); ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv"); xSheet = (Excel.Worksheet)ex.Worksheets[1]; ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value); result1 = new Excel.Application(); result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1); newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2); newWorksheet.Name = "线路电流"; xSheet.Name = "母线潮流"; ex.Visible = true; tempSheet.Cells.Select(); tempSheet.Cells.Copy(System.Reflection.Missing.Value); newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value); xSheet.Rows.AutoFit(); xSheet.Columns.AutoFit(); newWorksheet.Rows.AutoFit(); newWorksheet.Columns.AutoFit(); xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 9]).MergeCells = true; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体"; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; xSheet.get_Range(xSheet.Cells[5, 1], xSheet.Cells[5, 9]).Interior.ColorIndex = 45; xSheet.get_Range(xSheet.Cells[6, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; xSheet.get_Range(xSheet.Cells[6, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ "; xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312"; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 9]).MergeCells = true; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Size = 20; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).Font.Name = "黑体"; newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; newWorksheet.get_Range(newWorksheet.Cells[5, 1], newWorksheet.Cells[5, 8]).Interior.ColorIndex = 45; newWorksheet.get_Range(newWorksheet.Cells[6, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; newWorksheet.get_Range(newWorksheet.Cells[6, 2], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ "; newWorksheet.get_Range(newWorksheet.Cells[3, 1], newWorksheet.Cells[newWorksheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312"; //op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fck.excel"), FileMode.OpenOrCreate); //str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); string fn = tlVectorControl1.SVGDocument.FileName; //result1.Save(System.Windows.Forms.Application.StartupPath + "\\fck.xls"); newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + fn + "最优乘子法计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null); //str1.Write(); //op.Close(); System.Windows.Forms.Clipboard.Clear(); result1.Workbooks.Close(); result1.Quit(); } catch (System.Exception e1) { MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "VoltEvaluation": PspVoltEvaluation(); break; case "PowerLoss": try { PSPDEV _dev = new PSPDEV(); _dev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; _dev.Type = "Polyline"; IList list = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", _dev); for (int i = 0; i < list.Count; i++) { PSPDEV _pp = (PSPDEV)list[i]; if (_pp.BigP == 0) { MessageBox.Show("请设置线路" + _pp.Name + "的建设投资。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); output = null; output += ("全网交流线结果报表" + "\r\n" + "\r\n"); output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n"); output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "\r\n"); while (strLine != null) { array1 = strLine.Split(charSplit); string[] dev = new string[9]; dev.Initialize(); int i = 0; PSPDEV CR = new PSPDEV(); } } catch (System.Exception e1) { MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "ZLPResult1": if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH1.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH1.txt", FileMode.Open); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); output = null; output += ("全网交流线结果报表" + "\r\n" + "\r\n"); output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n"); output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "\r\n"); while (strLine != null) { array1 = strLine.Split(charSplit); string[] dev = new string[9]; dev.Initialize(); int i = 0; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } CR.Number = Convert.ToInt32(dev[0]); CR.Type = "Polyline"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR); output += CR.Name + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "\r\n"; strLine = readLine.ReadLine(); } readLine.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv"); } op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(output); str1.Close(); ex = new Excel.Application(); ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv"); ex.Visible = true; break; case "ZLAResult1": if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH1.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH1.txt", FileMode.Open); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); output = null; output += ("支路名称" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "\r\n"); while (strLine != null) { array1 = strLine.Split(charSplit); string[] dev = new string[9]; dev.Initialize(); int i = 0; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } CR.Number = Convert.ToInt32(dev[0]); CR.Type = "Polyline"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR); output += CR.Name + "," + dev[3] + "," + dev[4] + "," + dev[5] + "\r\n"; strLine = readLine.ReadLine(); } readLine.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv"); } op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(output); str1.Close(); ex = new Excel.Application(); ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv"); ex.Visible = true; break; case "PQResult": try { if (!CheckPQ()) { return; } PQ_PowerFlowCalClass pq = new PQ_PowerFlowCalClass(); pq.CurrentCal(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "PQ法计算结果.xls")) { //System.Diagnostics.Process.Start(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "PQ法计算结果.xls"); File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + tlVectorControl1.SVGDocument.FileName + "PQ法计算结果.xls"); } double yinzi = 0, capability = 0, volt = 0, current = 0, Rad_to_Deg = 57.29577951; PSPDEV benchmark = new PSPDEV(); benchmark.Type = "power"; benchmark.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark); if (list3 == null) { MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } foreach (PSPDEV dev in list3) { yinzi = Convert.ToDouble(dev.PowerFactor); capability = Convert.ToDouble(dev.StandardCurrent); volt = Convert.ToDouble(dev.StandardVolt); if (dev.PowerFactor == 0) { yinzi = 1; } if (dev.StandardCurrent == 0) { capability = 1; } if (dev.StandardVolt == 0) { volt = 1; } current = capability / (Math.Sqrt(3) * volt); } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\PF2.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\PF2.txt", FileMode.Open); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); output = null; int count = 0; output += ("全网母线(发电、负荷)结果报表 " + "\r\n" + "\r\n"); output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n"); output += ("母线名" + "," + "电压幅值" + "," + "电压相角" + "," + "有功发电" + "," + "无功发电" + "," + "有功负荷" + "," + "无功负荷" + "," + "越限标志" + "," + "过载标志" + "\r\n"); while (strLine != null && strLine != "") { array1 = strLine.Split(charSplit); string[] dev = new string[9]; dev.Initialize(); int i = 0; count++; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } CR.Number = Convert.ToInt32(dev[0]); CR.Type = "Use"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR); double vTemp = Convert.ToDouble(dev[1]) * volt; double vTemp1 = volt * 95 / 100; double vTemp2 = volt * 105 / 100; if (vTemp >= vTemp1 && vTemp <= vTemp2) { dev[5] = "0"; } else { dev[5] = "1"; } if (Convert.ToDouble(dev[3]) * capability > Convert.ToDouble(CR.Burthen)) { dev[6] = "1"; } else { dev[6] = "0"; } if (Convert.ToDouble(dev[3]) < 0) { output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2])).ToString() + "," + "0" + "," + "0" + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + dev[5] + "," + dev[6] + "\r\n"; } else { output += CR.Name + "," + (Convert.ToDouble(dev[1]) * volt).ToString() + "," + (Convert.ToDouble(dev[2])).ToString() + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + "0" + "," + "0" + "," + dev[5] + "," + dev[6] + "\r\n"; } strLine = readLine.ReadLine(); } PSPDEV ct = new PSPDEV(); ct.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; ct.Type = "Use"; IList cont = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", ct); if (count < cont.Count) { MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); readLine.Close(); return; } readLine.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv"); } op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(output); str1.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\DH2.txt")) { } else { return; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\IH2.txt")) { } else { return; } dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\DH2.txt", FileMode.Open); dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\IH2.txt", FileMode.Open); readLine2 = new StreamReader(dh2); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); charSplit2 = new char[] { ' ' }; strLine2 = readLine2.ReadLine(); output = null; output += ("全网交流线结果报表" + "\r\n" + "\r\n"); output += ("单位:kA\\kV\\MW\\Mvar" + "\r\n" + "\r\n"); output += ("支路名称" + "," + "支路有功" + "," + "支路无功" + "," + "有功损耗" + "," + "无功损耗" + "," + "电流幅值" + "," + "电流相角" + "," + "越限标志" + "," + "\r\n"); while (strLine != null && strLine2 != null && strLine != "" && strLine2 != "") { array1 = strLine.Split(charSplit); array2 = strLine2.Split(charSplit2); string[] dev = new string[20]; dev.Initialize(); int i = 0; PSPDEV CR = new PSPDEV(); CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (i == 0) { dev[i++] = str.ToString(); } else { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } } i = 7; for (int j = 3; j < 5; j++) { if (array2[j] != "") { if (array2[j] != "NaN") { dev[i++] = Convert.ToDouble(array2[j]).ToString(); } else { dev[i++] = array2[j]; } } } CR.Name = dev[0]; CR.Type = "Polyline"; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null) { if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange) { dev[11] = "1"; } else { dev[11] = "0"; } output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n"; } else { CR = new PSPDEV(); CR.Name = dev[0]; CR.Type = "TransformLine"; CR.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; CR = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByName", CR); if (CR != null) { if (Convert.ToDouble(dev[7]) * current * 1000 > CR.LineChange) { dev[11] = "1"; } else { dev[11] = "0"; } output += CR.Name + "," + (Convert.ToDouble(dev[3]) * capability).ToString() + "," + (Convert.ToDouble(dev[4]) * capability).ToString() + "," + (Convert.ToDouble(dev[5]) * capability).ToString() + "," + (Convert.ToDouble(dev[6]) * capability).ToString() + "," + (Convert.ToDouble(dev[7]) * current).ToString() + "," + (Convert.ToDouble(dev[8]) * Rad_to_Deg).ToString() + "," + dev[11] + "," + "\r\n"; } } strLine = readLine.ReadLine(); strLine2 = readLine2.ReadLine(); } readLine.Close(); readLine2.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result1.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); } op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result1.csv"), FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(output); str1.Close(); Excel.Application ex2 = new Excel.Application(); ex2.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv"); Excel.Worksheet xSheet2 = (Excel.Worksheet)ex2.Worksheets[1]; ex2.Worksheets.Add(System.Reflection.Missing.Value, xSheet2, 1, System.Reflection.Missing.Value); Excel.Application result11 = new Excel.Application(); result11.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); Excel.Application result12 = new Excel.Application(); Excel.Worksheet tempSheet11 = (Excel.Worksheet)result11.Worksheets.get_Item(1); Excel.Worksheet newWorksheet11 = (Excel.Worksheet)ex2.Worksheets.get_Item(2); newWorksheet11.Name = "线路电流"; xSheet2.Name = "母线潮流"; ex2.Visible = true; tempSheet11.Cells.Select(); tempSheet11.Cells.Copy(System.Reflection.Missing.Value); newWorksheet11.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value); xSheet2.Rows.AutoFit(); xSheet2.Columns.AutoFit(); newWorksheet11.Rows.AutoFit(); newWorksheet11.Columns.AutoFit(); xSheet2.get_Range(xSheet2.Cells[1, 1], xSheet2.Cells[1, 9]).MergeCells = true; xSheet2.get_Range(xSheet2.Cells[1, 1], xSheet2.Cells[1, 1]).Font.Size = 20; xSheet2.get_Range(xSheet2.Cells[1, 1], xSheet2.Cells[1, 1]).Font.Name = "黑体"; xSheet2.get_Range(xSheet2.Cells[1, 1], xSheet2.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; xSheet2.get_Range(xSheet2.Cells[5, 1], xSheet2.Cells[5, 9]).Interior.ColorIndex = 45; xSheet2.get_Range(xSheet2.Cells[6, 1], xSheet2.Cells[xSheet2.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; xSheet2.get_Range(xSheet2.Cells[6, 2], xSheet2.Cells[xSheet2.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ "; xSheet2.get_Range(xSheet2.Cells[3, 1], xSheet2.Cells[xSheet2.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312"; newWorksheet11.get_Range(newWorksheet11.Cells[1, 1], newWorksheet11.Cells[1, 9]).MergeCells = true; newWorksheet11.get_Range(newWorksheet11.Cells[1, 1], newWorksheet11.Cells[1, 1]).Font.Size = 20; newWorksheet11.get_Range(newWorksheet11.Cells[1, 1], newWorksheet11.Cells[1, 1]).Font.Name = "黑体"; newWorksheet11.get_Range(newWorksheet11.Cells[1, 1], newWorksheet11.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; newWorksheet11.get_Range(newWorksheet11.Cells[5, 1], newWorksheet11.Cells[5, 8]).Interior.ColorIndex = 45; newWorksheet11.get_Range(newWorksheet11.Cells[6, 1], newWorksheet11.Cells[newWorksheet11.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; newWorksheet11.get_Range(newWorksheet11.Cells[6, 2], newWorksheet11.Cells[newWorksheet11.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ "; newWorksheet11.get_Range(newWorksheet11.Cells[3, 1], newWorksheet11.Cells[newWorksheet11.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312"; string fn = tlVectorControl1.SVGDocument.FileName; //result1.Save(System.Windows.Forms.Application.StartupPath + "\\fck.xls"); newWorksheet11.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + fn + "PQ法计算结果.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null); System.Windows.Forms.Clipboard.Clear(); result11.Workbooks.Close(); result11.Quit(); } catch (System.Exception e3) { MessageBox.Show("请进行潮流计算后再查看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "mDLR": if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.txt")) { } else { return; } int ij = 1; dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\result.txt", FileMode.Open); readLine = new StreamReader(dh); charSplit = new char[] { ' ' }; strLine = readLine.ReadLine(); output = null; FileStream dh5 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\dlb.txt", FileMode.Open); StreamReader readLine5 = new StreamReader(dh5); string strLine5; string[] array5; char[] charSplit5 = new char[] { ' ' }; strLine5 = readLine5.ReadLine(); array5 = strLine5.Split(charSplit5); output += ("全网短路计算结果报表" + "\r\n" + "\r\n"); PSPDEV CR235 = new PSPDEV(); CR235.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; CR235.Number = Convert.ToInt32(array5[0]); CR235.Type = array5[1]; double ibb = 0; double temp11 = 0; CR235 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR235); if (CR235 == null) { MessageBox.Show("错误!当前图元与结果报表不符!"); readLine.Close(); readLine5.Close(); return; } output += ("短路点" + ":" + " " + CR235.Name + " " + "故障类型" + ":" + " " + array5[2] + "\r\n" + "\r\n"); output += ("名称" + "," + "零序电流" + "," + "正序电流" + "," + "负序电流" + "," + "A相电流" + "," + "B相电流" + "," + "C相电流" + "," + "短路电流" + "," + "短路容量" + "," + "\r\n"); while (strLine != null) { array1 = strLine.Split(charSplit); string[] dev = new string[9]; dev.Initialize(); int i = 0; PSPDEV CR2 = new PSPDEV(); CR2.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; foreach (string str in array1) { if (str != "") { if (str != "NaN") { dev[i++] = Convert.ToDouble(str).ToString(); } else { dev[i++] = str; } } } //CR2.Number = Convert.ToInt32(dev[2]); //CR2.Type = "Use"; //CR2 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR2); CR2.Number = Convert.ToInt32(array5[0]); CR2.Type = array5[1]; string nodeName = CR2.Name; CR2 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR2); int vr = Convert.ToInt32(CR2.VoltR); switch (vr) { case 220: { ibb = 251.03; for (int j = 3; j < 9; j++) { temp11 = Convert.ToDouble(dev[j]) * ibb * 0.001; dev[j] = temp11.ToString(); } ibb = Convert.ToDouble(dev[4]) * 3; temp11 = 1.732 * ibb * 230; } break; case 500: { ibb = 104.98; for (int j = 3; j < 9; j++) { temp11 = Convert.ToDouble(dev[j]) * ibb * 0.001; dev[j] = temp11.ToString(); } ibb = Convert.ToDouble(dev[4]) * 3; temp11 = 1.732 * ibb * 550; } break; default: { } break; } if (ij == 1) { output += CR2.Name + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "," + ibb.ToString() + "," + temp11.ToString() + "," + "\r\n"; } else { CR2.Number = Convert.ToInt32(dev[2]); CR2.Type = "Polyline"; CR2 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByNumberAndSvgUIDAndType", CR2); //output += CR2.Name + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "\r\n"; if (CR2 != null) { output += CR2.Name + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "\r\n"; } else if (dev[2] == "500") { output += nodeName + "故障生成线路" + "," + dev[3] + "," + dev[4] + "," + dev[5] + "," + dev[6] + "," + dev[7] + "," + dev[8] + "\r\n"; } } ij = 0; strLine = readLine.ReadLine(); } readLine.Close(); readLine5.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\result.csv")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\result.csv"); } op = new FileStream((System.Windows.Forms.Application.StartupPath + "\\result.csv"), FileMode.OpenOrCreate); str1 = new StreamWriter(op, Encoding.GetEncoding("GB2312")); str1.Write(output); str1.Close(); ex = new Excel.Application(); ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv"); //ex.Visible = true; //Excel.Application ex = new Excel.Application(); ex.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result.csv"); xSheet = (Excel.Worksheet)ex.Worksheets[1]; //ex.Worksheets.Add(System.Reflection.Missing.Value, xSheet, 1, System.Reflection.Missing.Value); //result1 = new Excel.Application(); //result1.Application.Workbooks.Add(System.Windows.Forms.Application.StartupPath + "\\result1.csv"); //tempSheet = (Excel.Worksheet)result1.Worksheets.get_Item(1); //Excel.Worksheet newWorksheet = (Excel.Worksheet)ex.Worksheets.get_Item(2); //newWorksheet.Name = "线路电流"; xSheet.Name = "短路计算"; //tempSheet.Cells.Select(); //tempSheet.Cells.Copy(System.Reflection.Missing.Value); //newWorksheet.Paste(System.Reflection.Missing.Value, System.Reflection.Missing.Value); xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 9]).MergeCells = true; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Size = 20; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).Font.Name = "黑体"; xSheet.get_Range(xSheet.Cells[1, 1], xSheet.Cells[1, 1]).HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter; xSheet.get_Range(xSheet.Cells[3, 1], xSheet.Cells[3, 1]).Font.Name = "楷体_GB2312"; xSheet.get_Range(xSheet.Cells[5, 1], xSheet.Cells[5, 9]).Interior.ColorIndex = 45; xSheet.get_Range(xSheet.Cells[6, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 1]).Interior.ColorIndex = 6; xSheet.get_Range(xSheet.Cells[8, 2], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).NumberFormat = "0.0000_ "; xSheet.get_Range(xSheet.Cells[5, 1], xSheet.Cells[xSheet.UsedRange.Rows.Count, 9]).Font.Name = "楷体_GB2312"; System.Windows.Forms.Clipboard.Clear(); //result1.Workbooks.Close(); //result1.Quit(); ex.Visible = true; 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; case "powerFactor": PSPDEV pspDev21 = new PSPDEV(); //pspDev2.SUID = Guid.NewGuid().ToString(); pspDev21.Type = "Power"; pspDev21.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; pspDev21 = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDAndType", pspDev21); if (pspDev21 != null) { } else { pspDev21 = new PSPDEV(); pspDev21.SUID = Guid.NewGuid().ToString(); pspDev21.Type = "Power"; pspDev21.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<PSPDEV>(pspDev21); } powerf ppz = new powerf(pspDev21); if (ppz.ShowDialog() == DialogResult.OK) { pspDev21.PowerFactor = Convert.ToDouble(ppz.powerfactor); pspDev21.StandardVolt = Convert.ToDouble(ppz.standardvolt); pspDev21.StandardCurrent = Convert.ToDouble(ppz.standardcurrent); pspDev21.BigP = Convert.ToDouble(ppz.bigP); Services.BaseService.Update<PSPDEV>(pspDev21); PSPDEV voltall = new PSPDEV(); voltall.Type = "Use"; voltall.Lable = "电厂"; voltall.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; IList allvolt = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandLableandType", voltall); foreach (PSPDEV dev in allvolt) { dev.OutP = Convert.ToDouble(dev.Burthen) * pspDev21.BigP; //dev.InPutP=dev.Burthen*pspDev2.BigP; dev.OutQ = dev.OutP * Math.Tan(Math.Acos(pspDev21.PowerFactor)); Services.BaseService.Update<PSPDEV>(dev); } voltall.Lable = "变电站"; allvolt = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandLableandType", voltall); foreach (PSPDEV dev in allvolt) { dev.InPutP = Convert.ToDouble(dev.Burthen) * pspDev21.BigP; //dev.InPutP=dev.Burthen*pspDev2.BigP; dev.InPutQ = dev.InPutP * pspDev21.BigP * Math.Tan(Math.Acos(pspDev21.PowerFactor)); Services.BaseService.Update<PSPDEV>(dev); } } break; //if (=null) //{ #endregion #region 视图 case "mLayer": frmlar.Show(); break; case "mOption": tlVectorControl1.SetOption(); 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; #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(); break; case "mDelete": if (tlVectorControl1.SVGDocument.CurrentElement is SVG) { } else { if (MessageBox.Show("确定要删除么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { SvgElementCollection collection = tlVectorControl1.SVGDocument.SelectCollection; foreach (XmlElement element in collection) { PSPDEV pspDev = new PSPDEV(); pspDev.EleID = element.GetAttribute("id"); pspDev.SvgUID = tlVectorControl1.SVGDocument.CurrentLayer.ID; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); Services.BaseService.Delete<PSPDEV>(pspDev); } tlVectorControl1.Delete(); } } break; case "mUodo": tlVectorControl1.Undo(); break; case "mRedo": tlVectorControl1.Redo(); break; #endregion #region 业务操作 case "mXLine": tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.XPolyLine; break; case "mYLine": tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.YPolyLine; 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; #endregion #region 参数维护 case "mNodeParam": frmNodeParam dlgNodeParam = new frmNodeParam(tlVectorControl1.SVGDocument.CurrentLayer.ID); dlgNodeParam.ShowDialog(); break; case "mLineParam": frmLineParamWJ dlgLineParam = new frmLineParamWJ(tlVectorControl1.SVGDocument.CurrentLayer.ID); dlgLineParam.ShowDialog(); break; case "mWire": wireTypeParam wirewire = new wireTypeParam(); wirewire.ShowDialog(); break; case "nTransformLineParam": frmTransformLineParam frmTransfor = new frmTransformLineParam(tlVectorControl1.SVGDocument.CurrentLayer.ID); frmTransfor.ShowDialog(); break; case "nGNDLineParam": break; case "mLineDL": frmLineParamDL dlgLineParamDL = new frmLineParamDL(tlVectorControl1.SVGDocument.CurrentLayer.ID); dlgLineParamDL.ShowDialog(); break; case "mFadianDL": frmFadejieDL dlgFadeDL = new frmFadejieDL(tlVectorControl1.SVGDocument.CurrentLayer.ID); dlgFadeDL.ShowDialog(); break; case "mTest": tlVectorControl1.Operation = ToolOperation.AreaSelect; break; case "mjianLine": if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "4") { zhengtiflag = true; jiqiflag = false; zhongqiflag = false; yuanqiflag = false; jianxiancheck(); MessageBox.Show("整体数据减线成功。"); Topology2(); //颜色发生变化 } if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "1" && zhengtiflag) { jiqiflag = true; zhengtiflag = false; zhongqiflag = false; yuanqiflag = false; jianxiancheck(); MessageBox.Show("近期数据减线成功。"); Topology2(); //颜色发生变化 } if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "2" && jiqiflag) { zhongqiflag = true; jiqiflag = false; yuanqiflag = false; jianxiancheck(); MessageBox.Show("中期数据减线成功。"); Topology2(); //颜色发生变化 } if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "3" && zhongqiflag) { yuanqiflag = true; jiqiflag = false; zhongqiflag = false; jianxiancheck(); MessageBox.Show("远期数据减线成功,请查看结果"); Topology2(); //颜色发生变化 } if (!zhengtiflag && !jiqiflag && !zhongqiflag && !yuanqiflag) { string msg2 = "减线法:\r\n 1、选中整体图层进行网架优化。\r\n 2、将整体图层拷贝到近期图层,然后选中近期图层进行网架优化。\r\n 3、拷贝到中期图层,然后选中中期图层进行网架优化\r\n 4、拷贝到远期图层,然后选中远期图层进行网架优化。"; MessageBox.Show(msg2, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "mjiaLine": if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "4") { MessageBox.Show("整体图层采用的是减线法!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "1" && zhengtiflag) { jiqiflag = true; zhengtiflag = false; zhongqiflag = false; yuanqiflag = false; addlinecheck(); addrightcheck(); for (int i = 0; i < ercilinedengdai.Count; i++) { ercilinedengdai[i].LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(ercilinedengdai[i]); } for (int i = 0; i < lineyiyou.Count; i++) { lineyiyou[i].LineStatus = "待选"; Services.BaseService.Update<PSPDEV>(lineyiyou[i]); } MessageBox.Show("近期数据加线成功。"); Topology2(); //颜色发生变化 } if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "2" && jiqiflag) { zhongqiflag = true; jiqiflag = false; yuanqiflag = false; addlinecheck(); addrightcheck(); for (int i = 0; i < ercilinedengdai.Count; i++) { ercilinedengdai[i].LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(ercilinedengdai[i]); } for (int i = 0; i < lineyiyou.Count; i++) { lineyiyou[i].LineStatus = "待选"; Services.BaseService.Update<PSPDEV>(lineyiyou[i]); } MessageBox.Show("中期数据加线成功。"); Topology2(); //颜色发生变化 } if (tlVectorControl1.SVGDocument.CurrentLayer.ID == tlVectorControl1.SVGDocument.SvgdataUid + "3" && zhongqiflag) { yuanqiflag = true; jiqiflag = false; zhongqiflag = false; addlinecheck(); addrightcheck(); for (int i = 0; i < ercilinedengdai.Count; i++) { ercilinedengdai[i].LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(ercilinedengdai[i]); } for (int i = 0; i < lineyiyou.Count; i++) { lineyiyou[i].LineStatus = "待选"; Services.BaseService.Update<PSPDEV>(lineyiyou[i]); } MessageBox.Show("远期数据加线成功。请查看优化结果"); Topology2(); //颜色发生变化 } if (!zhengtiflag && !jiqiflag && !zhongqiflag && !yuanqiflag) { string msg2 = "加线法:\r\n 1、选中整体图层进行网架优化,此时采用的是减线法。\r\n 2、将整体图层拷贝到近期图层,然后选中近期图层进行网架优化。\r\n 3、拷贝到中期图层,然后选中中期图层进行网架优化\r\n 4、拷贝到远期图层,然后选中远期图层进行网架优化。"; MessageBox.Show(msg2, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } break; case "YhResult": //优化结果 if (yuanqiflag) { frmGProList p1 = new frmGProList(); p1.Show(); p1.LoadData(LoadData()); } else MessageBox.Show("请依次做完各个时期的优化,再看结果!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; #endregion #region 参数维护 case "m_in": if (tlVectorControl1.SVGDocument.CurrentLayer.ID != tlVectorControl1.SVGDocument.SvgdataUid + "5") { MessageBox.Show("请选择背景参考层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } StringBuilder txt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"1500\" height=\"1000\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\" transform=\"matrix(1 0 0 1 0 1)\"><defs>"); StringBuilder Allcontent = new StringBuilder(); string svgdefs = ""; string layertxt = ""; frmLayerSel sel = new frmLayerSel(); if (sel.ShowDialog() == DialogResult.OK) { ArrayList tlist = sel.LayList; SVG_SYMBOL sym = new SVG_SYMBOL(); sym.svgID = oldsid; IList<SVG_SYMBOL> symlist = Services.BaseService.GetList<SVG_SYMBOL>("SelectSVG_SYMBOLBySvgID", sym); foreach (SVG_SYMBOL _sym in symlist) { svgdefs = svgdefs + _sym.XML; } txt.Append(svgdefs + "</defs>"); for (int i = 0; i < tlist.Count; i++) { SVG_LAYER lar = new SVG_LAYER(); lar.svgID = oldsid; lar.SUID = ((SVG_LAYER)tlist[i]).SUID; lar = (SVG_LAYER)Services.BaseService.GetObject("SelectSVG_LAYERByKey", lar); layertxt = layertxt + "<layer id=\"" + lar.SUID + "\" label=\"" + lar.NAME + "\" layerType=\"" + lar.layerType + "\" visibility=\"" + lar.visibility + "\" ParentID=\"" + lar.YearID + "\" IsSelect=\"" + lar.IsSelect + "\" />"; Allcontent.Append(lar.XML); } txt.Append(layertxt); txt.Append(Allcontent.ToString() + "</svg>"); SvgDocument document = new SvgDocument(); document.LoadXml(txt.ToString()); document.SvgdataUid = oldsid; XmlNodeList xlist = document.SelectNodes("svg/polyline [@IsLead='1']"); for (int i = 0; i < xlist.Count; i++) { SvgElement gra = xlist[i] as SvgElement; gra.SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "5"); ((IGraph)gra).Layer = tlVectorControl1.SVGDocument.CurrentLayer; tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)gra); } XmlNodeList xlist2 = document.SelectNodes("svg/use"); for (int i = 0; i < xlist2.Count; i++) { SvgElement gra = xlist2[i] as SvgElement; gra.SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "5"); ((IGraph)gra).Layer = tlVectorControl1.SVGDocument.CurrentLayer; tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)gra); } tlVectorControl1.Refresh(); MessageBox.Show("导入数据成功。"); } break; case "m_1to2"://近期 //删除掉原来元素 deltall(tlVectorControl1.SVGDocument.SvgdataUid + "1"); //******** ArrayList sel_line1 = new ArrayList(); LayerGrade l1 = new LayerGrade(); l1.Type = "1"; l1.SvgDataUid = oldsid; IList ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1); if (ttlist.Count > 0) { LayerGrade n1 = (LayerGrade)ttlist[0]; try { int yy = Convert.ToInt32(n1.Name.Substring(0, 4)); XmlNodeList list1to2 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4" + "' and @year<='" + yy + "']"); for (int i = 0; i < list1to2.Count; i++) { SvgElement gra = list1to2[i] as SvgElement; XmlNode temp = gra.Clone(); ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "1"); XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp); //加入节点的名称 XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + gra.GetAttribute("id") + "']"); XmlNode textemp = text.Clone(); ((SvgElement)textemp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "1"); ((SvgElement)textemp).SetAttribute("ParentID", ((SvgElement)temp).GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)textemp); PSPDEV pspDev = new PSPDEV(); pspDev.EleID = gra.ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4"; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); if (pspDev != null) { pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = ((SvgElement)newnode).ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "1"; Services.BaseService.Create<PSPDEV>(pspDev); } } XmlNodeList listline = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4']"); //for (int i = 0; i < list1to2.Count; i++) //{ // SvgElement temp = list1to2[i] as SvgElement; // RectangleF ff = ((IGraph)temp).GetBounds(); // Region r = new Region(((IGraph)temp).GetBounds()); // for (int j = 0; j < listline.Count;j++ ) // { // Polyline pln = listline[j] as Polyline; // if (r.IsVisible(pln.Points[0])) // { // if (!sel_line1.Contains(pln)) // { // sel_line1.Add(pln); // } // } // } //} for (int i = 0; i < listline.Count; i++) { bool firstnodeflag = false; bool lastnodeflag = false; Polyline pln = listline[i] as Polyline; PSPDEV psp = new PSPDEV(); psp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4"; psp.EleID = pln.ID; psp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", psp); if (psp.LineStatus != "等待") { for (int j = 0; j < list1to2.Count; j++) { SvgElement temp = list1to2[j] as SvgElement; Region ff = new Region(((IGraph)temp).GetBounds()); if (ff.IsVisible(pln.Points[0])) { firstnodeflag = true; } if (ff.IsVisible(pln.Points[1])) { lastnodeflag = true; } } if (firstnodeflag && lastnodeflag && !sel_line1.Contains(pln)) { sel_line1.Add(pln); } } } for (int i = 0; i < sel_line1.Count; i++) { SvgElement gra = sel_line1[i] as SvgElement; XmlNode temp = gra.Clone(); ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "1"); XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp); PSPDEV pspDev = new PSPDEV(); pspDev.EleID = gra.ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4"; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); if (pspDev != null) { pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = ((SvgElement)newnode).ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "1"; Services.BaseService.Create<PSPDEV>(pspDev); } } MessageBox.Show("数据处理成功。"); Topology2(); //颜色发生变化 } catch { MessageBox.Show("选择的年份前4位不是数字。"); } } break; case "m_2to3"://中期 deltall(tlVectorControl1.SVGDocument.SvgdataUid + "2"); ArrayList sel_line2 = new ArrayList(); LayerGrade l1_2 = new LayerGrade(); l1_2.Type = "1"; l1_2.SvgDataUid = oldsid; l1_2 = (LayerGrade)Services.BaseService.GetObject("SelectLayerGradeList5", l1_2); LayerGrade l2_2 = new LayerGrade(); l2_2.Type = "2"; l2_2.SvgDataUid = oldsid; l2_2 = (LayerGrade)Services.BaseService.GetObject("SelectLayerGradeList5", l2_2); if (l1_2 != null && l2_2 != null) { try { //整体规划层里的中期数据 int yy1 = Convert.ToInt32(l1_2.Name.Substring(0, 4)); int yy2 = Convert.ToInt32(l2_2.Name.Substring(0, 4)); XmlNodeList list1to2 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4" + "' and @year>'" + yy1 + "' and @year<='" + yy2 + "']"); for (int i = 0; i < list1to2.Count; i++) { SvgElement gra = list1to2[i] as SvgElement; XmlNode temp = gra.Clone(); ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "2"); XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp); //加入节点的名称 XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + gra.GetAttribute("id") + "']"); XmlNode textemp = text.Clone(); ((SvgElement)textemp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "2"); ((SvgElement)textemp).SetAttribute("ParentID", ((SvgElement)temp).GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)textemp); PSPDEV pspDev = new PSPDEV(); pspDev.EleID = gra.ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4"; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); if (pspDev != null) { pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = ((SvgElement)newnode).ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "2"; Services.BaseService.Create<PSPDEV>(pspDev); } } XmlNodeList listline2 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4']"); XmlNodeList list1to1 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4" + "' and @year<='" + yy1 + "']"); for (int i = 0; i < listline2.Count; i++) { bool firstnodeflag = false; bool lastnodeflag = false; bool jinqifirstnodeflag = false; bool jinqilastnodeflag = false; Polyline pln = listline2[i] as Polyline; PSPDEV psp = new PSPDEV(); psp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4"; psp.EleID = pln.ID; psp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", psp); if (psp.LineStatus != "等待") { for (int j = 0; j < list1to2.Count; j++) { SvgElement temp = list1to2[j] as SvgElement; Region ff = new Region(((IGraph)temp).GetBounds()); if (ff.IsVisible(pln.Points[0])) { firstnodeflag = true; } if (ff.IsVisible(pln.Points[1])) { lastnodeflag = true; } } for (int j = 0; j < list1to1.Count; j++) { SvgElement temp = list1to1[j] as SvgElement; Region ff = new Region(((IGraph)temp).GetBounds()); if (ff.IsVisible(pln.Points[0])) { jinqifirstnodeflag = true; } if (ff.IsVisible(pln.Points[1])) { jinqilastnodeflag = true; } } if (firstnodeflag && lastnodeflag && !sel_line2.Contains(pln)) { sel_line2.Add(pln); } if (firstnodeflag && jinqilastnodeflag && !sel_line2.Contains(pln)) { sel_line2.Add(pln); } if (lastnodeflag && jinqifirstnodeflag && !sel_line2.Contains(pln)) { sel_line2.Add(pln); } } } for (int i = 0; i < sel_line2.Count; i++) { SvgElement gra = sel_line2[i] as SvgElement; XmlNode temp = gra.Clone(); ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "2"); XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp); PSPDEV pspDev = new PSPDEV(); pspDev.EleID = gra.ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4"; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); if (pspDev != null) { pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = ((SvgElement)newnode).ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "2"; Services.BaseService.Create<PSPDEV>(pspDev); } } //近期数据 XmlNodeList list_1 = tlVectorControl1.SVGDocument.SelectNodes("svg/* [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "1']"); for (int i = 0; i < list_1.Count; i++) { SvgElement gra = list_1[i] as SvgElement; XmlNode temp = gra.Clone(); ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "2"); XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp); //加入节点的名称 XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + gra.GetAttribute("id") + "']"); if (text != null) { XmlNode textemp = text.Clone(); ((SvgElement)textemp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "2"); ((SvgElement)textemp).SetAttribute("ParentID", ((SvgElement)temp).GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)textemp); } PSPDEV pspDev = new PSPDEV(); pspDev.EleID = gra.ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "1"; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); if (pspDev != null) { pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = ((SvgElement)newnode).ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "2"; if (pspDev.LineStatus == "待选") { pspDev.LineStatus = "运行"; } if (pspDev.LineStatus == "等待") { pspDev.LineStatus = "待选"; } Services.BaseService.Create<PSPDEV>(pspDev); } } MessageBox.Show("数据处理成功。"); Topology2(); //颜色发生变化 } catch { MessageBox.Show("选择的年份前4位不是数字。"); } } break; case "m_3to4"://远期 deltall(tlVectorControl1.SVGDocument.SvgdataUid + "3"); ArrayList sel_line3 = new ArrayList(); LayerGrade l1_3 = new LayerGrade(); l1_3.Type = "2"; l1_3.SvgDataUid = oldsid; l1_3 = (LayerGrade)Services.BaseService.GetObject("SelectLayerGradeList5", l1_3); LayerGrade l2_3 = new LayerGrade(); l2_3.Type = "3"; l2_3.SvgDataUid = oldsid; l2_3 = (LayerGrade)Services.BaseService.GetObject("SelectLayerGradeList5", l2_3); if (l1_3 != null && l2_3 != null) { try { //整体规划层里的远期数据 int yy1 = Convert.ToInt32(l1_3.Name.Substring(0, 4)); int yy2 = Convert.ToInt32(l2_3.Name.Substring(0, 4)); XmlNodeList list1to2 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4" + "' and @year>'" + yy1 + "' and @year<='" + yy2 + "']"); for (int i = 0; i < list1to2.Count; i++) { SvgElement gra = list1to2[i] as SvgElement; XmlNode temp = gra.Clone(); ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "3"); XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp); XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + gra.GetAttribute("id") + "']"); XmlNode textemp = text.Clone(); ((SvgElement)textemp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "3"); ((SvgElement)textemp).SetAttribute("ParentID", ((SvgElement)temp).GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)textemp); PSPDEV pspDev = new PSPDEV(); pspDev.EleID = gra.ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4"; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); if (pspDev != null) { pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = ((SvgElement)newnode).ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "3"; Services.BaseService.Create<PSPDEV>(pspDev); } } XmlNodeList listline2 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4']"); XmlNodeList list1to1 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "4" + "' and @year<='" + yy1 + "']"); for (int i = 0; i < listline2.Count; i++) { bool firstnodeflag = false; bool lastnodeflag = false; bool jinqifirstnodeflag = false; bool jinqilastnodeflag = false; Polyline pln = listline2[i] as Polyline; PSPDEV psp = new PSPDEV(); psp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4"; psp.EleID = pln.ID; psp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", psp); if (psp.LineStatus != "等待") { for (int j = 0; j < list1to2.Count; j++) { SvgElement temp = list1to2[j] as SvgElement; Region ff = new Region(((IGraph)temp).GetBounds()); if (ff.IsVisible(pln.Points[0])) { firstnodeflag = true; } if (ff.IsVisible(pln.Points[1])) { lastnodeflag = true; } } for (int j = 0; j < list1to1.Count; j++) { SvgElement temp = list1to1[j] as SvgElement; Region ff = new Region(((IGraph)temp).GetBounds()); if (ff.IsVisible(pln.Points[0])) { jinqifirstnodeflag = true; } if (ff.IsVisible(pln.Points[1])) { jinqilastnodeflag = true; } } if (firstnodeflag && lastnodeflag && !sel_line3.Contains(pln)) { sel_line3.Add(pln); } if (firstnodeflag && jinqilastnodeflag && !sel_line3.Contains(pln)) { sel_line3.Add(pln); } if (lastnodeflag && jinqifirstnodeflag && !sel_line3.Contains(pln)) { sel_line3.Add(pln); } } } for (int i = 0; i < sel_line3.Count; i++) { SvgElement gra = sel_line3[i] as SvgElement; XmlNode temp = gra.Clone(); ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "3"); XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp); PSPDEV pspDev = new PSPDEV(); pspDev.EleID = gra.ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "4"; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); if (pspDev != null) { pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = ((SvgElement)newnode).ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "3"; Services.BaseService.Create<PSPDEV>(pspDev); } } //中期数据 XmlNodeList list_1 = tlVectorControl1.SVGDocument.SelectNodes("svg/* [@layer='" + tlVectorControl1.SVGDocument.SvgdataUid + "2']"); for (int i = 0; i < list_1.Count; i++) { SvgElement gra = list_1[i] as SvgElement; XmlNode temp = gra.Clone(); ((SvgElement)temp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "3"); XmlNode newnode = tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)temp); //加入节点的名称 XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + gra.GetAttribute("id") + "']"); if (text != null) { XmlNode textemp = text.Clone(); ((SvgElement)textemp).SetAttribute("layer", tlVectorControl1.SVGDocument.SvgdataUid + "3"); ((SvgElement)textemp).SetAttribute("ParentID", ((SvgElement)temp).GetAttribute("id")); tlVectorControl1.SVGDocument.RootElement.AppendChild((XmlNode)textemp); } PSPDEV pspDev = new PSPDEV(); pspDev.EleID = gra.ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "2"; pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev); if (pspDev != null) { pspDev.SUID = Guid.NewGuid().ToString(); pspDev.EleID = ((SvgElement)newnode).ID; pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid + "3"; if (pspDev.LineStatus == "待选") { pspDev.LineStatus = "运行"; } if (pspDev.LineStatus == "等待") { pspDev.LineStatus = "待选"; } Services.BaseService.Create<PSPDEV>(pspDev); } } MessageBox.Show("数据处理成功。"); Topology2(); //颜色发生变化 } catch { MessageBox.Show("选择的年份前4位不是数字。"); } } break; #endregion } } }
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(); } } }
/*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)tlVectorControl2.SVGDocument.CurrentElement; //PointF[] pf = TLMath.getPolygonPoints(xml1); //((Polygon)xml1).Transform.Matrix.TransformPoints(pf); // 规划 if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl2.SVGDocument.getLayerList())) { if (xml1 == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请先选择规划区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (tlVectorControl2.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") { XmlNodeList n1 = tlVectorControl2.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; 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]); } } 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); } glebeProperty _gle = new glebeProperty(); _gle.EleID = tlVectorControl2.SVGDocument.CurrentElement.ID; _gle.SvgUID = tlVectorControl2.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 (getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl2.SVGDocument.getLayerList())) { if (tlVectorControl2.SVGDocument.getRZBRatio() != "") { rzb = tlVectorControl2.SVGDocument.getRZBRatio(); } if (xml1 == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请先选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (tlVectorControl2.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") { string IsArea = ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).GetAttribute("IsArea"); if (IsArea != "") { frmProperty f = new frmProperty(); f.InitData(xml1.GetAttribute("id"), tlVectorControl2.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer); //f.ShowDialog(); if (progtype != "城市规划层") { f.IsReadonly = true; } if (f.ShowDialog() == DialogResult.OK) { if (f.gPro.ObligateField1 != "") { string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(f.gPro.ObligateField1))); color1 = "fill:" + color1 + ";"; ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).SetAttribute("style", color1); tlVectorControl2.UpdateProperty(); } } } } } if (tlVectorControl2.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl2.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") { string lineWidth = "2"; string IsLead = ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).GetAttribute("IsLead"); if (IsLead != "") { frmLineProperty fl = new frmLineProperty(); fl.InitData(tlVectorControl2.SVGDocument.CurrentElement.GetAttribute("id"), tlVectorControl2.SVGDocument.SvgdataUid, LineLen, 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:6 1;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))); ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).RemoveAttribute("style"); ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).SetAttribute("style", styleValue); // tlVectorControl1.UpdateProperty(); // xml1.SetAttribute("style", styleValue); } } } if (xml1.GetAttribute("xlink:href").Contains("Substation")) { string lab = xml1.GetAttribute("xlink:href"); frmSubstationProperty frmSub = new frmSubstationProperty(); frmSub.InitData(xml1.GetAttribute("id"), tlVectorControl2.SVGDocument.SvgdataUid, SvgDocument.currentLayer, lab); frmSub.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.InitData(Code, tlVectorControl2.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)tlVectorControl2.SVGDocument.CurrentElement).RemoveAttribute("style"); ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).SetAttribute("style", styleValue); xltProcessor.SetWholeLineAttribute(Code, "style", styleValue); } } } if (e.ClickedItem.Text == "移动") { if (tlVectorControl2.SVGDocument.CurrentElement == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") { return; } XmlElement xmln = (XmlElement)tlVectorControl2.SVGDocument.CurrentElement; frmMove fm = new frmMove(); if (fm.ShowDialog() == DialogResult.OK) { string strValue = fm.StrValue; string[] str = strValue.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); PointF OffPoint = TLMath.getUseOffset(xmln.GetAttribute("xlink:href")); xmln.RemoveAttribute("transform"); //xmln.RemoveAttribute("x"); xmln.SetAttribute("x", ((Double)(-xy.X / (Double)tlVectorControl2.ScaleRatio) - (Double)OffPoint.X).ToString("#####.####")); // xmln.RemoveAttribute("y"); xmln.SetAttribute("y", ((Double)(-xy.Y / (Double)tlVectorControl2.ScaleRatio) - (Double)OffPoint.Y).ToString("#####.####")); tlVectorControl2.Refresh(); } } if (e.ClickedItem.Text == "接线图") { if (tlVectorControl2.SVGDocument.CurrentElement == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") { return; } ParentUID = tlVectorControl2.SVGDocument.SvgdataUid; Save(); ParentUID = tlVectorControl2.SVGDocument.SvgdataUid; SVGFILE svg_temp = new SVGFILE(); svg_temp.SUID = ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).GetAttribute("id"); svg_temp.FILENAME = ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).GetAttribute("info-name"); IList svglist = Services.BaseService.GetList("SelectSVGFILEByKey", svg_temp); OpenJXT(svglist, svg_temp); //frmlar.SymbolDoc = tlVectorControl2.SVGDocument; //frmlar.Progtype = MapType; //frmlar.InitData(); //JxtBar(); } if (e.ClickedItem.Text == "打开") { if (tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } UseRelating UseRel = new UseRelating(); UseRel.UseID = tlVectorControl2.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(tlVectorControl2, 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 = tlVectorControl2.SVGDocument.CurrentElement as Graph; if (poly1 == null || poly1.GetAttribute("id") == "svg") { return; } GraphicsPath gr1 = new GraphicsPath(); 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 = tlVectorControl2.SVGDocument.GetElementsByTagName("defs"); if (nlist.Count > 0) { XmlNode node = nlist[0]; svgtxt.AppendLine(node.OuterXml); } SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl2.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 = tlVectorControl2.SVGDocument.SvgdataUid; frmPrintF pri = new frmPrintF(); pri.Init(tlVectorControl2.SVGDocument.CurrentElement.ID, tlVectorControl2.SVGDocument.SvgdataUid); if (pri.ShowDialog() == DialogResult.OK) { frmSubPrint s = new frmSubPrint(); s.Vector = tlVectorControl2; s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist); s.Open(_doc, ef1); s.Show(); } } if (e.ClickedItem.Text == "分类统计报表") { if (tlVectorControl2.SVGDocument.CurrentElement == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") { return; } IGraph poly1 = (IGraph)tlVectorControl2.SVGDocument.CurrentElement; frmPloyPrint p = new frmPloyPrint(); p.InitDate(poly1.ID, tlVectorControl2.SVGDocument.SvgdataUid); p.ShowDialog(); } } catch (Exception e1) { MessageBox.Show(e1.Message); } }