Beispiel #1
0
        public static void LoadSettings()
        {
            try
            {
                try
                {
                    Helper.Passcode = Views.Security.Passcode.Build();
                }
                catch { }
                try
                {
                    var obj = ApplicationSettingsHelper.LoadSettingsValue(nameof(Settings));
                    if (obj is string str && !string.IsNullOrEmpty(str))
                    {
                        var settings = JsonConvert.DeserializeObject <MinistaSettings>(str);
                        if (settings != null)
                        {
                            Settings = settings;
                        }
                    }
                }
                catch { Settings = new MinistaSettings(); }
                try
                {
                    var obj = ApplicationSettingsHelper.LoadSettingsValue(nameof(Helper.InstaApiSelectedUsername));
                    if (obj is string str)
                    {
                        Helper.InstaApiSelectedUsername = str;
                    }
                }
                catch { }

                try
                {
                    if (Settings.ElementSound)
                    {
                        ElementSoundPlayer.State = ElementSoundPlayerState.On;
                    }
                }
                catch { }

                try
                {
                    MinistaThemeCore themeCore = null;
                    MinistaTheme     theme     = null;
                    switch (Settings.AppTheme)
                    {
                    case AppTheme.Custom:
                        if (Settings.CurrentTheme != null)
                        {
                            themeCore = Settings.CurrentTheme;
                        }
                        theme = Settings.CurrentTheme?.Theme ?? new MinistaDarkTheme();
                        break;

                    case AppTheme.Light:
                        themeCore = GetMeTheme("Light");
                        theme     = new MinistaWhiteTheme();
                        break;

                    case AppTheme.Dark:
                    default:
                        themeCore = GetMeTheme("Dark");
                        theme     = new MinistaDarkTheme();
                        break;
                    }
                    if (themeCore == null)
                    {
                        themeCore = GetUnkownTheme();
                    }
                    themeCore.Theme       = theme;
                    Settings.CurrentTheme = themeCore;
                    ThemeHelper.InitTheme(themeCore);
                }
                catch { }
            }
            catch { }
        }