diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-02-27 18:18:42 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-02-27 18:18:42 +0100 |
| commit | 508b53d725958e6a8c8be51db04033aeff1df0da (patch) | |
| tree | 8495cf890a9cee3466aa8eaceb073f391fb5d628 /src | |
| parent | f4c05f6b4ddd426a87492b51aca5147d5def2bc5 (diff) | |
crowide wip, DesignIDS
Diffstat (limited to 'src')
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 12 | ||||
| -rw-r--r-- | src/GraphicObjects/Group.cs | 14 | ||||
| -rw-r--r-- | src/GraphicObjects/PrivateContainer.cs | 8 | ||||
| -rw-r--r-- | src/Instantiator.cs | 19 |
4 files changed, 53 insertions, 0 deletions
diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index fadbe124..f5a1a224 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -52,12 +52,23 @@ namespace Crow internal ReaderWriterLockSlim parentRWLock = new ReaderWriterLockSlim(); #if DESIGN_MODE + public volatile bool HasChanged = false; + public string design_id; public int design_line; public int design_column; public string design_imlPath; public Dictionary<string,string> design_members = new Dictionary<string, string>(); public bool design_isTGItem = false; + public virtual bool FindByDesignID(string designID, out GraphicObject go){ + go = null; + if (this.design_id == designID){ + go = this; + return true; + } + return false; + } + public string GetIML(){ XmlDocument doc = new XmlDocument( ); @@ -73,6 +84,7 @@ namespace Crow getIML (doc, (XmlNode)doc); doc.WriteTo (xtw); } + this.HasChanged = false; return sw.ToString (); } } diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index 2875b4de..0eb1ece2 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -39,6 +39,20 @@ namespace Crow public class Group : GraphicObject { #if DESIGN_MODE + public override bool FindByDesignID(string designID, out GraphicObject go){ + go = null; + if (base.FindByDesignID (designID, out go)) + return true; + childrenRWLock.EnterReadLock (); + foreach (GraphicObject w in Children) { + if (!w.FindByDesignID (designID, out go)) + continue; + childrenRWLock.ExitReadLock (); + return true; + } + childrenRWLock.ExitReadLock (); + return false; + } public override void getIML (System.Xml.XmlDocument doc, System.Xml.XmlNode parentElem) { if (this.design_isTGItem) diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index f2626e25..81017a7e 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -45,6 +45,14 @@ namespace Crow public PrivateContainer (Interface iface) : base(iface){} #endregion + #if DESIGN_MODE + public override bool FindByDesignID(string designID, out GraphicObject go){ + go = null; + if (base.FindByDesignID (designID, out go)) + return true; + return (bool)child?.FindByDesignID (designID, out go); + } + #endif protected GraphicObject child; protected virtual void SetChild(GraphicObject _child) diff --git a/src/Instantiator.cs b/src/Instantiator.cs index c0b886ad..5c6711f5 100644 --- a/src/Instantiator.cs +++ b/src/Instantiator.cs @@ -74,6 +74,13 @@ namespace Crow.IML internal string sourcePath; + #if DESIGN_MODE + public static int NextInstantiatorID = 0; + public int currentInstantiatorID = 0; + int currentDesignID = 0; + internal string NextDesignID { get { return string.Format ("{0}_{1}",currentInstantiatorID, currentDesignID++); }} + #endif + #region CTOR /// <summary> /// Initializes a new instance of the Instantiator class. @@ -86,6 +93,9 @@ namespace Crow.IML /// </summary> public Instantiator (Interface _iface, Stream stream, string srcPath = null) { + #if DESIGN_MODE + currentInstantiatorID = NextInstantiatorID++; + #endif iface = _iface; sourcePath = srcPath; #if DEBUG_LOAD @@ -112,12 +122,18 @@ namespace Crow.IML /// positionned on the start tag inside the itemTemplate /// </summary> public Instantiator (Interface _iface, XmlReader itr){ + #if DESIGN_MODE + currentInstantiatorID = NextInstantiatorID++; + #endif iface = _iface; parseIML (itr); } //TODO:check if still used public Instantiator (Interface _iface, Type _root, InstanciatorInvoker _loader) { + #if DESIGN_MODE + currentInstantiatorID = NextInstantiatorID++; + #endif iface = _iface; RootType = _root; loader = _loader; @@ -384,6 +400,9 @@ namespace Crow.IML #if DESIGN_MODE IXmlLineInfo li = (IXmlLineInfo)reader; ctx.il.Emit (OpCodes.Ldloc_0); + ctx.il.Emit (OpCodes.Ldstr, this.NextDesignID); + ctx.il.Emit (OpCodes.Stfld, typeof(GraphicObject).GetField("design_id")); + ctx.il.Emit (OpCodes.Ldloc_0); ctx.il.Emit (OpCodes.Ldc_I4, ctx.curLine + li.LineNumber); ctx.il.Emit (OpCodes.Stfld, typeof(GraphicObject).GetField("design_line")); ctx.il.Emit (OpCodes.Ldloc_0); |