From e3a586148d084b7eea974bae4fa00a19fc547c28 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bruyère Date: Wed, 31 Jan 2018 14:27:38 +0100 Subject: :memo: --- src/Interface.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/Interface.cs') diff --git a/src/Interface.cs b/src/Interface.cs index 19f4a889..188c4a39 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -53,6 +53,14 @@ namespace Crow { #region CTOR static Interface(){ + CrowConfigRoot = + System.IO.Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), + ".config"); + CrowConfigRoot = System.IO.Path.Combine (CrowConfigRoot, "crow"); + if (!Directory.Exists (CrowConfigRoot)) + Directory.CreateDirectory (CrowConfigRoot); + loadCursors (); loadStyling (); findAvailableTemplates (); @@ -70,6 +78,10 @@ namespace Crow #endregion #region Static and constants + /// + /// Crow configuration root path + /// + public static string CrowConfigRoot; /// If true, mouse focus is given when mouse is over control public static bool FocusOnHover = false; /// Threshold to catch borders for sizing @@ -217,9 +229,22 @@ namespace Crow public static Dictionary DefaultTemplates = new Dictionary(); /// Finds available default templates at startup static void findAvailableTemplates(){ + searchTemplatesOnDisk ("./"); + string defTemplatePath = System.IO.Path.Combine (CrowConfigRoot, "defaultTemplates"); + searchTemplatesOnDisk (defTemplatePath); searchTemplatesIn (Assembly.GetEntryAssembly ()); searchTemplatesIn (Assembly.GetExecutingAssembly ()); } + static void searchTemplatesOnDisk (string templatePath){ + if (!Directory.Exists (templatePath)) + return; + foreach (string f in Directory.GetFiles(templatePath, "*.template",SearchOption.AllDirectories)) { + string clsName = System.IO.Path.GetFileNameWithoutExtension(f); + if (DefaultTemplates.ContainsKey (clsName)) + continue; + DefaultTemplates [clsName] = f; + } + } static void searchTemplatesIn(Assembly assembly){ foreach (string resId in assembly .GetManifestResourceNames () -- cgit v1.3.1-4-g156e