]> O.S.I.I.S - jp/crow.git/commitdiff
first try to load style from current dir in *.style
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 19 Nov 2017 05:50:01 +0000 (06:50 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 19 Nov 2017 05:50:01 +0000 (06:50 +0100)
src/Interface.cs
src/StyleReader.cs

index 07c7afbf1b0c4cde408bb71e50fe41ddf91dd188..9add4f4efb046977c8365d03c33b72ccad5010bf 100644 (file)
@@ -196,20 +196,33 @@ namespace Crow
 
                        //fetch styling info in this order, if member styling is alreadey referenced in previous
                        //assembly, it's ignored.
-                       loadStylingFromAssembly (Assembly.GetEntryAssembly ());
-                       loadStylingFromAssembly (Assembly.GetExecutingAssembly ());
+                       loadStylingFrom (Directory.GetCurrentDirectory());
+                       loadStylingFrom (Assembly.GetEntryAssembly ());
+                       loadStylingFrom (Assembly.GetExecutingAssembly ());
                }
                /// <summary> Search for .style resources in assembly </summary>
-               static void loadStylingFromAssembly (Assembly assembly) {
+               static void loadStylingFrom (Assembly assembly) {
                        if (assembly == null)
                                return;
                        foreach (string s in assembly
                                .GetManifestResourceNames ()
                                .Where (r => r.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) {
+                               Console.WriteLine ("Loading style: {0}", s);
                                new StyleReader (assembly, s)
                                        .Dispose ();
                        }
                }
+               static void loadStylingFrom (string styleDirectory) {
+                       if (!Directory.Exists(styleDirectory))
+                               Console.WriteLine ("Error loading styles: {0} directory not found");
+                       foreach (string s in Directory.GetFiles(styleDirectory, "*.style",SearchOption.AllDirectories)) {
+                               using (Stream stream = new FileStream(s,FileMode.Open)){
+                                       Console.WriteLine ("Loading style: {0}", s);
+                                       new StyleReader (stream, s)
+                                               .Dispose ();
+                               }
+                       }
+               }
                static void loadCursors(){
                        //Load cursors
                        XCursor.Cross = XCursorFile.Load ("#Crow.Images.Icons.Cursors.cross").Cursors [0];
index db12053dc79718ad1789deb21a84e485570f3895..ec04f92fa812cbd633d6307f5e27a0220fa806dc 100644 (file)
@@ -40,7 +40,10 @@ namespace Crow
                int line = 1;
 
                public StyleReader (Assembly assembly, string resId)
-                       : base(assembly.GetManifestResourceStream (resId))
+                       : this(assembly.GetManifestResourceStream (resId), resId)
+               {}
+               public StyleReader (Stream stream, string resId)
+                       : base(stream)
                {
                        resourceId = resId;
                        string styleKey = resId.Substring (0, resId.Length - 6);