private void Item_PointerPressedHelper(CalendarViewDayItem sender, PointerRoutedEventArgs e) { FrameworkElement element = sender as FrameworkElement; flyout = (Flyout)this.Resources["flyout"]; string[] dates = sender.Date.ToString().Split('/', ' '); if (dates[1].Length == 1) { dates[1] = "0" + dates[1]; } if (dates[0].Length == 1) { dates[0] = "0" + dates[0]; } string date = dates[2] + "-" + dates[0] + "-" + dates[1]; year = int.Parse(dates[2]); month = int.Parse(dates[0]); day = int.Parse(dates[1]); if (dateMap.ContainsKey(date)) { flyoutText.Text = (string)dateMap[date][0]; GoToDayButton.Visibility = Visibility.Visible; } else { flyoutText.Text = "No Quests Today"; GoToDayButton.Visibility = Visibility.Collapsed; } flyout.ShowAt(element); }
private void CalendarView_OnCalendarViewDayItemChanging(CalendarView sender, CalendarViewDayItemChangingEventArgs args) { if (isInitialized) { CalendarViewDayItem localItem = args.Item; if (localItem != null && !args.InRecycleQueue && localItem.DataContext == null) { localItem.DataContext = ViewModel.GetEpisodesOnDate(localItem.Date.Date); } } }
private void CalendarViewPreviousRouteInfo(CalendarView sender, CalendarViewDayItemChangingEventArgs args) { converter.DisplayCalendarRouteInfo(InfoTextBlock); date = args.Item; SolidColorBrush greenBackground = new SolidColorBrush(Windows.UI.Colors.LightGreen); if (args.Phase == 0) { args.RegisterUpdateCallback(CalendarViewPreviousRouteInfo); } args.Item.PointerPressed += UpdateCalendarView; }
private void SetBlackout(CalendarViewDayItem dayItem) { Calendar calendar = new Calendar(); calendar.SetDateTime(dayItem.Date); bool isBlackout = isSundayBlackedOut.IsChecked.Value && calendar.DayOfWeek == Windows.Globalization.DayOfWeek.Sunday; if (!isBlackout && isTodayBlackedOut.IsChecked.Value) { Calendar calendarToday = new Calendar(); calendarToday.SetToNow(); isBlackout = calendar.Day == calendarToday.Day && calendar.Month == calendarToday.Month && calendar.Year == calendarToday.Year; } dayItem.IsBlackout = isBlackout; }
private void UpdateCalendarView(object sender, PointerRoutedEventArgs e) { SolidColorBrush greenBackground = new SolidColorBrush(Windows.UI.Colors.LightGreen); date = sender as CalendarViewDayItem; foreach (var checkpoint in checkpointsList) { string rightFormat = converter.SetStringRightFormat(checkpoint.CPDateTime); DateTime dateTime = DateTime.ParseExact(rightFormat, "MM-dd-yyyy", CultureInfo.InvariantCulture); DateTime checkDate = dateTime; if ((sender as CalendarViewDayItem).Date.Date.Equals(checkDate)) { (sender as CalendarViewDayItem).Background = greenBackground; (sender as CalendarViewDayItem).BorderThickness = new Thickness(1); (sender as CalendarViewDayItem).PointerPressed += OpenPopupRouteList; } } }
private void SetDensityColors(CalendarViewDayItem dayItem) { if (hasDensityBars.IsChecked.Value) { Calendar calendar = new Calendar(); calendar.SetDateTime(dayItem.Date); DateTime today = DateTime.Now.Date; bool isToday = calendar.Day == today.Day && calendar.Month == today.Month && calendar.Year == today.Year; if (calendar.Day % 6 == 0 || isToday) { List <Color> densityColors = new List <Color>(); densityColors.Add(Colors.Green); densityColors.Add(Colors.Green); if (calendar.Day % 4 == 0 || isToday) { densityColors.Add(Colors.Blue); densityColors.Add(Colors.Blue); } if (calendar.Day % 9 == 0 || isToday) { densityColors.Add(Colors.Orange); } if (isToday) { densityColors.Add(Colors.Red); densityColors.Add(Colors.Yellow); } dayItem.SetDensityColors(densityColors); } } else { dayItem.SetDensityColors(null); } }
private void SetDensityColors(CalendarViewDayItem dayItem) { if (hasDensityBars.IsChecked.Value) { bool isToday = dayItem.Date.Date.Equals(DateTime.Now.Date); if (dayItem.Date.Day % 6 == 0 || isToday) { List <Color> densityColors = new List <Color>(); densityColors.Add(Colors.Green); densityColors.Add(Colors.Green); if (dayItem.Date.Day % 4 == 0 || isToday) { densityColors.Add(Colors.Blue); densityColors.Add(Colors.Blue); } if (dayItem.Date.Day % 9 == 0 || isToday) { densityColors.Add(Colors.Orange); } if (isToday) { densityColors.Add(Colors.Red); densityColors.Add(Colors.Yellow); } dayItem.SetDensityColors(densityColors); } } else { dayItem.SetDensityColors(null); } }
private void OnDayItemChanging(CalendarView sender, CalendarViewDayItemChangingEventArgs args) { switch (args.Phase) { case 0: RegisterUpdateCallback(); break; case 1: SetBlackoutDates(); break; case 2: SetBookings(); break; default: break; } void RegisterUpdateCallback() => args.RegisterUpdateCallback(OnDayItemChanging); async void SetBlackoutDates() { RegisterUpdateCallback(); CalendarViewDayItem item = args.Item; await Task.Delay(500); // simulate a delay for an API call if (item.Date < DateTimeOffset.Now || item.Date.DayOfWeek == DayOfWeek.Saturday || item.Date.DayOfWeek == DayOfWeek.Sunday) { item.IsBlackout = true; } } async void SetBookings() { CalendarViewDayItem item = args.Item; if (item is null) { return; } await Task.Delay(3000); // simulate a delay for an API call var bookings = GetBookings().ToList(); var booking = bookings.SingleOrDefault(b => b.day.Date == item.Date.Date); if (booking.bookings > 0) { List <Color> colors = new(); for (int i = 0; i < booking.bookings; i++) { if (item.Date.DayOfWeek == DayOfWeek.Saturday || item.Date.DayOfWeek == DayOfWeek.Sunday) { colors.Add(Colors.Red); } else { colors.Add(Colors.Green); } } item.SetDensityColors(colors); } } }
private void SetBlackout(CalendarViewDayItem dayItem) { dayItem.IsBlackout = (isSundayBlackedOut.IsChecked.Value && dayItem.Date.DayOfWeek == System.DayOfWeek.Sunday) || (isTodayBlackedOut.IsChecked.Value && dayItem.Date.Date.Equals(DateTime.Now.Date)); }
private static void UnHighlightDay(CalendarViewDayItem displayedDay) { displayedDay.Background = new SolidColorBrush(Colors.Transparent); }
private static void HighlightDay(CalendarViewDayItem displayedDay) { displayedDay.Background = new SolidColorBrush(Colors.Red); }