//sets a skin as the current skin public void setCurrentSkin(Skin skin) { SkinObject.GetInstance().CurrentSkin = skin; /* BitmapImage img = new BitmapImage(); img.BeginInit(); img.UriSource = new Uri(skin.Background); img.EndInit(); * */ foreach (KeyValuePair<string, object> property in this.CurrentSkin.Properties) { App.Current.Resources[property.Key] = property.Value; } /* App.Current.Resources["BackgroundImage"] = img; App.Current.Resources["<LinearGradientBrush StartPoint="0,0" EndPoint="0,1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><LinearGradientBrush.GradientStops><GradientStop Color="#FFFFD700" Offset="0.2" /><GradientStop Color="#FFFFFF00" Offset="0.85" /><GradientStop Color="#FFFFD700" Offset="1" /></LinearGradientBrush.GradientStops></LinearGradientBrush>"] = this.CurrentSkin.HeaderBackgroundColor2; App.Current.Resources["HeaderBackgroundBrush"] = this.CurrentSkin.HeaderBackgroundColor1; App.Current.Resources["ButtonBrush"] = this.CurrentSkin.ButtonBrush; * */ }
//adds a new skin to the list private static void AddSkin(Skin skin) { skins.Add(skin); }
// load a given skin file private static void LoadSkin(string file) { XmlDocument doc = new XmlDocument(); doc.Load(file); XmlElement root = doc.DocumentElement; string name = root.Attributes["name"].Value; XmlNodeList propertiesList = root.SelectNodes("//property"); Skin skin = new Skin(name); foreach (XmlElement propertyElement in propertiesList) { string propertyName = propertyElement.Attributes["name"].Value; StringReader reader = new StringReader(propertyElement.InnerXml); XmlReader xmlReader = XmlReader.Create(reader); object o = XamlReader.Load(xmlReader); skin.addProperty(new KeyValuePair<string, object>(propertyName, o)); } Skins.AddSkin(skin); }