diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-10 03:07:00 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-10 03:07:00 +0200 |
| commit | 69c470239bfbab11192f3699f29b5352d74d3630 (patch) | |
| tree | d998519be790c1bc813a5a0e3e759603d6d17685 /src/Interface.cs | |
| parent | 799fec83c114d30652c96d2d245aaddd89f98db4 (diff) | |
ItemTemplate test, major changes in Instantiator implementation
bugs
modifié : Crow.csproj
modifié : Default.style
modifié : Tests/BasicTests.cs
modifié : Tests/Interfaces/Divers/welcome.crow
modifié : Tests/Interfaces/basicTests/0.crow
modifié : Tests/Interfaces/basicTests/4.crow
modifié : src/GraphicObjects/ListBox.cs
modifié : src/GraphicObjects/ProgressBar.cs
modifié : src/GraphicObjects/TemplatedControl.cs
modifié : src/IMLReader.cs
modifié : src/Instantiator.cs
modifié : src/Interface.cs
renommé : src/IMLStream.cs -> src/ItemTemplate.cs
Diffstat (limited to 'src/Interface.cs')
| -rw-r--r-- | src/Interface.cs | 48 |
1 files changed, 15 insertions, 33 deletions
diff --git a/src/Interface.cs b/src/Interface.cs index f3d8c73b..517d481a 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -28,6 +28,7 @@ using System.Threading; using System.Xml; using System.Xml.Serialization; using Cairo; +using System.Globalization; namespace Crow { @@ -55,6 +56,7 @@ namespace Crow } public Interface(){ Interface.CurrentInterface = this; + CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; } #endregion @@ -195,47 +197,27 @@ namespace Crow System.Globalization.CultureInfo savedCulture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; - GraphicObject tmp = null; try { - if (!Instantiators.ContainsKey(path)) - BuildInstaciator(path); - tmp = Instantiators [path].CreateInstance (); - + return GetInstantiator (path).CreateInstance (); } catch (Exception ex) { throw new Exception ("Error loading <" + path + ">:", ex); } Thread.CurrentThread.CurrentCulture = savedCulture; - - return tmp; } - public static void BuildInstaciator (string path) - { - System.Globalization.CultureInfo savedCulture = Thread.CurrentThread.CurrentCulture; - Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; - - #if DEBUG_LOAD - Stopwatch loadingTime = new Stopwatch (); - loadingTime.Start (); - #endif - - try { - using (IMLReader itr = new IMLReader (path)){ - Instantiators[path] = itr.GetInstanciator(); - } - } catch (Exception ex) { - throw new Exception ("Error loading <" + path + ">:", ex); - } - - #if DEBUG_LOAD - loadingTime.Stop (); - Debug.WriteLine ("IML Loading '{2}' : {0} ticks, {1} ms", - loadingTime.ElapsedTicks, loadingTime.ElapsedMilliseconds, path); - #endif - - Thread.CurrentThread.CurrentCulture = savedCulture; + /// <summary> + /// fetch it from cache or create it + /// </summary> + public static Instantiator GetInstantiator(string path){ + if (!Instantiators.ContainsKey(path)) + Instantiators [path] = new Instantiator(path); + return Instantiators [path]; + } + public static ItemTemplate GetItemTemplate(string path){ + if (!Instantiators.ContainsKey(path)) + Instantiators [path] = new ItemTemplate(path); + return Instantiators [path] as ItemTemplate; } - public GraphicObject LoadInterface (string path) { lock (UpdateMutex) { |