Beispiel #1
0
        /// <inheritdoc />
        protected override List <AutomationPeer> GetChildrenCore()
        {
#pragma warning disable CS8619 // Nullability of reference types in value doesn't match target type.
            return(this.Owner.VisualChildrenRecursive()
                   .Select(CreatePeerForElement)
                   .Where(x => x != null)
                   .ToList());

#pragma warning restore CS8619 // Nullability of reference types in value doesn't match target type.

            AutomationPeer?CreatePeerForElement(DependencyObject o)
            {
                if (o is UIElement uiElement)
                {
                    return(UIElementAutomationPeer.CreatePeerForElement(uiElement));
                }

                if (o is UIElement3D uiElement3D)
                {
                    return(UIElement3DAutomationPeer.CreatePeerForElement(uiElement3D));
                }

                return(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Is AutometionPeer represented by 'elementStart' is immediate child of AutomationPeer
        /// represented by 'ownerContentStart'.
        /// </summary>
        internal static bool IsImmediateAutomationChild(ITextPointer elementStart, ITextPointer ownerContentStart)
        {
            Invariant.Assert(elementStart.CompareTo(ownerContentStart) >= 0);
            bool immediateChild = true;
            // Walk element tree up looking for AutomationPeers.
            ITextPointer position = elementStart.CreatePointer();

            while (typeof(TextElement).IsAssignableFrom(position.ParentType))
            {
                position.MoveToElementEdge(ElementEdge.BeforeStart);
                if (position.CompareTo(ownerContentStart) <= 0)
                {
                    break;
                }
                AutomationPeer peer    = null;
                object         element = position.GetAdjacentElement(LogicalDirection.Forward);
                if (element is UIElement)
                {
                    peer = UIElementAutomationPeer.CreatePeerForElement((UIElement)element);
                }
                else if (element is ContentElement)
                {
                    peer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)element);
                }
                if (peer != null)
                {
                    immediateChild = false;
                    break;
                }
            }
            return(immediateChild);
        }
Beispiel #3
0
        //=====================================================================

        /// <summary>
        /// When an item is double clicked, handle it as a request to replace the misspelling with the selected
        /// word.  If Ctrl is held down, it is treated as a request to replace all occurrences.
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void lbSuggestions_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            AutomationPeer peer;

            var elem = lbSuggestions.InputHitTest(e.GetPosition(lbSuggestions)) as UIElement;

            // Only do it if an item is double clicked
            while (elem != null && elem != lbSuggestions)
            {
                if (elem is ListBoxItem)
                {
                    if (Keyboard.Modifiers == ModifierKeys.Control)
                    {
                        peer = UIElementAutomationPeer.CreatePeerForElement(btnReplaceAll);
                    }
                    else
                    {
                        peer = UIElementAutomationPeer.CreatePeerForElement(btnReplace);
                    }

                    if (peer.GetPattern(PatternInterface.Invoke) is IInvokeProvider provider)
                    {
                        provider.Invoke();
                    }

                    break;
                }

                elem = VisualTreeHelper.GetParent(elem) as UIElement;
            }
        }
Beispiel #4
0
        protected override string GetNameCore()
        {
            if (this.ChartArea.SelectionPanel != null && this.ChartArea.SelectionPanel.SelectedElement != null && this.ChartArea.SelectionPanel.SelectedElement != this.ChartArea)
            {
                AutomationPeer peerForElement = UIElementAutomationPeer.CreatePeerForElement((UIElement)this.ChartArea.SelectionPanel.SelectedElement);
                if (peerForElement != null)
                {
                    return(peerForElement.GetName());
                }
            }
            string str = base.GetNameCore();

            if (string.IsNullOrEmpty(str))
            {
                str = this.GetClassName();
            }
            if (string.IsNullOrEmpty(str))
            {
                str = this.ChartArea.Name;
            }
            if (string.IsNullOrEmpty(str))
            {
                str = this.ChartArea.GetType().Name;
            }
            return(str);
        }
        /// <summary>
        /// Gets the control pattern that is associated with the specified System.Windows.Automation.Peers.PatternInterface.
        /// </summary>
        /// <param name="patternInterface">A value from the System.Windows.Automation.Peers.PatternInterface enumeration.</param>
        /// <returns>The object that supports the specified pattern, or null if unsupported.</returns>
        public override object GetPattern(PatternInterface patternInterface)
        {
            switch (patternInterface)
            {
            case PatternInterface.Grid:
            case PatternInterface.Selection:
            case PatternInterface.Table:
                return(this);

            case PatternInterface.Scroll:
            {
                ScrollViewer scrollViewer = this.OwningDataGrid.InternalScrollHost;
                if (scrollViewer != null)
                {
                    AutomationPeer  scrollPeer     = UIElementAutomationPeer.CreatePeerForElement(scrollViewer);
                    IScrollProvider scrollProvider = scrollPeer as IScrollProvider;
                    if (scrollPeer != null && scrollProvider != null)
                    {
                        scrollPeer.EventsSource = this;
                        return(scrollProvider);
                    }
                }

                break;
            }
            }

            return(base.GetPattern(patternInterface));
        }
Beispiel #6
0
        private void EnableNarratorColorChangesAnnouncements()
        {
            INotifyPropertyChanged viewModel = (INotifyPropertyChanged)this.DataContext;

            viewModel.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName != "ColorName")
                {
                    return;
                }

                var colorTextBlock = (TextBlock)FindName("ColorTextBlock");
                if (colorTextBlock == null)
                {
                    return;
                }

                var peer = UIElementAutomationPeer.FromElement(colorTextBlock);
                if (peer == null)
                {
                    peer = UIElementAutomationPeer.CreatePeerForElement(colorTextBlock);
                }

                peer.RaiseAutomationEvent(AutomationEvents.MenuOpened);
            };
        }
Beispiel #7
0
        private void PINTabItem_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                e.Handled = true;
                typeof(Button).GetMethod("set_IsPressed", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(PinLoginButton, new object[] { true });
                var             peer       = UIElementAutomationPeer.CreatePeerForElement(PinLoginButton);
                IInvokeProvider invokeProv = peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;

                invokeProv.Invoke();
                return;
            }
            var isNumber = e.Key >= Key.D0 && e.Key <= Key.D9;
            var isKeyPad = e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9;

            if (isNumber || isKeyPad)
            {
                int value = -1;
                if (isNumber)
                { // numpad
                    value = (int)e.Key - ((int)Key.D0);
                }
                else if (isKeyPad)
                { // regular numbers
                    value = (int)e.Key - ((int)Key.NumPad0);
                }
                PinBox.Password = PinBox.Password + value.ToString();
                e.Handled       = true;
            }
            else
            {
                e.Handled = true;
            }
        }
        public override object GetPattern(PatternInterface patternInterface)
        {
            if (OwningRibbon.IsCollapsed)
            {
                return(null);
            }

            if (patternInterface == PatternInterface.ExpandCollapse)
            {
                return(this);
            }

            // ItemsControlAutomationPeer implements IScrollProvider which is supposed to scroll through TabHeaders
            if (patternInterface == PatternInterface.Scroll)
            {
                ItemsControl tabHeadersItemsControl = OwningRibbon.RibbonTabHeaderItemsControl;
                if (tabHeadersItemsControl != null)
                {
                    AutomationPeer tabHeadersItemsControlPeer = UIElementAutomationPeer.CreatePeerForElement(tabHeadersItemsControl);
                    if (tabHeadersItemsControlPeer != null)
                    {
                        return(tabHeadersItemsControlPeer.GetPattern(patternInterface));
                    }
                }
            }
            return(base.GetPattern(patternInterface));
        }
Beispiel #9
0
        /// <summary>
        /// Called when the <see cref="ToggleButton.IsChecked"/> property changes.
        /// </summary>
        /// <param name="args">The event data that describes the property that changed, as well as old and new values.</param>
        protected void OnIsCheckedChanged(DependencyPropertyChangedEventArgs args)
        {
            if (AutomationPeer.ListenerExists(AutomationEvents.PropertyChanged))
            {
                var peer = UIElementAutomationPeer.CreatePeerForElement(this);

                if (peer != null)
                {
                    var oldValue = (bool?)args.OldValue;
                    var newValue = (bool?)args.NewValue;

                    peer.RaisePropertyChangedEvent(
                        ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty,
                        (oldValue == true) ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed,
                        (newValue == true) ? ExpandCollapseState.Expanded : ExpandCollapseState.Collapsed);
                }
            }

            SetToolTip();
            ToolTip toolTip = (ToolTip)this.ToolTip;

            if (toolTip.IsOpen)
            {
                // need to reset so content changes if already open
                toolTip.IsOpen = false;
                toolTip.IsOpen = true;
            }
        }
Beispiel #10
0
        private void InvokeMenuOpenedClosedAutomationEvent(bool open)
        {
            AutomationEvents automationEvent = open ? AutomationEvents.MenuOpened : AutomationEvents.MenuClosed;

            if (AutomationPeer.ListenerExists(automationEvent))
            {
                System.Windows.Threading.DispatcherOperationCallback method = null;
                AutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(this);
                if (peer != null)
                {
                    if (open)
                    {
                        if (method == null)
                        {
                            method = delegate(object param)
                            {
                                peer.RaiseAutomationEvent(automationEvent);
                                return(null);
                            };
                        }
                        this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, method, null);
                    }
                    else
                    {
                        peer.RaiseAutomationEvent(automationEvent);
                    }
                }
            }
        }
Beispiel #11
0
        private static void IterateVisualChildren(DependencyObject parent, HwndContentControlAutomationPeer.IteratorCallback callback)
        {
            if (parent == null)
            {
                return;
            }
            int childrenCount = VisualTreeHelper.GetChildrenCount(parent);

            for (int childIndex = 0; childIndex < childrenCount; ++childIndex)
            {
                DependencyObject child       = VisualTreeHelper.GetChild(parent, childIndex);
                UIElement        element     = child as UIElement;
                UIElement3D      uiElement3D = child as UIElement3D;
                AutomationPeer   peerForElement1;
                if (element != null && (peerForElement1 = UIElementAutomationPeer.CreatePeerForElement(element)) != null)
                {
                    callback(peerForElement1);
                }
                else
                {
                    AutomationPeer peerForElement2;
                    if (uiElement3D != null && (peerForElement2 = UIElement3DAutomationPeer.CreatePeerForElement((UIElement3D)child)) != null)
                    {
                        callback(peerForElement2);
                    }
                    else
                    {
                        HwndContentControlAutomationPeer.IterateVisualChildren(child, callback);
                    }
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// This method is called when button is clicked.
        /// </summary>
        protected override void OnClick()
        {
            if (AutomationPeer.ListenerExists(AutomationEvents.InvokePatternOnInvoked))
            {
                AutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(this);
                if (peer != null)
                {
                    peer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked);
                }
            }

            // base.OnClick should be called first.
            // Our default command for Cancel Button to close dialog should happen
            // after Button's click event handler has been called.
            // If there is excption and it's a Cancel button and RoutedCommand is null,
            // We will raise Window.DialogCancelCommand.
            try
            {
                base.OnClick();
            }
            finally
            {
                // When the Button RoutedCommand is null, if it's a Cancel Button, Window.DialogCancelCommand will
                // be the default command. Do not assign Window.DialogCancelCommand to Button.Command.
                // If in Button click handler user nulls the Command, we still want to provide the default behavior.
                if ((Command == null) && IsCancel)
                {
                    // Can't invoke Window.DialogCancelCommand directly. Have to raise event.
                    // Filed bug 936090: Commanding perf issue: can't directly invoke a command.
                    MS.Internal.Commands.CommandHelpers.ExecuteCommand(Window.DialogCancelCommand, null, this);
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// A virtual function that is called when the selection is changed. Default behavior
        /// is to raise a SelectionChangedEvent
        /// </summary>
        /// <param name="e">The inputs for this event. Can be raised (default behavior) or processed
        ///   in some other way.</param>
        protected override void OnSelectionChanged(SelectionChangedEventArgs e)
        {
            base.OnSelectionChanged(e);
            if (IsKeyboardFocusWithin)
            {
                // If keyboard focus is within the control, make sure it is going to the correct place
                TabItem item = GetSelectedTabItem();
                if (item != null)
                {
                    item.SetFocus();
                }
            }
            UpdateSelectedContent();

            if (AutomationPeer.ListenerExists(AutomationEvents.SelectionPatternOnInvalidated) ||
                AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementSelected) ||
                AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementAddedToSelection) ||
                AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection))
            {
                TabControlAutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(this) as TabControlAutomationPeer;
                if (peer != null)
                {
                    peer.RaiseSelectionEvents(e);
                }
            }
        }
        protected override Rect GetBoundingRectangleCore()
        {
            if (this.Series == null || this.Series.ChartArea == null || !this.Series.ChartArea.IsTemplateApplied)
            {
                return(base.GetBoundingRectangleCore());
            }
            FrameworkElement dataPointView = SeriesVisualStatePresenter.GetDataPointView(this.DataPoint);

            if (dataPointView != null)
            {
                return(new FrameworkElementAutomationPeer(dataPointView).GetBoundingRectangle());
            }
            AutomationPeer peerForElement = UIElementAutomationPeer.CreatePeerForElement((UIElement)this.Series);

            if (!(this.Series is LineSeries) || this.DataPoint.View == null || peerForElement == null)
            {
                return(base.GetBoundingRectangleCore());
            }
            Point anchorPoint       = this.DataPoint.View.AnchorPoint;
            Rect  rectangle         = RectExtensions.Expand(new Rect(anchorPoint.X, anchorPoint.Y, 0.0, 0.0), 2.0, 2.0);
            Rect  boundingRectangle = peerForElement.GetBoundingRectangle();
            Size  renderSize        = this.Series.SeriesPresenter.RootPanel.RenderSize;
            Size  size = RectExtensions.GetSize(boundingRectangle);

            return(RectExtensions.Translate(RectExtensions.Transform(rectangle, (Transform) new ScaleTransform()
            {
                ScaleX = (size.Width / renderSize.Width),
                ScaleY = (size.Height / renderSize.Height)
            }), boundingRectangle.X, boundingRectangle.Y));
        }
Beispiel #15
0
        /// <summary>
        /// A virtual function that is called when the selection is changed. Default behavior
        /// is to raise a SelectionChangedEvent
        /// </summary>
        /// <param name="e">The inputs for this event. Can be raised (default behavior) or processed
        ///   in some other way.</param>
        protected override void OnSelectionChanged(SelectionChangedEventArgs e)
        {
            base.OnSelectionChanged(e);

            // In a single selection mode we want to move anchor to the selected element
            if (SelectionMode == SelectionMode.Single)
            {
                ItemInfo    info     = InternalSelectedInfo;
                ListBoxItem listItem = (info != null) ? info.Container as ListBoxItem : null;

                if (listItem != null)
                {
                    UpdateAnchorAndActionItem(info);
                }
            }

            if (AutomationPeer.ListenerExists(AutomationEvents.SelectionPatternOnInvalidated) ||
                AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementSelected) ||
                AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementAddedToSelection) ||
                AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection))
            {
                ListBoxAutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(this) as ListBoxAutomationPeer;
                if (peer != null)
                {
                    peer.RaiseSelectionEvents(e);
                }
            }
        }
Beispiel #16
0
        private void InvokeMenuOpenedClosedAutomationEvent(bool open)
        {
            AutomationEvents automationEvent = open ? AutomationEvents.MenuOpened : AutomationEvents.MenuClosed;

            if (AutomationPeer.ListenerExists(automationEvent))
            {
                AutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(this);
                if (peer != null)
                {
                    if (open)
                    {
                        // We raise the event async to allow PopupRoot to hookup
                        Dispatcher.BeginInvoke(DispatcherPriority.Input, new DispatcherOperationCallback(delegate(object param)
                        {
                            peer.RaiseAutomationEvent(automationEvent);
                            return(null);
                        }), null);
                    }
                    else
                    {
                        peer.RaiseAutomationEvent(automationEvent);
                    }
                }
            }
        }
        private void GetChildPeers(UIElement element, List <AutomationPeer> list)
        {
            Rect rect = new Rect(0.0, 0.0, ((FrameworkElement)base.Owner).ActualWidth, ((FrameworkElement)base.Owner).ActualHeight);

            for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++)
            {
                FrameworkElement frameworkElement = VisualTreeHelper.GetChild(element, i) as FrameworkElement;
                if (frameworkElement != null)
                {
                    AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(frameworkElement);
                    if (automationPeer != null && !(automationPeer is ScrollViewerAutomationPeer) && !(automationPeer is GroupItemAutomationPeer) && !automationPeer.IsOffscreen())
                    {
                        Rect rect2 = frameworkElement.TransformToAncestor(base.Owner).TransformBounds(new Rect(0.0, 0.0, frameworkElement.RenderSize.Width, frameworkElement.RenderSize.Height));
                        if (rect.IntersectsWith(rect2))
                        {
                            list.Add(automationPeer);
                        }
                    }
                    else
                    {
                        GetChildPeers(frameworkElement, list);
                    }
                }
            }
        }
        protected override void Invoke(object parameter)
        {
            if (AssociatedObject is not ListBox listBox)
            {
                return;
            }

            if (parameter is not SelectionChangedEventArgs args)
            {
                return;
            }
            if (args.AddedItems.Count <= 0)
            {
                return;
            }
            var selectedItem = args.AddedItems[0];

            if (selectedItem is null)
            {
                return;
            }

            var peer = UIElementAutomationPeer.CreatePeerForElement(listBox);

            if (peer.GetPattern(PatternInterface.Scroll) is not IScrollProvider scrollProvider)
            {
                return;
            }

            // ItemsSource 内の SelectedItem の割合(%)を求めます
            var verticalPercent = GetItemIndexPercent(listBox.ItemsSource.OfType <object>(), selectedItem);

            // %指定で垂直スクロールします(水平スクロールは現位置)
            scrollProvider.SetScrollPercent(scrollProvider.HorizontalScrollPercent, verticalPercent);
        }
Beispiel #19
0
        private static void OnIsOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ToolTip t = (ToolTip)d;

            if ((bool)e.NewValue)
            {
                if (t._parentPopup == null)
                {
                    t.HookupParentPopup();
                }
            }
            else
            {
                // When ToolTip is about to close but still hooked up - we need to raise Accessibility event
                if (AutomationPeer.ListenerExists(AutomationEvents.ToolTipClosed))
                {
                    AutomationPeer peer = UIElementAutomationPeer.CreatePeerForElement(t);
                    if (peer != null)
                    {
                        peer.RaiseAutomationEvent(AutomationEvents.ToolTipClosed);
                    }
                }
            }

            OnVisualStatePropertyChanged(d, e);
        }
Beispiel #20
0
        // Token: 0x06007245 RID: 29253 RVA: 0x0020AA54 File Offset: 0x00208C54
        internal static List <AutomationPeer> GetAutomationPeersFromRange(ITextPointer start, ITextPointer end, ITextPointer ownerContentStart)
        {
            List <AutomationPeer> list = new List <AutomationPeer>();

            start = start.CreatePointer();
            while (start.CompareTo(end) < 0)
            {
                bool flag = false;
                if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart)
                {
                    object adjacentElement = start.GetAdjacentElement(LogicalDirection.Forward);
                    if (adjacentElement is ContentElement)
                    {
                        AutomationPeer automationPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)adjacentElement);
                        if (automationPeer != null)
                        {
                            if (ownerContentStart == null || TextContainerHelper.IsImmediateAutomationChild(start, ownerContentStart))
                            {
                                list.Add(automationPeer);
                            }
                            start.MoveToNextContextPosition(LogicalDirection.Forward);
                            start.MoveToElementEdge(ElementEdge.AfterEnd);
                            flag = true;
                        }
                    }
                }
                else if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement)
                {
                    object adjacentElement = start.GetAdjacentElement(LogicalDirection.Forward);
                    if (adjacentElement is UIElement)
                    {
                        if (ownerContentStart == null || TextContainerHelper.IsImmediateAutomationChild(start, ownerContentStart))
                        {
                            AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement((UIElement)adjacentElement);
                            if (automationPeer != null)
                            {
                                list.Add(automationPeer);
                            }
                            else
                            {
                                TextContainerHelper.iterate((Visual)adjacentElement, list);
                            }
                        }
                    }
                    else if (adjacentElement is ContentElement)
                    {
                        AutomationPeer automationPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)adjacentElement);
                        if (automationPeer != null && (ownerContentStart == null || TextContainerHelper.IsImmediateAutomationChild(start, ownerContentStart)))
                        {
                            list.Add(automationPeer);
                        }
                    }
                }
                if (!flag && !start.MoveToNextContextPosition(LogicalDirection.Forward))
                {
                    break;
                }
            }
            return(list);
        }
Beispiel #21
0
        // Token: 0x06007246 RID: 29254 RVA: 0x0020AB60 File Offset: 0x00208D60
        internal static bool IsImmediateAutomationChild(ITextPointer elementStart, ITextPointer ownerContentStart)
        {
            Invariant.Assert(elementStart.CompareTo(ownerContentStart) >= 0);
            bool         result      = true;
            ITextPointer textPointer = elementStart.CreatePointer();

            while (typeof(TextElement).IsAssignableFrom(textPointer.ParentType))
            {
                textPointer.MoveToElementEdge(ElementEdge.BeforeStart);
                if (textPointer.CompareTo(ownerContentStart) <= 0)
                {
                    break;
                }
                AutomationPeer automationPeer  = null;
                object         adjacentElement = textPointer.GetAdjacentElement(LogicalDirection.Forward);
                if (adjacentElement is UIElement)
                {
                    automationPeer = UIElementAutomationPeer.CreatePeerForElement((UIElement)adjacentElement);
                }
                else if (adjacentElement is ContentElement)
                {
                    automationPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)adjacentElement);
                }
                if (automationPeer != null)
                {
                    result = false;
                    break;
                }
            }
            return(result);
        }
        private void AppearCopiedIndicator()
        {
            _copyIndicatorVisible = true;
            var opacityAppear = new DoubleAnimation(1.0, new Duration(TimeSpan.FromMilliseconds(300)));

            opacityAppear.EasingFunction = new CubicEase()
            {
                EasingMode = EasingMode.EaseInOut
            };
            var resize = new DoubleAnimation(56, new Duration(TimeSpan.FromMilliseconds(300)));

            resize.EasingFunction = new CubicEase()
            {
                EasingMode = EasingMode.EaseInOut
            };
            ColorCopiedNotificationBorder.BeginAnimation(Border.OpacityProperty, opacityAppear);
            ColorCopiedNotificationBorder.BeginAnimation(Border.HeightProperty, resize);

            var clipboardNotification = ((Decorator)ColorCopiedNotificationBorder).Child;

            if (clipboardNotification == null)
            {
                return;
            }

            var peer = UIElementAutomationPeer.FromElement(clipboardNotification);

            if (peer == null)
            {
                peer = UIElementAutomationPeer.CreatePeerForElement(clipboardNotification);
            }

            peer.RaiseAutomationEvent(AutomationEvents.MenuOpened);
        }
Beispiel #23
0
        // Handles IsSelected property changes
        private static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var container = (RibbonTabItem)d;
            var newValue  = (bool)e.NewValue;

            if (newValue)
            {
                if (container.TabControlParent?.SelectedTabItem != null &&
                    ReferenceEquals(container.TabControlParent.SelectedTabItem, container) == false)
                {
                    container.TabControlParent.SelectedTabItem.IsSelected = false;
                }

                container.OnSelected(new RoutedEventArgs(Selector.SelectedEvent, container));
            }
            else
            {
                container.OnUnselected(new RoutedEventArgs(Selector.UnselectedEvent, container));
            }

            // Raise UI automation events on this RibbonTabItem
            if (AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementSelected) ||
                AutomationPeer.ListenerExists(AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection))
            {
                //SelectorHelper.RaiseIsSelectedChangedAutomationEvent(container.TabControlParent, container, newValue);
                var peer = UIElementAutomationPeer.CreatePeerForElement(container) as RibbonTabItemAutomationPeer;
                peer?.RaiseTabSelectionEvents();
            }
        }
Beispiel #24
0
        protected MainWindow()
        {
            DataContext       = new MainWindowViewModel(this);
            IsVisibleChanged += OnVisibilityChanged;
            //TODO: Decide what to do with this

            //SetBinding(LeftProperty, new Binding
            //{
            //	Path = new PropertyPath("Left"),
            //	Mode = BindingMode.TwoWay,
            //	Converter = new DeviceToLogicalXConverter()
            //});
            //SetBinding(TopProperty, new Binding
            //{
            //	Path = new PropertyPath("Top"),
            //	Mode = BindingMode.TwoWay,
            //	Converter = new DeviceToLogicalYConverter()
            //});
            //SetBinding(WidthProperty, new Binding
            //{
            //	Path = new PropertyPath("Width"),
            //	Mode = BindingMode.TwoWay,
            //	Converter = new DeviceToLogicalXConverter()
            //});
            //SetBinding(HeightProperty, new Binding
            //{
            //	Path = new PropertyPath("Height"),
            //	Mode = BindingMode.TwoWay,
            //	Converter = new DeviceToLogicalYConverter()
            //});

            UIElementAutomationPeer.CreatePeerForElement(this);

            Application.Current.MainWindow = this;
        }
        protected override List <AutomationPeer> GetChildrenCore()
        {
            List <AutomationPeer> childrenCore = new List <AutomationPeer>();
            DateTimePicker        dtp          = (DateTimePicker)base.Owner;

            AutomationPeer tb = UIElementAutomationPeer.CreatePeerForElement(dtp.textBox);

            if (tb != null)
            {
                childrenCore.Add(tb);
            }

            AutomationPeer button = UIElementAutomationPeer.CreatePeerForElement(dtp.pickerBase.toggleButton);

            if (button != null)
            {
                childrenCore.Add(button);
            }

            if (dtp.pickerBase.IsDropDownOpen && dtp.monthCalendar != null)
            {
                AutomationPeer calendar = UIElementAutomationPeer.CreatePeerForElement(dtp.monthCalendar);
                if (calendar != null)
                {
                    childrenCore.Add(calendar);
                }
            }

            return(childrenCore);
        }
Beispiel #26
0
#pragma warning restore CS8619 // Nullability of reference types in value doesn't match target type.

            static AutomationPeer?CreatePeerForElement(DependencyObject o)
            {
                return(o switch
                {
                    UIElement uiElement => UIElementAutomationPeer.CreatePeerForElement(uiElement),
                    UIElement3D uiElement3D => UIElement3DAutomationPeer.CreatePeerForElement(uiElement3D),
                    _ => null,
                });
Beispiel #27
0
        private UIElementAutomationPeer GetStatusBarAutomationPeer(FrameworkElement element)
        {
            UIElementAutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(element) as UIElementAutomationPeer;

            return(this.EnumerateElement(automationPeer, peer =>
                                         peer?.GetAutomationControlType() == AutomationControlType.StatusBar &&
                                         peer.GetAutomationId() == "StatusBarContainer"));
        }
Beispiel #28
0
        /// <summary>
        /// Constructor
        /// </summary>
        public ImageChooseButton()
        {
            KinectCursor.AddCursorEnterHandler(this, OnCursorEnter);
            KinectCursor.AddCursorLeaveHandler(this, OnCursorLeave);

            // Get the automation peer that can invoke this button properly.
            _invoker = (IInvokeProvider)UIElementAutomationPeer.CreatePeerForElement(this).GetPattern(PatternInterface.Invoke);
        }
Beispiel #29
0
 private void FocusElement()
 {
     if (this.SelectedElement == null)
     {
         return;
     }
     UIElementAutomationPeer.CreatePeerForElement((UIElement)this.ChartArea).RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged);
 }
Beispiel #30
0
        // Token: 0x06007247 RID: 29255 RVA: 0x0020ABF0 File Offset: 0x00208DF0
        internal static AutomationPeer GetEnclosingAutomationPeer(ITextPointer start, ITextPointer end, out ITextPointer elementStart, out ITextPointer elementEnd)
        {
            List <object>       list        = new List <object>();
            List <ITextPointer> list2       = new List <ITextPointer>();
            ITextPointer        textPointer = start.CreatePointer();

            while (typeof(TextElement).IsAssignableFrom(textPointer.ParentType))
            {
                textPointer.MoveToElementEdge(ElementEdge.BeforeStart);
                object obj = textPointer.GetAdjacentElement(LogicalDirection.Forward);
                if (obj != null)
                {
                    list.Insert(0, obj);
                    list2.Insert(0, textPointer.CreatePointer(LogicalDirection.Forward));
                }
            }
            List <object>       list3 = new List <object>();
            List <ITextPointer> list4 = new List <ITextPointer>();

            textPointer = end.CreatePointer();
            while (typeof(TextElement).IsAssignableFrom(textPointer.ParentType))
            {
                textPointer.MoveToElementEdge(ElementEdge.AfterEnd);
                object obj = textPointer.GetAdjacentElement(LogicalDirection.Backward);
                if (obj != null)
                {
                    list3.Insert(0, obj);
                    list4.Insert(0, textPointer.CreatePointer(LogicalDirection.Backward));
                }
            }
            AutomationPeer automationPeer = null;
            ITextPointer   textPointer2;

            elementEnd   = (textPointer2 = null);
            elementStart = textPointer2;
            for (int i = Math.Min(list.Count, list3.Count); i > 0; i--)
            {
                if (list[i - 1] == list3[i - 1])
                {
                    object obj = list[i - 1];
                    if (obj is UIElement)
                    {
                        automationPeer = UIElementAutomationPeer.CreatePeerForElement((UIElement)obj);
                    }
                    else if (obj is ContentElement)
                    {
                        automationPeer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)obj);
                    }
                    if (automationPeer != null)
                    {
                        elementStart = list2[i - 1];
                        elementEnd   = list4[i - 1];
                        break;
                    }
                }
            }
            return(automationPeer);
        }