/// <summary> /// Save this node to XML /// </summary> /// <param name="writer">The XML writer</param> public void SaveToXML(System.Xml.XmlWriter writer) { writer.WriteComment(this.ConstraintDescription()); writer.WriteStartElement(GOM_TAGS.ASSIGN); writer.WriteStartElement(GOM_TAGS.L_VALUE); m_values[0].SaveToXML(writer); writer.WriteEndElement(); writer.WriteStartElement(GOM_TAGS.R_VALUE); m_values[1].SaveToXML(writer); writer.WriteEndElement(); writer.WriteEndElement(); }
/// <summary> /// Put the contents of the error and warning information to the /// passed in xml text writer. /// </summary> /// <param name="xmlOutput"></param> public void FlushTo(System.Xml.XmlTextWriter xmlOutput) { xmlOutput.Flush(); int ttlWarnings = m_Warnings.Count + m_sfmsWithOutData; // warnings and sfm's w/o data int ttlErrors = m_FatalErrors.Count + m_Errors.Count; // fatal and reg errors if (ttlErrors + ttlWarnings == 0) xmlOutput.WriteComment(" There were No errors or warnings during the creation of this file"); // put out the root error element xmlOutput.WriteComment(" This element contains error, warning and sfm data related information "); xmlOutput.WriteStartElement("ErrorLog"); OutputErrorElement(xmlOutput); // errors OutputWarningElement(xmlOutput); // warnings OutputOOOInfo(xmlOutput); // out of order cautions OutputDuplicateSfmWarnErrElement(xmlOutput); // duplicate SFM errors and warnings OutputSfmInfo(xmlOutput); // general statistics on sfm usage xmlOutput.WriteEndElement(); // end the "ErrorLog" element // remove all the errors and warnings m_Errors.Clear(); m_Warnings.Clear(); m_sfmWarningsAndErrors.Clear(); m_FatalErrors.Clear(); m_uniqueMsgs.Clear(); m_sfmsWithOutData = 0; m_sfmsWithData = 0; m_sfmData.Clear(); m_OOO.Clear(); m_OOOCnt = 0; m_OOOEntries.Clear(); m_OOOEntriesKEYS.Clear(); m_OOOEntriesOrdered.Clear(); }
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(); }
public void WriteXml(System.Xml.XmlWriter writer) { writer.WriteComment("Definición del flujograma que debe seguir el proceso"); XmlSerializer serializer = new XmlSerializer(xmlFlujogramaType); serializer.Serialize(writer, FlujogramaDef); writer.WriteComment("Estado Actual en el que se encuentra el proceso"); serializer = new XmlSerializer(xmlEstadoType); serializer.Serialize(writer, EstadoActual); writer.WriteComment("Última transición que se realizó en el proceso"); serializer = new XmlSerializer(xmlTransicionType); serializer.Serialize(writer, UltimaTransicion); if (Convert.ToBoolean(_procesosAnteriores.Count)) { writer.WriteComment("Histórico de transiciones"); writer.WriteStartElement("Historico"); foreach (var item in _procesosAnteriores) { serializer.Serialize(writer, item.Value); } writer.WriteEndElement(); } }
/// <summary> /// Write element to the output stream /// </summary> /// <param name="writer">Where to write</param> /// <param name="nameOverride">Local name to be used, or null if name should be retirevent from <see cref="XsTypeAttribute"/> of the type.</param> public override void WriteXml(System.Xml.XmlWriter writer, string nameOverride) { if (Text!=null && (Text.Contains("---") || Text.IndexOfAny("<>&".ToCharArray())!=-1)) writer.WriteProcessingInstruction("rem",Text); else writer.WriteComment(Text); }