/// <summary> /// Inherited code: Requires comment. /// </summary> /// <param name="childButton">Inherited code: Requires comment 1.</param> /// <param name="dateToAdd">Inherited code: Requires comment 2.</param> private void SetButtonState(CalendarDayButton childButton, DateTime dateToAdd) { if (Owner != null) { childButton.Opacity = 1; // If the day is outside the DisplayDateStart/End boundary, do // not show it if (DateTimeHelper.CompareDays(dateToAdd, Owner.DisplayDateRangeStart) < 0 || DateTimeHelper.CompareDays(dateToAdd, Owner.DisplayDateRangeEnd) > 0) { childButton.IsEnabled = false; childButton.Opacity = 0; } else { // SET IF THE DAY IS SELECTABLE OR NOT if (Owner.BlackoutDates.Contains(dateToAdd)) { childButton.IsBlackout = true; } else { childButton.IsBlackout = false; } childButton.IsEnabled = true; // SET IF THE DAY IS INACTIVE OR NOT: set if the day is a // trailing day or not childButton.IsInactive = (DateTimeHelper.CompareYearMonth(dateToAdd, Owner.DisplayDateInternal) != 0); // SET IF THE DAY IS TODAY OR NOT childButton.IsToday = (Owner.IsTodayHighlighted && dateToAdd == DateTime.Today); // SET IF THE DAY IS SELECTED OR NOT childButton.IsSelected = false; foreach (DateTime item in Owner.SelectedDates) { // Since we should be comparing the Date values not // DateTime values, we can't use // Owner.SelectedDates.Contains(dateToAdd) directly childButton.IsSelected |= (DateTimeHelper.CompareDays(dateToAdd, item) == 0); } // SET THE FOCUS ELEMENT if (Owner.LastSelectedDate != null) { if (DateTimeHelper.CompareDays(Owner.LastSelectedDate.Value, dateToAdd) == 0) { if (Owner.FocusButton != null) { Owner.FocusButton.IsCurrent = false; } Owner.FocusButton = childButton; if (Owner.HasFocusInternal) { Owner.FocusButton.IsCurrent = true; } } else { childButton.IsCurrent = false; } } } } }
/// <summary> /// Inherited code: Requires comment. /// </summary> private void PopulateGrids() { if (MonthView != null) { for (int i = 0; i < Calendar.RowsPerMonth; i++) { if (_dayTitleTemplate != null) { FrameworkElement cell = (FrameworkElement) _dayTitleTemplate.LoadContent(); cell.SetValue(Grid.RowProperty, 0); cell.SetValue(Grid.ColumnProperty, i); MonthView.Children.Add(cell); } } for (int i = 1; i < Calendar.RowsPerMonth; i++) { for (int j = 0; j < Calendar.ColumnsPerMonth; j++) { CalendarDayButton cell = new CalendarDayButton(); if (Owner != null) { cell.Owner = Owner; if (Owner.CalendarDayButtonStyle != null) { cell.Style = Owner.CalendarDayButtonStyle; } } cell.SetValue(Grid.RowProperty, i); cell.SetValue(Grid.ColumnProperty, j); cell.CalendarDayButtonMouseDown += new EventHandler<PointerRoutedEventArgs>(Cell_MouseLeftButtonDown); cell.CalendarDayButtonMouseUp += new EventHandler<PointerRoutedEventArgs>(Cell_PointerReleased); cell.PointerEntered += new PointerEventHandler(Cell_PointerEntered); cell.PointerExited += new PointerEventHandler(Cell_PointerExited); cell.Click += new RoutedEventHandler(Cell_Click); MonthView.Children.Add(cell); } } } if (YearView != null) { CalendarButton month; int count = 0; for (int i = 0; i < Calendar.RowsPerYear; i++) { for (int j = 0; j < Calendar.ColumnsPerYear; j++) { month = new CalendarButton(); if (Owner != null) { month.Owner = Owner; if (Owner.CalendarButtonStyle != null) { month.Style = Owner.CalendarButtonStyle; } } month.SetValue(Grid.RowProperty, i); month.SetValue(Grid.ColumnProperty, j); month.CalendarButtonMouseDown += new EventHandler<PointerRoutedEventArgs>(Month_CalendarButtonMouseDown); month.CalendarButtonMouseUp += new EventHandler<PointerRoutedEventArgs>(Month_CalendarButtonMouseUp); month.PointerEntered += new PointerEventHandler(Month_PointerEntered); month.PointerExited += new PointerEventHandler(Month_PointerExited); YearView.Children.Add(month); count++; } } } }
/// <summary> /// Inherited code: Requires comment. /// </summary> /// <param name="b">Inherited code: Requires comment 1.</param> private void AddSelection(CalendarDayButton b) { if (Owner != null) { Owner.HoverEndIndex = b.Index; Owner.HoverEnd = (DateTime) b.DataContext; if (Owner.HoverEnd != null && Owner.HoverStart != null) { // this is selection with Mouse, we do not guarantee the // range does not include BlackOutDates. AddRange method // will throw away the BlackOutDates based on the // SelectionMode Owner.IsMouseSelection = true; Owner.SelectedDates.AddRange(Owner.HoverStart.Value, Owner.HoverEnd.Value); Owner.OnDayClick((DateTime) b.DataContext); } } }
/// <summary> /// Inherited code: Requires comment. /// </summary> /// <param name="sender">Inherited code: Requires comment 1.</param> /// <param name="e">Inherited code: Requires comment 2.</param> internal void Cell_PointerExited(object sender, PointerRoutedEventArgs pointerRoutedEventArgs) { if (_isMouseLeftButtonDown) { CalendarDayButton b = sender as CalendarDayButton; // The button is in Pressed state. Change the state to normal. b.ReleasePointerCapture(pointerRoutedEventArgs.Pointer); // null check is added for unit tests if (_downEventArg != null) { b.SendPointerReleased(_downEventArg); } _lastCalendarDayButton = b; } }
/// <summary> /// Inherited code: Requires comment. /// </summary> /// <param name="dayButton">Inherited code: Requires comment 1.</param> /// <param name="oldDayButtonStyle">Inherited code: Requires comment 2.</param> /// <param name="newDayButtonStyle">Inherited code: Requires comment 3.</param> private static void EnsureDayButtonStyle(CalendarDayButton dayButton, Style oldDayButtonStyle, Style newDayButtonStyle) { Debug.Assert(dayButton != null, "The dayButton should not be null!"); if (newDayButtonStyle != null) { // REMOVE_RTM: Remove null check when Silverlight allows us to re-apply styles // Apply the newDayButtonStyle if the DayButton was using the // oldDayButtonStyle before if (dayButton != null && (dayButton.Style == null || dayButton.Style == oldDayButtonStyle)) { dayButton.Style = newDayButtonStyle; } } }
/// <summary> /// Initializes a new instance of the /// <see cref="T:WinRTXamlToolkit.Automation.Peers.CalendarDayButtonAutomationPeer" /> /// class. /// </summary> /// <param name="owner"> /// The /// <see cref="T:WinRTXamlToolkit.Controls.Primitives.CalendarDayButton" /> /// instance that is associated with this /// <see cref="T:WinRTXamlToolkit.Automation.Peers.CalendarDayButtonAutomationPeer" />. /// </param> public CalendarDayButtonAutomationPeer(CalendarDayButton owner) : base(owner) { }