public override void OnApplyTemplate() { base.OnApplyTemplate(); this.PopupEnabled = true; this.textbox = base.GetTemplateChild("PART_TextBox") as TextBox; this.popup = base.GetTemplateChild("PART_Popup") as Popup; this.list = base.GetTemplateChild("PART_ListBox") as ListBox; this.GotFocus += new RoutedEventHandler(AutoComplete_GotFocus); if (this.textbox != null) { AutomationProperties.SetName(this.textbox, AutomationProperties.GetName(this)); this.textbox.LostFocus += this.TextBoxLostFocus; this.textbox.KeyUp += new KeyEventHandler(TextBoxKeyUp); } if (this.popup != null && this.list != null) { this.list.KeyUp += new KeyEventHandler(ListBoxKeyUp); this.list.MouseUp += new MouseButtonEventHandler(ListBoxMouseUp); } Window mainWindow = Window.GetWindow(this); if (mainWindow != null) { mainWindow.LocationChanged += this.OnMainWindowLocationChanged; mainWindow.Deactivated += new EventHandler(OnMainWindowDeactivated); } }
private void FocusOnControl(FrameworkElement focusedControl) { if (focusedControl == null) { ClearContent(); return; } if (controlName != null) { controlName.Text = focusedControl.Name; } if (controlType != null) { controlType.Text = focusedControl.GetType().Name; } if (controlAutomationName != null) { controlAutomationName.Text = AutomationProperties.GetName(focusedControl); } if (controlFirstParentWithName != null) { var parentWithName = FindVisualAscendantWithName(focusedControl); controlFirstParentWithName.Text = parentWithName?.Name ?? string.Empty; } }
private void UpdateTimer_Tick(object sender, object e) { var focusedControl = FocusManager.GetFocusedElement() as FrameworkElement; if (focusedControl == null) { ClearContent(); return; } if (controlName != null) { controlName.Text = focusedControl.Name; } if (controlType != null) { controlType.Text = focusedControl.GetType().Name; } if (controlAutomationName != null) { controlAutomationName.Text = AutomationProperties.GetName(focusedControl); } if (controlFirstParentWithName != null) { var parentWithName = FindVisualAscendantWithName(focusedControl); controlFirstParentWithName.Text = parentWithName?.Name ?? string.Empty; } }
private static void UpdateSource(FrameworkElement element, string automationUIName) { var inputBinding = Application.Current.MainWindow.InputBindings .OfType <InputBinding>() .SingleOrDefault(x => AutomationProperties.GetName(x) == automationUIName); string shortcut = string.Empty; if (inputBinding?.Gesture is KeyGesture keyGesture) { shortcut = keyGesture.DisplayString; if (string.IsNullOrEmpty(shortcut)) { shortcut = keyGesture.Modifiers == ModifierKeys.None ? keyGesture.Key.ToString() : $"{keyGesture.Modifiers.ToString()}+{keyGesture.Key}"; } } if (!string.IsNullOrEmpty(shortcut)) { string tooltip = (element.ToolTip as string ?? string.Empty) + $" ({shortcut})"; element.ToolTip = tooltip; } }
// IFrameworkElement protected override void OnApplyTemplate() { // Uno Doc: Added to dispose event handlers _eventSubscriptions.Disposable = null; var registrations = new CompositeDisposable(); if (GetTemplateChild <Control>(c_expanderHeader) is ToggleButton toggleButton) { // We will do 2 things with the toggle button's peer: // 1. Set the events source of the toggle button peer to // the expander's automation peer. This is is because we // don't want to announce the toggle button's on/off property // changes, but the expander's expander/collapse property changes // (or on the events source that's set, if it's set) and // // 2. Set the expander's automation properties name to the // toggleButton's in case the expander doesn't have one. This just follows // what WPF does. if (FrameworkElementAutomationPeer.FromElement(toggleButton) is AutomationPeer toggleButtonPeer) { // 1. Set the events source of the toggle button peer to the expander's. if (FrameworkElementAutomationPeer.FromElement(this) is AutomationPeer expanderPeer) { // Uno Doc: EventSource is not implemented in the Uno Platform //var expanderEventsSource = expanderPeer.EventsSource != null ? // expanderPeer.EventsSource : // expanderPeer; //toggleButtonPeer.EventsSource = expanderEventsSource; } // 2. If the expander doesn't have any AutomationProperties.Name set, // we will try setting one based on the header. This is how // WPF's expanders work. if (string.IsNullOrEmpty(AutomationProperties.GetName(this)) && !string.IsNullOrEmpty(toggleButtonPeer.GetName())) { // Uno Doc: The equivalent '.GetName()' substituted for '.GetNameCore()' in WinUI AutomationProperties.SetName(this, toggleButtonPeer.GetName()); } } } if (GetTemplateChild <Border>(c_expanderContentClip) is Border expanderContentClip) { var visual = ElementCompositionPreview.GetElementVisual(expanderContentClip); visual.Clip = visual.Compositor.CreateInsetClip(); } if (GetTemplateChild <Border>(c_expanderContent) is Border expanderContent) { expanderContent.SizeChanged += OnContentSizeChanged; registrations.Add(() => expanderContent.SizeChanged -= OnContentSizeChanged); } UpdateExpandState(false); UpdateExpandDirection(false); // Uno Doc: Added to dispose event handlers _eventSubscriptions.Disposable = registrations; }
private void RaiseLiveRegionChangedAutomationEvent(bool isDateDiffMode) { TextBlock resultTextBlock = isDateDiffMode ? DateDiffAllUnitsResultLabel : DateResultLabel; string automationName = AutomationProperties.GetName(resultTextBlock); TextBlockAutomationPeer.FromElement(resultTextBlock).RaiseAutomationEvent(AutomationEvents.LiveRegionChanged); }
void AnnounceCategoryName() { String categoryName = AutomationProperties.GetName(Header); NarratorAnnouncement announcement = CalculatorAnnouncement.GetCategoryNameChangedAnnouncement(categoryName); // UNO TODO // NarratorNotifier.Announce(announcement); }
public void Refresh() { this.name = AutomationProperties.GetName(this.presenter); if (String.IsNullOrEmpty(this.name)) { this.name = (this.presenter.DataContext as PropertyViewModel)?.Name; } }
/// <summary> /// Makes screen reader announce the element if <see cref="AutomationProperties.LiveSettingProperty"/> /// is not <see cref="AutomationLiveSetting.Off"/> and <see cref="AutomationProperties.NameProperty"/> /// is not null or empty, by rising the <see cref="AutomationEvents.LiveRegionChanged"/> event. /// </summary> /// <param name="element"></param> public static void AnnounceIfNeeded(UIElement element) { if (AutomationProperties.GetLiveSetting(element) != AutomationLiveSetting.Off && !string.IsNullOrEmpty(AutomationProperties.GetName(element))) { var peer = FrameworkElementAutomationPeer.FromElement(element); peer?.RaiseAutomationEvent(AutomationEvents.LiveRegionChanged); } }
//-------------------------------------------------------------------- // // Constructors // //--------------------------------------------------------------------- #region Constructors private FixedSOMImage(Rect imageRect, GeneralTransform trans, Uri sourceUri, FixedNode node, DependencyObject o) : base(node, trans) { _boundingRect = trans.TransformBounds(imageRect); _source = sourceUri; _startIndex = 0; _endIndex = 1; _name = AutomationProperties.GetName(o); _helpText = AutomationProperties.GetHelpText(o); }
protected void UpdateAutomationName() { var name = AutomationProperties.GetName(Element); if (!string.IsNullOrEmpty(name)) { WAutomationProperties.SetName(Control, name); } }
public DataGridColumnInfo(DataGridColumn column) : this() { this.DisplayIndex = column.DisplayIndex; this.Name = AutomationProperties.GetName(column); this.SortDirection = column.SortDirection; this.Visibility = column.Visibility; this.WidthType = column.Width.UnitType; this.WidthValue = column.Width.DisplayValue; }
protected override string GetNameCore() { string name = AutomationProperties.GetName(base.Owner); if (!string.IsNullOrEmpty(name)) { return(name); } return(GetClassNameCore()); }
/// <inheritdoc /> protected override string GetNameCore() { var name = AutomationProperties.GetName(this.Owner); if (string.IsNullOrEmpty(name)) { name = (this.Owner as IHeaderedControl)?.Header as string; } return(name); }
protected override string?GetNameCore() { var result = AutomationProperties.GetName(Owner); if (string.IsNullOrWhiteSpace(result) && GetLabeledBy() is AutomationPeer labeledBy) { return(labeledBy.GetName()); } return(null); }
/// <summary> /// Called by GetName. /// </summary> /// <returns> /// Returns the first of these that is not null or empty: /// - Value returned by the base implementation /// - Name of the owning TokenizingTextBox /// - TokenizingTextBox class name /// </returns> protected override string GetNameCore() { string name = this.OwningTokenizingTextBox.Name; if (!string.IsNullOrWhiteSpace(name)) { return(name); } name = AutomationProperties.GetName(this.OwningTokenizingTextBox); return(!string.IsNullOrWhiteSpace(name) ? name : base.GetNameCore()); }
public async Task VerifyAutomationName() { if (ApiInformation.IsTypePresent("Windows.UI.Xaml.Automation.Peers.PersonPictureAutomationPeer")) { await RunOnUIThread.ExecuteAsync(() => { PersonPicture personPicture = new PersonPicture(); Verify.IsNotNull(personPicture); // Set properties and ensure that the AutomationName updates accordingly personPicture.Initials = "AB"; String automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "AB"); personPicture.DisplayName = "Jane Smith"; automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "Jane Smith"); if (ApiInformation.IsTypePresent("Windows.ApplicationModel.Contacts.Contact")) { Contact contact = new Contact(); contact.FirstName = "John"; contact.LastName = "Doe"; personPicture.Contact = contact; automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "John Doe"); personPicture.IsGroup = true; automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "Group"); personPicture.IsGroup = false; personPicture.BadgeGlyph = "\uE765"; automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "John Doe, icon"); personPicture.BadgeText = "Skype"; automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "John Doe, Skype"); personPicture.BadgeText = ""; personPicture.BadgeNumber = 5; automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "John Doe, 5 items"); personPicture.BadgeText = "direct reports"; automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "John Doe, 5 direct reports"); } }); } }
/// <summary>Gets the text label of the element that is associated with this <see cref="T:System.Windows.Automation.Peers.TextAutomationPeer" />. Called by <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetName" />.</summary> /// <returns>The value of <see cref="P:System.Windows.Automation.AutomationProperties.Name" /> or <see cref="P:System.Windows.Automation.AutomationProperties.LabeledBy" /> if either is set; otherwise this method returns an empty string. </returns> // Token: 0x06002832 RID: 10290 RVA: 0x000BBCD8 File Offset: 0x000B9ED8 protected override string GetNameCore() { string name = AutomationProperties.GetName(base.Owner); if (string.IsNullOrEmpty(name)) { AutomationPeer labeledByCore = this.GetLabeledByCore(); if (labeledByCore != null) { name = labeledByCore.GetName(); } } return(name ?? string.Empty); }
public void VerifyAutomationName() { RunOnUIThread.Execute(() => { PersonPicture personPicture = new PersonPicture(); Verify.IsNotNull(personPicture); // Set properties and ensure that the AutomationName updates accordingly personPicture.Initials = "AB"; String automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "AB"); personPicture.DisplayName = "Jane Smith"; automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "Jane Smith"); /* * Contact contact = new Contact(); * contact.FirstName = "John"; * contact.LastName = "Doe"; * personPicture.Contact = contact; * automationName = AutomationProperties.GetName(personPicture); * Verify.AreEqual(automationName, "John Doe"); */ personPicture.DisplayName = "John Doe"; personPicture.IsGroup = true; automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "Group"); personPicture.IsGroup = false; personPicture.BadgeGlyph = "\uE765"; automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "John Doe, icon"); personPicture.BadgeText = "Skype"; automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "John Doe, Skype"); personPicture.BadgeText = ""; personPicture.BadgeNumber = 5; automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "John Doe, 5 items"); personPicture.BadgeText = "direct reports"; automationName = AutomationProperties.GetName(personPicture); Verify.AreEqual(automationName, "John Doe, 5 direct reports"); }); }
/// <summary> /// GetNameCore will return a value matching (in priority order) /// /// 1. Automation.Name /// 2. GetLabeledBy.Name /// 3. String.Empty /// /// This differs from the base implementation in that we must /// never return GetPlainText() . /// </summary> override protected string GetNameCore() { string result = AutomationProperties.GetName(this.Owner); if (string.IsNullOrEmpty(result)) { AutomationPeer labelAutomationPeer = GetLabeledByCore(); if (labelAutomationPeer != null) { result = labelAutomationPeer.GetName(); } } return(result ?? string.Empty); }
protected override void OnApplyTemplate() { m_applyTemplateCalled = true; var closeButton = GetTemplateChild <Button>(c_closeButtonName); if (closeButton != null) { closeButton.Click += OnCloseButtonClick; // Do localization for the close button if (string.IsNullOrEmpty(AutomationProperties.GetName(closeButton))) { var closeButtonName = ResourceAccessor.GetLocalizedStringResource(ResourceAccessor.SR_InfoBarCloseButtonName); AutomationProperties.SetName(closeButton, closeButtonName); } // Setup the tooltip for the close button var tooltip = new ToolTip(); var closeButtonTooltipText = ResourceAccessor.GetLocalizedStringResource(ResourceAccessor.SR_InfoBarCloseButtonTooltip); tooltip.Content = closeButtonTooltipText; ToolTipService.SetToolTip(closeButton, tooltip); } var iconTextblock = GetTemplateChild <FrameworkElement>(c_iconTextBlockName); if (iconTextblock != null) { m_standardIconTextBlock = iconTextblock; AutomationProperties.SetName(iconTextblock, ResourceAccessor.GetLocalizedStringResource(GetIconSeverityLevelResourceName(Severity))); } var contentRootGrid = GetTemplateChild <Button>(c_contentRootName); if (contentRootGrid != null) { AutomationProperties.SetLocalizedLandmarkType(contentRootGrid, ResourceAccessor.GetLocalizedStringResource(ResourceAccessor.SR_InfoBarCustomLandmarkName)); } UpdateVisibility(m_notifyOpen, true); m_notifyOpen = false; UpdateSeverity(); UpdateIcon(); UpdateIconVisibility(); UpdateCloseButton(); UpdateForeground(); }
protected override string GetNameCore() { string name = AutomationProperties.GetName(base.Owner); if (!string.IsNullOrEmpty(name)) { return(name); } object header = ((TabItem)base.Owner).Header; if (header == null) { return(""); } return(header.ToString()); }
/// <summary> /// Called by GetName. /// </summary> /// <returns> /// Returns the first of these that is not null or empty: /// - Value returned by the base implementation /// - Name of the owning Carousel /// - Carousel class name /// </returns> protected override string GetNameCore() { string name = this.OwningCarousel.Name; if (!string.IsNullOrEmpty(name)) { return name; } name = AutomationProperties.GetName(this.OwningCarousel); if (!string.IsNullOrEmpty(name)) { return name; } return base.GetNameCore(); }
/// <summary> /// Gets the automation name. /// </summary> /// <returns>The automation name.</returns> protected override string GetNameCore() { if (this.splitListBoxItem.Content != null) { UIElement contentElement = this.splitListBoxItem.Content as UIElement; if (contentElement != null) { return(AutomationProperties.GetName(contentElement)); } else { return(this.splitListBoxItem.Content.ToString()); } } return(base.GetNameCore()); }
/// <summary> /// Updates the columns from column settings. /// </summary> /// <param name="dataGrid">The data grid.</param> private static void UpdateColumnsFromColumnSettings(DataGrid dataGrid) { if (!GetIsUpdatingColumnSettings(dataGrid)) { SetIsUpdatingColumnSettings(dataGrid, true); string columnSettings = GetColumnSettings(dataGrid); ArrayList columnInfos = (ArrayList)XamlReader.Parse(columnSettings); foreach (DataGridColumnInfo columnInfo in columnInfos) { DataGridColumn column = dataGrid.Columns.FirstOrDefault( x => string.Equals(columnInfo.Name, AutomationProperties.GetName(x), System.StringComparison.Ordinal)); columnInfo.Apply(column, dataGrid.Columns.Count); } SetIsUpdatingColumnSettings(dataGrid, false); } }
private void SetAccessibilityTraits() { var baseElement = Element as MvvmAspire.Controls.Image; if (baseElement != null && baseElement.AccessibilityTraits != string.Empty) { var accessiblityTrait = baseElement.AccessibilityTraits; switch (accessiblityTrait) { case "button": AutomationProperties.SetName(baseElement, AutomationProperties.GetName(baseElement) + " button. Double tap to activate."); break; default: break; } } }
public static void NotifyScreenReaderAutomationIfKeyboardFocused(AutomationPeer automationPeer, UIElement uiElement) { if (uiElement.IsKeyboardFocused) { var str = uiElement.GetValue(AutomationProperties.NameProperty) as String; #if DEBUG Console.WriteLine("AUTOMATION NAME ==> " + str); var str2 = AutomationProperties.GetName(uiElement); DebugFix.Assert(str2 == str); if (automationPeer != null) { string str3 = automationPeer.GetName(); DebugFix.Assert(str3 == str); } #endif //DEBUG TextBlockWithAutomationPeer.NotifyScreenReaderAutomation(automationPeer, str); } }
// IFrameworkElement protected override void OnApplyTemplate() { if (GetTemplateChild <Control>(c_expanderHeader) is ToggleButton toggleButton) { // We will do 2 things with the toggle button's peer: // 1. Set the events source of the toggle button peer to // the expander's automation peer. This is is because we // don't want to announce the toggle button's on/off property // changes, but the expander's expander/collapse property changes // (or on the events source that's set, if it's set) and // // 2. Set the expander's automation properties name to the // toggleButton's in case the expander doesn't have one. This just follows // what WPF does. if (FrameworkElementAutomationPeer.FromElement(toggleButton) is AutomationPeer toggleButtonPeer) { // 1. Set the events source of the toggle button peer to the expander's. if (FrameworkElementAutomationPeer.FromElement(this) is AutomationPeer expanderPeer) { // Uno Doc: EventSource is not implemented in the Uno Platform //var expanderEventsSource = expanderPeer.EventsSource != null ? // expanderPeer.EventsSource : // expanderPeer; //toggleButtonPeer.EventsSource = expanderEventsSource; } // 2. If the expander doesn't have any AutomationProperties.Name set, // we will try setting one based on the header. This is how // WPF's expanders work. if (string.IsNullOrEmpty(AutomationProperties.GetName(this)) && !string.IsNullOrEmpty(toggleButtonPeer.GetName())) { // Uno Doc: The equivalent '.GetName()' substituted for '.GetNameCore()' in WinUI AutomationProperties.SetName(this, toggleButtonPeer.GetName()); } } } UpdateExpandState(false); UpdateExpandDirection(false); }
// Set the AutomationPeer name to be the same as the x:Name on each FrameworkElement // that is a child of the given panel, and continue recursively into any panel children. // This is so we don't need to set both properties on the elements in XAML. void SetAutomationPeerNames(Panel root) { foreach (var child in root.Children) { if (child is FrameworkElement element) { // Copy the x:Name into the AutomationPeer name unless it already has an AutomationPeer name. var name = element.Name; if (!string.IsNullOrEmpty(name) && string.IsNullOrEmpty(AutomationProperties.GetName(element))) { AutomationProperties.SetName(element, name); } if (child is Panel panel) { // Recurse to get the rest of the tree. SetAutomationPeerNames(panel); } } } }
private void UpdateTimer_Tick(object sender, object e) { FrameworkElement focusedControl; if (Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.UI.Xaml.UIElement", "XamlRoot") && XamlRoot != null) { focusedControl = FocusManager.GetFocusedElement(XamlRoot) as FrameworkElement; } else { focusedControl = FocusManager.GetFocusedElement() as FrameworkElement; } if (focusedControl == null) { ClearContent(); return; } if (controlName != null) { controlName.Text = focusedControl.Name; } if (controlType != null) { controlType.Text = focusedControl.GetType().Name; } if (controlAutomationName != null) { controlAutomationName.Text = AutomationProperties.GetName(focusedControl); } if (controlFirstParentWithName != null) { var parentWithName = FindVisualAscendantWithName(focusedControl); controlFirstParentWithName.Text = parentWithName?.Name ?? string.Empty; } }