/// <summary> /// Initializes palette instance. /// </summary> /// <param name="info"> Palette info. </param> /// <exception cref="System.ArgumentNullException"> The Palette Info. </exception> /// <exception cref="ArgumentNullException">Thrown if palette info is null.</exception> public void Init(IPaletteInfo info) { if (info == null) { throw new ArgumentNullException("info"); } var duration = new Duration(new TimeSpan(0, 0, 0, 0, 500)); var story = new Storyboard { Duration = duration }; IEasingFunction easing = new CircleEase { EasingMode = EasingMode.EaseOut }; Id = info.Id; Name = info.Name; InitColor(MainBackColor, info.MainBackColor.ToColor(), easing, duration, story, MainBackColorProperty); InitColor(MainFrontColor, info.MainFrontColor.ToColor(), easing, duration, story, MainFrontColorProperty); InitColor(CalmBackColor, info.CalmBackColor.ToColor(), easing, duration, story, CalmBackColorProperty); InitColor(CalmFrontColor, info.CalmFrontColor.ToColor(), easing, duration, story, CalmFrontColorProperty); InitColor(StrongBackColor, info.StrongBackColor.ToColor(), easing, duration, story, StrongBackColorProperty); InitColor(StrongFrontColor, info.StrongFrontColor.ToColor(), easing, duration, story, StrongFrontColorProperty); BindingOperations.SetBinding(this, DashboardBackgroundProperty, new Binding("MainBackColor") { Source = this, Mode = BindingMode.OneWay }); BindingOperations.SetBinding( Windows8Palette.Palette, Windows8Palette.AccentColorProperty, new Binding("CalmFrontColor") { Source = this, Mode = BindingMode.OneWay, Converter = new ChangeColorBrightnessConverter() }); BindingOperations.SetBinding( Windows8Palette.Palette, Windows8Palette.MainColorProperty, new Binding("CalmBackColor") { Source = this, Mode = BindingMode.OneWay }); BindingOperations.SetBinding( Windows8Palette.Palette, Windows8Palette.BasicColorProperty, new Binding("StrongBackColor") { Source = this, Mode = BindingMode.OneWay }); BindingOperations.SetBinding( Windows8Palette.Palette, Windows8Palette.StrongColorProperty, new Binding("CalmFrontColor") { Source = this, Mode = BindingMode.OneWay, Converter = new ChangeColorBrightnessConverter() }); BindingOperations.SetBinding( Windows8Palette.Palette, Windows8Palette.MarkerColorProperty, new Binding("CalmFrontColor") { Source = this, Mode = BindingMode.OneWay }); //Windows8Palette.Palette.MarkerColor = (Color)new ChangeColorBrightnessConverter().Convert(info.CalmFrontColor.ToColor(), typeof(Color), null, CultureInfo.InvariantCulture); _colorAnimation = story; _colorAnimation.Begin(); }
/// <summary> /// Converts palette to Xml string. /// </summary> /// <param name="paletteInfo">PaletteInfo instance.</param> /// <returns>Xml string representing specified palette information.</returns> /// <exception cref="System.ArgumentNullException">paletteInfo</exception> public static string SaveToXml(IPaletteInfo paletteInfo) { if (paletteInfo == null) { throw new ArgumentNullException("paletteInfo"); } var doc = new XDocument( new XElement( "palette", new XAttribute("id", paletteInfo.Id), new XAttribute("name", paletteInfo.Name ?? string.Empty), new XElement("MainBackColor", paletteInfo.MainBackColor), new XElement("MainFrontColor", paletteInfo.MainFrontColor), new XElement("StrongBackColor", paletteInfo.StrongBackColor), new XElement("StrongFrontColor", paletteInfo.StrongFrontColor), new XElement("CalmBackColor", paletteInfo.CalmBackColor), new XElement("CalmFrontColor", paletteInfo.CalmFrontColor))); return doc.ToString(SaveOptions.DisableFormatting); }
/// <summary> /// Sets the default palette. /// </summary> private static void SetDefaultPalette() { _selectedPalette = ReadFromIsolatedStorage() ?? ReadSystemDefault() ?? GetDefaultTheme(); _paletteName = _selectedPalette.Name; _palette.Init(_selectedPalette); }