private static void OnIsAutomationFocusedChanged(DependencyObject dobj, DependencyPropertyChangedEventArgs e) { if (AutomationPeerCache._objThatIsBinding == dobj) { return; } AutomationPeer automationPeer = AutomationPeerCache.GetAutomationPeer(dobj) ?? UIElementAutomationPeer.FromElement(dobj as UIElement); if (automationPeer == null) { return; } if (AutomationPeer.ListenerExists(AutomationEvents.PropertyChanged)) { automationPeer.RaisePropertyChangedEvent(SelectionItemPatternIdentifiers.IsSelectedProperty, e.OldValue, e.NewValue); automationPeer.RaisePropertyChangedEvent(AutomationElementIdentifiers.HasKeyboardFocusProperty, e.OldValue, e.NewValue); } if (AutomationPeer.ListenerExists(AutomationEvents.AutomationFocusChanged)) { automationPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged); } if (!(automationPeer is ItemAutomationPeer) || !AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementSelected)) { return; } automationPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementSelected); }
private void RaiseAutomationEvent(double oldValue, double newValue) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(this); if (peer != null) { peer.RaisePropertyChangedEvent(ValuePatternIdentifiers.ValueProperty, oldValue, newValue); } }
internal void RaiseToggleStatePropertyChangedEvent(bool oldValue, bool newValue) { AutomationPeer dataPeer = EventsSource; if (dataPeer != null) { dataPeer.RaisePropertyChangedEvent(TogglePatternIdentifiers.ToggleStateProperty, ConvertToToggleState(oldValue), ConvertToToggleState(newValue)); } }
/// <summary> /// Raises the automation peer selection changed event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.Windows.Controls.SelectionChangedEventArgs"/> instance containing the event data.</param> private void RaiseAutomationPeerSelectionChanged(object sender, SelectionChangedEventArgs e) { // the selection has changed, let automation know AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(this); // we are single select object oldValue = e.RemovedItems.Count == 1 ? e.RemovedItems[0] : String.Empty; object newValue = e.AddedItems.Count == 1 ? e.AddedItems[0] : String.Empty; peer.RaisePropertyChangedEvent(SelectionPatternIdentifiers.SelectionProperty, oldValue, newValue); }
private static void NotifyScreenReaderAutomation(AutomationPeer automationPeer, string str) { if (automationPeer == null) { return; } if (!AutomationInteropProvider.ClientsAreListening) { return; } // if (AutomationPeer.ListenerExists(AutomationEvents.AutomationFocusChanged)) // { // automationPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged); //#if DEBUG // Console.WriteLine("AUTOMATION EVENT ==> AutomationFocusChanged"); //#endif //DEBUG // } // if (AutomationPeer.ListenerExists(AutomationEvents.TextPatternOnTextSelectionChanged)) // { // automationPeer.RaiseAutomationEvent(AutomationEvents.TextPatternOnTextSelectionChanged); //#if DEBUG // Console.WriteLine("AUTOMATION EVENT ==> TextPatternOnTextSelectionChanged"); //#endif //DEBUG // } //automationPeer.InvalidatePeer(); //AutomationEventArgs args = new AutomationEventArgs(InvokePatternIdentifiers.InvokedEvent); //AutomationInteropProvider.RaiseAutomationEvent(InvokePatternIdentifiers.InvokedEvent, this, args); //AutomationProperties.NameProperty try { #if DEBUG var autoProp = AutomationProperty.LookupById(AutomationElementIdentifiers.NameProperty.Id); DebugFix.Assert(AutomationElementIdentifiers.NameProperty == autoProp); #endif //DEBUG automationPeer.RaisePropertyChangedEvent(AutomationElementIdentifiers.NameProperty, "", str); } catch (Exception e) { #if DEBUG Console.WriteLine("Exception automationPeer.RaisePropertyChangedEvent"); Debugger.Break(); #endif //DEBUG } }
internal virtual void PostOnLostFocus(RoutedEventArgs e) { EmitCurrentContext(EventIds.UIElement_LostFocusEvent, e); if (AutomationPeer != null) { AutomationPeer.RaisePropertyChangedEvent(AutomationElementIdentifiers.HasKeyboardFocusProperty, true, false); } }
internal void RaiseExpandCollapseAutomationEvent(bool oldValue, bool newValue) { AutomationPeer dataPeer = EventsSource; if (dataPeer != null) { dataPeer.RaisePropertyChangedEvent( ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty, oldValue ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed, newValue ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed); } }
internal static void RaiseAutomationPropertyChangedEvent <T>(UIElement element, T oldValue, T newValue) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(element); if (peer != null) { peer.RaisePropertyChangedEvent( ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty, oldValue, newValue); } }
private void RaiseAutomationEvent(double oldValue, double newValue) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(this); if (peer != null) { peer.RaisePropertyChangedEvent(ValuePatternIdentifiers.ValueProperty, oldValue, newValue); var ratingItem = this.Items.ElementAtOrDefault((int)newValue - 1) as RadRatingItem; if (ratingItem != null) { var ratingItemPeer = FrameworkElementAutomationPeer.FromElement(ratingItem); if (ratingItemPeer != null) { ratingItemPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged); } } } }
private void ItemCheckBox_Toggled(object sender, RoutedEventArgs e) { var itemCheckBox = sender as CheckBox; var itemContainer = itemCheckBox?.FindAncestor <ListViewItem>(); if (itemContainer is null) { return; } var newValue = (e.RoutedEvent == CheckBox.CheckedEvent); var oldValue = !newValue; // Assume the state has actually toggled. AutomationPeer peer = UIElementAutomationPeer.FromElement(itemContainer); peer?.RaisePropertyChangedEvent( TogglePatternIdentifiers.ToggleStateProperty, oldValue ? ToggleState.On : ToggleState.Off, newValue ? ToggleState.On : ToggleState.Off); }
// Whenever the checkbox in the item is checked, the containing item will raise a // UIA event to convey the fact that the toggle state of the item has changed. The // event must be raised regardless of whether the toggle state of the item changed // in response to keyboard, mouse, or programmatic input. private void CheckBox_Toggled(object sender, RoutedEventArgs e) { var itemCheckBox = sender as CheckBox; if (itemCheckBox is null || itemCheckBox.Visibility != Visibility.Visible) { return; } var parentContentPresenter = VisualTreeHelper.GetParent(this) as ContentPresenter; if (parentContentPresenter is null) { return; } var parentBorder = VisualTreeHelper.GetParent(parentContentPresenter) as Border; if (parentBorder is null) { return; } var itemContainer = VisualTreeHelper.GetParent(parentBorder) as ListBoxItem; if (itemContainer is null) { return; } var isChecked = (e.RoutedEvent == CheckBox.CheckedEvent); AutomationPeer itemAutomationPeer = UIElementAutomationPeer.FromElement(itemContainer); if (itemAutomationPeer != null) { itemAutomationPeer.RaisePropertyChangedEvent( TogglePatternIdentifiers.ToggleStateProperty, isChecked ? ToggleState.Off : ToggleState.On, // Assume the state has actually toggled. isChecked ? ToggleState.On : ToggleState.Off); } }
// Whenever the checkbox in the item is checked, the containing item will raise a // UIA event to convey the fact that the toggle state of the item has changed. The // event must be raised regardless of whether the toggle state of the item changed // in response to keyboard, mouse, or programmatic input. private void itemCheckBoxToggled(object sender, RoutedEventArgs e) { var itemCheckBox = sender as CheckBox; if (itemCheckBox != null) { var itemContainer = BirdList.ItemContainerGenerator.ContainerFromItem(itemCheckBox.DataContext) as ListViewItem; var isChecked = (e.RoutedEvent == CheckBox.CheckedEvent); AutomationPeer itemAutomationPeer = UIElementAutomationPeer.FromElement(itemContainer); if (itemAutomationPeer != null) { itemAutomationPeer.RaisePropertyChangedEvent( TogglePatternIdentifiers.ToggleStateProperty, isChecked ? ToggleState.Off : ToggleState.On, // Assume the state has actually toggled. isChecked ? ToggleState.On : ToggleState.Off); } } }
void IsDropDownOpenChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { bool open = (bool)e.NewValue; if (_popup != null) { _popup.IsOpen = open; } if (_dropDownToggle != null) { _dropDownToggle.IsChecked = open; } if (open) { ComboBoxItem t = null; FocusedIndex = Items.Count > 0 ? Math.Max(SelectedIndex, 0) : -1; if (FocusedIndex > -1) { t = ItemContainerGenerator.ContainerFromIndex(FocusedIndex) as ComboBoxItem; } // If the ItemsPresenter hasn't attached yet 't' will be null. // When the itemsPresenter attaches, focus will be set when the // item is loaded if (t != null) { t.Focus(); } LayoutUpdated += UpdatePopupSizeAndPosition; OnDropDownOpened(EventArgs.Empty); // Raises UIA Event AutomationPeer peer = ((ComboBox)sender).AutomationPeer; if (peer != null) { peer.RaisePropertyChangedEvent(ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty, ExpandCollapseState.Collapsed, ExpandCollapseState.Expanded); } } else { Focus(); LayoutUpdated -= UpdatePopupSizeAndPosition; OnDropDownClosed(EventArgs.Empty); // Raises UIA Event AutomationPeer peer = ((ComboBox)sender).AutomationPeer; if (peer != null) { peer.RaisePropertyChangedEvent(ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty, ExpandCollapseState.Expanded, ExpandCollapseState.Collapsed); } } UpdateDisplayedItem(open && SelectedItem is UIElement ? null : SelectedItem); UpdateVisualState(true); }
internal void UpdateDropTargetDropEffect(bool forceUpdate, bool isLeaving, TreeViewItem keyboardReorderedContainer) { //Preserve old value of string in case it's needed. string oldValue = m_dropTargetDropEffectString; TreeViewItem dragItem = null; AutomationPeer dragItemPeer = null; if (keyboardReorderedContainer != null) { dragItem = keyboardReorderedContainer; } else { var listItem = ContainerFromItem(m_draggedOverItem); if (listItem != null) { dragItem = (TreeViewItem)listItem; } } if (dragItem != null) { var dragItemString = ""; var itemBeforeInsertPositionString = ""; var itemAfterInsertPositionString = ""; var draggedOverString = ""; dragItemPeer = FrameworkElementAutomationPeer.FromElement(dragItem); if (dragItemPeer != null) { dragItemString = dragItemPeer.GetName(); } if (string.IsNullOrEmpty(dragItemString)) { dragItemString = ResourceAccessor.GetLocalizedStringResource( ResourceAccessor.SR_DefaultItemString); } if (isLeaving) { m_dropTargetDropEffectString = StringUtil.FormatString( ResourceAccessor.GetLocalizedStringResource(ResourceAccessor.SR_CancelDraggingString), dragItemString); } else { //unused variables in MUX source //TreeViewItem itemAfterInsertPosition = null; //TreeViewItem itemBeforeInsertPosition = null; if (m_draggedOverItem != null) { AutomationPeer draggedOverItemPeer = FrameworkElementAutomationPeer.FromElement(m_draggedOverItem); if (draggedOverItemPeer != null) { draggedOverString = draggedOverItemPeer.GetName(); } } else { int insertIndex = -1; int afterInsertIndex = -1; int beforeInsertIndex = -1; var dragItemIndex = IndexFromContainer(dragItem); if (keyboardReorderedContainer != null) { insertIndex = dragItemIndex; } else { insertIndex = m_emptySlotIndex; } if (insertIndex != -1) { afterInsertIndex = insertIndex + 1; beforeInsertIndex = insertIndex - 1; } if (insertIndex > dragItemIndex) { beforeInsertIndex++; } else if (insertIndex < dragItemIndex) { afterInsertIndex--; } itemBeforeInsertPositionString = GetAutomationName(beforeInsertIndex); itemAfterInsertPositionString = GetAutomationName(afterInsertIndex); } m_dropTargetDropEffectString = BuildEffectString(itemBeforeInsertPositionString, itemAfterInsertPositionString, dragItemString, draggedOverString); } if (!forceUpdate && oldValue != m_dropTargetDropEffectString) { AutomationPeer treePeer = FrameworkElementAutomationPeer.FromElement(this); treePeer.RaisePropertyChangedEvent(DropTargetPatternIdentifiers.DropTargetEffectProperty, oldValue, m_dropTargetDropEffectString); } } }