///
        internal override void SetValueCore(double val)
        {
            double       horizontalPercent = -1;
            double       verticalPercent   = -1;
            ScrollBar    sb = Owner as ScrollBar;
            ScrollViewer sv = sb.TemplatedParent as ScrollViewer;

            if (sv == null)
            {
                base.SetValueCore(val);
            }
            else
            {
                if (sb.Orientation == Orientation.Horizontal)
                {
                    horizontalPercent = (val / (sv.ExtentWidth - sv.ViewportWidth)) * 100;
                }
                else
                {
                    verticalPercent = (val / (sv.ExtentHeight - sv.ViewportHeight)) * 100;
                }

                ScrollViewerAutomationPeer svAP           = UIElementAutomationPeer.FromElement(sv) as ScrollViewerAutomationPeer;
                IScrollProvider            scrollProvider = svAP as IScrollProvider;
                scrollProvider.SetScrollPercent(horizontalPercent, verticalPercent);
            }
        }
示例#2
0
 internal void RaiseAutomationEvents(double extentX, double extentY, double viewportX, double viewportY, double offsetX, double offsetY)
 {
     if (ScrollViewerAutomationPeer.AutomationIsScrollable(extentX, viewportX) != ((IScrollProvider)this).HorizontallyScrollable)
     {
         base.RaisePropertyChangedEvent(ScrollPatternIdentifiers.HorizontallyScrollableProperty, ScrollViewerAutomationPeer.AutomationIsScrollable(extentX, viewportX), ((IScrollProvider)this).HorizontallyScrollable);
     }
     if (ScrollViewerAutomationPeer.AutomationIsScrollable(extentY, viewportY) != ((IScrollProvider)this).VerticallyScrollable)
     {
         base.RaisePropertyChangedEvent(ScrollPatternIdentifiers.VerticallyScrollableProperty, ScrollViewerAutomationPeer.AutomationIsScrollable(extentY, viewportY), ((IScrollProvider)this).VerticallyScrollable);
     }
     if (ScrollViewerAutomationPeer.AutomationGetViewSize(extentX, viewportX) != ((IScrollProvider)this).HorizontalViewSize)
     {
         base.RaisePropertyChangedEvent(ScrollPatternIdentifiers.HorizontalViewSizeProperty, ScrollViewerAutomationPeer.AutomationGetViewSize(extentX, viewportX), ((IScrollProvider)this).HorizontalViewSize);
     }
     if (ScrollViewerAutomationPeer.AutomationGetViewSize(extentY, viewportY) != ((IScrollProvider)this).VerticalViewSize)
     {
         base.RaisePropertyChangedEvent(ScrollPatternIdentifiers.VerticalViewSizeProperty, ScrollViewerAutomationPeer.AutomationGetViewSize(extentY, viewportY), ((IScrollProvider)this).VerticalViewSize);
     }
     if (ScrollViewerAutomationPeer.AutomationGetScrollPercent(extentX, viewportX, offsetX) != ((IScrollProvider)this).HorizontalScrollPercent)
     {
         base.RaisePropertyChangedEvent(ScrollPatternIdentifiers.HorizontalScrollPercentProperty, ScrollViewerAutomationPeer.AutomationGetScrollPercent(extentX, viewportX, offsetX), ((IScrollProvider)this).HorizontalScrollPercent);
     }
     if (ScrollViewerAutomationPeer.AutomationGetScrollPercent(extentY, viewportY, offsetY) != ((IScrollProvider)this).VerticalScrollPercent)
     {
         base.RaisePropertyChangedEvent(ScrollPatternIdentifiers.VerticalScrollPercentProperty, ScrollViewerAutomationPeer.AutomationGetScrollPercent(extentY, viewportY, offsetY), ((IScrollProvider)this).VerticalScrollPercent);
     }
 }
示例#3
0
        // Token: 0x060027D3 RID: 10195 RVA: 0x000BAACC File Offset: 0x000B8CCC
        internal override void SetValueCore(double val)
        {
            double       horizontalPercent = -1.0;
            double       verticalPercent   = -1.0;
            ScrollBar    scrollBar         = base.Owner as ScrollBar;
            ScrollViewer scrollViewer      = scrollBar.TemplatedParent as ScrollViewer;

            if (scrollViewer == null)
            {
                base.SetValueCore(val);
                return;
            }
            if (scrollBar.Orientation == Orientation.Horizontal)
            {
                horizontalPercent = val / (scrollViewer.ExtentWidth - scrollViewer.ViewportWidth) * 100.0;
            }
            else
            {
                verticalPercent = val / (scrollViewer.ExtentHeight - scrollViewer.ViewportHeight) * 100.0;
            }
            ScrollViewerAutomationPeer scrollViewerAutomationPeer = UIElementAutomationPeer.FromElement(scrollViewer) as ScrollViewerAutomationPeer;
            IScrollProvider            scrollProvider             = scrollViewerAutomationPeer;

            scrollProvider.SetScrollPercent(horizontalPercent, verticalPercent);
        }
示例#4
0
 // Token: 0x060027E2 RID: 10210 RVA: 0x000BAF87 File Offset: 0x000B9187
 private static double AutomationGetScrollPercent(double extent, double viewport, double actualOffset)
 {
     if (!ScrollViewerAutomationPeer.AutomationIsScrollable(extent, viewport))
     {
         return(-1.0);
     }
     return(actualOffset * 100.0 / (extent - viewport));
 }
        /// <summary>
        /// Gets the <see cref="AutomationPeer"/>s from the <see cref="DataFormAutomationPeer"/>.
        /// </summary>
        private void GetChildAutomationPeers()
        {
            this._firstItemButtonAutomationPeer = null;
            this._previousItemButtonAutomationPeer = null;
            this._nextItemButtonAutomationPeer = null;
            this._lastItemButtonAutomationPeer = null;
            this._editButtonAutomationPeer = null;
            this._newItemButtonAutomationPeer = null;
            this._deleteItemButtonAutomationPeer = null;
            this._commitButtonAutomationPeer = null;
            this._cancelButtonAutomationPeer = null;

            this._labelAutomationPeers = new List<TextBlockAutomationPeer>();
            this._inputControlAutomationPeers = new List<AutomationPeer>();
            this._descriptionAutomationPeers = new List<DescriptionViewerAutomationPeer>();

            List<AutomationPeer> automationPeers = this._dataFormAutomationPeer.GetChildren();

            foreach (AutomationPeer automationPeer in automationPeers)
            {
                string className = automationPeer.GetClassName();

                if (className == "Button")
                {
                    ButtonAutomationPeer buttonAutomationPeer = automationPeer as ButtonAutomationPeer;
                    Assert.IsNotNull(buttonAutomationPeer);

                    string automationId = automationPeer.GetAutomationId();

                    switch (automationId)
                    {
                        case "FirstItemButton":
                            this._firstItemButtonAutomationPeer = buttonAutomationPeer;
                            break;

                        case "PreviousItemButton":
                            this._previousItemButtonAutomationPeer = buttonAutomationPeer;
                            break;

                        case "NextItemButton":
                            this._nextItemButtonAutomationPeer = buttonAutomationPeer;
                            break;

                        case "LastItemButton":
                            this._lastItemButtonAutomationPeer = buttonAutomationPeer;
                            break;

                        case "EditButton":
                            this._editButtonAutomationPeer = buttonAutomationPeer;
                            break;

                        case "NewItemButton":
                            this._newItemButtonAutomationPeer = buttonAutomationPeer;
                            break;

                        case "DeleteItemButton":
                            this._deleteItemButtonAutomationPeer = buttonAutomationPeer;
                            break;

                        case "CommitButton":
                            this._commitButtonAutomationPeer = buttonAutomationPeer;
                            break;

                        case "CancelButton":
                            this._cancelButtonAutomationPeer = buttonAutomationPeer;
                            break;

                        default:
                            Assert.Fail("Unexpected ButtonAutomationPeer.");
                            break;
                    }
                }
                else if (className == "TextBlock")
                {
                    this._changeIndicatorAutomationPeer = automationPeer as TextBlockAutomationPeer;
                }
                else if (className == "ScrollViewer")
                {
                    this._scrollViewerAutomationPeer = automationPeer as ScrollViewerAutomationPeer;
                    Assert.IsNotNull(this._scrollViewerAutomationPeer);
                    List<AutomationPeer> formAutomationPeers = this._scrollViewerAutomationPeer.GetChildren();

                    for (int i = 0; i < formAutomationPeers.Count; i++)
                    {
                        if (i % 3 == 0)
                        {
                            TextBlockAutomationPeer textBlockAutomationPeer = formAutomationPeers[i] as TextBlockAutomationPeer;

                            if (textBlockAutomationPeer != null)
                            {
                                this._labelAutomationPeers.Add(textBlockAutomationPeer);
                            }
                        }
                        else if (i % 3 == 1)
                        {
                            this._inputControlAutomationPeers.Add(formAutomationPeers[i]);
                        }
                        else
                        {
                            DescriptionViewerAutomationPeer descriptionViewerAutomationPeer = formAutomationPeers[i] as DescriptionViewerAutomationPeer;

                            if (descriptionViewerAutomationPeer != null)
                            {
                                this._descriptionAutomationPeers.Add(descriptionViewerAutomationPeer);
                            }
                        }
                    }
                }
            }
        }