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

Contents of /trunk/NexusPowerControl/ThemeLoader.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (show annotations) (download)
Sat Oct 22 08:58:41 2011 UTC (8 years ago) by william
File size: 2107 byte(s)
** initial support for themes (better put this in now, rather than having to do a major re-write later)

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5
6 namespace NexusPowerControl
7 {
8
9
10
11 public interface IThemeLoader
12 {
13 bool LoadThemeOrDefault(string ThemeName);
14 //bool LoadCustomTheme(string ThemeName, string ThemeXml);
15 ThemeLoader.ThemeDefinition GetLoadedTheme();
16 }
17 public class ThemeLoader : IThemeLoader
18 {
19
20 private ThemeLoader.ThemeDefinition LoadedTheme;
21 public ThemeLoader()
22 {
23 this.LoadedTheme = new ThemeDefinition();
24 this.LoadThemeOrDefault(ThemeDefinition.DefaultTheme);
25 }
26 #region IThemeLoader Members
27 public bool LoadThemeOrDefault(string ThemeName)
28 {
29 this.LoadedTheme = new ThemeDefinition(ThemeName);
30 return LoadedTheme.ThemeLoaded;
31 }
32 public ThemeLoader.ThemeDefinition GetLoadedTheme()
33 {
34 return (this.LoadedTheme == null) ? new ThemeDefinition() : this.LoadedTheme;
35 }
36 #endregion
37
38 #region sub-classes
39 public class ThemeDefinition
40 {
41 private const string ThemeDirectory = "theme";
42
43 public const string DefaultTheme = "AeroLowRes";
44 public ThemeDefinition() : this(ThemeDefinition.DefaultTheme) { }
45 public ThemeDefinition(string ThemeXml) { this.LoadTheme(ThemeXml); }
46
47 private void LoadTheme(string theme) { if (theme.ToLower().Contains(".xml")) { this.LoadCustomTheme(theme); } else { this.LoadStandardTheme(theme); } }
48
49 private void LoadStandardTheme(string theme)
50 {
51 // load theme in format: theme/<themname>/theme.xml : will throw file not found excetion (use default)
52 }
53 private void LoadCustomTheme(string theme)
54 {
55 // load theme in format: <theme xml file>: will throw file not found excetion (use default)
56 }
57 public bool ThemeLoaded { get; set; }
58 }
59 #endregion
60 }
61 }

  ViewVC Help
Powered by ViewVC 1.1.22