Example #1
0
 /// <summary>
 /// 查询变电站数据
 /// </summary>
 private void SelectBDZ(Itop.Client.Base.FormBase FB, string strName)
 {
     string sql = " AreaID='" + FB.ProjectUID + "'and uid in(select svguid from pspDEV where  ProjectID='" + FB.ProjectUID + "' and  Type='01'and Name in(select JName from pspdev where Name='" + strName + "'))";
     string sql1 = " AreaID='" + FB.ProjectUID + "'and uid in(select svguid from pspDEV where  ProjectID='" + FB.ProjectUID + "' and  Type='01'and Name in(select IName from pspdev where Name='" + strName + "'))";
     try
     {
         BDZ = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoListByWhere", sql);
         BDZ1 = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoListByWhere", sql1);
     }
     catch (System.Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Example #2
0
        public override void UpdateIn(DataTable table)
        {
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (table.Rows[i][0].ToString().IndexOf("�ϼ�") > 0 || table.Rows[i][1].ToString().IndexOf("�ϼ�") > 0)
                    continue;
                PSP_Substation_Info area = new PSP_Substation_Info();
                //area.UID += "|" + ProjectID;
                area.AreaID = ProjectID;
               // area.CreateDate = DateTime.Now;

                foreach (DataColumn col in table.Columns)
                {
                    try
                    {
                        if (table.Rows[i][col] != null)
                        {
                            string inserted = table.Rows[i][col].ToString();
                            if (inserted == "�滮" || inserted == "��״")
                                area.GetType().GetProperty("Flag").SetValue(area, inserted == "�滮" ? "2" : "1", null);
                            else
                            {
                                Type type = area.GetType().GetProperty(col.ColumnName).PropertyType;//.GetValue(area, null).GetType();
                                if (type == typeof(int))
                                    area.GetType().GetProperty(col.ColumnName).SetValue(area, int.Parse(inserted == "" ? "0" : inserted), null);
                                else if (type == typeof(string))
                                    area.GetType().GetProperty(col.ColumnName).SetValue(area, inserted, null);
                                else if (type == typeof(decimal))
                                    area.GetType().GetProperty(col.ColumnName).SetValue(area, decimal.Parse(inserted == "" ? "0" : inserted), null);
                                else if (type == typeof(double))
                                    area.GetType().GetProperty(col.ColumnName).SetValue(area, double.Parse(inserted == "" ? "0.0" : inserted), null);
                                else if(type==typeof(DateTime))
                                {

                                }
                            }
                        }
                    }
                    catch { MessageBox.Show(string.Format("��{0}��{1}���������", i.ToString(), col.Caption)); }
                }
                DataService.Create<PSP_Substation_Info>(area);

            }
        }
Example #3
0
        void tlVectorControl1_LeftClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e)
        {
            //if (tlVectorControl1.ScaleRatio < 0.1f)
            //{
            //    tlVectorControl1.ScaleRatio = 0.01f;
            //    scaleBox.ComboBoxEx.Text = "1%";
            //    //scaleBox.SelectedText = "10%";
            //}
            //SvgElement e1 = null;
            //if (tlVectorControl1.SVGDocument.CurrentElement != null)
            //{
            //     e1 = (SvgElement)tlVectorControl1.SVGDocument.CurrentElement.Clone();

            //}
            ////tlVectorControl1.SVGDocument.CurrentElement = null;
            //tlVectorControl1.SVGDocument.SelectCollection.Clear();

            //tip.Hide();
            fInfo.Hide();
            //tlVectorControl1.SVGDocument.CurrentElement =(SvgElement) e.Elements[0];
            decimal ViewScale = 1;
            string str_Scale = tlVectorControl1.SVGDocument.getViewScale();
            if (str_Scale != "") {
                ViewScale = Convert.ToDecimal(str_Scale);
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                string IsArea = ((XmlElement)e.SvgElement).GetAttribute("IsArea");
                if (IsArea != "") {

                    PointF[] pnts = ((Polygon)e.SvgElement).Points.Clone() as PointF[];
                    ((Polygon)e.SvgElement).Transform.Matrix.TransformPoints(pnts);
                    decimal temp1 = TLMath.getPolygonArea(pnts, 1);
                    temp1 = TLMath.getNumber2(temp1, tlVectorControl1.ScaleRatio) / Convert.ToDecimal(4.2);
                    SelUseArea = temp1.ToString("#####.####");
                    if (SelUseArea != "") {
                        if (Convert.ToDecimal(SelUseArea) >= 1) {
                            fInfo.Info = "区域面积:" + SelUseArea + "(KM²)";
                        } else {
                            fInfo.Info = "区域面积: 0" + SelUseArea + "(KM²)";
                        }
                        fInfo.Top = e.Mouse.Y;
                        fInfo.Left = e.Mouse.X;
                        fInfo.Show();
                    }
                    //tip.Text = "区域面积:" + SelUseArea;
                    //tip.ShowToolTip();
                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Line") {
                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");
                if (IsLead != "") {
                    Line line = (Line)e.SvgElement;
                    decimal temp1 = TLMath.getLineLength(line, 1);
                    temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio);
                    string len = temp1.ToString("#####.####");
                    LineLen = len;
                    LineInfo lineInfo = new LineInfo();
                    lineInfo.EleID = e.SvgElement.ID;
                    lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    LineInfo _lineTemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", lineInfo);

                    if ((len != "") && (_lineTemp != null)) {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投运时间:" + _lineTemp.ObligateField3;
                        } else {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投运时间:" + _lineTemp.ObligateField3;
                        }
                    } else if (len != "") {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + _lineTemp.Voltage + " 投运时间:" + _lineTemp.ObligateField3;
                        } else {
                            fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + _lineTemp.Voltage + " 投运时间:" + _lineTemp.ObligateField3;
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 7;
                    fInfo.Height = 50;
                    if (len != "") {
                        fInfo.Show();

                    }

                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");
                if (IsLead != "") {
                    Polyline polyline = (Polyline)e.SvgElement;
                    double temp1 = 0;
                    for (int i = 1; i < polyline.Points.Length; i++) {
                        temp1 += this.mapview.CountLength(polyline.Points[i - 1], polyline.Points[i]);
                    }
                    string len = temp1.ToString("#####.####");
                    LineLen = len;
                    PSPDEV lineInfo = new PSPDEV();
                    lineInfo.SUID = ((XmlElement)e.SvgElement).GetAttribute("Deviceid");
                    // lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    PSPDEV _lineTemp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", lineInfo);

                    if ((len != "") && (_lineTemp != null)) {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路名称:" + _lineTemp.Name + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.RateVolt.ToString() + "kV 投产年限:" + _lineTemp.OperationYear;
                        } else {
                            fInfo.Info = "线路名称:" + _lineTemp.Name + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.RateVolt.ToString() + "kV 投产年限:" + _lineTemp.OperationYear;
                        }
                    } else if (len != "") {
                        if (Convert.ToDecimal(len) >= 1) {
                            fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投运时间:" + " ";
                        } else {
                            fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投运时间:" + " ";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 7;
                    fInfo.Height = 50;
                    //fInfo.Right = fInfo.Left+fInfo.Info.Length*10;
                    if (len != "") {
                        fInfo.Show();
                    }
                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Use") {
                string aaa = ((Use)e.SvgElement).RefElement.ID;
                //if (!aaa.Contains("Substation"))
                //{
                //    return;
                //}

                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");

                if (aaa.Contains("Substation")) {
                    PSP_Substation_Info sub = new PSP_Substation_Info();

                    string deviceid = ((XmlElement)e.SvgElement).GetAttribute("Deviceid");
                    //sub.AreaID = tlVectorControl1.SVGDocument.SvgdataUid;
                    PSP_Substation_Info _subTemp = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                    // PSP_Substation_Info _subTemp = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoListByEleID", sub);
                    if (_subTemp != null) {
                        fInfo.Info = "变电站名称:" + _subTemp.Title + " 容量:" + _subTemp.L2.ToString("##.##") + "MVA\r\n" + " 电压等级:" + _subTemp.L1.ToString("##.##") + "kV 最大负荷:" + _subTemp.L9.ToString("##.##") + "MW \r\n 投产年限:" + _subTemp.S2;
                    } else {
                        fInfo.Info = "变电站名称:" + " " + " 容量:0" + "MVA" + "\r\n 电压等级: 最大负荷: \r\n 负荷率: 投产年限:";
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 5;
                    fInfo.Height = 60;
                    fInfo.Show();
                }
                if (aaa.Contains("kbs") || aaa.Contains("fjx") || aaa.Contains("byq") || aaa.Contains("hwg")) {
                    string deviceid = ((XmlElement)e.SvgElement).GetAttribute("Deviceid");
                    string s_name = "";
                    if (aaa.Contains("kbs")) {
                        s_name = "开闭所";
                    }
                    if (aaa.Contains("fjx")) {
                        s_name = "分接箱";
                    }
                    if (aaa.Contains("byq")) {
                        s_name = "变压器";
                    }
                    if (aaa.Contains("hwg")) {
                        s_name = "环网柜";
                    }
                    PSPDEV _subTemp = new PSPDEV();
                    _subTemp.SUID = deviceid;
                    _subTemp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", _subTemp);
                    //PSP_Gra_item sub = new PSP_Gra_item();
                    //sub.EleID = e.SvgElement.ID;
                    //sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    //sub.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    //PSP_Gra_item _subTemp = (PSP_Gra_item)Services.BaseService.GetObject("SelectPSP_Gra_itemByEleIDKey", sub);
                    if (_subTemp != null) {
                        fInfo.Info = s_name + " 名称:" + _subTemp.Name;
                    } else {
                        fInfo.Info = s_name; // +"编号:   \r\n 名称: ";
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 15;
                    fInfo.Height = 60;
                    fInfo.Show();
                }
            }

            //if(e1!=null){
            //    tlVectorControl1.SVGDocument.CurrentElement = e1;
            //}
        }
        private void fpfhyj(PSP_Substation_Info sub,ref double zgfh,ref Dictionary<PSP_Substation_Info,IList<PSPDEV>> listfhfp)
        {
            //�����������ѹĸ��
            string con = "where SvgUID='" + sub.UID + "'and Type='01' and ProjectID='" + Itop.Client.MIS.ProgUID + "' order by RateVolt";
            IList<PSPDEV> list = UCDeviceBase.DataService.GetList<PSPDEV>("SelectPSPDEVByCondition", con);
            List<int> listnum = new List<int>(); //��¼�Ǽ���ĸ�� Ҫ���п��ǵ�ϵͳ������\
            IList<PSPDEV> list1 = new List<PSPDEV>();
            double minv = sub.L1;
            if (list.Count==0)
            {
                return;
            }
            bool flag=false;
            for (int i = 0; i < list.Count;i++ )
            {
                if (list[i].RateVolt <= minv)
                {
                    minv = list[i].RateVolt;
                }
                if (list[i].RateVolt==sub.L1)
                {
                    flag=true;
                }
                //�� ��������������� ���·���
                list[i].InPutP = 0;
                list[i].InPutQ= 0;
                UCDeviceBase.DataService.Update<PSPDEV>(list[i]);
                con = "where IName='" + list[i].Name + "'and Type='12' and ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                PSPDEV obj = UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con) as PSPDEV;
                if (obj!=null)
                {
                    obj.InPutP = 0;
                    obj.InPutQ = 0;
                    obj.UnitFlag ="1";
                    UCDeviceBase.DataService.Update<PSPDEV>(obj);
                }
            }

            for (int i = 0; i < list.Count;i++ )
            {
                if (list[i].RateVolt == minv)
                {
                    con = "where IName='" + list[i].Name + "'and Type='12' and ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                    PSPDEV obj = UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con)as PSPDEV;
                    if (obj != null)
                    {
                        list1.Add(obj);
                    }
                    else
                        list1.Add(list[i]);

                }
                if (flag)
                {
                    if (list[i].RateVolt == sub.L1)
                    {
                        con = "where IName='" + list[i].Name + "'and Type='12' and ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                        PSPDEV obj = UCDeviceBase.DataService.GetObject("SelectPSPDEVByCondition", con) as PSPDEV;
                        if (obj != null)
                        {
                            zgfh += obj.OutP;
                        }
                        else
                            zgfh += list[i].HuganTQ1;
                    }
                }

            }

            listfhfp[sub] = list1;
        }
Example #5
0
        private void button5_Click_1(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            frmGHDeviceList frmDevList = new frmGHDeviceList();
            frmDevList.ProjectID = Itop.Client.MIS.ProgUID;
            frmDevList.ProjectSUID = ctrlPSP_GProg1.FocusedObject.UID;
            frmDevList.Init();
            if (frmDevList.ShowDialog() == DialogResult.OK) {
                foreach (DataRow row in frmDevList.DT.Rows) {
                    try {
                        if ((bool)row["C"]) {
                            PSP_GprogElevice elcDevice = new PSP_GprogElevice();
                            elcDevice.DeviceSUID = row["A"].ToString();
                            elcDevice.GprogUID = ctrlPSP_GProg1.FocusedObject.UID;
                            elcDevice = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByKey", elcDevice);
                            if (elcDevice != null) {
                                elcDevice.Type = row["D"].ToString();
                                elcDevice.L2 = "0";
                                Services.BaseService.Update<PSP_GprogElevice>(elcDevice);
                            } else {
                                elcDevice = new PSP_GprogElevice();
                                elcDevice.DeviceSUID = row["A"].ToString();
                                elcDevice.GprogUID = ctrlPSP_GProg1.FocusedObject.UID;
                                elcDevice.Type = row["D"].ToString();
                                elcDevice.L2 = "0";
                                Services.BaseService.Create<PSP_GprogElevice>(elcDevice);
                            }

                        } else {
                            PSP_GprogElevice elcDevice = new PSP_GprogElevice();
                            elcDevice.DeviceSUID = row["A"].ToString();
                            elcDevice.GprogUID = ctrlPSP_GProg1.FocusedObject.UID;

                            Services.BaseService.Delete<PSP_GprogElevice>(elcDevice);
                        }
                    } catch (System.Exception ex) {

                    }
                }
            } else
                return;
            //在此处将其选择的元件设备的属性进行更改

            LayerGrade l1 = new LayerGrade();
            l1.Type = "1";
            l1.SvgDataUid = svguid;
            IList ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            int yy1 = System.DateTime.Now.Year, yy2 = System.DateTime.Now.Year, yy3 = System.DateTime.Now.Year;
            if (ttlist.Count > 0) {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy1 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type = "2";
            l1.SvgDataUid = svguid;
            ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0) {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy2 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type = "3";
            l1.SvgDataUid = svguid;
            ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0) {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy3 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            string con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '变电站'";

            IList list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {

                PSP_Substation_Info ps = new PSP_Substation_Info();
                ps.UID = pg.DeviceSUID;
                ps = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", ps);
                if (ps != null) {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S2)) {
                        s2 = Convert.ToInt32(ps.S2);
                    }
                    if (s2 <= System.DateTime.Now.Year) {
                        pg.L1 = "现行";
                    } else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S2) <= yy1) {
                        pg.L1 = "近期";
                    } else if (s2 > yy1 && Convert.ToInt32(ps.S2) <= yy2) {
                        pg.L1 = "中期";
                    } else if (s2 > yy2 && Convert.ToInt32(ps.S2) <= yy3) {
                        pg.L1 = "远期";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                } else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);

            }
            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '电源'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                PSP_PowerSubstation_Info ps = new PSP_PowerSubstation_Info();
                ps.UID = pg.DeviceSUID;
                ps = (PSP_PowerSubstation_Info)Services.BaseService.GetObject("SelectPSP_PowerSubstation_InfoByKey", ps);
                if (ps != null) {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S3)) {
                        s2 = Convert.ToInt32(ps.S3);
                    }
                    if (s2 <= System.DateTime.Now.Year) {
                        pg.L1 = "现行";
                    } else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S3) <= yy1) {
                        pg.L1 = "近期";
                    } else if (s2 > yy1 && Convert.ToInt32(ps.S3) <= yy2) {
                        pg.L1 = "中期";
                    } else if (s2 > yy2 && Convert.ToInt32(ps.S3) <= yy3) {
                        pg.L1 = "远期";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                } else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
            }
            //变电站里判断两绕和三绕是哪个时期的

            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '变电站'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='02'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                IList uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist) {

                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '两绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null) {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update<PSP_GprogElevice>(pglr);
                    }

                }
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='03'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist) {

                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '三绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null) {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update<PSP_GprogElevice>(pglr);
                    }

                }
            }
            //发电厂里两绕和三绕组是哪个时期的
            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '电源'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='02'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                IList uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist) {

                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '两绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null) {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update<PSP_GprogElevice>(pglr);
                    }

                }
                con = "c.UID='" + pg.DeviceSUID + "'and a.Type='03'and a.ProjectID='" + Itop.Client.MIS.ProgUID + "'";
                uidlist = Services.BaseService.GetList("SelectPSPDEV_byqSUID", con);
                foreach (string uid in uidlist) {

                    con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '三绕组变压器'AND DeviceSUID='" + uid + "'";
                    PSP_GprogElevice pglr = (PSP_GprogElevice)Services.BaseService.GetObject("SelectPSP_GprogEleviceByCondition", con);
                    if (pglr != null) {
                        pglr.L1 = pg.L1;
                        Services.BaseService.Update<PSP_GprogElevice>(pglr);
                    }

                }
            }
            //判断设备参数中有没有在规划设备中的两绕,三绕组变压器,发电机和负荷 如果没有则删掉

            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND (Type= '两绕组变压器'or Type= '三绕组变压器'or Type= '负荷'or Type= '发电机')";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                PSPDEV ps = new PSPDEV();
                ps.SUID = pg.DeviceSUID;
                ps = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", ps);
                if (ps == null) {
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
                }
            }
            //线路信息
            con = "GprogUID = '" + ctrlPSP_GProg1.FocusedObject.UID + "' AND Type= '线路'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list) {
                PSPDEV ps = new PSPDEV();
                ps.SUID = pg.DeviceSUID;
                ps = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", ps);
                if (ps != null) {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.OperationYear)) {
                        s2 = Convert.ToInt32(ps.OperationYear);
                    }
                    if (s2 <= System.DateTime.Now.Year) {
                        pg.L1 = "运行";
                        ps.LineStatus = "运行";
                    } else {
                        pg.L1 = "待选";
                        ps.LineStatus = "待选";

                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                    Services.BaseService.Update<PSPDEV>(ps);
                } else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);

            }
        }
Example #6
0
 private string getBdzName(string id)
 {
     PSP_Substation_Info sub = new PSP_Substation_Info();
     sub.EleID = id;
     //sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
     IList svglist20 = Services.BaseService.GetList("SelectPSP_Substation_InfoListByEleID", sub);
     sub = null;
     string ret = string.Empty;
     if (svglist20.Count > 0)
     {
         sub = (PSP_Substation_Info)svglist20[0];
         ret = sub.Title;
     }
     return ret;
 }
Example #7
0
        private void ShowResult(int order, string projectsuid, string FileName, int pspouttype, frnReport wFrom)
        {
            try
            {
                //删除原来的text文本
                //XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("svg/*[@flag='" + "1" + "']");

                //foreach (XmlNode node in list)
                //{
                //    SvgElement element = node as SvgElement;
                //    tlVectorControl1.SVGDocument.CurrentElement = element;
                //    tlVectorControl1.Delete();
                //}
                wFrom.ShowText += "\r\n开始显示计算结果\t" + System.DateTime.Now.ToString();
                double yinzi = 0, capability = 0, volt = 0, standvolt = 0, current = 0;
                PSPDEV benchmark = new PSPDEV();
                benchmark.Type = "power";
                benchmark.SvgUID = projectsuid;
                IList list3 = Services.BaseService.GetList("SelectPSPDEVBySvgUIDAndType", benchmark);
                //if (list3 == null)
                //{
                //    MessageBox.Show("请设置基准后再进行计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    return;
                //}
                foreach (PSPDEV dev in list3)
                {
                    yinzi = Convert.ToDouble(dev.PowerFactor);
                    capability = Convert.ToDouble(dev.StandardCurrent);
                    volt = Convert.ToDouble(dev.StandardVolt);
                    TLPSPVmin = dev.iV;
                    TLPSPVmax = dev.jV;
                    if (dev.PowerFactor == 0)
                    {
                        yinzi = 1;
                    }
                    if (dev.StandardCurrent == 0)
                    {
                        capability = 1;
                    }
                    if (dev.StandardVolt == 0)
                    {
                        volt = 1;
                    }
                    standvolt = volt;
                    current = capability / (Math.Sqrt(3) * volt);
                };
                Layer lar = null;
                if (Layer.CkLayerExist(FileName, tlVectorControl1.SVGDocument))
                {
                    ArrayList layercol = tlVectorControl1.SVGDocument.getLayerList();
                    for (int i = 0; i < layercol.Count; i++)
                    {
                        if (FileName == (layercol[i] as Layer).GetAttribute("label"))
                        {
                            lar = (Layer)layercol[i];
                            break;
                        }
                    }
                }
                else
                {
                    lar = Layer.CreateNew(FileName, tlVectorControl1.SVGDocument);

                    lar.SetAttribute("layerType", progtype);
                    lar.SetAttribute("ParentID", tlVectorControl1.SVGDocument.CurrentLayer.GetAttribute("ParentID"));
                    this.frmlar.checkedListBox1.SelectedIndex = -1;
                    this.frmlar.checkedListBox1.Items.Add(lar, true);
                }
                int size = tlVectorControl1.ScaleRatio > 1 ? 12 : (int)(12 / tlVectorControl1.ScaleRatio);
                XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");
                foreach (XmlNode node in useList)
                {
                    XmlElement element = node as XmlElement;
                    string strCon = null;
                    IList listMX = null;
                    if (pspouttype == 0)
                    {
                        strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectsuid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01'";
                        listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                    }

                    //XmlNode text = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@ParentID='" + element.GetAttribute("id") + "']");
                    if (pspouttype == 1)
                    {
                        bool pspflag = false;
                        PSP_Substation_Info ps = new PSP_Substation_Info();
                        ps.UID = (element).GetAttribute("Deviceid");
                        ps = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", ps);
                        if (ps != null)
                        {
                            if (ps.Flag == "2")
                            {
                                strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectsuid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01'";
                                listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                            }

                            pspflag = true;
                        }
                        if (!pspflag)
                        {
                            PSP_PowerSubstation_Info ppi = new PSP_PowerSubstation_Info();
                            ppi.UID = (element).GetAttribute("Deviceid");
                            ppi = (PSP_PowerSubstation_Info)Services.BaseService.GetObject("SelectPSP_PowerSubstation_InfoByKey", ppi);
                            if (ppi != null)
                            {
                                if (ppi.Flag == "2")
                                {
                                    strCon = ",PSP_ELCDEVICE WHERE PSPDEV.SUID = PSP_ELCDEVICE.DeviceSUID AND PSP_ELCDEVICE.ProjectSUID = '" + projectsuid + "' AND SvgUID = '" + (element).GetAttribute("Deviceid") + "' AND Type = '01'";
                                    listMX = Services.BaseService.GetList("SelectPSPDEVByCondition", strCon);
                                }

                            }
                        }

                    }

                    if (listMX != null)
                    {
                        for (int i = 0; i < listMX.Count; i++)
                        {
                            PSPDEV elementDEV = (PSPDEV)(listMX[i]);
                            PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                            elcDEV.ProjectSUID = projectsuid;
                            elcDEV.DeviceSUID = ((PSPDEV)listMX[i]).SUID;
                            elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                            if (elcDEV != null)
                            {
                                XmlElement elementn1 = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID1='" + ((PSPDEV)listMX[i]).SUID + "']") as XmlElement;
                                XmlElement elementn2 = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID2='" + ((PSPDEV)listMX[i]).SUID + "']") as XmlElement;
                                if (elementn1 == null)
                                {
                                    //RectangleF bound = ((IGraph)element).GetBounds();
                                    //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    //XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    //n1.SetAttribute("x", Convert.ToString(bound.X));
                                    //n1.SetAttribute("y", Convert.ToString(bound.Y - i * 20));
                                    //n1.SetAttribute("font-size", size.ToString());//"12");
                                    //n1.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL2).ToString("N2");
                                    ////Layer la = tlVectorControl1.SVGDocument.GetLayerByID(element.GetAttribute("layer"));
                                    //n1.SetAttribute("layer", lar.ID);
                                    ////MessageBox.Show(Convert.ToString(n1.InnerText));
                                    //n1.SetAttribute("flag", "1");
                                    //n1.SetAttribute("ParentID1", ((PSPDEV)listMX[i]).SUID);
                                    //if (Convert.ToDouble(GetColValue(elcDEV, order).COL2) > TLPSPVmax * elementDEV.RateVolt / elementDEV.ReferenceVolt || Convert.ToDouble(GetColValue(elcDEV, order).COL2) < TLPSPVmin * elementDEV.RateVolt / elementDEV.ReferenceVolt)//电压越限,需修改
                                    //    n1.SetAttribute("stroke", "#FF0000");
                                    //if (elementDEV.NodeType == "0")
                                    //{

                                    //    n2.SetAttribute("x", Convert.ToString(bound.X));
                                    //    n2.SetAttribute("y", Convert.ToString(bound.Y + bound.Height + 20));
                                    //    if (Convert.ToDouble(elcDEV.COL5) >= 0)
                                    //    {
                                    //        n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  + " + "j" + Convert.ToDouble(GetColValue(elcDEV, order).COL5).ToString("N2");
                                    //    }
                                    //    else
                                    //    {
                                    //        n2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  - " + "j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                    //    }
                                    //    n2.SetAttribute("layer", lar.ID);
                                    //    n2.SetAttribute("flag", "1");
                                    //    n2.SetAttribute("ParentID", ((PSPDEV)listMX[i]).SUID);
                                    //    n2.SetAttribute("font-size", size.ToString());//"12");
                                    //    // n2.SetAttribute("limitsize", "true");

                                    //    double tempi = Convert.ToDouble(GetColValue(elcDEV, order).COL4);
                                    //    double tempj = Convert.ToDouble(GetColValue(elcDEV, order).COL5);
                                    //    double temptotal = Math.Sqrt(tempi * tempi + tempj * tempj);
                                    //    if (temptotal > Convert.ToDouble(elementDEV.Burthen))
                                    //    {
                                    //        n2.SetAttribute("stroke", "#FF0000");
                                    //    }
                                    //    tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);

                                    //}
                                    //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                    //tlVectorControl1.Operation = ToolOperation.Select;
                                }
                                else
                                {
                                    //elementn1.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL2).ToString("N2");
                                    //if (Convert.ToDouble(GetColValue(elcDEV, order).COL2) > TLPSPVmax * elementDEV.RateVolt / elementDEV.ReferenceVolt || Convert.ToDouble(GetColValue(elcDEV, order).COL2) < TLPSPVmin * elementDEV.RateVolt / elementDEV.ReferenceVolt)//电压越限,需修改
                                    //    elementn1.SetAttribute("stroke", "#FF0000");
                                    //if (elementDEV.NodeType == "0")
                                    //{

                                    //    if (Convert.ToDouble(elcDEV.COL5) >= 0)
                                    //    {
                                    //        elementn2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  + " + "j" + Convert.ToDouble(GetColValue(elcDEV, order).COL5).ToString("N2");
                                    //    }
                                    //    else
                                    //    {
                                    //        elementn2.InnerText = Convert.ToDouble(GetColValue(elcDEV, order).COL4).ToString("N2") + "  - " + "j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                    //    }
                                    //}
                                }

                            } tlVectorControl1.Refresh();
                        }
                    }

                }
                List<PSPDEV> listline = new List<PSPDEV>();
                if (pspouttype==1)
                {
                     SelShowlineform selbusfrm = new SelShowlineform();
                    selbusfrm.ProjectSUID = projectsuid;
                    selbusfrm.ProjectID = Itop.Client.MIS.ProgUID;
                    selbusfrm.ShowDialog();
                    if (selbusfrm.DialogResult == DialogResult.OK)
                    {

                        foreach (DataRow row in selbusfrm.DT.Rows)
                        {
                            try
                            {
                                if ((bool)row["C"])
                                {
                                    PSPDEV psp = new PSPDEV();
                                    psp.SUID = row["A"].ToString();

                                    psp = (PSPDEV)UCDeviceBase.DataService.GetObject("SelectPSPDEVByKey", psp);
                                    if (psp != null)
                                    {
                                        listline.Add(psp);
                                    }
                                }

                            }
                            catch (System.Exception ex)
                            {

                            }
                        }
                        if (listline.Count == 0)
                        {
                            MessageBox.Show("没有选择显示的线路!");
                            return;
                        }
                    }
                }
                wFrom.ShowText += "\r\n正在显示线路信息\t" + System.DateTime.Now.ToString();
                XmlNodeList polyLineList = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline");

                foreach (XmlNode node in polyLineList)
                {
                    XmlElement element = node as XmlElement;
                    PSP_ElcDevice elcDEV = new PSP_ElcDevice();
                    elcDEV.ProjectSUID = projectsuid;
                    elcDEV.DeviceSUID = element.GetAttribute("Deviceid");
                    elcDEV = (PSP_ElcDevice)Services.BaseService.GetObject("SelectPSP_ElcDeviceByKey", elcDEV);
                    PSPDEV elementDEV = new PSPDEV();
                    if (elcDEV != null)
                    {
                        elementDEV.SUID = elcDEV.DeviceSUID;
                        elementDEV = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", elementDEV);
                        if (pspouttype == 1)                             //如果只显示规划线路的数据
                        {
                            bool flag = false;
                            foreach (PSPDEV showdev in listline)
                            {
                                if (elementDEV.SUID==showdev.SUID)
                                {
                                    flag = true;
                                    break;
                                }
                            }
                            if (!flag)
                            {
                                //删除不是选中的线路的数据

                                XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID='" + elementDEV.SUID + "']") as XmlElement;
                                if (elementdl != null)
                                {
                                    tlVectorControl1.SVGDocument.RootElement.RemoveChild(elementdl);
                                }
                                tlVectorControl1.Refresh();

                                continue;
                            }
                            //if (Convert.ToInt32(elementDEV.OperationYear) <= DateTime.Now.Year)
                            //{
                            //    continue;
                            //}
                        }
                    }
                    else
                    {
                        continue;
                    }

                    if (elementDEV != null && elementDEV.KSwitchStatus == "0")
                    {
                        XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID='" + elementDEV.SUID + "']") as XmlElement;

                        if (elementdl == null)
                        {
                            List<PointF> pcol = CheckLenth((Polyline)element);

                            PointF[] t = ((Polyline)element).Points;
                            PointF[] t2 = ((Polyline)element).Points; t = t2;
                            int lastnum = t2.Length - 1;
                            PointF midt = new PointF((float)((pcol[0].X + pcol[1].X) / 2), (float)((pcol[0].Y + pcol[1].Y) / 2));
                            float angel = 0f;
                            angel = (float)(180 * Math.Atan2((pcol[0].Y - pcol[1].Y), (pcol[1].X - pcol[0].X)) / Math.PI);

                            string l3 = Convert.ToString(midt.X);
                            string l4 = Convert.ToString(midt.Y);

                            string tran = ((Polyline)element).Transform.ToString();

                            PointF center = new PointF((float)(pcol[0].X + (pcol[1].X - pcol[0].X) / 2), (float)(pcol[0].Y + (pcol[1].Y - pcol[0].Y) / 2));
                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            // XmlElement n2 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;
                            //XmlElement n3 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;

                            PointF pStart = new PointF(center.X + (float)(15 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(15 * Math.Cos((angel) * Math.PI / 180)));
                            PointF pStart2 = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));

                            XmlNode firstNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("FirstNode") + "']");
                            XmlNode lastNodeElement = tlVectorControl1.SVGDocument.SelectSingleNode("svg/*[@id='" + element.GetAttribute("LastNode") + "']");
                            //if (firstNodeElement != null)
                            {
                                if ((angel > 10 && angel < 90) || (angel < 0 && Math.Abs(angel) < 90) || (angel > 180 && angel < 350))
                                {
                                    //if (t2[0].X > ((IGraph)firstNodeElement).CenterPoint.X)
                                    //{
                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    //}
                                }
                                else if ((angel >= 0 && angel <= 10) || (angel >= 350 && angel <= 360) || (angel < 0 && Math.Abs(angel) <= 90))
                                {
                                    //if (t2[0].Y > ((IGraph)firstNodeElement).CenterPoint.Y)
                                    //{
                                    pStart = new PointF(center.X - (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(23 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(23 * Math.Cos((angel) * Math.PI / 180)));
                                    //}
                                }
                                else if ((angel < 0 && Math.Abs(angel) > 90) || (angel >= 90 && angel <= 180))
                                {
                                    //if (t2[0].Y > ((IGraph)firstNodeElement).CenterPoint.Y)
                                    //{
                                    pStart = new PointF(center.X - (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y + (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                                    pStart2 = new PointF(center.X + (float)(7 * Math.Sin((angel) * Math.PI / 180)), center.Y - (float)(7 * Math.Cos((angel) * Math.PI / 180)));
                                    //}
                                }
                                if (Convert.ToDouble(GetColValue(elcDEV, order).COL5) >= 0)
                                {
                                    n1.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " + j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                }
                                else
                                {
                                    n1.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " - j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                                }
                                Graphics dd = this.CreateGraphics();
                                Font ff = new Font("宋体", 12);
                                SizeF sf = dd.MeasureString(n1.InnerText, ff);
                                double ztlength = Math.Sqrt(sf.Width * sf.Width + sf.Height * sf.Height);
                                PointF newp1 = new PointF(t[0].X + (t[1].X - t[0].X) / 2 - (float)(15 * Math.Sin(angel)), t[0].Y + (t[1].Y - t[0].Y) / 2 - (float)(15 * Math.Cos(angel)));
                                //n1.SetAttribute("x", Convert.ToString(center.X - (float)(Math.Sin((angel) * Math.PI / 180) * ztlength)));
                                //n1.SetAttribute("y", Convert.ToString(center.Y - (float)(Math.Cos((angel) * Math.PI / 180) * ztlength)));

                                n1.SetAttribute("x", Convert.ToString(center.X));
                                n1.SetAttribute("y", Convert.ToString(center.Y));

                                //Layer la = tlVectorControl1.SVGDocument.GetLayerByID(element.GetAttribute("layer"));
                                n1.SetAttribute("layer", lar.ID);
                                n1.SetAttribute("ParentID", elementDEV.SUID);
                                n1.SetAttribute("flag", "1");
                                n1.SetAttribute("Showline", "1");            //为显示哪条线路做标志
                                n1.SetAttribute("font-size", "96");// size.ToString());//"12");
                                // n1.SetAttribute("limitsize", "true");
                                if (Convert.ToDouble(GetColValue(elcDEV, order).COL14) > (elementDEV.LineChange))//电流越限,需修改。

                                    n1.SetAttribute("stroke", "#FF0000");

                                //PointF p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 25) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 25) * Math.PI / 180)));
                                //PointF p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 335) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 335) * Math.PI / 180)));

                                //if (Convert.ToDouble(elcDEV.COL4) < 0)
                                //{
                                //    p1 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 155) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 155) * Math.PI / 180)));
                                //    p2 = new PointF(midt.X - (float)(10 * Math.Cos((angel + 205) * Math.PI / 180)), midt.Y - (float)(10 * Math.Sin((angel + 205) * Math.PI / 180)));
                                //}

                                //string l1 = Convert.ToString(p1.X);
                                //string l2 = Convert.ToString(p1.Y);
                                //string l5 = Convert.ToString(p2.X);
                                //string l6 = Convert.ToString(p2.Y);

                                //n2.SetAttribute("points", l1 + " " + l2 + "," + l3 + " " + l4 + "," + l5 + " " + l6);
                                //n2.SetAttribute("fill-opacity", "1");
                                //n2.SetAttribute("layer", SvgDocument.currentLayer);
                                //n2.SetAttribute("flag", "1");
                                //n2.SetAttribute("font-size", "6");
                                //tlVectorControl1.SVGDocument.RootElement.AppendChild(n2);
                                //tlVectorControl1.SVGDocument.CurrentElement = n2 as SvgElement;

                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                tlVectorControl1.Operation = ToolOperation.Select;

                                tlVectorControl1.SVGDocument.CurrentElement = n1 as SvgElement;

                                RectangleF ttt = ((Polyline)element).GetBounds();

                                tlVectorControl1.RotateSelection(angel, pStart);
                                if (Math.Abs(angel) > 90)
                                    tlVectorControl1.RotateSelection(180, pStart);

                            }
                        }
                        else
                        {
                            elementdl.SetAttribute("Showline", "1");            //为显示哪条线路做标志
                            if (Convert.ToDouble(GetColValue(elcDEV, order).COL5) >= 0)
                            {
                                elementdl.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " + j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                            }
                            else
                            {
                                elementdl.InnerText = (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL4))).ToString("N2") + " - j" + (Math.Abs(Convert.ToDouble(GetColValue(elcDEV, order).COL5))).ToString("N2");
                            }
                            if (Convert.ToDouble(GetColValue(elcDEV, order).COL14) > (elementDEV.LineChange))//电流越限,需修改。

                                elementdl.SetAttribute("stroke", "#FF0000");
                        }
                        tlVectorControl1.Refresh();
                    }
                    //删除不投入运行的输出结果
                    else if (elementDEV != null && elementDEV.KSwitchStatus == "1")
                    {
                        XmlElement elementdl = tlVectorControl1.SVGDocument.SelectSingleNode("svg/text[@ layer='" + lar.ID + "'and @ParentID='" + elementDEV.SUID + "']") as XmlElement;
                        if (elementdl != null)
                        {
                            tlVectorControl1.SVGDocument.RootElement.RemoveChild(elementdl);
                        }
                        tlVectorControl1.Refresh();
                    }

                }
                //this.frmlar.checkedListBox1.Items.Add(lar, true);
                //this.frmlar.checkedListBox1.SelectedIndex = -1;
                MessageBox.Show("显示完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("参数错误,请调整参数后重新计算!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
Example #8
0
        public void InputBDZFile(string filename, bool create)
        {
            Excel.Application ex = new Excel.Application();
            Excel.Workbook workBook = ex.Workbooks.Open(filename, Type.Missing, Type.Missing,
                                                        Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                        Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            ex.Visible = false;
            FlashWindow frmLoad = new FlashWindow();
            frmLoad.Show();

            try
            {
                ArrayList alldata = new ArrayList();
                bool right = true;
                frmLoad.RefleshStatus("共有" + ex.Worksheets.Count.ToString() + "张工作表。");
                for (int n = 1; n <= ex.Worksheets.Count; n++)
                {
                    Excel.Worksheet xSheet1 = (Excel.Worksheet)ex.Worksheets[n];
                    int c = xSheet1.Columns.Count;
                    int r = xSheet1.Rows.Count;
                    ArrayList jwlist = new ArrayList();
                    ArrayList mclist = new ArrayList();
                    ArrayList dylist = new ArrayList();
                    int int_jd = 0;
                    int int_wd = 0;
                    int int_dy = 0;
                    int int_mc = 0;
                    string kv = "";
                    string s = "";

                    for (int j = 1; j < xSheet1.Columns.Count; j++)
                    {
                        frmLoad.RefleshStatus("正在导入第" + n.ToString() + "张工作表,第" + j.ToString() + "行记录。");
                        if (((Excel.Range)xSheet1.Cells[1, j]).Value2 == null)
                        {
                            break;
                        }
                        Excel.Range range1 = (Excel.Range)xSheet1.Cells[1, j];
                        if (range1.Value2.ToString().Contains("经度"))
                        {
                            int_jd = j;
                        }
                        if (range1.Value2.ToString().Contains("纬度"))
                        {
                            int_wd = j;
                        }
                        if (range1.Value2.ToString().Contains("电压"))
                        {
                            int_dy = j;
                        }
                        if (range1.Value2.ToString().Contains("名称"))
                        {
                            int_mc = j;
                        }
                    }
                    if (int_jd == 0 || int_wd == 0)
                    {
                        MessageBox.Show("第" + n.ToString() + "张工作表中不包含经纬度信息,请核对。");
                        right = false;
                        break;
                    }
                    if (int_dy == 0)
                    {
                        MessageBox.Show("第" + n.ToString() + "张工作表中不包含电压信息,请核对。");
                        right = false;
                        break;
                    }
                    if (int_mc == 0)
                    {
                        MessageBox.Show("第" + n.ToString() + "张工作表中不包含变电站名称信息,请核对。");
                        right = false;
                        break;
                    }
                    //   fInfo.Info = "正在导入第" + n.ToString() + "张工作表......";
                    //line_name = xSheet1.Name;
                    for (int i = 2; i < xSheet1.Rows.Count; i++)
                    {
                        if (((Excel.Range)xSheet1.Cells[i, 1]).Value2 == null)
                        {
                            goto LabReadEnd;
                        }
                        Excel.Range range_J = (Excel.Range)xSheet1.Cells[i, int_jd];
                        Excel.Range range_W = (Excel.Range)xSheet1.Cells[i, int_wd];
                        Excel.Range range_mc = (Excel.Range)xSheet1.Cells[i, int_mc];
                        Excel.Range range_kv = (Excel.Range)xSheet1.Cells[i, int_dy];
                        if (range_J.Value2 == null || range_W.Value2 == null)
                        {
                            MessageBox.Show("第" + n.ToString() + "张工作表中第" + i.ToString() + "行经纬度数据格式错误,请核对。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            right = false;
                            break;
                        }
                        if (range_mc.Value2 == null)
                        {
                            MessageBox.Show("第" + n.ToString() + "张工作表中第" + i.ToString() + "行名称数据格式错误,请核对。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            right = false;
                            break;
                        }
                        if (range_kv.Value2 == null)
                        {
                            MessageBox.Show("第" + n.ToString() + "张工作表中第" + i.ToString() + "行电压数据格式错误,请核对。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            right = false;
                            break;
                        }
                        if (range_kv.Value2.ToString() != "500" && range_kv.Value2.ToString() != "220" && range_kv.Value2.ToString() != "110" && range_kv.Value2.ToString() != "35")
                        {
                            MessageBox.Show("第" + n.ToString() + "张工作表中第" + i.ToString() + "行中电压在图元中不存在,请核对。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            right = false;
                            break;
                        }

                        else
                        {
                            bool ck_r = true;
                            //gt = gt + range_gt.Value2.ToString() + ",";
                            s = s + range_J.Value2.ToString() + "," + range_W.Value2.ToString() + ";";
                            string s2 = range_J.Value2.ToString().Trim() + "," + range_W.Value2.ToString().Trim();

                        labLoop:
                            if (!alldata.Contains(s2))
                            {
                                alldata.Add(s2);
                                ck_r = true;
                            }
                            else
                            {
                                ck_r = false;
                            }

                            if (ck_r)
                            {
                                jwlist.Add(s2);
                            }
                            else
                            {
                                s2 = "S" + s2;
                                goto labLoop;
                                //jwlist.Add("S" + s2);
                            }
                            mclist.Add(range_mc.Value2.ToString());
                            dylist.Add(range_kv.Value2.ToString());
                        }
                    }
                LabReadEnd:
                    if (right == true)
                    {
                        StringBuilder bpts = new StringBuilder();
                        string jwd = "";
                        string points = "";
                        for (int k = 0; k < jwlist.Count; k++)
                        {
                            bool ck_s = true;
                            string str_jwdlist = ((string)jwlist[k]);
                            int int_s = 0;
                            if (str_jwdlist.Contains("S"))
                            {
                                ck_s = false;
                                int_s = str_jwdlist.LastIndexOfAny("S".ToCharArray());
                                if (int_s > -1)
                                {
                                    int_s = int_s + 1;
                                }
                                str_jwdlist = str_jwdlist.Replace("S", "");
                            }

                            jwd = jwd + str_jwdlist + ";";

                            double JD = 0;
                            double WD = 0;
                            if (str_jwdlist.LastIndexOfAny(" ".ToCharArray()) > 3)
                            {
                                string[] str = str_jwdlist.Split(',');
                                string[] JWD1 = str[0].Trim().Split(' ');
                                double J1 = Convert.ToDouble(JWD1[0]);
                                Double W1 = Convert.ToDouble(JWD1[1]);
                                Double D1 = Convert.ToDouble(JWD1[2]);
                                string[] JWD2 = str[1].Trim().Split(' ');
                                Double J2 = Convert.ToDouble(JWD2[0]);
                                Double W2 = Convert.ToDouble(JWD2[1]);
                                Double D2 = Convert.ToDouble(JWD2[2]);

                                JD = J1 + W1 / 60 + D1 / 3600;
                                WD = J2 + W2 / 60 + D2 / 3600;
                            }
                            else
                            {
                                string[] str = str_jwdlist.Split(',');
                                JD = Convert.ToDouble(str[0]);
                                WD = Convert.ToDouble(str[1]);
                            }

                            IntXY xy = mapview.getXY(JD, WD);
                            double _x = xy.X;
                            double _y = xy.Y;
                            if (ck_s)
                            {
                                if (mapview is MapViewGoogle)
                                {
                                    _x = xy.X;
                                    _y = xy.Y;
                                }
                                else
                                {
                                    _x = xy.X / (double)tlVectorControl1.ScaleRatio;
                                    _y = xy.Y / (double)tlVectorControl1.ScaleRatio;
                                }
                            }
                            else
                            {
                                if (mapview is MapViewGoogle)
                                {
                                    _x = xy.X + 5 * int_s;
                                    _y = xy.Y + 5 * int_s;
                                }
                                else
                                {
                                    _x = xy.X / (double)tlVectorControl1.ScaleRatio + 5 * int_s;
                                    _y = xy.Y / (double)tlVectorControl1.ScaleRatio + 5 * int_s;
                                }

                            }

                            string pspid = "";
                            if (create)
                            {
                                PSP_Substation_Info sub = new PSP_Substation_Info();
                                sub.UID = Guid.NewGuid().ToString();
                                sub.Title = mclist[k].ToString();
                                sub.AreaID = MIS.ProgUID;
                                sub.L1 = Convert.ToInt32(dylist[k]);
                                Services.BaseService.Create<Substation_Info>(sub);
                                pspid = sub.UID;
                            }

                            string str_sub = getHCSubName(dylist[k].ToString());
                            //PointF pf = getOff(str_dy);
                            XmlElement e0 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement;
                            e0.SetAttribute("x", Convert.ToString(_x));
                            e0.SetAttribute("y", Convert.ToString(_y));
                            e0.SetAttribute("info-name", mclist[k].ToString());
                            e0.SetAttribute("jwd-info", str_jwdlist);
                            e0.SetAttribute("xlink:href", str_sub);
                            e0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                            e0.SetAttribute("layer", SvgDocument.currentLayer);
                            if (pspid != "")
                            {
                                e0.SetAttribute("Deviceid", pspid);
                            }
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(e0);

                        }

                    }
                }
                //fInfo.Hide();
                ex.Quit();
                frmLoad.Close();
            }
            catch
            {
                MessageBox.Show(" 数据格式错误,请检查。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ex.Quit();
                frmLoad.Close();
            }
        }
Example #9
0
        private void checkwjghelement()
        {
            //判断图元有没有

            wjghelement.Clear();
            XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("svg/use");
            XmlNodeList linelist = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1']");
            string con = "GprogUID='" + ff.Key + "'";
            IList list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            try
            {
                foreach (PSP_GprogElevice pg in list)
                {
                    bool flag = false;
                    if (pg.Type == "变电站" || pg.Type == "电源")
                    {
                        foreach (XmlNode element in useList)
                        {
                            if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid")))
                            {
                                if ((element as XmlElement).GetAttribute("Deviceid") == pg.DeviceSUID)
                                {
                                    flag = true;
                                    if (pg.L2 == "0")
                                    {
                                        pg.L2 = "1";
                                        Services.BaseService.Update<PSP_GprogElevice>(pg);
                                    }
                                    break;
                                }
                            }

                        }
                    }
                    else
                    {
                        foreach (XmlNode element in linelist)
                        {
                            if (!string.IsNullOrEmpty((element as XmlElement).GetAttribute("Deviceid")))
                            {
                                if ((element as XmlElement).GetAttribute("Deviceid") == pg.DeviceSUID)
                                {
                                    //显示隐藏的图元

                                    (element as XmlElement).SetAttribute("visibility", "show");
                                    flag = true;
                                    if (pg.L2 == "0")
                                    {
                                        pg.L2 = "1";
                                        Services.BaseService.Update<PSP_GprogElevice>(pg);
                                    }

                                    break;
                                }
                            }

                        }
                    }
                    if (!flag)
                    {
                        if (pg.L2 == "1")
                        {
                            pg.L2 = "0";
                            Services.BaseService.Update<PSP_GprogElevice>(pg);
                        }

                    }
                    if (pg.Type == "变电站")
                    {
                        PSP_Substation_Info sb = new PSP_Substation_Info();
                        sb.UID = pg.DeviceSUID;
                        sb = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", sb);
                        eleclass el = new eleclass(sb.Title, sb.UID, "20", flag);
                        wjghelement.Add(el);
                    }
                    if (pg.Type == "电源")
                    {
                        PSP_PowerSubstation_Info sb = new PSP_PowerSubstation_Info();
                        sb.UID = pg.DeviceSUID;
                        sb = (PSP_PowerSubstation_Info)Services.BaseService.GetObject("SelectPSP_PowerSubstation_InfoByKey", sb);
                        eleclass el = new eleclass(sb.Title, sb.UID, "30", flag);
                        wjghelement.Add(el);
                    }
                    if (pg.Type == "线路")
                    {
                        PSPDEV sb = new PSPDEV();
                        sb.SUID = pg.DeviceSUID;
                        sb = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", sb);
                        eleclass el = new eleclass(sb.Name, sb.SUID, "05", flag);
                        wjghelement.Add(el);
                    }
                }

            }
            catch (System.Exception ex)
            {

            }
        }
Example #10
0
        void tlVectorControl1_RightClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e)
        {
            str_outjwd = "";
            str_djcl = "";
            sel_sym = "";
            sel_start_point = "";
            if (mapview is MapViewGoogle)
                mapMenu.Visible = true;
            try
            {
                if (csOperation == CustomOperation.OP_MeasureDistance)
                {
                    tlVectorControl1.Operation = ToolOperation.Select;
                    contextMenuStrip1.Hide();
                    return;
                }

                if (tlVectorControl1.Operation == ToolOperation.LeadLine && str_dhx == "1")
                {
                    SvgElement _x = tlVectorControl1.SVGDocument.CurrentElement;
                    _x.SetAttribute("dhx_key", "1");

                }
                //tlVectorControl1.DocumentSize = new SizeF(3170f, 2540f);
                //MessageBox.Show(MapType);
                tmLineConnect.Visible = false;
                SvgElementCollection elements = tlVectorControl1.SVGDocument.SelectCollection;
                if (elements.Count == 2)
                {
                    Polyline pl1 = elements[0] as Polyline;
                    Polyline pl2 = elements[1] as Polyline;
                    if (pl1 != null && pl2 != null && pl1.GetAttribute("IsLead") != "" && pl2.GetAttribute("IsLead") != "")
                    {

                        tmLineConnect.Visible = true;
                    }
                }
                if (MapType == "接线图")
                {
                    tip.Hide();
                    if (getlayer(SvgDocument.currentLayer, "背景层", tlVectorControl1.SVGDocument.getLayerList()))
                    {
                        contextMenuStrip1.Enabled = false;
                    }
                    else
                    {
                        contextMenuStrip1.Enabled = true;
                    }

                    if (tlVectorControl1.SVGDocument.CurrentElement == null ||
                       tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() != "ItopVector.Core.Figure.Use")
                    {
                        moveMenuItem.Visible = false;
                        jxtToolStripMenuItem.Visible = false;
                        w3MenuItem.Visible = false;

                    }
                    else
                    {
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("xlink:href").Contains("Substation"))
                        {
                            moveMenuItem.Visible = true;
                            jxtToolStripMenuItem.Visible = true;
                            w3MenuItem.Visible = true;
                        }
                    }
                    if (show3d == 0)
                    {
                        w3MenuItem.Visible = false;
                    }
                    if (tlVectorControl1.SVGDocument.CurrentElement != null &&
                      tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() != "ItopVector.Core.Figure.RectangleElement" &&
                      tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() != "ItopVector.Core.Figure.Polygon")
                    {
                        printToolStripMenuItem.Visible = false;
                        toolDel.Visible = false;
                        SubToolStripMenuItem.Visible = false;
                    }
                    else
                    {
                        printToolStripMenuItem.Visible = true;
                        toolDel.Visible = true;
                        SubToolStripMenuItem.Visible = false;
                        saveImg.Visible = true;

                    }
                    if (tlVectorControl1.SVGDocument.CurrentElement != null && tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline")
                    {
                        mUpdateMenuItem.Visible = true;
                        tmloctaionjxt.Visible = true;
                    }
                    else
                    {
                        mUpdateMenuItem.Visible = false;
                        tmloctaionjxt.Visible = false;
                    }
                    string guid = Guid.NewGuid().ToString();
                    if (tlVectorControl1.Operation == ToolOperation.LeadLine && linekey != "")
                    {
                        string str = "";

                        LineList1 line1 = new LineList1();
                        line1.UID = Guid.NewGuid().ToString();
                        line1.LineEleID = tlVectorControl1.SVGDocument.CurrentElement.ID;
                        line1.PointNum = ((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)).Points.Length - 2;
                        line1.Coefficient = (decimal)(1.02);
                        line1.Length = TLMath.getPolylineLength(((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)), Convert.ToDecimal(tlVectorControl1.ScaleRatio));
                        line1.Length2 = TLMath.getPolylineLength(((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)), Convert.ToDecimal(tlVectorControl1.ScaleRatio)) * Convert.ToDecimal(1.02);
                        PointF[] pnt = ((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)).Points;
                        if (pnt.Length < 3) return;
                        for (int i = 0; i < pnt.Length; i++)
                        {
                            double ang = TLMath.getLineAngle(pnt[i], pnt[i + 1], pnt[i + 2]);
                            if (ang * 57.3 > 60)
                            {
                                MessageBox.Show("线路转角不能大于60度。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                tlVectorControl1.Delete();
                                return;
                            }
                            str = str + "第" + (i + 1) + "转角:" + Convert.ToDouble(ang * 57.3).ToString("##.##") + "度。\r\n";
                            if (i == pnt.Length - 3)
                            {
                                break;
                            }
                        }
                        line1.TurnAngle = str;
                        line1.col1 = linekey;
                        frmInputDialog input = new frmInputDialog();
                        if (input.ShowDialog() == DialogResult.OK)
                        {
                            line1.LineName = input.InputStr;
                            Services.BaseService.Create<LineList1>(line1);
                        }
                        else
                        {
                            tlVectorControl1.Delete();
                        }
                        linekey = "";

                    }
                    if (tlVectorControl1.Operation == ToolOperation.InterEnclosure && bdz_xz == "yes")
                    {
                        D_TIN.Clear();
                        ArrayList polylist = new ArrayList();
                        ArrayList useList = new ArrayList();
                        System.Collections.SortedList list = new SortedList();
                        ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection;
                        int t = 0;
                    Lab009:
                        t = t + 1;
                        XmlElement poly1 = (XmlElement)selCol[selCol.Count - t];
                        if (poly1.GetType().FullName != "ItopVector.Core.Figure.Polygon")
                        {
                            goto Lab009;
                        }

                        SvgElement se = null;
                        for (int i = 0; i < selCol.Count; i++)
                        {
                            string tem = selCol[i].GetType().FullName;
                            if (tem == "ItopVector.Core.Figure.Polygon")
                            {

                                string IsArea = ((XmlElement)selCol[i]).GetAttribute("IsArea");
                                if (IsArea == "")
                                {
                                    se = (SvgElement)selCol[i];   //大范围
                                }
                                else
                                {
                                    polylist.Add((SvgElement)selCol[i]);
                                }
                            }
                            if (tem == "ItopVector.Core.Figure.Use")
                            {
                                useList.Add((SvgElement)selCol[i]);
                            }
                        }
                        decimal sumss = 0;
                        for (int m = 0; m < polylist.Count; m++)
                        {
                            XmlElement _x = (XmlElement)polylist[m];

                            string sid = _x.GetAttribute("id");
                            glebeProperty pl = new glebeProperty();
                            pl.EleID = sid;
                            pl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            pl = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", pl);
                            if (pl != null)
                            {
                                sumss = sumss + pl.Burthen;//区域负荷
                            }

                        }
                        double sumSub = 0;
                        for (int m = 0; m < useList.Count; m++)
                        {
                            XmlElement _x = (XmlElement)useList[m];

                            string sid = _x.GetAttribute("Deviceid");
                            PSP_Substation_Info pl = new PSP_Substation_Info();
                            pl.UID = sid;
                            //pl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            pl = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", pl);
                            if (pl != null)
                            {
                                sumSub = sumSub + pl.L2;  //现有的容量
                            }
                        }

                        FrmSet f_set = new FrmSet();
                        f_set.s = sumss;
                        f_set.sub_s = sumSub;
                        if (f_set.ShowDialog() == DialogResult.OK)
                        {
                            str_dy = f_set.Str_dj;   //电压等级
                            str_num = f_set.Str_num;  //所需建的数目
                            str_jj = f_set.Str_jj;//变电站最小距离

                            tlVectorControl1.SVGDocument.SelectCollection.Clear();

                            if (Convert.ToDecimal(str_num) < 0)
                            {
                                MessageBox.Show("区域内供电满足要求,不需要新建变电站。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                            Polygon pp = se as Polygon;

                            if (useList.Count < 3)
                            {
                                for (int i = 0; i < pp.Points.Length; i++)
                                {
                                    //加点
                                    D_TIN.DS.Vertex[D_TIN.DS.VerticesNum].x = (long)pp.Points[i].X;
                                    D_TIN.DS.Vertex[D_TIN.DS.VerticesNum].y = (long)pp.Points[i].Y;
                                    D_TIN.DS.Vertex[D_TIN.DS.VerticesNum].ID = D_TIN.DS.VerticesNum;
                                    D_TIN.DS.vetexboundary[D_TIN.DS.VerticesNum].pointid = D_TIN.DS.VerticesNum;//填写各个节点泰森多边形影响区域
                                    D_TIN.DS.VerticesNum++;
                                }
                            }
                            else
                            {
                                for (int m = 0; m < useList.Count; m++)
                                {
                                    Use _p = useList[m] as Use;
                                    string str_t = _p.GetAttribute("xlink:href");

                                    PointF of = TLMath.getUseOffset(str_t);
                                    PointF p1 = new PointF(_p.X, _p.Y);
                                    PointF[] pnt = new PointF[1];
                                    pnt[0] = p1;
                                    _p.Transform.Matrix.TransformPoints(pnt);
                                    D_TIN.DS.Vertex[D_TIN.DS.VerticesNum].x = (long)pnt[0].X + (long)of.X;
                                    D_TIN.DS.Vertex[D_TIN.DS.VerticesNum].y = (long)pnt[0].Y + (long)of.Y;
                                    D_TIN.DS.Vertex[D_TIN.DS.VerticesNum].ID = D_TIN.DS.VerticesNum;
                                    D_TIN.DS.vetexboundary[D_TIN.DS.VerticesNum].pointid = D_TIN.DS.VerticesNum;//填写各个节点泰森多边形影响区域
                                    D_TIN.DS.VerticesNum++;
                                }
                            }
                            if ((Convert.ToInt32(str_num) > 1) && (sumss == 0) && (useList.Count > Convert.ToInt32(str_num) + 2))
                            {
                                if ((MessageBox.Show("区域内负荷为0,无法进行负荷分布自动选址。\r\n 是否进行最小覆盖圆自动选址?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) == DialogResult.Yes)
                                {
                                    int n = D_TIN.DS.VerticesNum;
                                    D_TIN.DS.set_cnt = D_TIN.DS.VerticesNum; D_TIN.DS.pos_cnt = 0;
                                    for (int i = 0; i < n; i++)
                                        D_TIN.DS.curset[i] = i;

                                    D_TIN.mindisk();
                                    Pen p2 = new Pen(Color.Red, 2);
                                    Rectangle rec = new Rectangle((int)(D_TIN.DS.maxcic.x - D_TIN.DS.radius), (int)(D_TIN.DS.maxcic.y - D_TIN.DS.radius), (int)(2 * D_TIN.DS.radius), (int)(2 * D_TIN.DS.radius));
                                    string str_sub = getSubName(str_dy);
                                    PointF pf = getOff(str_dy);

                                    XmlElement e0 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement;
                                    e0.SetAttribute("x", Convert.ToString(D_TIN.DS.maxcic.x - pf.X));
                                    e0.SetAttribute("y", Convert.ToString(D_TIN.DS.maxcic.y - pf.Y));
                                    e0.SetAttribute("xzflag", "1");
                                    e0.SetAttribute("xlink:href", str_sub);
                                    e0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                    e0.SetAttribute("layer", SvgDocument.currentLayer);
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(e0);
                                    tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e0);
                                    //获得此变电站的最小半径的圆 生成辐射线
                                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                                    n1.SetAttribute("cx", e0.GetAttribute("x").ToString());
                                    n1.SetAttribute("cy", e0.GetAttribute("y").ToString());
                                    n1.SetAttribute("r", (TLMath.getdcNumber(Convert.ToDecimal(str_jj), tlVectorControl1.ScaleRatio)).ToString());

                                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                                    n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;");
                                    SubandFHcollect sf = new SubandFHcollect(GetsubFhk((Circle)n1, polylist), e0);
                                    CreateSubline(sf);
                                    //
                                    XmlElement t0 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    t0.SetAttribute("x", Convert.ToString(D_TIN.DS.maxcic.x));
                                    t0.SetAttribute("y", Convert.ToString(D_TIN.DS.maxcic.y));

                                    t0.SetAttribute("layer", SvgDocument.currentLayer);
                                    t0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                    t0.SetAttribute("font-famliy", "宋体");
                                    t0.SetAttribute("font-size", "48");
                                    t0.InnerText = "1号";
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(t0);

                                    PSP_SubstationSelect s = new PSP_SubstationSelect();
                                    s.UID = Guid.NewGuid().ToString();
                                    s.EleID = e0.GetAttribute("id");
                                    s.SName = "1号";
                                    s.Remark = "";
                                    s.col2 = XZ_bdz;
                                    s.SvgID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    Services.BaseService.Create<PSP_SubstationSelect>(s);

                                    decimal c = 360 / (Convert.ToInt32(str_num));
                                    for (int k = 2; k <= Convert.ToInt32(str_num); k++)
                                    {

                                        decimal x = Convert.ToDecimal(D_TIN.DS.maxcic.x + D_TIN.DS.radius * Math.Cos(Convert.ToDouble(c * k) * Math.PI / 180));
                                        decimal y = Convert.ToDecimal(D_TIN.DS.maxcic.y + D_TIN.DS.radius * Math.Sin(Convert.ToDouble(c * k) * Math.PI / 180));

                                        XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement;
                                        e1.SetAttribute("x", Convert.ToString(Convert.ToSingle(x) - pf.X));
                                        e1.SetAttribute("y", Convert.ToString(Convert.ToSingle(y) - pf.Y));
                                        e1.SetAttribute("xzflag", "1");
                                        e1.SetAttribute("xlink:href", str_sub);
                                        e1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                        e1.SetAttribute("layer", SvgDocument.currentLayer);
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(e1);
                                        tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e1);
                                        //获得此变电站的最小半径的圆 生成辐射线
                                        n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                                        n1.SetAttribute("cx", e1.GetAttribute("x").ToString());
                                        n1.SetAttribute("cy", e1.GetAttribute("y").ToString());
                                        n1.SetAttribute("r", (TLMath.getdcNumber(Convert.ToDecimal(str_jj), tlVectorControl1.ScaleRatio)).ToString());

                                        n1.SetAttribute("layer", SvgDocument.currentLayer);
                                        n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;");
                                         sf = new SubandFHcollect(GetsubFhk((Circle)n1, polylist), e1);
                                        CreateSubline(sf);
                                        //
                                        PSP_SubstationSelect s2 = new PSP_SubstationSelect();
                                        s2.UID = Guid.NewGuid().ToString();
                                        s2.EleID = e1.GetAttribute("id");
                                        s2.SName = Convert.ToString((k)) + "号";
                                        s2.Remark = "";
                                        s2.col2 = XZ_bdz;
                                        s2.SvgID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        Services.BaseService.Create<PSP_SubstationSelect>(s2);

                                        XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                        t1.SetAttribute("x", Convert.ToString(x));
                                        t1.SetAttribute("y", Convert.ToString(y));

                                        t1.SetAttribute("layer", SvgDocument.currentLayer);
                                        t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                        t1.SetAttribute("font-famliy", "宋体");
                                        t1.SetAttribute("font-size", "54");
                                        t1.InnerText = Convert.ToString((k)) + "号";
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(t1);
                                    }
                                    return;
                                }
                            }
                            if ((Convert.ToInt32(str_num) > 1) && (useList.Count < Convert.ToInt32(str_num) + 2))
                            {
                                if ((MessageBox.Show("当自动选址变电站个数等于" + str_num + "时,区域内必须至少有" + Convert.ToString(Convert.ToInt32(str_num) + 2) + "座已有变电站,否则无法进行负荷分布自动选址。\r\n 是否进行最小覆盖圆自动选址?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) == DialogResult.Yes)
                                {

                                    int n = D_TIN.DS.VerticesNum;
                                    D_TIN.DS.set_cnt = D_TIN.DS.VerticesNum; D_TIN.DS.pos_cnt = 0;
                                    for (int i = 0; i < n; i++)
                                        D_TIN.DS.curset[i] = i;

                                    D_TIN.mindisk();
                                    Pen p2 = new Pen(Color.Red, 2);
                                    Rectangle rec = new Rectangle((int)(D_TIN.DS.maxcic.x - D_TIN.DS.radius), (int)(D_TIN.DS.maxcic.y - D_TIN.DS.radius), (int)(2 * D_TIN.DS.radius), (int)(2 * D_TIN.DS.radius));
                                    string str_sub = getSubName(str_dy);

                                    //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                                    //// Point point1 = tlVectorControl1.PointToView(new Point((int)D_TIN.DS.maxcic.x, (int)D_TIN.DS.maxcic.y));
                                    //n1.SetAttribute("cx", D_TIN.DS.maxcic.x.ToString());
                                    //n1.SetAttribute("cy", D_TIN.DS.maxcic.y.ToString());
                                    //n1.SetAttribute("r", D_TIN.DS.radius.ToString());
                                    //n1.SetAttribute("r", D_TIN.DS.radius.ToString());
                                    //n1.SetAttribute("layer", SvgDocument.currentLayer);
                                    //n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;");
                                    //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                    //str_sub = getSubName(str_dy);
                                    PointF pf = getOff(str_dy);

                                    XmlElement e0 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement;
                                    e0.SetAttribute("x", Convert.ToString(D_TIN.DS.maxcic.x - pf.X));
                                    e0.SetAttribute("y", Convert.ToString(D_TIN.DS.maxcic.y - pf.Y));
                                    e0.SetAttribute("xzflag", "1");
                                    e0.SetAttribute("xlink:href", str_sub);
                                    e0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                    e0.SetAttribute("layer", SvgDocument.currentLayer);
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(e0);
                                    tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e0);
                                    //获得此变电站的最小半径的圆 生成辐射线
                                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                                    n1.SetAttribute("cx", e0.GetAttribute("x").ToString());
                                    n1.SetAttribute("cy", e0.GetAttribute("y").ToString());
                                    n1.SetAttribute("r", (TLMath.getdcNumber(Convert.ToDecimal(str_jj), tlVectorControl1.ScaleRatio)).ToString());

                                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                                    n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;");
                                    SubandFHcollect sf = new SubandFHcollect(GetsubFhk((Circle)n1, polylist), e0);
                                    CreateSubline(sf);
                                    //
                                    XmlElement t0 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                    t0.SetAttribute("x", Convert.ToString(D_TIN.DS.maxcic.x));
                                    t0.SetAttribute("y", Convert.ToString(D_TIN.DS.maxcic.y));

                                    t0.SetAttribute("layer", SvgDocument.currentLayer);
                                    t0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                    t0.SetAttribute("font-famliy", "宋体");
                                    t0.SetAttribute("font-size", "48");
                                    t0.InnerText = "1号";
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(t0);

                                    PSP_SubstationSelect s = new PSP_SubstationSelect();
                                    s.UID = Guid.NewGuid().ToString();
                                    s.EleID = e0.GetAttribute("id");
                                    s.SName = "1号";
                                    s.Remark = "";
                                    s.col2 = XZ_bdz;
                                    s.SvgID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    Services.BaseService.Create<PSP_SubstationSelect>(s);

                                    decimal c = 360 / (Convert.ToInt32(str_num));
                                    for (int k = 2; k <= Convert.ToInt32(str_num); k++)
                                    {

                                        decimal x = Convert.ToDecimal(D_TIN.DS.maxcic.x + D_TIN.DS.radius * Math.Cos(Convert.ToDouble(c * k) * Math.PI / 180));
                                        decimal y = Convert.ToDecimal(D_TIN.DS.maxcic.y + D_TIN.DS.radius * Math.Sin(Convert.ToDouble(c * k) * Math.PI / 180));

                                        XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement;
                                        e1.SetAttribute("x", Convert.ToString(Convert.ToSingle(x) - pf.X));
                                        e1.SetAttribute("y", Convert.ToString(Convert.ToSingle(y) - pf.Y));
                                        e1.SetAttribute("xzflag", "1");
                                        e1.SetAttribute("xlink:href", str_sub);
                                        e1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                        e1.SetAttribute("layer", SvgDocument.currentLayer);
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(e1);
                                        tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e1);
                                        //获得此变电站的最小半径的圆 生成辐射线
                                          n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                                        n1.SetAttribute("cx", e1.GetAttribute("x").ToString());
                                        n1.SetAttribute("cy", e1.GetAttribute("y").ToString());
                                        n1.SetAttribute("r", (TLMath.getdcNumber(Convert.ToDecimal(str_jj), tlVectorControl1.ScaleRatio)).ToString());

                                        n1.SetAttribute("layer", SvgDocument.currentLayer);
                                        n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;");
                                       sf = new SubandFHcollect(GetsubFhk((Circle)n1, polylist), e1);
                                        CreateSubline(sf);
                                        //
                                        PSP_SubstationSelect s2 = new PSP_SubstationSelect();
                                        s2.UID = Guid.NewGuid().ToString();
                                        s2.EleID = e1.GetAttribute("id");
                                        s2.SName = Convert.ToString((k)) + "号";
                                        s2.Remark = "";
                                        s2.col2 = XZ_bdz;
                                        s2.SvgID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        Services.BaseService.Create<PSP_SubstationSelect>(s2);

                                        XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                        t1.SetAttribute("x", Convert.ToString(x));
                                        t1.SetAttribute("y", Convert.ToString(y));

                                        t1.SetAttribute("layer", SvgDocument.currentLayer);
                                        t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                        t1.SetAttribute("font-famliy", "宋体");
                                        t1.SetAttribute("font-size", "54");
                                        t1.InnerText = Convert.ToString((k)) + "号";
                                        tlVectorControl1.SVGDocument.RootElement.AppendChild(t1);
                                    }
                                    return;
                                }
                                else
                                {
                                    bdz_xz = "";
                                    return;
                                }
                            }

                            if (str_num == "1" && useList.Count < 3)
                            {
                                int n = D_TIN.DS.VerticesNum;
                                D_TIN.DS.set_cnt = D_TIN.DS.VerticesNum; D_TIN.DS.pos_cnt = 0;
                                for (int i = 0; i < n; i++)
                                    D_TIN.DS.curset[i] = i;

                                D_TIN.mindisk();
                                Pen p2 = new Pen(Color.Red, 2);
                                Rectangle rec = new Rectangle((int)(D_TIN.DS.maxcic.x - D_TIN.DS.radius), (int)(D_TIN.DS.maxcic.y - D_TIN.DS.radius), (int)(2 * D_TIN.DS.radius), (int)(2 * D_TIN.DS.radius));

                                // g.DrawEllipse(p2, rec);
                                //string ele_uid = "";
                                string str_sub = getSubName(str_dy);

                                XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                                // Point point1 = tlVectorControl1.PointToView(new Point((int)D_TIN.DS.maxcic.x, (int)D_TIN.DS.maxcic.y));
                                n1.SetAttribute("cx", D_TIN.DS.maxcic.x.ToString());
                                n1.SetAttribute("cy", D_TIN.DS.maxcic.y.ToString());
                                n1.SetAttribute("r", D_TIN.DS.radius.ToString());
                                n1.SetAttribute("r", D_TIN.DS.radius.ToString());
                                n1.SetAttribute("layer", SvgDocument.currentLayer);
                                n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;");
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);

                                PointF pf = getOff(str_dy);
                                XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement;
                                e1.SetAttribute("x", Convert.ToString(D_TIN.DS.maxcic.x - pf.X));
                                e1.SetAttribute("y", Convert.ToString(D_TIN.DS.maxcic.y - pf.Y));
                                e1.SetAttribute("xzflag", "1");
                                e1.SetAttribute("xlink:href", str_sub);
                                e1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                e1.SetAttribute("layer", SvgDocument.currentLayer);
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(e1);
                                tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e1);
                                //获得此变电站的最小半径的圆 生成辐射线

                                SubandFHcollect sf = new SubandFHcollect(GetsubFhk((Circle)n1, polylist), e1);
                                CreateSubline(sf);
                                //
                                PSP_SubstationSelect s2 = new PSP_SubstationSelect();
                                s2.UID = Guid.NewGuid().ToString();
                                s2.EleID = e1.GetAttribute("id");
                                s2.SName = "1号";
                                s2.Remark = "";
                                s2.col2 = XZ_bdz;
                                s2.SvgID = tlVectorControl1.SVGDocument.SvgdataUid;
                                Services.BaseService.Create<PSP_SubstationSelect>(s2);

                                tlVectorControl1.Refresh();
                                // Thread.Sleep(3);
                                tlVectorControl1.SVGDocument.RootElement.RemoveChild(n1);

                                XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                                t1.SetAttribute("x", Convert.ToString(D_TIN.DS.maxcic.x));
                                t1.SetAttribute("y", Convert.ToString(D_TIN.DS.maxcic.y));

                                t1.SetAttribute("layer", SvgDocument.currentLayer);
                                t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                t1.SetAttribute("font-famliy", "宋体");
                                t1.SetAttribute("font-size", "54");
                                t1.InnerText = "1号";
                                tlVectorControl1.SVGDocument.RootElement.AppendChild(t1);

                                bdz_xz = "";
                                return;
                            }
                            else
                            {
                               // ShowTriangle(polylist, poly1);    //王哥写的
                                ShowTriangle1(polylist, poly1);
                                bdz_xz = "";
                                return;
                            }
                        }
                        else
                        {
                            bdz_xz = "";
                            return;
                        }
                    }
                    if (tlVectorControl1.Operation == ToolOperation.InterEnclosure && !SubPrint)
                    {

                        System.Collections.SortedList list = new SortedList();
                        decimal s = 0;
                        ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection;
                        if (selCol.Count > 1)
                        {
                            decimal ViewScale = 1;
                            string str_Scale = Convert.ToString(tlVectorControl1.ScaleRatio);//SVGDocument.getViewScale();
                            if (str_Scale != "")
                            {
                                ViewScale = Convert.ToDecimal(str_Scale);
                            }
                            string str_remark = "";
                            string str_selArea = "";
                            //string Elements = "";
                            Hashtable SelAreaCol = new Hashtable();
                            this.Cursor = Cursors.WaitCursor;
                            int t = 0;
                        Lab001:
                            t = t + 1;
                            XmlElement poly1 = (XmlElement)selCol[selCol.Count - t];
                            if (poly1.GetType().FullName != "ItopVector.Core.Figure.Polygon")
                            {
                                // selCol.Remove(selCol[selCol.Count-1]);
                                goto Lab001;
                            }
                            frmWaiting wait = new frmWaiting();
                            wait.Show(this);
                            wait.Refresh();

                            GraphicsPath gr1 = new GraphicsPath();
                            //gr1.AddRectangle(TLMath.getRectangle(poly1));
                            gr1.AddPolygon(TLMath.getPolygonPoints(poly1));
                            gr1.CloseFigure();

                            for (int i = 0; i < selCol.Count - 1; i++)
                            {
                                if (selCol[i].GetType().FullName == "ItopVector.Core.Figure.Polygon")
                                {

                                    string IsArea = ((XmlElement)selCol[i]).GetAttribute("IsArea");
                                    if (IsArea != "")
                                    {
                                        XmlElement polyn = (XmlElement)selCol[i];
                                        GraphicsPath gr2 = new GraphicsPath();
                                        //gr2.AddRectangle(TLMath.getRectangle(polyn));
                                        gr2.AddPolygon(TLMath.getPolygonPoints(polyn));
                                        gr2.CloseFigure();
                                        Region region = new Region(gr1);
                                        region.Intersect(gr2);

                                        RectangleF rect = new RectangleF();
                                        rect = tlVectorControl1.SelectedRectangle(region);

                                        decimal sub_s = TLMath.getInterPolygonArea(region, rect, 1);
                                        sub_s = TLMath.getNumber2(sub_s, tlVectorControl1.ScaleRatio) / Convert.ToDecimal(areaoption);
                                        SelAreaCol.Add(polyn.GetAttribute("id"), sub_s);
                                        glebeProperty _gleProp = new glebeProperty();
                                        _gleProp.EleID = polyn.GetAttribute("id");
                                        _gleProp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                        IList gList = Services.BaseService.GetList("SelectglebePropertyByEleID", _gleProp);

                                        if (gList.Count > 0)
                                        {
                                            _gleProp = (glebeProperty)gList[0];
                                            list.Add(_gleProp.UseID, sub_s.ToString("#####.####"));
                                            str_selArea = str_selArea + _gleProp.EleID + "," + sub_s.ToString("#####.####") + ";";
                                            //str_remark = str_remark + "地块" + _gleProp.UseID + "选中面积为:" + sub_s.ToString() + "\r\n";
                                            s += sub_s;
                                        }
                                    }
                                }
                                if (selCol[i].GetType().FullName == "ItopVector.Core.Figure.Use")
                                {
                                    XmlElement e1 = (XmlElement)selCol[i];
                                    string str_id = e1.GetAttribute("id");

                                    // PSP_Substation_Info _sub1 = new PSP_Substation_Info();
                                    //// substation _sub1 = new substation();
                                    // _sub1.EleID = str_id;
                                    // _sub1.AreaID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    // _sub1 = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoListByEleID", _sub1);
                                    // if (_sub1 != null)
                                    // {
                                    //     _sub1.glebeEleID = guid;
                                    //     Services.BaseService.Update<PSP_Substation_Info>( _sub1);
                                    // }

                                }

                            }
                            decimal nullpoly = TLMath.getNumber2(TLMath.getPolygonArea(TLMath.getPolygonPoints(poly1), 1), tlVectorControl1.ScaleRatio) / Convert.ToDecimal(areaoption) - s;

                            for (int j = 0; j < list.Count; j++)
                            {
                                if (Convert.ToString(list.GetByIndex(j)) != "")
                                {
                                    if (Convert.ToDecimal(list.GetByIndex(j)) < 1)
                                    {
                                        str_remark = str_remark + "地块" + list.GetKey(j).ToString() + "选中面积为:" + "0" + list.GetByIndex(j).ToString() + "(KM²)\r\n";
                                    }
                                    else
                                    {
                                        str_remark = str_remark + "地块" + list.GetKey(j).ToString() + "选中面积为:" + list.GetByIndex(j).ToString() + "(KM²)\r\n";
                                    }
                                }
                            }
                            XmlElement x1 = poly1;// (XmlElement)selCol[selCol.Count - 1];

                            gPro.UID = guid;
                            gPro.EleID = x1.GetAttribute("id");
                            gPro.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            gPro.ParentEleID = "0";
                            if (s != 0)
                            {
                                gPro.Area = Convert.ToDecimal(s.ToString("#####.####"));
                            }
                            else
                            {
                                gPro.Area = 0;
                            }
                            gPro.SelSonArea = str_selArea;

                            if (nullpoly < 1)
                            {
                                gPro.ObligateField10 = "0" + nullpoly.ToString("#####.####");
                            }
                            else
                            {
                                gPro.ObligateField10 = nullpoly.ToString("#####.####");
                            }

                            str_remark = str_remark + "\r\n 空白区域面积" + gPro.ObligateField10 + "(KM²)\r\n";
                            if (str_remark != "")
                            {
                                str_remark = str_remark.Substring(0, str_remark.Length - 2);
                            }

                            gPro.Remark = str_remark;
                            wait.Close();
                            this.Cursor = Cursors.Default;
                            if (s < 1)
                            {
                                MessageBox.Show("选中区域面积:" + "0" + s.ToString("#####.####") + "(KM²)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                MessageBox.Show("选中区域面积:" + s.ToString("#####.####") + "(KM²)", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }

                            Services.BaseService.Create<glebeProperty>(gPro);

                            IDictionaryEnumerator ISelList = SelAreaCol.GetEnumerator();
                            while (ISelList.MoveNext())
                            {
                                glebeProperty sub_gle = new glebeProperty();
                                sub_gle.EleID = ISelList.Key.ToString();
                                sub_gle.ParentEleID = gPro.EleID;
                                sub_gle.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                Services.BaseService.Update("UpdateglebePropertySelArea", sub_gle);
                            }

                            tlVectorControl1.SVGDocument.SelectCollection.Clear();
                            tlVectorControl1.SVGDocument.CurrentElement = (SvgElement)x1;
                        }
                        SubPrint = false;
                    }
                    if (tlVectorControl1.CurrentOperation == ToolOperation.InterEnclosure && SubPrint)
                    {
                        //ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection;
                        //if(selCol.Count>2){
                        //    XmlElement selArea = (SvgElement)selCol[selCol.Count - 1];

                        //    GraphicsPath gr1 = new GraphicsPath();
                        //    gr1.AddPolygon(TLMath.getPolygonPoints(selArea));
                        //    gr1.CloseFigure();
                        //    RectangleF rect= gr1.GetBounds();

                        //    SvgDocument _doc = new SvgDocument();
                        //    string svgtxt = "<?xml version=\"1.0\" encoding=\"utf-8\"?><svg id=\"svg\" width=\""+rect.Width+"\" height=\""+rect.Height+"\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:itop=\"http://www.Itop.com/itop\">";

                        //    for (int n = 0; n < selCol.Count-1;n++ )
                        //    {
                        //        //_doc.AppendChild((XmlNode)selCol[n]);
                        //        svgtxt=svgtxt+((XmlElement)selCol[n]).OuterXml+"\r\n";
                        //    }
                        //    svgtxt = svgtxt + "</svg>";
                        //    _doc.LoadXml(svgtxt);
                        //    frmSubPrint s = new frmSubPrint();
                        //    s.Show();
                        //    s.Open(_doc, rect);
                        ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection;
                        XmlElement x1 = (XmlElement)selCol[selCol.Count - 1];
                        tlVectorControl1.SVGDocument.SelectCollection.Clear();
                        tlVectorControl1.SVGDocument.CurrentElement = (SvgElement)x1;
                        SubPrint = false;
                        //}
                    }
                    if (tlVectorControl1.Operation == ToolOperation.Enclosure)
                    {

                        string Elements = "";
                        ItopVector.Core.SvgElementCollection selCol = tlVectorControl1.SVGDocument.SelectCollection;

                        for (int i = 0; i < selCol.Count - 1; i++)
                        {
                            XmlElement e1 = (XmlElement)selCol[i];
                            Elements = Elements + "'" + e1.GetAttribute("id") + "',";
                        }
                        if (Elements.Length > 0)
                        {
                            Elements = Elements.Substring(0, Elements.Length - 1);
                        }
                        XmlElement x1 = (XmlElement)selCol[selCol.Count - 1];

                        gPro.UID = Guid.NewGuid().ToString();
                        gPro.EleID = x1.GetAttribute("id");

                        gPro.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                        gPro.SonUid = Elements;
                        Services.BaseService.Create<glebeProperty>(gPro);

                        tlVectorControl1.SVGDocument.SelectCollection.Clear();
                        tlVectorControl1.SVGDocument.CurrentElement = (SvgElement)x1;

                    }
                    if (tlVectorControl1.CurrentOperation == ToolOperation.LeadLine)
                    {
                        sgt1.Visible = false;
                    }
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                tlVectorControl1.SVGDocument.SelectCollection.Clear();
            }
            finally
            {
                tlVectorControl1.Operation = ToolOperation.Select;
                tlVectorControl1.Operation = ToolOperation.FreeTransform;

            }
        }
Example #11
0
        void tlVectorControl1_LeftClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e)
        {
            //SvgElement ele2 = tlVectorControl1.CreateBySymbolID("kbs-8", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
            //ele2 = tlVectorControl1.AddShape(ele2, Point.Empty);
            if (tlVectorControl1.SVGDocument.CurrentElement != null &&
                tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("xlink:href").Contains("XL_GT_1"))
            {
                sel_start_point = tlVectorControl1.SVGDocument.CurrentElement.ID;
            }

            if (sel_sym == "bt_start")
            {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_1", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele = tlVectorControl1.AddShape(ele, Point.Empty);
                ele.SetAttribute("order", "0");
                ele.SetAttribute("start_point", ele.ID);
            }
            if (sel_sym == "bt_end")
            {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_2", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele.SetAttribute("start_point", sel_start_point);
                ele.SetAttribute("order", "999");
                tlVectorControl1.AddShape(ele, Point.Empty);
            }
            if (sel_sym == "bt_must")
            {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_3", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele.SetAttribute("start_point", sel_start_point);
                tlVectorControl1.AddShape(ele, Point.Empty);
                frmInputNum num = new frmInputNum();
                num.ShowDialog();
                ele.SetAttribute("order", num.InputStrSEL);
            }
            if (sel_sym == "bt_point")
            {
                SvgElement ele = tlVectorControl1.CreateBySymbolID("XL_GT_4", (tlVectorControl1.DrawArea.PointToView(e.Mouse.Location)));
                ele.SetAttribute("start_point", sel_start_point);
                tlVectorControl1.AddShape(ele, Point.Empty);
                frmInputNum num = new frmInputNum();
                num.ShowDialog();
                ele.SetAttribute("order", num.InputStrSEL);
            }
            //if (sel_sym != "" && sel_start_point!="")
            //{
            //    XmlNodeList il= tlVectorControl1.SVGDocument.SelectNodes("svg/use [@start_point='" + sel_start_point + "']");
            //    if (il.Count < 3)
            //    {
            //        return;
            //    }
            //    for (int i = 0; i < il.Count;i++ )
            //    {
            //        Use u = (Use)il[i];
            //        PointF f = u.CenterPoint;

            //    }
            //    //PointF[] pnt = ((Polyline)(tlVectorControl1.SVGDocument.CurrentElement)).Points;
            //    //if (pnt.Length < 3) return;
            //    for (int i = 0; i < il.Count; i++)
            //    {
            //        double ang = TLMath.getLineAngle(((Use)il[i]).CenterPoint, ((Use)il[i + 1]).CenterPoint, ((Use)il[i + 2]).CenterPoint);
            //        if (ang * 57.3 > 60)
            //        {
            //            MessageBox.Show("线路转角不能大于60度。\r\n "+"第" + (i + 1) + "转角:" + Convert.ToDouble(ang * 57.3).ToString("##.##") + "度。\r\n", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //           // tlVectorControl1.Delete();
            //            return;
            //        }

            //        if (i == il.Count - 3)
            //        {
            //            break;
            //        }
            //    }
            //}
            if (csOperation == CustomOperation.OP_MeasureDistance)
            {
                Polyline pl = tlVectorControl1.SVGDocument.CurrentElement as Polyline;
                if (pl.Points.Length > 1)
                {
                    double d = 0;
                    for (int i = 1; i < pl.Points.Length; i++)
                    {
                        d += this.mapview.CountLength(pl.Points[i - 1], pl.Points[i]);
                    }
                    label1.Text = Math.Round(d, 3) + "公里";

                    Point pt = new Point(e.Mouse.X, e.Mouse.Y);
                    pt = PointToClient(tlVectorControl1.PointToScreen(pt));
                    //tlVectorControl1.SetToolTip(label1.Text);
                    label1.Left = pt.X;
                    label1.Top = pt.Y;

                    label1.Visible = true;
                }
                return;
            }

            tip.Hide();
            fInfo.Hide();

            if (tlVectorControl1.Operation == ToolOperation.Text)
            {
                frmTextInput ft = new frmTextInput();
                if (ft.ShowDialog() == DialogResult.OK)
                {
                    string txt = ft.Content;
                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                    Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    n1.SetAttribute("x", point1.X.ToString());
                    n1.SetAttribute("y", point1.Y.ToString());
                    n1.InnerText = txt;
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                    tlVectorControl1.Operation = ToolOperation.Select;
                }
            }
            if (MapType == "规划统计")
            {
                try
                {
                    if (e.SvgElement.ID == "svg")
                    {
                        MapType = "接线图";
                        return;
                    }
                    if (((Polygon)e.SvgElement) == null) return;
                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                    Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    n1.SetAttribute("cx", point1.X.ToString());
                    n1.SetAttribute("cy", point1.Y.ToString());
                    n1.SetAttribute("r", "42.5");
                    n1.SetAttribute("r", "42.5");
                    //n1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID);
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;");
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);

                    frmMainProperty fmain = new frmMainProperty();
                    glebeProperty gp = new glebeProperty();
                    gp.EleID = ((XmlElement)e.SvgElement).GetAttribute("id");
                    gp.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    //fmain.InitData(gp); ///////////////////////////////////

                    XmlNodeList nlist = tlVectorControl1.SVGDocument.GetElementsByTagName("use");

                    PointF[] tfArray1 = TLMath.getPolygonPoints((XmlElement)e.SvgElement);
                    string str220 = "";
                    string str110 = "";
                    string str66 = "";
                    GraphicsPath selectAreaPath = new GraphicsPath();
                    selectAreaPath.AddLines(tfArray1);
                    selectAreaPath.CloseFigure();
                    //Matrix x=new Matrix(
                    //Region region1 = new Region(selectAreaPath);
                    for (int i = 0; i < nlist.Count; i++)
                    {
                        float OffX = 0f;
                        float OffY = 0f;
                        Use use = (Use)nlist[i];
                        if (use.GetAttribute("xlink:href").Contains("Substation"))
                        {
                            string strMatrix = use.GetAttribute("transform");
                            if (strMatrix != "")
                            {
                                strMatrix = strMatrix.Replace("matrix(", "");
                                strMatrix = strMatrix.Replace(")", "");
                                string[] mat = strMatrix.Split(',');
                                if (mat.Length > 5)
                                {
                                    OffX = Convert.ToSingle(mat[4]);
                                    OffY = Convert.ToSingle(mat[5]);
                                }
                            }
                            PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href"));
                            if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY))
                            {
                                if (use.GetAttribute("xlink:href").Contains("220"))
                                {
                                    str220 = str220 + "'" + use.GetAttribute("id") + "',";
                                }
                                if (use.GetAttribute("xlink:href").Contains("110"))
                                {
                                    str110 = str110 + "'" + use.GetAttribute("id") + "',";
                                }
                                if (use.GetAttribute("xlink:href").Contains("66"))
                                {
                                    str66 = str66 + "'" + use.GetAttribute("id") + "',";
                                }
                            }
                        }
                    }
                    if (str220.Length > 1)
                    {
                        str220 = str220.Substring(0, str220.Length - 1);
                    }
                    if (str110.Length > 1)
                    {
                        str110 = str110.Substring(0, str110.Length - 1);
                    }
                    if (str66.Length > 1)
                    {
                        str66 = str66.Substring(0, str66.Length - 1);
                    }
                    fmain.InitData(gp, str220, str110, str66);

                    XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                    Point point2 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                    t1.SetAttribute("x", Convert.ToString(point2.X - 20));
                    t1.SetAttribute("y", Convert.ToString(point2.Y - 10));
                    // t1.SetAttribute("layer", getlayer("供电区域层", tlVectorControl1.SVGDocument.getLayerList()).ID);
                    t1.SetAttribute("layer", SvgDocument.currentLayer);
                    t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                    t1.SetAttribute("font-famliy", "宋体");
                    t1.SetAttribute("font-size", "14");
                    t1.InnerText = fmain.glebeProp.Area + "\r\n" + fmain.glebeProp.Burthen; //+"\r\n" + fmain.glebeProp.Number;
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(t1);
                    tlVectorControl1.Refresh();
                    fmain.Dispose();
                    MapType = "接线图";
                }
                catch (Exception e2) { MapType = "接线图"; }
            }
            if (tlVectorControl1.SVGDocument.SelectCollection.Count > 1)
            {
                return;
            }
            decimal ViewScale = 1;
            string str_Scale = tlVectorControl1.SVGDocument.getViewScale();
            if (str_Scale != "")
            {
                ViewScale = Convert.ToDecimal(str_Scale);
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Text")
            {
                string showlineflag = ((XmlElement)e.SvgElement).GetAttribute("Showline");
                if (showlineflag == "1")
                {
                    XmlElement n1 = (XmlElement)e.SvgElement;
                    string suid = n1.GetAttribute("ParentID");
                    PSPDEV psp = new PSPDEV();
                    psp.SUID = suid;
                    psp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", psp);
                    if (psp != null)
                    {
                        fInfo.Info = "线路名称:" + psp.Name;
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 20;
                    fInfo.Show();

                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
            {
                string IsArea = ((XmlElement)e.SvgElement).GetAttribute("IsArea");
                if (IsArea != "")
                {
                    SelUseArea = "";
                    //XmlElement n1 = (XmlElement)e.SvgElement;
                    PointF[] pnts = ((Polygon)e.SvgElement).Points.Clone() as PointF[];
                    ((Polygon)e.SvgElement).Transform.Matrix.TransformPoints(pnts);
                    decimal temp1 = TLMath.getPolygonArea(pnts, 1);

                    temp1 = TLMath.getNumber2(temp1, tlVectorControl1.ScaleRatio) / Convert.ToDecimal(areaoption);
                    SelUseArea = temp1.ToString("#####.####");
                    //tip.Text = "区域面积:" + SelUseArea;
                    if (SelUseArea != "")
                    {
                        if (Convert.ToDecimal(SelUseArea) >= 1)
                        {
                            fInfo.Info = "区域面积:" + SelUseArea + "(KM²)";
                        }
                        else
                        {
                            fInfo.Info = "区域面积: 0" + SelUseArea + "(KM²)";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 12;
                    if (SelUseArea != "")
                    {
                        fInfo.Show();

                    }
                    //tip.ShowToolTip();
                }

            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Line")
            {
                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");
                if (IsLead != "")
                {
                    Line line = (Line)e.SvgElement;
                    decimal temp1 = TLMath.getLineLength(line, 1);
                    temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio);
                    string len = temp1.ToString("#####.####");
                    LineLen = len;
                    LineInfo lineInfo = new LineInfo();
                    lineInfo.EleID = e.SvgElement.ID;
                    lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    LineInfo _lineTemp = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", lineInfo);

                    if ((len != "") && (_lineTemp != null))
                    {
                        if (Convert.ToDecimal(len) >= 1)
                        {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3;
                        }
                        else
                        {
                            fInfo.Info = "线路名称:" + _lineTemp.LineName + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.Voltage + "kV 投产年限:" + _lineTemp.ObligateField3;
                        }
                    }
                    else if (len != "")
                    {
                        if (Convert.ToDecimal(len) >= 1)
                        {
                            fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        }
                        else
                        {
                            fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 7;
                    fInfo.Height = 50;
                    if (len != "")
                    {
                        fInfo.Show();

                    }

                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline" && str_outjwd == "1")
            {
                PointF[] pf = ((Polyline)e.SvgElement).Points;
                ((Polyline)e.SvgElement).Transform.Matrix.TransformPoints(pf);

                string strM = "";
                for (int i = 0; i < pf.Length; i++)
                {
                    strM = strM + getJWD(mapview.ParseToLongLat(pf[i].X, pf[i].Y));
                }
                System.IO.FileInfo ff = new System.IO.FileInfo("c:\\temp.txt");
                System.IO.StreamWriter wt = ff.CreateText();
                wt.Write(strM);
                wt.Close();
                System.Diagnostics.Process.Start("c:\\temp.txt");
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline" && str_djcl == "1")
            {
                Layer lar = null;
                Layer lar2 = null;
                bool create = true;
                int TempObjRadius = Convert.ToInt32(ConfigurationSettings.AppSettings.Get("TempObjRadius"));
                int TempTextSize = Convert.ToInt32(ConfigurationSettings.AppSettings.Get("TempTextSize"));

                for (int n = 0; n < tlVectorControl1.SVGDocument.Layers.Count; n++)
                {
                    Layer l = tlVectorControl1.SVGDocument.Layers[n] as Layer;
                    if (l.Label == "临时显示层-杆塔号")
                    {
                        lar = l;
                    }
                    if (l.Label == "临时显示层-公里数")
                    {
                        lar2 = l;
                    }
                }
                if (!Layer.CkLayerExist("临时显示层-杆塔号", tlVectorControl1.SVGDocument))
                {
                    lar = Layer.CreateNew("临时显示层-杆塔号", tlVectorControl1.SVGDocument);
                    lar.SetAttribute("layerType", progtype);
                    lar.SetAttribute("ParentID", tlVectorControl1.SVGDocument.CurrentLayer.GetAttribute("ParentID"));
                    this.frmlar.checkedListBox1.SelectedIndex = -1;
                    this.frmlar.checkedListBox1.Items.Add(lar, true);
                    lar2 = Layer.CreateNew("临时显示层-公里数", tlVectorControl1.SVGDocument);
                    lar2.SetAttribute("layerType", progtype);
                    lar2.SetAttribute("ParentID", tlVectorControl1.SVGDocument.CurrentLayer.GetAttribute("ParentID"));
                    this.frmlar.checkedListBox1.SelectedIndex = -1;
                    this.frmlar.checkedListBox1.Items.Add(lar2, true);
                }
                string gt = ((XmlElement)e.SvgElement).GetAttribute("gt-info");
                string _gtxh = ((XmlElement)e.SvgElement).GetAttribute("gtxh-info");

                string[] gtid = gt.Split(",".ToCharArray());
                string[] strgtxh = _gtxh.Split(",".ToCharArray());

                XmlNodeList useList = tlVectorControl1.SVGDocument.SelectNodes("//* [@layer='" + lar.ID + "'] [@parentobj='" + ((Polyline)e.SvgElement).ID + "']");

                for (int kk = 0; kk < useList.Count; kk++)
                {
                    tlVectorControl1.SVGDocument.RootElement.RemoveChild(useList[kk]);
                }

                PointF[] pf = ((Polyline)e.SvgElement).Points;
                ((Polyline)e.SvgElement).Transform.Matrix.TransformPoints(pf);
                if (create)
                {
                    for (int i = 0; i < pf.Length; i++)
                    {

                        if (_gtxh == "")
                        {
                            XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                            n1.SetAttribute("cx", Convert.ToString(pf[i].X));
                            n1.SetAttribute("cy", Convert.ToString(pf[i].Y));
                            n1.SetAttribute("r", TempObjRadius.ToString());
                            n1.SetAttribute("layer", lar.ID);
                            n1.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID);
                            n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                            tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                        }
                        else
                        {
                            if (strgtxh.Length > i)
                            {
                                if (strgtxh[i] == "0")
                                {
                                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
                                    n1.SetAttribute("cx", Convert.ToString(pf[i].X));
                                    n1.SetAttribute("cy", Convert.ToString(pf[i].Y));
                                    n1.SetAttribute("r", TempObjRadius.ToString());
                                    n1.SetAttribute("layer", lar.ID);
                                    n1.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID);
                                    n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                }
                                else
                                {
                                    XmlElement tk = tlVectorControl1.SVGDocument.CreateElement("rect") as RectangleElement;
                                    tk.SetAttribute("x", Convert.ToString(pf[i].X - 10));
                                    tk.SetAttribute("y", Convert.ToString(pf[i].Y - 10));
                                    tk.SetAttribute("width", Convert.ToString(TempObjRadius * 2));
                                    tk.SetAttribute("height", Convert.ToString(TempObjRadius * 2));
                                    tk.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID);
                                    tk.SetAttribute("style", "fill:#FFFFC0;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                                    tk.SetAttribute("layer", lar.ID);
                                    tlVectorControl1.SVGDocument.RootElement.AppendChild(tk);
                                }
                            }
                        }
                        XmlElement t0 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                        t0.SetAttribute("x", Convert.ToString(pf[i].X));
                        t0.SetAttribute("y", Convert.ToString(pf[i].Y));
                        t0.SetAttribute("layer", lar.ID);
                        t0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                        t0.SetAttribute("font-famliy", "宋体");
                        t0.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID);
                        t0.SetAttribute("font-size", TempTextSize.ToString());

                        if (gtid.Length > i)
                        {
                            t0.InnerText = gtid[i] + "号";
                        }
                        else
                        {
                            t0.InnerText = Convert.ToString(i + 1) + "号";
                        }
                        tlVectorControl1.SVGDocument.RootElement.AppendChild(t0);
                    }
                    for (int i = 0; i < pf.Length - 1; i++)
                    {
                        double s = this.mapview.CountLength(pf[i], pf[i + 1]);
                        //   TLMath.getLength(pf[i], pf[i + 1], (decimal)tlVectorControl1.ScaleRatio);
                        XmlElement t0 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                        t0.SetAttribute("x", Convert.ToString((pf[i].X + pf[i + 1].X) / 2));
                        t0.SetAttribute("y", Convert.ToString((pf[i].Y + pf[i + 1].Y) / 2));
                        t0.SetAttribute("layer", lar2.ID);
                        t0.SetAttribute("parentobj", ((Polyline)e.SvgElement).ID);
                        t0.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                        t0.SetAttribute("font-famliy", "宋体");
                        t0.SetAttribute("font-size", TempTextSize.ToString());
                        t0.InnerText = s.ToString("0.##") + "km";
                        tlVectorControl1.SVGDocument.RootElement.AppendChild(t0);
                    }
                }
                str_djcl = "";
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline")
            {
                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");
                if (IsLead != "")
                {
                    Polyline polyline = (Polyline)e.SvgElement;
                    double temp1 = 0;
                    for (int i = 1; i < polyline.Points.Length; i++)
                    {
                        temp1 += this.mapview.CountLength(polyline.Points[i - 1], polyline.Points[i]);
                    }

                    //decimal temp1 = TLMath.getPolylineLength(polyline, 1);
                    //temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio);
                    string len = temp1.ToString("#####.####");
                    LineLen = len;
                    PSPDEV lineInfo = new PSPDEV();
                    lineInfo.SUID = ((XmlElement)e.SvgElement).GetAttribute("Deviceid");
                    // lineInfo.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    PSPDEV _lineTemp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", lineInfo);

                    if ((len != "") && (_lineTemp != null))
                    {
                        if (Convert.ToDecimal(len) >= 1)
                        {
                            fInfo.Info = "线路名称:" + _lineTemp.Name + " 线路长度:" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.RateVolt.ToString() + "kV 投产年限:" + _lineTemp.OperationYear;
                        }
                        else
                        {
                            fInfo.Info = "线路名称:" + _lineTemp.Name + " 线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + _lineTemp.LineType + " 电压等级:" + _lineTemp.RateVolt.ToString() + "kV 投产年限:" + _lineTemp.OperationYear;
                        }
                    }
                    else if (len != "")
                    {
                        if (Convert.ToDecimal(len) >= 1)
                        {
                            fInfo.Info = "线路名称:" + " " + "线路长度:" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        }
                        else
                        {
                            fInfo.Info = "线路名称:" + " " + "线路长度: 0" + len + "(KM)\r\n" + "导线型号:" + " " + " 电压等级:" + " " + " 投产年限:" + " ";
                        }
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 7;
                    fInfo.Height = 50;
                    //fInfo.Right = fInfo.Left+fInfo.Info.Length*10;
                    if (len != "")
                    {
                        fInfo.Show();
                    }
                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.Use")
            {
                string aaa = ((Use)e.SvgElement).RefElement.ID;
                //if (!aaa.Contains("Substation"))
                //{
                //    return;
                //}

                string IsLead = ((XmlElement)e.SvgElement).GetAttribute("IsLead");

                if (aaa.Contains("Substation"))
                {
                    PSP_Substation_Info sub = new PSP_Substation_Info();

                    string deviceid = ((XmlElement)e.SvgElement).GetAttribute("Deviceid");
                    //sub.AreaID = tlVectorControl1.SVGDocument.SvgdataUid;
                    PSP_Substation_Info _subTemp = DeviceHelper.GetDevice<PSP_Substation_Info>(deviceid);
                    // PSP_Substation_Info _subTemp = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoListByEleID", sub);
                    if (_subTemp != null)
                    {
                        fInfo.Info = "变电站名称:" + _subTemp.Title + " 容量:" + _subTemp.L2.ToString("##.##") + "MVA\r\n" + " 电压等级:" + _subTemp.L1.ToString("##.##") + "kV 最大负荷:" + _subTemp.L9.ToString("##.##") + "MW \r\n 投产年限:" + _subTemp.S2;
                    }
                    else
                    {
                        fInfo.Info = "变电站名称:" + " " + " 容量:0" + "MVA" + "\r\n 电压等级: 最大负荷: \r\n 负荷率: 投产年限:";
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 5;
                    fInfo.Height = 60;
                    fInfo.Show();
                }
                if (aaa.Contains("kbs") || aaa.Contains("fjx") || aaa.Contains("pds") || aaa.Contains("byq") || aaa.Contains("hwg") || aaa.Contains("kg"))
                {
                    string deviceid = ((XmlElement)e.SvgElement).GetAttribute("Deviceid");
                    string s_name = "";
                    if (aaa.Contains("kbs"))
                    {
                        s_name = "开闭所";
                    }
                    if (aaa.Contains("fjx"))
                    {
                        s_name = "分接箱";
                    }
                    if (aaa.Contains("byq"))
                    {
                        s_name = "变压器";
                    }
                    if (aaa.Contains("hwg"))
                    {
                        s_name = "环网柜";
                    }
                    if (aaa.Contains("kg"))
                    {
                        s_name = "柱上开关";
                    }
                    if (aaa.Contains("pds"))
                    {
                        s_name = "配电室";
                    }
                    PSPDEV _subTemp = new PSPDEV();
                    _subTemp.SUID = deviceid;
                    _subTemp = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", _subTemp);
                    //PSP_Gra_item sub = new PSP_Gra_item();
                    //sub.EleID = e.SvgElement.ID;
                    //sub.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    //sub.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                    //PSP_Gra_item _subTemp = (PSP_Gra_item)Services.BaseService.GetObject("SelectPSP_Gra_itemByEleIDKey", sub);
                    if (_subTemp != null)
                    {
                        fInfo.Info = s_name + " 编号:" + _subTemp.EleID + " 名称:" + _subTemp.Name + " 电压等级:" + _subTemp.RateVolt + "kV";
                    }
                    else
                    {
                        fInfo.Info = s_name; // +"编号:   \r\n 名称: ";
                    }
                    fInfo.Top = e.Mouse.Y;
                    fInfo.Left = e.Mouse.X;
                    fInfo.Width = (fInfo.Info.Length) * 15;
                    fInfo.Height = 60;
                    fInfo.Show();
                }
            }
            if (e.SvgElement.GetType().ToString() == "ItopVector.Core.Figure.ConnectLine")
            {
                ConnectLine cline = (ConnectLine)tlVectorControl1.SVGDocument.CurrentElement;
                if (cline.StartGraph != null)
                {
                    string code = ((XmlElement)cline.StartGraph).GetAttribute("devxldm");

                    if (code != "")
                    {
                        xltProcessor.SelectLine(code);
                        tlVectorControl1.CurrentOperation = ToolOperation.Select;
                    }
                }
            }
            /*  if (tlVectorControl1.Operation == ToolOperation.LeadLine)
              {
                  string gt = sgt1.Text;
                  XmlElement u1 = tlVectorControl1.SVGDocument.CreateElement("use") as Use;
                  Point point1 = tlVectorControl1.PointToView(new Point(e.Mouse.X, e.Mouse.Y));
                  u1.SetAttribute("xlink:href", "#" + gt + "0");
                  u1.SetAttribute("x", point1.X.ToString());
                  u1.SetAttribute("y", point1.Y.ToString());
                  u1.SetAttribute("layer", SvgDocument.currentLayer);
                  u1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                  tlVectorControl1.SVGDocument.RootElement.AppendChild(u1);
              }*/
            //tlVectorControl1.SVGDocument.CurrentElement = null;
        }
Example #12
0
        //�������ڵ�ʱ��ָ�pspdev����·������״̬ ��Ϊ���кʹ�ѡ��״̬
        public void initdat(string GprogUID)
        {
            //�ڴ˴�����ѡ���Ԫ���豸�����Խ��и���
            LayerGrade l1 = new LayerGrade();
            l1.Type = "1";
            l1.SvgDataUid = svguid;
            IList ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            int yy1 = System.DateTime.Now.Year, yy2 = System.DateTime.Now.Year, yy3 = System.DateTime.Now.Year;
            if (ttlist.Count > 0)
            {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy1 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type = "2";
            l1.SvgDataUid = svguid;
            ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0)
            {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy2 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            l1.Type = "3";
            l1.SvgDataUid = svguid;
            ttlist = Services.BaseService.GetList("SelectLayerGradeList5", l1);
            if (ttlist.Count > 0)
            {
                LayerGrade n1 = (LayerGrade)ttlist[0];
                yy3 = Convert.ToInt32(n1.Name.Substring(0, 4));
            }
            string con = "GprogUID = '" + GprogUID + "' AND Type= '���վ'";

            IList list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {

                PSP_Substation_Info ps = new PSP_Substation_Info();
                ps.UID = pg.DeviceSUID;
                ps = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", ps);
                if (ps != null)
                {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S2))
                    {
                        s2 = Convert.ToInt32(ps.S2);
                    }
                    if (s2 <= System.DateTime.Now.Year)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S2) <= yy1)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > yy1 && Convert.ToInt32(ps.S2) <= yy2)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > yy2 && Convert.ToInt32(ps.S2) <= yy3)
                    {
                        pg.L1 = "Զ��";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                }
                else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
            }
            con = "GprogUID = '" + GprogUID + "' AND Type= '��Դ'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {
                PSP_PowerSubstation_Info ps = new PSP_PowerSubstation_Info();
                ps.UID = pg.DeviceSUID;
                ps = (PSP_PowerSubstation_Info)Services.BaseService.GetObject("SelectPSP_PowerSubstation_InfoByKey", ps);
                if (ps != null)
                {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.S3))
                    {
                        s2 = Convert.ToInt32(ps.S3);
                    }
                    if (s2 <= System.DateTime.Now.Year)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > System.DateTime.Now.Year && Convert.ToInt32(ps.S3) <= yy1)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 > yy1 && Convert.ToInt32(ps.S3) <= yy2)
                    {
                        pg.L1 = "����";
                    }
                    else if (s2 >yy2 && Convert.ToInt32(ps.S3) <= yy3)
                    {
                        pg.L1 = "Զ��";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                }
                else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
            }
            con = "GprogUID = '" + GprogUID + "' AND Type= '��·'";

            list = Services.BaseService.GetList("SelectPSP_GprogEleviceByCondition", con);
            foreach (PSP_GprogElevice pg in list)
            {
                PSPDEV ps = new PSPDEV();
                ps.SUID = pg.DeviceSUID;
                ps = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", ps);
                if (ps != null)
                {
                    int s2 = 0;
                    if (!string.IsNullOrEmpty(ps.OperationYear))
                    {
                        s2 = Convert.ToInt32(ps.OperationYear);
                    }
                    if (s2 <= System.DateTime.Now.Year)
                    {
                        pg.L1 = "����";
                        ps.LineStatus = "����";
                    }
                    else
                    {
                        pg.L1 = "��ѡ";
                        ps.LineStatus = "��ѡ";
                    }
                    Services.BaseService.Update<PSP_GprogElevice>(pg);
                    Services.BaseService.Update<PSPDEV>(ps);
                }
                else
                    Services.BaseService.Delete<PSP_GprogElevice>(pg);
            }
        }
Example #13
0
        //private void dateEdit1_EditValueChanged(object sender, EventArgs e)
        //{
        //    ChangeCheck(sender);
        //}
        //private void dateEdit2_EditValueChanged(object sender, EventArgs e)
        //{
        //    ChangeCheck(sender);
        //}
        public void ChangeCheck(object sender)
        {
            if (dateEdit1.Text == "" || dateEdit2.Text == "") return;
            for (int i = 0; i < checkedListBox1.Items.Count; i++) {
                Layer layer = this.checkedListBox1.Items[i] as Layer;
                if (checkedListBox1.GetItemCheckState(i) == CheckState.Checked) {
                    for (int j = 0; j < layer.GraphList.Count; j++) {
                        IGraph gp = (IGraph)layer.GraphList[j];
                        if (gp.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                            if (checkEdit1.Checked == true) {
                                PSPDEV line = new PSPDEV();
                                line.SUID = ((XmlElement)gp).GetAttribute("Deviceid");
                                line = (PSPDEV)Services.BaseService.GetObject("SelectPSPDEVByKey", line);
                                if (line != null) {
                                    if (line.Date1 == null || line.Date1 == "" || line.Date2 == null || line.Date2 == "") {
                                        gp.Visible = false;
                                        continue;
                                    }
                                    if ((Convert.ToInt32(dateEdit1.Text) == Convert.ToInt32(line.Date1)) && (Convert.ToInt32(dateEdit2.Text) == Convert.ToInt32(line.Date2))) {
                                        gp.Visible = true;
                                        continue;
                                    } else {
                                        gp.Visible = false;
                                    }
                                    for (int k = 0; k <= (Convert.ToInt32(dateEdit2.Text) - Convert.ToInt32(dateEdit1.Text)); k++) {
                                        if ((Convert.ToInt32(dateEdit1.Text) + k >= Convert.ToInt32(line.Date1)) && (Convert.ToInt32(dateEdit1.Text) + k <= Convert.ToInt32(line.Date2))) {

                                            gp.Visible = true;
                                            break;
                                        } else {
                                            gp.Visible = false;
                                        }
                                    }

                                } else {
                                    gp.Visible = false;
                                }
                            } else {
                                gp.Visible = true;
                            }
                        }
                        if (gp.GetType().ToString() == "ItopVector.Core.Figure.Use") {
                            if (checkEdit1.Checked == true) {
                                PSP_Substation_Info sub = new PSP_Substation_Info();
                                sub.UID = ((XmlElement)gp).GetAttribute("Deviceid");
                                sub = (PSP_Substation_Info)Services.BaseService.GetObject("SelectPSP_Substation_InfoByKey", sub);
                                if (sub != null) {

                                    if (sub.L28 == null || sub.L28 == "" || sub.L29 == null || sub.L29 == "") {
                                        gp.Visible = false;
                                        continue;
                                    }
                                    if ((Convert.ToInt32(dateEdit1.Text) == Convert.ToInt32(sub.L28)) && (Convert.ToInt32(dateEdit2.Text) == Convert.ToInt32(sub.L29))) {
                                        gp.Visible = true;
                                        continue;
                                    } else {
                                        gp.Visible = false;
                                    }
                                    for (int k = 0; k <= (Convert.ToInt32(dateEdit2.Text) - Convert.ToInt32(dateEdit1.Text)); k++) {
                                        if ((Convert.ToInt32(dateEdit1.Text) + k >= Convert.ToInt32(sub.L28)) && (Convert.ToInt32(dateEdit1.Text) + k <= Convert.ToInt32(sub.L29))) {

                                            gp.Visible = true;
                                            break;
                                        } else {
                                            gp.Visible = false;
                                        }
                                    }
                                } else {
                                    gp.Visible = false;
                                }
                            } else {
                                gp.Visible = true;
                            }
                        }
                    }

                }

            }
            if (OnCheck != null) {
                OnCheck(sender);
            }
        }
Example #14
0
        private void simpleButton4_Click(object sender, EventArgs e)
        {
            int index = this.checkedListBox1.SelectedIndex;
            if (index > 0) {
                ArrayList layerlist1 = this.SymbolDoc.getLayerList();
                string str1 = null;
                string str2 = null;
                foreach (Layer l in layerlist1) {
                    if (l.Visible) {
                        str1 += l.Label;
                        str2 += l.Label + "��";
                    }
                }
                if (MessageBox.Show(this, "�˲������ϲ��ɼ�ͼ�㣺" + str2 + "���Ҳ��ɻָ����Ƿ������", "��ȷ��", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {
                    Layer layer = this.checkedListBox1.Items[index] as Layer;
                    string str = layer.GetAttribute("layerType");
                    Layer layer2 = Layer.CreateNew(str1, this.SymbolDoc);
                    if (ilist.Count > 0) {
                        layer2.SetAttribute("ParentID", ilist[0].ToString());
                    }
                    foreach (Layer layer1 in layerlist1) {
                        if (layer1.Visible) {
                            //foreach (SvgElement g in layer1.GraphList)
                            //{
                            //    layer2.GraphList.Add(g);
                            //}
                            this.SymbolDoc.NumberOfUndoOperations = (2 * layer1.GraphList.Count) + 200;
                            SvgElementCollection sc = layer1.GraphList;
                            for (int i = layer1.GraphList.Count - 1; i >= 0; i--) {
                                SvgElement element = sc[i] as SvgElement;
                                SvgElement temp = element.Clone() as SvgElement;
                                IGraph graph = (IGraph)layer2.AddElement(temp);
                                graph.Layer = layer2;

                                PSPDEV _line = new PSPDEV();
                                _line.EleID = element.ID;
                                _line.SvgUID = this.SymbolDoc.SvgdataUid;
                                IList lineInfoList = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandEleID", _line);
                                foreach (PSPDEV line in lineInfoList) {
                                    line.LayerID = layer2.ID;
                                    line.EleID = temp.ID;
                                    Services.BaseService.Update<PSPDEV>(line);
                                }
                                glebeProperty gle = new glebeProperty();
                                gle.EleID = element.ID;
                                gle.SvgUID = this.SymbolDoc.SvgdataUid;
                                IList gleProList = Services.BaseService.GetList("SelectglebePropertyByEleID", gle);
                                foreach (glebeProperty gleP in gleProList) {
                                    gleP.LayerID = layer2.ID;
                                    gleP.EleID = temp.ID;
                                    Services.BaseService.Update("UpdateglebeProperty", gle);
                                }
                                PSP_Substation_Info _sub = new PSP_Substation_Info();
                                _sub.EleID = element.ID;
                                _sub.AreaID = this.SymbolDoc.SvgdataUid;
                                IList substationList = Services.BaseService.GetList("SelectPSP_Substation_InfoListByEleID", _sub);
                                foreach (PSP_Substation_Info sub in substationList) {
                                    sub.LayerID = layer2.ID;
                                    sub.EleID = temp.ID;
                                    Services.BaseService.Update<PSP_Substation_Info>(sub);
                                }
                            }
                        }
                    }

                    this.SymbolDoc.NotifyUndo();
                    layer2.SetAttribute("layerType", str);
                    //layer2.Label = str1;
                    this.checkedListBox1.Items.Add(layer2);
                    layer2.Visible = false;
                    foreach (Layer layer3 in layerlist1) {
                        if (layer3.Visible) {
                            DeleteLayer(layer3);
                        }
                    }
                }
            }
        }