/// <summary> /// Inherited code: Requires comment. /// </summary> /// <param name="cal">Inherited code: Requires comment 1.</param> /// <param name="value">Inherited code: Requires comment 2.</param> /// <returns>Inherited code: Requires comment 3.</returns> private static bool IsValidKeyboardSelection(Calendar cal, object value) { if (value == null) { return true; } else { if (cal.BlackoutDates.Contains((DateTime) value)) { return false; } else { return (DateTime.Compare((DateTime) value, cal.DisplayDateRangeStart) >= 0 && DateTime.Compare((DateTime) value, cal.DisplayDateRangeEnd) <= 0); } } }
/// <summary> /// Inherited code: Requires comment. /// </summary> /// <param name="cal">Inherited code: Requires comment 1.</param> /// <param name="value">Inherited code: Requires comment 2.</param> /// <returns>Inherited code: Requires comment 3.</returns> internal static bool IsValidDateSelection(Calendar cal, object value) { if (value == null) { return true; } else { if (cal.BlackoutDates.Contains((DateTime) value)) { return false; } else { if (DateTime.Compare((DateTime) value, cal.DisplayDateRangeStart) < 0) { cal.SetValueNoCallback(Calendar.DisplayDateStartProperty, value); } else if (DateTime.Compare((DateTime) value, cal.DisplayDateRangeEnd) > 0) { cal.SetValueNoCallback(Calendar.DisplayDateEndProperty, value); } return true; } } }
/// <summary> /// Inherited code: Requires comment. /// </summary> /// <param name="cal">Inherited code: Requires comment 1.</param> /// <returns>Inherited code: Requires comment 2.</returns> private static DateTime? SelectedDateMax(Calendar cal) { DateTime selectedDateMax; if (cal.SelectedDates.Count > 0) { selectedDateMax = cal.SelectedDates[0]; Debug.Assert(DateTime.Compare(cal.SelectedDate.Value, selectedDateMax) == 0, "The SelectedDate should be the maximum SelectedDate!"); } else { return null; } foreach (DateTime selectedDate in cal.SelectedDates) { if (DateTime.Compare(selectedDate, selectedDateMax) > 0) { selectedDateMax = selectedDate; } } return selectedDateMax; }
/// <summary> /// Updates the display date. /// </summary> /// <param name="c">Calendar instance.</param> /// <param name="addedDate">Added date.</param> /// <param name="removedDate">Removed date.</param> private static void UpdateDisplayDate(Calendar c, DateTime addedDate, DateTime removedDate) { Debug.Assert(c != null, "c should not be null!"); // If DisplayDate < DisplayDateStart, DisplayDate = DisplayDateStart if (DateTime.Compare(addedDate, c.DisplayDateRangeStart) < 0) { c.DisplayDate = c.DisplayDateRangeStart; return; } // If DisplayDate > DisplayDateEnd, DisplayDate = DisplayDateEnd if (DateTime.Compare(addedDate, c.DisplayDateRangeEnd) > 0) { c.DisplayDate = c.DisplayDateRangeEnd; return; } c.DisplayDateInternal = DateTimeHelper.DiscardDayTime(addedDate); c.UpdateMonths(); c.OnDisplayDate(new CalendarDateChangedEventArgs(removedDate, addedDate)); }
/// <summary> /// Raise an automation peer event for the selection of a day button. /// </summary> /// <param name="calendar"> /// The Calendar associated with this automation peer. /// </param> /// <param name="date">The selected date.</param> /// <param name="eventToRaise">The selection event to raise.</param> private static void RaiseDayButtonSelectionEvent(Calendar calendar, DateTime date, AutomationEvents eventToRaise) { CalendarDayButton button = calendar.FindDayButtonFromDay(date); if (button != null) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(button); if (peer != null) { peer.RaiseAutomationEvent(eventToRaise); } } }
/// <summary> /// Initializes a new instance of the /// <see cref="T:WinRTXamlToolkit.Automation.Peers.CalendarAutomationPeer" /> /// class. /// </summary> /// <param name="owner"> /// The <see cref="T:WinRTXamlToolkit.Controls.Calendar" /> instance to /// associate with the /// <see cref="T:WinRTXamlToolkit.Automation.Peers.CalendarAutomationPeer" />. /// </param> public CalendarAutomationPeer(Calendar owner) : base(owner) { }