Exemplo n.º 1
0
        private void LoadSettings()
        {
            if (!File.Exists("settings.json"))
            {
                isInitalizating  = true;
                Theme            = "BaseDark"; // ThemeManager.Accents.Select(x=>x.Name).First(),
                Accent           = "Amber";    // ThemeManager.AppThemes.Select(x => x.Name).First()
                AutoSaveLocation = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                isInitalizating  = false;
                UpdateSettings();
                return;
            }

            var settings = JsonConvert.DeserializeObject <AudioViewSettings>(File.ReadAllText("settings.json"));

            isInitalizating = true;
            if (settings.Theme == null || Themes.All(x => x != settings.Theme))
            {
                settings.Theme = "BaseDark";
                SaveSettings();
            }
            Theme = settings.Theme;

            if (settings.Accent == null || Accents.All(x => x != settings.Accent))
            {
                settings.Accent = "Amber";
                SaveSettings();
            }
            Accent = settings.Accent;

            if (settings.AutoSaveLocation == null || !Directory.Exists(settings.AutoSaveLocation))
            {
                settings.AutoSaveLocation = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                SaveSettings();
            }
            AutoSaveLocation = settings.AutoSaveLocation;

            isInitalizating = false;

            ThemeManager.ChangeAppStyle(Application.Current,
                                        ThemeManager.Accents.Where(x => x.Name == Accent).First(),
                                        ThemeManager.AppThemes.Where(x => x.Name == Theme).First());

            AudioViewSettings.Overwrite(settings);
        }
Exemplo n.º 2
0
        protected override void OnOK()
        {
            if (_themeChecked && Themes.Any() && Themes.All(x => !x.IsActive))
            {
                MessageBox.Show("You should select one theme.", "Warning", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            if (_intervalBetweenImages <= 0)
            {
                MessageBox.Show("Interval between images must be greater than zero.", "Warning", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (_intervalForShowImage <= 0)
            {
                MessageBox.Show("Interval for show image must be greater than zero.", "Warning", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            base.OnOK();
        }