public bool RemoveSelection(int i) { IRawElementProviderSimple[] selection = selectionProvider.GetSelection(); if (selection == null || i < 0 || i > selection.Length - 1) { return(false); } AutomationPeer childPeer = selection[i].AutomationPeer; if (childPeer == null) { return(false); } ISelectionItemProvider childItem = childPeer.GetPattern( PatternInterface.SelectionItem) as ISelectionItemProvider; if (childItem == null) { return(false); } try { if (childItem.IsSelected) { childItem.RemoveFromSelection(); } else { return(false); } } catch (InvalidOperationException e) { // May happen, ie, if a ComboBox requires a selection Log.Debug(e); return(false); } return(true); }
// This method is called from DataGrid.OnSelectedCellsChanged // Raises the selection events when Cell selection changes internal void RaiseAutomationCellSelectedEvent(SelectedCellsChangedEventArgs e) { // If the result of an AddToSelection or RemoveFromSelection is a single selected cell, // then all we raise is the ElementSelectedEvent for single item if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementSelected) && this.OwningDataGrid.SelectedCells.Count == 1 && e.AddedCells.Count == 1) { DataGridCellItemAutomationPeer cellPeer = GetCellItemPeer(e.AddedCells[0]); if (cellPeer != null) { cellPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementSelected); } } else { int i; if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementAddedToSelection)) { for (i = 0; i < e.AddedCells.Count; i++) { DataGridCellItemAutomationPeer cellPeer = GetCellItemPeer(e.AddedCells[i]); if (cellPeer != null) { cellPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementAddedToSelection); } } } if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection)) { for (i = 0; i < e.RemovedCells.Count; i++) { DataGridCellItemAutomationPeer cellPeer = GetCellItemPeer(e.RemovedCells[i]); if (cellPeer != null) { cellPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection); } } } } }
IRawElementProviderSimple IGridProvider.GetItem(int row, int column) { EnsureEnabled(); if (this.OwningDataGrid != null && this.OwningDataGrid.DataConnection != null && row >= 0 && row < _group.GroupItems.Count /*ItemCount*/ && column >= 0 && column < this.OwningDataGrid.Columns.Count) { DataGridRowGroupInfo groupInfo = this.OwningDataGrid.RowGroupInfoFromCollectionViewGroup(_group); if (groupInfo != null) { // Adjust the row index to be relative to the DataGrid instead of the group row = groupInfo.Slot - this.OwningDataGrid.RowGroupHeadersTable.GetIndexCount(0, groupInfo.Slot) + row + 1; Debug.Assert(row >= 0, "Expected positive row."); Debug.Assert(row < this.OwningDataGrid.DataConnection.Count, "Expected row smaller than this.OwningDataGrid.DataConnection.Count."); int slot = this.OwningDataGrid.SlotFromRowIndex(row); if (!this.OwningDataGrid.IsSlotVisible(slot)) { object item = this.OwningDataGrid.DataConnection.GetDataItem(row); this.OwningDataGrid.ScrollIntoView(item, this.OwningDataGrid.Columns[column]); } Debug.Assert(this.OwningDataGrid.IsSlotVisible(slot), "Expected OwningDataGrid.IsSlotVisible(slot) is true."); DataGridRow dgr = this.OwningDataGrid.DisplayData.GetDisplayedElement(slot) as DataGridRow; // the first cell is always the indentation filler cell if grouping is enabled, so skip it Debug.Assert(column + 1 < dgr.Cells.Count, "Expected column + 1 smaller than dgr.Cells.Count."); DataGridCell cell = dgr.Cells[column + 1]; AutomationPeer peer = CreatePeerForElement(cell); if (peer != null) { return(ProviderFromPeer(peer)); } } } return(null); }
public override void GetName_AttachedProperty0Event() { if (!EventsManager.Instance.AutomationSingletonExists) { EnqueueTestComplete(); return; } CreateAsyncTest(calendar, () => { List <AutomationPeer> buttonChildren = GetButtonChildren(); FrameworkElement fe = ((FrameworkElementAutomationPeer)buttonChildren [0]).Owner as FrameworkElement; AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe); AutomationPropertyEventTuple tuple = null; EventsManager.Instance.Reset(); tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty); Assert.IsNull(tuple, "#0"); EventsManager.Instance.Reset(); fe.SetValue(AutomationProperties.NameProperty, "Attached Name"); tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty); Assert.IsNotNull(tuple, "#1"); Assert.AreEqual("Attached Name", (string)tuple.NewValue, "#2"); Assert.AreEqual(CURRENT_MONTH, tuple.OldValue, "#3"); EventsManager.Instance.Reset(); fe.SetValue(AutomationProperties.NameProperty, "Name"); tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty); Assert.IsNotNull(tuple, "#4"); Assert.AreEqual("Name", (string)tuple.NewValue, "#5"); Assert.AreEqual("Attached Name", (string)tuple.OldValue, "#6"); EventsManager.Instance.Reset(); fe.SetValue(AutomationProperties.NameProperty, null); tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty); Assert.IsNotNull(tuple, "#7"); Assert.AreEqual(CURRENT_MONTH, (string)tuple.NewValue, "#8"); Assert.AreEqual("Name", (string)tuple.OldValue, "#9"); }); }
public bool AddSelection(int i) { AutomationPeer childPeer = GetChildAt(i); if (childPeer == null) { return(false); } ISelectionItemProvider childItem = childPeer.GetPattern( PatternInterface.SelectionItem) as ISelectionItemProvider; if (childItem == null) { return(false); } if (selectionProvider.CanSelectMultiple) { try { childItem.AddToSelection(); } catch (InvalidOperationException e) { Log.Debug(e); return(false); } } else { try { childItem.Select(); } catch (ElementNotEnabledException e) { Log.Debug(e); return(false); } catch (InvalidOperationException e) { Log.Debug(e); return(false); } } return(true); }
private void OnOwnerPropertyChanged(object sender, PropertyChangedEventArgs e) { if (!AutomationPeer.ListenerExists(AutomationEvents.PropertyChanged)) { return; } Debug.Assert(sender == this.Owner); if (string.IsNullOrEmpty(e.PropertyName) || (e.PropertyName == DataGridGroupAutomationPeer.GroupIsExpandedPropertyName)) { if (this.Owner.IsExpanded) { this.RaisePropertyChangedEvent(ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty, ExpandCollapseState.Collapsed, ExpandCollapseState.Expanded); } else { this.RaisePropertyChangedEvent(ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty, ExpandCollapseState.Expanded, ExpandCollapseState.Collapsed); } } }
public override object GetPattern(PatternInterface patternInterface) { if (patternInterface == PatternInterface.Scroll) { DataGridControl owner = this.DataGridControl; ScrollViewer scrollViewer = owner.ScrollViewer; if (scrollViewer != null) { AutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(scrollViewer); if ((peer != null) && (peer is IScrollProvider)) { peer.EventsSource = this; return(peer); } } } return(m_innerDataGridContextAutomationPeer.GetPattern(patternInterface)); }
internal void AutomationGetSelectionContainerUIAPeer(out AutomationPeer ppPeer) { //wrl.ComPtr<xaml.Automation.Peers.FrameworkElementAutomationPeerStatics> spAutomationPeerStatics; AutomationPeer spAutomationPeer; UIElement spLoopingSelectorAsUI; LoopingSelector pLoopingSelectorNoRef = null; GetParentNoRef(out pLoopingSelectorNoRef); //(pLoopingSelectorNoRef.QueryInterface( // __uuidof(UIElement), // &spLoopingSelectorAsUI)); spLoopingSelectorAsUI = this; //(wf.GetActivationFactory( // wrl_wrappers.Hstring(RuntimeClass_Microsoft_UI_Xaml_Automation_Peers_FrameworkElementAutomationPeer), // &spAutomationPeerStatics)); //spAutomationPeerStatics.CreatePeerForElement(spLoopingSelectorAsUI, &spAutomationPeer); spAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(spLoopingSelectorAsUI); //spAutomationPeer.CopyTo(ppPeer); ppPeer = spAutomationPeer; }
private static void OnDrawerStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var sideDrawer = d as RadSideDrawer; var mainContent = sideDrawer.MainContent as FrameworkElement; if (mainContent != null) { mainContent.IsHitTestVisible = (DrawerState)e.NewValue == DrawerState.Closed; } sideDrawer.CommandService.ExecuteCommand(CommandId.DrawerStateChanged, e.NewValue); if (AutomationPeer.ListenerExists(AutomationEvents.PropertyChanged)) { var peer = FrameworkElementAutomationPeer.FromElement(sideDrawer) as RadSideDrawerAutomationPeer; if (peer != null) { peer.RaiseExpandCollapseAutomationEvent((DrawerState)e.OldValue, (DrawerState)e.NewValue); } } }
// Token: 0x06005872 RID: 22642 RVA: 0x00188288 File Offset: 0x00186488 private static void OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ToolTip toolTip = (ToolTip)d; if ((bool)e.NewValue) { if (toolTip._parentPopup == null) { toolTip.HookupParentPopup(); } } else if (AutomationPeer.ListenerExists(AutomationEvents.ToolTipClosed)) { AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(toolTip); if (automationPeer != null) { automationPeer.RaiseAutomationEvent(AutomationEvents.ToolTipClosed); } } Control.OnVisualStatePropertyChanged(d, e); }
/// <summary> /// Retrieves a UI Automation provider for each child element that is /// selected. /// </summary> /// <returns>An array of UI Automation providers.</returns> /// <remarks> /// This API supports the .NET Framework infrastructure and is not /// intended to be used directly from your code. /// </remarks> public IRawElementProviderSimple[] GetSelection() { Accordion owner = this.OwnerAccordion; List <IRawElementProviderSimple> selection = new List <IRawElementProviderSimple>(owner.SelectedIndices.Count); foreach (int index in owner.SelectedIndices) { AccordionItem item = owner.ItemContainerGenerator.ContainerFromIndex(index) as AccordionItem; if (item != null) { AutomationPeer peer = FromElement(item); if (peer != null) { selection.Add(this.ProviderFromPeer(peer)); } } } return(selection.ToArray()); }
public override void GetChildren() { bool sliderLoaded = false; Slider slider = new Slider(); slider.Loaded += (o, e) => sliderLoaded = true; TestPanel.Children.Add(slider); SliderAutomationPeerPoker sapp = new SliderAutomationPeerPoker(slider); EnqueueConditional(() => sliderLoaded, "SliderLoaded #0"); Enqueue(() => { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(slider); Assert.IsNotNull(peer, "FrameworkElementAutomationPeer.CreatePeerForElement"); List <AutomationPeer> children = sapp.GetChildren(); Assert.IsNotNull(children, "GetChildren #0"); Assert.AreEqual(3, children.Count, "GetChildren #1"); }); EnqueueTestComplete(); }
// Return proxy representing the root of this WCP tree... private object InContextFragmentRoot(object unused) { AutomationPeer peer = Peer; AutomationPeer root = peer; if (root == null) { return(null); } while (true) { AutomationPeer parent = root.GetParent(); if (parent == null) { break; } root = parent; } return(StaticWrap(root, peer)); }
public override void GetLabeledBy_AttachedProperty() { FrameworkElement fe = CreateConcreteFrameworkElement(); FrameworkElementAutomationPeerContract feap = CreateConcreteFrameworkElementAutomationPeer(fe); Assert.IsNull(feap.GetLabeledBy(), "GetLabeledBy"); Assert.IsNull(feap.GetLabeledByCore_(), "GetLabeledByCore"); TextBlock labeledBy = new TextBlock(); labeledBy.Text = "LabeledBy text"; AutomationPeer labeledByPeer = FrameworkElementAutomationPeer.CreatePeerForElement(labeledBy); fe.SetValue(AutomationProperties.LabeledByProperty, labeledBy); Assert.AreSame(labeledByPeer, feap.GetLabeledBy(), "GetLabeledBy #1"); Assert.AreSame(labeledByPeer, feap.GetLabeledByCore_(), "GetLabeledByCore #1"); fe.SetValue(AutomationProperties.LabeledByProperty, null); Assert.IsNull(feap.GetLabeledBy(), "GetLabeledBy #2"); Assert.IsNull(feap.GetLabeledByCore_(), "GetLabeledByCore #2"); }
private static void UpdateImportantForAccessibilityForAddedChild(UIElement parent, DependencyObject child) { var parentPeer = FrameworkElementAutomationPeer.FromElement(parent); if (DoesHideDescendants(parent) || IsHiddenByAncestor(parentPeer)) { if (child is UIElement childElement) { // If an ancestor is "hiding" the element, set AccessibilityView to Raw. AutomationPeer childPeer = FrameworkElementAutomationPeer.FromElement(childElement); AutomationProperties.SetAccessibilityView(childElement, AccessibilityView.Raw); SetChildrenAccessibilityView(childPeer, AccessibilityView.Raw); } else { // If the parent or an ancestor is "hiding" the children, set AccessibilityView to Raw. SetChildrenAccessibilityView(parentPeer, AccessibilityView.Raw); } } }
IRawElementProviderSimple[] ITableItemProvider.GetRowHeaderItems() { if (this.OwningDataGrid != null && (this.OwningDataGrid.HeadersVisibility & DataGridHeadersVisibility.Row) == DataGridHeadersVisibility.Row) { DataGridAutomationPeer dataGridAutomationPeer = UIElementAutomationPeer.CreatePeerForElement(this.OwningDataGrid) as DataGridAutomationPeer; DataGridItemAutomationPeer dataGridItemAutomationPeer = dataGridAutomationPeer.GetOrCreateItemPeer(_item); if (dataGridItemAutomationPeer != null) { AutomationPeer rowHeaderAutomationPeer = dataGridItemAutomationPeer.RowHeaderAutomationPeer; if (rowHeaderAutomationPeer != null) { List <IRawElementProviderSimple> providers = new List <IRawElementProviderSimple>(1); providers.Add(ProviderFromPeer(rowHeaderAutomationPeer)); return(providers.ToArray()); } } } return(null); }
/// <summary> /// Generates name from peer and list of children. /// Warning! It has clearing the Name AP as a side effect! /// </summary> /// <param name="peer"></param> /// <returns>Generated name.</returns> private static string GenerateNameFromPeer(AutomationPeer peer) { // Clear Name attached property to unhide any name generated by peer var element = GetUIElementFromAutomationPeer(peer); if (element != null) { element.ClearValue(AutomationProperties.NameProperty); } var ownName = peer.GetName(); if (!string.IsNullOrEmpty(ownName)) { // Own name present, we can use return(ownName); } // Defer to children return(GenerateNameFromChildren(peer.GetChildren())); }
/// <summary>Responds to a list box selection change by raising a <see cref="E:System.Windows.Controls.Primitives.Selector.SelectionChanged" /> event. </summary> /// <param name="e">Provides data for <see cref="T:System.Windows.Controls.SelectionChangedEventArgs" />. </param> // Token: 0x06005130 RID: 20784 RVA: 0x0016C274 File Offset: 0x0016A474 protected override void OnSelectionChanged(SelectionChangedEventArgs e) { base.OnSelectionChanged(e); if (this.SelectionMode == SelectionMode.Single) { ItemsControl.ItemInfo internalSelectedInfo = base.InternalSelectedInfo; ListBoxItem listBoxItem = (internalSelectedInfo != null) ? (internalSelectedInfo.Container as ListBoxItem) : null; if (listBoxItem != null) { this.UpdateAnchorAndActionItem(internalSelectedInfo); } } if (AutomationPeer.ListenerExists(AutomationEvents.SelectionPatternOnInvalidated) || AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementSelected) || AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementAddedToSelection) || AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection)) { ListBoxAutomationPeer listBoxAutomationPeer = UIElementAutomationPeer.CreatePeerForElement(this) as ListBoxAutomationPeer; if (listBoxAutomationPeer != null) { listBoxAutomationPeer.RaiseSelectionEvents(e); } } }
/// <summary> /// Retrieves a UI Automation provider for each child element that is /// selected. /// </summary> /// <returns>A collection of UI Automation providers.</returns> /// <remarks> /// This API supports the .NET Framework infrastructure and is not /// intended to be used directly from your code. /// </remarks> IRawElementProviderSimple[] ISelectionProvider.GetSelection() { if (OwnerAutoCompleteBox.SelectionAdapter != null) { object selectedItem = OwnerAutoCompleteBox.SelectionAdapter.SelectedItem; if (selectedItem != null) { UIElement uie = selectedItem as UIElement; if (uie != null) { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(uie); if (peer != null) { return(new IRawElementProviderSimple[] { ProviderFromPeer(peer) }); } } } } return(new IRawElementProviderSimple[] { }); }
public override void StructureChanged_Events() { if (!EventsManager.Instance.AutomationSingletonExists) { EnqueueTestComplete(); return; } AutomationPeer peer = null; TabControl tabControl = CreateConcreteFrameworkElement() as TabControl; CreateAsyncTest(tabControl, () => { peer = FrameworkElementAutomationPeer.CreatePeerForElement(tabControl); Assert.IsNotNull(peer, "FrameworkElementAutomationPeer.CreatePeerForElement #0"); AutomationEventTuple tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationEvents.StructureChanged); Assert.IsNull(tuple, "GetAutomationEventFrom #0"); }, () => { EventsManager.Instance.Reset(); tabControl.Items.Add(new TabItem() { Header = "Item 0" }); }, () => { AutomationEventTuple tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationEvents.StructureChanged); Assert.IsNotNull(tuple, "GetAutomationEventFrom #1"); }, () => { EventsManager.Instance.Reset(); tabControl.Items.RemoveAt(0); }, () => { AutomationEventTuple tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationEvents.StructureChanged); Assert.IsNotNull(tuple, "GetAutomationEventFrom #2"); }); }
public void StructureChanged_Events() { if (!EventsManager.Instance.AutomationSingletonExists) { EnqueueTestComplete(); return; } bool scrollbarLoaded = false; bool scrollbarLayoutUpdated = false; ScrollBar scrollbar = new ScrollBar(); scrollbar.Orientation = Orientation.Vertical; scrollbar.Loaded += (o, e) => scrollbarLoaded = true; TestPanel.Children.Add(scrollbar); ScrollBarAutomationPeerPoker sbapp = new ScrollBarAutomationPeerPoker(scrollbar); EnqueueConditional(() => scrollbarLoaded, "ScrollBarLoaded #0"); Enqueue(() => { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(scrollbar); Assert.IsNotNull(peer, "FrameworkElementAutomationPeer.CreatePeerForElement"); List <AutomationPeer> children = sbapp.GetChildren(); Assert.IsNotNull(children, "GetChildren #0"); Assert.AreEqual(5, children.Count, "GetChildren #1"); scrollbar.LayoutUpdated += (o, e) => scrollbarLayoutUpdated = true; EventsManager.Instance.Reset(); scrollbar.Orientation = Orientation.Horizontal; }); EnqueueConditional(() => scrollbarLayoutUpdated, "ScrollBarLayoutUpdated #0"); Enqueue(() => { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(scrollbar); Assert.IsNotNull(peer, "FrameworkElementAutomationPeer.CreatePeerForElement"); AutomationEventTuple tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationEvents.StructureChanged); Assert.IsNotNull(tuple, "AutomationEvents.StructureChanged #0"); }); EnqueueTestComplete(); }
public void IGridItemProvider_Methods() { AutomationPeer calendarAutomationPeer = null; DateTime date = new DateTime(2000, 2, 2); List <AutomationPeer> buttonChildren = null; CreateAsyncTest(calendar, () => { calendarAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(calendar); Assert.IsNotNull(calendarAutomationPeer, "#0"); buttonChildren = GetButtonChildren(); Assert.IsNotNull(buttonChildren.Count, "#1"); Assert.AreEqual(12, buttonChildren.Count, "#2"); }, () => { calendar.SelectedDate = date; }, () => { int count = 0; foreach (AutomationPeer peer in (from c in calendarAutomationPeer.GetChildren() where c.GetType() == typeof(CalendarButtonAutomationPeer) select c)) { FrameworkElementAutomationPeer feap = peer as FrameworkElementAutomationPeer; Assert.IsNotNull("#3"); IGridItemProvider gridItem = (IGridItemProvider)peer.GetPattern(PatternInterface.GridItem); Assert.IsNotNull(gridItem, "#4"); Assert.AreEqual(feap.Owner.GetValue(Grid.ColumnProperty), gridItem.Column, "#5"); Assert.AreEqual((int)feap.Owner.GetValue(Grid.RowProperty), gridItem.Row, "#6"); Assert.AreEqual(1, gridItem.ColumnSpan, "#7"); Assert.AreEqual(1, gridItem.RowSpan, "#8"); Assert.AreEqual(calendarAutomationPeer, new PeerFromProvider().GetPeerFromProvider(gridItem.ContainingGrid), "#9"); count++; } Assert.AreEqual(12, count, "#10"); }); }
public void ValueProvider_Methods() { bool concreteLoaded = false; ComboBoxConcrete concrete = CreateConcreteFrameworkElement() as ComboBoxConcrete; concrete.Loaded += (o, e) => concreteLoaded = true; concrete.Items.Add(new ComboBoxItem() { Content = "1" }); concrete.Items.Add(new ComboBoxItem() { Content = "2" }); concrete.Width = 300; TestPanel.Children.Add(concrete); EnqueueConditional(() => concreteLoaded, "ConcreteLoaded #0"); Enqueue(() => concrete.ApplyTemplate()); Enqueue(() => { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(concrete); Assert.IsNotNull(peer, "CreatePeerForElement #0"); IValueProvider value = peer.GetPattern(PatternInterface.Value) as IValueProvider; // Yes is returning null! Assert.IsNull(value, "ValueProvider #0"); // We are going to try again using explicit cast value = peer as IValueProvider; Assert.IsNotNull(value, "ValueProvider #1"); // We can't change the value anyway Assert.IsTrue(value.IsReadOnly, "IsReadOnly #0"); Assert.Throws <InvalidOperationException> (delegate { value.SetValue("1"); }, "SetValue #0"); }); EnqueueTestComplete(); }
/// <summary> /// Recursively sets AccessibilityView to <paramref name="accessibilityView"/> for <paramref name="parentPeer"/> children. /// </summary> /// <param name="parentPeer"></param> /// <param name="accessibilityView"></param> private static void SetChildrenAccessibilityView(AutomationPeer parentPeer, AccessibilityView accessibilityView) { if (parentPeer?.GetChildren() == null) { return; } foreach (AutomationPeer childPeer in parentPeer.GetChildren()) { UIElement child = GetUIElementFromAutomationPeer(childPeer); if (child != null) { AutomationProperties.SetAccessibilityView(child, accessibilityView); // If element is hidden clear the generated label if any. if (IsInGenerativeStateAndHidden(child)) { child.ClearValue(AutomationProperties.NameProperty); } } SetChildrenAccessibilityView(childPeer, accessibilityView); } }
protected override List <AutomationPeer> GetChildrenCore() { List <AutomationPeer> children = GetItemPeers(); DataGridColumnHeadersPresenter columnsHeaderPresenter = this.OwningDataGrid.ColumnHeadersPresenter; // Add ColumnsHeaderPresenter if it is visible if (columnsHeaderPresenter != null && columnsHeaderPresenter.IsVisible) { AutomationPeer columnsHeaderPresenterPeer = FrameworkElementAutomationPeer.CreatePeerForElement(columnsHeaderPresenter); if (columnsHeaderPresenterPeer != null) { if (children == null) { children = new List <AutomationPeer>(1); } children.Insert(0, columnsHeaderPresenterPeer); } } return(children); }
/// <summary> /// The KB should only show when we have an object that implements the /// UIAutomation Text pattern. Therefore, we should test for this /// pattern on any focused object that we get. /// </summary> /// <param name="focusedObject">The object being focused</param> /// <returns>True if the touch KB should show, false otherwise.</returns> private static bool ShouldShow(DependencyObject focusedObject) { UIElement uiElement; UIElement3D uiElement3D; ContentElement contentElement; AutomationPeer peer = null; if ((uiElement = focusedObject as UIElement) != null) { peer = uiElement.GetAutomationPeer(); } else if ((uiElement3D = focusedObject as UIElement3D) != null) { peer = uiElement3D.GetAutomationPeer(); } else if ((contentElement = focusedObject as ContentElement) != null) { peer = contentElement.GetAutomationPeer(); } return(peer?.GetPattern(PatternInterface.Text) != null); }
internal void RaiseAutomationInvokeEvents(DataGridEditingUnit editingUnit, DataGridColumn column, DataGridRow row) { switch (editingUnit) { case DataGridEditingUnit.Cell: { DataGridCell cell = row.Cells[column.Index]; AutomationPeer peer = FromElement(cell); if (peer != null) { peer.InvalidatePeer(); } else { peer = CreatePeerForElement(cell); } if (peer != null) { #if DEBUG_AUTOMATION Debug.WriteLine(peer.ToString() + ".RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked)"); #endif peer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked); } break; } case DataGridEditingUnit.Row: { DataGridItemAutomationPeer peer = GetOrCreateItemPeer(row.DataContext); #if DEBUG_AUTOMATION Debug.WriteLine("DataGridItemAutomationPeer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked)"); #endif peer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked); break; } } }
internal void RaiseSelectionEvents(CurrentSelectionChangedEventArgs args) { if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementSelected)) { CalendarSelectableCellnfoAutomationPeer peer = GetOrCreatePeerFromDateTime(args.NewSelection); if (peer != null) { peer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged); peer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementSelected); } } if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementAddedToSelection)) { CalendarSelectableCellnfoAutomationPeer peer = GetOrCreatePeerFromDateTime(args.NewSelection); if (peer != null) { peer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged); peer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementAddedToSelection); } } }
protected override List <AutomationPeer> GetChildrenCore() { List <AutomationPeer> children = new List <AutomationPeer>(); AutoCompleteTextBox owner = OwnerAutoCompleteBox; // TextBox part. TextBox textBox = owner.TextBox; if (textBox != null) { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(textBox); if (peer != null) { children.Insert(0, peer); } } // TODO: Consult UIA experts to determine whether the IsDropDownOpen // check should be present. // Include SelectionAdapter's children. if (owner.IsDropDownOpen && owner.SelectionAdapter != null) { AutomationPeer selectionAdapterPeer = owner.SelectionAdapter.CreateAutomationPeer(); if (selectionAdapterPeer != null) { List <AutomationPeer> listChildren = selectionAdapterPeer.GetChildren(); if (listChildren != null) { foreach (AutomationPeer child in listChildren) { children.Add(child); } } } } return(children); }
/// <summary> /// The override of ButtonBase.OnClick. /// Informs the owning datagrid to sort itself after the execution of usual button stuff /// </summary> protected override void OnClick() { if (!SuppressClickEvent) { if (AutomationPeer.ListenerExists(AutomationEvents.InvokePatternOnInvoked)) { AutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(this); if (peer != null) { peer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked); } } base.OnClick(); if (Column != null && Column.DataGridOwner != null) { Column.DataGridOwner.PerformSort(Column); } } }