/// <summary> /// Clears any existing selection and then selects the current element. /// </summary> void ISelectionItemProvider.Select() { CalendarExButton button = OwningCalendarButton; if (!button.IsEnabled) { throw new ElementNotEnabledException(); } CalendarEx calendar = OwningCalendar; if (calendar != null && button.Visibility != Visibility.Collapsed && !button.IsCalendarButtonFocused) { foreach (CalendarExButton child in calendar.MonthControl.YearView.Children) { if (child.IsCalendarButtonFocused) { child.IsCalendarButtonFocused = false; break; } } button.IsCalendarButtonFocused = true; } }
/// <summary> /// Returns the text label of the CalendarButton that is associated with /// this CalendarButtonAutomationPeer. This method is called by GetName. /// </summary> /// <returns> /// The text label of the element that is associated with this /// automation peer. /// </returns> /// <remarks> /// The name property can be thought of as the string of text that a /// user would use to explain which control is being referred to. It is /// important to have a textual representation for all controls in the /// graphical user interface (GUI) so that you can programmatically /// refer to the control in a localized manner. The value is settable /// on control instances through the AutomationProperties.Name attached /// property. /// </remarks> protected override string GetNameCore() { string name = base.GetNameCore(); if (string.IsNullOrEmpty(name)) { AutomationPeer labeledBy = GetLabeledByCore(); if (labeledBy != null) { name = labeledBy.GetName(); } CalendarExButton button = this.OwningCalendarButton; if (string.IsNullOrEmpty(name) && button != null) { if (button.DataContext is DateTime) { if (this.OwningCalendar.DisplayMode == CalendarExMode.Decade) { name = DateTimeHelper.ToYearString((DateTime)button.DataContext); } else { name = DateTimeHelper.ToYearMonthPatternString((DateTime)button.DataContext); } } else if (button.Content != null) { name = string.Format(DateTimeHelper.GetCurrentDateFormat(), button.Content.ToString()); } } } return(name); }
/// <summary> /// Returns the string that describes the functionality of the /// CalendarButton that is associated with this /// CalendarButtonAutomationPeer. 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() { CalendarExButton button = OwningCalendarButton; if (button != null && button.DataContext != null && button.DataContext is DateTime) { DateTime dataContext = (DateTime)OwningCalendarButton.DataContext; return(dataContext.Date.ToString(DateTimeHelper.GetCurrentDateFormat().LongDatePattern, DateTimeHelper.GetCurrentDateFormat())); } return(base.GetHelpTextCore()); }
/// <summary> /// Initializes a new instance of the /// <see cref="T:System.Windows.Automation.Peers.CalendarExAutomationPeer" /> /// class. /// </summary> /// <param name="owner"> /// The /// <see cref="T:System.Windows.Controls.Primitives.CalendarButton" /> /// to associate with this /// <see cref="T:System.Windows.Automation.Peers.AutomationPeer" />. /// </param> public CalendarExButtonAutomationPeer(CalendarExButton owner) : base(owner) { }