public ConfigurationViewModel() { // ComboBoxの初期値を設定するにはItemsSourceで利用しているインスタンスの中から指定する必要がある SelectedSwatch = new ReactivePropertySlim <Swatch>(Swatches.FirstOrDefault(s => s.Name == ThemeService.CurrentTheme.Name)); SelectedSwatch.Subscribe(s => ChangeTheme(s)).AddTo(CompositeDisposable); var backupPath = UserConfigurationManager.Instance.GetConfiguration <BackupPathConfig>(ConfigKey.BackupPath); BackupPath = new ReactivePropertySlim <string>(backupPath?.DirectoryPath); var favorites = UserConfigurationManager.Instance.GetConfiguration <FavoriteWorkTasksConfig>(ConfigKey.FavoriteWorkTask); FavoriteWorkTasks = new ObservableCollection <FavoriteWorkTask>(favorites?.FavoriteWorkTasks ?? new FavoriteWorkTask[0]); var maps = UserConfigurationManager.Instance.GetConfiguration <ScheduleTitleMapConfig>(ConfigKey.ScheduleTitleMap)?.ScheduleTitleMaps; if (maps == null || maps.Count() == 0) { // 新設定が未登録なら旧設定をとる var config = JsonFileIO.Deserialize <TimeRecorderConfiguration>("TimeRecorderConfiguration.json") ?? new TimeRecorderConfiguration(); maps = config.WorkTaskBuilderConfig.TitleMappers?.Select(t => t.ConvertToScheduleTitleMap()).ToArray(); } ScheduleTitleMaps = new ObservableCollection <ScheduleTitleMap>(maps ?? new ScheduleTitleMap[0]); ShowFavoriteDescription = new ReactivePropertySlim <bool>(FavoriteWorkTasks.Count == 0); ShowScheduleDescription = new ReactivePropertySlim <bool>(ScheduleTitleMaps.Count == 0); var url = UserConfigurationManager.Instance.GetConfiguration <WorkingHourImportApiUrlConfig>(ConfigKey.WorkingHourImportApiUrl); WorkingHourImportUrl = new ReactivePropertySlim <string>(url?.URL); }
/// <summary> /// 设置默认样式 /// </summary> /// <param name="swatch"></param> public void ApplyDefault(string skinName) { var Swatch = Swatches.FirstOrDefault(t => t.Name.Equals(skinName)); if (Swatch != null) { new PaletteHelper().ReplacePrimaryColor(Swatch); } }
private void RefreshPreview(string primary, string accent) { if (!string.IsNullOrWhiteSpace(primary)) { var primarySwatch = Swatches.FirstOrDefault(s => s.Name == primary); RefreshPrimaryPreview(primarySwatch); } if (!string.IsNullOrWhiteSpace(accent)) { var accentSwatch = Swatches.FirstOrDefault(s => s.Name == accent); RefreshAccentPreview(accentSwatch); } }
public void RestoreColors() { var primary = Swatches.FirstOrDefault(s => s.Name == Configuration.PrimaryColor); var accent = Swatches.FirstOrDefault(s => s.Name == Configuration.AccentColor); if (primary != null) { ChoosePrimaryColor(primary); } if (accent != null) { ChooseAccentColor(accent); } DarkMode = Configuration.DarkMode; }