diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-10 07:13:14 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-08-10 07:13:40 +0200 |
| commit | 1b2e2794fc8c4c8c20ff50fd7fbe842908912d23 (patch) | |
| tree | e84e01c98b958e9d93214757543639110b07ae4f /src/Interface.cs | |
| parent | 5a03df5faeda15e2d99c4c656eb62ed21817fdf6 (diff) | |
| parent | 69c470239bfbab11192f3699f29b5352d74d3630 (diff) | |
ItemTemplate instantiator, basic listbox ok
Diffstat (limited to 'src/Interface.cs')
| -rw-r--r-- | src/Interface.cs | 50 |
1 files changed, 16 insertions, 34 deletions
diff --git a/src/Interface.cs b/src/Interface.cs index f3d8c73b..ba9769b1 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 @@ -82,7 +84,7 @@ namespace Crow public static FontOptions FontRenderingOptions; #endregion - internal bool XmlLoading = false; + internal bool XmlLoading = true; public Dictionary<string,object> Ressources = new Dictionary<string, object>(); public Queue<LayoutingQueueItem> LayoutingQueue = new Queue<LayoutingQueueItem> (); @@ -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) { |