Esempio n. 1
0
        private void CreateSubline(SubandFHcollect _subandfh)
        {
            XmlElement sub = _subandfh.Sub ;
                 foreach (KeyValuePair<XmlElement, PointF> kv in _subandfh.FHcollect )
                 {
                     XmlElement _x = kv.Key;
                     PointF pf = kv.Value;
                     PointF _f = TLMath.polyCentriod(_x);
                     XmlNode xnode = tlVectorControl1.SVGDocument.SelectSingleNode("svg/polyline[@xz='1' and FirstNode='" + sub.GetAttribute("id").ToString() + "'and LastNode='" + _x.GetAttribute("id").ToString() + "']");
                   if (xnode!=null)
                   {
                       tlVectorControl1.SVGDocument.RootElement.RemoveChild(xnode);
                   }
                     string temp = sub.GetAttribute("x").ToString() + " " + sub.GetAttribute("y").ToString() + "," + _f.X.ToString() + " " + _f.Y.ToString();

                    XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;

                    n1.SetAttribute("points",temp);
                    n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
                    n1.SetAttribute("layer", SvgDocument.currentLayer);
                    n1.SetAttribute("IsLead", "1");
                    n1.SetAttribute("FirstNode", sub.GetAttribute("id").ToString());
                    n1.SetAttribute("LastNode", _x.GetAttribute("id").ToString());
                    n1.SetAttribute("xz", "1");
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                    tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)n1);
                 }

            //    XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement;

            //    e1.SetAttribute("x", Convert.ToString(X));
            //    e1.SetAttribute("y", Convert.ToString(Y));

            //    e1.SetAttribute("xlink:href", str_sub);
            //    e1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
            //    e1.SetAttribute("layer", SvgDocument.currentLayer);
            //    SubandFHcollect _subandfh = new SubandFHcollect(FHandPointF, e1);
            //    tlVectorControl1.SVGDocument.RootElement.AppendChild(e1);
            //    tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e1);
        }
Esempio n. 2
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;

            }
        }
Esempio n. 3
0
        //flag 为false时为已有变电站
        //flag为ture时变电站为规划的
        private void CreateSubline1(SubandFHcollect _subandfh, bool flag, Layer lay)
        {
            XmlElement sub = _subandfh.Sub;
            double subrl = 0;
            double yfcrl = 0;
            if (!string.IsNullOrEmpty(sub.GetAttribute("rl"))) {
                subrl = Convert.ToDouble(sub.GetAttribute("rl"));
            }
            double sumrl = 0;
            string fhdk = "";
            foreach (KeyValuePair<XmlElement, PointF> kv in _subandfh.FHcollect) {
                XmlElement _x = kv.Key;
                PointF pf = kv.Value;
                PointF _f = TLMath.polyCentriod(_x);
                //XmlNode xnode = tlVectorControl1.SVGDocument.SelectSingleNode("svg/polyline[@layer='" + lay.ID + "'and @FirstNode='" + sub.GetAttribute("id").ToString() + "'and @LastNode='" + _x.GetAttribute("id").ToString() + "']");
                //if (xnode != null) {
                //    tlVectorControl1.SVGDocument.RootElement.RemoveChild(xnode);
                //}
                XmlNodeList nodelist = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline[@layer='" + lay.ID + "'and @xz='1']");
                foreach(XmlNode xnode in nodelist)
                {
                    tlVectorControl1.SVGDocument.RootElement.RemoveChild(xnode);
                }
                glebeProperty pl = new glebeProperty();

                pl.EleID = _x.GetAttribute("id");
                pl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                pl = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", pl);

                double dkrl = 0;
                string ygdflag = "0";    //0表示还没有供电,1表示完全有已知的变电站供,2表示部分符合已有供并且写上变电站供给了多少
                if (!string.IsNullOrEmpty(_x.GetAttribute("ygdflag"))) {
                    ygdflag = _x.GetAttribute("ygdflag");
                }
                if (!string.IsNullOrEmpty(_x.GetAttribute("Burthen"))) {
                    dkrl = Convert.ToDouble(_x.GetAttribute("Burthen")) * dbl_rzb;

                }
                //查找此地块离所有变电站中是否离此变电站最近
                 //地块负荷供应情况
                    string bdzandlenth= _x.GetAttribute("bdzandlenth");
                   string[] dkqk=null;
                   int minnumber = 0;
                    if (!string.IsNullOrEmpty(bdzandlenth))
                    {
                        double minlenth = 1000000;
                        dkqk = (bdzandlenth.Substring(0, bdzandlenth.LastIndexOf(";"))).Split(';');

                        for (int j = 0; j < dkqk.Length; j++)
                        {
                            string[] dk = dkqk[j].Split(',');
                            if (Convert.ToDouble(dk[1])<minlenth)
                            {
                                minlenth = Convert.ToDouble(dk[1]);
                                minnumber = j;
                            }
                        }
                        if (!dkqk[minnumber].Contains(sub.GetAttribute("subname")))
                        {
                            continue;
                        }
                    }

                //
                sumrl += dkrl;
                //改进后的不能有部分剩余了 能供则供 不能供则选择其他的变电站来供
                if (ygdflag == "0")  //说明还没有供给的
                {
                    if (subrl * 1.5 >= sumrl)
                    {
                        fhdk += _x.GetAttribute("id") + "," + dkrl.ToString() + ";";
                        _x.SetAttribute("ygdflag", "1");
                        yfcrl = sumrl;
                    }
                    else
                    {
                        //去掉此地块的信息 在其他变电站重新寻找供给
                        bdzandlenth = "";
                         for (int j = 0; j < dkqk.Length; j++)
                         {
                             if (j!=minnumber)
                             {
                                 bdzandlenth += dkqk[j] + ";";
                             }
                         }
                         _x.SetAttribute("bdzandlenth",bdzandlenth);
                        continue;
                    }
                    //else if (subrl * 1.5< sumrl && subrl >= (sumrl - dkrl)) {
                    //    double gyrl = ((subrl * 1.5 + dkrl) - sumrl);
                    //    double syrl = sumrl - subrl * 1.5;
                    //    fhdk += _x.GetAttribute("id") + "," + gyrl.ToString() + ";";
                    //    _x.SetAttribute("ygdflag", "2");
                    //    _x.SetAttribute("syrl", syrl.ToString());
                    //    yfcrl = subrl * 1.5;

                    //}
                }
                //else if (ygdflag == "2")   //有一部分剩余的还需要来供
                //{
                //    double syrl = 0;
                //    if (!string.IsNullOrEmpty(_x.GetAttribute("syrl"))) {
                //        syrl = Convert.ToDouble(_x.GetAttribute("syrl"));
                //    }
                //    if ((subrl * 1.5- yfcrl) > syrl) {
                //        fhdk += _x.GetAttribute("id") + "," + syrl.ToString() + ";";
                //        _x.SetAttribute("ygdflag", "1");
                //        _x.SetAttribute("syrl", "0");
                //        yfcrl = sumrl;
                //    } else {
                //        syrl = syrl - (subrl * 1.5 - yfcrl);
                //        fhdk += _x.GetAttribute("id") + "," + (subrl * 1.5 - yfcrl).ToString() + ";";
                //        _x.SetAttribute("ygdflag", "2");
                //        _x.SetAttribute("syrl", syrl.ToString());
                //        yfcrl = subrl * 1.5;
                //    }
                //}
                    else if (ygdflag == "1")  //已经有供应的了
                {
                    continue;
                }

                if (pl != null) {
                    string sname = sub.GetAttribute("subname");
                    if (!string.IsNullOrEmpty(sname)) {

                        //if (_x.GetAttribute("xz") == "0")
                        //{
                        //    pl.ObligateField7 = sname;
                        //    Services.BaseService.Update<glebeProperty>(pl);
                        //}
                        if (sname.Contains("号"))         //为规划的变电站 自动为true
                        {
                            flag = true;
                        }
                        if (string.IsNullOrEmpty(pl.ObligateField7)) {
                            pl.ObligateField7 = sname;
                        } else {
                            if (!pl.ObligateField7.Contains(sname)) {
                                pl.ObligateField7 += "," + sname;
                            }
                        }

                        Services.BaseService.Update<glebeProperty>(pl);
                    }
                }
                //if (!flag)
                //{
                //    if (_x.GetAttribute("xz")=="1")
                //    {
                //        return;
                //    }
                //}

                string temp = "";
                if (!flag) {
                    temp = sub.GetAttribute("cx").ToString() + " " + sub.GetAttribute("cy").ToString() + "," + _f.X.ToString() + " " + _f.Y.ToString();
                } else
                    temp = sub.GetAttribute("x").ToString() + " " + sub.GetAttribute("y").ToString() + "," + _f.X.ToString() + " " + _f.Y.ToString();

                XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;

                n1.SetAttribute("points", temp);
                //如果是规划
                if (flag) {
                    _x.SetAttribute("xz", "1");
                    n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#990033;stroke-opacity:1;");

                } else {
                    if (_x.GetAttribute("xz") != "1") {
                        _x.SetAttribute("xz", "0");
                    }

                    n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#330099;stroke-opacity:1;");

                }
                n1.SetAttribute("layer", lay.ID);
                n1.SetAttribute("IsLead", "1");
                n1.SetAttribute("FirstNode", sub.GetAttribute("id").ToString());
                n1.SetAttribute("LastNode", _x.GetAttribute("id").ToString());
                n1.SetAttribute("xz", "1");
                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)n1);

            }
            sub.SetAttribute("fhdk", fhdk);
            if (yfcrl != 0) {
                sub.SetAttribute("yfcrzb", (subrl / ((yfcrl / dbl_rzb))).ToString());
            } else {
                sub.SetAttribute("yfcrzb", (dbl_rzb).ToString());
            }
        }
Esempio n. 4
0
        private void ShowTriangle1(ArrayList _polylist, XmlElement _poly)
        {
            try {
             Dictionary<XmlElement, PointF> fhkcollect = new Dictionary<XmlElement, PointF>();
             PointF fhcenter = new PointF();

             string aaa = yearID;
             if (D_TIN.DS.VerticesNum > 2)  //构建三角网
             D_TIN.CreateTIN();

             //输出三角形
             for (int i = 0; i < D_TIN.DS.TriangleNum; i++) {
             Point point1 = new Point(Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V1Index].x), Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V1Index].y));
             Point point2 = new Point(Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V2Index].x), Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V2Index].y));
             Point point3 = new Point(Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V3Index].x), Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V3Index].y));

             string str_points = "";
             str_points = point1.X.ToString() + " " + point1.Y.ToString() + "," + point2.X.ToString() + " " + point2.Y.ToString() + "," + point3.X.ToString() + " " + point3.Y.ToString();
             //XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as XmlElement;
             //e1.SetAttribute("points", str_points);
             //e1.SetAttribute("style", "stroke-width:1;stroke:#0000FF;stroke-opacity:1;");
             //e1.SetAttribute("IsTin", "1");
             //e1.SetAttribute("layer", SvgDocument.currentLayer);
             //tlVectorControl1.SVGDocument.RootElement.AppendChild(e1);

             }
             D_TIN.CalculateBC();
             D_TIN.CreateVoronoi();

             ArrayList CirList = new ArrayList();
             ArrayList polyCentriodList = new ArrayList();
             for (int n = 0; n < D_TIN.DS.Barycenters.Length; n++) {

             Barycenter bar = D_TIN.DS.Barycenters[n];
             if (bar.X == 0 && bar.Y == 0) {
                 break;
             }
             Triangle tri = D_TIN.DS.Triangle[n];
             Vertex ver = D_TIN.DS.Vertex[tri.V1Index];
             Vertex ver2 = D_TIN.DS.Vertex[tri.V2Index];
             Vertex ver3 = D_TIN.DS.Vertex[tri.V3Index];
             Decimal r = Convert.ToDecimal(Math.Abs(Math.Sqrt(Math.Pow(Convert.ToDouble(ver.x - bar.X), 2.0) + Math.Pow(Convert.ToDouble(ver.y - bar.Y), 2.0))));

             XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle;
             n1.SetAttribute("cx", bar.X.ToString());
             n1.SetAttribute("cy", bar.Y.ToString());
             n1.SetAttribute("r", r.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);
             CirList.Add(n1);

             PointF[] Flist = new PointF[3];
             Flist[0] = new PointF(ver.x, ver.y);
             Flist[1] = new PointF(ver2.x, ver2.y);
             Flist[2] = new PointF(ver3.x, ver3.y);
             polyCentriodList.Add(TLMath.polyCentriod(Flist));
             }
             System.Collections.SortedList clist = new SortedList();
             System.Collections.SortedList CtoFHlist = new SortedList();
             decimal sum = 0;
             for (int n = 0; n < CirList.Count; n++) {
             fhkcollect = new Dictionary<XmlElement, PointF>();
             int k = 0;
             Circle cir = (Circle)CirList[n];
             GraphicsPath gr1 = new GraphicsPath();
             gr1.AddPath(cir.GPath, true);
             gr1.CloseFigure();
             for (int m = 0; m < _polylist.Count; m++) {
                 XmlElement _x = (XmlElement)_polylist[m];
                 PointF _f = TLMath.polyCentriod(_x);
                 if (gr1.IsVisible(_f))    //外接圆包括那些负荷中心点
                    {
                     k = k + 1;   //求和的过程
                     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) {
                         sum = sum + pl.Burthen;
                     }
                     fhkcollect.Add(_x, _f);//记录外包圆相交的负荷块
                 }
             }
             clist.Add(sum + n, cir);
             CtoFHlist.Add(sum + n, fhkcollect);
             string aa = "";

             }

             string str_sub = getSubName(str_dy);

             for (int k = 0; k < Convert.ToInt32(str_num); k++) {
             GraphicsPath gr1 = new GraphicsPath();
             gr1.AddPolygon(TLMath.getPolygonPoints(_poly));
             gr1.CloseFigure();

             Circle c1 = clist.GetByIndex(k) as Circle;
             Dictionary<XmlElement, PointF> FHandPointF = CtoFHlist.GetByIndex(k) as Dictionary<XmlElement, PointF>;
             PointF pf = TLMath.getUseOffset(str_sub);
             float X = 0f;
             float Y = 0f;
             float ox = 0f;
             float oy = 0f;
             if (gr1.IsVisible(new PointF(c1.CX, c1.CY))) {
                 X = c1.CenterPoint.X - pf.X;
                 Y = c1.CenterPoint.Y - pf.Y;
                 ox = c1.CenterPoint.X + 8;
                 oy = c1.CenterPoint.Y;
             } else {
                 X = ((PointF)polyCentriodList[k]).X - pf.X;
                 Y = ((PointF)polyCentriodList[k]).Y - pf.Y;
                 ox = ((PointF)polyCentriodList[k]).X + 8;
                 oy = ((PointF)polyCentriodList[k]).Y;
             }
             XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement;

             e1.SetAttribute("x", Convert.ToString(X));
             e1.SetAttribute("y", Convert.ToString(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);
             SubandFHcollect _subandfh = new SubandFHcollect(FHandPointF, e1);
             tlVectorControl1.SVGDocument.RootElement.AppendChild(e1);
             tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e1);

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

             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 + 1) + "号";
             tlVectorControl1.SVGDocument.RootElement.AppendChild(t1);

             decimal temp1 = TLMath.getNumber((decimal)c1.R, tlVectorControl1.ScaleRatio);
             //MessageBox.Show(temp1.ToString());
             if (Convert.ToDecimal(str_jj) > temp1) {
                 MessageBox.Show(Convert.ToString(k + 1) + "号变电站候选站址小于最小供电半径,请手动进行调整。");
             }

             PSP_SubstationSelect s = new PSP_SubstationSelect();
             s.UID = Guid.NewGuid().ToString();
             s.EleID = t1.GetAttribute("id");
             s.SName = Convert.ToString(k + 1) + "号";
             s.Remark = "";
             s.col2 = XZ_bdz;
             s.SvgID = tlVectorControl1.SVGDocument.SvgdataUid;
             Services.BaseService.Create<PSP_SubstationSelect>(s);
             CreateSubline(_subandfh);    //生成负荷中心与变电站的连接线

             }
             }
             catch (Exception e1) { }
        }
Esempio n. 5
0
        private void CreateSubline(SubandFHcollect _subandfh, bool flag)
        {
            XmlElement sub = _subandfh.Sub;

            foreach (KeyValuePair<XmlElement, PointF> kv in _subandfh.FHcollect) {
                XmlElement _x = kv.Key;

                //if (!flag)
                //{
                //    if (_x.GetAttribute("xz")=="1")
                //    {
                //        return;
                //    }
                //}
                PointF pf = kv.Value;
                PointF _f = TLMath.polyCentriod(_x);
                XmlNode xnode = tlVectorControl1.SVGDocument.SelectSingleNode("svg/polyline[@xz='1' and FirstNode='" + sub.GetAttribute("id").ToString() + "'and LastNode='" + _x.GetAttribute("id").ToString() + "']");
                if (xnode != null) {
                    tlVectorControl1.SVGDocument.RootElement.RemoveChild(xnode);
                }
                string temp = "";
                if (!flag) {
                    temp = sub.GetAttribute("cx").ToString() + " " + sub.GetAttribute("cy").ToString() + "," + _f.X.ToString() + " " + _f.Y.ToString();
                } else
                    temp = sub.GetAttribute("x").ToString() + " " + sub.GetAttribute("y").ToString() + "," + _f.X.ToString() + " " + _f.Y.ToString();

                glebeProperty pl = new glebeProperty();
                pl.EleID = _x.GetAttribute("id");
                pl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                pl = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", pl);
                if (pl != null) {
                    string sname = sub.GetAttribute("subname");
                    if (!string.IsNullOrEmpty(sname)) {

                        if (_x.GetAttribute("xz") == "0") {
                            pl.ObligateField7 = sname;
                            Services.BaseService.Update<glebeProperty>(pl);
                        }

                    }
                }

                XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline;

                n1.SetAttribute("points", temp);
                //如果是规划
                if (flag) {
                    _x.SetAttribute("xz", "1");
                    n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#990033;stroke-opacity:1;");

                } else {
                    if (_x.GetAttribute("xz") != "1") {
                        _x.SetAttribute("xz", "0");
                    }

                    n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#330099;stroke-opacity:1;");

                }
                n1.SetAttribute("layer", SvgDocument.currentLayer);
                n1.SetAttribute("IsLead", "1");
                n1.SetAttribute("FirstNode", sub.GetAttribute("id").ToString());
                n1.SetAttribute("LastNode", _x.GetAttribute("id").ToString());
                n1.SetAttribute("xz", "1");
                tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)n1);

            }

            //    XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement;

            //    e1.SetAttribute("x", Convert.ToString(X));
            //    e1.SetAttribute("y", Convert.ToString(Y));

            //    e1.SetAttribute("xlink:href", str_sub);
            //    e1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;");
            //    e1.SetAttribute("layer", SvgDocument.currentLayer);
            //    SubandFHcollect _subandfh = new SubandFHcollect(FHandPointF, e1);
            //    tlVectorControl1.SVGDocument.RootElement.AppendChild(e1);
            //    tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e1);
        }