private void ChangeColorScheme(ColorScheme scheme) { PaletteHelper paletteHelper = new PaletteHelper(); ITheme theme = paletteHelper.GetTheme(); theme.SetBaseTheme(scheme.Theme == Config.Theme.Dark ? MaterialDesignThemes.Wpf.Theme.Dark : MaterialDesignThemes.Wpf.Theme.Light); var swatches = new SwatchesProvider().Swatches; if (swatches.Where(x => x.ExemplarHue != null).Select(x => x.Name).Contains(scheme.PrimaryHue)) { theme.SetPrimaryColor(swatches.First(x => x.Name == scheme.PrimaryHue).ExemplarHue.Color); } if (swatches.Where(x => x.AccentExemplarHue != null).Select(x => x.Name).Contains(scheme.AccentHue)) { theme.SetSecondaryColor(swatches.First(x => x.Name == scheme.AccentHue).AccentExemplarHue.Color); } paletteHelper.SetTheme(theme); ResourceDictionary oldThemeResourceDictionary = Application.Current.Resources.MergedDictionaries .Where(resourceDictionary => resourceDictionary != null && resourceDictionary.Source != null) .SingleOrDefault(resourceDictionary => Regex.IsMatch(resourceDictionary.Source.OriginalString, @"(\/MaterialDesignExtensions;component\/Themes\/MaterialDesign)((Light)|(Dark))Theme\.")); string newThemeSource = $"pack://application:,,,/MaterialDesignExtensions;component/Themes/MaterialDesign{(scheme.Theme == Config.Theme.Dark ? "Dark" : "Light")}Theme.xaml"; ResourceDictionary newThemeResourceDictionary = new ResourceDictionary() { Source = new Uri(newThemeSource) }; Application.Current.Resources.MergedDictionaries.Remove(oldThemeResourceDictionary); Application.Current.Resources.MergedDictionaries.Add(newThemeResourceDictionary); }
public SettingViewModel() { if (!(bool)IsInDesignModeStatic) { var swatches = new SwatchesProvider().Swatches; this._PrimarySwatches = swatches.Where(swatch => swatch.ExemplarHue != null).ToArray(); this._AccentSwatches = swatches.Where(swatch => swatch.AccentExemplarHue != null).ToArray(); this._PaletteHelper = new PaletteHelper(); this.SelectedPrimaryColor = this._PrimarySwatches.First(swatch => swatch.Name.Equals(ConfigurationModel.Instance.Primary, StringComparison.InvariantCultureIgnoreCase)); this.SelectedAccentColor = this._AccentSwatches.First(swatch => swatch.Name.Equals(ConfigurationModel.Instance.Accent, StringComparison.InvariantCultureIgnoreCase)); this.IsDark = ConfigurationModel.Instance.Dark; } }
public SettingViewModel() { HotKeyCollect = new ObservableCollection <HotKeyModel>(); foreach (var it in ConfigMgr.Instance.HardwareCfgMgr.AxisSettings) { var MotionCard = MotionMgr.Instance.FindMotionCardByAxisIndex(it.AxisNo); if (MotionCard != null) { HotKeyCollect.Add(new HotKeyModel() { AxisName = MotionCard.AxisArgsList[it.AxisNo - MotionCard.MIN_AXIS].AxisName, AxisNo = MotionCard.AxisArgsList[it.AxisNo - MotionCard.MIN_AXIS].AxisNo, }); } else { HotKeyCollect.Add(new HotKeyModel()); } } //初始化Google控件皮肤 Swatches = new SwatchesProvider().Swatches; PaletteHelper paletteHelper = new PaletteHelper(); paletteHelper.ReplacePrimaryColor(Swatches.Where(a => a.Name == "blue").First()); }
public ColourProvider() { var swatches = new SwatchesProvider().Swatches.AsArray(); Swatches = swatches.ToDictionary(s => s.Name); var accents = swatches.Where(s => s.IsAccented).ToArray(); var orders = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase); ThemeConstants.Themes.Select((str, idx) => new { str, idx }) .ForEach(x => orders[x.str] = x.idx); var greys = swatches//.Where(s => !s.IsAccented) .Where(s => s.Name == "bluegrey") .SelectMany(swatch => { var hues = swatch.PrimaryHues .Where(hue => hue.Name == "Primary200" || hue.Name == "Primary300" || hue.Name == "Primary400" || hue.Name == "Primary500") .Select(hue => new Hue(swatch.Name, hue.Name, hue.Foreground, hue.Color)); var withNumber = hues.Select(h => { var num = GetNumber(h.Name); return(new { hue = h, Num = num }); }).OrderBy(h => h.Num) .Take(8) .Select(x => x.hue); return(withNumber); }); Hues = accents .OrderBy(x => orders.Lookup(x.Name).ValueOr(() => 100)) .SelectMany(swatch => { return(swatch.AccentHues.Select(hue => new Hue(swatch.Name, hue.Name, hue.Foreground, hue.Color))); }) .Union(greys) .ToArray(); HueCache = Hues.ToDictionary(h => h.Key); }
public SettingViewModel() { HotKeyCollect = new ObservableCollection <HotKeyModel>(); foreach (var it in ConfigMgr.Instance.HardwareCfgMgr.AxisSettings) { var MotionCard = MotionMgr.Instance.FindMotionCardByAxisIndex(it.AxisNo); if (MotionCard != null) { int axisNo = MotionCard.AxisArgsList[it.AxisNo - MotionCard.MIN_AXIS].AxisNo; string axisName = MotionCard.AxisArgsList[it.AxisNo - MotionCard.MIN_AXIS].AxisName; string backwardKey = ""; string forwardKey = ""; if (axisName == "X") { backwardKey = "Left"; forwardKey = "Right"; } else if (axisName == "Y2") { backwardKey = "Up"; forwardKey = "Down"; } HotKeyCollect.Add(new HotKeyModel() { AxisName = axisName, AxisNo = axisNo, BackwardKeyValue = backwardKey, ForwardKeyValue = forwardKey }); } else { HotKeyCollect.Add(new HotKeyModel()); } } //初始化Google控件皮肤 Swatches = new SwatchesProvider().Swatches; PaletteHelper paletteHelper = new PaletteHelper(); paletteHelper.ReplacePrimaryColor(Swatches.Where(a => a.Name == "blue").First()); //初始化Model Messenger.Default.Send("", "UpdateModelFiles"); //更新耦合参数列表 AlignArgsBaseFCollect = new ObservableCollection <AlignArgsBaseF>(); foreach (var it in ConfigMgr.Instance.ProcessDataMgr.BlindSearArgs) { AlignArgsBaseFCollect.Add(it); } }
public ColourProvider() { var swatches = new SwatchesProvider().Swatches.AsArray(); Swatches = swatches.ToDictionary(s => s.Name); var accents = swatches.Where(s => s.IsAccented).ToArray(); var orders = new Dictionary <string, int>(StringComparer.OrdinalIgnoreCase); ThemeConstants.Themes.Select((str, idx) => new { str, idx }) .ForEach(x => orders[x.str] = x.idx); Hues = accents .OrderBy(x => orders.Lookup(x.Name).ValueOr(() => 100)) .SelectMany(swatch => { return(swatch.AccentHues.Select(hue => new Hue(swatch.Name, hue.Name, hue.Foreground, hue.Color))); }) .ToArray(); HueCache = Hues.ToDictionary(h => h.Key); }