コード例 #1
0
        public override void IsOffScreen_ScrollViewer()
        {
            AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(CreateConcreteFrameworkElement());

            Assert.IsNotNull(peer, "IsOffScreen");

            DataGridColumnHeader control = ((FrameworkElementAutomationPeer)peer).Owner as DataGridColumnHeader;

            Assert.IsFalse(peer.IsOffscreen(), "IsOffScreen #1");
            control.Visibility = Visibility.Collapsed;
            Assert.IsTrue(peer.IsOffscreen(), "IsOffScreen #2");
            control.Visibility = Visibility.Visible;
            Assert.IsFalse(peer.IsOffscreen(), "IsOffScreen #3");
        }
コード例 #2
0
ファイル: PopupAutomationPeerTest.cs プロジェクト: ynkbt/moon
        public override void IsOffScreen()
        {
            Popup          popup = new Popup();
            AutomationPeer peer  = null;

            CreateAsyncTest(popup,
                            () => {
                peer = FrameworkElementAutomationPeer.CreatePeerForElement(popup);
                Assert.IsNotNull(peer, "FrameworkElementAutomationPeer.CreatePeerForElement");

                Assert.IsTrue(peer.IsOffscreen(), "#0");
            },
                            () => popup.IsOpen = true,
                            () => Assert.IsFalse(peer.IsOffscreen(), "#1"),
                            () => popup.IsOpen = false,
                            () => Assert.IsTrue(peer.IsOffscreen(), "#2"));
        }
コード例 #3
0
        protected override bool IsOffscreenCore()
        {
            AutomationPeer wrapperPeer = this.GetWrapperPeer();

            if (wrapperPeer != null)
            {
                return(wrapperPeer.IsOffscreen());
            }

            return(true);
        }
コード例 #4
0
        public void AllTests()
        {
            DataGridColumnHeader fe   = CreateConcreteFrameworkElement() as DataGridColumnHeader;
            AutomationPeer       peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe);

            // GetAutomationControlType
            Assert.AreEqual(AutomationControlType.HeaderItem, peer.GetAutomationControlType(), "GetAutomationControlType");

            // GetBoundingRectangle
            Rect boundingRectangle = peer.GetBoundingRectangle();

            Assert.AreNotEqual(0, boundingRectangle.X, "GetBoundingRectangle X");
            Assert.AreNotEqual(0, boundingRectangle.Y, "GetBoundingRectangle Y");
            Assert.AreNotEqual(0, boundingRectangle.Width, "GetBoundingRectangle Width");
            Assert.AreNotEqual(0, boundingRectangle.Height, "GetBoundingRectangle Height");

            // GetChildren
            List <AutomationPeer> children = peer.GetChildren();

            Assert.IsNotNull(children, "#0");
            Assert.AreEqual(1, children.Count, "#1");

            // IsKeyboardFocusable
            Assert.IsFalse(peer.IsKeyboardFocusable(), "IsKeyboardFocusable");

            // GetClassName
            Assert.AreEqual("DataGridColumnHeader", peer.GetClassName(), "#0");

            // IsContentElement
            Assert.IsFalse(peer.IsContentElement(), "#0");

            // GetName
            Assert.AreEqual(fe.Content, peer.GetName(), "GetName");

            // GetClickablePoint
            Point p = peer.GetClickablePoint();

            Assert.IsFalse(double.IsNaN(p.X), "#0");
            Assert.IsFalse(double.IsNaN(p.Y), "#1");

            // GetParent
            Assert.IsNotNull(peer.GetParent(), "GetParent");

            // IsOffscreen
            Assert.IsFalse(peer.IsOffscreen(), "IsOffScreen");
        }
コード例 #5
0
        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);
                    }
                }
            }
        }