/// <summary> /// Clears any existing selection and then selects the current element. /// </summary> void ISelectionItemProvider.Select() { GlobalCalendarButton button = OwningCalendarButton; if (!button.IsEnabled) { throw new ElementNotEnabledException(); } GlobalCalendar calendar = OwningCalendar; if (calendar != null && button.Visibility != Visibility.Collapsed && !button.IsCalendarButtonFocused) { foreach (GlobalCalendarButton child in calendar.MonthControl.YearView.Children) { if (child.IsCalendarButtonFocused) { child.IsCalendarButtonFocused = false; break; } } button.IsCalendarButtonFocused = true; } }
/// <summary> /// Retrieves a UI automation provider for each child element that is /// selected. /// </summary> /// <returns> /// A collection of UI automation providers. /// </returns> IRawElementProviderSimple[] ISelectionProvider.GetSelection() { List <IRawElementProviderSimple> providers = new List <IRawElementProviderSimple>(); if (OwningGrid != null) { if (OwningCalendar.DisplayMode == CalendarMode.Month && OwningCalendar.SelectedDates != null && OwningCalendar.SelectedDates.Count != 0) { // return selected DayButtons foreach (UIElement child in OwningGrid.Children) { int childRow = (int)child.GetValue(Grid.RowProperty); if (childRow != 0) { GlobalCalendarDayButton dayButton = child as GlobalCalendarDayButton; if (dayButton != null && dayButton.IsSelected) { AutomationPeer peer = CreatePeerForElement(dayButton); if (peer != null) { providers.Add(ProviderFromPeer(peer)); } } } } } else { // return the GlobalCalendarButton which has focus foreach (UIElement child in OwningGrid.Children) { GlobalCalendarButton calendarButton = child as GlobalCalendarButton; if (calendarButton != null && calendarButton.IsCalendarButtonFocused) { AutomationPeer peer = CreatePeerForElement(calendarButton); if (peer != null) { providers.Add(ProviderFromPeer(peer)); } break; } } } if (providers.Count > 0) { return(providers.ToArray()); } } return(null); }
/// <summary> /// Returns the string that describes the functionality of the /// GlobalCalendarButton that is associated with this /// GlobalCalendarButtonAutomationPeer. This method is called by GetHelpText. /// </summary> /// <returns> /// The help text, or String.Empty if there is no help text. /// </returns> protected override string GetHelpTextCore() { GlobalCalendarButton button = OwningCalendarButton; if (button != null && button.DataContext is DateTime) { DateTime date = (DateTime)OwningCalendarButton.DataContext; return(OwningCalendar.Info.DateToLongString(date)); } return(base.GetHelpTextCore()); }
/// <summary> /// Initializes a new instance of the /// <see cref="T:System.Windows.Automation.Peers.GlobalCalendarButtonAutomationPeer" /> /// class. /// </summary> /// <param name="owner"> /// The /// <see cref="T:System.Windows.Controls.Primitives.GlobalCalendarButton" /> /// to associate with this /// <see cref="T:System.Windows.Automation.Peers.AutomationPeer" />. /// </param> public GlobalCalendarButtonAutomationPeer(GlobalCalendarButton owner) : base(owner) { }