public override void Save(XmlTextWriter writer) { writer.WriteStartElement("Autoscroll"); writer.WriteAttributeString("speed", Speed.ToString()); writer.WriteAttributeString("startX", StartX.ToString()); writer.WriteEndElement(); }
/// <summary> /// convert the datatable to an XML document /// </summary> /// <param name="oNode"></param> /// <param name="y"></param> private void BuildTree(XmlNode oNode, int y) { XmlNode childNode = null; //has children foreach (TreeData.TreeDataTableRow childRow in dtTree.Select( string.Format("parentNodeID='{0}'", oNode.Attributes["nodeID"].InnerText))) { //for each child node call this function again childNode = GetXMLNode(childRow.nodeID, childRow.nodeDescription, childRow.nodeNote); oNode.AppendChild(childNode); BuildTree(childNode, y + 1); } //build node data //after checking for nodes we can add the current node int StartX; int StartY; int[] ResultsArr = new int[] { GetXPosByOwnChildren(oNode), GetXPosByParentPreviousSibling(oNode), GetXPosByPreviousSibling(oNode), _Margin }; Array.Sort(ResultsArr); StartX = ResultsArr[3]; StartY = (y * (_BoxHeight + _VerticalSpace)) + _Margin; int width = _BoxWidth; int height = _BoxHeight; //update the coordinates of this box into the matrix, for later calculations oNode.Attributes["X"].InnerText = StartX.ToString(); oNode.Attributes["Y"].InnerText = StartY.ToString(); //update the image size if (imgWidth < (StartX + width + _Margin)) { imgWidth = StartX + width + _Margin; } if (imgHeight < (StartY + height + _Margin)) { imgHeight = StartY + height + _Margin; } }