コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: RadRating.cs プロジェクト: cardinals/UI-For-UWP
        private void RaiseAutomationEvent(double oldValue, double newValue)
        {
            AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(this);

            if (peer != null)
            {
                peer.RaisePropertyChangedEvent(ValuePatternIdentifiers.ValueProperty, oldValue, newValue);
            }
        }
コード例 #3
0
        internal void RaiseToggleStatePropertyChangedEvent(bool oldValue, bool newValue)
        {
            AutomationPeer dataPeer = EventsSource;

            if (dataPeer != null)
            {
                dataPeer.RaisePropertyChangedEvent(TogglePatternIdentifiers.ToggleStateProperty, ConvertToToggleState(oldValue), ConvertToToggleState(newValue));
            }
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        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
            }
        }
コード例 #6
0
ファイル: Control.cs プロジェクト: ynkbt/moon
        internal virtual void PostOnLostFocus(RoutedEventArgs e)
        {
            EmitCurrentContext(EventIds.UIElement_LostFocusEvent, e);

            if (AutomationPeer != null)
            {
                AutomationPeer.RaisePropertyChangedEvent(AutomationElementIdentifiers.HasKeyboardFocusProperty,
                                                         true,
                                                         false);
            }
        }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        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);
            }
        }
コード例 #9
0
ファイル: RadRating.cs プロジェクト: zyhong/UI-For-UWP
        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);
                    }
                }
            }
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        // 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);
            }
        }
コード例 #12
0
        // 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);
                }
            }
        }
コード例 #13
0
        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);
        }
コード例 #14
0
ファイル: TreeViewList.cs プロジェクト: weitzhandler/Uno
        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);
                }
            }
        }