private void OnRemoveSelectedButtonClick(object sender, RoutedEventArgs e) { if (SurveySearchList.SelectedIndex != -1) { SurveyBasicInfo selectedListBoxItem = SurveySearchList.SelectedItem as SurveyBasicInfo; _filterViewModel.Filter.SurveyFiltration.RemoveSelectedSurvey(selectedListBoxItem); } }
private void ChooseSurvey(object sender, SelectionChangedEventArgs e) { _isNewPageInstance = false; if (ListOfSurveysBox.SelectedIndex == -1) { return; } SurveyBasicInfo selectedItem = (SurveyBasicInfo)ListOfSurveysBox.SelectedItem; string strSurveyName = selectedItem.Name; string strSurveyId = selectedItem.SurveyId; bool isFavorite = selectedItem.IsFavorite; if (strSurveyId != null && strSurveyName != null) { NavigationService.Navigate(new Uri(string.Format("/View/SurveyPage.xaml?SurveyName={0}&SurveyId={1}&isFavorite={2}", strSurveyName, strSurveyId, isFavorite), UriKind.Relative)); } ListOfSurveysBox.SelectedIndex = -1; }
/// <summary> /// Callback used to process server response. /// </summary> /// <param name="result">Server response state.</param> public void DownloadCallback(IAsyncResult result) { if (_aborted) { System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { _downloadStatus.ProgressBar.IsEnabled = false; }); _aborted = false; return; } try { _request = (WebRequest)result.AsyncState; var response = (WebResponse)_request.EndGetResponse(result); using (var stream = response.GetResponseStream()) using (var reader = new StreamReader(stream)) { var contents = reader.ReadToEnd(); XDocument documentXML = XDocument.Parse(contents); var root = documentXML.Element("surveys"); var surveys = root.Elements("survey"); int howMany = 0; foreach (XElement xSurvey in surveys) { if (_operationsOnListOfSurveys.IsSurveySaved(xSurvey.Attribute("id").Value)) { continue; } ++howMany; SurveyBasicInfo survey = new SurveyBasicInfo() { Name = xSurvey.Attribute("title").Value, SurveyId = xSurvey.Attribute("id").Value }; System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { _list.Add(survey); }); } System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { _downloadStatus.ProgressBar.IsEnabled = false; if (howMany == 0) { _downloadStatus.StatusMessage = Languages.AppResources.checkForNewSurveyList_ZeroNewSurvey; _downloadStatus.Show = true; } else { if (howMany == 1) { _downloadStatus.Message.Show(Languages.AppResources.checkForNewSurveyList_OneNewSurvey); } else { _downloadStatus.Message.Show(string.Format(Languages.AppResources.checkForNewSurveyList_ManyNewSurveys, howMany)); } _downloadStatus.Show = false; _downloadStatus.IsDownloadButtonEnabled = true; } }); } } catch (WebException e) { var status = ((HttpWebResponse)e.Response).StatusCode; string message = string.Empty; switch (status) { case HttpStatusCode.NotFound: message = Languages.AppResources.checkForNewSurveyList_ServerNotFound; break; default: message = Languages.AppResources.checkForNewSurveyList_ServerError; break; } System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { _downloadStatus.ProgressBar.IsEnabled = false; _downloadStatus.Message.Show(message); }); } catch (XmlException) { System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { _downloadStatus.ProgressBar.IsEnabled = false; _downloadStatus.Message.Show(Languages.AppResources.checkForNewSurveyList_ServerIncompleteResponse); }); } }