internal void RaiseSelectionEvents(SelectionChangedEventArgs e) { int numSelected = OwningCalendar.SelectedDates.Count; int numAdded = e.AddedItems.Count; if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementSelected) && numSelected == 1 && numAdded == 1) { CalendarDayButton selectedButton = OwningCalendar.FindDayButtonFromDay((DateTime)e.AddedItems[0]); if (selectedButton != null) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(selectedButton); if (peer != null) { peer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementSelected); } } } else { if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementAddedToSelection)) { foreach (DateTime date in e.AddedItems) { CalendarDayButton selectedButton = OwningCalendar.FindDayButtonFromDay(date); if (selectedButton != null) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(selectedButton); if (peer != null) { peer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementAddedToSelection); } } } } if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection)) { foreach (DateTime date in e.RemovedItems) { CalendarDayButton removedButton = OwningCalendar.FindDayButtonFromDay(date); if (removedButton != null) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(removedButton); if (peer != null) { peer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection); } } } } } }
/// <summary> /// Sends a request to activate the control and to initiate its single, /// unambiguous action. /// </summary> void IInvokeProvider.Invoke() { if (EnsureSelection()) { OwningCalendar.SelectedDates.Clear(); if (OwningCalendarDayButton.DataContext != null) { OwningCalendar.SelectedDates.Add((DateTime)OwningCalendarDayButton.DataContext); OwningCalendar.OnDayClick((DateTime)OwningCalendarDayButton.DataContext); } } }
/// <summary> /// Sends a request to activate the control and to initiate its single, /// unambiguous action. /// </summary> void IInvokeProvider.Invoke() { if (EnsureSelection()) { OwningCalendar.SelectedDates.Clear(); DateTime?date = OwningCalendarDayButton.GetDateNullable(); if (date != null) { OwningCalendar.SelectedDates.Add(date.Value); OwningCalendar.OnDayClick(date.Value); } } }
/// <summary> /// Returns the text label of the Calendar that is associated with this /// CalendarAutomationPeer. This method is called by GetName. /// </summary> /// <returns> /// The text label of the element that is associated with this /// automation peer. /// </returns> protected override string GetNameCore() { string name = base.GetNameCore(); if (string.IsNullOrEmpty(name)) { AutomationPeer labeledBy = GetLabeledByCore(); if (labeledBy != null) { name = labeledBy.GetName(); } if (string.IsNullOrEmpty(name)) { name = OwningCalendar.ToString(); } } return(name); }