]> O.S.I.I.S - jp/crow.git/commitdiff
use design_id as default name in every situation
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 28 Mar 2018 13:02:08 +0000 (15:02 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 28 Mar 2018 13:02:08 +0000 (15:02 +0200)
src/GraphicObjects/GraphicObject.cs
src/Instantiator.cs

index 86d20369c60503e7e6652b3a0dc310dc91d88722..cbcbe7ccee83eb07bbfc4b4555d846bbd2a9a550 100644 (file)
@@ -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
                /// </summary>
                protected GraphicObject () {
                        Clipping = new Region ();
-                       #if DEBUG
-                       uid = currentUid;
-                       currentUid++;
-                       #endif                  
                }
                /// <summary>
                /// 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
                /// <summary>
@@ -523,18 +517,14 @@ namespace Crow
                /// </summary>
                [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);
                        }
                }
                /// <summary>
index 388c5d7681c3c4a2346b6a914eb862398f96d5b2..8589b75a3a103759585208d69611eba7866a19f8 100644 (file)
@@ -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
                /// <summary>
@@ -93,9 +91,7 @@ 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
@@ -122,18 +118,14 @@ 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;
@@ -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"));