private Layer CopyLayer(Layer layer) { Layer layer2 = Layer.CreateNew(layer.Label + " ����", this.SymbolDoc); //foreach (SvgElement g in layer.GraphList) //{ // layer2.GraphList.Add(g); //} this.SymbolDoc.NumberOfUndoOperations = (2 * layer2.GraphList.Count) + 200; SvgElementCollection sc = layer.GraphList; for (int i = layer.GraphList.Count - 1; i >= 0; i--) { SvgElement element = sc[i] as SvgElement; SvgElement temp = element.Clone() as SvgElement; //if (temp.Name=="use"){ if (temp.GetAttribute("CopyOf") == "") { temp.SetAttribute("CopyOf", temp.ID); } IGraph graph = (IGraph)layer2.AddElement(temp); graph.Layer = layer2; LineInfo _line = new LineInfo(); _line.EleID = element.ID; _line.SvgUID = this.SymbolDoc.SvgdataUid; IList lineInfoList = Services.BaseService.GetList("SelectLineInfoByEleID", _line); foreach (LineInfo line in lineInfoList) { line.UID = Guid.NewGuid().ToString(); line.LayerID = layer2.ID; line.EleID = temp.ID; Services.BaseService.Create<LineInfo>(line); } glebeProperty gle = new glebeProperty(); gle.EleID = element.ID; gle.SvgUID = this.SymbolDoc.SvgdataUid; IList gleProList = Services.BaseService.GetList("SelectglebePropertyByEleID", gle); foreach (glebeProperty gleP in gleProList) { gleP.UID = Guid.NewGuid().ToString(); gleP.LayerID = layer2.ID; gleP.EleID = temp.ID; Services.BaseService.Create<glebeProperty>(gleP); } substation _sub = new substation(); _sub.EleID = element.ID; _sub.SvgUID = this.SymbolDoc.SvgdataUid; IList substationList = Services.BaseService.GetList("SelectsubstationByEleID", _sub); foreach (substation sub in substationList) { sub.UID = Guid.NewGuid().ToString(); sub.LayerID = layer2.ID; sub.EleID = temp.ID; Services.BaseService.Create<substation>(sub); } } this.SymbolDoc.NotifyUndo(); return layer2; }
/// <summary> /// ������ر��վͼ������� /// </summary> /// <param name="layer"></param> void createBdzInfo(Layer layer) { if (layer == null) layer = tlVectorControl1.SVGDocument.CurrentLayer; if (layer == null) return; if (!layer.Label.Contains("���վ")) return; string name = layer.Label + "��������"; string name2 = layer.Label + "��������"; Layer lay1 = null; Layer lay2 = null; foreach (Layer lay in tlVectorControl1.SVGDocument.Layers) { if (lay.Label == name) lay1 = lay; else if (lay.Label == name2) lay2 = lay; } //tlVectorControl1.SVGDocument.AcceptChanges = false; if (lay1 == null) { lay1 = Layer.CreateNew(name, tlVectorControl1.SVGDocument); lay1.SetAttribute("layerType", "�����滮��"); lay1.SetAttribute("ParentID", SaveID[0].ToString()); frmlar.AddLayer(lay1, true); } else { for (int i = lay1.GraphList.Count - 1; i > 0; i--) lay1.GraphList.RemoveAt(i); } if (lay2 == null) { lay2 = Layer.CreateNew(name2, tlVectorControl1.SVGDocument); lay2.SetAttribute("layerType", "�����滮��"); lay2.SetAttribute("ParentID", SaveID[0].ToString()); frmlar.AddLayer(lay2, true); } else { for (int i = lay2.GraphList.Count - 1; i > 0; i--) lay2.GraphList.RemoveAt(i); } foreach (SvgElement ele in layer.GraphList) { if (!(ele is Use)) continue; PSP_Substation_Info bdz = Services.BaseService.GetOneByKey<PSP_Substation_Info>(ele.GetAttribute("Deviceid")); if (bdz == null) continue; createName(ele as IGraph, lay1, bdz.Title); createName2(ele as IGraph, lay2, "(" + bdz.L4 + ")");//������� } //tlVectorControl1.SVGDocument.AcceptChanges = true; lay1.Visible = false; lay2.Visible = false; frmlar.SymbolDoc = tlVectorControl1.SVGDocument; //frmlar.InitData(); tlVectorControl1.Refresh(); }
void frmlar_OnClickLayer(object sender, Layer lar) { tlVectorControl1.SVGDocument.SelectCollection.Clear(); ArrayList a = tlVectorControl1.SVGDocument.getLayerList(); SvgDocument.currentLayer = lar.ID; }
void frmlar_OnClickLayer(object sender, Layer lar) { //tlVectorControl1.SVGDocument.SelectCollection.Clear(); ArrayList a = tlVectorControl1.SVGDocument.getLayerList(); SvgDocument.currentLayer = lar.ID; //tlVectorControl1.SVGDocument.CurrentElement = null; string larid = lar.ID; if (!ChangeLayerList.Contains(larid)) { ChangeLayerList.Add(larid); } if (lar.GetAttribute("layerType") == progtype) { tlVectorControl1.CanEdit = true; if (progtype == "地理信息层") { DlBarVisible(true); } if (progtype == "城市规划层") { DkBarVisible(true); } if (progtype == "电网规划层") { DwBarVisible(true); } } else { tlVectorControl1.CanEdit = false; if (progtype == "地理信息层") { DlBarVisible(false); } if (progtype == "城市规划层") { DkBarVisible(false); } if (progtype == "电网规划层") { DwBarVisible(false); } } if (lar.GetAttribute("layerType") == "所内接线图") { JxtBar(); return; } }
private void DeleteLayer(Layer layer) { //if (!CkRight(layer)) //{ // MessageBox.Show("基础图层不能改名或删除。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} //if (true) //{ // LineInfo _line = new LineInfo(); // _line.LayerID = layer.ID; // Services.BaseService.Update("DeleteLineInfoByLayerID", _line); // glebeProperty gle = new glebeProperty(); // gle.LayerID = layer.ID; // Services.BaseService.Update("DeleteglebePropertyByLayerID", gle); // substation _sub = new substation(); // _sub.LayerID = layer.ID; // Services.BaseService.Update("DeletesubstationByLayerID", _sub); //} XmlNodeList list = tlVectorControl1.SVGDocument.SelectNodes("//*[@layer='" + layer.ID + "']"); foreach (XmlNode elNode in list) { tlVectorControl1.SVGDocument.RootElement.RemoveChild(elNode); } //Services.BaseService.Update("UpdateGraPowerRelationByLayerID", layer.ID); //在文档中移除 layer.Remove(); //在列表中移除 }
private void createName2(IGraph temp, Layer layer, string text) { Text n1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; RectangleF t = ((IGraph)temp).GetBounds(); n1.SetAttribute("x", (t.X + t.Width).ToString()); n1.SetAttribute("y", (t.Y + t.Height / 2 + 350).ToString()); n1.InnerText = text; n1.Layer = layer; //doc.CurrentLayer.Add(n1 as SvgElement); //n1.SetAttribute("ParentID", temp.ID); n1.SetAttribute("limitsize", "true"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); }
void frmlar_OnClickLayer(object sender, Layer lar) { tlVectorControl1.SVGDocument.SelectCollection.Clear(); ArrayList a = tlVectorControl1.SVGDocument.getLayerList(); SvgDocument.currentLayer = lar.ID; string larid = lar.ID; if (!ChangeLayerList.Contains(larid)) { ChangeLayerList.Add(larid); } }
public override XmlElement CreateElement(string prefix, string localName, string ns) { XmlElement element1; if (this.firstload) { // SvgElement element2 = null; if (this.preelement != null) { // if (this.preelement.ParentNode == null) // { // if (this.groups.Count > 0) // { // element2 = (SvgElement) this.groups[this.groups.Count - 1]; // if ((element2 is ContainerElement) && ((ContainerElement) element2).IsValidChild(this.preelement)) // { // ((ContainerElement) element2).ChildList.Add(this.preelement); // } // } // this.groups.Add(this.preelement); // } // else if (this.groups.Count > 0) // { // if(this.preelement.ParentNode is ContainerElement && ((ContainerElement) this.preelement.ParentNode).IsValidChild(this.preelement)) // { // ((ContainerElement)this.preelement.ParentNode).ChildList.Add(this.preelement); // } // // } } } switch (localName) { case "clipPath": { element1 = new ClipPath(prefix, localName, ns, this); break; } case "rect": { element1 = new RectangleElement(prefix, localName, ns, this); break; } case "path": { element1 = new GraphPath(prefix, localName, ns, this); break; } case "polyline": { element1 = new Polyline(prefix, localName, ns, this); break; } case "polygon": { element1 = new Polygon(prefix, localName, ns, this); break; } case "circle": { element1 = new Circle(prefix, localName, ns, this); break; } case "ellipse": { element1 = new Ellips(prefix, localName, ns, this); break; } case "script": { element1 = new SvgScript(prefix, localName, ns, this); break; } case "line": { element1 = new Line(prefix, localName, ns, this); break; } case "connectline": case "connect": { element1 = new ConnectLine(prefix, localName, ns, this); break; } case "g": { element1 = new Group(prefix, localName, ns, this); break; } case "svg": { element1 = new SVG(prefix, localName, ns, this); break; } case "text": { element1 = new Text(prefix, localName, ns, this); break; } case "tspan": { element1 = new TSpan(prefix, localName, ns, this); break; } case "tref": { element1 = new TRef(prefix, localName, ns, this); break; } case "linearGradient": { element1 = new LinearGradient(prefix, localName, ns, this); break; } case "radialGradient": { element1 = new RadialGradients(prefix, localName, ns, this); break; } case "stop": { element1 = new GradientStop(prefix, localName, ns, this); break; } case "symbol": { element1 = new ItopVector.Core.Figure.Symbol(prefix, localName, ns, this); break; } case "marker": { element1 = new ItopVector.Core.Figure.Marker(prefix, localName, ns, this); break; } case "defs": { element1 = new ItopVector.Core.Figure.Defs(prefix, localName, ns, this); break; } case "image": { element1 = new ItopVector.Core.Figure.Image(prefix, localName, ns, this); break; } case "a": { element1 = new ItopVector.Core.Figure.Link(prefix, localName, ns, this); break; } case "use": { element1 = new ItopVector.Core.Figure.Use(prefix, localName, ns, this); break; } case "animate": { element1 = new ItopVector.Core.Animate.Animate(prefix, localName, ns, this); break; } case "set": { element1 = new SetAnimate(prefix, localName, ns, this); break; } case "animateColor": { element1 = new ColorAnimate(prefix, localName, ns, this); break; } case "animateMotion": { element1 = new MotionAnimate(prefix, localName, ns, this); break; } case "animateTransform": { element1 = new TransformAnimate(prefix, localName, ns, this); break; } case "pattern": { element1 = new Pattern(prefix, localName, ns, this); break; } case "audio3d": case "audio": { element1 = new AudioAnimate(prefix, localName, ns, this); break; } case "state"://״̬ { element1 =new State(prefix, localName, ns, this); break; } case "layer": { element1 =new Layer(prefix, localName, ns, this); break; } default: { element1 = base.CreateElement(prefix, localName, ns); break; } } if (element1 is SvgElement) { ((SvgElement) element1).ShowParticular = this.AutoShowAnim; } if ((element1 is SvgElement) && this.firstload) { this.preelement = (SvgElement) element1; } else { this.preelement = null; } if (this.xmlreader != null) { int num3 = this.xmlreader.LineNumber; int num4 = this.xmlreader.LinePosition; } // if ((element1 is SVG) && (this.DocumentType == null)) // { // XmlDocumentType type1 = this.CreateDocumentType("svg", "-/W3C/DTD SVG 1.1/EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", null); // this.AppendChild(type1); // this.AppendChild(this.CreateWhitespace("\r\n")); // } return element1; }
internal void AddLayer(Layer lar, bool p) { SVG_LAYER _svg = new SVG_LAYER() { SUID = lar.ID, NAME = lar.Label }; if (treeList1.FocusedNode != null) { if(ilist.Count>0) _svg.YearID = ilist[0].ToString(); _svg.svgID = symbolDoc.SvgdataUid; _svg.OrderID = int.Parse(treeList1.Nodes[treeList1.Nodes.Count-1]["OrderID"].ToString()) + 1; _svg.MDATE = DateTime.Now; } addtotreelist(_svg); }
public void DeleteLayer(Layer layer) { if (!CkRight(layer)) { MessageBox.Show("����ͼ�㲻�ܸ�����ɾ����", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //if (true) { // LineInfo _line = new LineInfo(); // _line.LayerID = layer.ID; // Services.BaseService.Update("DeleteLineInfoByLayerID", _line); // glebeProperty gle = new glebeProperty(); // gle.LayerID = layer.ID; // Services.BaseService.Update("DeleteglebePropertyByLayerID", gle); // substation _sub = new substation(); // _sub.LayerID = layer.ID; // Services.BaseService.Update("DeletesubstationByLayerID", _sub); //} XmlNodeList list = this.SymbolDoc.SelectNodes("//*[@layer='" + layer.ID + "']"); foreach (XmlNode elNode in list) { this.SymbolDoc.RootElement.RemoveChild(elNode); } //Services.BaseService.Update("UpdateGraPowerRelationByLayerID", layer.ID); //���ĵ����Ƴ� SVG_LAYER lar = new SVG_LAYER(); lar.SUID = layer.ID; Services.BaseService.Update("DeleteSVG_LAYER", lar); layer.Remove(); //���б����Ƴ� TreeListNode node = treeList1.FindNodeByKeyID(layer.ID); if (node != null) { if (node.ParentNode == null) treeList1.Nodes.Remove(node); else node.ParentNode.Nodes.Remove(node); } layer = null; LayerName = ""; }
private Layer CopyLayer2(Layer layer, string gradeid) { LayerGrade la = Services.BaseService.GetOneByKey<LayerGrade>(gradeid); string layerlabelf = layer.Label.Substring(4); string layer2name = la.Name.Substring(0, 4) + layerlabelf; int j = 0; //for (int i = 0; i < checkedListBox1.Items.Count; i++) { // if (checkedListBox1.Items[i].ToString() == layer2name) // j = 1; // else // j = 0; //} Layer layer2 = null; if (j == 0) { layer2 = Layer.CreateNew(layer2name, this.SymbolDoc); //this.SymbolDoc.NumberOfUndoOperations = (2 * layer2.GraphList.Count) + 200; SvgElementCollection sc = layer.GraphList; for (int i = layer.GraphList.Count - 1; i >= 0; i--) { SvgElement element = sc[i] as SvgElement; SvgElement temp = element.Clone() as SvgElement; if (temp.GetAttribute("CopyOf") == "") { temp.SetAttribute("CopyOf", temp.ID); } IGraph graph = (IGraph)layer2.AddElement(temp); graph.Layer = layer2; //LineInfo _line = new LineInfo(); //_line.EleID = element.ID; //_line.SvgUID = this.SymbolDoc.SvgdataUid; //IList lineInfoList = Services.BaseService.GetList("SelectLineInfoByEleID", _line); /* PSPDEV _line = new PSPDEV(); _line.EleID = element.ID; _line.SvgUID = this.SymbolDoc.SvgdataUid; IList lineInfoList = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandEleID", _line); foreach (PSPDEV line in lineInfoList) { line.SUID = Guid.NewGuid().ToString(); line.LayerID = layer2.ID; line.EleID = temp.ID; Services.BaseService.Create<PSPDEV>(line); } glebeProperty gle = new glebeProperty(); gle.EleID = element.ID; gle.SvgUID = this.SymbolDoc.SvgdataUid; IList gleProList = Services.BaseService.GetList("SelectglebePropertyByEleID", gle); foreach (glebeProperty gleP in gleProList) { gleP.UID = Guid.NewGuid().ToString(); gleP.LayerID = layer2.ID; gleP.EleID = temp.ID; Services.BaseService.Create<glebeProperty>(gleP); } substation _sub = new substation(); _sub.EleID = element.ID; _sub.SvgUID = this.SymbolDoc.SvgdataUid; IList substationList = Services.BaseService.GetList("SelectsubstationByEleID", _sub); foreach (substation sub in substationList) { sub.UID = Guid.NewGuid().ToString(); sub.LayerID = layer2.ID; sub.EleID = temp.ID; Services.BaseService.Create<substation>(sub); } */ } } //this.SymbolDoc.NotifyUndo(); return layer2; }
//private void simpleButton5_Click(object sender, EventArgs e) //{ // int index = this.checkedListBox1.SelectedIndex; // if (index>0) // { // Layer layer = this.checkedListBox1.Items[index] as Layer; // LayerFile temp = new LayerFile(); // temp.SvgDataUid = this.symbolDoc.SvgdataUid; // IList lList = Services.BaseService.GetList("SelectLayerFileBySvgDataUid", temp); // foreach (LayerFile lay in lList) // { // if (lay.LayerFileName==layer.Label) // { // MessageBox.Show("�ĵ����Ѿ�����ͬ��ͼ��,����ͼ�����ƺ���", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information); // return; // } // } // string strsvgData = this.symbolDoc.SelectNodesToString("svg/*[@layer='" + layer.ID + "']|svg/defs"); // LayerFile layerFile = new LayerFile(); // layerFile.SUID = Guid.NewGuid().ToString(); // layerFile.LayerID = layer.ID; // layerFile.LayerFileName = layer.Label; // layerFile.SvgDataUid = this.symbolDoc.SvgdataUid; // layerFile.LayerOuterXml = strsvgData; // Services.BaseService.Create<LayerFile>(layerFile); // DeleteLayer(layer); // } // //StreamWriter sw = new StreamWriter("c:\\1.xml"); // //sw.Write(str1); // //sw.Close(); // //sw = new StreamWriter("c:\\2.txt"); // //sw.Write(str2); // //sw.Close(); // //sw = new StreamWriter("c:\\3.xml"); // //sw.Write(str3); // //sw.Close(); // //sw = new StreamWriter("c:\\4.txt"); // //sw.Write(str4); // //sw.Close(); // //sw = new StreamWriter("c:\\5.xml"); // //sw.Write(newOutXml); // //sw.Close(); // //string str2 = this.SymbolDoc.SvgdataUid; // //SVGFILE svg = new SVGFILE(); // //svg = (SVGFILE)svglist[0]; // //svg.SVGDATA = this.SymbolDoc.OuterXml; // //Services.BaseService.Update<SVGFILE>(svg); //} private Layer CopyLayer(Layer layer) { Layer layer2 = Layer.CreateNew(layer.Label + " ����", this.SymbolDoc); layer2.SetAttribute("ParentID", layer.GetAttribute("ParentID")); //foreach (SvgElement g in layer.GraphList) //{ // layer2.GraphList.Add(g); //} SVG_LAYER la = new SVG_LAYER(); la.SUID = layer.ID; la.svgID = symbolDoc.SvgdataUid; la = (SVG_LAYER)Services.BaseService.GetObject("SelectSVG_LAYERByKey", la); if (la != null) { la.SUID = layer2.ID; la.NAME = layer2.Label; Services.BaseService.Create<SVG_LAYER>(la); DataTable dt = treeList1.DataSource as DataTable; dt.Rows.Add(Itop.Common.DataConverter.ObjectToRow(la, dt.NewRow())); } this.SymbolDoc.NumberOfUndoOperations = (2 * layer2.GraphList.Count) + 200; SvgElementCollection sc = layer.GraphList; for (int i = layer.GraphList.Count - 1; i >= 0; i--) { SvgElement element = sc[i] as SvgElement; SvgElement temp = element.Clone() as SvgElement; //if (temp.Name=="use"){ if (temp.GetAttribute("CopyOf") == "") { temp.SetAttribute("CopyOf", temp.ID); } //else //{ // temp.SetAttribute("CopyOf", temp.ID); //} //} IGraph graph = (IGraph)layer2.AddElement(temp); graph.Layer = layer2; //LineInfo _line = new LineInfo(); //_line.EleID = element.ID; //_line.SvgUID = this.SymbolDoc.SvgdataUid; //IList lineInfoList = Services.BaseService.GetList("SelectLineInfoByEleID", _line); /* PSPDEV _line = new PSPDEV(); _line.EleID = element.ID; _line.SvgUID = this.SymbolDoc.SvgdataUid; IList lineInfoList = Services.BaseService.GetList("SelectPSPDEVBySvgUIDandEleID", _line); foreach (PSPDEV line in lineInfoList) { line.SUID = Guid.NewGuid().ToString(); line.LayerID = layer2.ID; line.EleID = temp.ID; line.Type = "05"; Services.BaseService.Create<PSPDEV>(line); } glebeProperty gle = new glebeProperty(); gle.EleID = element.ID; gle.SvgUID = this.SymbolDoc.SvgdataUid; IList gleProList=Services.BaseService.GetList("SelectglebePropertyByEleID", gle); foreach (glebeProperty gleP in gleProList) { gleP.UID = Guid.NewGuid().ToString(); gleP.LayerID = layer2.ID; gleP.EleID = temp.ID; Services.BaseService.Create<glebeProperty>(gleP); } PSP_Substation_Info _sub = new PSP_Substation_Info(); _sub.EleID = element.ID; _sub.AreaID = this.SymbolDoc.SvgdataUid; IList substationList = Services.BaseService.GetList("SelectPSP_Substation_InfoListByEleID", _sub); foreach (PSP_Substation_Info sub in substationList) { sub.UID = Guid.NewGuid().ToString(); sub.LayerID = layer2.ID; sub.EleID = temp.ID; Services.BaseService.Create<PSP_Substation_Info>(sub); } */ } this.SymbolDoc.NotifyUndo(); return layer2; }
private bool CkRight(Layer lar) { if (lar == null) return false; if (lar.Label == "������0" /*|| lar.Label=="�滮��" || lar.Label=="ͳ�Ʋ�"*/) { return false; } #if(!CITY) if (progtype == "�����滮��") { string ltype = lar.GetAttribute("layerType"); if (ltype == "������Ϣ��" || ltype == "���й滮��") return false; } #endif return true; }
private void ShowTriangle1(ArrayList _polylist, XmlElement _poly, ref ArrayList arraylist, Layer lay) { try { Dictionary<XmlElement, PointF> fhkcollect = new Dictionary<XmlElement, PointF>(); PointF fhcenter = new PointF(); string aaa = yearID; if (D_TIN.DS.VerticesNum > 2) //构建三角网 D_TIN.CreateTIN(); //输出三角形 for (int i = 0; i < D_TIN.DS.TriangleNum; i++) { Point point1 = new Point(Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V1Index].x), Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V1Index].y)); Point point2 = new Point(Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V2Index].x), Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V2Index].y)); Point point3 = new Point(Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V3Index].x), Convert.ToInt32(D_TIN.DS.Vertex[D_TIN.DS.Triangle[i].V3Index].y)); string str_points = ""; str_points = point1.X.ToString() + " " + point1.Y.ToString() + "," + point2.X.ToString() + " " + point2.Y.ToString() + "," + point3.X.ToString() + " " + point3.Y.ToString(); //XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as XmlElement; //e1.SetAttribute("points", str_points); //e1.SetAttribute("style", "stroke-width:1;stroke:#0000FF;stroke-opacity:1;"); //e1.SetAttribute("IsTin", "1"); //e1.SetAttribute("layer", SvgDocument.currentLayer); //tlVectorControl1.SVGDocument.RootElement.AppendChild(e1); } D_TIN.CalculateBC(); D_TIN.CreateVoronoi(); ArrayList CirList = new ArrayList(); ArrayList polyCentriodList = new ArrayList(); for (int n = 0; n < D_TIN.DS.Barycenters.Length; n++) { Barycenter bar = D_TIN.DS.Barycenters[n]; if (bar.X == 0 && bar.Y == 0) { break; } Triangle tri = D_TIN.DS.Triangle[n]; Vertex ver = D_TIN.DS.Vertex[tri.V1Index]; Vertex ver2 = D_TIN.DS.Vertex[tri.V2Index]; Vertex ver3 = D_TIN.DS.Vertex[tri.V3Index]; Decimal r = Convert.ToDecimal(Math.Abs(Math.Sqrt(Math.Pow(Convert.ToDouble(ver.x - bar.X), 2.0) + Math.Pow(Convert.ToDouble(ver.y - bar.Y), 2.0)))); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("circle") as Circle; n1.SetAttribute("cx", bar.X.ToString()); n1.SetAttribute("cy", bar.Y.ToString()); n1.SetAttribute("r", r.ToString()); n1.SetAttribute("layer", SvgDocument.currentLayer); n1.SetAttribute("style", "fill:#FFFFC0;fill-opacity:0.5;stroke:#000000;stroke-opacity:1;"); //tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); CirList.Add(n1); PointF[] Flist = new PointF[3]; Flist[0] = new PointF(ver.x, ver.y); Flist[1] = new PointF(ver2.x, ver2.y); Flist[2] = new PointF(ver3.x, ver3.y); polyCentriodList.Add(TLMath.polyCentriod(Flist)); } System.Collections.SortedList clist = new SortedList(); System.Collections.SortedList CtoFHlist = new SortedList(); decimal sum = 0; for (int n = 0; n < CirList.Count; n++) { List<fhdkandcirsort> dkcol = new List<fhdkandcirsort>(); fhkcollect = new Dictionary<XmlElement, PointF>(); int k = 0; Circle cir = (Circle)CirList[n]; GraphicsPath gr1 = new GraphicsPath(); gr1.AddPath(cir.GPath, true); gr1.CloseFigure(); for (int m = 0; m < _polylist.Count; m++) { XmlElement _x = (XmlElement)_polylist[m]; PointF _f = TLMath.polyCentriod(_x); if (gr1.IsVisible(_f)) //外接圆包括那些负荷中心点 { double lenth = Math.Sqrt(Math.Pow(_f.X - cir.CX, 2) + Math.Pow(_f.Y - cir.CY, 2)); fhdkandcirsort ds = new fhdkandcirsort(_x, _f, lenth); dkcol.Add(ds); if (n<Convert.ToInt32(str_num)) { if (!string.IsNullOrEmpty(_x.GetAttribute("bdzandlenth"))) { _x.SetAttribute("bdzandlenth", _x.GetAttribute("bdzandlenth") + (n + 1).ToString() + "号" + "," + (lenth).ToString() + ";"); } else { _x.SetAttribute("bdzandlenth", (n+ 1).ToString() + "号" + "," + (lenth).ToString() + ";"); } } k = k + 1; //求和的过程 string sid = _x.GetAttribute("id"); glebeProperty pl = new glebeProperty(); pl.EleID = sid; pl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; pl = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", pl); if (pl != null) { sum = sum + pl.Burthen; } //fhkcollect.Add(_x, _f);//记录外包圆相交的负荷块 } } dkcol.Sort(); for (int m = 0; m < dkcol.Count; m++) { fhkcollect.Add(dkcol[m].DK, dkcol[m].DKZX); } clist.Add(sum + n, cir); CtoFHlist.Add(sum + n, fhkcollect); string aa = ""; } string str_sub = getSubName(str_dy); for (int k = 0; k < Convert.ToInt32(str_num); k++) { GraphicsPath gr1 = new GraphicsPath(); gr1.AddPolygon(TLMath.getPolygonPoints(_poly)); gr1.CloseFigure(); Circle c1 = clist.GetByIndex(k) as Circle; Dictionary<XmlElement, PointF> FHandPointF = CtoFHlist.GetByIndex(k) as Dictionary<XmlElement, PointF>; PointF pf = TLMath.getUseOffset(str_sub); float X = 0f; float Y = 0f; float ox = 0f; float oy = 0f; if (gr1.IsVisible(new PointF(c1.CX, c1.CY))) { X = c1.CenterPoint.X - pf.X; Y = c1.CenterPoint.Y - pf.Y; ox = c1.CenterPoint.X + 8; oy = c1.CenterPoint.Y; } else { X = ((PointF)polyCentriodList[k]).X - pf.X; Y = ((PointF)polyCentriodList[k]).Y - pf.Y; ox = ((PointF)polyCentriodList[k]).X + 8; oy = ((PointF)polyCentriodList[k]).Y; } XmlElement e1 = tlVectorControl1.SVGDocument.CreateElement("use") as XmlElement; e1.SetAttribute("cx", Convert.ToString(X)); e1.SetAttribute("cy", Convert.ToString(Y)); e1.SetAttribute("x", Convert.ToString(X)); e1.SetAttribute("y", Convert.ToString(Y)); e1.SetAttribute("xzflag", "1"); e1.SetAttribute("xlink:href", str_sub); e1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); e1.SetAttribute("layer", SvgDocument.currentLayer); e1.SetAttribute("subname", Convert.ToString(k + 1) + "号"); e1.SetAttribute("rl", dbl_rl.ToString()); SubandFHcollect _subandfh = new SubandFHcollect(FHandPointF, e1); subandfhlist.Add(_subandfh); tlVectorControl1.SVGDocument.RootElement.AppendChild(e1); tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)e1); XmlElement t1 = tlVectorControl1.SVGDocument.CreateElement("text") as Text; t1.SetAttribute("x", Convert.ToString(ox)); t1.SetAttribute("y", Convert.ToString(oy)); t1.SetAttribute("layer", SvgDocument.currentLayer); t1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#000000;stroke-opacity:1;"); t1.SetAttribute("font-famliy", "宋体"); t1.SetAttribute("font-size", "118"); t1.InnerText = Convert.ToString(k + 1) + "号"; tlVectorControl1.SVGDocument.RootElement.AppendChild(t1); decimal temp1 = TLMath.getNumber((decimal)c1.R, tlVectorControl1.ScaleRatio); //MessageBox.Show(temp1.ToString()); if (Convert.ToDecimal(str_jj) > temp1) { MessageBox.Show(Convert.ToString(k + 1) + "号变电站候选站址小于最小供电半径,请手动进行调整。"); } PSP_SubstationSelect s = new PSP_SubstationSelect(); s.UID = Guid.NewGuid().ToString(); s.EleID = t1.GetAttribute("id"); s.SName = Convert.ToString(k + 1) + "号"; s.Remark = ""; s.col2 = XZ_bdz; s.SvgID = tlVectorControl1.SVGDocument.SvgdataUid; Services.BaseService.Create<PSP_SubstationSelect>(s); // CreateSubline1(_subandfh, true, lay); //生成负荷中心与变电站的连接线 arraylist.Add(e1); } } catch (Exception e1) { } }
//flag 为false时为已有变电站 //flag为ture时变电站为规划的 private void CreateSubline1(SubandFHcollect _subandfh, bool flag, Layer lay) { XmlElement sub = _subandfh.Sub; double subrl = 0; double yfcrl = 0; if (!string.IsNullOrEmpty(sub.GetAttribute("rl"))) { subrl = Convert.ToDouble(sub.GetAttribute("rl")); } double sumrl = 0; string fhdk = ""; foreach (KeyValuePair<XmlElement, PointF> kv in _subandfh.FHcollect) { XmlElement _x = kv.Key; PointF pf = kv.Value; PointF _f = TLMath.polyCentriod(_x); //XmlNode xnode = tlVectorControl1.SVGDocument.SelectSingleNode("svg/polyline[@layer='" + lay.ID + "'and @FirstNode='" + sub.GetAttribute("id").ToString() + "'and @LastNode='" + _x.GetAttribute("id").ToString() + "']"); //if (xnode != null) { // tlVectorControl1.SVGDocument.RootElement.RemoveChild(xnode); //} XmlNodeList nodelist = tlVectorControl1.SVGDocument.SelectNodes("svg/polyline[@layer='" + lay.ID + "'and @xz='1']"); foreach(XmlNode xnode in nodelist) { tlVectorControl1.SVGDocument.RootElement.RemoveChild(xnode); } glebeProperty pl = new glebeProperty(); pl.EleID = _x.GetAttribute("id"); pl.SvgUID = tlVectorControl1.SVGDocument.SvgdataUid; pl = (glebeProperty)Services.BaseService.GetObject("SelectglebePropertyByEleID", pl); double dkrl = 0; string ygdflag = "0"; //0表示还没有供电,1表示完全有已知的变电站供,2表示部分符合已有供并且写上变电站供给了多少 if (!string.IsNullOrEmpty(_x.GetAttribute("ygdflag"))) { ygdflag = _x.GetAttribute("ygdflag"); } if (!string.IsNullOrEmpty(_x.GetAttribute("Burthen"))) { dkrl = Convert.ToDouble(_x.GetAttribute("Burthen")) * dbl_rzb; } //查找此地块离所有变电站中是否离此变电站最近 //地块负荷供应情况 string bdzandlenth= _x.GetAttribute("bdzandlenth"); string[] dkqk=null; int minnumber = 0; if (!string.IsNullOrEmpty(bdzandlenth)) { double minlenth = 1000000; dkqk = (bdzandlenth.Substring(0, bdzandlenth.LastIndexOf(";"))).Split(';'); for (int j = 0; j < dkqk.Length; j++) { string[] dk = dkqk[j].Split(','); if (Convert.ToDouble(dk[1])<minlenth) { minlenth = Convert.ToDouble(dk[1]); minnumber = j; } } if (!dkqk[minnumber].Contains(sub.GetAttribute("subname"))) { continue; } } // sumrl += dkrl; //改进后的不能有部分剩余了 能供则供 不能供则选择其他的变电站来供 if (ygdflag == "0") //说明还没有供给的 { if (subrl * 1.5 >= sumrl) { fhdk += _x.GetAttribute("id") + "," + dkrl.ToString() + ";"; _x.SetAttribute("ygdflag", "1"); yfcrl = sumrl; } else { //去掉此地块的信息 在其他变电站重新寻找供给 bdzandlenth = ""; for (int j = 0; j < dkqk.Length; j++) { if (j!=minnumber) { bdzandlenth += dkqk[j] + ";"; } } _x.SetAttribute("bdzandlenth",bdzandlenth); continue; } //else if (subrl * 1.5< sumrl && subrl >= (sumrl - dkrl)) { // double gyrl = ((subrl * 1.5 + dkrl) - sumrl); // double syrl = sumrl - subrl * 1.5; // fhdk += _x.GetAttribute("id") + "," + gyrl.ToString() + ";"; // _x.SetAttribute("ygdflag", "2"); // _x.SetAttribute("syrl", syrl.ToString()); // yfcrl = subrl * 1.5; //} } //else if (ygdflag == "2") //有一部分剩余的还需要来供 //{ // double syrl = 0; // if (!string.IsNullOrEmpty(_x.GetAttribute("syrl"))) { // syrl = Convert.ToDouble(_x.GetAttribute("syrl")); // } // if ((subrl * 1.5- yfcrl) > syrl) { // fhdk += _x.GetAttribute("id") + "," + syrl.ToString() + ";"; // _x.SetAttribute("ygdflag", "1"); // _x.SetAttribute("syrl", "0"); // yfcrl = sumrl; // } else { // syrl = syrl - (subrl * 1.5 - yfcrl); // fhdk += _x.GetAttribute("id") + "," + (subrl * 1.5 - yfcrl).ToString() + ";"; // _x.SetAttribute("ygdflag", "2"); // _x.SetAttribute("syrl", syrl.ToString()); // yfcrl = subrl * 1.5; // } //} else if (ygdflag == "1") //已经有供应的了 { continue; } if (pl != null) { string sname = sub.GetAttribute("subname"); if (!string.IsNullOrEmpty(sname)) { //if (_x.GetAttribute("xz") == "0") //{ // pl.ObligateField7 = sname; // Services.BaseService.Update<glebeProperty>(pl); //} if (sname.Contains("号")) //为规划的变电站 自动为true { flag = true; } if (string.IsNullOrEmpty(pl.ObligateField7)) { pl.ObligateField7 = sname; } else { if (!pl.ObligateField7.Contains(sname)) { pl.ObligateField7 += "," + sname; } } Services.BaseService.Update<glebeProperty>(pl); } } //if (!flag) //{ // if (_x.GetAttribute("xz")=="1") // { // return; // } //} string temp = ""; if (!flag) { temp = sub.GetAttribute("cx").ToString() + " " + sub.GetAttribute("cy").ToString() + "," + _f.X.ToString() + " " + _f.Y.ToString(); } else temp = sub.GetAttribute("x").ToString() + " " + sub.GetAttribute("y").ToString() + "," + _f.X.ToString() + " " + _f.Y.ToString(); XmlElement n1 = tlVectorControl1.SVGDocument.CreateElement("polyline") as Polyline; n1.SetAttribute("points", temp); //如果是规划 if (flag) { _x.SetAttribute("xz", "1"); n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#990033;stroke-opacity:1;"); } else { if (_x.GetAttribute("xz") != "1") { _x.SetAttribute("xz", "0"); } n1.SetAttribute("style", "fill:#FFFFFF;fill-opacity:1;stroke:#330099;stroke-opacity:1;"); } n1.SetAttribute("layer", lay.ID); n1.SetAttribute("IsLead", "1"); n1.SetAttribute("FirstNode", sub.GetAttribute("id").ToString()); n1.SetAttribute("LastNode", _x.GetAttribute("id").ToString()); n1.SetAttribute("xz", "1"); tlVectorControl1.SVGDocument.RootElement.AppendChild(n1); tlVectorControl1.SVGDocument.SelectCollection.Add((SvgElement)n1); } sub.SetAttribute("fhdk", fhdk); if (yfcrl != 0) { sub.SetAttribute("yfcrzb", (subrl / ((yfcrl / dbl_rzb))).ToString()); } else { sub.SetAttribute("yfcrzb", (dbl_rzb).ToString()); } }
void frmlar_OnClickLayer(object sender, Layer lar) { ArrayList a = tlVectorControl2.SVGDocument.getLayerList(); SvgDocument.currentLayer = lar.ID; if (lar.GetAttribute("layerType") == progtype) { tlVectorControl2.CanEdit = true; if (progtype == "地理信息层") { DlBarVisible(true); } if (progtype == "城市规划层") { DkBarVisible(true); } if (progtype == "电网规划层") { DwBarVisible(true); } } else { tlVectorControl2.CanEdit = false; if (progtype == "地理信息层") { DlBarVisible(false); } if (progtype == "城市规划层") { DkBarVisible(false); } if (progtype == "电网规划层") { DwBarVisible(false); } } if (lar.GetAttribute("layerType") == "所内接线图") { JxtBar(); return; } }