public virtual void Deserialize(Version documentVersion, XmlElement node) { this.ID = node.GetAttribute("id"); this.Text = node.GetAttribute("text"); // if (node.HasAttribute("x")) { this.Bounds = new Rectangle( ST.GetIntDefault(node.GetAttribute("x")), ST.GetIntDefault(node.GetAttribute("y")), ST.GetIntDefault(node.GetAttribute("width")), ST.GetIntDefault(node.GetAttribute("height"))); } // this.Remark = ST.ReadTextNode(node, "remark"); if (string.IsNullOrEmpty(this.Remark)) // 向后兼容 { string notes = ST.ReadCDataNode(node, "description"); if (string.IsNullOrEmpty(notes)) { notes = ST.ReadTextNode(node, "description"); } this.Remark = notes; } }
public override void Deserialize(Version documentVersion, XmlElement node) { // if (documentVersion >= Document.DV_3) // 新 { this.Bounds = new Rectangle( ST.GetIntDefault(node.GetAttribute("x")), ST.GetIntDefault(node.GetAttribute("y")), ST.GetIntDefault(node.GetAttribute("width")), ST.GetIntDefault(node.GetAttribute("height"))); CustomWidth = ST.GetInt(node.GetAttribute("custom_width")); CustomHeight = ST.GetInt(node.GetAttribute("custom_height")); } else { CustomWidth = ST.GetInt(node.GetAttribute("width")); CustomHeight = ST.GetInt(node.GetAttribute("height")); } if (node.HasAttribute("align")) { Alignment = ST.GetEnumValue <WidgetAlignment>(node.GetAttribute("align"), Alignment); } Hyperlink = node.GetAttribute("hyperlink"); DisplayIndex = ST.GetIntDefault(node.GetAttribute("display_index")); Padding = ST.GetIntDefault(node.GetAttribute("padding")); Text = ST.ReadTextNode(node, "text"); }
public static int GetLayoutSuspendCount(this Control control) { if (control == null) { throw new ArgumentNullException(); } var type = typeof(Control); var fif = type.GetField("layoutSuspendCount", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.GetField); if (fif != null) { return(ST.GetIntDefault(fif.GetValue(control))); } else { return(0); } }
protected virtual object DeserializeValue(string type, string value) { if (string.IsNullOrEmpty(type)) { return(value); } switch (type) { case "int": return(ST.GetIntDefault(value)); case "decimal": return(ST.GetDecimalDefault(value)); case "float": return(ST.GetFloatDefault(value)); default: return(value); } }
public static Document Load(XmlDocument dom) { if (dom.DocumentElement == null) { return(null); } // version var documentVersion = Document.DocumentVersion; if (dom.DocumentElement.HasAttribute("document_version")) { documentVersion = new Version(dom.DocumentElement.GetAttribute("document_version")); } else if (dom.DocumentElement.HasAttribute("editor_version")) { documentVersion = new Version(dom.DocumentElement.GetAttribute("editor_version")); if (documentVersion.Major == 3) // 3.0早期的beta版本没有 documentVersion, 而其editor_version 可能略大 DocumentVersion { documentVersion = Document.DV_3; } } if (documentVersion > DocumentVersion) { throw new Exception("Unsupport Document Version"); } // old version document, one chart in a document, 1.5.0 or earlier if (dom.DocumentElement.Name == "map") { return(LoadSingleMindMap(documentVersion, dom)); } // new document, multi-charts in a document if (dom.DocumentElement.Name != "document") { return(null); } // var doc = new Document(); // information var infos = dom.DocumentElement.SelectSingleNode("information") as XmlElement; if (infos != null) { if (documentVersion < Document.DV_3) // 老式的写法 { doc.Author = ST.ReadTextNode(infos, "Author"); doc.Company = ST.ReadTextNode(infos, "Company"); doc.Version = ST.ReadTextNode(infos, "Version"); doc.Description = ST.ReadTextNode(infos, "Description"); } else { doc.Author = ST.ReadTextNode(infos, "author"); doc.Company = ST.ReadTextNode(infos, "company"); doc.Version = ST.ReadTextNode(infos, "version"); doc.Description = ST.ReadTextNode(infos, "description"); } } // attributes var attrs = dom.DocumentElement.SelectSingleNode("attributes") as XmlElement; if (attrs != null) { foreach (XmlNode attr in attrs.ChildNodes) { if (!(attr is XmlElement)) { continue; } XmlElement attr_e = (XmlElement)attr; if (attr_e.Name != "item") { continue; } doc.Attributes[attr_e.GetAttribute("name")] = attr_e.InnerText; } } // charts var charts = dom.DocumentElement.SelectSingleNode("charts") as XmlElement; if (charts != null) { foreach (XmlNode chart in charts) { if (!(chart is XmlElement)) { continue; } XmlElement chart_e = (XmlElement)chart; if (chart_e.Name != "chart") { continue; } ChartPage cdoc = LoadChartDocument(documentVersion, chart_e); if (cdoc != null) { doc.Charts.Add(cdoc); } } doc.ActiveChartIndex = ST.GetIntDefault(charts.GetAttribute("active_chart")); } doc.Modified = false; return(doc); }