From a2a18e264a8a2d586f2c058ebb5b2b15b745804e Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bruyère Date: Fri, 23 Feb 2018 12:51:16 +0100 Subject: instantiators dictionary no longer static but local to Interface --- src/Interface.cs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/Interface.cs') diff --git a/src/Interface.cs b/src/Interface.cs index 3d2389b2..ee95eeb5 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -89,7 +89,6 @@ namespace Crow } loadCursors (); - findAvailableTemplates (); FontRenderingOptions = new FontOptions (); FontRenderingOptions.Antialias = Antialias.Subpixel; @@ -101,6 +100,7 @@ namespace Crow CurrentInterface = this; CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; loadStyling (); + findAvailableTemplates (); initTooltip (); initContextMenus (); } @@ -210,7 +210,7 @@ namespace Crow /// each IML and fragments (such as inline Templates) are compiled as a Dynamic Method stored here /// on the first instance creation of a IML item. /// - public static Dictionary Instantiators = new Dictionary(); + public Dictionary Instantiators = new Dictionary(); public List CrowThreads = new List();//used to monitor thread finished public DragDropEventArgs DragAndDropOperation = null; @@ -278,16 +278,16 @@ namespace Crow /// Resource ID must be 'fullClassName.template' (not case sensitive) /// Those found in application assembly have priority to the default Crow's one /// - public static Dictionary DefaultTemplates = new Dictionary(); + public Dictionary DefaultTemplates = new Dictionary(); /// Finds available default templates at startup - static void findAvailableTemplates(){ + void findAvailableTemplates(){ searchTemplatesOnDisk ("./"); string defTemplatePath = System.IO.Path.Combine (CrowConfigRoot, "defaultTemplates"); searchTemplatesOnDisk (defTemplatePath); searchTemplatesIn (Assembly.GetEntryAssembly ()); searchTemplatesIn (Assembly.GetExecutingAssembly ()); } - static void searchTemplatesOnDisk (string templatePath){ + void searchTemplatesOnDisk (string templatePath){ if (!Directory.Exists (templatePath)) return; foreach (string f in Directory.GetFiles(templatePath, "*.template",SearchOption.AllDirectories)) { @@ -297,7 +297,7 @@ namespace Crow DefaultTemplates [clsName] = f; } } - static void searchTemplatesIn(Assembly assembly){ + void searchTemplatesIn(Assembly assembly){ if (assembly == null) return; foreach (string resId in assembly @@ -344,7 +344,7 @@ namespace Crow /// a valid IML string public GraphicObject LoadIMLFragment (string imlFragment) { lock (UpdateMutex) { - GraphicObject tmp = Instantiator.CreateFromImlFragment (imlFragment).CreateInstance(this); + GraphicObject tmp = Instantiator.CreateFromImlFragment (this, imlFragment).CreateInstance(); AddWidget (tmp); return tmp; } @@ -370,7 +370,7 @@ namespace Crow public GraphicObject Load (string path) { //try { - return GetInstantiator (path).CreateInstance (this); + return GetInstantiator (path).CreateInstance (); //} catch (Exception ex) { // throw new Exception ("Error loading <" + path + ">:", ex); //} @@ -380,22 +380,22 @@ namespace Crow /// /// new Instantiator /// path of the iml file to load - public static Instantiator GetInstantiator(string path){ + public Instantiator GetInstantiator(string path){ if (!Instantiators.ContainsKey(path)) - Instantiators [path] = new Instantiator(path); + Instantiators [path] = new Instantiator(this, path); return Instantiators [path]; } /// Item templates are derived from instantiator, this function /// try to fetch the requested one in the cache or create it. /// They have additional properties for recursivity and /// custom display per item type - public static ItemTemplate GetItemTemplate(string path){ + public ItemTemplate GetItemTemplate(string path){ if (!Instantiators.ContainsKey(path)) - Instantiators [path] = new ItemTemplate(path); + Instantiators [path] = new ItemTemplate(this, path); return Instantiators [path] as ItemTemplate; } //TODO: .Net xml serialisation is no longer used, it has been replaced with instantiators - public static void Save (string file, T graphicObject) + public void Save (string file, T graphicObject) { XmlSerializerNamespaces xn = new XmlSerializerNamespaces (); xn.Add ("", ""); -- cgit v1.3.1-4-g156e