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) { switch (btItem.Name) { #region 文件操作 case "mNew": frmNewProject frmprojectDLG = new frmNewProject(); frmprojectDLG.Name = ""; if (frmprojectDLG.ShowDialog() == DialogResult.OK) { tlVectorControl1.NewFile(); PSP_ELCPROJECT pd = new PSP_ELCPROJECT(); pd.Name = frmprojectDLG.Name; pd.FileType = frmprojectDLG.FileType; pd.Class = System.DateTime.Now.ToString(); pd.ProjectID = this.ProjectUID; tlVectorControl1.SVGDocument.SvgdataUid = pd.ID; SvgDocument.currentLayer = Layer.CreateNew("默认层", tlVectorControl1.SVGDocument).ID; Layer la = tlVectorControl1.SVGDocument.GetLayerByID(SvgDocument.currentLayer); la.SetAttribute("layerType", "电网规划层"); Services.BaseService.Create<PSP_ELCPROJECT>(pd); if (pd.ID != null) { Open(pd.ID); intdata(pd.ID); //if (this.Text.Contains()) //{ //} this.Text = frmname + "-" + pd.Name; } this.Show(); jxtbar(1); LoadShape("symbol20.xml"); } 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; // } //} OpenProject op = new OpenProject(); op.ProjectID = this.ProjectUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { Open(op.FileSUID); intdata(op.FileSUID); //if (this.Text.Contains()) //{ //} this.Text = frmname + "-" + op.FileName; } this.Show(); jxtbar(1); LoadShape("symbol20.xml"); } break; case "barDeviceData": frmProjectManager frmPdlg = new frmProjectManager(); frmPdlg.SetMode(tlVectorControl1.SVGDocument.SvgdataUid); frmPdlg.ShowDialog(); break; case "btExSymbol": tlVectorControl1.ExportSymbol(); break; case "mjxt"://导入接线图 ImportJxt2 jxt = new ImportJxt2(tlVectorControl1); jxt.Import(); break; case "mSave": Save(); //tlVectorControl1.Save(); //frmElementName dlg = new frmElementName(); //dlg.TextInput = tlVectorControl1.SVGDocument.FileName; //if (dlg.ShowDialog() == DialogResult.OK) //{ // tlVectorControl1.SVGDocument.FileName = dlg.TextInput; // Save(); //} break; case "mSaveAs": tlVectorControl1.SaveAs(); break; case "mExit": this.Close(); break; case "bt1": //InitTK(); 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.SvgdataUid); //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": break; case "Dlqibutt": break; //MessageBox.Show("请选中母线点,然后点击右键输入断路器属性" "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //duluqiflag=true; //基础操作 case "mFreeTransform": tlVectorControl1.Operation = ToolOperation.FreeTransform; break; case "mCJ": tlVectorControl1.Operation = ToolOperation.PolyLine; csOperation = CustomOperation.OP_MeasureDistance; break; //case "ButtonItem2": // break; #endregion #region 无功优化参数维护 case "VoltLimit": break; case "GeneratorLimit": break; case "TransformLimit": break; case "SVC": break; #endregion #region 基础图元 case "mLayer": tlVectorControl1.LayerManager(); break; 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 "butRef": Ref(); 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": break; case "ButtonItem8": break; case "mCheck": break; case "DFSResult": frmSetPower frmSPR = new frmSetPower(); frmSPR.ProjectID = this.tlVectorControl1.SVGDocument.SvgdataUid; if (frmSPR.ShowDialog() == DialogResult.OK) { ElectricLoadCal elcDFS = new ElectricLoadCal(); //string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'"; //string strCon2 = null; //string strCon = null; //strCon2 = " AND Type = '05'"; //strCon = strCon1 + strCon2; //IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon); //strCon2 = " AND Type = '01'"; //strCon = strCon1 + strCon2; //IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon); IList branchList = new List<PSPDEV>(); IList busList = new List<PSPDEV>(); //foreach (PSPDEV dev in listXL) //{ // if (dev.Number>=14) // { // branchList.Add(dev); // } //} //foreach (PSPDEV dev in listMX) //{ // if (dev.Number<=3) // { // busList.Add(dev); // } //} busList = frmSPR.ListPower; branchList = frmSPR.ListBranch; if (busList != null) { elcDFS.DFSER(branchList, busList, tlVectorControl1.SVGDocument.SvgdataUid, 100, 1); } } break; case "DFS": frmSetPower frmSP = new frmSetPower(); frmSP.ProjectID = this.tlVectorControl1.SVGDocument.SvgdataUid; if (frmSP.ShowDialog() == DialogResult.OK) { ElectricLoadCal elcDFS = new ElectricLoadCal(); //string strCon1 = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + tlVectorControl1.SVGDocument.SvgdataUid + "'"; //string strCon2 = null; //string strCon = null; //strCon2 = " AND Type = '05'"; //strCon = strCon1 + strCon2; //IList listXL = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon); //strCon2 = " AND Type = '01'"; //strCon = strCon1 + strCon2; //IList listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon); IList branchList = new List<PSPDEV>(); IList busList = new List<PSPDEV>(); //foreach (PSPDEV dev in listXL) //{ // if (dev.Number>=14) // { // branchList.Add(dev); // } //} //foreach (PSPDEV dev in listMX) //{ // if (dev.Number<=3) // { // busList.Add(dev); // } //} busList = frmSP.ListPower; branchList = frmSP.ListBranch; if (busList != null) { elcDFS.DFS(branchList, busList, tlVectorControl1.SVGDocument.SvgdataUid, 100); ShowResult(0); } } break; case "niula": 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(tlVectorControl1.SVGDocument.SvgdataUid, 1, 100, wFrom); ShowResult(0, wFrom); break; case "pq": frnReport wFromPQ = new frnReport(); wFromPQ.Owner = this; wFromPQ.Show(); wFromPQ.Text = this.Text + "—PQ分解法潮流计算"; wFromPQ.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString(); ElectricLoadCal elcPQ = new ElectricLoadCal(); elcPQ.LFC(tlVectorControl1.SVGDocument.SvgdataUid, 2, 100, wFromPQ); ShowResult(1, wFromPQ); break; case "GaussSeidel": frnReport wFromGS = new frnReport(); wFromGS.Owner = this; wFromGS.Show(); wFromGS.Text = this.Text + "—高斯赛德尔迭代法潮流计算"; wFromGS.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString(); ElectricLoadCal elcGS = new ElectricLoadCal(); elcGS.LFC(tlVectorControl1.SVGDocument.SvgdataUid, 3, 100, wFromGS); ShowResult(2, wFromGS); break; case "N_RZYz": 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(tlVectorControl1.SVGDocument.SvgdataUid, 4, 100, wFromZYZ); ShowResult(3, wFromZYZ); break; case "niulaNfh": elc = new ElectricLoadCal(); elc.LFCS(tlVectorControl1.SVGDocument.SvgdataUid, 4, 100); ShowResult(3); break; case "WebRela": //进行网络N-1检验 ElectricRelcheck elcRela = new ElectricRelcheck(); elcRela.WebCalAndPrint(tlVectorControl1.SVGDocument.SvgdataUid, this.ProjectUID, 100); break; case "TransRela": //进行变压器N-1检验 break; case "Shortibut": break; case "dd": //SubPrint = true; tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint; break; case "NiulaResult": ElectricLoadCal elcResult = new ElectricLoadCal(); elcResult.LFCER(tlVectorControl1.SVGDocument.SvgdataUid, 1, 100); break; case "PQResult": ElectricLoadCal elcPQResult = new ElectricLoadCal(); elcPQResult.LFCER(tlVectorControl1.SVGDocument.SvgdataUid, 2, 100); break; case "GaussSeidelResult": ElectricLoadCal elcGSResult = new ElectricLoadCal(); elcGSResult.LFCER(tlVectorControl1.SVGDocument.SvgdataUid, 3, 100); break; case "N_RZYzResult": ElectricLoadCal elcNZResult = new ElectricLoadCal(); elcNZResult.LFCER(tlVectorControl1.SVGDocument.SvgdataUid, 4, 100); break; case "NLnFHresult": elc = new ElectricLoadCal(); elc.LFCERS(tlVectorControl1.SVGDocument.SvgdataUid, 4, 100); break; case "VoltEvaluation": ElectricLoadCal elcVE = new ElectricLoadCal(); elcVE.VE(tlVectorControl1.SVGDocument.SvgdataUid, 100); break; case "PowerLossCal": ElectricLoadCal elcPLResult = new ElectricLoadCal(); elcPLResult.PLE(tlVectorControl1.SVGDocument.SvgdataUid, 2, 100); ShowPowerLoss(); break; case "PowerLoss": ElectricLoadCal elcPLE = new ElectricLoadCal(); elcPLE.PLE(tlVectorControl1.SVGDocument.SvgdataUid, 2, 100); break; case "ZLPResult1": break; case "mDLR": break; case "clearResult": try { XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']"); foreach (XmlNode node in list) { SvgElement element = node as SvgElement; tlVectorControl1.SVGDocument.CurrentElement = element; tlVectorControl1.Delete(); } } catch (System.Exception ex) { } 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": break; #endregion #region 视图 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) { if (element is Text) { PSP_ElcDevice elcDEV = new PSP_ElcDevice(); elcDEV.ProjectSUID = tlVectorControl1.SVGDocument.SvgdataUid; elcDEV.DeviceSUID = element.GetAttribute("Deviceid"); Services.BaseService.Delete<PSP_ElcDevice>(elcDEV); } } 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; case "PSPIdleOptimize": ElectricLoadCal elcORP = new ElectricLoadCal(); elcORP.ORP(tlVectorControl1.SVGDocument.SvgdataUid, 100); break; #endregion #region 参数维护 case "mNodeParam": break; case "mLineParam": break; case "mWire": break; case "nTransformLineParam": break; case "nGNDLineParam": break; case "mLineDL": break; case "mFadianDL": break; case "mConvert": break; #endregion } } }
private void dotNetBarManager1_ItemClick(object sender, EventArgs e) { DevComponents.DotNetBar.ButtonItem btItem = sender as DevComponents.DotNetBar.ButtonItem; //Layer layer1 = (Layer)LayerBox.ComboBoxEx.SelectedItem; if (btItem != null) { if (btItem.Name == "mRoam") { frmlar.Hide(); } else { frmlar.Show(); } switch (btItem.Name) { #region 文件操作 case "mNew": tlVectorControl1.NewFile(); break; case "mOpen": break; case "mImport": ExportImage(); //ImportDxf(); break; case "ImportDxf": ImportDxf(); break; case "btExSymbol": tlVectorControl1.ExportSymbol(); break; case "mSave": SaveButton(); break; case "mSaveSVG": tlVectorControl1.SaveAs(); break; case "mExit": this.Close(); //System.Data.OleDb.OleDbConnection c = new OleDbConnection("Provider=SQLOLEDB;Data source=192.168.0.30;initial catalog=tlpsp_tzkq;user id=sa;password=sa"); //OleDbCommand cmd = c.CreateCommand(); break; case "bt1": InitTK(); break; case "callCAD": try { //Autodesk.AutoCAD.Interop. if (MessageBox.Show("此操作需要花费较长时间,确认导出么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { CAD cad = new CAD(); cad.tlVectorControl1 = tlVectorControl1; cad.WriteDwg("ALL"); } } catch { MessageBox.Show("请安装AutoCAD2006或以上版本。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "callCADSub": try { //Autodesk.AutoCAD.Interop.AcadApplicationClass a = new Autodesk.AutoCAD.Interop.AcadApplicationClass(); if (MessageBox.Show("此操作需要花费较长时间,确认导出么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { CAD cad = new CAD(); cad.tlVectorControl1 = tlVectorControl1; string strlar = frmlar.getSelectedLayer(); cad.WriteDwg(strlar); } } catch { MessageBox.Show("请安装AutoCAD2006或以上版本。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "mPriSet": tlVectorControl1.PaperSetup(); break; case "mPrint": tlVectorControl1.Print(); break; case "mView": //frmSvgView fView = new frmSvgView(); //fView.Open(tlVectorControl1.SVGDocument.SvgdataUid); //fView.Show(); break; case "mViewScale": if (img != null) { frmtempViewScale fscale1 = new frmtempViewScale(); fscale1.ShowDialog(); } else { frmViewScale fScale = new frmViewScale(); string viewScale = tlVectorControl1.SVGDocument.getViewScale(); if (viewScale != "") { fScale.InitData(viewScale); } if (fScale.ShowDialog() == DialogResult.OK) { //viewScale = fScale.ViewScale; string _viewScale = fScale.ViewScale; tlVectorControl1.SVGDocument.setViewScale(_viewScale); if (viewScale == "") { viewScale = "1"; } Recalculate(Convert.ToDecimal(_viewScale) / Convert.ToDecimal(viewScale)); } } break; //case "mIncreaseView": // tlVectorControl1.Operation = ToolOperation.IncreaseView; // break; case "mRzb": frmRatio fRat = new frmRatio(); string viewRat = tlVectorControl1.SVGDocument.getRZBRatio(); if (viewRat != "") { fRat.InitData(viewRat); } if (fRat.ShowDialog() == DialogResult.OK) { viewRat = fRat.ViewScale; tlVectorControl1.SVGDocument.setRZBRatio(viewRat); } break; case "mEdit": if (MapType == "所内接线图") { Save(); dotNetBarManager1.Bars["mainmenu"].GetItem("ImportDxf").Visible = false; svg.SUID = ParentUID; IList svglist = Services.BaseService.GetList("SelectSVGFILEByKey", svg); svg = (SVGFILE)svglist[0]; sdoc = null; sdoc = new SvgDocument(); sdoc.LoadXml(svg.SVGDATA); tlVectorControl1.SVGDocument = sdoc; tlVectorControl1.SVGDocument.SvgdataUid = svg.SUID; MapType = "接线图"; CtrlSvgView.MapType = "接线图"; LoadShape("symbol_3.xml"); Init(progtype); //ButtonEnb(true); frmlar.SymbolDoc = tlVectorControl1.SVGDocument; frmlar.Progtype = progtype; frmlar.InitData(); dotNetBarManager1.Bars["mainmenu"].GetItem("ButtonItem2").Enabled = true; dotNetBarManager1.Bars["mainmenu"].GetItem("ButtonItem7").Enabled = true; bk1.Enabled = true; LoadImage = true; tlVectorControl1.Refresh(); } tlVectorControl1.ContextMenuStrip = contextMenuStrip1; MapType = "接线图"; break; case "mAbout": frmAbout frma = new frmAbout(); frma.ShowDialog(); break; //基础操作 case "mFreeTransform": tlVectorControl1.Operation = ToolOperation.FreeTransform; break; case "mRoam1": tlVectorControl1.Operation = ToolOperation.Roam; break; case "mShapeTransform1": tlVectorControl1.Operation = ToolOperation.Custom11; break; case "mShapeTransform2": tlVectorControl1.Operation = ToolOperation.Custom12; break; case "mShapeTransform3": tlVectorControl1.Operation = ToolOperation.Custom13; break; case "mShapeTransform4": tlVectorControl1.Operation = ToolOperation.Custom15; break; case "mShapeTransform5": tlVectorControl1.Operation = ToolOperation.Custom14; break; case "m_ljxl": ConnLine(); break; case "mAngleRectangle1": tlVectorControl1.Operation = ToolOperation.AngleRectangle; break; case "mSelect1": case "mSel1": //tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.FreeTransform; break; case "mLine1": tlVectorControl1.Operation = ToolOperation.Line; break; case "mPolyline1": tlVectorControl1.Operation = ToolOperation.PolyLine; break; case "mImage1": tlVectorControl1.Operation = ToolOperation.Image; break; case "mText1": tlVectorControl1.Operation = ToolOperation.Text; break; case "mEllipse1": tlVectorControl1.Operation = ToolOperation.Ellipse; break; case "mBezier1": tlVectorControl1.Operation = ToolOperation.Bezier; break; //图元操作 case "mCopy1": tlVectorControl1.Copy(); break; case "mCut1": tlVectorControl1.Cut(); break; case "mPaste1": PasteWithProperty(); break; case "mDelete1": if (tlVectorControl1.SVGDocument.CurrentElement != null && tlVectorControl1.SVGDocument.CurrentElement.ID != "svg") { frmMessageBox msg = new frmMessageBox(); if (msg.ShowDialog() == DialogResult.OK) { if (msg.ck) { // if(MessageBox.Show("确认删除么?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Information)==DialogResult.Yes){ for (int i = 0; i < tlVectorControl1.SVGDocument.SelectCollection.Count; i++) { if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polygon") { glebeProperty gle = new glebeProperty(); gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; gle.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; Services.BaseService.Update("DeleteglebePropertyByEleID", gle); } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line") { LineInfo _line = new LineInfo(); _line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _line.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; LineInfo temp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _line); if (temp != null) { Services.BaseService.Update("DeleteLinePropertyByEleID", _line); Services.BaseService.Update("DeleteLine_InfoByCode", temp.UID); } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use") { string str_name = ((XmlElement)(tlVectorControl1.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href"); if (str_name.Contains("Substation")) { substation _sub = new substation(); _sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _sub.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; substation temp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub); if (temp != null) { Services.BaseService.Update("DeletesubstationByEleID", _sub); Services.BaseService.Update("DeleteSubstation_InfoByCode", temp.UID); } } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") { ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.SelectCollection[i]; if (cline.StartGraph != null) { SvgElement ele = (SvgElement)cline.StartGraph; if (!ele.GetAttribute("xlink:href").Contains("Substation")) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.StartGraph); } } if (cline.EndGraph != null) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.EndGraph); } } } } else { for (int i = 0; i < tlVectorControl1.SVGDocument.SelectCollection.Count; i++) { if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Polyline" || tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Line") { LineInfo _line = new LineInfo(); _line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _line.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; LineInfo linetemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", _line); if (linetemp != null) { PowerProTypes temp = (PowerProTypes)Services.BaseService.GetObject("SelectPowerProTypesByCode", linetemp.UID); if (temp != null) { linetemp.EleID = ""; Services.BaseService.Update<LineInfo>(linetemp); } else { Services.BaseService.Update("DeleteLineInfo", linetemp); } } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.Use") { string str_name = ((XmlElement)(tlVectorControl1.SVGDocument.SelectCollection[i])).GetAttribute("xlink:href"); if (str_name.Contains("Substation")) { substation _sub = new substation(); _sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; _sub.EleID = tlVectorControl1.SVGDocument.SelectCollection[i].ID; substation subtemp = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub); if (subtemp != null) { PowerProTypes temp = (PowerProTypes)Services.BaseService.GetObject("SelectPowerProTypesByCode", subtemp.UID); if (temp != null) { subtemp.EleID = ""; Services.BaseService.Update<substation>(subtemp); } else { Services.BaseService.Update("Deletesubstation", subtemp); } } } } if (tlVectorControl1.SVGDocument.SelectCollection[i].GetType().ToString() == "ItopVector.Core.Figure.ConnectLine") { ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.SelectCollection[i]; if (cline.StartGraph != null) { SvgElement ele = (SvgElement)cline.StartGraph; if (!ele.GetAttribute("xlink:href").Contains("Substation")) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.StartGraph); } } if (cline.EndGraph != null) { tlVectorControl1.SVGDocument.SelectCollection.Add(cline.EndGraph); } } } } tlVectorControl1.Delete(); } } //tlVectorControl1.Operation = ToolOperation.Select; break; case "mUodo1": tlVectorControl1.Undo(); break; case "mRedo1": tlVectorControl1.Redo(); break; case "mAlign1": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.Align(AlignType.Left); } else { tlVectorControl1.Align(AlignType.Left); } tlVectorControl1.Refresh(); break; case "mAlignLeft1": tlVectorControl1.Align(AlignType.Left); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignRight1": tlVectorControl1.Align(AlignType.Right); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignTop1": tlVectorControl1.Align(AlignType.Top); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignBottom1": tlVectorControl1.Align(AlignType.Bottom); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignHorizontalCenter1": tlVectorControl1.Align(AlignType.HorizontalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignVerticalCenter1": tlVectorControl1.Align(AlignType.VerticalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mOrder1": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.ChangeLevel(LevelType.Top); } else { tlVectorControl1.ChangeLevel(LevelType.Top); } break; case "mGoTop1": tlVectorControl1.ChangeLevel(LevelType.Top); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoUp1": tlVectorControl1.ChangeLevel(LevelType.Up); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoDown1": tlVectorControl1.ChangeLevel(LevelType.Down); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoBottom1": tlVectorControl1.ChangeLevel(LevelType.Bottom); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mRotate1": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.FlipX(); } else { tlVectorControl1.FlipX(); } break; case "mToH1": tlVectorControl1.FlipX(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToV1": tlVectorControl1.FlipY(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToLeft1": tlVectorControl1.RotateSelection(-90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToRight1": tlVectorControl1.RotateSelection(90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; //图形操作 case "mLeadLine1": if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("电网规划层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // sgt1.Visible = true; tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.LeadLine; break; case "mAreaPoly1": if (!getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("城市规划层")) { MessageBox.Show("请选择城市规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.AreaPolygon; break; case "mFzzj1": //放置注记 if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //LayerBox.ComboBoxEx.SelectedIndex = 2; tlVectorControl1.Operation = ToolOperation.Select; MapType = "规划统计"; break; case "mPriQu1": SubPrint = true; tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint; break; case "mReCompute1": if (MessageBox.Show("确认要重新计算全图的电量和负荷么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string scale = tlVectorControl1.SVGDocument.getViewScale(); if (scale != "") { Recalculate(Convert.ToDecimal(scale)); } else { Recalculate(1); } MessageBox.Show("重新计算完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "mFhbz1": if (MessageBox.Show("是否生成负荷标注?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { Fhbz(); } break; case "mCJ": tlVectorControl1.Operation = ToolOperation.PolyLine; csOperation = CustomOperation.OP_MeasureDistance; break; #endregion #region 基础图元 case "mDecreaseView": tlVectorControl1.Operation = ToolOperation.DecreaseView; break; case "mIncreaseView": tlVectorControl1.Operation = ToolOperation.IncreaseView; break; case "mRoam": tlVectorControl1.Operation = ToolOperation.Roam; break; case "mSelect": case "mSel": //tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.FreeTransform; sel_sym = ""; sel_start_point = ""; break; //case "mFreeTransform": // tlVectorControl1.Operation = ToolOperation.FreeTransform; // break; case "mFreeLines"://锁套 tlVectorControl1.Operation = ToolOperation.FreeLines; break; case "mFreePath": tlVectorControl1.Operation = ToolOperation.FreePath; break; case "mShapeTransform": tlVectorControl1.Operation = ToolOperation.ShapeTransform; break; case "mAngleRectangle": tlVectorControl1.Operation = ToolOperation.AngleRectangle; break; case "mEllipse": tlVectorControl1.Operation = ToolOperation.Ellipse; break; case "mLine": tlVectorControl1.Operation = ToolOperation.Line; break; case "mPolyline": tlVectorControl1.Operation = ToolOperation.PolyLine; break; case "mPolygon": tlVectorControl1.Operation = ToolOperation.Polygon; break; case "mImage": tlVectorControl1.Operation = ToolOperation.Image; break; case "mText": tlVectorControl1.Operation = ToolOperation.Text; break; case "mBezier": tlVectorControl1.Operation = ToolOperation.Bezier; break; case "mEnclosure": tlVectorControl1.Operation = ToolOperation.Enclosure; break; case "mGroup": tlVectorControl1.Group(); break; case "mUnGroup": tlVectorControl1.UnGroup(); break; case "mlinelx": tlVectorControl1.Operation = ToolOperation.ConnectLine_Line; break; case "mzxlx": tlVectorControl1.Operation = ToolOperation.ConnectLine_Rightangle; break; case "mqxlx": tlVectorControl1.Operation = ToolOperation.ConnectLine_Spline; break; case "mqzlx": tlVectorControl1.Operation = ToolOperation.ConnectLine_Polyline; break; case "mCJ1": tlVectorControl1.Operation = ToolOperation.PolyLine; csOperation = CustomOperation.OP_MeasureDistance; break; #endregion #region 视图 case "mOption": tlVectorControl1.SetOption(); break; case "mLayer": LayerManagerShow(); //tlVectorControl1.LayerManager(); break; case "mAirscape": frmAirscape fAir = new frmAirscape(); fAir.InitData(tlVectorControl1); fAir.Owner = this; fAir.ShowInTaskbar = false; fAir.Top = Screen.PrimaryScreen.WorkingArea.Height - 250; fAir.Left = Screen.PrimaryScreen.WorkingArea.Width - 300; fAir.Show(); break; case "btTL": frmGlebeTypeList fgle = new frmGlebeTypeList(); fgle.Show(); break; case "mMapOpacity"://地图透明度 frmMapSetup dlg = new frmMapSetup(); dlg.MapOpacity = this.MapOpacity; if (dlg.ShowDialog() == DialogResult.OK) { this.MapOpacity = dlg.MapOpacity; } break; #endregion #region 查看 case "mDklb": //SaveAllLayer(); frmLayerList lay = new frmLayerList(); lay.InitData(tlVectorControl1.SVGDocument.getLayerList(), "1"); if (lay.ShowDialog() == DialogResult.OK) { frmglebePropertyList flist1 = new frmglebePropertyList(); flist1.InitDataSub(tlVectorControl1.SVGDocument.SvgdataUid, lay.str_sid); flist1.Show(); } break; case "m_dktj": frmLayerList layn = new frmLayerList(); layn.InitData(tlVectorControl1.SVGDocument.getLayerList(), "1"); if (layn.ShowDialog() == DialogResult.OK) { frmglebePropertyZHList flist1 = new frmglebePropertyZHList(); flist1.InitDataSub(tlVectorControl1.SVGDocument.SvgdataUid, layn.str_sid); flist1.Show(); } break; case "mGhlb": frmLayerList lay2 = new frmLayerList(); lay2.InitData(tlVectorControl1.SVGDocument.getLayerList(), "2"); if (lay2.ShowDialog() == DialogResult.OK) { frmglebePropertyList flist2 = new frmglebePropertyList(); flist2.InitData(tlVectorControl1.SVGDocument.SvgdataUid, lay2.str_sid); flist2.Show(); } break; case "mLineList": frmLayerList lay3 = new frmLayerList(); lay3.InitData(tlVectorControl1.SVGDocument.getLayerList(), "2"); if (lay3.ShowDialog() == DialogResult.OK) { frmLinePropertyList flist3 = new frmLinePropertyList(); flist3.InitData(tlVectorControl1.SVGDocument.SvgdataUid, lay3.str_sid); flist3.Show(); } break; case "mDlph": frmLayerList lay4 = new frmLayerList(); lay4.InitData(tlVectorControl1.SVGDocument.getLayerList(), "3"); if (lay4.ShowDialog() == DialogResult.OK) { frmSubstationPropertyList fSub = new frmSubstationPropertyList(); fSub.InitData(tlVectorControl1.SVGDocument.SvgdataUid, lay4.str_sid); fSub.Show(); } break; case "ButtonJXT": if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg" || (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString()) != "ItopVector.Core.Figure.Use") { MessageBox.Show("没有选择变电站!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ParentUID = tlVectorControl1.SVGDocument.SvgdataUid; Save(); ParentUID = tlVectorControl1.SVGDocument.SvgdataUid; SVGFILE svg_temp = new SVGFILE(); svg_temp.SUID = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("id"); svg_temp.FILENAME = getBdzName(svg_temp.SUID);// IList svglist1 = Services.BaseService.GetList("SelectSVGFILEByKey", svg_temp); OpenJXT(svglist1, svg_temp); break; #endregion #region 布局,对齐,顺序 case "mRotate": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.FlipX(); } else { tlVectorControl1.FlipX(); } break; case "mToH": tlVectorControl1.FlipX(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToV": tlVectorControl1.FlipY(); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToLeft": tlVectorControl1.RotateSelection(-90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mToRight": tlVectorControl1.RotateSelection(90f); this.rotateButton.Tag = btItem; this.rotateButton.ImageIndex = btItem.ImageIndex; break; case "mAlign": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.Align(AlignType.Left); } else { tlVectorControl1.Align(AlignType.Left); } tlVectorControl1.Refresh(); break; case "mAlignLeft": tlVectorControl1.Align(AlignType.Left); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignRight": tlVectorControl1.Align(AlignType.Right); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignTop": tlVectorControl1.Align(AlignType.Top); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignBottom": tlVectorControl1.Align(AlignType.Bottom); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignHorizontalCenter": tlVectorControl1.Align(AlignType.HorizontalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mAlignVerticalCenter": tlVectorControl1.Align(AlignType.VerticalCenter); this.alignButton.ImageIndex = btItem.ImageIndex; this.alignButton.Tag = btItem; tlVectorControl1.Refresh(); break; case "mOrder": if (btItem.Tag is ButtonItem) { btItem = btItem.Tag as ButtonItem; tlVectorControl1.ChangeLevel(LevelType.Top); } else { tlVectorControl1.ChangeLevel(LevelType.Top); } break; case "mGoTop": tlVectorControl1.ChangeLevel(LevelType.Top); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoUp": tlVectorControl1.ChangeLevel(LevelType.Up); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoDown": tlVectorControl1.ChangeLevel(LevelType.Down); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; case "mGoBottom": tlVectorControl1.ChangeLevel(LevelType.Bottom); this.orderButton.Tag = btItem; this.orderButton.ImageIndex = btItem.ImageIndex; break; #endregion #region 图元操作 case "mCopy": tlVectorControl1.Copy(); break; case "mCut": tlVectorControl1.Cut(); break; case "mPaste": //tlVectorControl1.Paste(); PasteWithProperty(); break; case "mDelete": Delete(); //tlVectorControl1.Operation = ToolOperation.Select; break; case "mUodo": tlVectorControl1.Undo(); break; case "mRedo": tlVectorControl1.Redo(); break; #endregion #region 业务操作 case "m_line1": //线路走廊优化 Wjghboolflag = false; frmPlanList f = new frmPlanList(); if (f.ShowDialog() == DialogResult.Yes) { linekey = f.Key; tlVectorControl1.Operation = ToolOperation.Select; //tlVectorControl1.Operation = ToolOperation.LeadLine; } break; case "m_subxz": //变电站选址 Wjghboolflag = false; Services.BaseService.GetList<PSP_SubstationSelect>(); frmSubstationManager mng = new frmSubstationManager(); mng.OnOpen += new OnOpenSubhandler(mng_OnOpen); DialogResult dia = mng.ShowDialog(); if (dia == DialogResult.OK) { XZ_bdz = mng.code; MessageBox.Show("请选择变电站拖放置到希望的位置或者进行变电站自动选址。"); PSP_SubstationSelect sel = new PSP_SubstationSelect(); sel.col2 = XZ_bdz; IList<PSP_SubstationSelect> _plist = Services.BaseService.GetList<PSP_SubstationSelect>("SelectPSP_SubstationSelectList", sel); for (int n = 0; n < _plist.Count; n++) { XmlNodeList _nlist = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@id='" + _plist[n].EleID + "']"); if (_nlist.Count < 1) { Services.BaseService.Delete<PSP_SubstationSelect>(_plist[n]); } } } if (dia == DialogResult.Ignore) { string keyid = mng.KeyID; string suid = mng.SUID; PSP_SubstationUserNum n1 = new PSP_SubstationUserNum(); n1.col2 = keyid; IList<PSP_SubstationUserNum> list1 = Services.BaseService.GetList<PSP_SubstationUserNum>("SelectPSP_SubstationNum2", n1); for (int i = 0; i < list1.Count; i++) { if (suid == list1[i].SubStationID) { PSP_SubstationSelect s = new PSP_SubstationSelect(); s.UID = list1[i].SubStationID; s.EleID = list1[i].userID; XmlNodeList nnn1 = tlVectorControl1.SVGDocument.SelectNodes("//* [@id='" + s.EleID + "']"); foreach (XmlNode node1 in nnn1) { tlVectorControl1.SVGDocument.RootElement.RemoveChild(node1); } Services.BaseService.Update("DeletePSP_SubstationSelect", s); } } tlVectorControl1.Refresh(); } break; case "mSubPrint": Hashtable HashTable1 = new Hashtable(); HashTable1.Add("SUID", tlVectorControl1.SVGDocument.SvgdataUid); Services.BaseService.Update("UpdateGlebePropertyAll", HashTable1); break; case "mJQLeadLine": tlVectorControl1.Operation = ToolOperation.Select; frmAddLine aLine = new frmAddLine(); if (aLine.ShowDialog() == DialogResult.OK) { string points = ""; StringBuilder bpts = new StringBuilder(); ArrayList list = aLine.list; LineInfo line = aLine.line; string lineWidth = aLine.LineWidth; //ICollection Ilist = list.Values; //IEnumerator IEnum=Ilist.GetEnumerator(); for (int n = 0; n < list.Count; n++) { //while (IEnum.MoveNext()) //{ string[] str = ((string)list[n]).Split(','); //string[] str = ((string)IEnum.Current).Split(','); string[] JWD1 = str[0].Split(' '); double J1 = Convert.ToDouble(JWD1[0]); Double W1 = Convert.ToDouble(JWD1[1]); Double D1 = Convert.ToDouble(JWD1[2]); string[] JWD2 = str[1].Split(' '); Double J2 = Convert.ToDouble(JWD2[0]); Double W2 = Convert.ToDouble(JWD2[1]); Double D2 = Convert.ToDouble(JWD2[2]); Double JD = J1 + W1 / 60 + D1 / 3600; Double WD = J2 + W2 / 60 + D2 / 3600; IntXY xy = mapview.getXY(JD, WD); if (mapview is MapViewGoogle) bpts.Append(xy.X + " " + xy.Y + ","); else bpts.Append((-xy.X / (double)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (double)tlVectorControl1.ScaleRatio) + ","); //} } if (bpts.Length > 0) points = bpts.ToString(0, bpts.Length - 1); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; n1.SetAttribute("IsLead", "1"); n1.SetAttribute("points", points); n1.SetAttribute("layer", SvgDocument.currentLayer); // n1.SetAttribute("style", styleValue); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); line.UID = Guid.NewGuid().ToString(); line.EleID = n1.GetAttribute("id"); line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<LineInfo>(line); } break; case "mLeadLine": if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("电网规划层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // sgt1.Visible = true; tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.LeadLine; break; case "m_dhx": if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("电网规划层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } // sgt1.Visible = true; str_dhx = "1"; tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.LeadLine; break; case "mAreaPoly": #if(!CITY) if (!getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("城市规划层")) { MessageBox.Show("请选择城市规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } #endif tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.AreaPolygon; break; case "sjsz": frmCS cs = new frmCS(); cs.ShowDialog(); break; case "shjg": GHWPG(); break; case "mFx": SubPrint = false; bool ck = false; ArrayList listlayers = frmlar.GetSelectLayers(); //CheckedListBox.CheckedItemCollection ckcol = frmlar.checkedListBox1.CheckedItems; for (int i = 0; i < listlayers.Count; i++) { Layer _lar = listlayers[i] as Layer; if (_lar.GetAttribute("layerType") == "城市规划层") { ck = true; } } if (!ck) { MessageBox.Show("请打开城市规划层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.InterEnclosure; MapType = "接线图"; break; case "mGhfx": if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl1.Operation = ToolOperation.Enclosure; // SvgDocument.currentLayer = getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID; MapType = "接线图"; //bar2.Visible = false; break; //case "mEdit": // //bar2.Visible = true; // SvgDocument.currentLayer = "layer97052"; // MapType = "接线图"; // break; case "mFzzj": //放置注记 if (!getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) //if (!layer1.Label.Contains("供电区域层")) { MessageBox.Show("请选择电网规划层作为当前图层。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //LayerBox.ComboBoxEx.SelectedIndex = 2; tlVectorControl1.Operation = ToolOperation.Select; MapType = "规划统计"; break; case "mDkwh": //地块维护 frmPropertyClass frmProp = new frmPropertyClass(); frmProp.ShowDialog(); break; case "mDkfl": //地块分类 if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } frmUsePropertySelect frmUseSel = new frmUsePropertySelect(); frmUseSel.InitData(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid); frmUseSel.ShowDialog(); break; case "mGldt": //关联地图 if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } frmFileSelect frmSel = new frmFileSelect(); frmSel.InitData(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid, true); frmSel.ShowDialog(); break; case "mPriQu": SubPrint = true; tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint; break; case "m_djcl": tlVectorControl1.Operation = ToolOperation.Select; str_djcl = "1"; MessageBox.Show("请选择线路进行档距测量。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; case "m_inxljwd": frmInJWD f_in = new frmInJWD(); if (f_in.ShowDialog() == DialogResult.OK) { InputFile(f_in.GetFileName(), f_in.GetCheck()); } break; case "m_inbdzjwd": frmInJWD f_in2 = new frmInJWD(); if (f_in2.ShowDialog() == DialogResult.OK) { InputBDZFile(f_in2.GetFileName(), f_in2.GetCheck()); } break; case "m_outsubjwd": if (MessageBox.Show("确定要导出当前图层所有变电站坐标吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { string str_dy = ""; XmlNodeList nn0 = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@layer='" + SvgDocument.currentLayer + "']"); string lab = tlVectorControl1.SVGDocument.CurrentLayer.Label; Excel.Application ex = new Excel.Application(); Excel.Workbook workBook = ex.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet); //workBook.Worksheets.Add(Type.Missing, workBook.ActiveSheet, 1, Type.Missing); Excel.Worksheet xSheet1 = (Excel.Worksheet)ex.Worksheets[1]; int c = xSheet1.Columns.Count; int r = xSheet1.Rows.Count; ((Excel.Range)xSheet1.Cells[1, 1]).Value2 = "序号"; ((Excel.Range)xSheet1.Cells[1, 2]).Value2 = "变电站名称"; ((Excel.Range)xSheet1.Cells[1, 3]).Value2 = "电压等级"; ((Excel.Range)xSheet1.Cells[1, 4]).Value2 = "经度"; ((Excel.Range)xSheet1.Cells[1, 5]).Value2 = "纬度"; for (int n = 0; n < nn0.Count; n++) { XmlElement _xele = (XmlElement)nn0[n]; string jwd_info = _xele.GetAttribute("jwd-info"); string infoname = _xele.GetAttribute("info-name"); string dyinfo = _xele.GetAttribute("xlink:href"); dyinfo = getDY(dyinfo); if (jwd_info != "") { string[] jwd = jwd_info.Split(",".ToCharArray()); ((Excel.Range)xSheet1.Cells[n + 2, 1]).Value2 = n + 1; ((Excel.Range)xSheet1.Cells[n + 2, 2]).Value2 = infoname; ((Excel.Range)xSheet1.Cells[n + 2, 3]).Value2 = dyinfo; ((Excel.Range)xSheet1.Cells[n + 2, 4]).Value2 = jwd[0].Trim(); ((Excel.Range)xSheet1.Cells[n + 2, 5]).Value2 = jwd[1].Trim(); } else { // LongLat lat = mapview.ParseToLongLat(((Use)_xele).CenterPoint.X, ((Use)_xele).CenterPoint.Y); LongLat lat = mapview.OffSetZero(-(int)(Convert.ToInt32(((Use)_xele).CenterPoint.X) * tlVectorControl1.ScaleRatio), -(int)(Convert.ToInt32(((Use)_xele).CenterPoint.Y) * tlVectorControl1.ScaleRatio)); ((Excel.Range)xSheet1.Cells[n + 2, 1]).Value2 = n + 1; ((Excel.Range)xSheet1.Cells[n + 2, 2]).Value2 = infoname; ((Excel.Range)xSheet1.Cells[n + 2, 3]).Value2 = dyinfo; ((Excel.Range)xSheet1.Cells[n + 2, 4]).Value2 = lat.Longitude; ((Excel.Range)xSheet1.Cells[n + 2, 5]).Value2 = lat.Latitude; } } ex.Visible = true; } break; case "m_outxljwd": tlVectorControl1.Operation = ToolOperation.Select; bool ckright = true; if (MessageBox.Show("确定要导出当前图层所有线路坐标吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { string str_dy = ""; XmlNodeList nn0 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@layer='" + SvgDocument.currentLayer + "']"); string lab = tlVectorControl1.SVGDocument.CurrentLayer.Label; for (int n = 0; n < nn0.Count; n++) { str_dy = ""; XmlElement x = nn0[n] as XmlElement; str_dy = x.GetAttribute("dy-info"); string devid = x.GetAttribute("Deviceid"); if (str_dy == "") { if (devid != "") { PSPDEV dev = Services.BaseService.GetOneByKey<PSPDEV>(devid); if (dev != null) { if (dev.RateVolt != 0) { str_dy = dev.RateVolt.ToString("###"); ckright = true; break; } } } } } if (str_dy == "") { if (MessageBox.Show("选择图层线路不包含电压等级信息,是否继续导出?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { ckright = true; } else { ckright = false; } } if (ckright) { Excel.Application ex = new Excel.Application(); Excel.Workbook workBook = ex.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet); for (int n = 0; n < nn0.Count; n++) { XmlElement _xele = (XmlElement)nn0[n]; workBook.Worksheets.Add(Type.Missing, workBook.ActiveSheet, 1, Type.Missing); Excel.Worksheet xSheet1 = (Excel.Worksheet)ex.Worksheets[n + 1]; int c = xSheet1.Columns.Count; int r = xSheet1.Rows.Count; ((Excel.Range)xSheet1.Cells[1, 1]).Value2 = "杆塔号"; ((Excel.Range)xSheet1.Cells[1, 2]).Value2 = "电压等级"; ((Excel.Range)xSheet1.Cells[1, 3]).Value2 = "经度"; ((Excel.Range)xSheet1.Cells[1, 4]).Value2 = "纬度"; string jwd_info = _xele.GetAttribute("jwd-info"); string gt_info = _xele.GetAttribute("gt-info"); if (jwd_info != "") { string[] gt = gt_info.Split(",".ToCharArray()); string[] jwd = jwd_info.Split(";".ToCharArray()); for (int m = 0; m < jwd.Length; m++) { string[] jw_str = jwd[m].Split(",".ToCharArray()); ((Excel.Range)xSheet1.Cells[m + 2, 1]).Value2 = gt[m]; ((Excel.Range)xSheet1.Cells[m + 2, 2]).Value2 = str_dy; ((Excel.Range)xSheet1.Cells[m + 2, 3]).Value2 = jw_str[0].Trim(); ((Excel.Range)xSheet1.Cells[m + 2, 4]).Value2 = jw_str[1].Trim(); } } else { PointF[] pt = TLMath.getPolygonPoints(_xele); for (int k = 0; k < pt.Length; k++) { LongLat lat = mapview.OffSetZero(-(int)(Convert.ToInt32(pt[k].X) * tlVectorControl1.ScaleRatio), -(int)(Convert.ToInt32(pt[k].Y) * tlVectorControl1.ScaleRatio)); //LongLat lat= mapview.ParseToLongLat(pt[k].X, pt[k].Y); ((Excel.Range)xSheet1.Cells[k + 2, 1]).Value2 = Convert.ToString(k + 1); ((Excel.Range)xSheet1.Cells[k + 2, 2]).Value2 = str_dy; ((Excel.Range)xSheet1.Cells[k + 2, 3]).Value2 = lat.Longitude; ((Excel.Range)xSheet1.Cells[k + 2, 4]).Value2 = lat.Latitude; } } string info_name = _xele.GetAttribute("info-name"); if (info_name != "") { for (int k = 1; k < workBook.Worksheets.Count; k++) { if (((Excel.Worksheet)workBook.Worksheets[k]).Name == info_name) { info_name = info_name + k.ToString(); break; } } xSheet1.Name = info_name; } } Excel.Worksheet xSheett = (Excel.Worksheet)ex.Worksheets[ex.Worksheets.Count]; xSheett.Activate(); xSheett.Delete(); ex.Visible = true; } } break; case "m_unsel": string bdzwhere = " UID not in ("; string xlwhere = " where SUID not in ("; PSPDEV obj = new PSPDEV(); DeviceHelper.pspflag = false; DeviceHelper.Wjghflag = false; string[] deviceType = new string[] { "05", "20" }; XmlNodeList lslist = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@Deviceid!='']"); XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@Deviceid!='']"); //XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use [contains(use,'Sub')]"); for (int x1 = 0; x1 < lslist.Count; x1++) { XmlElement _node = lslist[x1] as XmlElement; xlwhere = xlwhere + "'" + _node.GetAttribute("Deviceid") + "',"; } for (int x2 = 0; x2 < useList.Count; x2++) { XmlElement _node = useList[x2] as XmlElement; bdzwhere = bdzwhere + "'" + _node.GetAttribute("Deviceid") + "',"; } if (bdzwhere.Length > 15) { bdzwhere = bdzwhere.Substring(0, bdzwhere.Length - 1); } if (xlwhere.Length > 15) { xlwhere = xlwhere.Substring(0, xlwhere.Length - 1); } bdzwhere = bdzwhere + ") and "; xlwhere = xlwhere + ") and "; DeviceHelper.bdzwhere = bdzwhere; DeviceHelper.xlwhere = xlwhere; DeviceHelper.SelectDeviceDLG(Itop.Client.MIS.ProgUID, deviceType); DeviceHelper.bdzwhere = ""; DeviceHelper.xlwhere = ""; break; case "ORP": OpenProject orp = new OpenProject(); orp.ProjectID = Itop.Client.MIS.ProgUID; orp.Initdata(false); if (orp.ShowDialog() == DialogResult.OK) { if (orp.FileSUID != null) { ElectricLoadCal elcORP = new ElectricLoadCal(); elcORP.ORP(orp.FileSUID, 100); } } break; case "mReCompute": if (MessageBox.Show("确认要重新计算全图的电量和负荷么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string scale = tlVectorControl1.SVGDocument.getViewScale(); if (scale != "") { Recalculate(Convert.ToDecimal(scale)); } else { Recalculate(1); } MessageBox.Show("重新计算完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "mXLine": tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.XPolyLine; break; case "mYLine": tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.YPolyLine; break; case "mFhbz": //if (MessageBox.Show("是否生成负荷标注?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) //{ // Fhbz(); //} //FrmSet f_set = new FrmSet(); //if (f_set.ShowDialog()==DialogResult.OK) //{ if (XZ_bdz == "") { MessageBox.Show("请选择一个变电站选址方案。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } tlVectorControl1.Operation = ToolOperation.Select; tlVectorControl1.Operation = ToolOperation.InterEnclosure; bdz_xz = "yes"; // str_dy = f_set.Str_dj; // str_num = f_set.Str_num; // str_jj = f_set.Str_jj; //} break; case "mSaveGroup": if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1) { string content = "<svg>"; SvgElementCollection col = tlVectorControl1.SVGDocument.SelectCollection; for (int i = 0; i < col.Count; i++) { SvgElement _e = (SvgElement)col[i]; if (_e.ID != "svg") { content = content + _e.OuterXml; } } RectangleF rect = tlVectorControl1.DrawArea.viewer.SelectedViewRectangle; content = content + "</svg>"; frmSaveGroup fm = new frmSaveGroup(); fm.rect = rect; fm.Content = content; fm.ShowDialog(); } else { MessageBox.Show("请至少选择2个图元。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } break; case "mInsert": frmUseGroup fg = new frmUseGroup(); if (fg.ShowDialog() == DialogResult.OK) { UseGroup u = fg.SelectedUseGroup; if (u != null) { frmXY xy = new frmXY(); if (xy.ShowDialog() == DialogResult.OK) { decimal x = xy.GetX(); decimal y = xy.GetY(); string content = u.Content; XmlDocument doc = new XmlDocument(); doc.LoadXml(u.Content); XmlNodeList list = doc.ChildNodes; XmlNode _node = list[0]; XmlNodeList sonlist = _node.ChildNodes; XmlElement ele = tlVectorControl1.SVGDocument.CreateElement("g"); ele.SetAttribute("layer", SvgDocument.currentLayer); for (int i = 0; i < sonlist.Count; i++) { XmlNode _sonnode = sonlist[i]; //string str = _sonnode.OuterXml; if (_sonnode.Name == "use") { string sid = ((XmlElement)_sonnode).GetAttribute("xlink:href"); XmlNode _snode = symbolSelector.SymbolDoc.SelectSingleNode("//*[@id='" + sid.Substring(1) + "']"); tlVectorControl1.SVGDocument.AddDefsElement((SvgElement)_snode); } ele.AppendChild(_sonnode); string ss = ele.OuterXml; } //RectangleF r=((Group)ele).GetBounds(); string tr = "matrix(1,0,0,1,"; tr = tr + Convert.ToString(x - Convert.ToDecimal(u.X)) + ","; tr = tr + Convert.ToString(y - Convert.ToDecimal(u.Y)) + ")"; ele.SetAttribute("transform", tr); // transform="matrix(1,0,0,1,2558.82,-352.94)" tlVectorControl1.SVGDocument.RootElement.AppendChild(ele); tlVectorControl1.SVGDocument.SelectCollection.Clear(); tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)ele); tlVectorControl1.UnGroup(); // tlVectorControl1.Refresh(); } } } break; case "m_tp": frmImgManager frm = new frmImgManager(); frm.StrName = ""; frm.StrRemark = ""; frm.ShowDialog(); break; case "m_reDraw": string svguid = tlVectorControl1.SVGDocument.SvgdataUid; XmlNodeList nn1 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1']"); LineType lt = new LineType(); IList tpList = Services.BaseService.GetList("SelectLineTypeList", lt); Hashtable dkHs = new Hashtable(); for (int i = 0; i < tpList.Count; i++) { LineType _gle = (LineType)tpList[i]; dkHs.Add(_gle.TypeName, _gle.Color); } bool bo = tlVectorControl1.SVGDocument.Update; tlVectorControl1.SVGDocument.Update = false; for (int j = 0; j < nn1.Count; j++) { XmlElement _node1 = (XmlElement)nn1.Item(j); LineInfo line = new LineInfo(); line.SvgUID = svguid; line.EleID = _node1.GetAttribute("id"); line = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", line); if (line != null) { string t = (string)dkHs[line.Voltage + "kV"]; string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(t))); ItopVector.Core.Func.AttributeFunc.SetAttributeValue(_node1, "stroke", color1); } } tlVectorControl1.SVGDocument.Update = bo; break; case "m_subColor": string svguid1 = tlVectorControl1.SVGDocument.SvgdataUid; XmlNodeList nn2 = tlVectorControl1.SVGDocument.SelectNodes("svg/defs/symbol"); LineType lt1 = new LineType(); IList tpList1 = Services.BaseService.GetList("SelectLineTypeList", lt1); Hashtable dkHs1 = new Hashtable(); for (int i = 0; i < tpList1.Count; i++) { LineType _gle = (LineType)tpList1[i]; dkHs1.Add(_gle.TypeName.ToLower(), _gle.Color); } bool bo1 = tlVectorControl1.SVGDocument.Update; tlVectorControl1.SVGDocument.Update = false; Regex regex = new Regex(@"\d{2,3}(?=kv)"); foreach (Symbol _node1 in nn2) { string subName = _node1.GetAttribute("label").ToLower(); Match match1 = regex.Match(subName); if (match1.Success) { try { string t = (string)dkHs1[match1.Value + "kv"]; //if (match1.Value == "220") //{ // t = t; //} string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(t))); foreach (SvgElement element in _node1.GraphList) { if (element.SvgAttributes.ContainsKey("stroke") && element.SvgAttributes["stroke"].ToString() != "#FFFFFF") { ItopVector.Core.Func.AttributeFunc.SetAttributeValue(element, "stroke", color1); } if (element.SvgAttributes.ContainsKey("fill") && element.SvgAttributes["fill"].ToString() != "#FFFFFF") { ItopVector.Core.Func.AttributeFunc.SetAttributeValue(element, "fill", color1); } if (element.SvgAttributes.ContainsKey("hatch-color") && element.SvgAttributes["hatch-color"].ToString() != "#FFFFFF") { ItopVector.Core.Func.AttributeFunc.SetAttributeValue(element, "hatch-color", color1); } } } catch { } } } tlVectorControl1.SVGDocument.Update = bo1; break; #endregion #region 图层操作 case "layerImport": tlVectorControl1.Operation = ToolOperation.FreePath; layerImport(); break; case "layerExport": layerExport(); break; case "m_kbsText": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[12]); WD = Convert.ToDecimal(r1[13]); PointF fnt = mapview.ParseToPoint(JD, WD); XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t1.SetAttribute("x", Convert.ToString(fnt.X / (float)tlVectorControl1.ScaleRatio + 8)); t1.SetAttribute("y", Convert.ToString(fnt.Y / (float)tlVectorControl1.ScaleRatio)); t1.SetAttribute("layer", SvgDocument.currentLayer); t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t1.SetAttribute("font-famliy", "宋体"); t1.SetAttribute("font-size", "6"); t1.InnerText = r1[2].ToString(); tlVectorControl1.SVGDocument.RootElement.AppendChild(t1); } } tlVectorControl1.Refresh(); } break; case "m_fText": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[9]); WD = Convert.ToDecimal(r1[10]); PointF fnt = mapview.ParseToPoint(JD, WD); XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t1.SetAttribute("x", Convert.ToString(fnt.X / (float)tlVectorControl1.ScaleRatio + 8)); t1.SetAttribute("y", Convert.ToString(fnt.Y / (float)tlVectorControl1.ScaleRatio)); t1.SetAttribute("layer", SvgDocument.currentLayer); t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t1.SetAttribute("font-famliy", "宋体"); t1.SetAttribute("font-size", "6"); t1.InnerText = r1[1].ToString(); tlVectorControl1.SVGDocument.RootElement.AppendChild(t1); } } tlVectorControl1.Refresh(); } break; case "m_inkbs": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[12]); WD = Convert.ToDecimal(r1[13]); //IntXY xy = mapview.getXY(JD, WD); PointF fnt = mapview.ParseToPoint(JD, WD); if (r1[7].ToString() == "运行") { ele = tlVectorControl1.CreateBySymbolID("kbs-111", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } else { ele = tlVectorControl1.CreateBySymbolID("kbs-112", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } ele = tlVectorControl1.AddShape(ele, Point.Empty); ele.SetAttribute("layer", tlVectorControl1.SVGDocument.CurrentLayer.ID); //points = points + (-xy.X / (decimal)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (decimal)tlVectorControl1.ScaleRatio) + ","; PSP_Gra_item item = new PSP_Gra_item(); item.UID = Guid.NewGuid().ToString(); item.EleKeyID = r1[1].ToString(); item.EleName = r1[2].ToString(); item.EleID = ele.ID; item.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; item.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; item.col1 = r1[7].ToString(); item.col2 = r1[3].ToString(); item.col3 = r1[4].ToString(); item.col4 = r1[5].ToString(); item.col5 = r1[6].ToString(); item.col6 = r1[8].ToString(); item.col7 = r1[9].ToString(); item.col8 = "kbs"; Services.BaseService.Create<PSP_Gra_item>(item); } } } break; case "m_infjx": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[9]); WD = Convert.ToDecimal(r1[10]); //IntXY xy = mapview.getXY(JD, WD); PointF fnt = mapview.ParseToPoint(JD, WD); if (r1[4].ToString() == "运行") { ele = tlVectorControl1.CreateBySymbolID("fjx-111", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } else { ele = tlVectorControl1.CreateBySymbolID("fjx-112", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } ele = tlVectorControl1.AddShape(ele, Point.Empty); ele.SetAttribute("layer", tlVectorControl1.SVGDocument.CurrentLayer.ID); //points = points + (-xy.X / (decimal)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (decimal)tlVectorControl1.ScaleRatio) + ","; PSP_Gra_item item = new PSP_Gra_item(); item.UID = Guid.NewGuid().ToString(); item.EleKeyID = r1[2].ToString(); item.EleName = r1[1].ToString(); item.EleID = ele.ID; item.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; item.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; item.col1 = r1[4].ToString(); item.col2 = r1[3].ToString(); item.col3 = r1[5].ToString(); item.col4 = r1[6].ToString(); //item.col5 = r1[6].ToString(); //item.col6 = r1[8].ToString(); //item.col7 = r1[9].ToString(); item.col8 = "fjx"; Services.BaseService.Create<PSP_Gra_item>(item); } } } break; case "m_inbyq": openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Excel文件(*.xls)|*.xls"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { DataSet ds = ImportExcel(openFileDialog1.FileName); DataTable dt1 = ds.Tables[0]; foreach (DataRow r1 in dt1.Rows) { if (r1[0].ToString() != "") { SvgElement ele = null; decimal JD = 0; decimal WD = 0; JD = Convert.ToDecimal(r1[9]); WD = Convert.ToDecimal(r1[10]); //IntXY xy = mapview.getXY(JD, WD); PointF fnt = mapview.ParseToPoint(JD, WD); if (r1[4].ToString() == "运行") { ele = tlVectorControl1.CreateBySymbolID("byq-111", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } else { ele = tlVectorControl1.CreateBySymbolID("byq-112", new PointF((float)(fnt.X / (float)tlVectorControl1.ScaleRatio), (float)(fnt.Y / (float)tlVectorControl1.ScaleRatio))); } ele = tlVectorControl1.AddShape(ele, Point.Empty); ele.SetAttribute("layer", tlVectorControl1.SVGDocument.CurrentLayer.ID); //points = points + (-xy.X / (decimal)tlVectorControl1.ScaleRatio) + " " + (-xy.Y / (decimal)tlVectorControl1.ScaleRatio) + ","; PSP_Gra_item item = new PSP_Gra_item(); item.UID = Guid.NewGuid().ToString(); item.EleKeyID = r1[2].ToString(); item.EleName = r1[1].ToString(); item.EleID = ele.ID; item.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID; item.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; item.col1 = r1[4].ToString(); item.col2 = r1[3].ToString(); item.col3 = r1[5].ToString(); item.col4 = r1[6].ToString(); item.col8 = "byq"; Services.BaseService.Create<PSP_Gra_item>(item); } } } break; #endregion #region 未来联动 case "m_bxz": //tlVectorControl1.GoLocation(); Gh_BXZ(); break; case "m_jp": tlVectorControl1.ClipScreen(true); break; case "m_ld": if (SvgDocument.currentLayer == "") { MessageBox.Show("请选择图层", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (MessageBox.Show("确认要以当前选中年份为准调整以后年度的变电站及线路位置么?", "请确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Linkage(); } break; case "m_fz": if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") { MessageBox.Show("请选择图元", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } CopyEle(); break; case "m_cx": xltProcessor.GoLocation(tlVectorControl1.SVGDocument.SvgdataUid, frmlar.getSelectedLayer()); //XmlNodeList n1111 = tlVectorControl1.SVGDocument.SelectNodes("svg/polygon [@IsArea='1']"); //string a = "1"; break; #endregion #region 网架优化 case "OpenWJ": ff = new frmGProg(); if (ff.ShowDialog() == DialogResult.OK) { Wjghboolflag = true; checkwjghelement(); dotNetBarManager1.Bars["mainmenu"].GetItem("YHoperator").Enabled = true; dotNetBarManager1.Bars["mainmenu"].GetItem("YHresult").Enabled = true; dotNetBarManager1.Bars["mainmenu"].GetItem("ZTBut").Enabled = true; dotNetBarManager1.Bars["mainmenu"].GetItem("JQBut").Enabled = false; dotNetBarManager1.Bars["mainmenu"].GetItem("ZQBut").Enabled = false; dotNetBarManager1.Bars["mainmenu"].GetItem("YQBut").Enabled = false; } else { Wjghboolflag = false; } break; case "YHoperator": break; case "ghwj": GHWPG(); break; case "ZTBut": dotNetBarManager1.Bars["mainmenu"].GetItem("ZTBut").Enabled = false; dotNetBarManager1.Bars["mainmenu"].GetItem("JQBut").Enabled = true; ElectricWjgh wjgh = new ElectricWjgh(); wjgh.initdat(ff.Key); //恢复数据的原来面貌 WaitDialogForm wait = null; try { wait = new WaitDialogForm("", "正在处理数据, 请稍候..."); wjgh.jianxiancheck(ff.Key, 1, 100); wait.Close(); MessageBox.Show("整体数据优化成功。"); string con = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + ff.Key + "'and type='线路')"; IList list1 = Services.BaseService.GetList("SelectPSPDEVByCondition", con); foreach (PSPDEV dev in list1) { PSP_GprogElevice pg = new PSP_GprogElevice(); pg.GprogUID = ff.Key; pg.DeviceSUID = dev.SUID; //先找到再修改 pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg); if (pg != null) { if (dev.LineStatus == "运行") { pg.ZTstatus = "运行"; pg.JQstatus = "运行"; pg.ZQstatus = "运行"; pg.YQstatus = "运行"; Services.BaseService.Update<PSP_GprogElevice>(pg); } else if (dev.LineStatus == "等待") { pg.ZTstatus = "等待"; pg.JQstatus = "等待"; pg.ZQstatus = "等待"; pg.YQstatus = "等待"; Services.BaseService.Update<PSP_GprogElevice>(pg); } else if (dev.LineStatus == "待选") { pg.ZTstatus = "待选"; Services.BaseService.Update<PSP_GprogElevice>(pg); } } } wjghmapview(1); } catch (Exception exc) { MessageBox.Show("数据存在问题,请检查后再继续!"); wait.Close(); return; } break; case "JQBut": dotNetBarManager1.Bars["mainmenu"].GetItem("JQBut").Enabled = false; dotNetBarManager1.Bars["mainmenu"].GetItem("ZQBut").Enabled = true; wjgh = new ElectricWjgh(); wjgh.JDlinecheck(ff.Key, 2); JorJform selectmethod = new JorJform(); selectmethod.Text = "近期网架优化方法"; if (selectmethod.ShowDialog() == DialogResult.OK) { wait = new WaitDialogForm("", "正在处理数据, 请稍候..."); if (selectmethod.Mathindex == 0) { wjgh.jianxiancheck(ff.Key, 2, 100); MessageBox.Show("近期数据减线优化成功。"); } else if (selectmethod.Mathindex == 1) { wjgh.addlinecheck(ff.Key, 2, 100); wjgh.addrightcheck(ff.Key, 2, 100); for (int i = 0; i < wjgh.ercilinedengdai.Count; i++) { wjgh.ercilinedengdai[i].LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(wjgh.ercilinedengdai[i]); } for (int i = 0; i < wjgh.lineyiyou.Count; i++) { wjgh.lineyiyou[i].LineStatus = "待选"; Services.BaseService.Update<PSPDEV>(wjgh.lineyiyou[i]); } MessageBox.Show("近期数据加线成功。"); } wait.Close(); //此处写项目jq变化状况 string conjq = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + ff.Key + "'and type='线路'and ZTstatus in('待选'))"; IList list1jq = Services.BaseService.GetList("SelectPSPDEVByCondition", conjq); foreach (PSPDEV dev in list1jq) { PSP_GprogElevice pg = new PSP_GprogElevice(); pg.GprogUID = ff.Key; pg.DeviceSUID = dev.SUID; //先找到再修改 pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg); if (pg != null) { if (dev.LineStatus == "等待") { pg.JQstatus = "待选"; Services.BaseService.Update<PSP_GprogElevice>(pg); //dev.LineStatus = "待选"; //Services.BaseService.Update<PSPDEV>(dev); } else if (dev.LineStatus == "待选") { bool flag = false; foreach (eleclass el in wjgh.JDlinecol) { if (dev.SUID == el.suid) { flag = true; dev.LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(dev); } } if (flag) { pg.JQstatus = "投放"; pg.ZQstatus = "运行"; pg.YQstatus = "运行"; } else { pg.JQstatus = "待选"; } Services.BaseService.Update<PSP_GprogElevice>(pg); } } } wjghmapview(2); } break; case "ZQBut": dotNetBarManager1.Bars["mainmenu"].GetItem("ZQBut").Enabled = false; dotNetBarManager1.Bars["mainmenu"].GetItem("YQBut").Enabled = true; wjgh = new ElectricWjgh(); wjgh.JDlinecheck(ff.Key, 3); selectmethod = new JorJform(); selectmethod.Text = "中期网架优化方法"; if (selectmethod.ShowDialog() == DialogResult.OK) { wjghmapview(5); wait = new WaitDialogForm("", "正在处理数据, 请稍候..."); if (selectmethod.Mathindex == 0) { wjgh.jianxiancheck(ff.Key, 3, 100); MessageBox.Show("中期数据减线优化成功。"); } else if (selectmethod.Mathindex == 1) { wjgh.addlinecheck(ff.Key, 3, 100); wjgh.addrightcheck(ff.Key, 3, 100); for (int i = 0; i < wjgh.ercilinedengdai.Count; i++) { wjgh.ercilinedengdai[i].LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(wjgh.ercilinedengdai[i]); } for (int i = 0; i < wjgh.lineyiyou.Count; i++) { wjgh.lineyiyou[i].LineStatus = "待选"; Services.BaseService.Update<PSPDEV>(wjgh.lineyiyou[i]); } MessageBox.Show("中期数据加线成功。"); } wait.Close(); //此处写项目jq变化状况 string conzq = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + ff.Key + "'and type='线路'and JQstatus in('待选'))"; IList list1zq = Services.BaseService.GetList("SelectPSPDEVByCondition", conzq); foreach (PSPDEV dev in list1zq) { PSP_GprogElevice pg = new PSP_GprogElevice(); pg.GprogUID = ff.Key; pg.DeviceSUID = dev.SUID; //先找到再修改 pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg); if (pg != null) { if (dev.LineStatus == "等待") { pg.ZQstatus = "待选"; Services.BaseService.Update<PSP_GprogElevice>(pg); //dev.LineStatus = "待选"; //Services.BaseService.Update<PSPDEV>(dev); } else if (dev.LineStatus == "待选") { bool flag = false; foreach (eleclass el in wjgh.JDlinecol) { if (el.suid == dev.SUID) { flag = true; dev.LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(dev); } } if (flag) { pg.ZQstatus = "投放"; pg.YQstatus = "运行"; } else pg.ZQstatus = "待选"; Services.BaseService.Update<PSP_GprogElevice>(pg); } } } wjghmapview(3); } break; case "YQBut": dotNetBarManager1.Bars["mainmenu"].GetItem("YQBut").Enabled = false; dotNetBarManager1.Bars["mainmenu"].GetItem("ZTBut").Enabled = true; wjgh = new ElectricWjgh(); wjgh.JDlinecheck(ff.Key, 4); wjghmapview(6); selectmethod = new JorJform(); selectmethod.Text = "远期网架优化方法"; if (selectmethod.ShowDialog() == DialogResult.OK) { wait = new WaitDialogForm("", "正在处理数据, 请稍候..."); if (selectmethod.Mathindex == 0) { wjgh.jianxiancheck(ff.Key, 4, 100); MessageBox.Show("远期数据减线优化成功。"); } else if (selectmethod.Mathindex == 1) { wjgh.addlinecheck(ff.Key, 4, 100); wjgh.addrightcheck(ff.Key, 4, 100); for (int i = 0; i < wjgh.ercilinedengdai.Count; i++) { wjgh.ercilinedengdai[i].LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(wjgh.ercilinedengdai[i]); } for (int i = 0; i < wjgh.lineyiyou.Count; i++) { wjgh.lineyiyou[i].LineStatus = "待选"; Services.BaseService.Update<PSPDEV>(wjgh.lineyiyou[i]); } MessageBox.Show("远期数据加线成功。"); } wait.Close(); //此处写项目jq变化状况 string conyq = "WHERE Type='05' AND SUID in (select DeviceSUID from PSP_GprogElevice where GprogUID='" + ff.Key + "'and type='线路'and ZQstatus in('待选'))"; IList list1yq = Services.BaseService.GetList("SelectPSPDEVByCondition", conyq); // wjgh = new ElectricWjgh(); foreach (PSPDEV dev in list1yq) { PSP_GprogElevice pg = new PSP_GprogElevice(); pg.GprogUID = ff.Key; pg.DeviceSUID = dev.SUID; //先找到再修改 pg = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", pg); if (pg != null) { if (dev.LineStatus == "等待") { bool flag = false; foreach (eleclass el in wjgh.JDlinecol) { if (el.suid == dev.SUID) { flag = true; dev.LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(dev); } } if (flag) pg.YQstatus = "投放"; else pg.YQstatus = "待选"; Services.BaseService.Update<PSP_GprogElevice>(pg); //pg.YQstatus = "待选"; //Services.BaseService.Update<PSP_GprogElevice>(pg); } else if (dev.LineStatus == "待选") { bool flag = false; foreach (eleclass el in wjgh.JDlinecol) { if (el.suid == dev.SUID) { flag = true; dev.LineStatus = "运行"; Services.BaseService.Update<PSPDEV>(dev); } } if (flag) pg.YQstatus = "投放"; else pg.YQstatus = "待选"; Services.BaseService.Update<PSP_GprogElevice>(pg); } } } wjghmapview(4); } break; case "YHresult": wjgh = new ElectricWjgh(); frmGProList p1 = new frmGProList(); p1.Show(); p1.LoadData(wjgh.LoadData(ff.Key)); break; #endregion #region 线路优选 case "bt_edit": break; case "bt_start": if (linekey == "") { MessageBox.Show("请选择线路所属的方案。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } sel_sym = "bt_start"; tlVectorControl1.Operation = ToolOperation.Symbol; break; case "bt_end": if (sel_start_point == "") { MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } sel_sym = "bt_end"; tlVectorControl1.Operation = ToolOperation.Symbol; break; case "bt_must": if (sel_start_point == "") { MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } sel_sym = "bt_must"; tlVectorControl1.Operation = ToolOperation.Symbol; break; case "bt_point": if (sel_start_point == "") { MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } sel_sym = "bt_point"; tlVectorControl1.Operation = ToolOperation.Symbol; break; case "bt_make": if (sel_start_point == "") { MessageBox.Show("请选择线路起点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } frmInputDialog frm_input = new frmInputDialog(); if (frm_input.ShowDialog() == DialogResult.OK) { SortedList orderlist = new SortedList(); XmlNodeList XLlist = tlVectorControl1.SVGDocument.SelectNodes("//*[@start_point=\"" + sel_start_point + "\"]"); try { for (int i = 0; i < XLlist.Count; i++) { XmlElement node = (XmlElement)XLlist[i]; orderlist.Add(Convert.ToInt32(node.GetAttribute("order")), node); } } catch (Exception ex1) { MessageBox.Show("存在相同的节点顺序号,请修改。\n\r" + ex1.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } PointF[] _points = new PointF[XLlist.Count]; for (int i = 0; i < orderlist.Count; i++) { PointF[] f1 = new PointF[1] { new PointF(((Use)orderlist.GetByIndex(i)).X + 6, ((Use)orderlist.GetByIndex(i)).Y + 6) }; ((Use)orderlist.GetByIndex(i)).Transform.Matrix.TransformPoints(f1); _points[i] = f1[0]; } string str_points = ""; for (int i = 0; i < _points.Length; i++) { str_points = str_points + _points[i].X + " " + _points[i].Y + ","; } if (str_points.Length > 1) { str_points = str_points.Substring(0, str_points.Length - 1); } XmlElement _templine = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; _templine.SetAttribute("IsLead", "1"); _templine.SetAttribute("points", str_points); _templine.SetAttribute("layer", SvgDocument.currentLayer); Random dom = new Random(); int int_d = dom.Next(99999); string styleValue = "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(int_d)); _templine.SetAttribute("style", styleValue); XmlNode tt_node = tlVectorControl1.SVGDocument.RootElement.AppendChild(_templine); LineInfo gh_line = new LineInfo(); gh_line.UID = Guid.NewGuid().ToString(); gh_line.EleID = _templine.GetAttribute("id"); gh_line.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<LineInfo>(gh_line); tlVectorControl1.Refresh(); if (MessageBox.Show("是否删除该线路的参考点?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { tlVectorControl1.SVGDocument.SelectCollection.Clear(); for (int i = 0; i < XLlist.Count; i++) { if (((SvgElement)XLlist[i]).GetAttribute("xlink:href").Contains("XL_GT_4") || ((SvgElement)XLlist[i]).GetAttribute("xlink:href").Contains("XL_GT_3")) { tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)XLlist[i]); } } tlVectorControl1.Delete(); } string str = ""; LineList1 line1 = new LineList1(); line1.UID = Guid.NewGuid().ToString(); //line1.LineEleID = tlVectorControl1.SVGDocument.CurrentElement.ID; line1.PointNum = ((Polyline)(tt_node)).Points.Length - 2; line1.Coefficient = (decimal)(1.02); line1.Length = TLMath.getPolylineLength(((Polyline)(tt_node)), Convert.ToDecimal(tlVectorControl1.ScaleRatio)); line1.Length2 = TLMath.getPolylineLength(((Polyline)(tt_node)), Convert.ToDecimal(tlVectorControl1.ScaleRatio)) * Convert.ToDecimal(1.02); PointF[] pnt = ((Polyline)(tt_node)).Points; if (pnt.Length < 3) return; for (int i = 0; i < pnt.Length; i++) { double ang = TLMath.getLineAngle(pnt[i], pnt[i + 1], pnt[i + 2]); if (ang * 57.3 > 60) { MessageBox.Show("线路转角不能大于60度。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tlVectorControl1.Delete(); return; } str = str + "第" + (i + 1) + "转角:" + Convert.ToDouble(ang * 57.3).ToString("##.##") + "度。\r\n"; if (i == pnt.Length - 3) { break; } } line1.TurnAngle = str; line1.col1 = linekey; line1.LineName = frm_input.InputStr; line1.LineEleID = ((SvgElement)tt_node).ID; Services.BaseService.Create<LineList1>(line1); sel_start_point = ""; tlVectorControl1.Operation = ToolOperation.Select; } break; case "Niula": Wjghboolflag = false; OpenProject op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { Psptypeform pt = new Psptypeform(); if (pt.ShowDialog() == DialogResult.OK) { frnReport wFrom = new frnReport(); wFrom.Owner = this; wFrom.Show(); wFrom.Text = this.Text + "—牛拉法潮流计算"; wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString(); ElectricLoadCal elc = new ElectricLoadCal(); elc.LFC(op.FileSUID, 1, 100, wFrom); ShowResult(0, op.FileSUID, op.FileName, pt.PspOuttype, wFrom); } } } break; case "pq": Wjghboolflag = false; op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { Psptypeform pt = new Psptypeform(); if (pt.ShowDialog() == DialogResult.OK) { frnReport wFrom = new frnReport(); wFrom.Owner = this; wFrom.Show(); wFrom.Text = this.Text + "—PQ法潮流计算"; wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString(); ElectricLoadCal elc = new ElectricLoadCal(); ElectricLoadCal elcPQ = new ElectricLoadCal(); elcPQ.LFC(op.FileSUID, 2, 100, wFrom); // elcPQ.LFCER(op.FileSUID, 2, 100); ShowResult(1, op.FileSUID, op.FileName, pt.PspOuttype, wFrom); } } } break; case "GausSeidel": Wjghboolflag = false; op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { Psptypeform pt = new Psptypeform(); if (pt.ShowDialog() == DialogResult.OK) { frnReport wFrom = new frnReport(); wFrom.Owner = this; wFrom.Show(); wFrom.Text = this.Text + "—高斯赛德尔迭代法潮流计算"; wFrom.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString(); ElectricLoadCal elc = new ElectricLoadCal(); ElectricLoadCal elcGS = new ElectricLoadCal(); elcGS.LFC(op.FileSUID, 3, 100, wFrom); ShowResult(2, op.FileSUID, op.FileName, pt.PspOuttype, wFrom); } } } break; case "N_RZYz": Wjghboolflag = false; op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { Psptypeform pt = new Psptypeform(); if (pt.ShowDialog() == DialogResult.OK) { frnReport wFromZYZ = new frnReport(); wFromZYZ.Owner = this; wFromZYZ.Show(); wFromZYZ.Text = this.Text + "—最有乘子法潮流计算"; wFromZYZ.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString(); ElectricLoadCal elcN_RZYz = new ElectricLoadCal(); elcN_RZYz.LFC(op.FileSUID, 4, 100, wFromZYZ); ShowResult(3, op.FileSUID, op.FileName, pt.PspOuttype, wFromZYZ); } } } break; case "NLnFH": Wjghboolflag = false; op = new OpenProject(); op.ProjectID = Itop.Client.MIS.ProgUID; op.Initdata(false); if (op.ShowDialog() == DialogResult.OK) { if (op.FileSUID != null) { Psptypeform pt = new Psptypeform(); if (pt.ShowDialog() == DialogResult.OK) { frnReport wFromZYZ = new frnReport(); wFromZYZ.Owner = this; wFromZYZ.Show(); wFromZYZ.Text = this.Text + "—最有乘子法潮流计算"; wFromZYZ.ShowText += "正在收集信息\t" + System.DateTime.Now.ToString(); ElectricLoadCal elcN_RZYz = new ElectricLoadCal(); elcN_RZYz.LFCS(op.FileSUID, 4, 100); ShowResult(3, op.FileSUID, op.FileName, pt.PspOuttype, wFromZYZ); } } } break; #endregion } } }
public void Partshort(string projectSUID, string projectid, int dulutype, double ratecaplity, List<PSPDEV> list1,frnReport wFrom) { int cishu = 0; //��¼�ڶ��ٴγ����ڴ����� try { wFrom.ShowText += "\r\n��ʼ����·��������\t" + System.DateTime.Now.ToString(); if (Compuflag == 1) { ElectricLoadCal elcc = new ElectricLoadCal(); elcc.LFCS(projectSUID, 1, (float)ratecaplity); if (!CheckDLL(projectSUID, projectid, ratecaplity)) { return; } } else { if (!CheckDL(projectSUID, projectid, ratecaplity)) { return; } } //if (!CheckDL(projectSUID, projectid, ratecaplity)) //{ // return; //} System.Windows.Forms.Clipboard.Clear(); Dictionary<int, double> nodeshorti = new Dictionary<int, double>(); //��¼ĸ����û�н��й���· KeyValuePair<int, double> maxshorti = new KeyValuePair<int, double>(); //ȡ����·������·���� string con = null; PSPDEV pspDev = new PSPDEV(); //IList list1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); PSPDEV psp = new PSPDEV(); string data = System.DateTime.Now.ToString("d"); string time = System.DateTime.Now.ToString("T"); string duanResult = null; duanResult += "��·�������" + "\r\n" + "\r\n"; duanResult += "��·��ҵ�ţ�1" + "\r\n"; duanResult += "��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n"; duanResult += "��λ��kA" + "\r\n"; string dianYaResult = null; dianYaResult += "ĸ�ߵ�ѹ���" + "\r\n" + "\r\n"; dianYaResult += "��·��ҵ�ţ�1" + "\r\n"; dianYaResult += "��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n"; dianYaResult += "��λ����ֵ( p.u. ) �Ƕ�(deg.)" + "\r\n"; string dianLiuResult = null; dianLiuResult += "֧·�������" + "\r\n" + "\r\n"; dianLiuResult += "��·��ҵ�ţ�1" + "\r\n"; dianLiuResult += "��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n"; dianLiuResult += "��λ����ֵ( p.u. ) �Ƕ�(deg.)" + "\r\n"; int intshorti = 0; //��һ�м�¼��ΪҪ����·����������˵�� bool shortiflag = false; int muxiannum = 0; //��¼һ��ĸ�߶�·�� �ж��ٸ���¼ĸ�ߵ�ѹ int linenum = 0; //��¼һ��ĸ�߶�· �ж��ٸ���·���� shortbuscir shortCutCal = new shortbuscir(Compuflag); for (int i = 0; i < list1.Count; i++) { cishu++; pspDev = list1[i] as PSPDEV; bool flag = false; string dlr = null; con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='05'AND PSPDEV.KSwitchStatus = '0'AND (PSPDEV.IName='" + pspDev.Name + "'OR PSPDEV.JName='" + pspDev.Name + "')order by PSPDEV.number"; IList list2 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); for (int j = 0; j < list2.Count; j++) { psp = list2[j] as PSPDEV; con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'"; IList listiswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'"; IList listjswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); PSPDEV pspiswitch = (PSPDEV)listiswitch[0]; PSPDEV pspjswitch = (PSPDEV)listjswitch[0]; if (pspDev.Number == psp.FirstNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0") { flag = true; dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0 " + " " + dulutype; } if (pspDev.Number == psp.LastNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0") { flag = true; dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "1 " + " " + dulutype; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt"); } if (flag) { break; //������ѭ�� ����ĸ�ߵ�����һ��ĸ�߶�· } if (!flag) continue; //д������� } //�����һ����·��û�������������н��� if (!flag) { con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='02'AND PSPDEV.KSwitchStatus = '0'AND(PSPDEV.IName='" + pspDev.Name + "'OR PSPDEV.JName='" + pspDev.Name + "') order by PSPDEV.number"; IList list3 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); for (int j = 0; j < list3.Count; j++) { dlr = null; psp = list3[j] as PSPDEV; //PSPDEV devFirst = new PSPDEV(); //con = " WHERE Name='" + psp.IName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'"; //devFirst = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con); //PSPDEV devLast = new PSPDEV(); //con = " WHERE Name='" + psp.JName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'"; //devLast = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con); con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'"; IList listiswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'"; IList listjswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); PSPDEV pspiswitch = (PSPDEV)listiswitch[0]; PSPDEV pspjswitch = (PSPDEV)listjswitch[0]; if (pspDev.Number == psp.FirstNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0") { flag = true; dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0" + " " + dulutype; } if (pspDev.Number == psp.LastNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0") { flag = true; dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "1" + " " + dulutype; } if (flag) { break; //������ѭ�� ����ĸ�ߵ�����һ��ĸ�߶�· } if (!flag) continue; //д������� } } if (!flag) { con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='03'AND PSPDEV.KSwitchStatus = '0'AND(PSPDEV.IName='" + pspDev.Name + "'OR PSPDEV.JName='" + pspDev.Name + "'OR PSPDEV.KName='" + pspDev.Name + "') order by PSPDEV.number"; IList list4 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); for (int j = 0; j < list4.Count; j++) { dlr = null; psp = list4[j] as PSPDEV; //PSPDEV devINode = new PSPDEV(); //con = " WHERE Name='" + psp.IName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'"; //devINode = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con); //PSPDEV devJNode = new PSPDEV(); //con = " WHERE Name='" + psp.JName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'"; //devJNode = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con); //PSPDEV devKNode = new PSPDEV(); //con = " WHERE Name='" + psp.KName + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'"; //devKNode = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con); con = " WHERE Name='" + psp.ISwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'"; IList listiswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); con = " WHERE Name='" + psp.JSwitch + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'"; IList listjswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); con = " WHERE Name='" + psp.HuganLine1 + "' AND ProjectID = '" + projectid + "'" + "AND Type='07'"; IList listkswitch = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); PSPDEV pspiswitch = (PSPDEV)listiswitch[0]; PSPDEV pspjswitch = (PSPDEV)listjswitch[0]; PSPDEV pspkswitch = (PSPDEV)listkswitch[0]; if (pspDev.Number == psp.FirstNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0") { flag = true; dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0" + " " + dulutype; } if (pspDev.Number == psp.LastNode && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0") { flag = true; dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "1" + " " + dulutype; } if (pspDev.Number == psp.Flag && pspiswitch.KSwitchStatus == "0" && pspjswitch.KSwitchStatus == "0" && pspkswitch.KSwitchStatus == "0") { flag = true; dlr = "0" + " " + psp.FirstNode + " " + psp.Flag + " " + psp.Number + " " + "1" + " " + dulutype; } if (flag) { break; //������ѭ�� ����ĸ�ߵ�����һ��ĸ�߶�· } if (!flag) continue; //д������� } } if (flag) { //FileStream VK = new FileStream(, FileMode.OpenOrCreate); StreamWriter str11 = new StreamWriter((System.Windows.Forms.Application.StartupPath + "\\fault.txt"),false); str11.Write(dlr); str11.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"); } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"); } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"); } wFrom.ShowText += "\r\n��ʼ���ж�·����\t" + System.DateTime.Now.ToString(); //shortcir shortCutCal = new shortcir(); shortCutCal.Show_shortcir(Compuflag, OutType, 1); GC.Collect(); //bool matrixflag=true; //�����ж��Ƿ��ɾ����������Ƿ��������� string matrixstr = null; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt")) { matrixstr = "�����ɾ���"; // matrixflag = false; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt")) { // matrixflag = false; matrixstr += "�����ɾ���"; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt")) { //matrixflag = false; matrixstr += "�����ɾ���"; } if (matrixstr != null) { wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString(); System.Windows.Forms.MessageBox.Show(matrixstr + "�����������������������ٽ��м��㣡", "��ʾ", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt")) { } else { wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString(); return; } wFrom.ShowText += "\r\n��ʼ�����·������\t" + System.DateTime.Now.ToString(); 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[] { ' ' }; intshorti = 0; while ((strLineGU = readLineGU.ReadLine()) != null) { arrayGU = strLineGU.Split(charSplitGU); string[] shorti = new string[4]; shorti.Initialize(); int m = 0; foreach (string str in arrayGU) { if (str != "") { shorti[m++] = str.ToString(); } } if (intshorti == 0) { if (!shortiflag) { duanResult += shorti[0] + "," + shorti[1] + "," + shorti[3] + "\r\n"; shortiflag = true; } } else duanResult += shorti[0] + "," + shorti[1] + "," + Convert.ToDouble(shorti[3]) * ratecaplity / (Math.Sqrt(3) * pspDev.ReferenceVolt) + "\r\n"; intshorti++; } readLineGU.Close(); if (OutType == 0) { //**��ȡ�����ѹ��ֵ if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt")) { } else { wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString(); 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(); int j = 0; muxiannum = 0; while (strLineDY != null) { arrayDY = strLineDY.Split(charSplitDY); int m = 0; string[] dev = new string[14]; dev.Initialize(); foreach (string str in arrayDY) { if (str != "") { dev[m++] = str; } } if (j == 0) { dianYaResult += "\r\n" + "����ĸ�ߣ�" + pspDev.Name + "\r\n"; 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"; } else { bool dianyaflag = true; //�жϴ�ĸ���Ƕ�·��ĸ����һ���ĸ�� PSPDEV CR = new PSPDEV(); if (dev[1] != "du") { con = " WHERE Name='" + dev[1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'"; CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con); if (CR == null) { dianyaflag = false; } } //else //{ // dianyaflag = false; // CR.Name = duanluname; // CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByNameANDSVG", CR); //} if (dianyaflag) dianYaResult += dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[2]) * CR.ReferenceVolt + "," + dev[3] + "," + Convert.ToDouble(dev[4]) * CR.ReferenceVolt + "," + dev[5] + "," + Convert.ToDouble(dev[6]) * CR.ReferenceVolt + "," + dev[7] + "," + Convert.ToDouble(dev[8]) * CR.ReferenceVolt + "," + dev[9] + "," + Convert.ToDouble(dev[10]) * CR.ReferenceVolt + "," + dev[11] + "," + Convert.ToDouble(dev[12]) * CR.ReferenceVolt + "," + dev[13] + "\r\n"; //else // dianYaResult += dev[0] + "," + duanluname + "�϶�·��" + "," + Convert.ToDouble(dev[2]) * CR.ReferenceVolt + "," + dev[3] + "," + Convert.ToDouble(dev[4]) * CR.ReferenceVolt + "," + dev[5] + "," + Convert.ToDouble(dev[6]) * CR.ReferenceVolt + "," + dev[7] + "," + Convert.ToDouble(dev[8]) * CR.ReferenceVolt + "," + // dev[9] + "," + Convert.ToDouble(dev[10]) * CR.ReferenceVolt + "," + dev[11] + Convert.ToDouble(dev[12]) * CR.ReferenceVolt + "," + dev[13] + "\r\n"; } strLineDY = readLineDY.ReadLine(); muxiannum++; j++; } readLineDY.Close(); //**��ȡ���������ֵ if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt")) { } else { wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString(); 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(); j = 0; linenum = 0; while (strLineDL != null) { arrayDL = strLineDL.Split(charSplitDL); int m = 0; string[] dev = new string[15]; dev.Initialize(); foreach (string str in arrayDL) { if (str != "") { dev[m++] = str; } } if (j == 0) { dianLiuResult += "\r\n" + "����ĸ�ߣ�" + pspDev.Name + "\r\n"; 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"; } else { //��Ϊ����·�������ʱ����һ����·�ĵ��������������������·�ĵ������нӵص������͵翹���ĵ��������ֻ��������������� PSPDEV CR = new PSPDEV(); if (dev[0] != "du") { con = " WHERE Name='" + dev[0] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'"; } else con = " WHERE Name='" + dev[1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'"; CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con); dianLiuResult += dev[0] + "," + dev[1] + "," + dev[2] + "," + Convert.ToDouble(dev[3]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[4] + "," + Convert.ToDouble(dev[5]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[6] + "," + Convert.ToDouble(dev[7]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[8] + "," + Convert.ToDouble(dev[9]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[10] + "," + Convert.ToDouble(dev[11]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[12] + "," + Convert.ToDouble(dev[13]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[14] + "\r\n"; } strLineDL = readLineDL.ReadLine(); j++; linenum++; } readLineDL.Close(); } } } wFrom.ShowText += "\r\n��ʼ���ɱ���\t" + System.DateTime.Now.ToString(); //д�뱨���� 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.Default); 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.Default); 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.Default); strDL.Write(dianLiuResult); strDL.Close(); PSP_ELCPROJECT psproject = new PSP_ELCPROJECT(); psproject.ID = projectSUID; psproject = (PSP_ELCPROJECT)UCDeviceBase.DataService.GetObject("SelectPSP_ELCPROJECTByKey", psproject); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.xls")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.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.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[6, 1], xSheet.Cells[6, 3]).Interior.ColorIndex = 45; xSheet.get_Range(xSheet.Cells[7, 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; if (OutType == 0) { for (int m = 0; m < cishu; m++) { newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 8, 1], newWorksheet.Cells[m * (muxiannum + 2) + 8, 14]).Interior.ColorIndex = 45; newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 9, 1], newWorksheet.Cells[m * (muxiannum + 2) + 8 + muxiannum - 1, 1]).Interior.ColorIndex = 6; newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 9, 3], newWorksheet.Cells[m * (muxiannum + 2) + 8 + muxiannum - 1, 13]).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; if (OutType == 0) { for (int m = 0; m < cishu; m++) { newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 8, 1], newWorkSheet1.Cells[m * (linenum + 2) + 8, 15]).Interior.ColorIndex = 45; newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 9, 1], newWorkSheet1.Cells[m * (linenum + 2) + 8 + linenum - 1, 1]).Interior.ColorIndex = 6; newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 9, 2], newWorkSheet1.Cells[m * (linenum + 2) + 8 + linenum - 1, 2]).Interior.ColorIndex = 6; newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 9, 3], newWorkSheet1.Cells[m * (linenum + 2) + 8 + linenum - 1, 3]).Interior.ColorIndex = 6; newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum + 2) + 9, 4], newWorkSheet1.Cells[m * (linenum + 2) + 8 + linenum - 1, 14]).NumberFormat = "0.0000_ "; } } xSheet.Rows.AutoFit(); xSheet.Columns.AutoFit(); newWorksheet.Rows.AutoFit(); newWorksheet.Columns.AutoFit(); newWorkSheet1.Rows.AutoFit(); newWorkSheet1.Columns.AutoFit(); newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.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(); wFrom.ShowText += "\r\n��·�������\t" + System.DateTime.Now.ToString(); } catch (System.Exception ex) { wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString(); MessageBox.Show("���ݴ���������������ȫ���ٲ���", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } }
public void AllShortWJ(string projectSUID, string projectid, int dulutype, double ratecaplity, WaitDialogForm wf) { try { OutType = 1; if (Compuflag == 1) { ElectricLoadCal elcc = new ElectricLoadCal(); elcc.LFCS(projectSUID, 1, (float)ratecaplity); if (!CheckDLL(projectSUID, projectid, ratecaplity)) { return; } } else { if (!CheckDL(projectSUID, projectid, ratecaplity)) { return; } } System.Windows.Forms.Clipboard.Clear(); Dictionary<int, double> nodeshorti = new Dictionary<int, double>(); //��¼ĸ����û�н��й���· KeyValuePair<int, double> maxshorti = new KeyValuePair<int, double>(); //ȡ����·������·���� string con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number"; PSPDEV pspDev = new PSPDEV(); IList list1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type in ('05','03','02') AND PSPDEV.KSwitchStatus = '0'order by PSPDEV.number"; IList list2 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); PSPDEV psp = new PSPDEV(); psp = list2[0] as PSPDEV; string data = System.DateTime.Now.ToString("d"); string time = System.DateTime.Now.ToString("T"); StringBuilder duanResult = new StringBuilder(); duanResult.Append("��·�������" + "\r\n" + "\r\n"); duanResult.Append("��·��ҵ�ţ�1" + "\r\n"); duanResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n"); duanResult.Append("��λ��kA" + "\r\n"); StringBuilder dianYaResult = new StringBuilder(); dianYaResult.Append("ĸ�ߵ�ѹ���" + "\r\n" + "\r\n"); dianYaResult.Append("��·��ҵ�ţ�1" + "\r\n"); dianYaResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n"); dianYaResult.Append("��λ����ֵ( p.u. ) �Ƕ�(deg.)" + "\r\n"); StringBuilder dianLiuResult = new StringBuilder(); dianLiuResult.Append("֧·�������" + "\r\n" + "\r\n"); dianLiuResult.Append("��·��ҵ�ţ�1" + "\r\n"); dianLiuResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n"); dianLiuResult.Append("��λ����ֵ( p.u. ) �Ƕ�(deg.)" + "\r\n"); int intshorti = 0; //��һ�м�¼��ΪҪ����·����������˵�� bool shortiflag = false; int muxiannum = 0; //��¼һ��ĸ�߶�·�� �ж��ٸ���¼ĸ�ߵ�ѹ int linenum = 0; //��¼һ��ĸ�߶�· �ж��ٸ���·���� shortbuscir shortCutCal = new shortbuscir(Compuflag); string dlr = null; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt"); } if (psp != null) { dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0 " + " " + dulutype; } else { return; } FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate); StreamWriter str11 = new StreamWriter(VK); str11.Write(dlr); str11.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"); } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"); } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"); } shortCutCal.Show_shortcir(Compuflag, OutType, 0); string matrixstr = null; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt")) { matrixstr = "�����ɾ���"; // matrixflag = false; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt")) { // matrixflag = false; matrixstr += "�����ɾ���"; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt")) { //matrixflag = false; matrixstr += "�����ɾ���"; } if (matrixstr != null) { System.Windows.Forms.MessageBox.Show(matrixstr + "�����������������������ٽ��м��㣡", "��ʾ", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return; } } catch (System.Exception ex) { } }
//�����еĶ�·�������в��� public void AllShorti(string projectSUID, string projectid, int dulutype, double ratecaplity, Dictionary<string, double> shortcap) { try { //OutType = 1; if (Compuflag == 1) { ElectricLoadCal elcc = new ElectricLoadCal(); elcc.LFCS(projectSUID, 1, (float)ratecaplity); if (!CheckDLL(projectSUID, projectid, ratecaplity)) { return; } } else { if (!CheckDL(projectSUID, projectid, ratecaplity)) { return; } } System.Windows.Forms.Clipboard.Clear(); Dictionary<int, double> nodeshorti = new Dictionary<int, double>(); //��¼ĸ����û�н��й���· KeyValuePair<int, double> maxshorti = new KeyValuePair<int, double>(); //ȡ����·������·���� string con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number"; PSPDEV pspDev = new PSPDEV(); IList list1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type in ('05','03','02') AND PSPDEV.KSwitchStatus = '0'order by PSPDEV.number"; IList list2 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); PSPDEV psp = new PSPDEV(); psp = list2[0] as PSPDEV; string data = System.DateTime.Now.ToString("d"); string time = System.DateTime.Now.ToString("T"); int intshorti = 0; //��һ�м�¼��ΪҪ����·����������˵�� bool shortiflag = false; int muxiannum = 0; //��¼һ��ĸ�߶�·�� �ж��ٸ���¼ĸ�ߵ�ѹ int linenum = 0; //��¼һ��ĸ�߶�· �ж��ٸ���·���� shortbuscir shortCutCal = new shortbuscir(Compuflag); string dlr = null; if (psp != null) { dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0 " + " " + dulutype; } else { return; } FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate); StreamWriter str11 = new StreamWriter(VK); str11.Write(dlr); str11.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"); } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"); } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"); } shortCutCal.Show_shortcir(Compuflag, OutType, 0); string matrixstr = null; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt")) { matrixstr = "�����ɾ���"; // matrixflag = false; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt")) { // matrixflag = false; matrixstr += "�����ɾ���"; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt")) { //matrixflag = false; matrixstr += "�����ɾ���"; } if (matrixstr != null) { System.Windows.Forms.MessageBox.Show(matrixstr + "�����������������������ٽ��м��㣡", "��ʾ", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return; } 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[] { ' ' }; intshorti = 0; while ((strLineGU = readLineGU.ReadLine()) != null) { arrayGU = strLineGU.Split(charSplitGU, StringSplitOptions.RemoveEmptyEntries); string[] shorti = arrayGU; shorti.Initialize(); //int m = 0; //foreach (string str in arrayGU) //{ // if (str != "") // { // shorti[m++] = str.ToString(); // } //} if (intshorti == 0) { if (!shortiflag) { //duanResult.Append(shorti[0] + "," + shorti[1] + "," + shorti[3] + "\r\n"); shortiflag = true; } } else shortcap[shorti[1]] = Convert.ToDouble(shorti[3]); intshorti++; //wf.SetCaption(intshorti.ToString()); } readLineGU.Close(); } catch (System.Exception ex) { MessageBox.Show("��·���ݴ������⣬�迹�����ڻ��ߴ��ڹ����ڵ㣬���֤���ٽ��У�"); } }
public void AllShort(string projectSUID, string projectid, int dulutype, double ratecaplity, frnReport wFrom) { try { wFrom.ShowText += "\r\n��ʼ����·��������\t" + System.DateTime.Now.ToString(); //OutType = 1; if (Compuflag == 1) { ElectricLoadCal elcc = new ElectricLoadCal(); elcc.LFCS(projectSUID, 1, (float)ratecaplity); if (!CheckDLL(projectSUID, projectid, ratecaplity)) { return; } } else { if (!CheckDL(projectSUID, projectid, ratecaplity)) { return; } } System.Windows.Forms.Clipboard.Clear(); Dictionary<int, double> nodeshorti = new Dictionary<int, double>(); //��¼ĸ����û�н��й���· KeyValuePair<int, double> maxshorti = new KeyValuePair<int, double>(); //ȡ����·������·���� string con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0' order by PSPDEV.number"; PSPDEV pspDev = new PSPDEV(); IList list1 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); con = " ,PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type in ('05','03','02') AND PSPDEV.KSwitchStatus = '0'order by PSPDEV.number"; IList list2 = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con); PSPDEV psp = new PSPDEV(); psp = list2[0] as PSPDEV; string data = System.DateTime.Now.ToString("d"); string time = System.DateTime.Now.ToString("T"); StringBuilder duanResult = new StringBuilder(); duanResult.Append("��·�������" + "\r\n" + "\r\n"); duanResult.Append("��·��ҵ�ţ�1" + "\r\n"); duanResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n"); duanResult.Append("��λ��kA" + "\r\n"); StringBuilder dianYaResult = new StringBuilder(); dianYaResult.Append("ĸ�ߵ�ѹ���" + "\r\n" + "\r\n"); dianYaResult.Append("��·��ҵ�ţ�1" + "\r\n"); dianYaResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n"); dianYaResult.Append("��λ����ֵ( p.u. ) �Ƕ�(deg.)" + "\r\n"); StringBuilder dianLiuResult = new StringBuilder(); dianLiuResult.Append("֧·�������" + "\r\n" + "\r\n"); dianLiuResult.Append("��·��ҵ�ţ�1" + "\r\n"); dianLiuResult.Append("��·�������ڣ�" + data + " " + "ʱ�䣺" + time + "\r\n"); dianLiuResult.Append("��λ����ֵ( p.u. ) �Ƕ�(deg.)" + "\r\n"); int intshorti = 0; //��һ�м�¼��ΪҪ����·����������˵�� bool shortiflag = false; int muxiannum = 0; //��¼һ��ĸ�߶�·�� �ж��ٸ���¼ĸ�ߵ�ѹ int linenum = 0; //��¼һ��ĸ�߶�· �ж��ٸ���·���� shortbuscir shortCutCal = new shortbuscir(Compuflag); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\fault.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\fault.txt"); } string dlr = null; if (psp != null) { dlr = "0" + " " + psp.FirstNode + " " + psp.LastNode + " " + psp.Number + " " + "0 " + " " + dulutype; } else { return; } FileStream VK = new FileStream((System.Windows.Forms.Application.StartupPath + "\\fault.txt"), FileMode.OpenOrCreate); StreamWriter str11 = new StreamWriter(VK); str11.Write(dlr); str11.Close(); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt"); } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt"); } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt"); } wFrom.ShowText += "\r\n��ʼ���ж�·����\t" + System.DateTime.Now.ToString(); shortCutCal.Show_shortcir(Compuflag, OutType, 0); string matrixstr = null; if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Zmatrixcheck.txt")) { matrixstr = "�����ɾ���"; // matrixflag = false; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Fmatrixcheck.txt")) { // matrixflag = false; matrixstr += "�����ɾ���"; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Lmatrixcheck.txt")) { //matrixflag = false; matrixstr += "�����ɾ���"; } if (matrixstr != null) { System.Windows.Forms.MessageBox.Show(matrixstr + "�����������������������ٽ��м��㣡", "��ʾ", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return; } if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\ShortcuitI.txt")) { } else { wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString(); return; } wFrom.ShowText += "\r\n��ʼ�����·������\t" + System.DateTime.Now.ToString(); 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[] { ' ' }; intshorti = 0; while ((strLineGU = readLineGU.ReadLine()) != null) { arrayGU = strLineGU.Split(charSplitGU, StringSplitOptions.RemoveEmptyEntries); string[] shorti = arrayGU; shorti.Initialize(); //int m = 0; //foreach (string str in arrayGU) //{ // if (str != "") // { // shorti[m++] = str.ToString(); // } //} if (intshorti == 0) { if (!shortiflag) { duanResult.Append(shorti[0] + "," + shorti[1] + "," + shorti[3] + "\r\n"); shortiflag = true; } } else duanResult.Append(shorti[0] + "," + shorti[1] + "," + Convert.ToDouble(shorti[3]) + "\r\n"); intshorti++; // wf.SetCaption(intshorti.ToString()); } readLineGU.Close(); if (OutType == 0) { //**��ȡ�����ѹ��ֵ if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianya.txt")) { } else { wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString(); 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(); int j = 0; muxiannum = 0; while (strLineDY != null) { arrayDY = strLineDY.Split(charSplitDY, StringSplitOptions.RemoveEmptyEntries); //int m = 0; string[] dev = arrayDY; //dev.Initialize(); //foreach (string str in arrayDY) //{ // if (str != "") // { // dev[m++] = str; // } //} if (j == 0) { //dianYaResult += "\r\n" + "����ĸ�ߣ�" + pspDev.Name + "\r\n"; dianYaResult.Append(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"); } else { if (dev[0] == "����ĸ��") { dianYaResult.Append("\r\n" + "����ĸ�ߣ�" + dev[1] + "\r\n"); muxiannum++; } else { bool dianyaflag = true; //�жϴ�ĸ���Ƕ�·��ĸ����һ���ĸ�� PSPDEV CR = new PSPDEV(); if (dev[1] != "du") { con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.Name='" + dev[1] + "'"; //con = " WHERE Name='" + dev[1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'"; CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con); if (CR == null) { dianyaflag = false; } } //else //{ // dianyaflag = false; // CR.Name = duanluname; // CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByNameANDSVG", CR); //} if (dianyaflag) dianYaResult.Append(dev[0] + "," + dev[1] + "," + Convert.ToDouble(dev[2]) * CR.ReferenceVolt + "," + dev[3] + "," + Convert.ToDouble(dev[4]) * CR.ReferenceVolt + "," + dev[5] + "," + Convert.ToDouble(dev[6]) * CR.ReferenceVolt + "," + dev[7] + "," + Convert.ToDouble(dev[8]) * CR.ReferenceVolt + "," + dev[9] + "," + Convert.ToDouble(dev[10]) * CR.ReferenceVolt + "," + dev[11] + "," + Convert.ToDouble(dev[12]) * CR.ReferenceVolt + "," + dev[13] + "\r\n"); //else // dianYaResult.Append( dev[0] + "," + duanluname + "�϶�·��" + "," + Convert.ToDouble(dev[2]) * CR.ReferenceVolt + "," + dev[3] + "," + Convert.ToDouble(dev[4]) * CR.ReferenceVolt + "," + dev[5] + "," + Convert.ToDouble(dev[6]) * CR.ReferenceVolt + "," + dev[7] + "," + Convert.ToDouble(dev[8]) * CR.ReferenceVolt + "," + // dev[9] + "," + Convert.ToDouble(dev[10]) * CR.ReferenceVolt + "," + dev[11] + Convert.ToDouble(dev[12]) * CR.ReferenceVolt + "," + dev[13] + "\r\n"; } } strLineDY = readLineDY.ReadLine(); j++; //wf.SetCaption(muxiannum.ToString()); } readLineDY.Close(); //**��ȡ���������ֵ if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\Sxdianliu.txt")) { } else { wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString(); 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(); j = 0; int jxflag = 0; //��¼��һ��ĸ�߶�·ʱ����·���� linenum = 0; while (strLineDL != null) { arrayDL = strLineDL.Split(charSplitDL, StringSplitOptions.RemoveEmptyEntries); int m = 0; string[] dev = arrayDL; //dev.Initialize(); //foreach (string str in arrayDL) //{ // if (str != "") // { // dev[m++] = str; // } //} if (j == 0) { //dianLiuResult.Append( "\r\n" + "����ĸ�ߣ�" + pspDev.Name + "\r\n"; dianLiuResult.Append(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"); } else { if (dev[0] == "����ĸ��") { dianLiuResult.Append("\r\n" + "����ĸ�ߣ�" + dev[1] + "\r\n"); jxflag++; } else { PSPDEV CR = new PSPDEV(); if (dev[0] != "du") { con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.Name='" + dev[0] + "'"; //con = " WHERE Name='" + dev[0] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'"; } else con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.Name='" + dev[1] + "'"; //con = " WHERE Name='" + dev[1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'"; CR = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con); dianLiuResult.Append(dev[0] + "," + dev[1] + "," + dev[2] + "," + Convert.ToDouble(dev[3]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[4] + "," + Convert.ToDouble(dev[5]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[6] + "," + Convert.ToDouble(dev[7]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[8] + "," + Convert.ToDouble(dev[9]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[10] + "," + Convert.ToDouble(dev[11]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[12] + "," + Convert.ToDouble(dev[13]) * ratecaplity / (Math.Sqrt(3) * CR.ReferenceVolt) + "," + dev[14] + "\r\n"); } //��Ϊ����·�������ʱ����һ����·�ĵ��������������������·�ĵ������нӵص������͵翹���ĵ��������ֻ��������������� } strLineDL = readLineDL.ReadLine(); j++; if (jxflag==1) { linenum++; } // wf.SetCaption(linenum.ToString()); } readLineDL.Close(); } wFrom.ShowText += "\r\n��ʼ���ɱ���\t" + System.DateTime.Now.ToString(); //д�뱨���� 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.Default); strGU.Write(duanResult.ToString()); 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.Default); strDY.Write(dianYaResult.ToString()); 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.Default); strDL.Write(dianLiuResult); strDL.Close(); PSP_ELCPROJECT psproject = new PSP_ELCPROJECT(); psproject.ID = projectSUID; psproject = (PSP_ELCPROJECT)UCDeviceBase.DataService.GetObject("SelectPSP_ELCPROJECTByKey", psproject); if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.xls")) { File.Delete(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.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]; xSheet.Name = "��·����"; ex.Visible = true; xSheet.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[6, 1], xSheet.Cells[6, 3]).Interior.ColorIndex = 45; xSheet.get_Range(xSheet.Cells[7, 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_ "; if (muxiannum>50) { if (OutType == 0) { if (MessageBox.Show("����ʾ�����ѹʱ���ܵ����ݳ����˱���ij��ܷ�Χ��ѡ���Ƿ����?", "��ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes) { OutType=1; } } } if (OutType == 0) { 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 = "֧·����"; 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); newWorksheet.UsedRange.Font.Name = "����_GB2312"; newWorkSheet1.UsedRange.Font.Name = "����_GB2312"; //ĸ�ߵ�ѹ��ʾ��ʽ 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; if (OutType == 0) { for (int m = 0; m < muxiannum ; m++) { newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 8, 1], newWorksheet.Cells[m * (muxiannum + 2) + 8, 14]).Interior.ColorIndex = 45; newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 9, 1], newWorksheet.Cells[m * (muxiannum + 2) + 8 + muxiannum, 1]).Interior.ColorIndex = 6; newWorksheet.get_Range(newWorksheet.Cells[m * (muxiannum + 2) + 9, 3], newWorksheet.Cells[m * (muxiannum + 2) + 8 + muxiannum - 1, 13]).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; if (OutType == 0) { for (int m = 0; m < muxiannum; m++) { newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum-1 + 2) + 8, 1], newWorkSheet1.Cells[m * (linenum-1 + 2) + 8, 15]).Interior.ColorIndex = 45; newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum - 1 + 2) + 9, 1], newWorkSheet1.Cells[m * (linenum - 1 + 2) + 8 + linenum - 1, 1]).Interior.ColorIndex = 6; newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum - 1 + 2) + 9, 2], newWorkSheet1.Cells[m * (linenum - 1 + 2) + 8 + linenum - 1, 2]).Interior.ColorIndex = 6; newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum - 1 + 2) + 9, 3], newWorkSheet1.Cells[m * (linenum - 1 + 2) + 8 + linenum - 1, 3]).Interior.ColorIndex = 6; newWorkSheet1.get_Range(newWorkSheet1.Cells[m * (linenum - 1 + 2) + 9, 4], newWorkSheet1.Cells[m * (linenum - 1 + 2) + 8 + linenum - 1, 14]).NumberFormat = "0.0000_ "; } } System.Windows.Forms.Clipboard.Clear(); newWorksheet.Rows.AutoFit(); newWorksheet.Columns.AutoFit(); newWorkSheet1.Rows.AutoFit(); newWorkSheet1.Columns.AutoFit(); newWorksheet.SaveAs(System.Windows.Forms.Application.StartupPath + "\\" + psproject.Name + "ȫ����·������.xls", Excel.XlFileFormat.xlXMLSpreadsheet, null, null, false, false, false, null, null, null); result1.Workbooks.Close(); result1.Quit(); result2.Workbooks.Close(); result2.Quit(); } xSheet.Rows.AutoFit(); xSheet.Columns.AutoFit(); System.Windows.Forms.Clipboard.Clear(); ex.DisplayAlerts = false; wFrom.ShowText += "\r\n��·�������\t" + System.DateTime.Now.ToString(); } catch (System.Exception ex) { wFrom.ShowText += "\r\n��·����ʧ��\t" + System.DateTime.Now.ToString(); MessageBox.Show("��·���ݴ������⣬�迹�����ڻ��ߴ��ڹ����ڵ㣬���֤���ٽ��У�"); } }