public UpdateSkinViewModel() { SkinColorType skin = SkinHelper.DefaultSkinColor; if (ConfigurationMaster.ContainsKey(SkinHelper.SkinColorConfigurationKey)) { skin = SkinHelper.StringToSkinColorType(ConfigurationMaster.Get(SkinHelper.SkinColorConfigurationKey)); } DefaultColorType = skin; }
protected override void BindCommands() { ColorSelectedCommand = new RelayCommand(() => { SkinColorType colorType = BooleanToSkinColorType(); SkinHelper.LoadSkin(colorType); SaveSkin(colorType); }); CancelCommand = new RelayCommand(() => { SkinColorTypeToBoolean(DefaultColorType); SkinHelper.LoadSkin(DefaultColorType); Messenger.Default.Send(new NotificationMessage(this, UIMessageType.SkinConfiguration_CloseWindowEvent)); }); OKCommand = new RelayCommand(() => { Messenger.Default.Send(new NotificationMessage(this, UIMessageType.SkinConfiguration_CloseWindowEvent)); }); }
private void OnLoaded(object sender, RoutedEventArgs e) { try { if (ConfigurationMaster.ContainsKey(SkinHelper.SkinColorConfigurationKey)) { SkinColorType skin = SkinHelper.StringToSkinColorType(ConfigurationMaster.Get(SkinHelper.SkinColorConfigurationKey)); SkinHelper.LoadSkin(skin); } LanguageLoader.LoadLanguageResource(CultureHelper.Component, CultureHelper.Culture); } catch (Exception ex) { ExceptionHandler.Handle(ex); } LoginModel model = new LoginModel(); LoginViewModel viewModel = new LoginViewModel(model, LoginResultCallback); loginView.DataContext = viewModel; }
private void SkinColorTypeToBoolean(SkinColorType colorType) { switch (colorType) { case SkinColorType.Black: IsBlack = true; break; case SkinColorType.Blue: IsBlue = true; break; case SkinColorType.Cyan: IsCyan = true; break; case SkinColorType.Gold: IsGold = true; break; case SkinColorType.Green: IsGreen = true; break; case SkinColorType.Purple: IsPurple = true; break; case SkinColorType.Red: IsRed = true; break; case SkinColorType.Silver: IsSilver = true; break; case SkinColorType.Violet: IsViolet = true; break; case SkinColorType.Yellow: IsYellow = true; break; case SkinColorType.CadetBlue: IsCadetBlue = true; break; case SkinColorType.Crimson: IsCrimson = true; break; case SkinColorType.DodgerBlue: IsDodgerBlue = true; break; case SkinColorType.Gainsboro: IsGainsboro = true; break; case SkinColorType.Goldenrod: IsGoldenrod = true; break; case SkinColorType.LightYellow: IsLightYellow = true; break; case SkinColorType.LimeGreen: IsLimeGreen = true; break; case SkinColorType.Peru: IsPeru = true; break; case SkinColorType.Pink: IsPink = true; break; case SkinColorType.SkyBlue: IsSkyBlue = true; break; default: IsCyan = true; break; } }
private void SaveSkin(SkinColorType colorType) { ConfigurationMaster.Set(SkinHelper.SkinColorConfigurationKey, colorType.ToString()); }
private SkinColorType BooleanToSkinColorType() { SkinColorType colorType = SkinColorType.Cyan; if (IsBlack) { colorType = SkinColorType.Black; } else if (IsBlue) { colorType = SkinColorType.Blue; } else if (IsCyan) { colorType = SkinColorType.Cyan; } else if (IsGold) { colorType = SkinColorType.Gold; } else if (IsGreen) { colorType = SkinColorType.Green; } else if (IsPurple) { colorType = SkinColorType.Purple; } else if (IsRed) { colorType = SkinColorType.Red; } else if (IsSilver) { colorType = SkinColorType.Silver; } else if (IsViolet) { colorType = SkinColorType.Violet; } else if (IsYellow) { colorType = SkinColorType.Yellow; } else if (IsCadetBlue) { colorType = SkinColorType.CadetBlue; } else if (IsCrimson) { colorType = SkinColorType.Crimson; } else if (IsDodgerBlue) { colorType = SkinColorType.DodgerBlue; } else if (IsGainsboro) { colorType = SkinColorType.Gainsboro; } else if (IsGoldenrod) { colorType = SkinColorType.Goldenrod; } else if (IsLightYellow) { colorType = SkinColorType.LightYellow; } else if (IsLimeGreen) { colorType = SkinColorType.LimeGreen; } else if (IsPeru) { colorType = SkinColorType.Peru; } else if (IsPink) { colorType = SkinColorType.Pink; } else if (IsSkyBlue) { colorType = SkinColorType.SkyBlue; } return(colorType); }
public static void LoadSkin(SkinColorType colorType) { List<ResourceDictionary> dicts = new List<ResourceDictionary>(); foreach (var item in Application.Current.Resources.MergedDictionaries) { dicts.Add(item); } Application.Current.Resources.MergedDictionaries.Clear(); ResourceDictionary colorDict = new ResourceDictionary(); switch (colorType) { case SkinColorType.Black: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Blue.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.Cyan: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Gold.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.Green: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Purple.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.Red: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Silver.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.Violet: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Yellow.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.CadetBlue: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Crimson.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.DodgerBlue: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Gainsboro.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.Goldenrod: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/LightYellow.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.LimeGreen: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Peru.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.Pink: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/SkyBlue.xaml", UriKind.RelativeOrAbsolute); break; default: colorDict.Source = new Uri(@"pack://*****:*****@"\", @"/").EndsWith(@"component/Skins/Black.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Blue.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Cyan.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Gold.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Green.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Purple.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Red.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Silver.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Violet.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Yellow.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/CadetBlue.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Crimson.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/DodgerBlue.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Gainsboro.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Goldenrod.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/LightYellow.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/LimeGreen.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Peru.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Pink.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/SkyBlue.xaml".ToLowerInvariant()) ) { System.Diagnostics.Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Change Skin : {0}", colorDict.Source.ToString())); } else { Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(item.Source.AbsoluteUri, UriKind.RelativeOrAbsolute) }); } } dicts.Clear(); }
public static void LoadSkin(SkinColorType colorType) { List <ResourceDictionary> dicts = new List <ResourceDictionary>(); foreach (var item in Application.Current.Resources.MergedDictionaries) { dicts.Add(item); } Application.Current.Resources.MergedDictionaries.Clear(); ResourceDictionary colorDict = new ResourceDictionary(); switch (colorType) { case SkinColorType.Black: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Blue.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.Cyan: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Gold.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.Green: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Purple.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.Red: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Silver.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.Violet: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Yellow.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.CadetBlue: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Crimson.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.DodgerBlue: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Gainsboro.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.Goldenrod: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/LightYellow.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.LimeGreen: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/Peru.xaml", UriKind.RelativeOrAbsolute); break; case SkinColorType.Pink: colorDict.Source = new Uri(@"pack://*****:*****@"pack://application:,,,/Gimela.Presentation.Skins;component/Skins/SkyBlue.xaml", UriKind.RelativeOrAbsolute); break; default: colorDict.Source = new Uri(@"pack://*****:*****@"\", @"/").EndsWith(@"component/Skins/Black.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Blue.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Cyan.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Gold.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Green.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Purple.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Red.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Silver.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Violet.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Yellow.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/CadetBlue.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Crimson.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/DodgerBlue.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Gainsboro.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Goldenrod.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/LightYellow.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/LimeGreen.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Peru.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/Pink.xaml".ToLowerInvariant()) || item.Source.ToString().ToLowerInvariant().Replace(@"\", @"/").EndsWith(@"component/Skins/SkyBlue.xaml".ToLowerInvariant()) ) { System.Diagnostics.Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Change Skin : {0}", colorDict.Source.ToString())); } else { Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri(item.Source.AbsoluteUri, UriKind.RelativeOrAbsolute) }); } } dicts.Clear(); }