Beispiel #1
0
        public void Reset()
        {
            var accent = Settings.GetById(SettingKeys.Accent).Value;
            var theme  = Settings.GetById(SettingKeys.Theme).Value;

            SelectedAccent = AvailableAccents.FirstOrDefault(a => a.Name == accent);
            SelectedTheme  = AvailableThemes.FirstOrDefault(t => t.Name == theme);

            ExpandEntries    = Settings.GetById(SettingKeys.ExpandEntries).Get <bool>();
            StartMinimized   = Settings.GetById(SettingKeys.StartMinimized).Get <bool>();
            StartWithWindows = Settings.GetById(SettingKeys.StartWithWindows).Get <bool>();
            CloseToTray      = Settings.GetById(SettingKeys.CloseToTray).Get <bool>();

            var lang = Settings.GetById(SettingKeys.Language).Value;

            ChangeLanguage   = false;
            SelectedLanguage = AvailableLanguages.FirstOrDefault(l => l.IetfLanguageTag.Equals(lang)) ??
                               AvailableLanguages.FirstOrDefault(l => l.IetfLanguageTag.Equals("en-US"));
            ChangeLanguage = true;

            var path = Settings.GetById(SettingKeys.DatabasePath)?.Value;

            if (string.IsNullOrWhiteSpace(path))
            {
                path = Constants.DefaultDatabasePath;
            }

            DatabasePath = path;
        }
        public SettingsWindowViewmodel(MainWindow main, AppSettings data)
        {
            mainWindow = main;
            Settings   = data;

            ShortcutList = ShortcutManager.ListObservableShortcuts(data);

            AvailableThemes   = App.Themes.GetAllAvailableThemes();
            AvailableModifier = App.Themes.GetAllAvailableModifier().Select(m => new CheckableAlephTheme {
                Theme = m, Owner = this, Checked = data.ThemeModifier.Contains(m.SourceFilename)
            }).ToList();

            _selectedTheme = App.Themes.GetThemeByFilename(Settings.Theme, out _)
                             ?? App.Themes.GetDefault()
                             ?? AvailableThemes.FirstOrDefault()
                             ?? App.Themes.GetFallback();

            _oldTheme     = ThemeManager.Inst.CurrentBaseTheme;
            _oldModifiers = ThemeManager.Inst.CurrentModifers.ToList();

            SnippetList = new ObservableCollectionNoReset <EditableSnippet>(data.Snippets.Data.Select(p => new EditableSnippet {
                PreviewFunc = SnippetPrev, ID = p.Key, Name = p.Value.DisplayName, Value = p.Value.Value
            }));
            NewSnippetID = GetNextSnippetID();
        }
        public SettingsWindowViewmodel(MainWindow main, AppSettings data)
        {
            mainWindow = main;
            Settings   = data;

            ShortcutList    = ShortcutManager.ListObservableShortcuts(data);
            AvailableThemes = App.Themes.GetAllAvailable();

            _selectedTheme = App.Themes.GetByFilename(Settings.Theme, out _)
                             ?? App.Themes.GetByFilename("default.xml", out _)
                             ?? AvailableThemes.FirstOrDefault()
                             ?? App.Themes.GetFallback();
        }