From d7457dc87ec4a282ac58a5617f149164a1421a64 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Wed, 28 Mar 2018 15:02:08 +0200 Subject: [PATCH] use design_id as default name in every situation --- src/GraphicObjects/GraphicObject.cs | 40 +++++++++++------------------ src/Instantiator.cs | 13 +++------- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index 86d20369..cbcbe7cc 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -51,6 +51,16 @@ namespace Crow { internal ReaderWriterLockSlim parentRWLock = new ReaderWriterLockSlim(); + public string design_id; + public virtual bool FindByDesignID(string designID, out GraphicObject go){ + go = null; + if (this.design_id == designID){ + go = this; + return true; + } + return false; + } + #if DESIGN_MODE static MethodInfo miDesignAddDefLoc = typeof(GraphicObject).GetMethod("design_add_style_location", BindingFlags.Instance | BindingFlags.NonPublic); @@ -58,7 +68,6 @@ namespace Crow BindingFlags.Instance | BindingFlags.NonPublic); public volatile bool design_HasChanged = false; - public string design_id; public int design_line; public int design_column; public string design_imlPath; @@ -83,14 +92,6 @@ namespace Crow // design_iml_locations.Add(memberName, new FileLocation(path,line,col)); // } - 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( ); @@ -197,9 +198,6 @@ namespace Crow } #endregion - internal static ulong currentUid = 0; - internal ulong uid = 0; - internal bool isPopup = false; public GraphicObject focusParent { get { return (isPopup ? LogicalParent : parent) as GraphicObject; } @@ -242,10 +240,6 @@ namespace Crow /// protected GraphicObject () { Clipping = new Region (); - #if DEBUG - uid = currentUid; - currentUid++; - #endif } /// /// This constructor **must** be used when creating widget from code. @@ -513,7 +507,7 @@ namespace Crow } #if DEBUG [XmlIgnore]public string TreePath { - get { return this.GetType().Name + uid.ToString (); } + get { return Name; } } #endif /// @@ -523,18 +517,14 @@ namespace Crow /// [DesignCategory ("Divers")] public virtual string Name { - get { - #if DEBUG - return string.IsNullOrEmpty(name) ? this.GetType().Name + uid.ToString () : name; - #else - return name; - #endif + get { + return string.IsNullOrEmpty(name) ? design_id : name; } set { - if (name == value) + if (Name == value) return; name = value; - NotifyValueChanged("Name", name); + NotifyValueChanged("Name", Name); } } /// diff --git a/src/Instantiator.cs b/src/Instantiator.cs index 388c5d76..8589b75a 100644 --- a/src/Instantiator.cs +++ b/src/Instantiator.cs @@ -74,12 +74,10 @@ 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 /// @@ -93,9 +91,7 @@ namespace Crow.IML /// public Instantiator (Interface _iface, Stream stream, string srcPath = null) { - #if DESIGN_MODE currentInstantiatorID = NextInstantiatorID++; - #endif iface = _iface; sourcePath = srcPath; #if DEBUG_LOAD @@ -122,18 +118,14 @@ namespace Crow.IML /// positionned on the start tag inside the itemTemplate /// 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; @@ -409,11 +401,12 @@ namespace Crow.IML using (XmlTextReader reader = new XmlTextReader (tmpXml, XmlNodeType.Element, null)) { reader.Read (); - #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")); + + #if DESIGN_MODE + IXmlLineInfo li = (IXmlLineInfo)reader; 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")); -- 2.47.3