Ejemplo n.º 1
0
        void tlVectorControl1_RightClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e)
        {
            sel_sym = "";
            sel_start_point = "";
            try {
                if (csOperation == CustomOperation.OP_MeasureDistance) {
                    tlVectorControl1.Operation = ToolOperation.Select;
                    contextMenuStrip1.Hide();
                    return;
                }
                //tlVectorControl1.DocumentSize = new SizeF(3170f, 2540f);
                //MessageBox.Show(MapType);
                tmLineConnect.Visible = false;
                SvgElementCollection elements = tlVectorControl1.SVGDocument.SelectCollection;
                if (elements.Count == 2) {
                    Polyline pl1 = elements[0] as Polyline;
                    Polyline pl2 = elements[1] as Polyline;
                    if (pl1 != null && pl2 != null && pl1.GetAttribute("IsLead") != "" && pl2.GetAttribute("IsLead") != "") {

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

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

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

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

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

                    }
                    if (tlVectorControl1.Operation == ToolOperation.InterEnclosure && !SubPrint) {

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

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

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

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

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

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

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

                                    substation _sub1 = new substation();
                                    _sub1.EleID = str_id;
                                    _sub1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    _sub1 = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub1);
                                    if (_sub1 != null) {
                                        _sub1.glebeEleID = guid;
                                        Services.BaseService.Update("Updatesubstation", _sub1);
                                    }

                                }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            }
        }
Ejemplo n.º 2
0
        void tlVectorControl1_RightClick(object sender, ItopVector.DrawArea.SvgElementSelectedEventArgs e)
        {
            if (MapType == "接线图") {
                tip.Hide();
                contextMenuStrip1.Show(e.Mouse.X, e.Mouse.Y);
                if (getlayer(SvgDocument.currentLayer, "背景层", tlVectorControl1.SVGDocument.getLayerList())) {
                    contextMenuStrip1.Enabled = false;
                } else {
                    contextMenuStrip1.Enabled = true;
                }

                if (tlVectorControl1.SVGDocument.CurrentElement == null ||
                   tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() != "ItopVector.Core.Figure.Use") {

                    jxtMenuItem.Visible = false;
                } else {
                    if (tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("xlink:href").Contains("Substation")) {

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

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

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

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

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

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

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

                            //    substation _sub1 = new substation();
                            //    _sub1.EleID = str_id;
                            //    _sub1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                            //    _sub1 = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", _sub1);
                            //    if (_sub1 != null)
                            //    {
                            //        _sub1.glebeEleID = guid;
                            //        Services.BaseService.Update("Updatesubstation", _sub1);
                            //    }

                            //}

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

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

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

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

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

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

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

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

                        tlVectorControl1.SVGDocument.SelectCollection.Clear();
                        tlVectorControl1.SVGDocument.CurrentElement = (SvgElement)x1;
                    }
                    // SubPrint = false;
                }
            } else {
                contextMenuStrip1.Enabled = false;
            }
        }
Ejemplo n.º 3
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;

            }
        }