Esempio n. 1
0
 // Methods
 internal LinearGradient(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     this.x1 = 0f;
     this.y1 = 0f;
     this.x2 = 1f;
     this.y2 = 0f;
     this.gradientTransform = new Transf();
     this.gradientUnit = Units.ObjectBoundingBox;
     this.spreadMethod = SpreadMethods.Pad;
     this.boundsPath = new GraphicsPath();
     this.boundrect = RectangleF.Empty;
     this.stops = new SvgElementCollection();
     this.gradientstart = PointF.Empty;
     this.gradientend = PointF.Empty;
     this.rotatepoint = PointF.Empty;
     this.translatepoint = PointF.Empty;
     this.scalePoint = PointF.Empty;
     this.boundsPoints = new PointF[0];
     this.ratiomatrix = new Matrix();
     this.brush = null;
     this.coord = new Matrix();
     this.gradientpath = new GraphicsPath();
     this.pen = null;
     this.GraphMatrix = new Matrix();
 }
Esempio n. 2
0
 // Methods
 internal RadialGradients(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     this.cx = 0.5f;
     this.cy = 0.5f;
     this.r = 0.5f;
     this.gradientpath = new GraphicsPath();
     this.gradientTransform = new Transf();
     this.bounds = RectangleF.Empty;
     this.gradientUnit = Units.ObjectBoundingBox;
     this.spreadMethod = SpreadMethods.Pad;
     this.stops = new SvgElementCollection();
     this.boundsPoints = new PointF[0];
     this.coord = new Matrix();
     this.pen = null;
 }
Esempio n. 3
0
 // Methods
 internal Graph(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     //			this.transform = new Transf();
     this.visible = true;
     this.showBound = false;
     this.graphTransform = new Transf();
     this.tempOpacity = 1f;
     this.tempFillOpacity = 1f;
     this.tempStrokeOpacity = 1f;
     this.boundColor = Color.Empty;
     this.isLock = false;
     this.drawVisible = true;
     this.pointsinfo = new PointInfoCollection();
     this.pointsinfo.OwerGraph = this;
     this.IsClip = false;
     this.Changed = true;
     this.connectPoints = new PointF[0];
     this.connectLines = new SvgElementCollection();
     this.canSelect=true;
     this.limitSize =false;
 }
Esempio n. 4
0
 // Methods
 internal Group(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     this.graphList = new SvgElementCollection();
     this.graphPath = new GraphicsPath();
     this.graphTransform = new Transf();
     this.graphBrush = new SolidColor(Color.Empty);
     this.graphStroke = new Stroke();
     this.connectPoints = new PointF[0];
     this.visible = true;
     this.showBound = false;
     this.tempOpacity = 1f;
     this.tempFillOpacity = 1f;
     this.tempStrokeOpacity = 1f;
     this.boundColor = Color.Empty;
     this.isLock = false;
     this.drawVisible = true;
     this.updateattribute = true;
     this.Changed = true;
     this.connectLines = new ItopVector.Core.SvgElementCollection();
     this.graphStroke.OnStrokeBrushChanged += new EventHandler(this.ChangeStrokeBrush);
     canSelect=true;
     this.limitSize =false;
 }
Esempio n. 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)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 (IsLead != "")       //修改后的导线的属性添加情况
                        {
                            PSPDEV obj = new PSPDEV();
                            string deviceid = xml1.GetAttribute("Deviceid");
                            if (string.IsNullOrEmpty(deviceid)) {
                                obj = (PSPDEV)DeviceHelper.SelectDevice(DeviceType.XL, Itop.Client.MIS.ProgUID);
                                if (obj==null)
                                {
                                    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    tlVectorControl1.Delete();
                                }
                                if ( obj is PSPDEV) {
                                    deviceid = ((PSPDEV)obj).SUID;
                                    xml1.SetAttribute("Deviceid", deviceid);
                                }
                            }
                            if (!string.IsNullOrEmpty(deviceid)) {
                                obj = (PSPDEV)DeviceHelper.GetDevice<PSPDEV>(deviceid);
                                if (obj != null) {
                                    xml1.SetAttribute("info-name", ((PSPDEV)obj).Name);
                                    DeviceHelper.ShowDeviceDlg(DeviceType.XL, deviceid, false);
                                }

                                LineInfo li = new LineInfo();
                                li.UID = obj.SUID;
                                li = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByKey", li);
                                if (li != null) {
                                    li.LayerID = SvgDocument.currentLayer;
                                    li.EleID = xml1.GetAttribute("id");
                                    li.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    LineType lt = new LineType();
                                    lt.TypeName = li.Voltage.ToString() + "kV";
                                    lt = (LineType)Services.BaseService.GetObject("SelectLineTypeByTypeName", lt);
                                    li.ObligateField3 = obj.OperationYear;
                                    if (lt != null)
                                    {
                                        li.ObligateField2 = lt.Color;
                                        lineWidth = lt.ObligateField1;
                                    }

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

                                    if (!string.IsNullOrEmpty(li.ObligateField3)) {
                                        if (Convert.ToInt32(obj.OperationYear) > DateTime.Now.Year) {
                                            li.ObligateField1 = "规划";
                                        } else
                                            li.ObligateField1 = "运行";
                                    }

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

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

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

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

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

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

                        x = ((Use)xml1).X;

                        y = ((Use)xml1).Y;

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

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

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

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

                        string strjwd = "经纬度: " + d1.ToString() + "°" + f1.ToString() + "′" + m1.ToString("##.#") + "″," + d2.ToString() + "°" + f2.ToString() + "′" + m2.ToString("##.#") + "″";
                        object obj = null;
                        string deviceid = xml1.GetAttribute("Deviceid");
                        if (string.IsNullOrEmpty(deviceid)) {
                            //XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text;
                            if (xml1.GetAttribute("xlink:href").Contains("Power")) {
                                obj = DeviceHelper.SelectDevice(DeviceType.DY, Itop.Client.MIS.ProgUID);
                                if (obj == null)
                                {
                                    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    tlVectorControl1.Delete();
                                }
                                if (obj is PSP_PowerSubstation_Info) {
                                    deviceid = ((PSP_PowerSubstation_Info)obj).UID;
                                    xml1.SetAttribute("Deviceid", deviceid);
                                }
                                substation sb = new substation();
                                sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                if (sb != null) {
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    sb.EleID = xml1.GetAttribute("id");
                                    if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Update<substation>(sb);
                                } else {
                                    sb = new substation();
                                    sb.UID = ((PSP_PowerSubstation_Info)obj).UID;
                                    sb.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                    sb.EleID = xml1.GetAttribute("id");
                                    sb.LayerID = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                                    if (((PSP_PowerSubstation_Info)obj).Flag == "2") {
                                        sb.ObligateField3 = "规划";
                                    } else if (((PSP_PowerSubstation_Info)obj).Flag == "1") {
                                        sb.ObligateField3 = "现行";
                                    }
                                    Services.BaseService.Create<substation>(sb);
                                }
                            } else {
                                obj = DeviceHelper.SelectDevice(DeviceType.BDZ, Itop.Client.MIS.ProgUID);
                                if (obj == null)
                                {
                                    tlVectorControl1.SVGDocument.CurrentElement = xml1 as SvgElement;
                                    tlVectorControl1.Delete();
                                }
                                if (obj is PSP_Substation_Info) {
                                    deviceid = ((PSP_Substation_Info)obj).UID;
                                    xml1.SetAttribute("Deviceid", deviceid);
                                    //RectangleF t = ((IGraph)xml1).GetBounds();
                                    //n1.SetAttribute("x", (t.X - 30).ToString());
                                    //n1.SetAttribute("y", (t.Y - 30).ToString());
                                    //n1.SetAttribute("font-size", "24");
                                    //n1.InnerText = ((PSP_Substation_Info)obj).Title;
                                    //n1.SetAttribute("layer", SvgDocument.currentLayer);
                                    //n1.SetAttribute("ParentID", temp.GetAttribute("id"));
                                    //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1);
                                    //tlVectorControl1.Operation = ToolOperation.Select;
                                }
                                substation sb = new substation();
                                sb.UID = ((PSP_Substation_Info)obj).UID;
                                sb = (substation)Services.BaseService.GetObject("SelectsubstationByKey", sb);
                                if (sb != null) {

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

                        }
                        //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(' ');
                        decimal J1 = Convert.ToDecimal(JWD1[0]);
                        decimal W1 = Convert.ToDecimal(JWD1[1]);
                        decimal D1 = Convert.ToDecimal(JWD1[2]);
                        string[] JWD2 = str[1].Split(' ');
                        decimal J2 = Convert.ToDecimal(JWD2[0]);
                        decimal W2 = Convert.ToDecimal(JWD2[1]);
                        decimal D2 = Convert.ToDecimal(JWD2[2]);

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

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

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

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

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

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

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

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

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

                    SvgDocument _doc = new SvgDocument();

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

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

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

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

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

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

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

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

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

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

                        }
                        //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();
            }
        }
Esempio n. 6
0
        public void ConnLine()
        {
            try {
                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") != "") {

                        PointF[] pfs1 = new PointF[2] { pl1.Points[0], pl1.Points[pl1.Points.Length - 1] };
                        PointF[] pfs2 = new PointF[2] { pl2.Points[0], pl2.Points[pl2.Points.Length - 1] };
                        PointF[] pfs3 = (PointF[])pl1.Points.Clone();
                        PointF[] pfs4 = (PointF[])pl2.Points.Clone();
                        pl1.Transform.Matrix.TransformPoints(pfs3);
                        pl2.Transform.Matrix.TransformPoints(pfs4);
                        ArrayList list = new ArrayList();
                        list.AddRange(pfs3);
                        list.Reverse();
                        PointF[] pfs5 = (PointF[])list.ToArray(typeof(PointF));
                        list.Clear();
                        list.AddRange(pfs4);
                        list.Reverse();
                        PointF[] pfs6 = (PointF[])list.ToArray(typeof(PointF));

                        pl1.Transform.Matrix.TransformPoints(pfs1);
                        pl2.Transform.Matrix.TransformPoints(pfs2);

                        double[] d = new double[4];

                        d[0] = TLMath.GetPointsLen(pfs1[0], pfs2[0]);
                        d[1] = TLMath.GetPointsLen(pfs1[0], pfs2[1]);
                        d[2] = TLMath.GetPointsLen(pfs1[1], pfs2[0]);
                        d[3] = TLMath.GetPointsLen(pfs1[1], pfs2[1]);

                        int num = 0;
                        double min = d[0];

                        for (int i = 1; i < 4; i++) {
                            if (min > d[i]) {
                                num = i;
                                min = d[i];
                            }
                        }
                        list.Clear();
                        switch (num) {
                            case 0:
                                list.AddRange(pfs5);
                                list.AddRange(pfs4);
                                break;
                            case 1:
                                list.AddRange(pfs5);
                                list.AddRange(pfs6);
                                break;
                            case 2:
                                list.AddRange(pfs3);
                                list.AddRange(pfs4);
                                break;
                            case 3:
                                list.AddRange(pfs3);
                                list.AddRange(pfs6);
                                break;
                        }
                        pl1.Points = (PointF[])list.ToArray(typeof(PointF));
                        LineInfo lpl1 = new LineInfo();
                        LineInfo lpl2 = new LineInfo();
                        lpl1.EleID = pl1.ID;
                        lpl1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                        lpl2.EleID = pl2.ID;
                        lpl2.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                        lpl1 = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", lpl1);
                        lpl2 = (LineInfo)Services.BaseService.GetObject("SelectLineInfoByEleID", lpl2);
                        if (lpl1 != null && lpl2 != null) {
                            lpl1.LineName = lpl1.LineName + "连接" + lpl2.LineName;
                            decimal temp1 = TLMath.getPolylineLength(pl1, 1);
                            temp1 = TLMath.getNumber(temp1, tlVectorControl1.ScaleRatio);
                            string len = temp1.ToString("#####.####");
                            lpl1.Length = len;
                            Services.BaseService.Update<LineInfo>(lpl1);
                            Services.BaseService.Update("DeleteLineInfo", lpl2);
                        }
                        ItopVector.Core.Types.Transf transf = new ItopVector.Core.Types.Transf(new Matrix());
                        pl1.Transform = transf;
                        pl2.ParentNode.RemoveChild(pl2);
                        elements.Remove(pl2);
                    }
                }
            } catch (Exception e) {
                MessageBox.Show("提示", "请选择两条线路。", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 7
0
        public SvgElement AddElement(ISvgElement mypath)
        {
            //			AttributeFunc.SetAttributeValue((XmlElement)mypath,"layer",SvgDocument.currentLayer);
            XmlNode node1 = OwnerDocument.RootElement;
            XmlNode newNode =null;

                Matrix matrix1 = new Matrix();
            //				if (node1 is IGraph)
            //				{
            //					matrix1 = ((IGraph) node1).GraphTransform.Matrix.Clone();
            //					Matrix matrix2 = this.coordTransform.Clone();
            //					matrix2.Invert();
            //					matrix1.Multiply(matrix2, MatrixOrder.Append);
            //				}
            //				matrix1.Invert();
            //				matrix1 = TransformFunc.RoundMatrix(matrix1, 2);
                bool flag1 = OwnerDocument.AcceptChanges;
                //				OwnerDocument.AcceptChanges = false;
                OwnerDocument.AcceptChanges = true;
                if (mypath is IGraphPath)
                {
                    ISvgBrush brush1 = ((IGraphPath) mypath).GraphBrush;
                    if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null))
                    {
                        bool flag2 = OwnerDocument.AcceptChanges;
                        OwnerDocument.AcceptChanges = true;
                        OwnerDocument.NumberOfUndoOperations++;
                        XmlNode node2 = OwnerDocument.AddDefsElement((SvgElement) brush1);
                        OwnerDocument.AcceptChanges = false;
                        if (node2 is ITransformBrush)
                        {
                            string text1 = ((SvgElement) node2).ID;
                            AttributeFunc.SetAttributeValue((SvgElement) mypath, "fill", "url(#" + text1 + ")");
                        }
                        OwnerDocument.AcceptChanges = flag2;
                    }
                    brush1 = ((IGraphPath) mypath).GraphStroke.Brush;
                    if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null))
                    {
                        bool flag3 = OwnerDocument.AcceptChanges;
                        OwnerDocument.AcceptChanges = true;
                        OwnerDocument.NumberOfUndoOperations++;
                        XmlNode node3 = OwnerDocument.AddDefsElement((SvgElement) brush1);
                        OwnerDocument.AcceptChanges = false;
                        if (node3 is ITransformBrush)
                        {
                            string text2 = ((SvgElement) node3).ID;
                            AttributeFunc.SetAttributeValue((SvgElement) mypath, "stroke", "url(#" + text2 + ")");
                        }
                        OwnerDocument.AcceptChanges = flag3;
                    }
                }
                if (!matrix1.IsIdentity && (mypath is IGraph))
                {
                    bool flag4 = OwnerDocument.AcceptChanges;
                    OwnerDocument.AcceptChanges = false;
                    Matrix matrix3 = ((IGraph) mypath).Transform.Matrix.Clone();
                    matrix1.Multiply(matrix3);
                    Transf transf1 = new Transf();
                    transf1.setMatrix(matrix1);
                    AttributeFunc.SetAttributeValue((SvgElement) mypath, "transform", transf1.ToString());
                    OwnerDocument.AcceptChanges = flag4;
                }
                if (((SvgElement) mypath).ParentNode != node1)
                {
                    if (((ContainerElement) node1).IsValidChild((SvgElement) mypath))
                    {
                        //						node1.AppendChild((SvgElement) mypath);
                        SvgElement element1 =(SvgElement) mypath;//(SvgElement)OwnerDocument.ImportNode((SvgElement) mypath,true);
                        newNode = node1.AppendChild(element1);
                        OwnerDocument.Render(element1);
                    }
                }
                OwnerDocument.AcceptChanges = flag1;

            return newNode!=null?newNode as SvgElement:null;
        }
Esempio n. 8
0
        public void ParseAttribute(string localname, string valuestr, bool add, Point p)
        {
            if (this.CreateParse)
            {
                if (localname == "clip-path")
                {
                    int num1 = this.OwnerDocument.FlowChilds.IndexOf(this);
                    XmlNode node1 = NodeFunc.GetRefNode(valuestr, this.ownerDocument);
                    if (((node1 is ClipPath) && (this is IGraph)) && !this.ownerDocument.FlowChilds.Contains((SvgElement) node1))
                    {
                        if ((num1 + 1) < this.OwnerDocument.FlowChilds.Count)
                        {
                            this.OwnerDocument.InsertFlowElement(num1 + 1, (SvgElement) node1);
                        }
                        else
                        {
                            this.OwnerDocument.AddFlowElement((SvgElement) node1);
                        }
                    }
                }
                localname = localname.Trim();
            //				if(localname!="id")
                valuestr = valuestr.Trim();
                if (localname == "style")
                {
                    string text1 = valuestr.Trim();
                    string text2 = @"[\t\n;\t\n]+";
                    Regex regex1 = new Regex(text2, RegexOptions.IgnoreCase);
                    regex1.Replace(text1, ";");
                    text2 = ";";
                    string[] textArray2 = regex1.Split(text1);

                    ArrayList list1 =new ArrayList();

                    for (int num3 = 0; num3 < textArray2.Length; num3++)
                    {
                        string text3 = textArray2[num3];
                        int num2 = text3.IndexOf(":");
                        if (num2 >= 0)
                        {
                            list1.Add(text3.Substring(0, num2));
                            this.ParseAttribute(text3.Substring(0, num2), text3.Substring(num2 + 1, (text3.Length - num2) - 1), add, p);
                        }
                    }

                    ArrayList list2 =new ArrayList(this.svgAnimAttributes.Keys);
                    foreach(object key in list2)
                    {

                        if(AttributeFunc.StyleAttributes.Contains(key)&&!list1.Contains(key))
                        {
                            this.svgAnimAttributes.Remove(key);
                        }
                    }
                }
                else
                {
                    try
                    {
                        GraphicsPath path1;
                        Matrix matrix1;
                        SvgTime time1;
                        PointF[] tfArray1;
                        if (!add)
                        {
                            goto Label_0627;
                        }
                        switch (DomTypeFunc.GetTypeOfAttributeName(localname))
                        {
                            case DomType.SvgMatrix:
                            {
                                matrix1 = new Matrix();
                                matrix1 = new Transf(valuestr).Matrix;
                                if (!this.svgAttributes.ContainsKey(localname))
                                {
                                    goto Label_0301;
                                }
                                this.svgAttributes[localname] = matrix1;
                                goto Label_030F;
                            }
                            case DomType.SvgNumber:
                            {
                                float single1 = 0f;
                                ItopVector.Core.Func.SvgLengthDirection direction1 = ItopVector.Core.Func.SvgLengthDirection.Horizontal;
                                if ((localname == "height") || (localname == "y"))
                                {
                                    direction1 = ItopVector.Core.Func.SvgLengthDirection.Vertical;
                                }
                                single1 = ItopVector.Core.Func.Number.parseToFloat(valuestr, this, direction1);
                                if (this.svgAttributes.ContainsKey(localname))
                                {
                                    this.svgAttributes[localname] = single1;
                                }
                                else
                                {
                                    this.svgAttributes.Add(localname, single1);
                                }
                                if (this.svgAttributes.ContainsKey(localname))
                                {
                                    this.svgAnimAttributes[localname] = single1;
                                    goto Label_0625;
                                }
                                this.svgAnimAttributes.Add(localname, single1);
                                return;
                            }
                            case DomType.SvgString:
                            case DomType.SvgColor:
                            {
                                goto Label_04F1;
                            }
                            case DomType.SvgPath:
                            {
                                path1 = new GraphicsPath();
                                if (!(this is IPath))
                                {
                                    break;
                                }
                                PointF tf1 = PointF.Empty;
                                path1 = PathFunc.PathDataParse(valuestr, ((IPath) this).PointsInfo);
                                goto Label_01CF;
                            }
                            case DomType.SvgPoints:
                            {
                                tfArray1 = null;
                                if (!(this is IPath))
                                {
                                    goto Label_03CA;
                                }
                                tfArray1 = PointsFunc.PointsParse(valuestr, ((IPath) this).PointsInfo);
                                goto Label_03D2;
                            }
                            case DomType.SvgTime:
                            {
                                if (this is ConnectLine)goto Label_04F1;
                                time1 = new SvgTime(valuestr.Trim());
                                if (!this.svgAttributes.ContainsKey(localname))
                                {
                                    goto Label_036B;
                                }
                                this.svgAttributes[localname] = time1;
                                goto Label_0379;
                            }
                            case DomType.SvgLink:
                            {
                                if (!(this is ItopVector.Core.Figure.Image))
                                {
                                    goto Label_0454;
                                }

                                if(SvgDocument.BkImageLoad)
                                {
                                    Bitmap bitmap1;
                                    if(valuestr=="")
                                    {
                                        bitmap1=null;
                                    }
                                    else
                                    {
                                        bitmap1 = ImageFunc.GetImageForURL(valuestr.Trim(),this);
                                    }
                                    ((ItopVector.Core.Figure.Image) this).RefImage = bitmap1;
                                }
                                else
                                {
                                    Bitmap bitmap1 = ImageFunc.GetImageForURL(valuestr.Trim(), this);//wlwl
                                    ((ItopVector.Core.Figure.Image) this).RefImage = bitmap1;
                                }
                                goto Label_0498;
                            }
                            default:
                            {
                                goto Label_04F1;
                            }
                        }
                        path1 = PathFunc.PathDataParse(valuestr);
                    Label_01CF:
                        if (this.svgAttributes.ContainsKey(localname))
                        {
                            this.svgAttributes[localname] = path1;
                        }
                        else
                        {
                            this.svgAttributes.Add(localname, path1);
                        }
                        if (this.svgAttributes.ContainsKey(localname))
                        {
                            this.svgAnimAttributes[localname] = path1;
                            goto Label_0625;
                        }
                        this.svgAnimAttributes.Add(localname, path1);
                        return;
                    Label_0301:
                        this.svgAttributes.Add(localname, matrix1);
                    Label_030F:
                        if (this.svgAttributes.ContainsKey(localname))
                        {
                            this.svgAnimAttributes[localname] = matrix1;
                            goto Label_0625;
                        }
                        this.svgAnimAttributes.Add(localname, matrix1);
                        return;
                    Label_036B:
                        this.svgAttributes.Add(localname, time1);
                    Label_0379:
                        if (this.svgAttributes.ContainsKey(localname))
                        {
                            this.svgAnimAttributes[localname] = time1;
                            goto Label_0625;
                        }
                        this.svgAnimAttributes.Add(localname, time1);
                        return;
                    Label_03CA:
                        tfArray1 = PointsFunc.PointsParse(valuestr);
                    Label_03D2:
                        if (this.svgAttributes.ContainsKey(localname))
                        {
                            this.svgAttributes[localname] = tfArray1;
                        }
                        else
                        {
                            this.svgAttributes.Add(localname, tfArray1);
                        }
                        if (this.svgAttributes.ContainsKey(localname))
                        {
                            this.svgAnimAttributes[localname] = tfArray1;
                            goto Label_0625;
                        }
                        this.svgAnimAttributes.Add(localname, tfArray1);
                        return;
                    Label_0454:
                        if (this is Use)
                        {
                            XmlNode node2 = NodeFunc.GetRefNode(valuestr.Trim(), this.ownerDocument);
                            if (node2 is SvgElement)
                            {
                                ((Use) this).RefElement = (SvgElement) node2;
                            }
                            else
                            {
                                ((Use) this).RefElement = null;
                            }
                        }
                    Label_0498:
                        if (this.svgAttributes.ContainsKey(localname))
                        {
                            this.svgAttributes[localname] = valuestr;
                        }
                        else
                        {
                            this.svgAttributes.Add(localname, valuestr);
                        }
                        if (this.svgAnimAttributes.ContainsKey(localname))
                        {
                            this.svgAnimAttributes[localname] = valuestr;
                            goto Label_0625;
                        }
                        this.svgAnimAttributes.Add(localname, valuestr);
                        return;
                    Label_04F1:
                        if (this.svgAttributes.ContainsKey(localname))
                        {
                            string text4 = this.svgAttributes[localname].ToString();
                            this.svgAttributes[localname] = valuestr;
                            if (((this is IGraphPath) && (text4 != valuestr)) && (this.ParentNode != null))
                            {
                                if (localname == "stroke")
                                {
                                    ((IGraphPath) this).GraphStroke.Brush = BrushManager.Parsing(valuestr, this.ownerDocument);
                                    goto Label_05F9;
                                }
                                if (localname == "fill")
                                {
                                    ((IGraphPath) this).GraphBrush = BrushManager.Parsing(valuestr, this.ownerDocument);
                                }
                            }
            //							if (localname == "layer")
            //							{
            //                                ISvgElement element1= ownerDocument.Layers[text4] ;
            //								if(element1!=null )
            //								{
            //									(element1 as ILayer).Remove(this);
            //								}
            //								element1= ownerDocument.Layers[valuestr] ;
            //								if(element1!=null )
            //								{
            //									(element1 as ILayer).Add(this);
            //								}
            //							}
                        }
                        else
                        {
                            this.svgAttributes.Add(localname, valuestr);
                            if ((this is IGraphPath) && (this.ParentNode != null))
                            {
                                if (localname == "stroke")
                                {
                                    ((IGraphPath) this).GraphStroke.Brush = BrushManager.Parsing(valuestr, this.ownerDocument);
                                }
                                else if (localname == "fill")
                                {
                                    ((IGraphPath) this).GraphBrush = BrushManager.Parsing(valuestr, this.ownerDocument);
                                }
                            }
            //							if (localname == "layer")
            //							{
            //								ISvgElement 	element1= ownerDocument.Layers[valuestr] ;
            //								if(element1!=null )
            //								{
            //									(element1 as ILayer).Add(this);
            //								}
            //							}
                        }
                    Label_05F9:

                        if (this.svgAnimAttributes.ContainsKey(localname))
                        {
                            this.svgAnimAttributes[localname] = valuestr;
                        }
                        else
                        {
                            this.svgAnimAttributes.Add(localname, valuestr);
                        }/**/
                    Label_0625:
                        return;
                    Label_0627:
                        this.svgAnimAttributes.Remove(localname);
                        this.svgAttributes.Remove(localname);
                    }
                    catch (Exception exception1)
                    {
                        if (!p.IsEmpty)
                        {
                            string[] textArray3 = new string[6] { exception1.Message, "��(", p.X.ToString(), "��", p.Y.ToString(), ")����������" } ;
                            this.ownerDocument.ErrorInfos.Add(new SvgException(string.Concat(textArray3), p.X, p.Y));
                        }
                    }
                }
            }
        }

        public void PreAppendAnim(ItopVector.Core.Animate.Animate anim)
        {
            this.PrependChild(anim);
        }

        public override XmlNode PrependChild(XmlNode newChild)
        {
            if (newChild.OwnerDocument != this.OwnerDocument)
            {
                XmlNode node1 = newChild.Clone();
                bool flag1 = this.ownerDocument.AcceptChanges;
                this.ownerDocument.AcceptChanges = false;
                XmlNode node2 = this.ownerDocument.ImportNode(node1, true);
                newChild = node2;
                this.ownerDocument.AcceptChanges = flag1;
            }
            XmlNode node3 = base.PrependChild(newChild);
            if ((node3 is ItopVector.Core.Animate.Animate) && !this.animatelist.Contains((SvgElement) node3))
            {
                if (this.animatelist.Count == 0)
                {
                    this.animatelist.Add((SvgElement) node3);
                }
                else
                {
                    this.animatelist.Insert(0, (SvgElement) node3);
                }
                if (this.showParticular)
                {
                    this.InsertFlowElment(0, (SvgElement) node3);
                }
            }
            return node3;
        }

        public override void RemoveAll()
        {
            base.RemoveAll();
            this.animatelist.Clear();
            this.svgAttributes.Clear();
        }

        public override void RemoveAllAttributes()
        {
            base.RemoveAllAttributes();
            this.svgAttributes.Clear();
            this.svgAnimAttributes.Clear();
            if (this is IPath)
            {
                ((IPath) this).PointsInfo.Clear();
            }
        }

        public override void RemoveAttribute(string name)
        {
            base.RemoveAttribute(name);
            if (this.svgAttributes.ContainsKey(name))
            {
                this.svgAttributes.Remove(name);
            }
            if (this.svgAnimAttributes.ContainsKey(name))
            {
                this.svgAnimAttributes.Remove(name);
            }
            if (((name == "d") || (name == "path")) && (this is IPath))
            {
                ((IPath) this).PointsInfo.Clear();
            }
        }

        public virtual void RemoveAttribute(XmlAttribute oldattr)
        {
            if (oldattr != null)
            {
                this.ParseAttribute(oldattr.Name.Trim(), oldattr.Value.Trim(), false);
            }
        }

        public override void RemoveAttribute(string localname, string namespaceURI)
        {
            base.RemoveAttribute(localname, namespaceURI);
            if (this.svgAttributes.ContainsKey(localname))
            {
                this.svgAttributes.Remove(localname);
            }
            if (this.svgAnimAttributes.ContainsKey(localname))
            {
                this.svgAnimAttributes.Remove(localname);
            }
        }

        public override XmlNode RemoveAttributeAt(int i)
        {
            XmlNode node1 = base.RemoveAttributeAt(i);
            if (node1 != null)
            {
                if (this.svgAttributes.ContainsKey(node1.Name))
                {
                    this.svgAttributes.Remove(node1.Name);
                }
                if (this.svgAnimAttributes.ContainsKey(node1.Name))
                {
                    this.svgAnimAttributes.Remove(node1.Name);
                }
            }
            return node1;
        }

        public override XmlAttribute RemoveAttributeNode(XmlAttribute oldAttr)
        {
            XmlAttribute attribute1 = base.RemoveAttributeNode(oldAttr);
            if (attribute1 != null)
            {
                if (this.svgAttributes.ContainsKey(attribute1.Name))
                {
                    this.svgAttributes.Remove(attribute1.Name);
                }
                if (this.svgAnimAttributes.ContainsKey(attribute1.Name))
                {
                    this.svgAnimAttributes.Remove(attribute1.Name);
                }
            }
            return attribute1;
        }

        public override XmlAttribute RemoveAttributeNode(string localname, string ns)
        {
            XmlAttribute attribute1 = base.RemoveAttributeNode(localname, ns);
            if (attribute1 != null)
            {
                if (this.svgAttributes.ContainsKey(attribute1.Name))
                {
                    this.svgAttributes.Remove(attribute1.Name);
                }
                if (this.svgAnimAttributes.ContainsKey(attribute1.Name))
                {
                    this.svgAnimAttributes.Remove(attribute1.Name);
                }
                if ((attribute1.Name != "d") && (attribute1.Name != "path"))
                {
                    return attribute1;
                }
                if (this is IPath)
                {
                    ((IPath) this).PointsInfo.Clear();
                }
            }
            return attribute1;
        }

        public override XmlNode RemoveChild(XmlNode oldChild)
        {
            if (oldChild == this.ownerDocument.RootElement)
            {
                if (this.ownerDocument.EditRoots.Contains((SvgElement) oldChild))
                {
                    this.ownerDocument.EditRoots.Remove((SvgElement) oldChild);
                }
                this.ownerDocument.RootElement = (SvgElement) this.ownerDocument.DocumentElement;
            }
            SvgDocument document1 = this.ownerDocument;
            bool flag1 = false;
            int num1 = this.NodeDepth;
            bool flag2 = document1.AcceptChanges;
            if ((oldChild is SvgElement) && this.FormatOutXml)
            {
                XmlNode node2;
                document1.AcceptChanges = false;
                flag1 = true;
                for (XmlNode node1 = oldChild.PreviousSibling; node1 is XmlWhitespace; node1 = node2)
                {
                    if (((XmlWhitespace) node1).Value.IndexOf("\n") >= 0)
                    {
                        base.RemoveChild(node1);
                        break;
                    }
                    node2 = node1.PreviousSibling;
                    base.RemoveChild(node1);
                }
            }
            document1.AcceptChanges = flag2;
            XmlNode node3 = oldChild.NextSibling;
            XmlNode node4 = base.RemoveChild(oldChild);
            int num2 = 0;
            if (flag1)
            {
                document1.AcceptChanges = false;
                bool flag3 = false;
                while (node3 is XmlWhitespace)
                {
                    if (num2 >= this.NodeDepth)
                    {
                        break;
                    }
                    string text2 = ((XmlWhitespace) node3).Value;
                    if (text2.IndexOf("\n") >= 0)
                    {
                        flag3 = true;
                    }
                    if (flag3)
                    {
                        num2 += text2.Length;
                    }
                    XmlNode node5 = node3.NextSibling;
                    base.RemoveChild(node3);
                    node3 = node5;
                }
            }
            document1.AcceptChanges = flag2;
            if (node4 is ItopVector.Core.Animate.Animate)
            {
                if (this.animatelist.Contains((SvgElement) node4))
                {
                    this.animatelist.Remove((SvgElement) node4);
                }
                this.svgAnimAttributes = (Hashtable) this.svgAttributes.Clone();
            }
            if ((node4 is SvgElement) && this.ownerDocument.FlowChilds.Contains((SvgElement) node4))
            {
                this.ownerDocument.RemoveFlowElement((SvgElement) node4);
            }
            return node4;
        }

        public void RemoveKey(int index)
        {
            if ((index >= 0) && (index < this.infoList.Count))
            {
                for (int num1 = 0; num1 < this.animatelist.Count; num1++)
                {
                    ItopVector.Core.Animate.Animate animate1 = (ItopVector.Core.Animate.Animate) this.animatelist[num1];
                    int num2 = this.animatelist.Count;
                    KeyInfo info1 = (KeyInfo) this.infoList[index];
                    animate1.DelKeyTime(info1.keytime);
                    num1 -= (num2 - this.animatelist.Count);
                }
                this.infoList.RemoveAt(index);
            }
        }

        public void RemoveKeyTime(int keytime)
        {
            int num1 = 0;
            for (int num2 = 0; num2 < this.infoList.Count; num2++)
            {
                KeyInfo info1 = (KeyInfo) this.infoList[num2];
                if (info1.keytime == keytime)
                {
                    num1 = num2;
                    break;
                }
            }
            this.infoList.RemoveAt(num1);
        }

        public override void SetAttribute(string name, string strvalue)
        {
            base.SetAttribute(name, strvalue);
            Point point1 = Point.Empty;
            /*
            XmlAttribute attribute1 = this.Attributes[name];
            if ((this.ownerDocument.XmlTextReader != null) && (attribute1 != null))
            {
                int num1 = this.ownerDocument.XmlTextReader.LineNumber;
                int num2 = this.ownerDocument.XmlTextReader.LinePosition;
                if (!this.AttributePos.ContainsKey(attribute1))
                {
                    this.AttributePos.Add(attribute1, new Point(num1, num2));
                }
                point1 = new Point(num1, num2);
            }
            */
            this.ParseAttribute(name, strvalue, true, point1);
        }
Esempio n. 9
0
        private IGraph CreateGraph(PointF startpoint, PointF endpoint, ToolOperation operation)
        {
            SvgDocument document1 = this.mouseAreaControl.SVGDocument;
            if (document1 == null)
            {
                return null;
            }
            bool flag1 = document1.AcceptChanges;
            document1.AcceptChanges = false;
            IGraph graph1 = this.mouseAreaControl.PicturePanel.PreGraph;
            if (graph1 == null)
            {
                return null;
            }
            IGraph graph2 = (IGraph) ((SvgElement) graph1).Clone();
            if ((operation == ToolOperation.Ellipse) && ((Control.ModifierKeys == Keys.Shift) || (Control.ModifierKeys == (Keys.Control | Keys.Shift))))
            {
                graph2 = (Circle) document1.CreateElement(document1.Prefix, "circle", document1.NamespaceURI);
                foreach (XmlAttribute attribute1 in ((SvgElement) graph1).Attributes)
                {
                    ((SvgElement) graph2).SetAttributeNode((XmlAttribute) attribute1.Clone());
                }
            }
            if (((SvgElement) graph1) is IGraphPath)
            {
                if ((((SvgElement) graph1).GetAttribute("style") != string.Empty) && (((SvgElement) graph1).GetAttribute("style") != null))
                {
                    this.mouseAreaControl.SVGDocument.AcceptChanges = false;
                    AttributeFunc.SetAttributeValue((SvgElement) graph2, "style", ((SvgElement) graph1).GetAttribute("style"));
                }
                ISvgBrush brush1 = ((IGraphPath) graph1).GraphBrush;
                if (brush1 is SvgElement)
                {
                    ISvgBrush brush2 = (ISvgBrush) ((SvgElement) brush1).Clone();
                    ((IGraphPath) graph2).GraphBrush = brush2;
                    ((SvgElement) brush2).pretime = -1;
                }
                else
                {
                    ((IGraphPath) graph2).GraphBrush = brush1;
                }
                brush1 = ((IGraphPath) graph1).GraphStroke.Brush;
                if (brush1 is SvgElement)
                {
                    ISvgBrush brush3 = (ISvgBrush) ((SvgElement) brush1).Clone();
                    ((IGraphPath) graph2).GraphStroke = new Stroke(brush3);
                    ((SvgElement) brush3).pretime = -1;
                }
                else
                {
                    ((IGraphPath) graph2).GraphStroke.Brush = brush1;
                }
            }
            if (document1 == null)
            {
                return null;
            }
            PointF point1 = this.mouseAreaControl.PicturePanel.PointToView(startpoint);
            PointF point2 = this.mouseAreaControl.PicturePanel.PointToView(endpoint);
            float single1 = this.mouseAreaControl.PicturePanel.ScaleUnit;
            SizeF ef1 = this.mouseAreaControl.PicturePanel.GridSize;
            float single2 = ef1.Height;
            float single3 = ef1.Width;
            if (this.mouseAreaControl.PicturePanel.SnapToGrid)
            {
                int num1 = (int) ((point1.X + (single3 / 2f)) / single3);
                int num2 = (int) ((point1.Y + (single2 / 2f)) / single2);
                point1 = new Point((int) (num1 * single3), (int) (num2 * single2));
                num1 = (int) ((point2.X + (single3 / 2f)) / single3);
                num2 = (int) ((point2.Y + (single2 / 2f)) / single2);
                point2 = new Point((int) (num1 * single3), (int) (single2 * num2));
            }
            float single4 = Math.Min(point1.X, point2.X);
            float single5 = Math.Min(point1.Y, point2.Y);
            float single6 = Math.Max(point1.X, point2.X);
            float single7 = Math.Max(point1.Y, point2.Y);
            float single8 = single6 - single4;
            float single9 = single7 - single5;
            switch (operation)
            {
                case ToolOperation.AngleRectangle:
                {
                    float single10 = 0f;
                    single10 = Math.Max(0, ((ItopVector.Core.Figure.RectangleElement)this.mouseAreaControl.PicturePanel.PreGraph).Angle);
                    float single11 = single10;
                    float single12 = single10;
                    if ((single8 < 5f) || (single9 < 5f))
                    {
                        return null;
                    }
                    if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                    {
                        single8 = single9 = Math.Max(single8, single9);
                        single4 = ((point1.X - point2.X) < 0) ? ((float)point1.X) : (point1.X - single8);
                        single5 = ((point1.Y - point2.Y) < 0) ? ((float)point1.Y) : (point1.Y - single9);
                    }
                    if (single11 > (single8 / 2f))
                    {
                        single11 = single8;
                    }
                    if (single12 > (single9 / 2f))
                    {
                        single12 = single9;
                    }
                    ItopVector.Core.Figure.RectangleElement rectangle1 = (ItopVector.Core.Figure.RectangleElement)graph2;
                    rectangle1.X = single4;
                    rectangle1.Y = single5;
                    rectangle1.Width = single8;
                    rectangle1.Height = single9;
                    rectangle1.RX = single11;
                    rectangle1.RY = single12;
                   // AttributeFunc.SetAttributeValue((XmlElement)rectangle1, "style", "fill:#C0C0FF;fill-opacity:0.3;stroke:#000000;stroke-opacity:1;");
                    goto Label_0F08;
                }
                case ToolOperation.InterEnclosurePrint:
                {
                    float single10 = 0f;
                    single10 = Math.Max(0, ((ItopVector.Core.Figure.RectangleElement) this.mouseAreaControl.PicturePanel.PreGraph).Angle);
                    float single11 = single10;
                    float single12 = single10;
                    if ((single8 < 5f) || (single9 < 5f))
                    {
                        return null;
                    }
                    if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                    {
                        single8 = single9 = Math.Max(single8, single9);
                        single4 = ((point1.X - point2.X) < 0) ? ((float) point1.X) : (point1.X - single8);
                        single5 = ((point1.Y - point2.Y) < 0) ? ((float) point1.Y) : (point1.Y - single9);
                    }
                    if (single11 > (single8 / 2f))
                    {
                        single11 = single8;
                    }
                    if (single12 > (single9 / 2f))
                    {
                        single12 = single9;
                    }
                    ItopVector.Core.Figure.RectangleElement rectangle1 = (ItopVector.Core.Figure.RectangleElement) graph2;
                    rectangle1.X = single4;
                    rectangle1.Y = single5;
                    rectangle1.Width = single8;
                    rectangle1.Height = single9;
                    rectangle1.RX = single11;
                    rectangle1.RY = single12;
                    AttributeFunc.SetAttributeValue((XmlElement)rectangle1, "style", "fill:#C0C0FF;fill-opacity:0.0;stroke:#000000;stroke-opacity:1;");
                    goto Label_0F08;
                }
                case ToolOperation.Circle:
                case ToolOperation.Bezier:
                case ToolOperation.Text:
                {
                    goto Label_0F08;
                }
                case ToolOperation.Ellipse:
                {
                    if ((single8 < 3f) || (single9 < 3f))
                    {
                        return null;
                    }
                    if (Control.ModifierKeys == Keys.Shift)
                    {
                        float single13 = Math.Max((float) (single6 - single4), (float) (single7 - single5)) / 2f;
                        if (single13 < 3f)
                        {
                            return null;
                        }
                        single4 = ((point1.X - point2.X) < 0) ? ((float) point1.X) : (point1.X - (2f * single13));
                        single5 = ((point1.Y - point2.Y) < 0) ? ((float) point1.Y) : (point1.Y - (2f * single13));
                        float single14 = single4 + single13;
                        float single15 = single5 + single13;
                        Circle circle1 = (Circle) graph2;
                        circle1.CX = single14;
                        circle1.CY = single15;
                        circle1.R = single13;
                        goto Label_0F08;
                    }
                    if (Control.ModifierKeys == (Keys.Control | Keys.Shift))
                    {
                        Circle circle2 = (Circle) graph2;
                        circle2.CX = point1.X;
                        circle2.CY = point1.Y;
                        float single16 = Math.Max(Math.Abs((int) (point1.Y - point2.Y)), Math.Abs((int) (point1.X - point2.X)));
                        if (single16 < 3f)
                        {
                            return null;
                        }
                        circle2.R = single16;
                        goto Label_0F08;
                    }
                    Ellips ellips1 = (Ellips) graph2;
                    if (Control.ModifierKeys == Keys.Control)
                    {
                        ellips1.CX = point1.X;
                        ellips1.CY = point1.Y;
                        ellips1.RX = Math.Abs((int) (point2.X - point1.X));
                        ellips1.RY = Math.Abs((int) (point2.Y - point1.Y));
                        goto Label_0F08;
                    }
                    ellips1.CX = single4 + (single8 / 2f);
                    ellips1.CY = single5 + (single9 / 2f);
                    ellips1.RX = single8 / 2f;
                    ellips1.RY = single9 / 2f;
                    goto Label_0F08;
                }
                case ToolOperation.Line:
                {
                    if ((single8 < 1f) && (single9 < 1f))
                    {
                        return null;
                    }
                    if ((Math.Abs((int) (point1.X - point2.X)) <= (2f * single1)) && (Math.Abs((int) (point1.Y - point2.Y)) <= (2f * single1)))
                    {
                        goto Label_0F07;
                    }
                    if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                    {
                        float single17 = (((float) Math.Atan2((double) (point2.Y - point1.Y), (double) (point2.X - point1.X))) * 180f) / 3.141593f;
                        single17 = ((int) Math.Round((double) (single17 / 45f), 0)) * 0x2d;
                        if ((single17 != 90f) && (single17 != -90f))
                        {
                            single17 = (float) Math.Tan((single17 / 180f) * 3.1415926535897931);
                            point2 = new PointF(point2.X, point1.Y + ((int) ((point2.X - point1.X) * single17)));
                            break;
                        }
                        point2 = new PointF(point1.X, point2.Y);
                    }
                    break;
                }
                case ToolOperation.ConnectLine://������
                 {
                     if (((single8 < 1f) && (single9 < 1f)) ||connectBegin==null || connectEnd==null || connectBegin==connectEnd)
                     {
                         return null;
                     }
                    ConnectLine cline =graph2 as ConnectLine;
                    cline.SetAttribute("start","#"+connectBegin.ID+"."+connectBeginIndex);

                    cline.SetAttribute("end","#"+connectEnd.ID+"."+connectEndIndex);

                    connectBegin=null;
                    connectEnd =null;

                     break;
                 }
                case ToolOperation.PolyLine:
                case ToolOperation.XPolyLine:
                case ToolOperation.YPolyLine:
                case ToolOperation.FreeLines:
                case ToolOperation.Confines_GuoJie:
                case ToolOperation.Confines_ShengJie:
                case ToolOperation.Confines_ShiJie:
                case ToolOperation.Confines_XianJie:
                case ToolOperation.Confines_XiangJie:
                case ToolOperation.Railroad:
                case ToolOperation.LeadLine:
                {
                    if (this.drawPath != null)
                    {
                        PointF[] tfArray1 = this.drawPath.PathPoints;
                        PointF[] tfArray2 = new PointF[tfArray1.Length];
                        for (int num3 = 0; num3 < tfArray1.Length; num3++)
                        {
                            PointF tf1 = this.mouseAreaControl.PicturePanel.PointToView(tfArray1[num3]);
                            tf1 = new PointF(tf1.X, tf1.Y);
                            tfArray2[num3] = tf1;
                        }
                        ((Polyline) graph2).Points = tfArray2;
                    }
                    goto Label_0F08;
                }
                case ToolOperation.Polygon:
                case ToolOperation.Enclosure:
                case ToolOperation.InterEnclosure:
                case ToolOperation.AreaPolygon:
                {
                    if (this.drawPath != null)
                    {
                        PointF[] tfArray3 = this.drawPath.PathPoints;
                        PointF[] tfArray4 = new PointF[tfArray3.Length];
                        for (int num4 = 0; num4 < tfArray3.Length; num4++)
                        {
                            PointF tf2 = this.mouseAreaControl.PicturePanel.PointToView(tfArray3[num4]);
                            tf2 = new PointF(tf2.X, tf2.Y);
                            tfArray4[num4] = tf2;
                        }
                        ((Polygon) graph2).Points = tfArray4;
                    }
                    goto Label_0F08;
                }
                case ToolOperation.EqualPolygon:
                {
                    int num5 = 3;
                    num5 = Math.Max(3, ((Polygon) this.mouseAreaControl.PicturePanel.PreGraph).LineCount);
                    double num6 = 6.2831853071795862 / ((double) num5);
                    GraphicsPath path1 = new GraphicsPath();
                    double num7 = 0;
                    double num8 = 0;
                    double num9 = Math.Sqrt(Math.Pow((double) (point1.X - point2.X), 2) + Math.Pow((double) (point1.Y - point2.Y), 2));
                    float single18 = (float) Math.Round((double) ((Polygon) this.mouseAreaControl.PicturePanel.PreGraph).Indent, 1);
                    int num10 = num5;
                    if (single18 < 1f)
                    {
                        num10 = num5 * 2;
                    }
                    PointF[] tfArray5 = new PointF[num10];
                    if (num9 < 2)
                    {
                        return null;
                    }
                    if (num9 >= 2)
                    {
                        double num11 = Math.Asin(((double) (point2.Y - point1.Y)) / num9);
                        if (point2.X < point1.X)
                        {
                            num11 = 3.1415926535897931 - num11;
                        }
                        PointF tf3 = PointF.Empty;
                        for (int num13 = 0; num13 < num10; num13 += (num10 / num5))
                        {
                            double num12 = num11 + (num6 * (num13 / (num10 / num5)));
                            num7 = num9 * Math.Cos(num12);
                            num8 = num9 * Math.Sin(num12);
                            tfArray5[num13] = new PointF((float) (point1.X + ((int) num7)), (float) (point1.Y + ((int) num8)));
                            if (num10 == (2 * num5))
                            {
                                if (!tf3.IsEmpty)
                                {
                                    PointF tf4 = new PointF((tf3.X + tfArray5[num13].X) / 2f, (tf3.Y + tfArray5[num13].Y) / 2f);
                                    tf4 = new PointF((float) (point1.X + ((int) (single18 * (tf4.X - point1.X)))), (float) (point1.Y + ((int) (single18 * (tf4.Y - point1.Y)))));
                                    tfArray5[num13 - 1] = tf4;
                                }
                                tf3 = tfArray5[num13];
                                if (num13 == ((2 * num5) - 2))
                                {
                                    PointF tf5 = new PointF((tfArray5[0].X + tfArray5[num13].X) / 2f, (tfArray5[0].Y + tfArray5[num13].Y) / 2f);
                                    tf5 = new PointF((float) (point1.X + ((int) (single18 * (tf5.X - point1.X)))), (float) (point1.Y + ((int) (single18 * (tf5.Y - point1.Y)))));
                                    tfArray5[num13 + 1] = tf5;
                                }
                            }
                        }
                        string text1 = string.Empty;
                        for (int num14 = 0; num14 < tfArray5.Length; num14++)
                        {
                            PointF tf6 = tfArray5[num14];
                            text1 = text1 + tf6.X.ToString() + " " + tf6.Y.ToString();
                            if (num14 < (tfArray5.Length - 1))
                            {
                                text1 = text1 + ",";
                            }
                        }
                        AttributeFunc.SetAttributeValue((SvgElement) graph2, "points", text1);
                    }
                    goto Label_0F08;
                }
                case ToolOperation.Image:
                {
                    graph2=null;
                    if (this.showdialog && (this.filename != string.Empty))
                    {
                        graph2 = (ItopVector.Core.Figure.Image) document1.CreateElement(document1.Prefix, "image", document1.NamespaceURI);
                        ItopVector.Core.Figure.Image image1 = (ItopVector.Core.Figure.Image) graph2;
                        image1.X = single4;
                        image1.Y = single5;
                        image1.Width = single8;
                        image1.Height = single9;
                        image1.ImageUrl = this.filename;
                    }
                    goto Label_0F08;
                }
                case ToolOperation.PreShape:
                {
                    GraphicsPath path2 = PathFunc.GetPathFromGraph(this.mouseAreaControl.PicturePanel.PreGraph);
                    single4 = point1.X;
                    single5 = point1.Y;
                    single8 = point2.X - point1.X;
                    single9 = point2.Y - point1.Y;
                    if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
                    {
                        single8 = single9 = Math.Max(single8, single9);
                        single4 = ((point1.X - point2.X) < 0) ? ((float) point1.X) : (point1.X - single9);
                        single5 = ((point1.Y - point2.Y) < 0) ? ((float) point1.Y) : (point1.Y - single8);
                    }
                    if ((Math.Abs(single8) < 2f) || (Math.Abs(single9) < 2f))
                    {
                        return null;
                    }
                    path2.Flatten(new Matrix());
                    float single19 = single4;
                    float single20 = single5;
                    RectangleF ef2 = path2.GetBounds();
                    Matrix matrix1 = new Matrix();
                    matrix1.Translate(single19 - ef2.X, single20 - ef2.Y);
                    matrix1.Translate(ef2.X, ef2.Y);
                    matrix1.Scale(single8 / ef2.Width, single9 / ef2.Height);
                    matrix1.Translate(-ef2.X, -ef2.Y);
                    Transf transf1 = new Transf();
                    transf1.setMatrix(matrix1);
                    AttributeFunc.SetAttributeValue((SvgElement) graph2, "transform", transf1.ToString());
                    goto Label_0F08;
                }
                case ToolOperation.Pie:
                case ToolOperation.Arc:
                {

                    if (!this.pieRect.IsEmpty)
                    {
                        SvgElement element9 = graph2 as SvgElement;
                        startpoint = new PointF(this.pieRect.X + (this.pieRect.Width / 2f), this.pieRect.Y + (this.pieRect.Height / 2f));
                        PointF tf7 = this.mouseAreaControl.PicturePanel.PointToView(endpoint);
                        if (tf7 == lastPoint)
                        {
                            graph2 =null;
                            goto Label_0F08;
                        }
                        endpoint = this.lastPoint;
                        float single17 = this.startArcAngle;
                        float single18 = this.endArcAngle;
                        while (single18 > 360f)
                        {
                            single18 -= 360f;
                        }
                        float single19 = this.pieRect.Width / 2f;
                        float single20 = this.pieRect.Height / 2f;
                        float single21 = startpoint.X;
                        float single22 = startpoint.Y;
                        string text4 = (((single18 - single17) > 180f) || (single18 < single17)) ? "1" : "0";
                        single17 = (float) ((single17 / 180f) * 3.1415926535897931);
                        single18 = (float) ((single18 / 180f) * 3.1415926535897931);
                        PointF tf8 = this.GetCrossPoint(this.pieRect, startpoint, endpoint);
                        float single23 = tf8.X;
                        float single24 = tf8.Y;
                        tf8 = this.GetCrossPoint(this.pieRect, startpoint, tf7);
                        float single25 = tf8.X;
                        float single26 = tf8.Y;
                        string text5 = string.Concat(new string[] {
                                                                      "M", single21.ToString(), " ", single22.ToString(), "L", single23.ToString(), " ", single24.ToString(), "A", single19.ToString(), " ", single20.ToString(), " 0 ", text4, " 1 ", single25.ToString(),
                                                                      " ", single26.ToString(), "Z"
                                                                  });
                        if (operation ==ToolOperation.Arc)
                        {
                            text5 = string.Concat(new string[] { "M", single23.ToString(), " ", single24.ToString(), "A", single19.ToString(), " ", single20.ToString(), " 0 ", text4, " 1 ", single25.ToString(), " ", single26.ToString() });
                        }
                        element9.SetAttribute("d", text5);
                        graph2 = element9 as IGraph;
                        this.pieRect = RectangleF.Empty;
                    }
                    else
                    {
                        graph2 =null;
                    }
                    goto Label_0F08;
                }
                default:
                {
                    goto Label_0F08;
                }
            }
            Label_0F07:
                Line line1 = (Line) graph2;
            line1.X1 = point1.X;
            line1.Y1 = point1.Y;
            line1.X2 = point2.X;
            line1.Y2 = point2.Y;
            Label_0F08:
                this.mouseAreaControl.SVGDocument.AcceptChanges = flag1;
            return graph2;
        }
Esempio n. 10
0
        public SvgElement AddShape(SvgElement element,Point p1)
        {
            SvgDocument document1 = this.SVGDocument;
            IGraph graph1 =(IGraph)element;
            if (graph1==null)return null;
            SvgElement newnode=null;
            if (graph1 is ConnectLine)
            {
                Point point2 = p1;

                ConnectLine connect =document1.ImportNode((SvgElement)graph1,true) as ConnectLine;

                connect.X1 += point2.X;
                connect.X2 += point2.X;
                connect.Y1 += point2.Y;
                connect.Y2 += point2.Y;
                newnode= this.drawArea1.AddElement(connect);
            }
            else if (graph1 is Symbol)
            {
                if (!document1.DefsElementContains((SvgElement) graph1))
                {
                    if((graph1 as SvgElement).ParentNode is State)
                    {
                        State state =(graph1 as SvgElement).ParentNode.Clone() as State;
                        foreach(SvgElement element1 in state.ChildList)
                        {
                            element1.Attributes.RemoveNamedItem("visibility");//ɾ�������е���������
                        }
                        document1.AddDefsElement(state);
                    }
                    else
                    {
                        document1.AddDefsElement((SvgElement) graph1);
                    }
                }
                Use use1 = (Use) document1.CreateElement(document1.Prefix, "use", document1.NamespaceURI);
                use1.GraphId = graph1.ID;
                //Point point1 = p1;
                Transf tf = new Transf();
                tf.Matrix.Translate(p1.X,p1.Y);
                use1.Transform = tf;
                use1.GraphBrush = this.drawArea1.FillBrush.Clone();
                use1.GraphStroke = this.drawArea1.Stroke.Clone() as Stroke;
                newnode =this.drawArea1.AddElement(use1);
            }
            else
            {
                newnode =this.drawArea1.AddElement(element);
            }
            return newnode;
        }
Esempio n. 11
0
        private void checkEdit2_CheckedChanged(object sender, EventArgs e)
        {
            if (checkEdit2.Checked == true)
            {
                XmlNodeList nn0 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@dhx_key='2']");
                for (int i = 0; i < nn0.Count; i++)
                {
                    XmlElement x = (XmlElement)nn0[i];
                    x.SetAttribute("visibility", "visible");
                }
                XmlNodeList nn1 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@dhx_key='1']");
                for (int i = 0; i < nn1.Count; i++)
                {
                    Polyline p = ((Polyline)nn1[i]).Clone() as Polyline;

                    XmlNodeList _n = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@dhx_copy='" + p.ID + "']");
                    if (_n.Count > 0) continue;

                    PointF[] pn = p.Points;
                    p.Transform.Matrix.TransformPoints(pn);
                    double angA = TLMath.Angle(pn[1], pn[0], pn[2]);
                    double ang = TLMath.Angle(pn[1], new PointF(pn[1].X - 10, pn[1].Y), pn[2]);
                    double ang2 = TLMath.Angle(pn[1], new PointF(pn[1].X - 10, pn[1].Y), pn[0]);
                    double ango = (ang - ang2);
                    double C = Math.Abs(50 / (Math.Sin(ango / 2)));
                    double A = 50;
                    double B = Math.Abs(50 / (Math.Tan(ango / 2)));
                    //y3=(x3-x2)(y1-y2)/(x1-x2)+y2
                    double x2 = pn[1].X - B;
                    float fy = Convert.ToSingle((x2 - pn[1].X) * (pn[0].Y - pn[1].Y) / (pn[0].X - pn[1].X) + pn[1].Y);
                    PointF p2 = new PointF(Convert.ToSingle(x2), fy);
                    double X = 0;
                    double Y = 0;
                    if (ang2 * 57.3 > 180)
                    {
                        Y = Math.Sin((180 - ang2 * 180 / Math.PI - 180 - ango / 2 * 180 / Math.PI) * (Math.PI / 180)) * A;
                    }
                    else
                    {
                        Y = Math.Sin((180 - ang2 * 180 / Math.PI - ango / 2 * 180 / Math.PI) * (Math.PI / 180)) * A;
                    }
                    X = Math.Cos((180 - ang2 * 180 / Math.PI - ango / 2 * 180 / Math.PI) * (Math.PI / 180)) * A;
                    //double ang2 = TLMath.getLineAngle(new PointF(0,0), p2, pn[1]);
                    //double X = p2.X + A * Math.Cos((ang2 * 57.3 - 90) / 57.3);
                    //double Y = p2.Y + A * Math.Sin((ang2 * 57.3 - 90) / 57.3);

                    //PointF[] pnf = TLMath.getPoint3(pn[1],p2, A, B, C);
                    //PointF pp = TLMath.getPoint3(p2, pn[1], 90 *(Math.PI/180), ang / 2);

                    //XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as XmlElement;
                    //e1.SetAttribute("points", "0 0,10 10,"+X.ToString()+" "+Y.ToString());
                    //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);

                    ItopVector.Core.Types.Transf transf = new ItopVector.Core.Types.Transf(p.Transform.Matrix);
                    double a = (ang2 + (angA / 2)) * 180 / Math.PI;
                    if (((ang2 + (angA / 2)) * 180 / Math.PI) < 180)
                    {
                        transf.setTranslate((float)X, -(float)Y);
                    }
                    else
                    {
                        transf.setTranslate((float)X, (float)Y);
                    }
                    p.Transform = transf;
                    p.SetAttribute("dhx_key", "2");
                    p.SetAttribute("dhx_copy", p.ID);
                    tlVectorControl1.SVGDocument.RootElement.AppendChild(p);
                }
                tlVectorControl1.Refresh();
            }
            if ((checkEdit2.Checked == false))
            {
                XmlNodeList nn1 = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline [@IsLead='1'] [@dhx_key='2']");
                for (int i = 0; i < nn1.Count; i++)
                {
                    XmlElement x = (XmlElement)nn1[i];
                    x.SetAttribute("visibility", "hidden");
                }
                tlVectorControl1.Refresh();
            }
        }
Esempio n. 12
0
        /*public void ResetPoly()
        {
            SvgElementCollection col= tlVectorControl1.SVGDocument.SelectCollection;
            if(col.Count<1){
                return;
            }
            SvgElementCollection.ISvgElementEnumerator enumerator1 = tlVectorControl1.DrawArea.ElementList.GetEnumerator();
            foreach(SvgElement ele in col){
                if (ele.GetType().ToString() == "ItopVector.Core.Figure.Polygon")
                {
                    glebeProperty p=new glebeProperty();
                    p.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    p.EleID = ((IGraph)ele).ID;
                    p = Services.BaseService.GetObject("SelectglebePropertyByEleID", p);
                    if(p!=null){
                        PointF[] tfArray1 = TLMath.getPolygonPoints(ele);
                        GraphicsPath selectAreaPath = new GraphicsPath();
                        selectAreaPath.AddLines(tfArray1);
                        selectAreaPath.CloseFigure();
                        Region region1 = new Region(selectAreaPath);
                        while (enumerator1.MoveNext())
                        {
                            IGraph graph1 = (IGraph)enumerator1.Current;
                            GraphicsPath path1 = (GraphicsPath)graph1.GPath.Clone();
                            path1.Transform(graph1.GraphTransform.Matrix);
                            Region region2 = new Region(path1);
                            region2.Intersect(region1);
                            if (!region2.GetBounds(Graphics.FromHwnd(IntPtr.Zero)).IsEmpty)
                            {
                                glebeProperty p1 = new glebeProperty();
                                p1.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                                p1.EleID = graph1.ID;
                                p1 = Services.BaseService.GetObject("SelectglebePropertyByEleID", p1);
                                if(p1!=null){
                                    p1.ParentEleID = p.UID;
                                    Services.BaseService.Update("UpdateglebePropertyAreaAll", p1);
                                }
                            }
                        }
                    }
                }
            }
            MessageBox.Show("更新完成。","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }*/
        private void contextMenuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try {
                if (e.ClickedItem.Text == "可靠性分析") {
                    XmlElement xml1 = (XmlElement)tlVectorControl1.SVGDocument.CurrentElement;
                    if (tlVectorControl1.SVGDocument.CurrentElement.GetType().ToString() == "ItopVector.Core.Figure.Polyline") {
                        string deviceid = xml1.GetAttribute("Deviceid");
                        if (!string.IsNullOrEmpty(deviceid)) {
                            DeviceHelper.uid = tlVectorControl1.SVGDocument.SvgdataUid;
                            DeviceHelper.layerid = tlVectorControl1.SVGDocument.CurrentLayer.ID;
                            DeviceHelper.eleid = tlVectorControl1.SVGDocument.CurrentElement.ID;

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

                        }
                    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                        }

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

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

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

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

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

                            }
                        }

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

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

                            y = ((Use)xml1).Y;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            }
                        }

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

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

                            x = ((Use)xml1).X;

                            y = ((Use)xml1).Y;

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

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

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

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

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

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

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

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

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

                                }

                            }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    SvgDocument _doc = new SvgDocument();

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

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

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

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

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

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

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

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

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

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

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

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

            } catch (Exception e1) {
                //MessageBox.Show(e1.Message);
            }
            if (e.ClickedItem.Text == "三维变电站") {
                try {
                    string strid = tlVectorControl1.SVGDocument.CurrentElement.ID;
                    substation s = new substation();
                    s.EleID = strid;
                    s.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid;
                    s = (substation)Services.BaseService.GetObject("SelectsubstationByEleID", s);
                    ProcessStartInfo p = new ProcessStartInfo();
                    p.FileName = Application.StartupPath + "\\" + s.EleName + "\\bdz.exe";
                    p.WorkingDirectory = Application.StartupPath + "\\" + s.EleName;
                    Process.Start(p);
                } catch (Exception e1) { }
            }
            if (e.ClickedItem.Text == "清除关联") {
                ((XmlElement)tlVectorControl1.SVGDocument.CurrentElement).RemoveAttribute("Deviceid");
            }
            if (e.ClickedItem.Text == "更新关联变电站") {
                UpdateLine();
            }
            if (e.ClickedItem.Text == "删除") {
                Delete();
            }
        }
Esempio n. 13
0
 private int Break(SvgElement graph, SvgElement parent, XmlNode next)
 {
     if (graph is Group)
     {
         if (graph is Text)
         {
             Graphics graphics1 = base.CreateGraphics();
             SvgElementCollection collection1 = ((Text) graph).Break(graphics1);
             graphics1.Dispose();
             SvgElementCollection.ISvgElementEnumerator enumerator1 = collection1.GetEnumerator();
             while (enumerator1.MoveNext())
             {
                 SvgElement element1 = (SvgElement) enumerator1.Current;
                 this.svgDocument.NumberOfUndoOperations++;
                 element1.ID = CodeFunc.CreateString(this.svgDocument, "text");
                 ISvgBrush brush1 = ((IGraphPath) element1).GraphBrush;
                 if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null))
                 {
                     string text1 = CodeFunc.CreateString(this.svgDocument, ((SvgElement) brush1).Name);
                     AttributeFunc.SetAttributeValue(element1, "fill", "url(#" + text1 + ")");
                     AttributeFunc.SetAttributeValue((SvgElement) brush1, "id", text1);
                     this.svgDocument.NumberOfUndoOperations++;
                     this.SVGDocument.AddDefsElement((SvgElement) brush1);
                 }
                 brush1 = ((IGraphPath) element1).GraphStroke.Brush;
                 if ((brush1 is ITransformBrush) && (((SvgElement) brush1).ParentNode == null))
                 {
                     string text2 = CodeFunc.CreateString(this.svgDocument, ((SvgElement) brush1).Name);
                     AttributeFunc.SetAttributeValue(element1, "stroke", "url(#" + text2 + ")");
                     AttributeFunc.SetAttributeValue((SvgElement) brush1, "id", text2);
                     this.svgDocument.NumberOfUndoOperations++;
                     this.SVGDocument.AddDefsElement((SvgElement) brush1);
                 }
                 if (next == null)
                 {
                     parent.AppendChild(element1);
                     continue;
                 }
                 parent.InsertBefore(element1, next);
             }
             this.svgDocument.NumberOfUndoOperations++;
             graph.ParentNode.RemoveChild(graph);
         }
         else
         {
             SvgElementCollection collection2 = ((Group) graph).GraphList.Clone();
             for (int num1 = collection2.Count - 1; num1 >= 0; num1--)
             {
                 SvgElement element2 = (SvgElement) collection2[num1];
                 Matrix matrix1 = new Matrix();
                 Matrix matrix2 = new Matrix();
                 if (element2 is IGraph)
                 {
                     if (graph.SvgAttributes.ContainsKey("transform"))
                     {
                         matrix1 = ((Matrix) graph.SvgAttributes["transform"]).Clone();
                     }
                     if (element2.SvgAttributes.ContainsKey("transform"))
                     {
                         matrix2 = ((Matrix) graph.SvgAttributes["transform"]).Clone();
                     }
                     matrix1.Multiply(matrix2);
                     Transf transf1 = new Transf();
                     transf1.setMatrix(matrix1);
                     AttributeFunc.SetAttributeValue(element2, "transform", transf1.ToString());
                 }
                 this.Break(element2, parent, next);
             }
             graph.ParentNode.RemoveChild(graph);
         }
         return 1;
     }
     if ((graph is IGraph) && (graph.ParentNode != parent))
     {
         this.svgDocument.NumberOfUndoOperations += 2;
         if (next != null)
         {
             parent.InsertBefore(graph.Clone(), next);
         }
         else
         {
             parent.PrependChild(graph.Clone());
         }
         return 0;
     }
     return 0;
 }
Esempio n. 14
0
        public void OnMouseUp(MouseEventArgs e)
        {
            if ((this.activeGraph == null) || (this.mouseAreaControl.Cursor == this.mouseAreaControl.DefaultCursor))
            {
                return;
            }
            if (e.Button != MouseButtons.Left)
            {
                return;
            }
            if (!(this.mouseAreaControl.SVGDocument.CurrentElement is ITransformBrush))
            {
                return;
            }
            ISvgBrush brush1 = (ISvgBrush) this.mouseAreaControl.SVGDocument.CurrentElement;
            if (brush1 is SolidColor)
            {
                return;
            }
            SizeF ef1 = this.mouseAreaControl.PicturePanel.GridSize;
            float single1 = ef1.Width;
            float single2 = ef1.Height;
            this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle);
            this.win32.W32SetROP2(6);
            this.win32.W32PolyDraw(this.reversePath);
            this.win32.ReleaseDC();
            float single3 = this.mouseAreaControl.PicturePanel.ScaleUnit;
            PointF tf1 = this.mouseAreaControl.PicturePanel.PointToView(this.startPoint);
            PointF tf2 = this.mouseAreaControl.PicturePanel.PointToView(new PointF((float) e.X, (float) e.Y));
            if (this.mouseAreaControl.PicturePanel.SnapToGrid)
            {
                int num1 = (int) ((tf1.X + (single1 / 2f)) / single1);
                int num2 = (int) ((tf1.Y + (single2 / 2f)) / single2);
                tf1 = (PointF) new Point((int) (num1 * single1), (int) (num2 * single2));
                num1 = (int) ((tf2.X + (single1 / 2f)) / single1);
                num2 = (int) ((tf2.Y + (single2 / 2f)) / single2);
                tf2 = (PointF) new Point((int) (num1 * single1), (int) (single2 * num2));
            }
            tf1 = this.mouseAreaControl.PicturePanel.PointToSystem(tf1);
            tf2 = this.mouseAreaControl.PicturePanel.PointToSystem(tf2);
            this.win32.hdc = this.win32.W32GetDC(this.mouseAreaControl.Handle);
            this.win32.W32SetROP2(6);
            this.win32.W32PolyDraw(this.reversePath);
            this.win32.ReleaseDC();
            Transf transf1 = new Transf();
            transf1 = ((ITransformBrush) brush1).Transform;
            SvgElement element1 = (SvgElement) brush1;
            ITransformBrush brush2 = (ITransformBrush) brush1;
            bool flag1 = brush2.Units == Units.UserSpaceOnUse;
            SvgDocument document1 = this.mouseAreaControl.SVGDocument;
            if (((((this.mouseAreaControl.Cursor == SpecialCursors.VScaleCursor) | (this.mouseAreaControl.Cursor == SpecialCursors.HScaleCursor)) | (this.mouseAreaControl.Cursor == SpecialCursors.TopRightScaleCursor)) | (this.mouseAreaControl.Cursor == SpecialCursors.EqualScaleCursor)) && (this.controlPoints.Length >= 6))
            {
                //string text11;
                PointF[] tfArray5 = new PointF[5] { tf1, tf2, this.controlPoints[0], this.controlPoints[1], this.controlPoints[5] } ;
                PointF[] tfArray1 = tfArray5;
                Matrix matrix1 = this.graphMatrix.Clone();
                matrix1.Multiply(this.gradientMatrix);
                matrix1.Invert();
                matrix1.TransformPoints(tfArray1);
                float single4 = 1f;
                if (tfArray1[3].X != tfArray1[2].X)
                {
                    single4 = 1f + ((tfArray1[1].X - tfArray1[0].X) / (tfArray1[3].X - tfArray1[2].X));
                }
                float single5 = 1f;
                if (tfArray1[4].Y != tfArray1[2].Y)
                {
                    single5 = 1f + ((tfArray1[1].Y - tfArray1[0].Y) / (tfArray1[4].Y - tfArray1[2].Y));
                }
                if (this.mouseAreaControl.Cursor == SpecialCursors.VScaleCursor)
                {
                    single5 = 1f;
                }
                else if (this.mouseAreaControl.Cursor == SpecialCursors.HScaleCursor)
                {
                    single4 = 1f;
                }
                else if (this.mouseAreaControl.Cursor == SpecialCursors.EqualScaleCursor)
                {
                    single5 = single4;
                }
                if ((element1.InfoList.Count == 1))
                {
                    if (flag1)
                    {
                        transf1.setTranslate(this.centerPoint.X, this.centerPoint.Y);
                    }
                    else
                    {
                        transf1.setTranslate(0.5f, 0.5f);
                    }
                    transf1.setScale(single4, single5);
                    if (flag1)
                    {
                        transf1.setTranslate(-this.centerPoint.X, -this.centerPoint.Y);
                    }
                    else
                    {
                        transf1.setTranslate(-0.5f, -0.5f);
                    }
                    string text1 = transf1.ToString();
                    string text2 = "gradientTransform";
                    if (brush2 is Pattern)
                    {
                        text2 = "patternTransform";
                    }
                    bool flag2 = document1.AcceptChanges;
                    document1.AcceptChanges = true;
                    document1.NumberOfUndoOperations = 1;
                    AttributeFunc.SetAttributeValue(element1, text2, text1);
                    document1.AcceptChanges = flag2;
                    element1.pretime = -1;
                    goto Label_1771;
                }

            }
            if ((this.mouseAreaControl.Cursor == SpecialCursors.SkewXCursor) || (this.mouseAreaControl.Cursor == SpecialCursors.SkewYCursor))
            {
                //string text16;
                PointF[] tfArray6 = new PointF[5] { tf1, tf2, this.controlPoints[0], this.controlPoints[3], this.controlPoints[4] } ;
                PointF[] tfArray2 = tfArray6;
                Matrix matrix2 = this.graphMatrix.Clone();
                matrix2.Multiply(this.gradientMatrix);
                matrix2.Invert();
                matrix2.TransformPoints(tfArray2);
                float single6 = 0f;
                if (tfArray2[3].Y != tfArray2[2].Y)
                {
                    single6 = ((tfArray2[1].X - tfArray2[0].X) / (tfArray2[3].Y - tfArray2[2].Y)) * 0.5f;
                }
                float single7 = 0f;
                if (tfArray2[4].X != tfArray2[2].X)
                {
                    single7 = ((tfArray2[1].Y - tfArray2[0].Y) / (tfArray2[4].X - tfArray2[2].X)) * 0.5f;
                }
                if (this.mouseAreaControl.Cursor == SpecialCursors.SkewXCursor)
                {
                    single7 = 0f;
                }
                else if (this.mouseAreaControl.Cursor == SpecialCursors.SkewYCursor)
                {
                    single6 = 0f;
                }
                if ( (element1.InfoList.Count == 1))
                {
                    if (flag1)
                    {
                        transf1.setTranslate(this.centerPoint.X, this.centerPoint.Y);
                    }
                    else
                    {
                        transf1.setTranslate(0.5f, 0.5f);
                    }
                    transf1.Matrix.Shear(single6, single7);
                    if (flag1)
                    {
                        transf1.setTranslate(-this.centerPoint.X, -this.centerPoint.Y);
                    }
                    else
                    {
                        transf1.setTranslate(-0.5f, -0.5f);
                    }
                    string text3 = transf1.ToString();
                    string text4 = "gradientTransform";
                    if (brush2 is Pattern)
                    {
                        text4 = "patternTransform";
                    }
                    bool flag4 = document1.AcceptChanges;
                    document1.AcceptChanges = true;
                    document1.NumberOfUndoOperations = 1;
                    AttributeFunc.SetAttributeValue(element1, text4, text3);
                    document1.AcceptChanges = flag4;
                    element1.pretime = -1;
                    goto Label_1771;
                }

            }
            if (this.mouseAreaControl.Cursor == SpecialCursors.RotateCursor)
            {
                //string text19;
                PointF tf3 = this.controlPoints[0];
                float single8 = (float) Math.Atan((double) ((tf1.Y - tf3.Y) / (tf1.X - tf3.X)));
                float single9 = (float) Math.Atan((double) ((tf2.Y - tf3.Y) / (tf2.X - tf3.X)));
                float single10 = ((float) (((double) (single9 - single8)) / 3.1415926535897931)) * 180f;
                if (((tf2.X - tf3.X) * (tf1.X - tf3.X)) < 0f)
                {
                    single10 += 180f;
                }
                if (single10 < 0f)
                {
                    single10 += 360f;
                }
                PointF[] tfArray7 = new PointF[1] { new PointF(0.5f, 0.5f) } ;
                PointF[] tfArray3 = tfArray7;
                if (flag1)
                {
                    PointF[] tfArray8 = new PointF[1] { this.centerPoint } ;
                    tfArray3 = tfArray8;
                }
                this.gradientMatrix.TransformPoints(tfArray3);
                if ( (element1.InfoList.Count == 1))
                {
                    transf1.Matrix.RotateAt(single10, tfArray3[0], MatrixOrder.Append);
                    string text5 = transf1.ToString();
                    string text6 = "gradientTransform";
                    if (brush2 is Pattern)
                    {
                        text6 = "patternTransform";
                    }
                    bool flag6 = document1.AcceptChanges;
                    document1.AcceptChanges = true;
                    AttributeFunc.SetAttributeValue(element1, text6, text5);
                    document1.AcceptChanges = flag6;
                    element1.pretime = -1;
                    goto Label_1771;
                }

            }
            else if (this.mouseAreaControl.Cursor == SpecialCursors.GradientTranslateCursor)
            {
                PointF[] tfArray9 = new PointF[5] { tf1, tf2, this.controlPoints[0], this.controlPoints[1], this.controlPoints[4] } ;
                PointF[] tfArray4 = tfArray9;
                Matrix matrix3 = this.graphMatrix.Clone();
                matrix3.Multiply(this.gradientMatrix);
                matrix3.Invert();
                matrix3.TransformPoints(tfArray4);
                float single11 = tfArray4[1].X - tfArray4[0].X;
                if (!flag1)
                {
                    single11 /= (tfArray4[3].X - tfArray4[2].X);
                }
                else
                {
                    single11 *= 2f;
                }
                float single12 = tfArray4[1].Y - tfArray4[0].Y;
                if (!flag1)
                {
                    single12 /= (tfArray4[4].Y - tfArray4[2].Y);
                }
                else
                {
                    single12 *= 2f;
                }
                single11 /= 2f;
                single12 /= 2f;
                if (element1.InfoList.Count == 1)
                {
                    transf1.setTranslate(single11, single12);
                    string text7 = transf1.ToString();
                    string text8 = "gradientTransform";
                    if (brush2 is Pattern)
                    {
                        text8 = "patternTransform";
                    }
                    bool flag7 = document1.AcceptChanges;
                    document1.AcceptChanges = true;
                    AttributeFunc.SetAttributeValue(element1, text8, text7);
                    document1.AcceptChanges = flag7;
                    element1.pretime = -1;
                }

            }
            Label_1771:
            this.mouseAreaControl.Invalidate();
        }
Esempio n. 15
0
 public void UnGroup2(ItopVector.Core.Figure.Group group)
 {
     if (group.ParentNode is ItopVector.Core.Figure.Group)
     {
         string LayerID=group.GetAttribute("layer");
         XmlNode node1 = group.PreviousSibling;
         while (!(node1 is SvgElement) && (node1 != null))
         {
             node1 = node1.PreviousSibling;
         }
         SvgElementCollection collection1 = group.GraphList;
         SvgDocument document1 = this.SVGDocument;
         document1.NumberOfUndoOperations += ((2*collection1.Count) + 500);
         ItopVector.Core.Figure.Group group1 = (ItopVector.Core.Figure.Group) group.ParentNode;
         Matrix matrix1 = group.Transform.Matrix.Clone();
         for (int num1 = collection1.Count - 1; num1 >= 0; num1--)
         {
             SvgElement element1 = (SvgElement) collection1[num1];
             if (element1 is IGraph)
             {
                 Matrix matrix2 = new Matrix();
                 if (element1.SvgAttributes.ContainsKey("transform"))
                 {
                     matrix2 = ((Matrix) element1.SvgAttributes["transform"]).Clone();
                 }
                 matrix2.Multiply(matrix1, MatrixOrder.Append);
                 Transf transf1 = new Transf();
                 transf1.setMatrix(matrix2);
                 string text1 = transf1.ToString();
                 AttributeFunc.SetAttributeValue(element1, "transform", text1);
     //						AttributeFunc.SetAttributeValue(element1, "layer", LayerID);
             }
             element1.AllowRename =false;
             if (node1 != null)
             {
                 group1.InsertAfter(element1, node1);
             }
             else
             {
                 group1.PrependChild(element1);
             }
             element1.AllowRename =true;
         }
         group1.RemoveChild(group);
         this.SVGDocument.NotifyUndo();
     }
 }
Esempio n. 16
0
 public SvgElement CreateBySymbolID(string symbolID,PointF p1)
 {
     string id = symbolID;
     XmlNode node =null;
     if (this.SymbolSelector!=null)
         node = this.SymbolSelector.SymbolDoc.SelectSingleNode("//*[@id='"+id+"']");
     if (node ==null)
         throw new ApplicationException("��Ч��ͼԪid: '"+id+"'");
     IGraph graph1= node as IGraph;
     IGraph graph2 =null;
     if (graph1 is ConnectLine)
     {
         ConnectLine connect =svgDocument.ImportNode((SvgElement)graph1,true) as ConnectLine;
         graph2 = connect;
     }
     else if (graph1 is Symbol)
     {
         if (!svgDocument.DefsElementContains((SvgElement) graph1))
         {
             if((graph1 as SvgElement).ParentNode is State)
             {
                 State state =(graph1 as SvgElement).ParentNode.Clone() as State;
                 foreach(SvgElement element1 in state.ChildList)
                 {
                     element1.Attributes.RemoveNamedItem("visibility");//ɾ�������е���������
                 }
                 svgDocument.AddDefsElement(state);
             }
             else
             {
                 svgDocument.AddDefsElement((SvgElement) graph1);
             }
         }
         Use use1 = (Use)svgDocument.CreateElement(svgDocument.Prefix, "use", svgDocument.NamespaceURI);
         use1.GraphId =symbolID;
         PointF point1 = p1;
         RectangleF ef1 = graph1.GPath.GetBounds();
         float X = (point1.X - ef1.X) - (ef1.Width / 2f);
         float Y = (point1.Y - ef1.Y) - (ef1.Height / 2f);
         Transf tf = new Transf();
         tf.Matrix.Translate(X, Y);
         use1.Transform = tf;
         graph2 = use1;
     }
     else
     {
         graph2 =this.svgDocument.ImportNode((SvgElement)graph1,true) as IGraph;
     }
     return graph2 as SvgElement;
 }
Esempio n. 17
0
        private void MouseAreaControl_DragDrop(object sender, DragEventArgs e)
        {
            object obj1 = e.Data.GetData("SvgElement");
            if (obj1 is IGraph)
            {
                if (BeforeDragDrop!=null)
                    BeforeDragDrop(obj1,e);
                if (e.Effect == DragDropEffects.None)return;

                IGraph graph1 = (IGraph) obj1;
                if (graph1 == this.SVGDocument.RootElement)
                {
                    MessageBox.Show("���ܽ�����Ӧ�õ������");
                }

                else
                {
                    SvgDocument document1 = this.SVGDocument;
                    if (graph1 is ConnectLine)
                    {
                        Point point2 = this.picturePanel.PointToView(base.PointToClient(new Point(e.X, e.Y)));

                        ConnectLine connect =document1.ImportNode((SvgElement)graph1,true) as ConnectLine;

                        #region delete
                        //						ConnectLine connect =document1.CreateElement("tonli","connectline",SvgDocument.TonliNamespace) as ConnectLine;
                        //
                        //						foreach(XmlAttribute attribute in (graph1 as SvgElement).Attributes )
                        //						{
                        //							if(attribute.LocalName!="id" && attribute.LocalName !="tonli")
                        //							{
                        //								AttributeFunc.SetAttributeValue(connect,attribute.LocalName,attribute.Value);
                        //							}
                        //						}
                        #endregion

                        connect.X1 += point2.X;
                        connect.X2 += point2.X;
                        connect.Y1 += point2.Y;
                        connect.Y2 += point2.Y;
                        this.picturePanel.AddElement(connect);

                    }
                    else
                    {
                        IGraph graph2;
                        if (!document1.DefsElementContains((SvgElement) graph1,out graph2))
                        {
                            if((graph1 as SvgElement).ParentNode is State)
                            {
                                State state =(graph1 as SvgElement).ParentNode.Clone() as State;
                                foreach(SvgElement element1 in state.ChildList)
                                {
                                    element1.Attributes.RemoveNamedItem("visibility");//ɾ�������е���������
                                }
                                document1.AddDefsElement(state);
                            }
                            else
                            {
                                graph2 = document1.AddDefsElement((SvgElement) graph1) as IGraph;
                            }
                        }
                        if (graph2!=null)graph1=graph2;
                        Use use1 = (Use) document1.CreateElement(document1.Prefix, "use", document1.NamespaceURI);
                        use1.GraphId = graph1.ID;
                        Point point1 = this.picturePanel.PointToView(base.PointToClient(new Point(e.X, e.Y)));
                        RectangleF ef1 = graph1.GPath.GetBounds(graph1.Transform.Matrix);
                        float X = (point1.X - ef1.X) - (ef1.Width/2f);
                        float Y = (point1.Y - ef1.Y) - (ef1.Height/2f);
                        Transf tf = new Transf();
                        tf.Matrix.Translate(X, Y);
                        use1.Transform = tf;

                        use1.GraphBrush = this.picturePanel.FillBrush.Clone();
                        use1.GraphStroke = this.picturePanel.Stroke.Clone() as Stroke;
                        this.picturePanel.AddElement(use1);
                        if (OnAddElement!=null)
                        {
                            AddSvgElementEventArgs eTemp = new AddSvgElementEventArgs(use1);
                            OnAddElement(use1,eTemp);
                        }
            //						this.picturePanel.InvalidateElement(use1);
                    }
                }
                if(DragAndDrop!=null)
                {
                    DragAndDrop(graph1,e);
                }
            }
        }
Esempio n. 18
0
 public void UpdateChild(XmlNode node)
 {
     if (node is IGraph)
     {
         IGraph graph1 = (IGraph) node;
         SvgDocument document1 = base.OwnerDocument;
         bool flag1 = document1.AcceptChanges;
         document1.AcceptChanges = false;
         if (!this.RefMatrix.IsIdentity)
         {
             Matrix matrix1 = this.RefMatrix.Clone();
             matrix1.Invert();
             Transf transf1 = new Transf();
             transf1.setMatrix(matrix1);
             graph1.Transform = transf1;
         }
         document1.AcceptChanges = flag1;
     }
 }