public ThemeSelectionViewModel() { Swatches = new SwatchesProvider().Swatches.Where(swatch => swatch.AccentHues.Any()); paletteHelper = new PaletteHelper(); ApplyPrimary(Swatches.FirstOrDefault(swatch => swatch.Name.Equals(Settings.Default.AccentTheme.ToLower()))); ApplyBase(Settings.Default.IsDarkTheme); }
public static void Apply(this PaletteHelper self, string swatchName, bool dark) { Swatch?swatch = self.GetSwatch(swatchName); if (swatch != null) { self.Apply(swatch, dark); } }
public static Swatch?GetSwatch(this PaletteHelper self, string name) { foreach (Swatch swatch in new SwatchesProvider().Swatches) { if (swatch.Name == name) { return(swatch); } } return(null); }
public ThemeSetterJob(ISetting<GeneralOptions> setting, ISchedulerProvider schedulerProvider) { _cleanUp = setting.Value.Select(options => options.Theme) .ObserveOn(schedulerProvider.MainThread) .Subscribe(theme => { var dark = theme == Theme.Dark; var paletteHelper = new PaletteHelper(); paletteHelper.SetLightDark(dark); paletteHelper.ReplaceAccentColor(theme.GetAccentColor()); }); }
public static Swatch?GetCurrentSwatch(this PaletteHelper self) { ITheme theme = self.GetTheme(); foreach (Swatch swatch in self.GetSwatches()) { if (theme.PrimaryMid.Color == swatch.ExemplarHue.Color && theme.SecondaryMid.Color == swatch.AccentExemplarHue?.Color) { return(swatch); } } return(null); }
public static void Apply(this PaletteHelper self, Swatch swatch, bool dark) { ITheme theme = self.GetTheme(); theme.SetBaseTheme(dark ? Theme.Dark : Theme.Light); if (swatch != null) { theme.SetPrimaryColor(swatch.ExemplarHue.Color); if (swatch.AccentExemplarHue != null) { theme.SetSecondaryColor(swatch.AccentExemplarHue.Color); } } self.SetTheme(theme); }
public static bool IsDark(this PaletteHelper self) { ITheme theme = self.GetTheme(); return(theme.Background == Theme.Dark.MaterialDesignBackground); }
public static IEnumerable <Swatch> GetSwatches(this PaletteHelper self) { return(swatchesProvider.Swatches); }
public MainWindow() { InitializeComponent(); this._paletteHelper = new PaletteHelper(); }
/// <summary> /// Set material design color /// </summary> private void SetMaterialDesignAccentColor() { var swatch = this.Swatches.Where(s => s.Name.ToUpper().Equals(this.SelectedAccentColor.Name.ToUpper())).FirstOrDefault(); if (swatch != null) { var ph = new PaletteHelper(); ph.ReplacePrimaryColor(swatch, true); ph.ReplaceAccentColor(swatch); } }