/// <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="sender">Inherited code: Requires comment 1.</param> /// <param name="e">Inherited code: Requires comment 2.</param> private void Month_PointerExited(object sender, PointerRoutedEventArgs pointerRoutedEventArgs) { if (_isMouseLeftButtonDownYearView) { CalendarButton b = sender as CalendarButton; // The button is in Pressed state. Change the state to normal. b.ReleasePointerCapture(pointerRoutedEventArgs.Pointer); if (_downEventArgYearView != null) { b.SendPointerReleased(_downEventArgYearView); } _lastCalendarButton = b; } }
/// <summary> /// Initializes a new instance of the /// <see cref="T:WinRTXamlToolkit.Automation.Peers.CalendarButtonAutomationPeer" /> /// class. /// </summary> /// <param name="owner"> /// The /// <see cref="T:WinRTXamlToolkit.Controls.Primitives.CalendarButton" /> /// to associate with this /// <see cref="T:WinRTXamlToolkit.Automation.Peers.AutomationPeer" />. /// </param> public CalendarButtonAutomationPeer(CalendarButton owner) : base(owner) { }
/// <summary> /// Inherited code: Requires comment. /// </summary> /// <param name="calendarButton">Inherited code: Requires comment 1.</param> internal void UpdateYearViewSelection(CalendarButton calendarButton) { if (Owner != null && calendarButton != null && calendarButton.DataContext != null) { Owner.FocusCalendarButton.IsCalendarButtonFocused = false; Owner.FocusCalendarButton = calendarButton; calendarButton.IsCalendarButtonFocused = Owner.HasFocusInternal; if (Owner.DisplayMode == CalendarMode.Year) { Owner.SelectedMonth = (DateTime) calendarButton.DataContext; } else { Owner.SelectedYear = (DateTime) calendarButton.DataContext; } } }
/// <summary> /// Inherited code: Requires comment. /// </summary> /// <param name="calendarButton">Inherited code: Requires comment 1.</param> /// <param name="oldCalendarButtonStyle">Inherited code: Requires comment 2.</param> /// <param name="newCalendarButtonStyle">Inherited code: Requires comment 3.</param> private static void EnsureCalendarButtonStyle(CalendarButton calendarButton, Style oldCalendarButtonStyle, Style newCalendarButtonStyle) { Debug.Assert(calendarButton != null, "The calendarButton should not be null!"); if (newCalendarButtonStyle != null) { // REMOVE_RTM: Remove null check when Silverlight allows us to re-apply styles // Apply the newCalendarButtonStyle if the CalendarButton was // using the oldCalendarButtonStyle before if (calendarButton != null && (calendarButton.Style == null || calendarButton.Style == oldCalendarButtonStyle)) { calendarButton.Style = newCalendarButtonStyle; } } }