/[NexusPowerControl]/trunk/NexusPowerControl/ThemeLoader.cs
ViewVC logotype

Diff of /trunk/NexusPowerControl/ThemeLoader.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/NexusPowerControl/ThemeLoader.cs	2011/10/22 09:46:14	9
+++ trunk/NexusPowerControl/ThemeLoader.cs	2011/10/25 07:13:09	21
@@ -50,7 +50,7 @@
         }
         public interface IThemeDefinition
         {
-            bool ThemeLoaded { get; set; }
+            bool ThemeLoaded { get; }
             string MainImage { get; set; }
             string ShutdownImage { get; set; }
             string RestartImage { get; set; }
@@ -61,9 +61,9 @@
         }
         public class ThemeDefinition : IThemeDefinition
         {
-            private const string MissingImage = "missing.png";
-            private const string ThemeDirectory = "theme";
-            private const string ThemeFile = "theme.xml";
+            //private const string MissingImage = "missing.png";
+            //private const string ThemeDirectory = "theme";
+            //private const string ThemeFile = "theme.xml";
 
             public const string DefaultTheme = "AeroLowRes";
             public ThemeDefinition() : this(ThemeDefinition.DefaultTheme) { }
@@ -71,7 +71,7 @@
 
             private void init()
             {
-                this.ThemeLoaded = false;
+                //this.ThemeLoaded = false;
                 this.MainImage = "";
                 this.ShutdownImage = "";
                 this.RestartImage = "";
@@ -86,15 +86,15 @@
             private void LoadStandardTheme(string theme)
             {
                 // load theme in format: theme/<themname>/theme.xml : will throw file not found excetion (use default)
-                string xml_file = string.Format(@"{0}\{1}\{2}", ThemeDirectory, theme, ThemeFile);
+                string xml_file = string.Format(@"{0}\{1}\{2}", ThemeConstants.ThemeDirectory, theme, ThemeConstants.ThemeFile);
                 this.LoadCustomTheme(xml_file);
             }
             private void LoadCustomTheme(string theme)
             {
                 // load theme in format: <theme xml file>: will throw file not found excetion (use default)
-                try { if (!File.Exists(theme)) { throw new FileNotFoundException(theme); } else { try { this.ReadThemeXml(theme); } catch { this.ThemeLoaded = false; return; } } this.ThemeLoaded = true; }
-                catch (FileNotFoundException) { this.ThemeLoaded = false; }
-                catch (Exception) { this.ThemeLoaded = false; }
+                try { if (!File.Exists(theme)) { throw new FileNotFoundException(theme); } else { try { this.ReadThemeXml(theme); } catch {  return; } } }
+                catch (FileNotFoundException) { }//this.ThemeLoaded = false; }
+                catch (Exception) { }//this.ThemeLoaded = false; }
             }
 
             private void ReadThemeXml(string theme_xml)
@@ -118,7 +118,7 @@
                                 case ThemeElements.restart: this.RestartImage =BuildThemeImageURI(theme_xml, r.GetAttribute("value")); break;
                                 case ThemeElements.shutdown: this.ShutdownImage =BuildThemeImageURI(theme_xml, r.GetAttribute("value")); break;
                                 case ThemeElements.sleep: this.SleepImage = BuildThemeImageURI(theme_xml, r.GetAttribute("value")); break;
-                                default: BuildThemeImageURI(ThemeDirectory,MissingImage); break;                                
+                                //default: this.ThemeLoaded = false; break;                                
                             }
                         }
                     }
@@ -133,14 +133,28 @@
                 fs = new FileInfo(fullpath);
                 if (!fs.Exists)
                 {
-                    fs = new FileInfo(ThemeDirectory);
-                    fullpath = string.Format(@"{0}\{1}\{2}", fs.DirectoryName, ThemeDirectory, MissingImage);
+                    //fs = new FileInfo(ThemeConstants.ThemeDirectory);
+                    //fullpath = string.Format(@"{0}\{1}\{2}", fs.DirectoryName, ThemeConstants.ThemeDirectory, MissingImage);
+                    fullpath = "";
+                    //this.ThemeLoaded = false;
                 }
                 return fullpath;
             }
 
             #region IThemeDefinition Members
-            public bool ThemeLoaded { get; set; }
+            public bool ThemeLoaded { 
+                get 
+                {
+                    return (
+                        this.MainImage != "" &&
+                        this.ShutdownImage != "" &&
+                        this.RestartImage != "" && 
+                        this.LogoffImage != "" &&
+                        this.LockScreenImage != "" &&
+                        this.SleepImage != "" &&
+                        this.CloseImage != "");
+                }
+            }
             public string MainImage { get; set; }
             public string ShutdownImage { get; set; }
             public string RestartImage { get; set; }

 

  ViewVC Help
Powered by ViewVC 1.1.22