diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-02-26 12:47:39 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-02-26 12:47:39 +0100 |
| commit | 225d8384090e77e6099010fdb0dfb474ab5c9a8f (patch) | |
| tree | 2681a1105edac064f2cfbf53d9a1d0aee04d7de8 /src/GraphicObjects/GraphicObject.cs | |
| parent | 57f94308df1d6c5ac4b4c94df47ba57a955b365d (diff) | |
in design saving of GraphicObject
Diffstat (limited to 'src/GraphicObjects/GraphicObject.cs')
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 768b5c07..fadbe124 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -36,6 +36,12 @@ using System.Diagnostics; using Crow.IML; using System.Threading; + +#if DESIGN_MODE +using System.Xml; +using System.IO; +#endif + namespace Crow { /// <summary> @@ -50,6 +56,42 @@ namespace Crow public int design_column; public string design_imlPath; public Dictionary<string,string> design_members = new Dictionary<string, string>(); + public bool design_isTGItem = false; + + public string GetIML(){ + XmlDocument doc = new XmlDocument( ); + + using (StringWriter sw = new StringWriter ()) { + XmlWriterSettings settings = new XmlWriterSettings { + Indent = true, + IndentChars = "\t", + }; + using (XmlWriter xtw = XmlWriter.Create (sw, settings)) { + //(1) the xml declaration is recommended, but not mandatory + XmlDeclaration xmlDeclaration = doc.CreateXmlDeclaration ("1.0", "UTF-8", null); + doc.InsertBefore (xmlDeclaration, null); + getIML (doc, (XmlNode)doc); + doc.WriteTo (xtw); + } + return sw.ToString (); + } + } + + public virtual void getIML(XmlDocument doc, XmlNode parentElem) { + if (this.design_isTGItem) + return; + + XmlElement xe = doc.CreateElement(this.GetType().Name); + + foreach (KeyValuePair<string,string> kv in design_members) { + XmlAttribute xa = doc.CreateAttribute (kv.Key); + xa.Value = kv.Value; + xe.Attributes.Append (xa); + } + + parentElem.AppendChild (xe); + } + #endif #region IDisposable implementation |