diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-16 15:23:34 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-16 15:23:34 +0200 |
| commit | 8c7cd405658cbe7e4d64be189549b8125300964f (patch) | |
| tree | 409ce325828c665bd0b285a09d40a5a924d73419 /src | |
| parent | ea5ba40d536aa80b56db118c3e8e077790c24359 (diff) | |
Correct bug 'Instanciing from code instead of IML'
set currentInterface to default one if null
modifié : Crow.OpenTK.nuspec
modifié : src/CompilerServices/CompilerServices.cs
modifié : src/GraphicObjects/Container.cs
modifié : src/GraphicObjects/GraphicObject.cs
modifié : src/GraphicObjects/PrivateContainer.cs
modifié : src/GraphicObjects/TemplatedControl.cs
modifié : src/Interface.cs
Diffstat (limited to 'src')
| -rw-r--r-- | src/CompilerServices/CompilerServices.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/Container.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/GraphicObject.cs | 34 | ||||
| -rw-r--r-- | src/GraphicObjects/PrivateContainer.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedControl.cs | 9 | ||||
| -rw-r--r-- | src/Interface.cs | 3 |
6 files changed, 28 insertions, 30 deletions
diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs index 79d3745d..7a73574b 100644 --- a/src/CompilerServices/CompilerServices.cs +++ b/src/CompilerServices/CompilerServices.cs @@ -13,8 +13,8 @@ namespace Crow public static class CompilerServices { static MethodInfo miAddBinding = typeof(GraphicObject).GetMethod ("BindMember"); - static FieldInfo miSetCurIface = typeof(GraphicObject). - GetField ("CurrentInterface", BindingFlags.NonPublic | BindingFlags.Instance); + static FieldInfo miSetCurIface = typeof(GraphicObject).GetField ("currentInterface", + BindingFlags.NonPublic | BindingFlags.Instance); public static void emitSetCurInterface(ILGenerator il){ il.Emit (OpCodes.Ldloc_0); diff --git a/src/GraphicObjects/Container.cs b/src/GraphicObjects/Container.cs index fb4a7834..0b6045bb 100644 --- a/src/GraphicObjects/Container.cs +++ b/src/GraphicObjects/Container.cs @@ -14,10 +14,6 @@ namespace Crow : base() { } - public Container(Rectangle _bounds) - : base(_bounds) - { - } #endregion [XmlIgnore] diff --git a/src/GraphicObjects/GraphicObject.cs b/src/GraphicObjects/GraphicObject.cs index bd96b76c..0cde106a 100644 --- a/src/GraphicObjects/GraphicObject.cs +++ b/src/GraphicObjects/GraphicObject.cs @@ -25,6 +25,21 @@ namespace Crow internal static ulong currentUid = 0; internal ulong uid = 0; + Interface currentInterface = null; + + public Interface CurrentInterface { + get { + if (currentInterface == null) { + currentInterface = Interface.CurrentInterface; + initialize (); + } + return currentInterface; + } + set { + currentInterface = value; + } + } + Rectangles clipping = new Rectangles(); public Rectangles Clipping { get { return clipping; }} @@ -41,23 +56,11 @@ namespace Crow { uid = currentUid; currentUid++; - -// if (CurrentInterface.XmlLoading) -// return; -// loadDefaultValues (); - } - public GraphicObject (Rectangle _bounds) - { -// if (!CurrentInterface.XmlLoading) -// loadDefaultValues (); - - Left = _bounds.Left; - Top = _bounds.Top; - Width = _bounds.Width; - Height = _bounds.Height; } #endregion - + internal protected virtual void initialize(){ + loadDefaultValues (); + } #region private fields LayoutingType registeredLayoutings = LayoutingType.All; ILayoutable logicalParent; @@ -729,7 +732,6 @@ namespace Crow if (RegisteredLayoutings == LayoutingType.None) CurrentInterface.EnqueueForRepaint (this); } - internal Interface CurrentInterface = null; #endregion #region Layouting diff --git a/src/GraphicObjects/PrivateContainer.cs b/src/GraphicObjects/PrivateContainer.cs index 5f70dd17..2a5deeaa 100644 --- a/src/GraphicObjects/PrivateContainer.cs +++ b/src/GraphicObjects/PrivateContainer.cs @@ -39,10 +39,6 @@ namespace Crow : base() { } - public PrivateContainer(Rectangle _bounds) - : base(_bounds) - { - } #endregion protected GraphicObject child; diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index b77c89e3..02d6108a 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -36,12 +36,15 @@ namespace Crow #region CTOR public TemplatedControl () : base() { -// if (CurrentInterface.XmlLoading) -// return; - //loadTemplate (); } #endregion + internal protected override void initialize () + { + loadTemplate (); + base.initialize (); + } + string _template; string _itemTemplate; public Dictionary<string, ItemTemplate> ItemTemplates = new Dictionary<string, Crow.ItemTemplate>();//TODO: dont instantiate if not used diff --git a/src/Interface.cs b/src/Interface.cs index bc0d1f98..0d97685e 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -56,6 +56,7 @@ namespace Crow FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb; } public Interface(){ + CurrentInterface = this; CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; } #endregion @@ -86,7 +87,7 @@ namespace Crow public static FontOptions FontRenderingOptions; #endregion - internal bool XmlLoading = true; + internal static Interface CurrentInterface; public Dictionary<string,object> Ressources = new Dictionary<string, object>(); public Queue<LayoutingQueueItem> LayoutingQueue = new Queue<LayoutingQueueItem> (); |