public override System.Xml.XmlNode ToXMl(System.Xml.XmlDocument d) { if (Value.ToString() != "") return d.CreateTextNode(((DateTime) Value).ToString("s")); else return d.CreateTextNode(""); }
public override System.Xml.XmlNode ToXMl(System.Xml.XmlDocument d) { if (Value != null && Value.ToString() != "") { if(Value is DateTime) return d.CreateTextNode(((DateTime) Value).ToString("s")); DateTime convertedDate; if (DateTime.TryParse(Value.ToString(), out convertedDate)) return d.CreateTextNode(convertedDate.ToString("s")); } return d.CreateTextNode(""); }
public virtual System.Xml.XmlNode ToXMl(System.Xml.XmlDocument d) { if (this._dataType.DBType == DBTypes.Ntext) return d.CreateCDataSection(this.Value.ToString()); return d.CreateTextNode(Value.ToString()); }
private static void AddStringToDict( System.Xml.XmlDocument doc, System.Xml.XmlElement dict, string value) { var element = doc.CreateElement("string"); var text = doc.CreateTextNode(value); element.AppendChild(text); dict.AppendChild(element); }
/// <summary> /// Save font. It will create this /// <font Name="something" StemV="20" Width="[234 34]"><EmbeddedFont>dasjdlkajsdljxlkjsaldjasldjxflj</embeddedFont></font> /// </summary> /// <param name="doc"></param> /// <param name="element"></param> public void Save(System.Xml.XmlDocument doc, System.Xml.XmlElement element) { // save font XmlElement el = doc.CreateElement("Font"); XmlAttribute attr = doc.CreateAttribute("Name"); attr.Value = this.Font.Name; el.SetAttributeNode(attr); attr = doc.CreateAttribute("SaveID"); attr.Value = this.SaveID.ToString(); el.SetAttributeNode(attr); // save metrics attr = doc.CreateAttribute("EmHeight"); attr.Value = this.Font.FontFamily.GetEmHeight(this.Font.Style).ToString(); el.SetAttributeNode(attr); attr = doc.CreateAttribute("Ascent"); attr.Value = this.Font.FontFamily.GetCellAscent(this.font.Style).ToString(); el.SetAttributeNode(attr); attr = doc.CreateAttribute("Descent"); attr.Value = this.Font.FontFamily.GetCellDescent(this.font.Style).ToString(); el.SetAttributeNode(attr); attr = doc.CreateAttribute("Bold"); attr.Value = this.Font.Bold ? "1" : "0"; el.SetAttributeNode(attr); attr = doc.CreateAttribute("Italic"); attr.Value = this.Font.Italic ? "1" : "0"; el.SetAttributeNode(attr); // Get font metrics to save some properties of font FontMetrics metrics = new FontMetrics(this.Font); attr = doc.CreateAttribute("EmbeddingLicense"); attr.Value = ((int)metrics.EmbeddingLicense).ToString(); el.SetAttributeNode(attr); attr = doc.CreateAttribute("ItalicAngle"); attr.Value = metrics.ItalicAngle.ToString(); el.SetAttributeNode(attr); attr = doc.CreateAttribute("BBoxLeft"); attr.Value = metrics.FontBBox.Left.ToString(); el.SetAttributeNode(attr); attr = doc.CreateAttribute("BBoxRight"); attr.Value = metrics.FontBBox.Right.ToString(); el.SetAttributeNode(attr); attr = doc.CreateAttribute("BBoxTop"); attr.Value = metrics.FontBBox.Top.ToString(); el.SetAttributeNode(attr); attr = doc.CreateAttribute("BBoxBottom"); attr.Value = metrics.FontBBox.Bottom.ToString(); el.SetAttributeNode(attr); attr = doc.CreateAttribute("StemV"); attr.Value = metrics.StemV.ToString(); el.SetAttributeNode(attr); attr = doc.CreateAttribute("Flags"); attr.Value = metrics.Flags.ToString(); el.SetAttributeNode(attr); attr = doc.CreateAttribute("FirstChar"); attr.Value = metrics.FirstChar.ToString(); el.SetAttributeNode(attr); attr = doc.CreateAttribute("LastChar"); attr.Value = metrics.LastChar.ToString(); el.SetAttributeNode(attr); // make glyph widths string glyphwidth = "[ "; for (int i = metrics.FirstChar; i <= metrics.LastChar; i++) { int gw = metrics.GetGlyphWidth(this.font, i); glyphwidth += gw.ToString() + " "; } glyphwidth += " ]"; attr = doc.CreateAttribute("Widths"); attr.Value = glyphwidth; el.SetAttributeNode(attr); // embedd font if not std font if (!this.IsStandardFont) { byte[] fontBuffer = FontMetrics.GetFontData(this.Font); attr = doc.CreateAttribute("EmbeddedDecodedFontLength"); attr.Value = fontBuffer.Length.ToString(); el.SetAttributeNode(attr); XmlText textValue = doc.CreateTextNode("EmdeddedFont"); textValue.Value = Convert.ToBase64String(fontBuffer); attr = doc.CreateAttribute("EmbeddedFontLength"); attr.Value = textValue.Value.Length.ToString(); el.SetAttributeNode(attr); el.AppendChild(textValue); } element.AppendChild(el); }
public void Serialize(System.Xml.XmlNode parentNode, String nodeName, System.Xml.XmlDocument document) { XmlNode child; // Default export directory child = document.CreateElement("DefaultExportDirectory"); child.AppendChild(document.CreateTextNode(DefaultExportDirectory)); parentNode.AppendChild(child); // SplitPanel sizes child = document.CreateElement("CategoriesSplitDistance"); child.AppendChild(document.CreateTextNode(CategoriesPanelSplitSize.ToString())); parentNode.AppendChild(child); child = document.CreateElement("WorkoutSplitDistance"); child.AppendChild(document.CreateTextNode(WorkoutPanelSplitSize.ToString())); parentNode.AppendChild(child); child = document.CreateElement("StepSplitDistance"); child.AppendChild(document.CreateTextNode(StepPanelSplitSize.ToString())); parentNode.AppendChild(child); child = document.CreateElement("CalendarSplitDistance"); child.AppendChild(document.CreateTextNode(CalendarPanelSplitSize.ToString())); parentNode.AppendChild(child); child = document.CreateElement("StepNotesSplitDistance"); child.AppendChild(document.CreateTextNode(StepNotesSplitSize.ToString())); parentNode.AppendChild(child); child = document.CreateElement("DonationReminderDate"); child.AppendChild(document.CreateTextNode(DonationReminderDate.Ticks.ToString())); parentNode.AppendChild(child); child = document.CreateElement("EnableAutoSplitWorkouts"); child.AppendChild(document.CreateTextNode(AllowSplitWorkouts.ToString())); parentNode.AppendChild(child); }