public void WriteXML(System.Xml.XmlWriter x, System.Data.DataTable datatable) { this.Table.DataTable = datatable; // --------------- x.WriteStartDocument(); x.WriteStartFlowDocument(); x.WriteTextStyleAttributes(this.TextStyle); x.WriteX(this.ReportHeaderDefinition.ReportTitle); x.WriteX(this.ReportHeaderDefinition.HeaderText); x.WriteX(this.Table); x.WriteX(this.ReportFooterDefinition.FooterText); x.WriteEndFlowDocument(); x.WriteEndDocument(); x.Flush(); }
private static void WriteRegions(EU2.Map.IDGrid idgrid, EU2.Data.ProvinceList provinces, IDMap idmap, System.Xml.XmlTextWriter writer) { writer.WriteStartDocument(); writer.WriteStartElement("IDGrid"); for(int y=0; y<idgrid.Height; ++y ) { for(int x=0; x<idgrid.Width; ++x ) { writer.WriteStartElement("Region"); writer.WriteAttributeString("index-x", x.ToString()); writer.WriteAttributeString("index-y", y.ToString()); writer.WriteAttributeString("offset-x", (x*EU2.Map.IDGrid.RegionWidth).ToString()); writer.WriteAttributeString("offset-y", (y*EU2.Map.IDGrid.RegionHeight).ToString()); ushort[] list = idgrid.GetIDs(x,y); int cnt=0; for(; cnt<list.Length; ++cnt) { if ( list[cnt] == 0 && cnt>0 ) break; } if ( cnt <= 1 ) { writer.WriteAttributeString("provinceCount", "0"); Rectangle rect = Rectangle.Empty; if ( !EU2.Map.IDGrid.CheckAreaForOverflow(idmap, EU2.Map.IDGrid.GetRegionRect(x,y), out rect) ) { writer.WriteStartElement("Overflow"); writer.WriteAttributeString("x", rect.X.ToString()); writer.WriteAttributeString("y", rect.Y.ToString()); writer.WriteAttributeString("width", rect.Width.ToString()); writer.WriteAttributeString("height", rect.Height.ToString()); writer.WriteEndElement(); } } else { writer.WriteAttributeString("provinceCount", cnt.ToString()); for(int i=0; i<list.Length; ++i) { if ( list[i] == 0 && i>0 ) break; writer.WriteStartElement("Province"); writer.WriteAttributeString("index", i.ToString()); writer.WriteAttributeString("id", list[i].ToString()); writer.WriteAttributeString("name", provinces[list[i]].Name); writer.WriteEndElement(); } } writer.WriteEndElement(); } } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); }
private static void WriteBoxes(EU2.Map.ProvinceBoundBox[] boxes, System.Xml.XmlTextWriter writer) { writer.WriteStartDocument(); writer.WriteStartElement("BoundBoxes"); foreach(EU2.Map.ProvinceBoundBox box in boxes) { writer.WriteStartElement("Box"); writer.WriteAttributeString("provinceId", box.ProvinceID.ToString()); writer.WriteAttributeString("left", box.Left.ToString()); writer.WriteAttributeString("top", box.Top.ToString()); writer.WriteAttributeString("right", box.Right.ToString()); writer.WriteAttributeString("bottom", box.Bottom.ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); }
private static void WriteAdjacencies(EU2.Map.AdjacencyTable adjtable, EU2.Data.ProvinceList provinces, System.Xml.XmlTextWriter writer) { writer.WriteStartDocument(); writer.WriteStartElement("Adjacencies"); for(int i=Province.MinID; i<=Province.MaxID; ++i) { EU2.Map.Adjacent[] adj = adjtable[i]; writer.WriteStartElement("From"); writer.WriteAttributeString("id", i.ToString()); writer.WriteAttributeString("name", provinces[i].Name); for(int t=0; t<adj.Length; ++t) { writer.WriteStartElement("To"); writer.WriteAttributeString("id", adj[t].ID.ToString()); writer.WriteAttributeString("name", provinces[adj[t].ID].Name); writer.WriteAttributeString("type", adj[t].Type.ToString().ToLower()); writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); }
public override void Write(System.Xml.XmlWriter writer) { writer.WriteStartDocument(); writer.WriteDocType("plist", "-//Apple Computer//DTD PLIST 1.0//EN", "http://www.apple.com/DTDs/PropertyList-1.0.dtd", null); writer.WriteStartElement("plist"); writer.WriteAttributeString("version", version); root.Write(writer); writer.WriteEndDocument(); }
private void AddThenCloseWriter(System.Xml.XmlWriter writer) { AddCodeTableTemplates(writer); AddGridColumnTemplate(writer); AddBackgroundTableTemplate(writer); writer.WriteEndDocument(); writer.Close(); }
public void Write(System.Xml.XmlWriter writer) { // Write the XML declaration if (_options.WriteXMLDecl) writer.WriteStartDocument(true); // Write header info writer.WriteComment("FlowChart.NET diagram"); // Write the root element writer.WriteStartElement("Diagram"); writer.WriteAttributeString("Version", Version.ToString()); // Write brushes int id = 0; SortedList brushes = new SortedList(); foreach(Brush b in Brush.Brushes) { brushes.Add(id, b); // Map brushes to ids id++; } writer.WriteStartElement("Brushes"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(brushes.Count)); for(int i = 0; i < brushes.Count; i++) { FlowChartX.Brush b = (FlowChartX.Brush)brushes.GetValueList()[i]; WriteBrushElement(writer, b, brushes); } // Close the Brushes element writer.WriteEndElement(); // Write the environment information writer.WriteStartElement("Environment"); // Write appearance information WriteProperties(writer, _diagram, _appearanceProps, "Appearance"); // Write behaviour information WriteProperties(writer, _diagram, _behaviourProps, "Behaviour"); // Write defaults information WriteProperties(writer, _diagram, _defaultProps, "Defaults"); // Write default brush and pens writer.WriteStartElement("DefaultsGDI"); WriteBrushRefElement(writer, _diagram.BoxBrush, "BoxBrush", brushes); WriteBrushRefElement(writer, _diagram.TableBrush, "TableBrush", brushes); WriteBrushRefElement(writer, _diagram.ArrowBrush, "ArrowBrush", brushes); WriteBrushRefElement(writer, _diagram.BackBrush, "BackBrush", brushes); WriteBrushRefElement(writer, _diagram.ExteriorBrush, "ExteriorBrush", brushes); WritePenElement(writer, _diagram.BoxPen, "BoxPen", brushes); WritePenElement(writer, _diagram.TablePen, "TablePen", brushes); WritePenElement(writer, _diagram.ArrowPen, "ArrowPen", brushes); writer.WriteEndElement(); // Write grid information WriteProperties(writer, _diagram, _gridProps, "Grid"); // Write layout information WriteProperties(writer, _diagram, _layoutProps, "Layout"); // Write miscellaneous information WriteProperties(writer, _diagram, _miscProps, "Miscellaneous"); // Close the environment element writer.WriteEndElement(); // Write the box information writer.WriteStartElement("Boxes"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(_diagram.Boxes.Count)); id = 0; SortedList sl = new SortedList(); foreach(Box b in _diagram.Boxes) { writer.WriteStartElement("Box"); writer.WriteAttributeString("Id", XmlConvert.FromInt32(id)); writer.WriteAttributeString("ZIndex", XmlConvert.FromInt32(b.ZIndex)); // Write the shape type string shape = "Invalid"; switch(b.Style) { case BoxStyle.Delay: shape = "Delay"; break; case BoxStyle.Ellipse: shape = "Ellipse"; break; case BoxStyle.Rectangle: shape = "Rectangle"; break; case BoxStyle.Rhombus: shape = "Decision"; break; case BoxStyle.RoundedRectangle: shape = "RoundRectangle"; break; case BoxStyle.Shape: // Only shapes with assigned ids are serialized shape = b.Shape.Id; if (shape == "") { // Possibly one of the old predefined shapes foreach (ShapeTemplate newShape in ShapeTemplate.Shapes) { if (b.Shape.Equals(newShape)) { shape = newShape.Id; break; } } if (shape == "") shape = "Rectangle"; } break; } writer.WriteElementString("Shape", shape); // Write brush index WriteBrushRefElement(writer, b.Brush, "Brush", brushes); // Write the pen WritePenElement(writer, b.Pen, "Pen", brushes); // Write the tag WriteTagElement(writer, b); // Write constraints WriteConstraints(writer, b); // Write properties WriteProperties(writer, b, _boxProps, null); writer.WriteEndElement(); sl.Add(id, b); // map boxes to ids id++; } // Close boxes element writer.WriteEndElement(); // Write the control host information writer.WriteStartElement("ControlHosts"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(_diagram.ControlHosts.Count)); BinaryFormatter fmt = new BinaryFormatter(); foreach (ControlHost h in _diagram.ControlHosts) { writer.WriteStartElement("Host"); writer.WriteAttributeString("Id", XmlConvert.FromInt32(id)); writer.WriteAttributeString("ZIndex", XmlConvert.FromInt32(h.ZIndex)); if (h.Control != null) { System.Type type = h.Control.GetType(); writer.WriteAttributeString("ControlAssembly", type.Assembly.GetName().Name); writer.WriteAttributeString("ControlType", type.FullName); // Find the z-index of the contained control int controlZIndex = 0; for (int i = 0; i < _diagram.Controls.Count; i++) { if (_diagram.Controls[i] == h.Control) { controlZIndex = i; break; } } writer.WriteAttributeString("ControlZIndex", controlZIndex.ToString()); } else { writer.WriteAttributeString("ControlAssembly", ""); writer.WriteAttributeString("ControlType", ""); writer.WriteAttributeString("ControlZIndex", "0"); } // Write brush index WriteBrushRefElement(writer, h.Brush, "Brush", brushes); // Write the pen WritePenElement(writer, h.Pen, "Pen", brushes); // Write control properties WriteControlProperties(writer, h.Control, fmt); // Write control host properties WriteProperties(writer, h, _hostProps, null); // Write the tag WriteTagElement(writer, h); // Write constraints WriteConstraints(writer, h); writer.WriteEndElement(); sl.Add(id, h); // map hosts to ids id++; } writer.WriteEndElement(); // Write table information writer.WriteStartElement("Tables"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(_diagram.Tables.Count)); foreach(Table t in _diagram.Tables) { writer.WriteStartElement("Table"); writer.WriteAttributeString("Id", XmlConvert.FromInt32(id)); writer.WriteAttributeString("ZIndex", XmlConvert.FromInt32(t.ZIndex)); writer.WriteAttributeString("Rows", XmlConvert.FromInt32(t.RowCount)); writer.WriteAttributeString("Columns", XmlConvert.FromInt32(t.ColumnCount)); // Write table data writer.WriteStartElement("Data"); for(int r = 0; r < t.RowCount; r++) { for(int c = 0; c < t.ColumnCount; c++) { Table.Cell cell = t[c, r]; writer.WriteStartElement("Cell"); WriteBrushRefElement(writer, cell.Brush, "Brush", brushes); // Write the tag WriteTagElement(writer, cell); WriteProperties(writer, cell, new string[] { "Text", "TextFormat", "Picture", "PicturePos", "TextColor", "HyperLink", "ToolTip", "RowSpan", "ColumnSpan", }, null); writer.WriteEndElement(); } } writer.WriteEndElement(); // Write row data writer.WriteStartElement("Rows"); for(int r = 0; r < t.RowCount; r++) { writer.WriteStartElement("Row"); WriteProperties(writer, t.Rows[r], new string[] { "Height", "AnchorPattern", "Header", "Expanded" }, null); writer.WriteEndElement(); } writer.WriteEndElement(); // Write column data writer.WriteStartElement("Columns"); for(int c = 0; c < t.ColumnCount; c++) { writer.WriteStartElement("Column"); WriteProperties(writer, t.Columns[c], new string[] { "ColumnStyle", "Width" }, null); writer.WriteEndElement(); } writer.WriteEndElement(); // Write brush index WriteBrushRefElement(writer, t.Brush, "Brush", brushes); // Write caption background brush WriteBrushRefElement(writer, t.CaptionBackBrush, "CaptionBackBrush", brushes); // Write the pen WritePenElement(writer, t.Pen, "Pen", brushes); // Write the tag WriteTagElement(writer, t); // Write constraints WriteConstraints(writer, t); // Write properties WriteProperties(writer, t, _tableProps, null); writer.WriteEndElement(); sl.Add(id, t); // map tables to ids id++; } // Close tables element writer.WriteEndElement(); // Write containers in v7 writer.WriteStartElement("Containers"); writer.WriteAttributeString("Count", "0"); writer.WriteEndElement(); // Write arrows data writer.WriteStartElement("Arrows"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(_diagram.Arrows.Count)); int oi, di; int aid = id; foreach(Arrow a in _diagram.Arrows) { writer.WriteStartElement("Arrow"); writer.WriteAttributeString("Id", XmlConvert.FromInt32(aid)); writer.WriteAttributeString("ZIndex", XmlConvert.FromInt32(a.ZIndex)); if (a.Origin != _diagram.Dummy) { oi = sl.IndexOfValue(a.Origin); if(oi < 0) throw new Exception("Unexpected arrow origin index"); id = (int)sl.GetKey(oi); } else { id = -1; } writer.WriteAttributeString("From", XmlConvert.FromInt32(id)); if(a.Origin is Table) writer.WriteAttributeString("RowFrom", XmlConvert.FromInt32(a.OrgnIndex)); if (a.Destination != _diagram.Dummy) { di = sl.IndexOfValue(a.Destination); if(di < 0) throw new Exception("Unexpected arrow destination index"); id = (int)sl.GetKey(di); } else { id = -1; } writer.WriteAttributeString("To", XmlConvert.FromInt32(id)); if(a.Destination is Table) writer.WriteAttributeString("RowTo", XmlConvert.FromInt32(a.DestIndex)); // Write control points writer.WriteStartElement("Data"); foreach(PointF pt in a.ControlPoints) { writer.WriteStartElement("Point"); writer.WriteAttributeString("X", XmlConvert.FromSingle(pt.X)); writer.WriteAttributeString("Y", XmlConvert.FromSingle(pt.Y)); writer.WriteEndElement(); } writer.WriteEndElement(); // Write brush index WriteBrushRefElement(writer, a.Brush, "Brush", brushes); // Write pen WritePenElement(writer, a.Pen, "Pen", brushes); // Write head pen WritePenElement(writer, a.HeadPen, "HeadPen", brushes); // Write the tag WriteTagElement(writer, a); // Write arrow properties WriteProperties(writer, a, _arrowProps, null); writer.WriteEndElement(); sl.Add(aid, a); // map arrows to ids aid++; } // Close arrows element writer.WriteEndElement(); // Write group objects writer.WriteStartElement("Groups"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(_diagram.Groups.Count)); foreach(Group g in _diagram.Groups) { writer.WriteStartElement("Group"); oi = sl.IndexOfValue(g.MainObject); if(oi < 0) throw new Exception("Unexpected group master index"); id = (int)sl.GetKey(oi); // Write group's main object writer.WriteStartElement("MainObject"); writer.WriteAttributeString("Id", XmlConvert.FromInt32(id)); writer.WriteEndElement(); // Write group's visibility writer.WriteElementString("Visible", g.Visible.ToString()); // Write AutoDeleteItems flag writer.WriteElementString("AutoDeleteItems", g.AutoDeleteItems.ToString()); // Write Expandable flag writer.WriteElementString("Expandable", g.Expandable.ToString()); // Write FollowMasterRotation flag writer.WriteElementString("FollowMasterRotation", g.FollowMasterRotation.ToString()); // Write group's tag WriteTagElement(writer, g); // Write attached objects writer.WriteStartElement("Attachments"); writer.WriteAttributeString("Count", XmlConvert.FromInt32(g.Attachments.Count)); foreach(Attachment at in g.Attachments) { writer.WriteStartElement("Attachment"); writer.WriteElementString("Data", XmlConvert.FromInt32(at.attData)); oi = sl.IndexOfValue(at.node); if(oi < 0) throw new Exception("Unexpected group attachee index"); id = (int)sl.GetKey(oi); writer.WriteElementString("Object", XmlConvert.FromInt32(id)); WriteRectangleFElement(writer, "Percents", at.percents); writer.WriteElementString("Type", at.type.ToString()); writer.WriteEndElement(); } writer.WriteEndElement(); writer.WriteEndElement(); } // Close groups element writer.WriteEndElement(); // Close the diagram element writer.WriteEndElement(); // Finish with this document if (_options.WriteXMLDecl) writer.WriteEndDocument(); writer.Flush(); }
/// <summary> /// Used to Display a Tree Like View of how the Nodes are organized. /// </summary> /// <param name="writer"></param> /// <param name="Position"></param> public void Tree(System.Xml.XmlTextWriter xmlwriter, int position) { if (position == 0) { xmlwriter.WriteStartDocument(); xmlwriter.WriteStartElement(this.NameType.ToString()); xmlwriter.WriteRaw(System.Environment.NewLine); } string f = this.FileName; xmlwriter.WriteStartElement(this.NameType.ToString()); xmlwriter.WriteAttributeString("FileName", f); xmlwriter.WriteAttributeString("ID", this.Id); xmlwriter.WriteRaw(System.Environment.NewLine); if (position != int.MaxValue) { position++; } for (int i = 0;i <= DefaultChildren.Count - 1;i++) { string key = (string)DefaultChildrenKeys[i]; Node node = DefaultChildren[key]; if (node.NameType == nBrowser.NodeType.DefaultBrowser) { node.Tree(xmlwriter, position); } } for (int i = 0;i <= Children.Count - 1;i++) { string key = (string)ChildrenKeys[i]; Node node = Children[key]; if (node.NameType == nBrowser.NodeType.Gateway) { node.Tree(xmlwriter, position); } } for (int i = 0;i <= Children.Count - 1;i++) { string key = (string)ChildrenKeys[i]; Node node = Children[key]; if (node.NameType == nBrowser.NodeType.Browser) { node.Tree(xmlwriter, position); } } if (position != int.MinValue) { position--; } xmlwriter.WriteEndElement(); xmlwriter.WriteRaw(System.Environment.NewLine); if (position == 0) { xmlwriter.WriteEndDocument(); xmlwriter.Flush(); } }