UpdateCurrentSettings() public method

public UpdateCurrentSettings ( Settings settings ) : Settings
settings Settings
return Settings
コード例 #1
0
        /// <summary>
        /// Starts intialization of view model.
        /// </summary>
        private void InitializeViewModeExecute()
        {
            if (!this.wasInitialization)
            {
                this.wasInitialization = true;
                using (var settingsRepository = new SettingsRepository())
                {
                    if (!IsolatedStorageSettings.ApplicationSettings.Contains(_firstLaunchKey))
                    {
                        IsolatedStorageSettings.ApplicationSettings[_firstLaunchKey] = wasInitialization;
                        var result = MessageBox.Show("Would you like this application to use your phone's GPS function?", "GPS", MessageBoxButton.OKCancel);
                        var currentSettings = settingsRepository.GetCurrentSettings();
                        currentSettings.IsGpsEnabled = result == MessageBoxResult.OK;
                        settingsRepository.UpdateCurrentSettings(currentSettings);
                    }

                    bool userAcceptedEula = false;
                    var store = IsolatedStorageSettings.ApplicationSettings;
                    if (store.Contains(EULA_KEY))
                        userAcceptedEula = (bool)store[EULA_KEY];

                    if (!userAcceptedEula)
                    {
                        NotificationTool.Show(
                            "Privacy Policy",
                            "NDG",
                            new NotificationAction("Accept", () => { AcceptedPrivacy(); }),
                            new NotificationAction("Decline", () => { DeclinedPrivacy(); }));
                    }

                    GpsTracker.Instance.GpsAllowed = settingsRepository.GetCurrentSettings().IsGpsEnabled;
                    GpsTracker.Instance.StartTracking();
                }                
            }

            if (Membership.CurrentUser == null)
            {
                this.Login = string.Empty;
                this.Password = string.Empty;
                using (var settingsRepository = new SettingsRepository())
                    this.ServerPath = settingsRepository.GetCurrentSettings().Server.Address;
            }

            var pageParameters = NavigationProvider.GetNavigationParameters();
            if (pageParameters.ContainsKey(SEVER_PATH_PARAMETER))
            {
                this.ServerPath = pageParameters[SEVER_PATH_PARAMETER];
            }
        }