private void OnContextMenuDeleteClick(object sender, RoutedEventArgs e) { var tileUtility = TileUtility.Instance; var common = Common.Instance; if (SelectedItem != null) { _viewModel.Load(); var item = (from i in _viewModel.Happenings where i.Guid == SelectedItem.Guid select i).FirstOrDefault(); var result = MessageBox.Show(AppResources.DeleteMessageBoxText, AppResources.DeleteMessageBoxTitle, MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { tileUtility.RemoveTile(item); _viewModel.Delete(item); _viewModel.Load(); HappeningsListBox.DataContext = _viewModel.Happenings; } } else { common.ShowErrorMessage(); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); while (NavigationService.CanGoBack) { NavigationService.RemoveBackEntry(); } _viewModel.Load(); if (_viewModel.Happenings != null && _viewModel.Happenings.Count > 0) { AllListControl.DataContext = _viewModel.Happenings; UpcomingListControl.DataContext = _viewModel.Happenings.Where(i => i.NumberOfDaysLeft >= 0).ToList(); PassedListControl.DataContext = _viewModel.Happenings.Where(i => i.NumberOfDaysLeft < 0).ToList(); } SetupBackgroundAgent(); SetupApplicationBar(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var common = Common.Instance; var guid = GetFromQuerystring(); if (!String.IsNullOrEmpty(guid)) { viewModel.Load(); CurrentItem = (from i in viewModel.Happenings where i.Guid == guid select i).FirstOrDefault(); if (CurrentItem != null) { PageTitle.Text = CurrentItem.Name; dateInfoTextBlock.Text = String.Format("{0} {1} {2} {3}", common.GetDayOfWeek(CurrentItem.Date.DayOfWeek), CurrentItem.Date.Day, common.GetMonth(CurrentItem.Date.Month), CurrentItem.Date.Year); numberOfdaysLeftTextBlock.Text = CurrentItem.NumberOfDaysLeft.ToString(); itemImage.Source = CurrentItem.SavedImage; if (CurrentItem.NumberOfDaysLeft.ToString().StartsWith("-")) { monthsAndDaysLeftTextBlock.Text = AppResources.HappeningOver; daysTextBlock.Text = AppResources.Days; } else { monthsAndDaysLeftTextBlock.Text = String.IsNullOrEmpty(CurrentItem.MonthsAndDaysLeftText) ? String.Format("{0} {1}", AppResources.Occurs, AppResources.Today) : String.Format("{0} {1}", AppResources.OccursIn, CurrentItem.MonthsAndDaysLeftText); daysTextBlock.Text = AppResources.DaysLeft; } } SetupApplicationBar(); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); _viewModel.Load(); var guid = GetFromQuerystring(); if (!String.IsNullOrEmpty(guid)) { PageTitle.Text = AppResources.Edit; CurrentItem = (from i in _viewModel.Happenings where i.Guid == guid select i).FirstOrDefault(); if (CurrentItem != null) { NameTextBox.Text = CurrentItem.Name; DatePicker.Value = CurrentItem.Date; ItemImage.Source = CurrentItem.SavedImage; ShowMonthsAndDaysOnLiveTileCheckBox.IsChecked = CurrentItem.ShowMonthsAndDaysOnLiveTile; } } SetupApplicationBar(); }