public SettingsWindowViewModel() : base() { AccentColors = ThemeManager.Current.Themes .GroupBy(x => x.ColorScheme) .OrderBy(a => a.Key) .Select(a => new AccentColorMenuData { Name = a.Key, ColorBrush = a.First().ShowcaseBrush }) .ToList(); AccentColor = AccentColors.First(x => x.Name == App.Theme.ColorScheme); AppThemes = ThemeManager.Current.Themes .GroupBy(x => x.BaseColorScheme) .Select(x => x.First()) .Select(a => new AppThemeMenuData { Name = a.BaseColorScheme, BorderColorBrush = a.Resources["MahApps.Brushes.ThemeForeground"] as Brush, ColorBrush = a.Resources["MahApps.Brushes.ThemeBackground"] as Brush }) .ToList(); AppTheme = AppThemes.First(x => x.Name == App.Theme.BaseColorScheme); var resources = App.Theme.LibraryThemes.First(x => x.Origin == "MahApps.Metro").Resources.MergedDictionaries.First(); Colors = typeof(Colors).GetProperties(BindingFlags.Public | BindingFlags.Static) .Where(x => x.Name != "Transparent") .Select(x => new AccentColorMenuData { Name = x.Name, ColorBrush = new SolidColorBrush((Color)x.GetValue(null)) }) .ToList(); }
public void Apply(ApplicationDesign design) { try { design.AccentColor.ApplyTheme(); } catch (Exception) { design.AccentColor = AccentColors.First(x => x.Name == "Blue"); design.AccentColor.ApplyTheme(); } try { design.AppTheme.ApplyTheme(); } catch (Exception) { design.AppTheme = AppThemes.First(); design.AppTheme.ApplyTheme(); } if (design.AudioVisualisation != null) { design.AudioVisualisation.AudioVisualisationPlugin.Refresh(); } }
/// <summary> /// CTOR /// </summary> public ShellSettingsFlyoutViewModel() { localizerService = Container.Resolve <ILocalizerService>(ServiceNames.LocalizerService); // create metro theme color menu items for the demo ApplicationThemes = ThemeManager.AppThemes .Select(a => new ApplicationTheme() { Name = a.Name, BorderColorBrush = a.Resources["BlackColorBrush"] as Brush, ColorBrush = a.Resources["WhiteColorBrush"] as Brush }) .ToList(); // create accent colors list AccentColors = ThemeManager.Accents .Select(a => new AccentColor() { Name = a.Name, ColorBrush = a.Resources["AccentColorBrush"] as Brush }) .ToList(); SelectedTheme = ApplicationThemes.Where(c => c.Name.Equals(Properties.Settings.Default.Theme)).FirstOrDefault(); SelectedAccentColor = AccentColors.Where(c => c.Name.Equals(Properties.Settings.Default.Color)).FirstOrDefault(); SelectedLanguage = SupportedLanguages.Where(c => c.Name.Equals(Properties.Settings.Default.Language)).FirstOrDefault(); Container.Resolve <ILoggerFacade>().Log("ShellSettingsFlyoutViewModel created", Category.Info, Priority.None); }
private void InnerInitialize() { AppearanceManager.Current.Initialize(); AppearanceManager.Current.ThemeObsolete += OnThemeObsolete; var theme = ValuesStorage.GetString(KeyTheme); InitializeThemesList(); SelectedTheme = Themes.OfType <ThemeLink>().GetByIdOrDefault(theme) ?? Themes.OfType <ThemeLink>().FirstOrDefault(); try { _loading = true; AccentColor = ValuesStorage.GetColor(KeyAccentColor, AccentColors.First()); if (AccentColor.A == 0) { AccentColor = AccentColors.First(); } AccentDisplayColor = ValuesStorage.GetString(KeyAccentDisplayColor); IdealFormattingMode = ValuesStorage.GetBool(KeyIdealFormattingMode, OptionIdealFormattingModeDefaultValue); SmallFont = ValuesStorage.GetBool(KeySmallFont); BitmapScalingMode = ValuesStorage.GetEnum(KeyBitmapScaling, BitmapScalingMode.HighQuality); LargeSubMenuFont = ValuesStorage.GetBool(KeyLargeSubMenuFont); ShowSubMenuDraggableIcons = ValuesStorage.GetBool(KeyShowSubMenuDraggableIcons, true); PopupToolBars = ValuesStorage.GetBool(KeyPopupToolBars); FrameAnimation = FrameAnimations.FirstOrDefault(x => x.Id == ValuesStorage.GetString(KeyFrameAnimation)) ?? FrameAnimations.First(); } finally { _loading = false; } }
public void OnClick(View view) { if (view.Equals(clickableFrameLayout)) { editor.PutString(ACCENT_COLOR_KEY, AccentColors.GetResource(AccentColors.GetNextColor(currentAccentColor))).Commit(); } }
/// <summary> /// Update the selected item property for each theme/accent when the theme/accent is changed /// </summary> private void ThemeManager_IsThemeChanged(object sender, OnThemeChangedEventArgs e) { OnPropertyChanged("CurrentAppTheme"); OnPropertyChanged("CurrentAppAccent"); AppThemes.ForEach(t => t.IsSelectedItem = (t == CurrentAppTheme)); AccentColors.ForEach(a => a.IsSelectedItem = (a == CurrentAppAccent)); }
public MainWindowViewModel() { this.AccentColors = ThemeManager.Accents .Select(a => new AccentColorMenuData() { Name = a.Name, ColorBrush = a.Resources["AccentColorBrush"] as Brush }) .ToList(); AccentColors.RemoveAt(AccentColors.Count - 1); }
private void LoadDefaults() { if (!this.IsInDesignMode) { SelectedAppTheme = AppThemes.FirstOrDefault(at => at.Name == App.SelectedAppTheme.Name); SelectedAccent = AccentColors.FirstOrDefault(ac => ac.Name == App.SelectedAccent.Name); SelectedLang = App.Language; App.LanguageChanged += AppOnLanguageChanged; } }
/// <summary> /// Load the saved theme and accent /// </summary> public void LoadSavedTheme() { // Get the saved theme and accent AppThemeMenuData savedTheme = AppThemes.Where(t => t.Name == Properties.Settings.Default.AppTheme).FirstOrDefault(); AccentColorMenuData savedAccent = AccentColors.Where(a => a.Name == Properties.Settings.Default.AppAccent).FirstOrDefault(); // Change to the saved theme and accent savedTheme?.ChangeAccentCommand.Execute(null); savedAccent?.ChangeAccentCommand.Execute(null); }
public void SetupTheme() { var primary = Settings.Default.Primary; var accents = Settings.Default.Accents; ApplyPrimary(PrimaryColors.FirstOrDefault(s => s.Name == primary)); ApplyAccent(AccentColors.FirstOrDefault(s => s.Name == accents)); Theme = Settings.Default.Theme; ApplyTheme(Theme); }
public override void OnActivated() { current_snackbar_message_duration = state_manager.Settings.SnackbarMessageDuration; PrimaryColors = theme_controller.GetPrimaryColors(); AccentColors = theme_controller.GetAccentColors(); SelectedPrimaryColor = PrimaryColors.SingleOrDefault(s => s.Name == state_manager.Settings.PrimaryColorName); SelectedAccentColor = AccentColors.SingleOrDefault(s => s.Name == state_manager.Settings.AccentColorName); IsThemeDark = state_manager.Settings.IsDarkTheme; }
public static Color ToWindowsColor(this AccentColors accentColor) { return(accentColor switch { AccentColors.Green => Color.FromRgb(0, 86, 76), AccentColors.Yellow => Color.FromRgb(164, 144, 0), AccentColors.Blue => Color.FromRgb(0, 120, 215), AccentColors.Purple => Color.FromRgb(104, 33, 122), AccentColors.Red => Color.FromRgb(183, 71, 42), _ => throw new ArgumentOutOfRangeException(nameof(accentColor), accentColor, null) });
public SettingsVM() { AccentColors = ThemeManager.Accents.Select(a => new AccentColorMenuData { Name = a.Name, ColorBrush = a.Resources["AccentColorBrush"] as Brush }).ToList(); SelectedAccentColor = AccentColors.First(x => x.Name == Settings.Default.AccentColorName); SelectedIndexTheme = Settings.Default.ThemeIndex; ShowPreviewOnSelect = Settings.Default.ActivatePreviewOnSelect; }
private void WindowThemeUserControl_Loaded(object sender, RoutedEventArgs e) { Window window = Window.GetWindow(this); window.Closing += window_Closing; // Get the saved theme and accent AppThemeMenuData savedTheme = AppThemes.Where(t => t.Name == Properties.Settings.Default.AppTheme).FirstOrDefault(); AccentColorMenuData savedAccent = AccentColors.Where(a => a.Name == Properties.Settings.Default.AppAccent).FirstOrDefault(); // Change to the saved theme and accent savedTheme?.ChangeAccentCommand.Execute(null); savedAccent?.ChangeAccentCommand.Execute(null); }
public static void Apply(this ResourceDictionary me, AccentColors accent) { if (me == null) { throw new ArgumentNullException("me"); } var a = (OfficeAccentColor.Palette.ContainsKey(accent) ? accent : AccentColors.PowerPoint); foreach (var kvp in OfficeAccentColor.Palette[a]) { me[kvp.Key] = new SolidColorBrush((Color)ColorConverter.ConvertFromString(kvp.Value)); } // next kvp } // end function
private void ColorSpinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e) { AccentColor selectedColor = AccentColors.GetAccentColors()[e.Position]; if (selectedColor != currentAccentColor && !ignoreSelection) { currentAccentColor = selectedColor; colorLayout.SetBackgroundColor(GetColor(currentAccentColor)); editor.PutString(ACCENT_COLOR_KEY, AccentColors.GetResource(currentAccentColor)).Commit(); } ignoreSelection = false; }
public SampleFlyoutViewModel() { AccentColors = ThemeManager.Accents .Select(a => new AccentColorMenuData { Name = a.Name, ColorBrush = a.Resources["AccentColorBrush"] as Brush }) .ToList(); var theme = ThemeManager.DetectAppStyle(Application.Current); _currentAccentColor = AccentColors.Single(accent => accent.Name == theme.Item2.Name); OkCommand = new RelayCommand(OnOk, () => !HasErrors); CancelCommand = new RelayCommand(Close); }
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key) { switch (key) { case ACCENT_COLOR_KEY: AccentColor newColor = AccentColors.GetIdFromResource(sharedPreferences.GetString(key, ACCENT_COLOR_DEFAULT)); if (newColor != currentAccentColor) { currentAccentColor = newColor; clickableFrameLayout.SetBackgroundColor(GetColor(currentAccentColor)); } break; } }
public SettingsViewModel() { InitializeCommands(); _selectedTheme = Domain.Settings.Instance.Theme; _selectedColorScheme = AccentColors.FirstOrDefault(c => c.Name == Domain.Settings.Instance.AccentColor); _checkForUpdates = Domain.Settings.Instance.CheckForUpdates; _enableTrayIcon = Domain.Settings.Instance.EnableTrayIcon; _blurBackground = Domain.Settings.Instance.BlurBackground; _selectedAccount = Domain.Settings.Instance.SelectedAccount; _customBackground = Domain.Settings.Instance.CustomBackground; _customBackgroundPath = Domain.Settings.Instance.CustomBackgroundPath; _saveMessagesToCache = Domain.Settings.Instance.SaveMessagesToCache; _loadFullVersions = Domain.Settings.Instance.LoadFullVersions; var lang = Languages.FirstOrDefault(l => l.LanguageCode == Domain.Settings.Instance.Language); _selectedLanguage = lang ?? Languages.First(); }
public SettingsVM() { AccentColors = ThemeManager.Current.Themes .GroupBy(x => x.ColorScheme) .OrderBy(x => x.Key) .Select(a => new AccentColorMenuData { Name = a.Key, ColorBrush = a.First().ShowcaseBrush }).ToList(); SelectedAccentColor = AccentColors.First(x => x.Name == Settings.Default.AccentColorName); SelectedIndexTheme = Settings.Default.ThemeIndex; ShowPreviewOnSelect = Settings.Default.ActivatePreviewOnSelect; PathOverrides = Settings.Default.PathOverrides; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.activity_main); settings = PreferenceManager.GetDefaultSharedPreferences(this); editor = settings.Edit(); //editor.Clear().Commit(); prefListener = new PrefListener(this); clickableFrameLayout = FindViewById <FrameLayout>(Resource.Id.clickableFrameLayout); currentAccentColor = AccentColors.GetIdFromResource(settings.GetString(ACCENT_COLOR_KEY, ACCENT_COLOR_DEFAULT)); clickableFrameLayout.SetBackgroundColor(GetColor(currentAccentColor)); clickableFrameLayout.SetOnClickListener(this); SetAmbientEnabled(); }
public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key) { switch (key) { case ACCENT_COLOR_KEY: AccentColor newColor = AccentColors.GetIdFromResource(sharedPreferences.GetString(key, ACCENT_COLOR_DEFAULT)); if (newColor != currentAccentColor) { currentAccentColor = newColor; colorLayout.SetBackgroundColor(GetColor(currentAccentColor)); ignoreSelection = true; colorSpinner.SetSelection(AccentColors.GetAccentColors().IndexOf(currentAccentColor)); } break; } }
public SettingsViewModel(MusicDataManager musicDataManager, Action refreshViewAction) { MusicDataManager = musicDataManager; _refreshViewAction = refreshViewAction; SelectedSoundOutDevice = musicDataManager.MusicManager.AudioEngine.SoundOutProvider.CurrentSoundOutDevice; AccentColors = ThemeManager.Accents.Select( x => new AccentColorData { ColorBrush = x.Resources["AccentColorBrush"] as Brush, Key = x.Name, AccentColor = x }) .ToList(); Themes = ThemeManager.AppThemes.Select(x => new ThemeData { Key = x.Name, Theme = x }).ToList(); SelectedTheme = Themes.FirstOrDefault(x => x.Key == _settings.Theme) ?? Themes.First(); SelectedAccentColor = AccentColors.FirstOrDefault(x => x.Key == _settings.AccentColor) ?? AccentColors.First(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); settings = PreferenceManager.GetDefaultSharedPreferences(this); editor = settings.Edit(); //editor.Clear().Commit(); prefListener = new PrefListener(this); colorSpinner = FindViewById <Spinner>(Resource.Id.colorSpinner); colorLayout = FindViewById <FrameLayout>(Resource.Id.colorLayout); currentAccentColor = AccentColors.GetIdFromResource(settings.GetString(ACCENT_COLOR_KEY, ACCENT_COLOR_DEFAULT)); AccentColor[] colors = AccentColors.GetAccentColors().ToArray(); colorSpinner.Adapter = new ArrayAdapter <AccentColor>(this, Resource.Layout.colorspinner_item, colors); colorLayout.SetBackgroundColor(GetColor(currentAccentColor)); colorSpinner.ItemSelected += ColorSpinner_ItemSelected; }
[ExcludeFromCodeCoverage] // TODO: could maybe remove after creating a test of this public SettingsFlyoutViewModel() { // localizerService = Container.Resolve<ILocalizerService>(ServiceNames.LOCALIZER_SERVICE); // create metro theme color menu items for the demo ApplicationThemes = ThemeManager.AppThemes.Select(a => new ApplicationTheme { Name = a.Name, BorderColorBrush = a.Resources["BlackColorBrush"] as Brush, ColorBrush = a.Resources["WhiteColorBrush"] as Brush }).ToList(); // create accent colors list AccentColors = ThemeManager.Accents.Select(a => new AccentColor { Name = a.Name, ColorBrush = a.Resources["AccentColorBrush"] as Brush }).ToList(); SelectedTheme = ApplicationThemes.FirstOrDefault(t => t.Name.Equals("BaseDark")); SelectedAccentColor = AccentColors.FirstOrDefault(c => c.Name.Equals("Cobalt")); }
private int GetColorResource(AccentColor accentColor) => GetColorResource(AccentColors.GetResource(accentColor));
private void SetAccentColor() => Current.AccentColor = AccentColors.ToWindowsColor();