private void InitializeViewModelExecute() { this.BusyCount++; this.IsNoResponses = false; this.IsResponsesVisible = false; Locator.NavigationStatic.NavigateToQuestionsCommand.RaiseCanExecuteChanged(); _surveyInfoLoader = new BackgroundWorker(); this.CurrentSurvey = new Survey(); this.SubmittedResponses = new ObservableCollection <ResponseSet>(); this.InProgressResponses = new ObservableCollection <ResponseSet>(); this.CompletedResponses = new ObservableCollection <ResponseSet>(); this.surveyRepository = new SurveyRepository(); var pageParameters = NavigationProvider.GetNavigationParameters(); if (pageParameters.ContainsKey(SURVEY_ID)) { this.currentSurveyId = int.Parse(pageParameters[SURVEY_ID]); this.CurrentSurvey = surveyRepository.GetSurveyByID(this.currentSurveyId); } _surveyInfoLoader.DoWork += new DoWorkEventHandler(LoadSurveyInformation); this.IsNoResponses = this.CurrentSurvey.ResponseSet.Count == 0; this.IsResponsesVisible = !this.IsNoResponses; _surveyInfoLoader.RunWorkerAsync(); }
/// <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]; } }
private void InitializeViewModelExecute() { this.BusyCount++; this.IsSaveButtonVisible = true; Locator.NavigationStatic.NavigateToSaveResponsesCommand.RaiseCanExecuteChanged(); this.categoriesWorker = new BackgroundWorker(); this.CurrentPageIndex = QuestionPageIndexes.Questions; this.CurrentSurvey = new Survey(); this.currentResponsesSetId = 0; this.Categories = new ObservableCollection <Category>(); this.surveyRepository = new SurveyRepository(); this.categoryRepository = new CategoryRepository(); this.responseSetRepository = new ResponseSetRepository(); pageParameters = NavigationProvider.GetNavigationParameters(); categoriesWorker.DoWork += this.LoadContent; categoriesWorker.RunWorkerAsync(); }
private void PopulateSurveys() { if (NavigationProvider.CurrentSource.OriginalString.Contains(HOME_PAGE_STRING) && this.allSurveyses == null || this.allSurveyses.Count == 0) { this.allSurveyses = new ObservableCollection <Survey>(_surveyRepository.GetAllUserSurveys(Membership.CurrentUser.ID)); } var pageParameters = NavigationProvider.GetNavigationParameters(); if (pageParameters.ContainsKey(IS_FOR_SEARCHING)) { this.DisplayedSurveyses = this.allSurveyses; this.SearchSurveys(); } else { this.TopSurveys = new ObservableCollection <Survey>(this._surveyRepository.GetUserTopSurveys(TOP_SURVYES_COUNT, Membership.CurrentUser.ID)); } }