61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using MaterialDesignColors;
|
|
|
|
namespace MetroGauges.Controls
|
|
{
|
|
public class PaletteSelectorViewModel
|
|
{
|
|
public PaletteSelectorViewModel()
|
|
{
|
|
Swatches = new SwatchesProvider().Swatches;
|
|
}
|
|
|
|
public ICommand ToggleBaseCommand { get; } = new AnotherCommandImplementation(o => ApplyBase((bool)o));
|
|
|
|
public IEnumerable<Swatch> Swatches { get; }
|
|
|
|
public ICommand ApplyPrimaryCommand { get; } = new AnotherCommandImplementation(o => ApplyPrimary((Swatch)o));
|
|
|
|
public ICommand ApplyAccentCommand { get; } = new AnotherCommandImplementation(o => ApplyAccent((Swatch)o));
|
|
|
|
private static void ApplyBase(bool isDark)
|
|
{
|
|
new PaletteHelper().SetLightDark(isDark);
|
|
|
|
Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
|
if (isDark)
|
|
{
|
|
cfa.AppSettings.Settings["Intensity"].Value = "Dark";
|
|
}
|
|
else
|
|
{
|
|
cfa.AppSettings.Settings["Intensity"].Value = "Light";
|
|
}
|
|
cfa.Save();
|
|
}
|
|
|
|
private static void ApplyPrimary(Swatch swatch)
|
|
{
|
|
new PaletteHelper().ReplacePrimaryColor(swatch);
|
|
|
|
Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
|
cfa.AppSettings.Settings["Primary"].Value = swatch.Name;
|
|
cfa.Save();
|
|
}
|
|
|
|
private static void ApplyAccent(Swatch swatch)
|
|
{
|
|
new PaletteHelper().ReplaceAccentColor(swatch);
|
|
|
|
Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
|
cfa.AppSettings.Settings["Accent"].Value = swatch.Name;
|
|
cfa.Save();
|
|
}
|
|
|
|
}
|
|
}
|