Exemple #1
0
        private void gridControl_DoubleClick(object sender, EventArgs e)
        {
            if (FocusedObject == null)
            {
                return;
            }

            PSP_SubstationSelect p = new PSP_SubstationSelect();

            p.UID = FocusedObject.SubStationID;
            p     = (PSP_SubstationSelect)Services.BaseService.GetObject("SelectPSP_SubstationSelectByKey", p);
            frmSubstationProperty frmSub = new frmSubstationProperty();

            frmSub.InitData(p.EleID, "c5ec3bc7-9706-4cbd-9b8b-632d3606f933", "", "");
            frmSub.IsReadonly = true;
            frmSub.ShowDialog();
        }
Exemple #2
0
        private void gridControl_DoubleClick(object sender, EventArgs e)
        {
            if (FocusedObject==null) return;

              PSP_SubstationSelect p = new PSP_SubstationSelect();
              p.UID = FocusedObject.SubStationID;
              p=(PSP_SubstationSelect)Services.BaseService.GetObject("SelectPSP_SubstationSelectByKey",p);
              frmSubstationProperty frmSub = new frmSubstationProperty();
              frmSub.InitData(p.EleID, "c5ec3bc7-9706-4cbd-9b8b-632d3606f933", "", "");
              frmSub.IsReadonly = true;
              frmSub.ShowDialog();
        }
Exemple #3
0
        /*public void ResetPoly()
        {
            SvgElementCollection col= tlVectorControl1.SVGDocument.SelectCollection;
            if(col.Count<1){
                return;
            }
            SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();
            foreach(SvgElement ele in col){
                if (ele.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                {
                    glebeProperty p=new glebeProperty();
                    p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    p.EleID = ((IGraph)ele).ID;
                    p = Services.BaseService.GetObject("SelectglebePropertyByEleID", p);
                    if(p!=null){
                        PointF[] tfArray1 = TLMath.getPolygonPoints(ele);
                        GraphicsPath selectAreaPath = new GraphicsPath();
                        selectAreaPath.AddLines(tfArray1);
                        selectAreaPath.CloseFigure();
                        Region region1 = new Region(selectAreaPath);
                        while (enumerator1.MoveNext())
                        {
                            IGraph graph1 = (IGraph)enumerator1.Current;
                            GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                            path1.Transform(graph1.GraphTransform.Matrix);
                            Region region2 = new Region(path1);
                            region2.Intersect(region1);
                            if (!region2.GetBounds(Graphics.FromHwnd(IntPtr.Zero)).IsEmpty)
                            {
                                glebeProperty p1 = new glebeProperty();
                                p1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                p1.EleID = graph1.ID;
                                p1 = Services.BaseService.GetObject("SelectglebePropertyByEleID", p1);
                                if(p1!=null){
                                    p1.ParentEleID = p.UID;
                                    Services.BaseService.Update("UpdateglebePropertyAreaAll", p1);
                                }
                            }
                        }
                    }
                }
            }
            MessageBox.Show("更新完成。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }*/
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try
            {
                if (e.ClickedItem.Text == "属性")
                {
                    XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    //PointF[] pf = TLMath.getPolygonPoints(xml1);

                    //((Polygon)xml1).Transform.Matrix.TransformPoints(pf);
                    // 规划
                    if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList()))
                    {

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

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

                            IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle);
                            if (UseProList.Count > 0)
                            {
                                _gle = UseProList[0];
                                _gle.LayerID = SvgDocument.currentLayer;
                                frmMainProperty f = new frmMainProperty();

                                f.InitData(_gle, str220, str110, str66);

                                f.ShowDialog();
                                if (f.checkBox1.Checked == false)
                                {
                                    tlVectorControl1.SVGDocument.RootElement.RemoveChild(tlVectorControl1.SVGDocument.CurrentElement);
                                }
                                //tlVectorControl1.Refresh();
                            }
                            //}
                        }

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

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

                        if (xml1 == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg")
                        {
                            MessageBox.Show("请先选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                        {
                            string IsArea = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsArea");
                            if (IsArea != "")
                            {
                                frmProperty f = new frmProperty();
                                if (SelUseArea == "") { SelUseArea = "0"; }
                                f.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer);
                                //f.ShowDialog();
                                if (progtype != "城市规划层")
                                {
                                    f.IsReadonly = true;
                                }
                                if (f.ShowDialog() == DialogResult.OK)
                                {
                                    SVG_ENTITY ent = new SVG_ENTITY();
                                    if (f.IsCreate)
                                    {
                                        ent.SUID = Guid.NewGuid().ToString();
                                        ent.EleID = f.gPro.EleID;
                                        ent.layerID = f.gPro.LayerID;
                                        ent.MDATE = System.DateTime.Now;
                                        ent.NAME = f.gPro.UseID;
                                        ent.svgID = f.gPro.SvgUID;
                                        ent.TYPE = "polygon-dk";
                                        //ent.voltage = f.gPro.Voltage;
                                        Services.BaseService.Create<SVG_ENTITY>(ent);
                                    }
                                    else
                                    {
                                        ent.NAME = f.gPro.UseID;
                                        ent.layerID = f.gPro.LayerID;
                                        ent.MDATE = System.DateTime.Now;
                                        //ent.voltage = fl.Line.Voltage;
                                        Services.BaseService.Update<SVG_ENTITY>(ent);
                                    }
                                    if (f.gPro.ObligateField1 != "")
                                    {
                                        string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(f.gPro.ObligateField1)));
                                        color1 = "fill:" + color1 + ";";
                                        ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).SetAttribute("style", color1);
                                        tlVectorControl1.UpdateProperty();
                                    }

                                }
                            }
                        }
                    }

                    if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline")
                    {
                        string lineWidth = "2";
                        string IsLead = ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).GetAttribute("IsLead");
                        if (IsLead != "")
                        {
                            frmLineProperty fl = new frmLineProperty();
                            fl.LineNode = tlVectorControl1.SVGDocument.CurrentElement;
                            fl.InitData(tlVectorControl1.SVGDocument.CurrentElement.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, LineLen, SvgDocument.currentLayer);
                            if (fl.ShowDialog() == DialogResult.OK)
                            {
                                SVG_ENTITY ent = new SVG_ENTITY();
                                if (fl.IsCreate)
                                {
                                    ent.SUID = Guid.NewGuid().ToString();
                                    ent.EleID = fl.Line.EleID;
                                    ent.layerID = fl.Line.LayerID;
                                    ent.MDATE = System.DateTime.Now;
                                    ent.NAME = fl.Line.LineName;
                                    ent.svgID = fl.Line.SvgUID;
                                    ent.TYPE = "line";
                                    ent.voltage =Convert.ToInt32(fl.Line.Voltage);
                                    Services.BaseService.Create<SVG_ENTITY>(ent);
                                }
                                else
                                {
                                    ent.NAME = fl.Line.LineName;
                                    ent.layerID = fl.Line.LayerID;
                                    ent.MDATE = System.DateTime.Now;
                                    ent.voltage =Convert.ToInt32( fl.Line.Voltage);
                                    Services.BaseService.Update<SVG_ENTITY>(ent);
                                }

                                lineWidth = fl.LineWidth;
                                string styleValue = "";
                                if (fl.Line.ObligateField1 == "规划")
                                {
                                    styleValue = "stroke-dasharray:" + ghType + ";stroke-width:" + lineWidth + ";";
                                }
                                else
                                {
                                    styleValue = "stroke-width:" + lineWidth + ";";
                                }
                                //string aa= ColorTranslator.ToHtml(Color.Black);
                                styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                                SvgElement se = tlVectorControl1.SVGDocument.CurrentElement;
                                se.RemoveAttribute("style");
                                se.SetAttribute("style", styleValue);
                                se.SetAttribute("info-name", fl.Line.LineName);

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

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

                         x = ((Use)xml1).X;

                         y = ((Use)xml1).Y;

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

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

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

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

                        string strjwd= "经纬度: " + d1.ToString() + "°" + f1.ToString() + "′" + m1.ToString("##.#") + "″," + d2.ToString() + "°" + f2.ToString() + "′" + m2.ToString("##.#") + "″";
                        frmSubstationProperty frmSub = new frmSubstationProperty();
                        frmSub.jwstr = strjwd;
                        frmSub.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SvgDocument.currentLayer, lab);
                        if (frmSub.ShowDialog() == DialogResult.OK)
                        {
                            xml1.SetAttribute("info-name", frmSub.Sub.EleName);
                            SVG_ENTITY ent = new SVG_ENTITY();
                            if (frmSub.IsCreate)
                            {
                                ent.SUID = Guid.NewGuid().ToString();
                                ent.EleID = frmSub.Sub.EleID;
                                ent.layerID = frmSub.Sub.LayerID;
                                ent.MDATE = System.DateTime.Now;
                                ent.NAME = frmSub.Sub.EleName;
                                ent.svgID = frmSub.Sub.SvgUID;
                                ent.TYPE = "substation";
                                ent.voltage = Convert.ToInt32(frmSub.Sub.ObligateField1);
                                Services.BaseService.Create<SVG_ENTITY>(ent);
                            }
                            else
                            {
                                ent.NAME = frmSub.Sub.EleName;
                                ent.layerID = frmSub.Sub.LayerID;
                                ent.MDATE = System.DateTime.Now;
                                //ent.voltage = fl.Line.Voltage;
                                Services.BaseService.Update<SVG_ENTITY>(ent);
                            }
                        }
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("XL_GT_3") || xml1.GetAttribute("xlink:href").Contains("XL_GT_4"))
                    {
                        frmInputNum num = new frmInputNum();
                        num.InputStr = xml1.GetAttribute("order");
                        num.ShowDialog();
                        xml1.SetAttribute("order",num.InputStrSEL);
                    }
                    //if (xml1.GetAttribute("xlink:href").Contains("bdz") || xml1.GetAttribute("xlink:href").Contains("hwg") ||
                    //    xml1.GetAttribute("xlink:href").Contains("fjx") || xml1.GetAttribute("xlink:href").Contains("kbs") ||
                    //    xml1.GetAttribute("xlink:href").Contains("byq") || xml1.GetAttribute("xlink:href").Contains("kg"))
                    //{
                    //    frmInputDialog n1 = new frmInputDialog();
                    //    n1.InputStr = xml1.GetAttribute("info-name").ToString();
                    //    if (n1.ShowDialog() == DialogResult.OK)
                    //    {
                    //        xml1.SetAttribute("info-name",n1.InputStr);
                    //    }

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

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

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

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

                            xltProcessor.SetWholeLineAttribute(Code, "style", styleValue);
                        }
                    }

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

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

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

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

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

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

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

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

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

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

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

                    SvgDocument _doc = new SvgDocument();

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

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

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

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

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

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

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

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

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

                                string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                                if (!symlist.Contains(symid))
                                {
                                    symlist.Add(symid);
                                }
                                //}
                            }
                            if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline")
                            {
                                string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                                if (IsLead != "")
                                {
                                    if (ef1.Contains(ef2))
                                    {
                                        idlist.Add(graph1.ID);
                                    }
                                }
                            }

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

                        //            string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                        //            if (!symlist.Contains(symid)) {
                        //                symlist.Add(symid);
                        //            }
                        //        }
                        //    }
                        //    if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") {
                        //        string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                        //        if (IsLead != "") {
                        //            if (ef1.Contains(ef2)) {
                        //                idlist.Add(graph1.ID);
                        //            }
                        //        }
                        //    }
                        //}

                    }
                    symlist = ResetList(symlist);
                    svgtxt.AppendLine("</svg>");
                    _doc.LoadXml(svgtxt.ToString());
                    _doc.SvgdataUid = tlVectorControl1.SVGDocument.SvgdataUid;
                    frmPrintF pri = new frmPrintF();
                    pri.Init(tlVectorControl1.SVGDocument.CurrentElement.ID, tlVectorControl1.SVGDocument.SvgdataUid);
                    if (pri.ShowDialog() == DialogResult.OK)
                    {
                        frmSubPrint s = new frmSubPrint();
                        s.Vector = tlVectorControl1;
                        s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist);
                        s.Open(_doc, ef1);
                        s.Show();
                    }
                }
                if (e.ClickedItem.Text == "分类统计报表")
                {
                    if (tlVectorControl1.SVGDocument.CurrentElement == null || tlVectorControl1.SVGDocument.CurrentElement.ID == "svg")
                    {
                        return;
                    }
                    IGraph poly1 = (IGraph)tlVectorControl1.SVGDocument.CurrentElement;
                    frmPloyPrint p = new frmPloyPrint();

                    p.InitDate(poly1.ID, tlVectorControl1.SVGDocument.SvgdataUid);
                    p.ShowDialog();
                }
                if (e.ClickedItem.Text == "保存图片")
                {
                    if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.RectangleElement")
                    {
                        //frmImgInfoInput finput = new frmImgInfoInput();
                        //if (finput.ShowDialog() == DialogResult.OK)
                        //{
                        PrintHelper ph = new PrintHelper(tlVectorControl1, mapview);
                        frmImgManager frm = new frmImgManager();
                        //frm.StrName = finput.StrName;
                        //frm.StrRemark = finput.StrRemark;
                        frm.Pic = ph.getImage();
                        frm.ShowDialog();
                        //}
                    }
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message);
            }
            if (e.ClickedItem.Text == "三维变电站")
            {
                try
                {
                    string strid = tlVectorControl1.SVGDocument.CurrentElement.ID;
                    substation s = new substation();
                    s.EleID = strid;
                    s.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    s = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", s);
                    ProcessStartInfo p = new ProcessStartInfo();
                    p.FileName = Application.StartupPath + "\\" + s.EleName + "\\bdz.exe";
                    p.WorkingDirectory = Application.StartupPath + "\\" + s.EleName;
                    Process.Start(p);
                }
                catch (Exception e1) { }
            }
            if(e.ClickedItem.Text =="更新关联变电站"){
                UpdateLine();
            }
            if (e.ClickedItem.Text == "删除")
            {
                Delete();
            }
        }
Exemple #4
0
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (tlVectorControl1.SVGDocument.RootElement == null) {
                return;
            }
            XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
            if (xml1 != null) {
                if (e.ClickedItem.Text == "属性") {

                    if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl1.SVGDocument.getLayerList()/*"layer24288"*/)) {

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

                              IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle);
                              if (UseProList.Count > 0)
                              {
                                  _gle = UseProList[0];

                                  frmMainProperty f = new frmMainProperty();

                                  XmlNodeList n1 = tlVectorControl1.SVGDocument.GetElementsByTagName("use");
                                  PointF[] tfArray1 = TLMath.getPolygonPoints(xml1);
                                  string str220 = "";
                                  string str110 = "";
                                  string str66 = "";

                                  GraphicsPath selectAreaPath = new GraphicsPath();
                                  selectAreaPath.AddLines(tfArray1);
                                  selectAreaPath.CloseFigure();
                                  //Matrix x=new Matrix(
                                  //Region region1 = new Region(selectAreaPath);
                                  for (int i = 0; i < n1.Count; i++)
                                  {
                                      float OffX = 0f;
                                      float OffY = 0f;
                                      bool ck = false;
                                      Use use = (Use)n1[i];
                                      if (use.GetAttribute("xlink:href").Contains("Substation"))
                                      {
                                          string strMatrix = use.GetAttribute("transform");
                                          if (strMatrix != "")
                                          {
                                              strMatrix = strMatrix.Replace("matrix(", "");
                                              strMatrix = strMatrix.Replace(")", "");
                                              string[] mat = strMatrix.Split(',');
                                              if (mat.Length > 5)
                                              {
                                                  OffX = Convert.ToSingle(mat[4]);
                                                  OffY = Convert.ToSingle(mat[5]);
                                              }
                                          }
                                          if (frmlar.getSelectedLayer().Contains(use.GetAttribute("layer")))
                                          {
                                              ck = true;
                                          }
                                          PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href"));
                                          if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY) && ck)
                                          {
                                              if (use.GetAttribute("xlink:href").Contains("220"))
                                              {
                                                  str220 = str220 + "'" + use.GetAttribute("id") + "',";
                                              }
                                              if (use.GetAttribute("xlink:href").Contains("110"))
                                              {
                                                  str110 = str110 + "'" + use.GetAttribute("id") + "',";
                                              }
                                              if (use.GetAttribute("xlink:href").Contains("66"))
                                              {
                                                  str66 = str66 + "'" + use.GetAttribute("id") + "',";
                                              }
                                          }
                                      }
                                  }
                                  if (str220.Length > 1)
                                  {
                                      str220 = str220.Substring(0, str220.Length - 1);
                                  }
                                  if (str110.Length > 1)
                                  {
                                      str110 = str110.Substring(0, str110.Length - 1);
                                  }
                                  if (str66.Length > 1)
                                  {
                                      str66 = str66.Substring(0, str66.Length - 1);
                                  }
                                  f.InitData(_gle, str220, str110, str66);  ////////////////////////////////////////////////////
                                  f.IsReadonly = true;
                                  f.ShowDialog();

                              }
                              //}
                          }*/

                    }
                    if (getlayer(SvgDocument.currentLayer, "城市规划层", tlVectorControl1.SVGDocument.getLayerList())/*"layer97052"*/) {
                        if (tlVectorControl1.SVGDocument.getRZBRatio() != "") {
                            rzb = tlVectorControl1.SVGDocument.getRZBRatio();
                        }
                        if (xml1.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            string IsArea = xml1.GetAttribute("IsArea");
                            if (IsArea != "") {
                                frmProperty f = new frmProperty();
                                f.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer);
                                f.IsReadonly = true;
                                f.ShowDialog();
                            }
                        }
                    }
                    if (xml1 == null) return;
                    if (xml1.GetType().ToString() == "ItopVector.Core.Figure.Line" || xml1.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                        string IsLead = xml1.GetAttribute("IsLead");
                        if (IsLead != "") {
                            frmLineProperty fl = new frmLineProperty();
                            fl.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, LineLen, SvgDocument.currentLayer);
                            fl.IsReadonly = true;
                            fl.ShowDialog();
                        }
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("Substation")) {
                        string lab = xml1.GetAttribute("xlink:href");
                        frmSubstationProperty frmSub = new frmSubstationProperty();
                        frmSub.InitData(xml1.GetAttribute("id"), tlVectorControl1.SVGDocument.SvgdataUid, SvgDocument.currentLayer, lab);
                        frmSub.IsReadonly = true;
                        frmSub.ShowDialog();
                    }
                    if (tlVectorControl1.Operation == ToolOperation.InterEnclosure) {
                        if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            XmlNodeList n1 = tlVectorControl1.SVGDocument.GetElementsByTagName("use");
                            PointF[] tfArray1 = TLMath.getPolygonPoints(xml1);
                            string str220 = "";
                            string str110 = "";
                            string str66 = "";

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

                            IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle);
                            if (UseProList.Count > 0) {
                                _gle = UseProList[0];
                                _gle.LayerID = SvgDocument.currentLayer;
                                frmMainProperty f = new frmMainProperty();
                                f.simpleButton4.Visible = false;
                                f.InitData(_gle, str220, str110, str66);
                                //f.InitData(_gle, str220, str110, str66);  ////////////////////////////////////////////////////
                                f.IsReadonly = true;
                                f.ShowDialog();
                                //if (f.checkBox1.Checked == false)
                                //{
                                tlVectorControl1.SVGDocument.RootElement.RemoveChild(tlVectorControl1.SVGDocument.CurrentElement);
                                //}
                                //tlVectorControl1.Refresh();
                            }
                            //}
                        }
                    }
                    tlVectorControl1.SVGDocument.CurrentElement = null;
                }

                if (e.ClickedItem.Text == "接线图") {
                    pid = tlVectorControl1.SVGDocument.SvgdataUid;
                    SVGFILE svg_temp = new SVGFILE();
                    svg_temp.SUID = xml1.GetAttribute("id");
                    IList svglist = Services.BaseService.GetList("SelectSVGFILEByKey", svg_temp);
                    if (svglist.Count > 0) {
                        svg_temp = (SVGFILE)svglist[0];
                        SvgDocument sdoc = new SvgDocument();
                        sdoc.LoadXml(svg_temp.SVGDATA);
                        tlVectorControl1.SVGDocument = sdoc;
                        tlVectorControl1.SVGDocument.SvgdataUid = svg_temp.SUID;
                        MapType = "所内接线图";
                    } else {
                        tlVectorControl1.NewFile();
                        tlVectorControl1.IsPasteGrid = false;
                        tlVectorControl1.IsShowGrid = false;
                        tlVectorControl1.IsShowRule = false;
                        tlVectorControl1.IsShowTip = false;
                        tlVectorControl1.SVGDocument.SvgdataUid = svg_temp.SUID;
                        MapType = "所内接线图";
                    }
                    if (tlVectorControl1.SVGDocument.getLayerList().Count == 0) {
                        Layer _lar = ItopVector.Core.Figure.Layer.CreateNew("接线图", tlVectorControl1.SVGDocument);
                        _lar.SetAttribute("layerType", "所内接线图");
                        _lar.Visible = true;
                        SvgDocument.currentLayer = ((Layer)tlVectorControl1.SVGDocument.getLayerList()[0]).ID;
                    }
                    CreateComboBox();

                    ButtonEnb(true);
                    LoadImage = false;
                    bk1.Visible = false;
                    selLar = "";
                    tlVectorControl1.Refresh();
                }
            }
        }
Exemple #5
0
        /*public void ResetPoly()
        {
            SvgElementCollection col= tlVectorControl1.SVGDocument.SelectCollection;
            if(col.Count<1){
                return;
            }
            SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();
            foreach(SvgElement ele in col){
                if (ele.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                {
                    glebeProperty p=new glebeProperty();
                    p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    p.EleID = ((IGraph)ele).ID;
                    p = Services.BaseService.GetObject("SelectglebePropertyByEleID", p);
                    if(p!=null){
                        PointF[] tfArray1 = TLMath.getPolygonPoints(ele);
                        GraphicsPath selectAreaPath = new GraphicsPath();
                        selectAreaPath.AddLines(tfArray1);
                        selectAreaPath.CloseFigure();
                        Region region1 = new Region(selectAreaPath);
                        while (enumerator1.MoveNext())
                        {
                            IGraph graph1 = (IGraph)enumerator1.Current;
                            GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                            path1.Transform(graph1.GraphTransform.Matrix);
                            Region region2 = new Region(path1);
                            region2.Intersect(region1);
                            if (!region2.GetBounds(Graphics.FromHwnd(IntPtr.Zero)).IsEmpty)
                            {
                                glebeProperty p1 = new glebeProperty();
                                p1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                p1.EleID = graph1.ID;
                                p1 = Services.BaseService.GetObject("SelectglebePropertyByEleID", p1);
                                if(p1!=null){
                                    p1.ParentEleID = p.UID;
                                    Services.BaseService.Update("UpdateglebePropertyAreaAll", p1);
                                }
                            }
                        }
                    }
                }
            }
            MessageBox.Show("更新完成。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }*/
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try {
                if (e.ClickedItem.Text == "属性") {
                    XmlElement xml1 = (XmlElement)tlVectorControl2.SVGDocument.CurrentElement;
                    //PointF[] pf = TLMath.getPolygonPoints(xml1);

                    //((Polygon)xml1).Transform.Matrix.TransformPoints(pf);
                    // 规划
                    if (getlayer(SvgDocument.currentLayer, "电网规划层", tlVectorControl2.SVGDocument.getLayerList())) {

                        if (xml1 == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") {
                            MessageBox.Show("请先选择规划区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        if (tlVectorControl2.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polygon") {
                            XmlNodeList n1 = tlVectorControl2.SVGDocument.GetElementsByTagName("use");
                            PointF[] tfArray1 = TLMath.getPolygonPoints(xml1);
                            string str220 = "";
                            string str110 = "";
                            string str66 = "";
                            GraphicsPath selectAreaPath = new GraphicsPath();
                            selectAreaPath.AddLines(tfArray1);
                            selectAreaPath.CloseFigure();
                            //Matrix x=new Matrix(
                            //Region region1 = new Region(selectAreaPath);
                            for (int i = 0; i < n1.Count; i++) {
                                float OffX = 0f;
                                float OffY = 0f;
                                Use use = (Use)n1[i];
                                if (use.GetAttribute("xlink:href").Contains("Substation")) {
                                    string strMatrix = use.GetAttribute("transform");
                                    if (strMatrix != "") {
                                        strMatrix = strMatrix.Replace("matrix(", "");
                                        strMatrix = strMatrix.Replace(")", "");
                                        string[] mat = strMatrix.Split(',');
                                        if (mat.Length > 5) {
                                            OffX = Convert.ToSingle(mat[4]);
                                            OffY = Convert.ToSingle(mat[5]);
                                        }
                                    }
                                    PointF TempPoint = TLMath.getUseOffset(use.GetAttribute("xlink:href"));
                                    if (selectAreaPath.IsVisible(use.X + TempPoint.X + OffX, use.Y + TempPoint.Y + OffY)) {
                                        if (use.GetAttribute("xlink:href").Contains("220")) {
                                            str220 = str220 + "'" + use.GetAttribute("id") + "',";
                                        }
                                        if (use.GetAttribute("xlink:href").Contains("110")) {
                                            str110 = str110 + "'" + use.GetAttribute("id") + "',";
                                        }
                                        if (use.GetAttribute("xlink:href").Contains("66"))
                                        {
                                            str66 = str66 + "'" + use.GetAttribute("id") + "',";
                                        }
                                    }
                                }
                            }
                            if (str220.Length > 1) {
                                str220 = str220.Substring(0, str220.Length - 1);
                            }
                            if (str110.Length > 1) {
                                str110 = str110.Substring(0, str110.Length - 1);
                            }
                            if (str66.Length > 1)
                            {
                                str66 = str66.Substring(0, str66.Length - 1);
                            }

                            glebeProperty _gle = new glebeProperty();
                            _gle.EleID = tlVectorControl2.SVGDocument.CurrentElement.ID;
                            _gle.SvgUID = tlVectorControl2.SVGDocument.SvgdataUid;

                            IList<glebeProperty> UseProList = Services.BaseService.GetList<glebeProperty>("SelectglebePropertyByEleID", _gle);
                            if (UseProList.Count > 0) {
                                _gle = UseProList[0];
                                _gle.LayerID = SvgDocument.currentLayer;
                                frmMainProperty f = new frmMainProperty();

                                f.InitData(_gle, str220, str110,str66);

                                f.ShowDialog();

                            }
                            //}
                        }

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

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

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

                                f.InitData(xml1.GetAttribute("id"), tlVectorControl2.SVGDocument.SvgdataUid, SelUseArea, rzb, SvgDocument.currentLayer);
                                //f.ShowDialog();
                                if (progtype != "城市规划层") {
                                    f.IsReadonly = true;
                                }
                                if (f.ShowDialog() == DialogResult.OK) {
                                    if (f.gPro.ObligateField1 != "") {
                                        string color1 = ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(f.gPro.ObligateField1)));
                                        color1 = "fill:" + color1 + ";";
                                        ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).SetAttribute("style", color1);
                                        tlVectorControl2.UpdateProperty();
                                    }

                                }
                            }
                        }
                    }

                    if (tlVectorControl2.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Line" || tlVectorControl2.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                        string lineWidth = "2";
                        string IsLead = ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).GetAttribute("IsLead");
                        if (IsLead != "") {
                            frmLineProperty fl = new frmLineProperty();
                            fl.InitData(tlVectorControl2.SVGDocument.CurrentElement.GetAttribute("id"), tlVectorControl2.SVGDocument.SvgdataUid, LineLen, SvgDocument.currentLayer);
                            if (fl.ShowDialog() == DialogResult.OK) {
                                //Value="stroke-dasharray:8 8;stroke-width:2;stroke:#00C000;"
                                lineWidth = fl.LineWidth;
                                string styleValue = "";
                                if (fl.Line.ObligateField1 == "规划") {
                                    styleValue = "stroke-dasharray:6 1;stroke-width:" + lineWidth + ";";
                                } else {
                                    styleValue = "stroke-width:" + lineWidth + ";";
                                }
                                //string aa= ColorTranslator.ToHtml(Color.Black);
                                styleValue = styleValue + "stroke:" + ColorTranslator.ToHtml(Color.FromArgb(Convert.ToInt32(fl.Line.ObligateField2)));
                                ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).RemoveAttribute("style");
                                ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).SetAttribute("style", styleValue);
                                // tlVectorControl1.UpdateProperty();
                                // xml1.SetAttribute("style", styleValue);

                            }
                        }
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("Substation")) {
                        string lab = xml1.GetAttribute("xlink:href");
                        frmSubstationProperty frmSub = new frmSubstationProperty();
                        frmSub.InitData(xml1.GetAttribute("id"), tlVectorControl2.SVGDocument.SvgdataUid, SvgDocument.currentLayer, lab);
                        frmSub.ShowDialog();
                    }
                    if (xml1.GetAttribute("xlink:href").Contains("SB_GT")) {
                        string lineWidth = "2";

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

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

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

                            xltProcessor.SetWholeLineAttribute(Code, "style", styleValue);
                        }
                    }

                }
                if (e.ClickedItem.Text == "移动") {
                    if (tlVectorControl2.SVGDocument.CurrentElement == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    XmlElement xmln = (XmlElement)tlVectorControl2.SVGDocument.CurrentElement;
                    frmMove fm = new frmMove();
                    if (fm.ShowDialog() == DialogResult.OK) {
                        string strValue = fm.StrValue;
                        string[] str = strValue.Split(',');
                        string[] JWD1 = str[0].Split(' ');
                        Double J1 = Convert.ToDouble(JWD1[0]);
                        Double W1 = Convert.ToDouble(JWD1[1]);
                        Double D1 = Convert.ToDouble(JWD1[2]);
                        string[] JWD2 = str[1].Split(' ');
                        Double J2 = Convert.ToDouble(JWD2[0]);
                        Double W2 = Convert.ToDouble(JWD2[1]);
                        Double D2 = Convert.ToDouble(JWD2[2]);

                        Double JD = J1 + W1 / 60 + D1 / 3600;
                        Double WD = J2 + W2 / 60 + D2 / 3600;
                        IntXY xy = mapview.getXY(JD, WD);
                        PointF OffPoint = TLMath.getUseOffset(xmln.GetAttribute("xlink:href"));

                        xmln.RemoveAttribute("transform");
                        //xmln.RemoveAttribute("x");
                        xmln.SetAttribute("x", ((Double)(-xy.X / (Double)tlVectorControl2.ScaleRatio) - (Double)OffPoint.X).ToString("#####.####"));
                        // xmln.RemoveAttribute("y");
                        xmln.SetAttribute("y", ((Double)(-xy.Y / (Double)tlVectorControl2.ScaleRatio) - (Double)OffPoint.Y).ToString("#####.####"));
                        tlVectorControl2.Refresh();
                    }
                }
                if (e.ClickedItem.Text == "接线图") {
                    if (tlVectorControl2.SVGDocument.CurrentElement == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    ParentUID = tlVectorControl2.SVGDocument.SvgdataUid;
                    Save();
                    ParentUID = tlVectorControl2.SVGDocument.SvgdataUid;
                    SVGFILE svg_temp = new SVGFILE();
                    svg_temp.SUID = ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).GetAttribute("id");
                    svg_temp.FILENAME = ((XmlElement)tlVectorControl2.SVGDocument.CurrentElement).GetAttribute("info-name");
                    IList svglist = Services.BaseService.GetList("SelectSVGFILEByKey", svg_temp);
                    OpenJXT(svglist, svg_temp);
                    //frmlar.SymbolDoc = tlVectorControl2.SVGDocument;
                    //frmlar.Progtype = MapType;
                    //frmlar.InitData();
                    //JxtBar();
                }
                if (e.ClickedItem.Text == "打开") {
                    if (tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") {
                        MessageBox.Show("请选择地块。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRelating UseRel = new UseRelating();
                    UseRel.UseID = tlVectorControl2.SVGDocument.CurrentElement.ID;
                    IList<UseRelating> UseRelList = Services.BaseService.GetList<UseRelating>("SelectUseRelatingByUseID", UseRel);
                    if (UseRelList.Count < 1) {
                        MessageBox.Show("选择的地块还没有关联到其他地图,请先设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    UseRel = UseRelList[0];
                    SVGFILE svgFile = new SVGFILE();
                    svgFile.SUID = UseRel.LinkUID;
                    IList svgList = Services.BaseService.GetList("SelectSVGFILEByKey", svgFile);
                    if (svgList.Count < 1) {
                        MessageBox.Show("被关联的地图已经被删除,请重新设置关联地图", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    svgFile = (SVGFILE)svgList[0];
                    //SvgDocument doc = new SvgDocument();

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

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

                    SvgDocument _doc = new SvgDocument();

                    Graph poly1 = tlVectorControl2.SVGDocument.CurrentElement as Graph;
                    if (poly1 == null || poly1.GetAttribute("id") == "svg") {
                        return;
                    }
                    GraphicsPath gr1 = new GraphicsPath();
                    gr1.AddPolygon(TLMath.getPolygonPoints(poly1));
                    //gr1.CloseFigure();
                    gr1 = (GraphicsPath)poly1.GPath.Clone();

                    gr1.Transform((poly1 as IGraph).Transform.Matrix);

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

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

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

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

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

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

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

                                    string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                                    if (!symlist.Contains(symid)) {
                                        symlist.Add(symid);
                                    }
                                //}
                            }
                            if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") {
                                string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                                if (IsLead != "") {
                                    if (ef1.Contains(ef2)) {
                                        idlist.Add(graph1.ID);
                                    }
                                }
                            }

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

                        //            string symid = ((XmlElement)graph1).GetAttribute("xlink:href");
                        //            if (!symlist.Contains(symid)) {
                        //                symlist.Add(symid);
                        //            }
                        //        }
                        //    }
                        //    if (graph1.GetType().FullName == "ItopVector.Core.Figure.Polyline") {
                        //        string IsLead = ((XmlElement)graph1).GetAttribute("IsLead");
                        //        if (IsLead != "") {
                        //            if (ef1.Contains(ef2)) {
                        //                idlist.Add(graph1.ID);
                        //            }
                        //        }
                        //    }
                        //}

                    }
                    symlist = ResetList(symlist);
                    svgtxt.AppendLine("</svg>");
                    _doc.LoadXml(svgtxt.ToString());
                    _doc.SvgdataUid = tlVectorControl2.SVGDocument.SvgdataUid;
                    frmPrintF pri = new frmPrintF();
                    pri.Init(tlVectorControl2.SVGDocument.CurrentElement.ID, tlVectorControl2.SVGDocument.SvgdataUid);
                    if (pri.ShowDialog() == DialogResult.OK) {
                        frmSubPrint s = new frmSubPrint();
                        s.Vector = tlVectorControl2;
                        s.InitImg(pri.strzt, pri.strgs, pri.pri, idlist, symlist);
                        s.Open(_doc, ef1);
                        s.Show();
                    }
                }
                if (e.ClickedItem.Text == "分类统计报表") {
                    if (tlVectorControl2.SVGDocument.CurrentElement == null || tlVectorControl2.SVGDocument.CurrentElement.ID == "svg") {
                        return;
                    }
                    IGraph poly1 = (IGraph)tlVectorControl2.SVGDocument.CurrentElement;
                    frmPloyPrint p = new frmPloyPrint();

                    p.InitDate(poly1.ID, tlVectorControl2.SVGDocument.SvgdataUid);
                    p.ShowDialog();
                }
            } catch (Exception e1) {
                MessageBox.Show(e1.Message);
            }
        }