Example #1
0
 public void Initdata()
 {
     PSP_ELCPROJECT pr = new PSP_ELCPROJECT();
     pr.ProjectID = this.ProjectID;
     IList list = Services.BaseService.GetList("SelectPSP_ELCPROJECTList", pr);
     DataTable dataSvg = Itop.Common.DataConverter.ToDataTable(list, typeof(PSP_ELCPROJECT));
     gridControl1.DataSource = dataSvg;
 }
Example #2
0
 public void InitData()
 {
     PSP_ELCPROJECT pj = new PSP_ELCPROJECT();
     pj.ProjectID = ProjectSUID;
     IList list = UCDeviceBase.DataService.GetList("SelectPSP_ELCPROJECTList", pj);
     DataTable dt = Itop.Common.DataConverter.ToDataTable(list, typeof(PSP_ELCPROJECT));
     lookUpEdit1.Properties.DataSource = dt;
     lookUpEdit1.ItemIndex = 0;
     lookUpEdit1.Properties.DisplayMember = "Name";
     lookUpEdit1.Properties.ValueMember = "ID";
 }
Example #3
0
 protected override void Add()
 {
     frmNewProject frmprojectDLG = new frmNewProject();
     frmprojectDLG.Name = "";
     if (frmprojectDLG.ShowDialog() == DialogResult.OK) {
         PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
         pd.Name = frmprojectDLG.Name;
         pd.FileType = frmprojectDLG.FileType;
         pd.Class = System.DateTime.Now.ToString();
         pd.ProjectID = Itop.Client.MIS.ProgUID;
         UCDeviceBase.DataService.Create<PSP_ELCPROJECT>(pd);
         DataRow row = datatable.NewRow();
         Itop.Common.DataConverter.ObjectToRow(pd, row);
         datatable.Rows.Add(row);
     }
 }
        public void PspProject()
        {
            this.Show();

            this.WindowState = FormWindowState.Maximized;
            PSPProject pd = new PSPProject();
            pd.ProjectID = this.ProjectUID;
            pd.Initdata(false);
            filetype = "����";
            if (pd.ShowDialog() == DialogResult.OK)
            {
                strID = pd.FileSUID;
                parentobj = pd.Parentobj;
                this.Text = "��������-"+parentobj.Name;

                initbar(true);
            }
            else
            {
                this.Close();
            }
        }
        public void Save()
        {
            //XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");
            //foreach (XmlNode node in list)
            //{
            //    SvgElement element = node as SvgElement;
            //    tlVectorControl1.SVGDocument.CurrentElement = element;
            //    tlVectorControl1.Delete();
            //}

            if (tlVectorControl1.SVGDocument.SvgdataUid != string.Empty)
            {
                IList svglist = Services.BaseService.GetList("SelectSVGFILEByKey", tlVectorControl1.SVGDocument.SvgdataUid);
                if (svglist.Count > 0)
                {
                    svg = (SVGFILE)svglist[0];
                    svg.SVGDATA = tlVectorControl1.SVGDocument.OuterXml;
                    svg.FILENAME = tlVectorControl1.SVGDocument.FileName;
                    Services.BaseService.Update<SVGFILE>(svg);
                    PSP_ELCPROJECT pspDir = new PSP_ELCPROJECT();
                    pspDir.ID = svg.SUID;
                    pspDir.ProjectID = this.ProjectUID;
                    pspDir.Name = tlVectorControl1.SVGDocument.FileName;
                    if (fileType == true)
                    {
                        pspDir.FileType = "潮流";
                    }
                    else
                    {
                        pspDir.FileType = "短路";
                    }
                    Services.BaseService.Update<PSP_ELCPROJECT>(pspDir);
                }
                else
                {
                    svg.SUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    svg.FILENAME = tlVectorControl1.SVGDocument.FileName;
                    svg.SVGDATA = tlVectorControl1.SVGDocument.OuterXml;
                    Services.BaseService.Create<SVGFILE>(svg);
                    PSP_ELCPROJECT pspDir = new PSP_ELCPROJECT();
                    pspDir.ID = svg.SUID;
                    pspDir.ProjectID = this.ProjectUID;
                    pspDir.Name = tlVectorControl1.SVGDocument.FileName;
                    if (fileType == true)
                    {
                        pspDir.FileType = "潮流";
                    }
                    else
                    {
                        pspDir.FileType = "短路";
                    }
                    Services.BaseService.Update<PSP_ELCPROJECT>(pspDir);
                }
            }
            else
            {
                svg.SUID = Guid.NewGuid().ToString();
                svg.FILENAME = tlVectorControl1.SVGDocument.FileName;
                svg.SVGDATA = tlVectorControl1.SVGDocument.OuterXml;
                Services.BaseService.Create<SVGFILE>(svg);
                tlVectorControl1.SVGDocument.SvgdataUid = svg.SUID;
                PSP_ELCPROJECT pspDir = new PSP_ELCPROJECT();
                pspDir.ID = svg.SUID;
                pspDir.ProjectID = this.ProjectUID;
                pspDir.Name = tlVectorControl1.SVGDocument.FileName;
                if (fileType == true)
                {
                    pspDir.FileType = "潮流";
                }
                else
                {
                    pspDir.FileType = "短路";
                }
                Services.BaseService.Create<PSP_ELCPROJECT>(pspDir);
            }
            tlVectorControl1.IsModified = false;
        }
        public void Open(string _SvgUID)
        {
            try
            {
                SVGFILE svgFile = new SVGFILE();
                svgFile.SUID = _SvgUID;
                SvgDocument document = new SvgDocument();
                if (document != null)
                {
                    IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile);
                    if (svgList.Count > 0)
                    {
                        svgFile = (SVGFILE)svgList[0];
                    }
                    else
                    {
                        PSP_ELCPROJECT pr = new PSP_ELCPROJECT();
                        pr.ID= _SvgUID;
                        pr = (PSP_ELCPROJECT)Services.BaseService.GetObject("SelectPSP_ELCPROJECTByKey", pr);
                        svgFile.FILENAME = pr.Name;
                        svgFile.SUID = _SvgUID;
                        Services.BaseService.Create<SVGFILE>(svgFile);
                    }
                    document = new SvgDocument();
                    if (!string.IsNullOrEmpty(svgFile.SVGDATA))
                    {
                        document.LoadXml(svgFile.SVGDATA);
                    }

                    document.FileName = svgFile.FILENAME;
                    document.SvgdataUid = svgFile.SUID;
                }
                SVGUID = document.SvgdataUid;

                this.Text = document.FileName;
                if (document.RootElement == null)
                {
                    tlVectorControl1.NewFile();
                    tlVectorControl1.SVGDocument.SvgdataUid = _SvgUID;
                    SvgDocument.currentLayer = Layer.CreateNew("默认层", tlVectorControl1.SVGDocument).ID;
                }
                else
                {
                    tlVectorControl1.SVGDocument = document;
                    tlVectorControl1.SVGDocument.CurrentLayer = ((tlVectorControl1.SVGDocument.getLayerList()[0]) as ItopVector.Core.Figure.Layer);
                }
                tlVectorControl1.SVGDocument.SvgdataUid = SVGUID;
                tlVectorControl1.SVGDocument.FileName = this.Text;
                tlVectorControl1.DocumentbgColor = Color.White;
                tlVectorControl1.BackColor = Color.White;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
        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":

                        //NewFile(fileType, this.Text);
                        frmNewProject frmprojectDLG = new frmNewProject();
                        frmprojectDLG.Name = "";
                        frmprojectDLG.FileType = "短路";
                        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);
                                this.Text = frmname + "-" + pd.Name;
                            }
                            this.Show();
                            jxtbar2(2);
                            LoadShape("symbol23.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(true);
                        if (op.ShowDialog() == DialogResult.OK)
                        {
                            if (op.FileSUID != null)
                            {
                                Open(op.FileSUID);
                                intdata(op.FileSUID);
                                this.Text = frmname + "-" + op.FileName;
                            }
                            this.Show();
                            jxtbar2(2);
                            LoadShape("symbol23.xml");
                        }
                        break;
                    case "btExSymbol":
                        tlVectorControl1.ExportSymbol();
                        break;
                    case "mjxt"://导入接线图

                        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 "mExit":
                        this.Close();
                        break;
                    case "bt1":
                        //InitTK();
                        break;
                    case "bt2":
                        break;
                    case "mPriSet":
                        this.tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint;
                        printToolStripMenuItem.Visible = true;
                        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 "deviceparam":
                        frmProjectManager frmPdlg = new frmProjectManager();
                        frmPdlg.SetMode(tlVectorControl1.SVGDocument.SvgdataUid);
                        frmPdlg.ShowDialog();
                        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 "mPolyline":
                        tlVectorControl1.Operation = ToolOperation.PolyLine;

                        break;
                    case "mConnectLine":
                      tlVectorControl1.Operation = ToolOperation.ConnectLine;
                        //tlVectorControl1.Operation = ToolOperation.ConnectLine_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 "ButtonItem2":

                        break;
                    case "ButtonItem8":

                        break;
                    case "mCheck":
                        break;
                    case "niula":
                        break;
                    case "pq":

                        break;

                    case "GaussSeidel":

                        break;
                    case "PowerLossCal":

                        break;
                    case "N_RZYz":

                        break;
                    case "WebRela":                        //进行网络N-1检验

                        break;
                    case "TransRela":                       //进行变压器N-1检验

                        break;
                    case "Shortibut":
                        if (!addcheck())  //检验是不是还有元件需要添加

                            return;
                        ElectricShorti elc = new ElectricShorti();
                       string strID =tlVectorControl1.SVGDocument.SvgdataUid;
                        //elc.CheckDL(strID, 100);
                        int n3 = 0;
                        ShortTform shorttype = new ShortTform();
                        frnReport wduanlu = new frnReport();
                        wduanlu.Owner = this;
                        wduanlu.Text = this.Text;
                        wduanlu.Show();
                        wduanlu.ShowText += "进行相关设置\t" + System.DateTime.Now.ToString();
                        shorttype.ShowDialog();
                        if (shorttype.DialogResult == DialogResult.OK)
                        {
                            switch (shorttype.DuanluType)
                            {
                                case "单相接地":
                                    n3 = 1;
                                    break;

                                case "两相接地":
                                    n3 = 3;
                                    break;
                                case "两相故障":
                                    n3 = 2;
                                    break;
                                case "三相故障":
                                    n3 = 0;
                                    break;

                            }
                            elc.OutType = shorttype.Mathindex;
                        }
                        //elc.P1 = strID; elc.P2 = this.ProjectUID; elc.P3 = n3; elc.P4 = 100;
                        //Thread wait = new Thread(new ThreadStart(elc.temp));
                        //wait.Start();
                       // WaitDialogForm wait = null;
                        try
                        {
                            //wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            elc.AllShort(strID, this.ProjectUID, n3, 100,wduanlu);
                           // wait.Close();
                        }
                        catch (Exception exc)
                        {
                            Debug.Fail(exc.Message);
                            HandleException.TryCatch(exc);
                            //wait.Close();
                            wduanlu.ShowText += "\r\n短路计算失败" + System.DateTime.Now.ToString();
                            return;
                        }

                        break;
                    case "ZLcheck":

                       elc = new ElectricShorti();

                        strID = tlVectorControl1.SVGDocument.SvgdataUid;
                        WaitDialogForm wait = null;
                        try
                        {
                            wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            wait.Close();
                            elc.Allshortcheck(strID, this.ProjectUID, 100, 3);

                        }
                        catch (Exception exc)
                        {
                            Debug.Fail(exc.Message);
                            Itop.Client.Common.HandleException.TryCatch(exc);
                            wait.Close();
                            return;
                        }

                       // Allshortcheck(3);
                        dotNetBarManager1.Bars["bar2"].GetItem("ZLcheck").Enabled = false;
                        dotNetBarManager1.Bars["bar2"].GetItem("Jiaoliucheck").Enabled = true;
                        //dotNetBarManager1.Bars["bar2"].GetItem("DLqiOutResult").Enabled =true;
                        break;
                    case "Jiaoliucheck":
                       elc = new ElectricShorti();

                        strID = tlVectorControl1.SVGDocument.SvgdataUid;
                     wait = null;
                        try
                        {
                            wait = new WaitDialogForm("", "正在处理数据, 请稍候...");
                            wait.Close();
                            elc.Allshortcheck(strID, this.ProjectUID, 100, 2);

                        }
                        catch (Exception exc)
                        {
                            Debug.Fail(exc.Message);
                            Itop.Client.Common.HandleException.TryCatch(exc);
                            wait.Close();
                            return;

                        }
                       // Allshortcheck(2);
                        dotNetBarManager1.Bars["bar2"].GetItem("Jiaoliucheck").Enabled = false;
                        dotNetBarManager1.Bars["bar2"].GetItem("ZLcheck").Enabled = true;
                        break;
                    case "dd":
                        //SubPrint = true;
                        tlVectorControl1.Operation = ToolOperation.InterEnclosurePrint;
                        break;

                    case "NiulaResult":

                        break;
                    case "GaussSeidelResult":

                        break;
                    case "N_RZYzResult":

                        break;
                    case "VoltEvaluation":
                        break;
                    case "PowerLoss":

                        break;
                    case "ZLPResult1":

                        break;

                    case "mDLR":

                        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)
                                {
                                    PSPDEV pspDev = new PSPDEV();
                                    pspDev.EleID = element.GetAttribute("id");
                                    pspDev.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    pspDev = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVBySvgUIDandEleID", pspDev);
                                    Services.BaseService.Delete<PSPDEV>(pspDev);
                                }
                                tlVectorControl1.Delete();
                            }

                        }
                        break;
                    case "mUodo":
                        tlVectorControl1.Undo();
                        break;
                    case "mRedo":
                        tlVectorControl1.Redo();
                        break;
                    #endregion
                    #region 业务操作

                    case "mXLine":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.XPolyLine;
                        break;
                    case "mYLine":
                        tlVectorControl1.Operation = ToolOperation.Select;
                        tlVectorControl1.Operation = ToolOperation.YPolyLine;
                        break;

                    case "mSaveGroup":
                        if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1)
                        {
                            string content = "<svg>";
                            SvgElementCollection col = tlVectorControl1.SVGDocument.SelectCollection;
                            for (int i = 0; i < col.Count; i++)
                            {
                                SvgElement _e = (SvgElement)col[i];
                                if (_e.ID != "svg")
                                {
                                    content = content + _e.OuterXml;
                                }
                            }
                            RectangleF rect = tlVectorControl1.DrawArea.viewer.SelectedViewRectangle;

                            content = content + "</svg>";
                            frmSaveGroup fm = new frmSaveGroup();
                            fm.rect = rect;
                            fm.Content = content;
                            fm.ShowDialog();
                        }
                        else
                        {
                            MessageBox.Show("请至少选择2个图元。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        break;

                    case "mInsert":
                        frmUseGroup fg = new frmUseGroup();
                        if (fg.ShowDialog() == DialogResult.OK)
                        {
                            UseGroup u = fg.SelectedUseGroup;
                            if (u != null)
                            {
                                frmXY xy = new frmXY();
                                if (xy.ShowDialog() == DialogResult.OK)
                                {
                                    decimal x = xy.GetX();
                                    decimal y = xy.GetY();
                                    string content = u.Content;
                                    XmlDocument doc = new XmlDocument();
                                    doc.LoadXml(u.Content);
                                    XmlNodeList list = doc.ChildNodes;
                                    XmlNode _node = list[0];
                                    XmlNodeList sonlist = _node.ChildNodes;
                                    XmlElement ele = tlVectorControl1.SVGDocument.CreateElement("g");
                                    ele.SetAttribute("layer", SvgDocument.currentLayer);
                                    for (int i = 0; i < sonlist.Count; i++)
                                    {
                                        XmlNode _sonnode = sonlist[i];
                                        //string str = _sonnode.OuterXml;
                                        if (_sonnode.Name == "use")
                                        {
                                            string sid = ((XmlElement)_sonnode).GetAttribute("xlink:href");
                                            XmlNode _snode = symbolSelector.SymbolDoc.SelectSingleNode("//*[@id='" + sid.Substring(1) + "']");
                                            tlVectorControl1.SVGDocument.AddDefsElement((SvgElement)_snode);
                                        }
                                        ele.AppendChild(_sonnode);
                                        string ss = ele.OuterXml;
                                    }
                                    //RectangleF r=((Group)ele).GetBounds();
                                    string tr = "matrix(1,0,0,1,";

                                    tr = tr + Convert.ToString(x - Convert.ToDecimal(u.X)) + ",";
                                    tr = tr + Convert.ToString(y - Convert.ToDecimal(u.Y)) + ")";

                                    ele.SetAttribute("transform", tr);
                                    // transform="matrix(1,0,0,1,2558.82,-352.94)"
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(ele);
                                    tlVectorControl1.SVGDocument.SelectCollection.Clear();
                                    tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)ele);
                                    tlVectorControl1.UnGroup();
                                    // tlVectorControl1.Refresh();
                                }
                            }
                        }
                        break;
                    case "PSPIdleOptimize":
                        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
                }
            }
        }
Example #8
0
        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
                }
            }
        }
Example #9
0
        public void ALLShortThread(string projectSUID, string projectid, int dulutype, double ratecaplity, WaitDialogForm wf)
        {
            try
            {
                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");
                string[,] dataDianliu = new string[65536, 15];

                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 (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;
                }
                ArrayList al = new ArrayList();
                FileReadV fv = new FileReadV(projectSUID, projectid, dulutype, ratecaplity, wf, shortiflag, duanResult);
                FileReadDLL fdl = new FileReadDLL(projectSUID, projectid, dulutype, ratecaplity, wf, con, dataDianliu);
                FileReadDV fdv = new FileReadDV(projectSUID, projectid, dulutype, ratecaplity, wf, con, dianYaResult);
                Thread shori = new Thread(new ThreadStart(fv.str));
                Thread dianya = new Thread(new ThreadStart(fdv.str));
                Thread dianliu = new Thread(new ThreadStart(fdl.str));
                shori.Start();
                if (OutType == 0)
                {
                    dianya.Start();
                    dianliu.Start();
                }

                //д�뱨����
                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];
                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);

                while (shori.IsAlive || dianya.IsAlive || dianliu.IsAlive)
                {
                    newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[65536, 20]).Clear();
                    newWorksheet.get_Range(newWorksheet.Cells[1, 1], newWorksheet.Cells[65536, 20]).Value2 = dataDianliu;

                }
                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 < muxiannum - 1; 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 < muxiannum - 1; 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();
                GC.Collect();
            }
            catch (System.Exception ex)
            {

            }
        }
Example #10
0
        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DataRow node = gridView1.GetDataRow(gridView1.FocusedRowHandle); ;
            if (node != null)
            {
                if (MessageBox.Show("确定删除么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    string id = node["ID"].ToString();
                    dataSvg.Rows.Remove(node);
                    PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                    pd.ID = id;
                    UCDeviceBase.DataService.Delete<PSP_ELCPROJECT>(pd);
                    //删除和其相连的设备记录
                    string con = "where ProjectSUID = '" + pd.ID + "'";
                    IList list = Services.BaseService.GetList("SelectPSP_ElcDeviceByCondition", con);
                    foreach (PSP_ElcDevice pe in list)
                    {
                        UCDeviceBase.DataService.Delete<PSP_ElcDevice>(pe);
                    }
                    //删除和其相关的图形记录
                    SVGFILE svgFile = new SVGFILE();
                    svgFile.SUID = pd.ID;
                    svgFile = (SVGFILE)Services.BaseService.GetObject("SelectSVGFILEByKey", svgFile);
                    if (svgFile != null)
                    {
                        UCDeviceBase.DataService.Delete<SVGFILE>(svgFile);
                    }

                }
            }
        }
Example #11
0
 private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     frmNewProject frmprojectDLG = new frmNewProject();
     frmprojectDLG.flag = pspflag;
     frmprojectDLG.init();
     frmprojectDLG.Name = "";
     if (frmprojectDLG.ShowDialog() == DialogResult.OK)
     {
         PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
         pd.Name = frmprojectDLG.Name;
         pd.FileType = frmprojectDLG.FileType;
         pd.Class = System.DateTime.Now.ToString();
         pd.BelongYear = frmprojectDLG.BelongYear;
         pd.ProjectID = Itop.Client.MIS.ProgUID;
         UCDeviceBase.DataService.Create<PSP_ELCPROJECT>(pd);
         DataRow row = dataSvg.NewRow();
         Itop.Common.DataConverter.ObjectToRow(pd, row);
         dataSvg.Rows.Add(row);
     }
 }
 protected override void Del()
 {
     TreeListNode node = treeList1.FocusedNode;
     if (node != null) {
         if (MessageBox.Show("ȷ��ɾ��ô?", "��ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) {
             string id = node["ID"].ToString();
             treeList1.DeleteNode(treeList1.FocusedNode);
             PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
             pd.ID = id;
             UCDeviceBase.DataService.Delete<PSP_ELCPROJECT>(pd);
             //ɾ�������������豸��¼
             string con = "where ProjectSUID = '"+pd.ID+"'";
             IList list = Services.BaseService.GetList("SelectPSP_ElcDeviceByCondition", con);
             foreach (PSP_ElcDevice pe in list)
             {
                 UCDeviceBase.DataService.Delete<PSP_ElcDevice>(pe);
             }
             //ɾ��������ص�ͼ�μ�¼
             SVGFILE svgFile = new SVGFILE();
             svgFile.SUID = pd.ID;
             svgFile = (SVGFILE)Services.BaseService.GetObject("SelectSVGFILEByKey", svgFile);
             if (svgFile!=null)
             {
                 UCDeviceBase.DataService.Delete<SVGFILE>(svgFile);
             }
             treeList1.FocusedNode = null;
             strID = null;
         }
     }
 }
        /// <summary>
        /// ��ʼ�豸����
        /// </summary>
        private void InitDeviceType()
        {
            TreeListColumn column = new TreeListColumn();
            column.Caption = "��Ŀ����";
            column.FieldName = "Name";
            column.VisibleIndex = 0;
            column.Width = 180;
            column.OptionsColumn.AllowEdit = false;
            column.OptionsColumn.AllowSort = false;
            this.treeList1.Columns.AddRange(new TreeListColumn[] {
            column});
            PSP_ELCPROJECT pj = new PSP_ELCPROJECT();
            pj.ProjectID = Itop.Client.MIS.ProgUID;
            IList list = UCDeviceBase.DataService.GetList("SelectPSP_ELCPROJECTList", pj);
            datatable = Itop.Common.DataConverter.ToDataTable(list, typeof(PSP_ELCPROJECT));
            treeList1.DataSource = datatable;

               // DeviceTypeHelper.InitDeviceTypes(treeList2);
            DeviceTypeHelper.initprojectDeviceTypes_SH1(treeList2);
        }
Example #14
0
        //网络N-1计算和输出
        public bool WebCalAndPrint(string projectSUID, string projectid, double ratedCapacity)
        {
            bool flag = true;
            FileStream dh;
            StreamReader readLine;
            // StreamReader readLine;
            ArrayList list = new ArrayList();   //用来记录线路不能解裂的位数

            char[] charSplit;
            string strLine;
            string[] array1;
            string outputZL ="";
            string outputv ="";//记录直流计算结果 线路功率和节点电压

            //string outputBC = null;   //记录补偿计算结果 节点电压
            string[] array2;

            string strLine2;

            char[] charSplit2 = new char[] { ' ' };
            List<lineclass> Overlinp = new List<lineclass>();
            List<lineclass> OverVp = new List<lineclass>();
            //Dictionary<int, List<lineclass>> OverPhege = new Dictionary<int, List<lineclass>>();       //为 线路功率的检验 键值为断开线路的编号,值为第几条线路出现了不合格

            //Dictionary<int, List<lineclass>> OverVhege = new Dictionary<int, List<lineclass>>();       //为 节点电压的检验 键值为断开线路的编号,值为第几个节点出现了不合格

            FileStream op;
            StreamWriter str1;
            FileStream dh2;
            StreamReader readLine2;
            Excel.Application ex;
            //Excel.Worksheet xSheet;
            Excel.Application result1;
            //Excel.Worksheet tempSheet;
            Excel.Worksheet newWorksheet;
            PSP_ELCPROJECT psproject = new PSP_ELCPROJECT();
            psproject.ID = projectSUID;
            psproject = (PSP_ELCPROJECT)UCDeviceBase.DataService.GetObject("SelectPSP_ELCPROJECTByKey", psproject);

            if (true)    //进行全网计算
            {
                if (!CheckN(projectSUID,projectid,ratedCapacity))
                {
                    return false;
                }

                try
                {
                    string datatime = System.DateTime.Now.ToString();
                    System.Windows.Forms.Clipboard.Clear(); //去掉剪切板中的数据

                    if (brchcount >= 50)
                    {
                        for (int i = 1; i <= 5; i++)
                        {
                            n1NL_DLL.ZYZ nl = new n1NL_DLL.ZYZ();
                            nl.jianyan(i);
                        }
                    }
                    else
                    {
                        for (int i = 1; i <= brchcount; i++)
                        {
                            n1NL_DLL.ZYZ nl = new n1NL_DLL.ZYZ();
                            nl.jianyan(i);
                        }
                    }
                    //int* busnumber;

                    //N1Test.NBcal kk = new N1Test.NBcal();                    //busnumber = kk.Show_Reliability();

                    double yinzi = 0, capability = 0, volt = 0, current = 0, standvolt = 1, Rad_to_Deg = 57.29577951;
                   // string branchname = getbranchname();
                   // string busname = getbusname();

                    capability = ratedCapacity;

                    string con = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectSUID + "'AND PSPDEV.type='01'AND PSPDEV.KSwitchStatus = '0'";
                    IList cont = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                    if (buscount < cont.Count)
                    {
                        MessageBox.Show("选择的母线又存在孤立的节点!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        return false;

                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\VandTheta.txt"))
                    {
                    }
                    else
                    {
                        MessageBox.Show("数据不收敛,请调整参数后重新计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return false;
                    }
                    if (File.Exists(System.Windows.Forms.Application.StartupPath + "\\lineP.txt"))
                    {
                    }
                    else
                    {
                        return false;
                    }
                    dh = new FileStream(System.Windows.Forms.Application.StartupPath + "\\" + "lineP.txt", FileMode.Open);
                    dh2 = new FileStream(System.Windows.Forms.Application.StartupPath + "\\" + "VandTheta.txt", FileMode.Open);
                    readLine2 = new StreamReader(dh2, Encoding.Default);
                    readLine = new StreamReader(dh, Encoding.Default);
                    charSplit = new char[] { ' ' };
                    //strLine = readLine.ReadLine();

                    outputZL = null;
                    //outputBC=null;
                   // outputZL += ("全网可靠性结果报表" + "\r\n");
                   //// outputZL += ("开断支路名称" + "," + "剩余网络线路功率Pij和Pji的有名值" + ",,");
                   // for (int i = 0; i < brchcount - 1; i++)
                   // {
                   //     outputZL += (",,");
                   // }
                   // outputZL += ("是否越限" + "," + "\r\n");
                   // outputZL += ",";
                    int n = 0; //记录线路的行数

                    while ((strLine = readLine.ReadLine()) != null)
                    {
                        array1 = strLine.Split(charSplit);

                        string[] devzl = new string[3 * brchcount + 1];

                        devzl.Initialize();
                        int i = 0;

                        n++;
                        foreach (string str in array1)
                        {
                            if (str != "")
                            {

                                devzl[i++] = str.ToString();

                            }
                        }
                        //for (int j = 0; j < brchcount; j++)
                        //{
                        //    outputZL += devzl[3 * j + 1] + "," + ",";
                        //}
                        //outputZL += branchname;
                        //outputZL += ("," + "\r\n");
                        //outputZL += devzl[0] + ",";
                        bool lineflag = true;      //只要有一个不合格则就为不合格
                        if (devzl[1] != "-1")
                        {
                            for (int j = 0; j < brchcount; j++)
                            {

                                double pij = Convert.ToDouble(devzl[j * 3 + 2].Substring(0, devzl[j * 3 + 2].IndexOf('j') - 1)) * capability;
                                double qij = Convert.ToDouble(devzl[j * 3 + 2].Substring(devzl[j * 3 + 2].IndexOf('j') + 1)) * capability;
                                double pji = Convert.ToDouble(devzl[j * 3 + 3].Substring(0, devzl[j * 3 + 3].IndexOf('j') - 1)) * capability;
                                double qji = Convert.ToDouble(devzl[j * 3 + 3].Substring(devzl[j * 3 + 3].IndexOf('j') + 1)) * capability;
                                double Sij = System.Math.Sqrt(pij * pij + qij * qij);
                                double Sji = System.Math.Sqrt(pji * pji + qji * qji);
                                double maxSij = (Sij > Sji) ? Sij : Sji;
                                PSPDEV psp = new PSPDEV();
                                con = " WHERE Name='" + devzl[j * 3 + 1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='05'";
                                IList listName = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);
                                PSPDEV pspline = (PSPDEV)listName[0];
                                double voltR = pspline.RateVolt;
                                //WireCategory wirewire = new WireCategory();
                                //wirewire.WireType = pspline.LineType;
                                //if (pspline.LineType == null || pspline.LineType == "")
                                //{
                                //    MessageBox.Show(pspline.Name + "的线路类型没有输入,无法进行可靠性检验", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                //    return;
                                //}
                                //WireCategory listware = (WireCategory)UCDeviceBase.DataService.GetObject("SelectWireCategoryByKey", wirewire);
                                double Ichange = (double)pspline.Burthen;
                                double linXij = System.Math.Sqrt(3) * voltR * Ichange ;
                               // outputZL += "'" + youming(devzl[j * 3 + 2], capability) + "," + "'" + youming(devzl[j * 3 + 3], capability) + ",";
                                if (maxSij >= linXij)
                                {
                                    lineflag = false;
                                    flag = false;
                                    lineclass _line = new lineclass(n, j);
                                    Overlinp.Add(_line);
                                    // OverPhege[n] = j;
                                }

                            }
                            if (!lineflag)
                            {
                                outputZL += "不合格";
                            }
                            else
                                outputZL += "合格";
                        }
                        else
                        {
                            outputZL += "该线路不可断。";
                        }
                        //OverPhege[n] = Overlinp;
                        //Overlinp.Clear();
                        //outputZL += "\r\n";
                        while ((strLine = readLine.ReadLine()) != null)
                        {
                            array1 = strLine.Split(charSplit);

                            string[] devzl1 = new string[3 * brchcount + 1];

                            devzl1.Initialize();

                            n++;
                            i = 0;
                            foreach (string str in array1)
                            {
                                if (str != "")
                                {

                                    devzl1[i++] = str.ToString();

                                }
                            }
                            if (devzl1[1] != "-1")
                            {
                                outputZL += devzl1[0] + ",";
                                for (int j = 0; j < brchcount; j++)
                                {
                                    double pij = Convert.ToDouble(devzl1[j * 3 + 2].Substring(0, devzl1[j * 3 + 2].IndexOf('j') - 1)) * capability;
                                    double qij = Convert.ToDouble(devzl1[j * 3 + 2].Substring(devzl1[j * 3 + 2].IndexOf('j') + 1)) * capability;
                                    double pji = Convert.ToDouble(devzl1[j * 3 + 3].Substring(0, devzl1[j * 3 + 3].IndexOf('j') - 1)) * capability;
                                    double qji = Convert.ToDouble(devzl1[j * 3 + 3].Substring(devzl1[j * 3 + 3].IndexOf('j') + 1)) * capability;
                                    double Sij = System.Math.Sqrt(pij * pij + qij * qij);
                                    double Sji = System.Math.Sqrt(pji * pji + qji * qji);
                                    double maxSij = (Sij > Sji) ? Sij : Sji;

                                    con = " WHERE Name='" + devzl1[j * 3 + 1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='05'";
                                    IList listName = UCDeviceBase.DataService.GetList("SelectPSPDEVByCondition", con);

                                    PSPDEV pspline = (PSPDEV)listName[0];
                                    double voltR = pspline.RateVolt;
                                    //WireCategory wirewire = new WireCategory();
                                    //wirewire.WireType = pspline.LineType;
                                    //if (pspline.LineType == null || pspline.LineType == "")
                                    //{
                                    //    MessageBox.Show(pspline.Name + "的线路类型没有输入,无法进行可靠性检验", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    //    return;
                                    //}
                                    //WireCategory listware = (WireCategory)UCDeviceBase.DataService.GetObject("SelectWireCategoryByKey", wirewire);
                                    double Ichange = (double)pspline.Burthen;
                                    double linXij = System.Math.Sqrt(3) * voltR * Ichange ;
                                    // outputZL += "'" + devzl[j * 3 + 2] + "," + "'" + devzl[j * 3 + 3] + ",";
                                    if (maxSij >= linXij)
                                    {
                                        lineflag = false;
                                        flag = false;
                                        return flag;
                                        lineclass subline = new lineclass(n, j);
                                        Overlinp.Add(subline);
                                        //OverPhege[n] = j;
                                    }
                                    outputZL += "'" + youming(devzl1[j * 3 + 2], capability) + "," + "'" + youming(devzl1[j * 3 + 3], capability) + ",";    //在此还可以判断线路是否超载

                                }
                                if (!lineflag)
                                {
                                    outputZL += "不合格";
                                }
                                else
                                    outputZL += "合格";
                                outputZL += "\r\n";
                                //OverPhege[n] = Overlinp;
                                //Overlinp.Clear();

                            }

                            else
                            {
                                list.Add(n);
                                outputZL += devzl1[0] + "," + "为不可断裂的线路";
                                outputZL += "\r\n";
                            }

                        }
                    }
                    outputZL += "注释:红色为线路超载" + "\r\n";
                    outputZL += "操作时间为:" + datatime;
                    outputZL += "\r\n";
                    outputZL += "单位:kA\\kV\\MW\\Mvar" + "\r\n";
                    readLine.Close();
                    if (File.Exists("result1.csv"))
                    {
                        File.Delete("result1.csv");
                    }

                    op = new FileStream("result1.csv", FileMode.OpenOrCreate);
                    str1 = new StreamWriter(op, Encoding.Default);
                    str1.Write(outputZL);
                    str1.Close();

                    outputZL = null;
                    //将各个节点的电压写入其中
                    // strLine2 = readLine2.ReadLine();
                    n = 0;
                    bool busvflag1 = true;
                    outputZL += ("网络节点电压和相角" + "\r\n");
                    outputZL += ("开断支路名称" + "," + "节点电压的幅值和相角的有名值");
                    for (int i = 0; i < buscount; i++)
                    {
                        outputZL += (",,");
                    }
                    outputZL += ("是否越限" + "," + "\r\n");
                    outputZL += ",";
                    while ((strLine2 = readLine2.ReadLine()) != null)
                    {
                        array2 = strLine2.Split(charSplit);

                        string[] devzl = new string[buscount * 3 + 1];

                        devzl.Initialize();
                        int i = 0;

                        n++;
                        foreach (string str in array2)
                        {
                            if (str != "")
                            {

                                devzl[i++] = str.ToString();

                            }
                        }

                       // outputZL += busname;
                        outputZL += ("," + "\r\n");
                        outputZL += devzl[0] + ",";
                        if (devzl[1] != "-1")
                        {

                            for (int j = 0; j < buscount; j++)
                            {
                                PSPDEV pspDev = new PSPDEV();
                                con = " WHERE Name='" + devzl[j * 3 + 1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                                pspDev =(PSPDEV) UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);

                                if (pspDev != null && pspDev.ReferenceVolt != 0)
                                {
                                    volt = pspDev.ReferenceVolt;
                                }
                                else
                                    volt = standvolt;
                                outputZL += "'" + (Convert.ToDouble(devzl[j * 3 + 2]) * volt).ToString() + "," + "'" + devzl[j * 3 + 3] + ",";
                                if (Convert.ToDouble(devzl[j * 3 + 2]) <= TLPSPVmin || Convert.ToDouble(devzl[j * 3 + 2]) >= TLPSPVmax)
                                {
                                    busvflag1 = false;
                                    flag = false;
                                    return flag;
                                    lineclass _vtheta = new lineclass(n, j);
                                    OverVp.Add(_vtheta);
                                    //OverVhege[n] = j;
                                }
                            }
                            if (busvflag1)
                            {
                                outputZL += "合格";
                            }
                            else
                            {
                                outputZL += "不合格";
                            }
                        }
                        else
                        {
                            outputZL += "不可断裂";
                        }
                        //OverVhege[n] = OverVp;
                        //OverVp.Clear();
                        outputZL += "\r\n";

                        while ((strLine2 = readLine2.ReadLine()) != null)
                        {
                            busvflag1 = true;
                            array2 = strLine2.Split(charSplit);

                            string[] devzl1 = new string[buscount * 3 + 1];

                            devzl1.Initialize();

                            n++;
                            i = 0;
                            foreach (string str in array2)
                            {
                                if (str != "")
                                {

                                    devzl1[i++] = str.ToString();

                                }
                            }

                            if (devzl1[1] != "-1")
                            {
                                outputZL += devzl1[0] + ",";
                                for (int j = 0; j < buscount; j++)
                                {
                                    PSPDEV pspDev = new PSPDEV();
                                    con = " WHERE Name='" + devzl1[j * 3 + 1] + "' AND ProjectID = '" + projectid + "'" + "AND Type='01'";
                                    pspDev =(PSPDEV) UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con);

                                    if (pspDev != null && pspDev.ReferenceVolt != 0)
                                    {
                                        volt = pspDev.ReferenceVolt;
                                    }
                                    else
                                        volt = standvolt;
                                    outputZL += "'" + (Convert.ToDouble(devzl1[j * 3 + 2]) * volt).ToString() + "," + "'" + devzl1[j * 3 + 3] + ",";   //在此还可以判断线路是否超载,如果超载加入一个标记,在excel里使其变为红色

                                    if (Convert.ToDouble(devzl1[j * 3 + 2]) >= TLPSPVmax || Convert.ToDouble(devzl1[j * 3 + 2]) <= TLPSPVmin)
                                    {
                                        lineclass vtheta = new lineclass(n, j);
                                        busvflag1 = false;
                                        flag = false;
                                        return flag;
                                        OverVp.Add(vtheta);
                                        //OverVhege[n] = j;
                                    }
                                }
                                if (busvflag1)
                                {
                                    outputZL += "合格";
                                }
                                else
                                    outputZL += "不合格";
                                outputZL += "\r\n";
                                //OverPhege[n] = OverVp;
                                //OverVp.Clear();
                            }
                            else
                            {
                                // list.Add(n);
                                outputZL += devzl1[0] + "," + "为不可断裂的线路" + ",,,,,,";
                                outputZL += "\r\n";
                            }

                        }
                    }
                    outputZL += "注释:红色为节点电压超载" + "\r\n";
                    outputZL += "节点电压合格范围为电压基准值的上下限,分别为" + TLPSPVmax + "和" + TLPSPVmin + "倍" + "\r\n";
                    outputZL += "操作时间为:" + datatime + "\r\n";
                    outputZL += "单位:kA\\kV\\MW\\Mvar" + "\r\n";
                    readLine2.Close();

                    //op = new FileStream(System.Windows.Forms.Application.StartupPath + "\\" + "reli.txt", FileMode.OpenOrCreate);
                    //str1 = new StreamWriter(op, Encoding.Default);
                    //str1.Write(outputZL);
                    //str1.Close();

                }
                catch (System.Exception e1)
                {
                    MessageBox.Show("数据存在问题,请仔细检查后再进行结果计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            //if (webn1.DialogResult == DialogResult.Ignore)
            //{
            //    PSPDEV pspDEV = new PSPDEV();
            //    pspDEV.ProjectID = projectid;
            //    pspDEV.SvgUID = projectSUID; //为了把 项目ID和卷id传入
            //    PartRelform selregion = new PartRelform(pspDEV);
            //    selregion.ShowDialog();
            //    if (selregion.DialogResult == DialogResult.Ignore)
            //    {
            //        DelLinenum = selregion.lineVnumlist;
            //        //DelTransnum = null;
            //       flag =  QyRelanalyst(projectSUID,projectid,ratedCapacity);
            //    }
            //    //IList list1 = UCDeviceBase.DataService.GetList("SelectPSPDEVBySvgUID", psp);
            //    //将进行潮流计算的文档传到选择网络中。

            //    else if (selregion.DialogResult == DialogResult.Yes)
            //    {
            //        DelLinenum = selregion.lineDnumlist;
            //        DelTransnum = selregion.lineVnumlist;
            //        //DelTransnum = null;
            //       flag =  QyRelanalyst(projectSUID,projectid,ratedCapacity);
            //    }
            //}
            //Operateflag = false;
            return flag;
        }
Example #15
0
        /*public void ResetPoly()
        {
            SvgElementCollection col= tlVectorControl1.SVGDocument.SelectCollection;
            if(col.Count<1){
                return;
            }
            SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();
            foreach(SvgElement ele in col){
                if (ele.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                {
                    glebeProperty p=new glebeProperty();
                    p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    p.EleID = ((IGraph)ele).ID;
                    p = Services.BaseService.GetObject("SelectglebePropertyByEleID", p);
                    if(p!=null){
                        PointF[] tfArray1 = TLMath.getPolygonPoints(ele);
                        GraphicsPath selectAreaPath = new GraphicsPath();
                        selectAreaPath.AddLines(tfArray1);
                        selectAreaPath.CloseFigure();
                        Region region1 = new Region(selectAreaPath);
                        while (enumerator1.MoveNext())
                        {
                            IGraph graph1 = (IGraph)enumerator1.Current;
                            GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                            path1.Transform(graph1.GraphTransform.Matrix);
                            Region region2 = new Region(path1);
                            region2.Intersect(region1);
                            if (!region2.GetBounds(Graphics.FromHwnd(IntPtr.Zero)).IsEmpty)
                            {
                                glebeProperty p1 = new glebeProperty();
                                p1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                p1.EleID = graph1.ID;
                                p1 = Services.BaseService.GetObject("SelectglebePropertyByEleID", p1);
                                if(p1!=null){
                                    p1.ParentEleID = p.UID;
                                    Services.BaseService.Update("UpdateglebePropertyAreaAll", p1);
                                }
                            }
                        }
                    }
                }
            }
            MessageBox.Show("更新完成。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }*/
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try {
                if (e.ClickedItem.Text == "可靠性分析") {
                    XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                        string deviceid = xml1.GetAttribute("Deviceid");
                        if (!string.IsNullOrEmpty(deviceid)) {
                            DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                            DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;

                            PSPDEV obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                            if (obj != null && obj.Type == "73") {
                                //更换为元件可靠性
                                Itop.TLPSP.DEVICE.FrmpdrelProject xf = new Itop.TLPSP.DEVICE.FrmpdrelProject();
                                xf.init(obj);
                                xf.ShowDialog();
                            }

                        }
                    }

                }
                if (e.ClickedItem.Text == "属性") {
                    XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    //PointF[] pf = TLMath.getPolygonPoints(xml1);
                    DeviceHelper.xml1 = xml1;
                    //((Polygon)xml1).Transform.Matrix.TransformPoints(pf);
                    // 规划
                    if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList())) {

                        if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请先选择规划区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") {
                            //frmImgManager frm = new frmImgManager();
                            //frm.Show();
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            XmlNodeList n1 = tlVectorControl1.SVGDocument.GetElementsByTagName("use");
                            PointF[] tfArray1 = TLMath.getPolygonPoints(xml1);
                            string str220 = "";
                            string str110 = "";
                            string str66 = "";

                            string str_id = "";
                            GraphicsPath selectAreaPath = new GraphicsPath();
                            selectAreaPath.AddLines(tfArray1);
                            selectAreaPath.CloseFigure();
                            //Matrix x=new Matrix(
                            //Region region1 = new Region(selectAreaPath);
                            for (int i = 0; i < n1.Count; i++) {
                                float OffX = 0f;
                                float OffY = 0f;
                                bool ck = false;
                                Use use = (Use)n1[i];
                                if (use.GetAttribute("xlink:href").Contains("byq") || use.GetAttribute("xlink:href").Contains("pds")) {
                                    if (selectAreaPath.IsVisible(use.CenterPoint)) {
                                        if (use.GetAttribute("Deviceid") != "") {
                                            str_id = str_id + "'" + use.GetAttribute("Deviceid") + "',";
                                        }
                                    }
                                }
                                if (use.GetAttribute("xlink:href").Contains("Substation")) {
                                    //string strMatrix = use.GetAttribute("transform");
                                    //if (strMatrix != "")
                                    //{
                                    //    strMatrix = strMatrix.Replace("matrix(", "");
                                    //    strMatrix = strMatrix.Replace(")", "");
                                    //    string[] mat = strMatrix.Split(',');
                                    //    if (mat.Length > 5)
                                    //    {
                                    //        OffX = Convert.ToSingle(mat[4]);
                                    //        OffY = Convert.ToSingle(mat[5]);
                                    //    }
                                    //}
                                    //if (frmlar.getSelectedLayer().Contains(use.GetAttribute("layer"))) {
                                    //    ck = true;
                                    //}
                                    for (int j= 0; j< frmlar.GetSelectLayers().Count;j++ )
                                    {
                                        if ((frmlar.GetSelectLayers()[j] as Layer).ID==use.GetAttribute("layer"))
                                        {
                                            ck = true;
                                        }
                                    }
                                    PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href"));
                                    //if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY) && ck)
                                    if (selectAreaPath.IsVisible(use.CenterPoint) && ck) {
                                        if (use.GetAttribute("xlink:href").Contains("220")) {
                                            str220 = str220 + "'" + use.GetAttribute("Deviceid") + "',";
                                        }
                                        if (use.GetAttribute("xlink:href").Contains("110")) {
                                            str110 = str110 + "'" + use.GetAttribute("Deviceid") + "',";
                                        }
                                        if (use.GetAttribute("xlink:href").Contains("66")) {
                                            str66 = str66 + "'" + use.GetAttribute("Deviceid") + "',";
                                        }
                                    }
                                }
                            }
                            if (str220.Length > 1) {
                                str220 = str220.Substring(0, str220.Length - 1);
                            }
                            if (str110.Length > 1) {
                                str110 = str110.Substring(0, str110.Length - 1);
                            }
                            if (str66.Length > 1) {
                                str66 = str66.Substring(0, str66.Length - 1);
                            }
                            if (str_id.Length > 1) {
                                str_id = str_id.Substring(0, str_id.Length - 1);
                            }
                            glebeProperty _gle = new glebeProperty();
                            _gle.EleID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                            _gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;

                            IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle);
                            if (UseProList.Count > 0) {
                                _gle = UseProList[0];
                                _gle.LayerID = SvgDocument.currentLayer;
                                frmMainProperty f = new frmMainProperty();
                                f.strID = str_id;
                                f.InitData(_gle, str220, str110, str66);
                                PointF[] pn = (PointF[])((Polygon)xml1).Points.Clone();
                                ((Polygon)xml1).Transform.Matrix.TransformPoints(pn);
                                string s1 = "";
                                for (int p = 0; p < pn.Length; p++) {
                                    s1 = s1 + pn[p].X.ToString() + " " + pn[p].Y.ToString() + ",";
                                }
                                f.Str = s1;
                                f.ShowDialog();
                                if (f.checkBox1.Checked == false) {
                                    tlVectorControl1.SVGDocument.RootElement.RemoveChild(tlVectorControl1.SVGDocument.CurrentElement);
                                }
                                //tlVectorControl1.Refresh();
                            } else {
                                _gle = new glebeProperty();
                                _gle.LayerID = SvgDocument.currentLayer;
                                frmMainProperty f = new frmMainProperty();
                                f.strID = str_id;
                                f.InitData(_gle, str220, str110, str66);
                                PointF[] pn = (PointF[])((Polygon)xml1).Points.Clone();
                                ((Polygon)xml1).Transform.Matrix.TransformPoints(pn);
                                string s1 = "";
                                for (int p = 0; p < pn.Length; p++) {
                                    s1 = s1 + pn[p].X.ToString() + " " + pn[p].Y.ToString() + ",";
                                }
                                f.Str = s1;
                                f.ShowDialog();
                            }
                            //}
                        }

                    }
                    if (getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())) {

                        if (tlVectorControl1.SVGDocument.getRZBRatio() != "") {
                            rzb = tlVectorControl1.SVGDocument.getRZBRatio();
                        }

                        if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请先选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            string IsArea = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsArea");
                            if (IsArea != "") {

                                frmProperty f = new frmProperty();//地块属性
                                if (SelUseArea == "") { SelUseArea = "0"; }
                                f.XZ_bdz = XZ_bdz;
                                f.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer);
                                //f.ShowDialog();
            #if(!CITY)
                                //将其中心点保存在XML中
                                PointF p = TLMath.polyCentriod((XmlElement)tlVectorControl1.SVGDocument.CurrentElement);
                                string title = p.X.ToString() + "," + p.Y.ToString();
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("centrpoint", title);
                                if (progtype != "城市规划层") {
                                    f.IsReadonly = true;
                                }
            #endif
                                if (f.ShowDialog() == DialogResult.OK) {
                                    SVG_ENTITY ent = new SVG_ENTITY();
                                    if (f.IsCreate) {
                                        ent.SUID = Guid.NewGuid().ToString();
                                        ent.EleID = f.gPro.EleID;
                                        ent.layerID = f.gPro.LayerID;
                                        ent.MDATE = System.DateTime.Now;
                                        ent.NAME = f.gPro.UseID;
                                        ent.svgID = f.gPro.SvgUID;
                                        ent.TYPE = "polygon-dk";
                                        //ent.voltage = f.gPro.Voltage;
                                        Services.BaseService.Create<SVG_ENTITY>(ent);
                                    } else {
                                        ent.NAME = f.gPro.UseID;
                                        ent.layerID = f.gPro.LayerID;
                                        ent.MDATE = System.DateTime.Now;
                                        //ent.voltage = fl.Line.Voltage;
                                        Services.BaseService.Update<SVG_ENTITY>(ent);
                                    }
                                    if (f.gPro.ObligateField1 != "") {
                                        string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(f.gPro.ObligateField1)));
                                        color1 = "fill:" + color1 + ";";
                                        ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", color1);
                                        tlVectorControl1.UpdateProperty();
                                    }
                                    if (xzwcflag == "1" && f.bdzflag)
                                   {

                                          if (extsublist.Count > 0 && subandfhlist.Count > 0)
                                          {
                                              bool sfsflag=false;
                                              for(int m=0;m<polylist.Count;m++)
                                              {
                                               if((polylist[m] as XmlElement).GetAttribute("id")==f.gPro.EleID)
                                               {
                                                   sfsflag=true;
                                                   break;
                                               }

                                              }
                                              if (!sfsflag)
                                              {
                                                  MessageBox.Show("地块非选址的地块中 请重新选址!");
                                                  return;
                                              }
                                              try
                                              {
                                                List<Layer> layercol=  getxzxllayers(tlVectorControl1.SVGDocument.getLayerList());
                                                  if (layercol.Count>0)
                                                  {
                                                      FrmSelxzlayer frm=new FrmSelxzlayer();
                                                      frm.Layercol=layercol;
                                                      if (frm.ShowDialog()==DialogResult.OK)
                                                      {
                                                          string layerid=frm.sellayerid;
                                                           RebdzxzResult1(subandfhlist, extsublist, f.gPro, f.bdzzqname,layerid);
                                                      }
                                                      else
                                                        RebdzxzResult(subandfhlist, extsublist, f.gPro, f.bdzzqname);
                                                  }
                                                 // RebdzxzResult(subandfhlist, extsublist, f.gPro, f.bdzzqname);
                                              }
                                              catch (System.Exception ex)
                                              {
                                                  MessageBox.Show("请计算有问题 请重新计算!");
                                                  return;
                                              }

                                          }
                                          else
                                          {
                                              MessageBox.Show("选址变电站没有数据 请重新选址!");
                                              return;
                                          }

                                  }
                                 else
                                  {
                                      MessageBox.Show("请重新选址!");
                                     return;
                                  }

                                }
                            }
                        }
                    }
                    if (!Wjghboolflag) {
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                            string lineWidth = "2";
                            string IsLead = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsLead");
                            //if (IsLead != "")       //原先导线的属性添加情况

                            if (IsLead != "")       //修改后的导线的属性添加情况
                            {
                                XmlNodeList n11 = tlVectorControl1.SVGDocument.SelectNodes("svg/polygon [@IsArea='1']");
                                using (Graphics g = Graphics.FromHwnd(IntPtr.Zero)) {
                                    List<glebeProperty> glist = new List<glebeProperty>();
                                    for (int i = 0; i < n11.Count; i++) {
                                        IGraph graph1 = (IGraph)n11[i];
                                        GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                                        //path1.Transform(graph1.GraphTransform.Matrix);
                                        Region ef1 = new Region(path1);

                                        Polyline line = tlVectorControl1.SVGDocument.CurrentElement as Polyline;
                                        GraphicsPath gr2 = new GraphicsPath();
                                        //gr2.AddLines(pfs);
                                        gr2.AddPath(line.GPath, true);
                                        gr2.CloseFigure();
                                        Region region = new Region(gr2);
                                        ef1.Intersect(region);
                                        if (!ef1.GetBounds(g).IsEmpty) {
                                            glebeProperty gy = new glebeProperty();
                                            gy.EleID = graph1.ID;
                                            gy.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                            gy = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", gy);
                                            if (gy != null) {
                                                glebeType gt = new glebeType();
                                                gt.UID = gy.TypeUID;
                                                gt = (glebeType)Services.BaseService.GetObject("SelectglebeTypeByKey", gt);
                                                gy.TypeUID = gt.TypeName;
                                                glist.Add(gy);
                                            }
                                        }
                                    }
                                    DeviceHelper.glist = glist;
                                }
                                string dhx = xml1.GetAttribute("dhx_key");
                                if (dhx == "1" && checkEdit2.Checked == false) {
                                    frmDHXdlg d = new frmDHXdlg();
                                    d.uid = xml1.GetAttribute("id");
                                    d.Show();
                                    return;
                                }

                                PSPDEV obj = new PSPDEV();
                                string deviceid = xml1.GetAttribute("Deviceid");
                                DeviceHelper.pspflag = false;
                                DeviceHelper.Wjghflag = false;
                                if (string.IsNullOrEmpty(deviceid)) {
                                    string[] deviceType = new string[] { "05", "73", "75" };
                                    string xlwhere = " where SUID not in (";
                                    XmlNodeList lslist = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@Deviceid!=''] [@layer='" + SvgDocument.currentLayer + "']");
                                    for (int x1 = 0; x1 < lslist.Count; x1++) {
                                        XmlElement _node = lslist[x1] as XmlElement;
                                        xlwhere = xlwhere + "'" + _node.GetAttribute("Deviceid") + "',";
                                    }
                                    if (xlwhere.Length > 20) {
                                        xlwhere = xlwhere.Substring(0, xlwhere.Length - 1);
                                        xlwhere = xlwhere + ") and ";
                                    } else {
                                        xlwhere = "";
                                    }
                                    DeviceHelper.xlwhere = xlwhere;
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(Itop.Client.MIS.ProgUID, deviceType);
                                    DeviceHelper.xlwhere = "";
                                    if (obj is PSPDEV) {
                                        deviceid = ((PSPDEV)obj).SUID;
                                        xml1.SetAttribute("Deviceid", deviceid);
                                        obj.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        obj.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        obj.EleID = ((SvgElement)xml1).ID;
                                        Services.BaseService.Update<PSPDEV>(obj);

                                        //将其设备加入到计算方案中
                                        //获得方案名称
                                        PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                                        pd.ID = frmlar.FAID;
                                        pd = Services.BaseService.GetOneByKey<PSP_ELCPROJECT>(pd);
                                        if (pd != null) {
                                            bool operflag = false, dataflag = false;
                                            if (!string.IsNullOrEmpty(((PSPDEV)obj).OperationYear) && ((PSPDEV)obj).OperationYear.Length == 4 && pd.BelongYear.Length == 4) {
                                                if (Convert.ToInt32(((PSPDEV)obj).OperationYear) < Convert.ToInt32(pd.BelongYear)) {
                                                    operflag = true;
                                                }
                                            }
                                            if (!string.IsNullOrEmpty(((PSPDEV)obj).Date2) && ((PSPDEV)obj).Date2.Length == 4 && pd.BelongYear.Length == 4) {
                                                if (Convert.ToInt32(((PSPDEV)obj).Date2) > Convert.ToInt32(pd.BelongYear)) {
                                                    dataflag = true;
                                                }
                                            }
                                            if (operflag && dataflag) {
                                                PSP_ElcDevice elcDevice = new PSP_ElcDevice();
                                                elcDevice.DeviceSUID = deviceid;
                                                elcDevice.ProjectSUID = frmlar.FAID;
                                                elcDevice = UCDeviceBase.DataService.GetOneByKey<PSP_ElcDevice>(elcDevice);
                                                if (elcDevice == null) {
                                                    elcDevice = new PSP_ElcDevice();
                                                    elcDevice.DeviceSUID = deviceid;
                                                    elcDevice.ProjectSUID = frmlar.FAID;
                                                    UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice);
                                                }
                                            }

                                        }

                                    }
                                }
                                if (!string.IsNullOrEmpty(deviceid)) {
                                    DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                                    DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;

                                    obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                                    if (obj != null)//------------wwwMX
                                    {
                                        xml1.SetAttribute("info-name", ((PSPDEV)obj).Name);
                                        if (obj.Type == "05") {
                                            DeviceHelper.ShowDeviceDlg(DeviceType.XL, deviceid, false);
                                        }
                                        if (obj.Type == "01") {
                                            DeviceHelper.ShowDeviceDlg(DeviceType.MX, deviceid, false);
                                        }
                                        if (obj.Type == "73") {
                                            DeviceHelper.ShowDeviceDlg(DeviceType.PDXL, deviceid, false);
                                        }
                                        if (obj.Type == "75") {
                                            DeviceHelper.ShowDeviceDlg(DeviceType.LUX, deviceid, false);
                                        }
                                    }

                                    //***** ********添加FistNode和LastNode
                                    XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");

                                    foreach (XmlNode element in useList) {
                                        if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid"))) {
                                            string con = "WHERE SvgUID='" + (element as XmlElement).GetAttribute("Deviceid") + "'AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='01'";
                                            IList pspMX = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                            if (pspMX != null) {
                                                foreach (PSPDEV pspmx in pspMX) {
                                                    if (obj.IName == pspmx.Name) {
                                                        (xml1 as XmlElement).SetAttribute("FirstNode", (element as XmlElement).GetAttribute("id"));

                                                    } else if (obj.JName == pspmx.Name) {
                                                        (xml1 as XmlElement).SetAttribute("LastNode", (element as XmlElement).GetAttribute("id"));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                //**

                            }
                        }

                        if (xml1.GetAttribute("xlink:href").Contains("Substation") || xml1.GetAttribute("xlink:href").Contains("Power")) {//变电站属性
                            string lab = xml1.GetAttribute("xlink:href");

                            float x = 0f;
                            float y = 0f;
                            //判断电压等级
                            int dyinfo = Convert.ToInt32(getDY(lab));
                            x = ((Use)xml1).X;

                            y = ((Use)xml1).Y;

                            PointF p1 = new PointF(x, y);
                            PointF[] pnt = new PointF[1];
                            pnt[0] = p1;
                            Use temp = xml1.Clone() as Use;
                            temp.Transform.Matrix.TransformPoints(pnt);

                            LongLat templat = mapview.OffSetZero(-(int)(pnt[0].X * tlVectorControl1.ScaleRatio), -(int)(pnt[0].Y * tlVectorControl1.ScaleRatio));

                            string[] jd = templat.Longitude.ToString("####.####").Split('.');
                            int d1 = Convert.ToInt32(jd[0]);
                            string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.');
                            int f1 = Convert.ToInt32(df1[0]);
                            decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60;

                            string[] wd = templat.Latitude.ToString("####.####").Split('.');
                            int d2 = Convert.ToInt32(wd[0]);
                            string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.');
                            int f2 = Convert.ToInt32(df2[0]);
                            decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60;

                            string strjwd = "经纬度: " + d1.ToString() + "°" + f1.ToString() + "′" + m1.ToString("##.#") + "″," + d2.ToString() + "°" + f2.ToString() + "′" + m2.ToString("##.#") + "″";
                            object obj = null;
                            string deviceid = xml1.GetAttribute("Deviceid");
                            DeviceHelper.pspflag = false;
                            DeviceHelper.Wjghflag = false;
                            if (dyinfo >= 66) {
                                DeviceHelper.subflag = false;
                            } else
                                DeviceHelper.subflag = true;
                        Lab1://变电站、电源属性
                            if (string.IsNullOrEmpty(deviceid)) {
                                //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                    obj = DeviceHelper.SelectDevice(DeviceType.DY, Itop.Client.MIS.ProgUID);
                                    //if (obj == null)
                                    //{
                                    //    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    //    tlVectorControl1.Delete();
                                    //}
                                    if (obj is PSP_PowerSubstation_Info) {
                                        deviceid = ((PSP_PowerSubstation_Info)obj).UID;
                                        ((PSP_PowerSubstation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        //((PSP_PowerSubstation_Info)obj). = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        Services.BaseService.Update<PSP_PowerSubstation_Info>(((PSP_PowerSubstation_Info)obj));
                                        xml1.SetAttribute("Deviceid", deviceid);
                                        xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title);

                                        //获得方案名称
                                        PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                                        pd.ID = frmlar.FAID;
                                        pd = Services.BaseService.GetOneByKey<PSP_ELCPROJECT>(pd);
                                        if (pd != null) {
                                            string where = "where projectid='" + Itop.Client.MIS.ProgUID + "'and SvgUID='" + ((PSP_PowerSubstation_Info)obj).UID + "'";
                                            IList<PSPDEV> list = Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", where);
                                            //根据年份进行筛选
                                            if (!string.IsNullOrEmpty(pd.BelongYear))   //根据参与计算设备属于那一年先进行一次筛选
                                            {
                                                for (int i = 0; i < list.Count; i++) {
                                                    if (!string.IsNullOrEmpty((list[i] as PSPDEV).OperationYear) && (list[i] as PSPDEV).OperationYear.Length == 4 && pd.BelongYear.Length == 4) {
                                                        if (Convert.ToInt32((list[i] as PSPDEV).OperationYear) > Convert.ToInt32(pd.BelongYear)) {
                                                            list.RemoveAt(i);
                                                            i--;
                                                            continue;
                                                        }
                                                    }
                                                    if (!string.IsNullOrEmpty((list[i] as PSPDEV).Date2) && (list[i] as PSPDEV).Date2.Length == 4 && pd.BelongYear.Length == 4) {
                                                        if (Convert.ToInt32((list[i] as PSPDEV).Date2) < Convert.ToInt32(pd.BelongYear)) {
                                                            list.RemoveAt(i);
                                                            i--;
                                                            continue;
                                                        }
                                                    }
                                                }
                                            }

                                            foreach (PSPDEV pv in list) {
                                                //将其设备加入到计算方案中
                                                PSP_ElcDevice elcDevice = new PSP_ElcDevice();
                                                elcDevice.DeviceSUID = pv.SUID;
                                                elcDevice.ProjectSUID = frmlar.FAID;
                                                elcDevice = UCDeviceBase.DataService.GetOneByKey<PSP_ElcDevice>(elcDevice);
                                                if (elcDevice == null) {
                                                    elcDevice = new PSP_ElcDevice();
                                                    elcDevice.DeviceSUID = pv.SUID;
                                                    elcDevice.ProjectSUID = frmlar.FAID;
                                                    UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice);
                                                }
                                            }
                                        }
                                    }

                                    substation sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);

                                    }
                                } else {
                                    DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                                    DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;
                                    DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    //wwww
                                    string bdzwhere = " UID not in (";

                                    XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use [@Deviceid!=''] [@layer='" + SvgDocument.currentLayer + "']");

                                    for (int x2 = 0; x2 < useList.Count; x2++) {
                                        XmlElement _node = useList[x2] as XmlElement;
                                        bdzwhere = bdzwhere + "'" + _node.GetAttribute("Deviceid") + "',";
                                    }
                                    if (bdzwhere.Length > 13) {
                                        bdzwhere = bdzwhere.Substring(0, bdzwhere.Length - 1);
                                        bdzwhere = bdzwhere + ") and ";
                                    } else {
                                        bdzwhere = "";
                                    }

                                    DeviceHelper.bdzwhere = bdzwhere;
                                    obj = DeviceHelper.SelectDevice(DeviceType.BDZ, Itop.Client.MIS.ProgUID);
                                    DeviceHelper.bdzwhere = "";
                                    //if (obj == null)
                                    //{
                                    //    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    //    tlVectorControl1.Delete();
                                    //}
                                    if (obj is PSP_Substation_Info) {
                                        deviceid = ((PSP_Substation_Info)obj).UID;
                                        ((PSP_Substation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        ((PSP_Substation_Info)obj).EleID = tlVectorControl1.SVGDocument.CurrentElement.ID;

                                        ((PSP_Substation_Info)obj).AreaID = Itop.Client.MIS.ProgUID;

                                        Services.BaseService.Update<PSP_Substation_Info>(((PSP_Substation_Info)obj));
                                        xml1.SetAttribute("Deviceid", deviceid);
                                        xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title);

                                        //获得方案名称
                                        PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                                        pd.ID = frmlar.FAID;
                                        pd = Services.BaseService.GetOneByKey<PSP_ELCPROJECT>(pd);
                                        if (pd != null) {
                                            string where = "where projectid='" + Itop.Client.MIS.ProgUID + "'and SvgUID='" + ((PSP_Substation_Info)obj).UID + "'";
                                            IList<PSPDEV> list = Services.BaseService.GetList<PSPDEV>("SelectPSPDEVByCondition", where);
                                            //根据年份进行筛选
                                            if (!string.IsNullOrEmpty(pd.BelongYear))   //根据参与计算设备属于那一年先进行一次筛选
                                            {
                                                for (int i = 0; i < list.Count; i++) {
                                                    if (!string.IsNullOrEmpty((list[i] as PSPDEV).OperationYear) && (list[i] as PSPDEV).OperationYear.Length == 4 && pd.BelongYear.Length == 4) {
                                                        if (Convert.ToInt32((list[i] as PSPDEV).OperationYear) > Convert.ToInt32(pd.BelongYear)) {
                                                            list.RemoveAt(i);
                                                            i--;
                                                            continue;
                                                        }
                                                    }
                                                    if (!string.IsNullOrEmpty((list[i] as PSPDEV).Date2) && (list[i] as PSPDEV).Date2.Length == 4 && pd.BelongYear.Length == 4) {
                                                        if (Convert.ToInt32((list[i] as PSPDEV).Date2) < Convert.ToInt32(pd.BelongYear)) {
                                                            list.RemoveAt(i);
                                                            i--;
                                                            continue;
                                                        }
                                                    }
                                                }
                                            }

                                            foreach (PSPDEV pv in list) {
                                                //将其设备加入到计算方案中
                                                PSP_ElcDevice elcDevice = new PSP_ElcDevice();
                                                elcDevice.DeviceSUID = pv.SUID;
                                                elcDevice.ProjectSUID = frmlar.FAID;
                                                elcDevice = UCDeviceBase.DataService.GetOneByKey<PSP_ElcDevice>(elcDevice);
                                                if (elcDevice == null) {
                                                    elcDevice = new PSP_ElcDevice();
                                                    elcDevice.DeviceSUID = pv.SUID;
                                                    elcDevice.ProjectSUID = frmlar.FAID;
                                                    UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcDevice);
                                                }
                                            }
                                        }

                                        //return;
                                        //根据变站创建线路
                                        createLine(xml1, deviceid);
                                    }
                                    /*
                                    substation sb = new substation();
                                    sb.UID = ((PSP_Substation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null)
                                    {

                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_Substation_Info)obj).Flag == "2")
                                        {
                                            sb.ObligateField3 = "规划";
                                        }
                                        else if (((PSP_Substation_Info)obj).Flag == "1")
                                        {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    }
                                    else
                                    {
                                        sb = new substation();
                                        sb.UID = ((PSP_Substation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_Substation_Info)obj).Flag == "2")
                                        {
                                            sb.ObligateField3 = "规划";
                                        }
                                        else if (((PSP_Substation_Info)obj).Flag == "1")
                                        {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }*/
                                }
                            }
                            if (!string.IsNullOrEmpty(deviceid)) {
                                if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                    DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                                    DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;
                                    DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid);
                                    if (obj != null) {
                                        DeviceHelper.StartYear = startyear;
                                        //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                        if (DeviceHelper.ShowDeviceDlg(DeviceType.DY, deviceid, false)) {
                                            obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid);
                                            xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title);
                                        }
                                    } else {
                                        deviceid = ""; goto Lab1;
                                    }

                                    // re
                                    substation sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }
                                } else {
                                    obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                                    if (obj != null) {
                                        DeviceHelper.StartYear = startyear;
                                        //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                        if (DeviceHelper.ShowDeviceDlg(DeviceType.BDZ, deviceid, false)) {
                                            obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                                            xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title);
                                        }
                                    } else {
                                        deviceid = ""; goto Lab1;
                                    }
                                    substation sb = new substation();
                                    sb.UID = ((PSP_Substation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_Substation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_Substation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_Substation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }
                                }

                            }

                        }
                        if (xml1.GetAttribute("xlink:href").Contains("XL_GT_3") || xml1.GetAttribute("xlink:href").Contains("XL_GT_4")) {
                            frmInputNum num = new frmInputNum();
                            num.InputStr = xml1.GetAttribute("order");
                            num.ShowDialog();
                            xml1.SetAttribute("order", num.InputStrSEL);
                        }
                        if (xml1.GetAttribute("xlink:href").Contains("hwg") || xml1.GetAttribute("xlink:href").Contains("pds") ||
                            xml1.GetAttribute("xlink:href").Contains("fjx") || xml1.GetAttribute("xlink:href").Contains("kbs") ||
                            xml1.GetAttribute("xlink:href").Contains("byq") || xml1.GetAttribute("xlink:href").Contains("kg") ||
                             xml1.GetAttribute("xlink:href").Contains("gt")) {
                            //frmInputDialog n1 = new frmInputDialog();
                            //n1.InputStr = xml1.GetAttribute("info-name").ToString();
                            //if (n1.ShowDialog() == DialogResult.OK)
                            //{
                            //    xml1.SetAttribute("info-name", n1.InputStr);
                            //}
                            PSPDEV obj = new PSPDEV();
                            string deviceid = xml1.GetAttribute("Deviceid");
                            DeviceHelper.pspflag = false;
                            DeviceHelper.Wjghflag = false;
                            if (string.IsNullOrEmpty(deviceid)) {
                                if (xml1.GetAttribute("xlink:href").Contains("kbs")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.KBS, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("fjx")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.FZX, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("hwg")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.HWG, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("kg")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.ZSKG, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("pds")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.PDS, Itop.Client.MIS.ProgUID);
                                }
                                if (xml1.GetAttribute("xlink:href").Contains("byq")) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(Itop.Client.MIS.ProgUID, "51", "52");
                                }
                                //if (xml1.GetAttribute("xlink:href").Contains("gt"))
                                //{
                                //    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.GT, Itop.Client.MIS.ProgUID);
                                //}
                                if (obj is PSPDEV) {
                                    deviceid = ((PSPDEV)obj).SUID;
                                    xml1.SetAttribute("Deviceid", deviceid);
                                    obj.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    obj.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    // obj.EleID = ((SvgElement)xml1).ID;
                                    Services.BaseService.Update<PSPDEV>(obj);
                                }
                            }
                            if (!string.IsNullOrEmpty(deviceid)) {
                                DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                                DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;

                                obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                                if (obj != null)//------------wwwMX
                                {
                                    xml1.SetAttribute("info-name", ((PSPDEV)obj).Name);
                                    DeviceHelper.ShowDeviceDlg((DeviceType)int.Parse(obj.Type), deviceid, false);
                                    //if (obj.Type == "54")
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.KBS, deviceid, false);
                                    //}
                                    //if (obj.Type == "56")
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.HWG, deviceid, false);
                                    //}
                                    //if (obj.Type == "58")
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.FZX, deviceid, false);
                                    //}
                                    //if (obj.Type == "51" )
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.FZX, deviceid, false);
                                    //}
                                    //if (obj.Type == "52")
                                    //{
                                    //    DeviceHelper.ShowDeviceDlg(DeviceType.FZX, deviceid, false);
                                    //}
                                }
                            }

                        }
                        /* if (xml1.GetAttribute("xlink:href").Contains("kbs") || xml1.GetAttribute("xlink:href").Contains("hwg"))
                         {
                             //frmkbsProperty num = new frmkbsProperty();
                             //num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                             //num.ShowDialog();

                         }
                         if (xml1.GetAttribute("xlink:href").Contains("fjx"))
                         {
                             frmfjxProperty num = new frmfjxProperty();
                             num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                             num.ShowDialog();
                         }
                         if (xml1.GetAttribute("xlink:href").Contains("byq"))
                         {
                             frmbyqProperty num = new frmbyqProperty();
                             num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                             num.ShowDialog();
                         } */
                        if (xml1.GetAttribute("xlink:href").Contains("SB_GT")) {
                            string lineWidth = "2";

                            string Code = xltProcessor.GetCurrentLineCode();
                            string _len = xltProcessor.GetWholeLineLength(Code).ToString("#####.####");

                            frmLineProperty fl = new frmLineProperty();
                            fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement;
                            fl.InitData(Code, tlVectorControl1.SVGDocument.SvgdataUid, _len, SvgDocument.currentLayer);
                            if (fl.ShowDialog() == DialogResult.OK) {
                                //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;"
                                lineWidth = fl.LineWidth;
                                string styleValue = "";
                                if (fl.Line.ObligateField1 == "规划") {
                                    styleValue = "stroke-dasharray:4 4;stroke-width:" + lineWidth + ";";
                                } else {
                                    styleValue = "stroke-width:" + lineWidth + ";";
                                }

                                styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("style");
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", styleValue);

                                xltProcessor.SetWholeLineAttribute(Code, "style", styleValue);
                            }
                        }
                    }
                    #region 网架优化的属性输入

                    if (Wjghboolflag) {
                        checkwjghelement();
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                            string lineWidth = "2";
                            string IsLead = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsLead");
                            if (IsLead != "")       //修改后的导线的属性添加情况
                            {
                                PSPDEV obj = new PSPDEV();
                                string deviceid = xml1.GetAttribute("Deviceid");
                                DeviceHelper.pspflag = false;
                                DeviceHelper.Wjghflag = true;
                                DeviceHelper.wjghuid = ff.Key;
                                if (string.IsNullOrEmpty(deviceid)) {
                                    obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.XL, Itop.Client.MIS.ProgUID);
                                    if (obj == null) {
                                        tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                        tlVectorControl1.Delete();
                                    }
                                    if (obj is PSPDEV) {
                                        deviceid = ((PSPDEV)obj).SUID;
                                        xml1.SetAttribute("Deviceid", deviceid);
                                        obj.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        obj.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        obj.EleID = ((SvgElement)xml1).ID;
                                        Services.BaseService.Update<PSPDEV>((PSPDEV)obj);
                                    }
                                }
                                if (!string.IsNullOrEmpty(deviceid)) {
                                    obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                                    if (obj != null) {
                                        xml1.SetAttribute("info-name", ((PSPDEV)obj).Name);
                                        DeviceHelper.ShowDeviceDlg(DeviceType.XL, deviceid, false);
                                    }

                                    LineInfo li = new LineInfo();
                                    li.UID = obj.SUID;
                                    li = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByKey", li);
                                    if (li != null) {
                                        li.LayerID = SvgDocument.currentLayer;
                                        li.EleID = xml1.GetAttribute("id");
                                        li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        LineType lt = new LineType();
                                        lt.TypeName = li.Voltage.ToString() + "kV";
                                        lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt);
                                        li.ObligateField3 = obj.OperationYear;
                                        li.ObligateField2 = lt.Color;
                                        lineWidth = lt.ObligateField1;
                                        if (!string.IsNullOrEmpty(li.ObligateField3)) {
                                            if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) {
                                                li.ObligateField1 = "规划";
                                            } else
                                                li.ObligateField1 = "运行";
                                        }
                                        Services.BaseService.Update<LineInfo>(li);
                                    } else {
                                        li = new LineInfo();
                                        li.UID = obj.SUID;
                                        li.LineName = obj.Name;
                                        li.Length = obj.LineLength.ToString();
                                        li.LineType = obj.LineType;
                                        li.Voltage = obj.ReferenceVolt.ToString();
                                        li.EleID = xml1.GetAttribute("id");
                                        li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        LineType lt = new LineType();
                                        lt.TypeName = obj.ReferenceVolt.ToString() + "kV";
                                        lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt);
                                        li.ObligateField3 = obj.OperationYear;
                                        li.ObligateField2 = lt.Color;
                                        lineWidth = lt.ObligateField1;
                                        if (!string.IsNullOrEmpty(li.ObligateField3)) {
                                            if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) {
                                                li.ObligateField1 = "规划";
                                            } else
                                                li.ObligateField1 = "运行";
                                        }

                                        Services.BaseService.Create<LineInfo>(li);
                                    }

                                    string styleValue = "";
                                    if (li.ObligateField1 == "规划") {
                                        styleValue = "stroke-dasharray:" + ghType + ";stroke-width:" + lineWidth + ";";
                                    } else {
                                        styleValue = "stroke-width:" + lineWidth + ";";
                                    }
                                    //string aa= ColorTranslator.ToHtml(Color.Black);
                                    styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(li.ObligateField2)));
                                    SvgElement se = tlVectorControl1.SVGDocument.CurrentElement;
                                    se.RemoveAttribute("style");
                                    se.SetAttribute("style", styleValue);
                                    se.SetAttribute("info-name", li.LineName);
                                    //***** ********添加FistNode和LastNode
                                    XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");

                                    foreach (XmlNode element in useList) {
                                        if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid"))) {
                                            string con = "WHERE SvgUID='" + (element as XmlElement).GetAttribute("Deviceid") + "'AND ProjectID = '" + Itop.Client.MIS.ProgUID + "'" + "AND Type='01'";
                                            IList pspMX = Services.BaseService.GetList("SelectPSPDEVByCondition", con);
                                            if (pspMX != null) {
                                                foreach (PSPDEV pspmx in pspMX) {
                                                    if (obj.IName == pspmx.Name) {
                                                        (xml1 as XmlElement).SetAttribute("FirstNode", (element as XmlElement).GetAttribute("id"));

                                                    } else if (obj.JName == pspmx.Name) {
                                                        (xml1 as XmlElement).SetAttribute("LastNode", (element as XmlElement).GetAttribute("id"));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                //**

                            }
                        }

                        if (xml1.GetAttribute("xlink:href").Contains("Substation") || xml1.GetAttribute("xlink:href").Contains("Power")) {
                            string lab = xml1.GetAttribute("xlink:href");

                            float x = 0f;
                            float y = 0f;

                            x = ((Use)xml1).X;

                            y = ((Use)xml1).Y;

                            PointF p1 = new PointF(x, y);
                            PointF[] pnt = new PointF[1];
                            pnt[0] = p1;
                            Use temp = xml1.Clone() as Use;
                            temp.Transform.Matrix.TransformPoints(pnt);

                            LongLat templat = mapview.OffSetZero(-(int)(pnt[0].X * tlVectorControl1.ScaleRatio), -(int)(pnt[0].Y * tlVectorControl1.ScaleRatio));

                            string[] jd = templat.Longitude.ToString("####.####").Split('.');
                            int d1 = Convert.ToInt32(jd[0]);
                            string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.');
                            int f1 = Convert.ToInt32(df1[0]);
                            decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60;

                            string[] wd = templat.Latitude.ToString("####.####").Split('.');
                            int d2 = Convert.ToInt32(wd[0]);
                            string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.');
                            int f2 = Convert.ToInt32(df2[0]);
                            decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60;

                            string strjwd = "经纬度: " + d1.ToString() + "°" + f1.ToString() + "′" + m1.ToString("##.#") + "″," + d2.ToString() + "°" + f2.ToString() + "′" + m2.ToString("##.#") + "″";
                            object obj = null;
                            string deviceid = xml1.GetAttribute("Deviceid");
                            DeviceHelper.pspflag = false;
                            DeviceHelper.Wjghflag = true;
                            if (string.IsNullOrEmpty(deviceid)) {
                                //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                    obj = DeviceHelper.SelectDevice(DeviceType.DY, Itop.Client.MIS.ProgUID);
                                    if (obj == null) {
                                        tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                        tlVectorControl1.Delete();
                                    }
                                    if (obj is PSP_PowerSubstation_Info) {
                                        deviceid = ((PSP_PowerSubstation_Info)obj).UID;
                                        ((PSP_PowerSubstation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;

                                        Services.BaseService.Update<PSP_PowerSubstation_Info>(((PSP_PowerSubstation_Info)obj));
                                        xml1.SetAttribute("Deviceid", deviceid);
                                    }
                                    substation sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }
                                } else {
                                    obj = DeviceHelper.SelectDevice(DeviceType.BDZ, Itop.Client.MIS.ProgUID);
                                    if (obj == null) {
                                        tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                        tlVectorControl1.Delete();
                                    }
                                    if (obj is PSP_Substation_Info) {
                                        deviceid = ((PSP_Substation_Info)obj).UID;
                                        ((PSP_Substation_Info)obj).LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        ((PSP_Substation_Info)obj).EleID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                                        Services.BaseService.Update<PSP_Substation_Info>(((PSP_Substation_Info)obj));
                                        xml1.SetAttribute("Deviceid", deviceid);

                                    }
                                    substation sb = new substation();
                                    sb.UID = ((PSP_Substation_Info)obj).UID;
                                    sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                    if (sb != null) {

                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        sb.EleID = xml1.GetAttribute("id");
                                        if (((PSP_Substation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Update<substation>(sb);
                                    } else {
                                        sb = new substation();
                                        sb.UID = ((PSP_Substation_Info)obj).UID;
                                        sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        sb.EleID = xml1.GetAttribute("id");
                                        sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                        if (((PSP_Substation_Info)obj).Flag == "2") {
                                            sb.ObligateField3 = "规划";
                                        } else if (((PSP_Substation_Info)obj).Flag == "1") {
                                            sb.ObligateField3 = "现行";
                                        }
                                        Services.BaseService.Create<substation>(sb);
                                    }
                                }
                            }
                            if (!string.IsNullOrEmpty(deviceid)) {
                                if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                    obj = DeviceHelper.GetDevice<PSP_PowerSubstation_Info>(deviceid);
                                    if (obj != null) {
                                        xml1.SetAttribute("info-name", ((PSP_PowerSubstation_Info)obj).Title);
                                        //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                        DeviceHelper.ShowDeviceDlg(DeviceType.DY, deviceid, false);
                                    }

                                } else {
                                    obj = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                                    if (obj != null) {
                                        xml1.SetAttribute("info-name", ((PSP_Substation_Info)obj).Title);
                                        //XmlElement n1 = tlVectorControl1.SVGDocument.SelectSingleNode("/text[@ParentUID='" + xml1.GetAttribute("id") + "']");
                                        DeviceHelper.ShowDeviceDlg(DeviceType.BDZ, deviceid, false);
                                    }

                                }

                            }

                        }
                        if (xml1.GetAttribute("xlink:href").Contains("XL_GT_3") || xml1.GetAttribute("xlink:href").Contains("XL_GT_4")) {
                            frmInputNum num = new frmInputNum();
                            num.InputStr = xml1.GetAttribute("order");
                            num.ShowDialog();
                            xml1.SetAttribute("order", num.InputStrSEL);
                        }

                        //if (xml1.GetAttribute("xlink:href").Contains("kbs") || xml1.GetAttribute("xlink:href").Contains("hwg"))
                        //{
                        //    frmkbsProperty num = new frmkbsProperty();
                        //    num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        //    num.ShowDialog();
                        //}
                        //if (xml1.GetAttribute("xlink:href").Contains("fjx"))
                        //{
                        //    frmfjxProperty num = new frmfjxProperty();
                        //    num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        //    num.ShowDialog();
                        //}
                        //if (xml1.GetAttribute("xlink:href").Contains("byq"))
                        //{
                        //    frmbyqProperty num = new frmbyqProperty();
                        //    num.InitData(((SvgElement)xml1).ID, tlVectorControl1.SVGDocument.SvgdataUid, tlVectorControl1.SVGDocument.CurrentLayer.ID);
                        //    num.ShowDialog();
                        //}
                        if (xml1.GetAttribute("xlink:href").Contains("SB_GT")) {
                            string lineWidth = "2";

                            string Code = xltProcessor.GetCurrentLineCode();
                            string _len = xltProcessor.GetWholeLineLength(Code).ToString("#####.####");

                            frmLineProperty fl = new frmLineProperty();
                            fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement;
                            fl.InitData(Code, tlVectorControl1.SVGDocument.SvgdataUid, _len, SvgDocument.currentLayer);
                            if (fl.ShowDialog() == DialogResult.OK) {
                                //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;"
                                lineWidth = fl.LineWidth;
                                string styleValue = "";
                                if (fl.Line.ObligateField1 == "规划") {
                                    styleValue = "stroke-dasharray:4 4;stroke-width:" + lineWidth + ";";
                                } else {
                                    styleValue = "stroke-width:" + lineWidth + ";";
                                }

                                styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("style");
                                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", styleValue);

                                xltProcessor.SetWholeLineAttribute(Code, "style", styleValue);
                            }
                        }
                    }
                    #endregion
                }
                if (e.ClickedItem.Text == "移动") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    XmlElement xmln = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    frmMove fm = new frmMove();
                    PointF pf11 = ((Use)xmln).CenterPoint;
                    LongLat temp = mapview.ParseToLongLat((int)pf11.X, (int)pf11.Y);
                    string[] jd = temp.Longitude.ToString("####.####").Split('.');
                    int d1 = Convert.ToInt32(jd[0]);
                    string[] df1 = Convert.ToString(Convert.ToDecimal("0." + jd[1]) * 60).Split('.');
                    int f1 = Convert.ToInt32(df1[0]);
                    decimal m1 = Convert.ToDecimal("0." + df1[1]) * 60;

                    string[] wd = temp.Latitude.ToString("####.####").Split('.');
                    int d2 = Convert.ToInt32(wd[0]);
                    string[] df2 = Convert.ToString(Convert.ToDecimal("0." + wd[1]) * 60).Split('.');
                    int f2 = Convert.ToInt32(df2[0]);
                    decimal m2 = Convert.ToDecimal("0." + df2[1]) * 60;
                    strj1 = d1.ToString();
                    strw1 = f1.ToString();
                    strd1 = m1.ToString();
                    strj2 = d2.ToString();
                    strw2 = f2.ToString();
                    strd2 = m2.ToString();
                    fm.Init(strj1, strw1, strd1, strj2, strw2, strd2);
                    if (fm.ShowDialog() == DialogResult.OK) {
                        string strValue = fm.StrValue;
                        string[] str = strValue.Split(',');
                        string[] JWD1 = str[0].Split(' ');
                        decimal J1 = Convert.ToDecimal(JWD1[0]);
                        decimal W1 = Convert.ToDecimal(JWD1[1]);
                        decimal D1 = Convert.ToDecimal(JWD1[2]);
                        string[] JWD2 = str[1].Split(' ');
                        decimal J2 = Convert.ToDecimal(JWD2[0]);
                        decimal W2 = Convert.ToDecimal(JWD2[1]);
                        decimal D2 = Convert.ToDecimal(JWD2[2]);

                        decimal JD = J1 + W1 / 60 + D1 / 3600;
                        decimal WD = J2 + W2 / 60 + D2 / 3600;

                        PointF pf1 = mapview.ParseToPoint(JD, WD);

                        PointF p1 = ((Use)xmln).CenterPoint;

                        SvgElement e1 = xmln as SvgElement;
                        Matrix matrix2 = ((IGraph)e1).GraphTransform.Matrix.Clone();
                        Matrix matrix3 = tlVectorControl1.DrawArea.CoordTransform.Clone();
                        matrix3.Invert();
                        matrix2.Multiply(matrix3, MatrixOrder.Append);
                        matrix2.Invert();
                        PointF[] pfArray1 = new PointF[] { new PointF(pf1.X / tlVectorControl1.ScaleRatio, pf1.Y / tlVectorControl1.ScaleRatio), p1 };
                        matrix2.TransformPoints(pfArray1);

                        float single1 = pfArray1[0].X - pfArray1[1].X;
                        float single2 = pfArray1[0].Y - pfArray1[1].Y;

                        Matrix matrix6 = ((IGraph)e1).Transform.Matrix.Clone();
                        if (e1.SvgAttributes.ContainsKey("transform")) {
                            Matrix matrix7 = ((Matrix)e1.SvgAttributes["transform"]).Clone();
                            matrix7.Invert();
                            matrix6.Multiply(matrix7, MatrixOrder.Append);
                        }
                        Matrix matrix5 = new Matrix();
                        matrix5.Translate(single1, single2);
                        Matrix matrix8 = ((IGraph)e1).Transform.Matrix.Clone();
                        matrix8.Multiply(matrix5);
                        matrix6.Invert();
                        matrix6.Multiply(matrix8, MatrixOrder.Append);
                        Transf tf = new Transf();
                        tf.setMatrix(matrix6);
                        (xmln as Use).Transform = tf;

                    }
                }
                if (e.ClickedItem.Text == "接线图") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    ParentUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    Save();
                    ParentUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    SVGFILE svg_temp = new SVGFILE();
                    //XmlElement xml1 = ((XmlElement)(e.Elements[0]));xml1.GetAttribute("id");
                    svg_temp.SUID = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("id");
                    svg_temp.FILENAME = getBdzName(svg_temp.SUID);// ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("info-name");
                    string strWhere = string.Format("suid='{0}' or filename='{1}' ", svg_temp.SUID, svg_temp.FILENAME);
                    IList svglist = Services.BaseService.GetList("SelectSVGFILEByWhere", strWhere);
                    OpenJXT(svglist, svg_temp);
                    //frmlar.SymbolDoc = tlVectorControl1.SVGDocument;
                    //frmlar.Progtype = MapType;
                    //frmlar.InitData();
                    //JxtBar();
                }
                if (e.ClickedItem.Text == "打开") {
                    if (tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRelating UseRel = new UseRelating();
                    UseRel.UseID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                    IList<UseRelating> UseRelList = Services.BaseService.GetList<UseRelating>("SelectUseRelatingByUseID", UseRel);
                    if (UseRelList.Count < 1) {
                        MessageBox.Show("选择的地块还没有关联到其他地图,请先设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRel = UseRelList[0];
                    SVGFILE svgFile = new SVGFILE();
                    svgFile.SUID = UseRel.LinkUID;
                    IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile);
                    if (svgList.Count < 1) {
                        MessageBox.Show("被关联的地图已经被删除,请重新设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    svgFile = (SVGFILE)svgList[0];
                    //SvgDocument doc = new SvgDocument();

                    if (!string.IsNullOrEmpty(svgFile.SVGDATA)) {
                        //doc.LoadXml(svgFile.SVGDATA);
                        ctlfile_OnOpenSvgDocument(sender, svgFile.SUID);
                    }

                }
                if (e.ClickedItem.Text == "区域打印") {
                    PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                    frmPrinter dlg = new frmPrinter();
                    dlg.printHelper = ph;
                    dlg.ShowDialog();
                    return;
                    ArrayList idlist = new ArrayList();
                    ArrayList symlist = new ArrayList();

                    SvgDocument _doc = new SvgDocument();

                    Graph poly1 = tlVectorControl1.SVGDocument.CurrentElement as Graph;
                    if (poly1 == null || poly1.GetAttribute("id") == "svg") {
                        return;
                    }

                    GraphicsPath gr1 = new GraphicsPath();
                    //gr1.AddRectangle(TLMath.getRectangle(poly1));
                    gr1.AddPolygon(TLMath.getPolygonPoints(poly1));
                    //gr1.CloseFigure();
                    gr1 = (GraphicsPath)poly1.GPath.Clone();
                    gr1.Transform((poly1 as IGraph).Transform.Matrix);

                    RectangleF ef1 = gr1.GetBounds();
                    ef1 = PathFunc.GetBounds(gr1);
                    StringBuilder svgtxt = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\"" + ef1.Width + "\" height=\"" + ef1.Height + "\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">");

                    XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("defs");
                    if (nlist.Count > 0) {
                        XmlNode node = nlist[0];
                        svgtxt.AppendLine(node.OuterXml);
                    }
                    SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();// mouseAreaControl.PicturePanel.ElementList.GetEnumerator();
                    while (enumerator1.MoveNext()) {
                        IGraph graph1 = (IGraph)enumerator1.Current;

                        GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                        //path1.Transform(graph1.GraphTransform.Matrix);
                        //path1.Transform(graph1.Transform.Matrix);
                        // RectangleF ef2 = path1.GetBounds();// PathFunc.GetBounds(path1);

                        //for (int n = 0; n < selCol.Count - 1; n++)
                        //{
                        //    //_doc.AppendChild((XmlNode)selCol[n]);
                        //    svgtxt = svgtxt + ((XmlElement)selCol[n]).OuterXml + "\r\n";
                        //}
                        if (!graph1.Visible || !graph1.DrawVisible || !graph1.Layer.Visible) continue;

                        GraphicsPath path2 = (GraphicsPath)graph1.GPath.Clone();
                        path2.Transform(graph1.Transform.Matrix);
                        RectangleF ef2 = PathFunc.GetBounds(path2);

                        if (ef1.Contains(ef2) || RectangleF.Intersect(ef1, ef2) != RectangleF.Empty) {

                            SvgElement ele = (SvgElement)graph1;
                            svgtxt.AppendLine(ele.OuterXml);
                            //tlVectorControl1.SVGDocument.AddSelectElement(graph1);
                            if (graph1 is Use) {
                                //PointF offset = TLMath.getUseOffset(((XmlElement)graph1).GetAttribute("xlink:href"));
                                //if (ef1.Contains(new PointF(((Use)graph1).X + offset.X, ((Use)graph1).Y + offset.Y))) {
                                //SvgElement ele = (SvgElement)graph1;
                                //svgtxt.AppendLine(ele.OuterXml);

                                string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                                if (!symlist.Contains(symid)) {
                                    symlist.Add(symid);
                                }
                                //}
                            }
                            if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") {
                                string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                                if (IsLead != "") {
                                    if (ef1.Contains(ef2)) {
                                        idlist.Add(graph1.ID);
                                    }
                                }
                            }
                        }
                    }
                    symlist = ResetList(symlist);
                    svgtxt.AppendLine("</svg>");
                    _doc.LoadXml(svgtxt.ToString());
                    _doc.SvgdataUid = tlVectorControl1.SVGDocument.SvgdataUid;
                    frmPrintF pri = new frmPrintF();
                    pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid);
                    if (pri.ShowDialog() == DialogResult.OK) {
                        frmSubPrint s = new frmSubPrint();
                        s.Vector = tlVectorControl1;
                        s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist);
                        s.Open(_doc, ef1);
                        s.Show();
                    }
                }
                if (e.ClickedItem.Text == "分类统计报表") {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    IGraph poly1 = (IGraph)tlVectorControl1.SVGDocument.CurrentElement;
                    frmPloyPrint p = new frmPloyPrint();

                    p.InitDate(poly1.ID, tlVectorControl1.SVGDocument.SvgdataUid);
                    p.ShowDialog();
                }
                if (e.ClickedItem.Text == "保存图片") {
                    if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement") {

                        PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                        frmImgManager frm = new frmImgManager();
                        frm.Pic = ph.getImage();
                        frm.ShowDialog();
                    }
                }

            } catch (Exception e1) {
                //MessageBox.Show(e1.Message);
            }
            if (e.ClickedItem.Text == "三维变电站") {
                try {
                    string strid = tlVectorControl1.SVGDocument.CurrentElement.ID;
                    substation s = new substation();
                    s.EleID = strid;
                    s.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    s = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", s);
                    ProcessStartInfo p = new ProcessStartInfo();
                    p.FileName = Application.StartupPath + "\\" + s.EleName + "\\bdz.exe";
                    p.WorkingDirectory = Application.StartupPath + "\\" + s.EleName;
                    Process.Start(p);
                } catch (Exception e1) { }
            }
            if (e.ClickedItem.Text == "清除关联") {
                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("Deviceid");
            }
            if (e.ClickedItem.Text == "更新关联变电站") {
                UpdateLine();
            }
            if (e.ClickedItem.Text == "删除") {
                Delete();
            }
        }
Example #16
0
        private void bbteditfa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            TreeListNode node = treeList1.FocusedNode;
            if (node != null)
            {
                string suid = node["SUID"].ToString();
                if (suid.Contains("FA"))
                {
                    frmInput dlg = new frmInput();
                    dlg.Text = "������Ϣ";
                    dlg.hide = true;
                    dlg.id = symbolDoc.SvgdataUid;
                    dlg.symbolDoc = symbolDoc;
                    dlg.InputString = node["NAME"].ToString();
                    dlg.InputType = progtype;

                    DialogResult d = dlg.ShowDialog(this);
                    if (d == DialogResult.OK)
                    {
                        SVG_LAYER temp = new SVG_LAYER();
                        temp.SUID = suid;
                        temp.svgID = symbolDoc.SvgdataUid;
                        SVG_LAYER lar = (SVG_LAYER)Services.BaseService.GetObject("SelectSVG_LAYERByKey", temp);
                        // lar.YearID = dlg.list[1].ToString();
                        lar.NAME = dlg.InputString;

                        Services.BaseService.Update<SVG_LAYER>(lar);
                        PSP_ELCPROJECT pe = new PSP_ELCPROJECT();
                        pe.ID = lar.SUID;
                        pe = Services.BaseService.GetOneByKey<PSP_ELCPROJECT>(pe);
                        if (pe != null)
                        {
                            pe.Name = dlg.InputString;
                            Services.BaseService.Update<PSP_ELCPROJECT>(pe);
                        }
                        treeList1.FocusedNode.SetValue("NAME", dlg.InputString);
                        treeList1.Refresh();
                        //InitData();
                    }
                    if (d == DialogResult.Retry)
                    {
                        if (dlg.list.Count > 1)
                        {

                            SVG_LAYER temp = new SVG_LAYER();
                            temp.SUID = suid;
                            temp.svgID = symbolDoc.SvgdataUid;
                            SVG_LAYER lar = (SVG_LAYER)Services.BaseService.GetObject("SelectSVG_LAYERByKey", temp);
                            lar.YearID = dlg.list[1].ToString();
                            Services.BaseService.Update<SVG_LAYER>(lar);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("��ѡ�з�����", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
        }
Example #17
0
        private void bbtaddfa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frmInput dlg = new frmInput();
            dlg.Text = "������Ϣ";
            dlg.InputType = progtype;
            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                if (Layer.CkLayerExist(dlg.InputString, this.SymbolDoc))
                {
                    MessageBox.Show("�ĵ����Ѿ�����ͬ��������", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                //Layer lar = Layer.CreateNew(dlg.InputString, this.SymbolDoc);
                //lar.SetAttribute("layerType", dlg.InputType);
                //if (ilist.Count > 0)
                //{
                //    lar.SetAttribute("ParentID", ilist[0].ToString());
                //}
                addflag = true;
                //this.checkedListBox1.Items.Add(lar, true);
                //checkedListBox1.SelectedIndex = checkedListBox1.Items.Count - 1;
                DataTable dt = treeList1.DataSource as DataTable;
                SVG_LAYER _svg = new SVG_LAYER() { SUID = Guid.NewGuid().ToString().Substring(0, 10) };
                //if (treeList1.FocusedNode != null)
                {
                    _svg.NAME = dlg.InputString;
                    _svg.SUID = "FA" + _svg.SUID;
                    //_svg.ParentID = treeList1.FocusedNode["ParentID"].ToString();
                    _svg.YearID = ilist[0].ToString();
                    _svg.svgID = symbolDoc.SvgdataUid;
                    //_svg.OrderID = int.Parse(treeList1.FocusedNode["OrderID"].ToString()) + 1;
                    _svg.MDATE = DateTime.Now;
                    Services.BaseService.Create<SVG_LAYER>(_svg);
                    //�������㷽��
                    PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                    pd.ID = _svg.SUID;
                    pd.Name = dlg.InputString;
                    pd.FileType = "����";
                    pd.Class = System.DateTime.Now.ToString();
                    if (!string.IsNullOrEmpty(StrYear) && StrYear.Length == 4)
                    {
                        pd.BelongYear = StrYear;
                    }

                    pd.ProjectID = Itop.Client.MIS.ProgUID;
                    Services.BaseService.Create<PSP_ELCPROJECT>(pd);
                }
                DataRow row = dt.NewRow();
                dt.Rows.Add(DataConverter.ObjectToRow(_svg, row));
            }
        }
Example #18
0
        public void Allshort(string projectSUID, string projectid, int dulutype, double ratecaplity)
        {
            int cishu = 0;           //��¼�ڶ��ٴγ����ڴ�����
            try
            {

                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);

                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.IName='" + pspDev.Name + "'OR PSPDEV.JName='" + pspDev.Name + "') AND PSPDEV.KSwitchStatus = '0'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.IName='" + pspDev.Name + "'OR PSPDEV.JName='" + pspDev.Name + "'OR PSPDEV.KName='" + pspDev.Name + "')AND PSPDEV.KSwitchStatus = '0' 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((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, 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)
                        {
                            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);
                            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
                            {
                                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
                            {
                                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();

                        }
                    }

                }
                //д�뱨����
                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 < muxiannum - 1; 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 < muxiannum - 1; 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();

            }
            catch (System.Exception ex)
            {
                MessageBox.Show("���ݴ���������������ȫ���ٲ���", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
Example #19
0
        /// <summary>
        /// ˢ�±���е�����
        /// </summary>
        /// <returns>ture:�ɹ�  false:ʧ��</returns>
        public bool RefreshData1(PSP_ELCPROJECT proj)
        {
            try
            {
                string filepath = "";
                // IList<Substation_Info> list = UCDeviceBase.DataService.GetList<Substation_Info>("SelectSubstation_InfoByFlag",flags1);
                string con = " AreaID = '" + Itop.Client.MIS.ProgUID + "' AND UID IN (SELECT PSPDEV.SVGUID FROM PSPDEV, PSP_ELCDEVICE WHERE  PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + proj.ID+ "'AND Type='01')";

                IList<Substation_Info> list = UCDeviceBase.DataService.GetList<Substation_Info>("SelectSubstation_InfoByCon", con);
                for (int i = 0; i < list.Count; i++)
                {
                    Substation_Info sb = (Substation_Info)list[i];
                    if (Convert.ToInt32(sb.L2) != 0 && sb.L2 != null)
                    {
                        sb.L10 = Convert.ToDouble(Convert.ToDouble(sb.L9) / sb.L2 * 100);
                        //sb.GetType().GetProperty("L10").SetValue(sb, LL10, null);

                    }
                    else { sb.L10 = 0; }

                }
                if (xmlflag == "guihua")
                    filepath = Path.GetTempPath() + "\\" + Path.GetFileName("SubstationGuiHua.xml");
                else
                {
                    filepath = Path.GetTempPath() + "\\" + Path.GetFileName("SubstationLayOut11.xml");
                }

                if (File.Exists(filepath))
                {
                    this.bandedGridView1.RestoreLayoutFromXml(filepath);
                }
                this.gridControl.DataSource = list;
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return false;
            }

            return true;
        }
Example #20
0
 public void Initdata(bool flag)
 {
     pspflag = flag;
     PSP_ELCPROJECT pr = new PSP_ELCPROJECT();
     pr.ProjectID = this.ProjectID;
     if (flag)
     {
         pr.FileType = "短路";
     }
     else
         pr.FileType="潮流";
     IList list = Services.BaseService.GetList("SelectPSP_ELCPROJECTByProjectIDandfiletype", pr);
     dataSvg= Itop.Common.DataConverter.ToDataTable(list, typeof(PSP_ELCPROJECT));
     gridControl1.DataSource = dataSvg;
 }
Example #21
0
 public void Initdata()
 {
     dt.Clear();
     dt.Columns.Add("ID");
     dt.Columns.Add("Name");
     dt.Columns.Add("Class");
     dt.Columns.Add("FileType");
     dt.Columns.Add("Check",typeof(bool));
     PSP_ELCPROJECT pr = new PSP_ELCPROJECT();
     pr.ProjectID = this.ProjectID;
     IList list = Services.BaseService.GetList("SelectPSP_ELCPROJECTList", pr);
     foreach(PSP_ELCPROJECT pe in list)
     {
         DataRow row = dt.NewRow();
         row["ID"] = pe.ID;
         row["Name"] = pe.Name;
         row["Class"] = pe.Class;
         row["FileType"] = pe.FileType;
         row["Check"] = false;
         dt.Rows.Add(row);
     }
     gridControl1.DataSource = dt;
 }
Example #22
0
        private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            DataRow node =gridView1.GetDataRow(gridView1.FocusedRowHandle);
            if (node != null)
            {
                string id = node["ID"].ToString();
                PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                pd.ID = id;
                pd.Name = node["Name"].ToString();
                pd.Class = node["Class"].ToString();
                pd.FileType = node["FileType"].ToString();
                pd.BelongYear = node["BelongYear"].ToString();
                pd.ProjectID = node["ProjectID"].ToString();
                frmNewProject frmprojectDLG = new frmNewProject();
                if (pd.FileType == "潮流")
                {
                    frmprojectDLG.flag = false;
                }
                else
                {
                    frmprojectDLG.flag = true;
                }

                frmprojectDLG.Name = pd.Name;
                frmprojectDLG.FileType = pd.FileType;
                frmprojectDLG.BelongYear = pd.BelongYear;
                frmprojectDLG.init();
                if (frmprojectDLG.ShowDialog() == DialogResult.OK)
                {
                    node["Name"] = frmprojectDLG.Name;
                    pd.Name = frmprojectDLG.Name;
                    pd.FileType = frmprojectDLG.FileType;
                    pd.BelongYear = frmprojectDLG.BelongYear;
                    node["BelongYear"] = frmprojectDLG.BelongYear;
                    UCDeviceBase.DataService.Update("UpdatePSP_ELCPROJECT", pd);
                    SVGFILE svgFile = new SVGFILE();
                    svgFile.SUID = pd.ID;
                    svgFile = (SVGFILE)Services.BaseService.GetObject("SelectSVGFILEByKey", svgFile);
                    if (svgFile != null)
                    {
                        svgFile.FILENAME = pd.Name;
                        UCDeviceBase.DataService.Update<SVGFILE>(svgFile);

                    }

                }
            }
        }
 private void barCopy_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     //TreeListNode node = treeList1.FocusedNode;
     if (string.IsNullOrEmpty(strID))
     {
         MessageBox.Show("����ѡ��������㷽����", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     } else {
         if (MessageBox.Show("�Ƿ��Ʒ�����" + parentobj.Name,"��ʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
         {
             string name = "����" + parentobj.Name.ToString();
             string strC = " Name like '" + name + "%'";
             IList list1 = UCDeviceBase.DataService.GetList("SelectPSP_ELCPROJECTByWhere", strC);
             if (list1.Count>0)
             {
                 name = "����" + parentobj.Name + "-" + list1.Count.ToString();
             }
             string strCon = " WHERE ProjectSUID = '" + parentobj.ID + "'";
             IList list = UCDeviceBase.DataService.GetList("SelectPSP_ElcDeviceByCondition", strCon);
             PSP_ELCPROJECT elcPro = new PSP_ELCPROJECT();
             elcPro.FileType = parentobj.FileType;
             elcPro.Name = name;
             elcPro.ProjectID = Itop.Client.MIS.ProgUID;
             elcPro.Class = System.DateTime.Now.ToString();
             DataRow row = datatable.NewRow();
             Itop.Common.DataConverter.ObjectToRow(elcPro, row);
             datatable.Rows.Add(row);
             UCDeviceBase.DataService.Create<PSP_ELCPROJECT>(elcPro);
             SVGFILE svg = UCDeviceBase.DataService.GetOneByKey<SVGFILE>(parentobj.ID);
             SVGFILE svgNew = new SVGFILE();
             svgNew.SUID = elcPro.ID;
             svgNew.FILENAME = elcPro.Name;
             svgNew.SVGDATA = svg.SVGDATA;
             UCDeviceBase.DataService.Create<SVGFILE>(svgNew);
             foreach (PSP_ElcDevice elcDEV in list) {
                 PSP_ElcDevice elcElement = new PSP_ElcDevice();
                 elcElement.ProjectSUID = elcPro.ID;
                 elcElement.DeviceSUID = elcDEV.DeviceSUID;
                 UCDeviceBase.DataService.Create<PSP_ElcDevice>(elcElement);
             }
         }
         return;
     }
 }
        protected override void Edit()
        {
            TreeListNode node = treeList1.FocusedNode;
            if (node != null) {
                string id = node["ID"].ToString();
                PSP_ELCPROJECT pd = new PSP_ELCPROJECT();
                pd.ID = id;
                pd.Name = node["Name"].ToString();
                pd.Class = node["Class"].ToString();
                pd.FileType = node["FileType"].ToString();
                pd.ProjectID = node["ProjectID"].ToString();
                frmNewProject frmprojectDLG = new frmNewProject();
                frmprojectDLG.Name = pd.Name;
                frmprojectDLG.FileType = pd.FileType;
                if (frmprojectDLG.ShowDialog() == DialogResult.OK) {
                    node["Name"] = frmprojectDLG.Name;
                    pd.Name = frmprojectDLG.Name;
                    pd.FileType = frmprojectDLG.FileType;
                    UCDeviceBase.DataService.Update("UpdatePSP_ELCPROJECT", pd);
                    SVGFILE svgFile = new SVGFILE();
                    svgFile.SUID =pd.ID;
                    svgFile= (SVGFILE)Services.BaseService.GetObject("SelectSVGFILEByKey", svgFile);
                    if (svgFile!=null)
                    {
                        svgFile.FILENAME = pd.Name;
                        UCDeviceBase.DataService.Update<SVGFILE>(svgFile);

                    }

                    treeList1.Refresh();
                }
            }
        }
Example #25
0
        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("��·���ݴ������⣬�迹���󲻴��ڻ��ߴ��ڹ����ڵ㣬���֤���ٽ��У�");
            }
        }