예제 #1
0
 /// <summary>
 /// Change UI theme
 /// </summary>
 private void ThemeCommandAction()
 {
     CurrentTheme++;
     CurrentTheme = CurrentTheme > 3 ? 0 : CurrentTheme;
     Theme        = ThemeTypes.GetTheme(CurrentTheme);
     OnPropertyChanged(nameof(Theme));
 }
        /// <summary>
        /// Gets the application user settings and updates the application with them
        /// </summary>
        private void GetUserSettings()
        {
            var jsonObject = (string)Properties.Settings.Default["Servers"];

            if (jsonObject != null)
            {
                try
                {
                    NetworkSettings = JsonConvert.DeserializeObject <ObservableCollection <NetworkConfig> >(jsonObject) ?? NetworkSettings;
                    if (NetworkSettings.Count == 0)
                    {
                        throw new Exception("Settings are empty.");
                    }
                }
                catch (Exception)
                {
                    NewConfigCommandAction();
                }
            }
            else
            {
                NewConfigCommandAction();
            }
            // Get theme
            var theme = (int)Properties.Settings.Default["Theme"];

            CurrentTheme = theme;
            Theme        = ThemeTypes.GetTheme(CurrentTheme);
            OnPropertyChanged(nameof(Theme));

            // Get selected tab
            SelectedTab = (int)Properties.Settings.Default["SelectedTab"] >= 0 ? (int)Properties.Settings.Default["SelectedTab"] : 0;

            Refresh();
        }
예제 #3
0
        /// <summary>
        /// Gets the application user settings and updates the application with them
        /// </summary>
        private void GetUserSettings()
        {
            var jsonObject = (string)Properties.Settings.Default["Servers"];

            if (jsonObject != null)
            {
                try
                {
                    HttpServer = JsonConvert.DeserializeObject <ObservableCollection <HttpServer> >(jsonObject) ?? HttpServer;
                    foreach (HttpServer server in HttpServer)
                    {
                        server.Started = false;
                        server.Stop    = false;
                    }
                    if (HttpServer.Count == 0)
                    {
                        throw new Exception("Settings are empty.");
                    }
                }
                catch (Exception)
                {
                    NewServerCommandAction();
                }
            }
            else
            {
                NewServerCommandAction();
            }
            // Get theme
            var theme = (int)Properties.Settings.Default["Theme"];

            CurrentTheme = theme;
            Theme        = ThemeTypes.GetTheme(CurrentTheme);
            OnPropertyChanged(nameof(Theme));

            // Get selected tab
            SelectedTab = (int)Properties.Settings.Default["SelectedTab"] >= 0 ? (int)Properties.Settings.Default["SelectedTab"] : 0;

            Refresh();
        }