protected override Atk.Object OnGetParent() { if (Peer == null) { return(null); } AutomationPeer parent = Peer.GetParent(); // XXX: This is a huge hack. // ScrollViewer is implemented so that its children // appear as the children of its parent. This gives us // a bit of a headache as the ScrollViewer is never // available in the Atk hierarchy, and an adapter is // never created for it. Thus we pretend it doesn't // exist. if (parent is ScrollViewerAutomationPeer && Peer is ItemAutomationPeer) { parent = parent.GetParent(); } if (parent == null) { return(DynamicAdapterFactory.Instance.RootVisualAdapter); } return(DynamicAdapterFactory.Instance.GetAdapter(parent)); }
internal static bool InvalidateAutomationPeer( DependencyObject o, out UIElement e, out ContentElement ce, out UIElement3D e3d) { e = null; ce = null; e3d = null; AutomationPeer ap = null; e = o as UIElement; if (e != null) { if (e.HasAutomationPeer == true) { ap = e.GetAutomationPeer(); } } else { ce = o as ContentElement; if (ce != null) { if (ce.HasAutomationPeer == true) { ap = ce.GetAutomationPeer(); } } else { e3d = o as UIElement3D; if (e3d != null) { if (e3d.HasAutomationPeer == true) { ap = e3d.GetAutomationPeer(); } } } } if (ap != null) { ap.InvalidateAncestorsRecursive(); // Check for parent being non-null while stopping as we don't want to stop in between due to peers not connected to AT // those peers sometimes gets created to serve for various patterns. // e.g: ScrollViewAutomationPeer for Scroll Pattern in case of ListBox. if (ap.GetParent() != null) { return(false); } } return(true); }
// Return proxy representing element in specified direction (parent/next/firstchild/etc.) private object InContextNavigate(object arg) { NavigateDirection direction = (NavigateDirection)arg; AutomationPeer dest; AutomationPeer peer = Peer; if (peer == null) { return(null); } switch (direction) { case NavigateDirection.Parent: dest = peer.GetParent(); break; case NavigateDirection.FirstChild: if (!peer.IsInteropPeer) { dest = peer.GetFirstChild(); } else { return(peer.GetInteropChild()); } break; case NavigateDirection.LastChild: if (!peer.IsInteropPeer) { dest = peer.GetLastChild(); } else { return(peer.GetInteropChild()); } break; case NavigateDirection.NextSibling: dest = peer.GetNextSibling(); break; case NavigateDirection.PreviousSibling: dest = peer.GetPreviousSibling(); break; default: dest = null; break; } return(StaticWrap(dest, peer)); }
public override void GetParentTest() { CreateAsyncTest(calendar, () => { List <AutomationPeer> buttonChildren = GetButtonChildren(); AutomationPeer parent = FrameworkElementAutomationPeer.CreatePeerForElement(calendar); AutomationPeer button = buttonChildren [0]; Assert.AreEqual(parent, button.GetParent(), "GetParent"); TestPanel.Children.Remove(calendar); }); }
public static AutomationPeer Navigate(this AutomationPeer peer, NavigateDirection direction) { List <AutomationPeer> children = null; if (direction == NavigateDirection.FirstChild || direction == NavigateDirection.LastChild) { children = peer.GetChildren(); if (children == null || children.Count == 0) { return(null); } if (direction == NavigateDirection.FirstChild) { return(children [0]); } return(children [children.Count - 1]); } var parent = peer.GetParent(); if (direction == NavigateDirection.Parent || parent == null) { return(parent); } children = parent.GetChildren(); if (children == null) { return(null); } AutomationPeer previous = null; AutomationPeer current = null; foreach (AutomationPeer child in children) { previous = current; current = child; if (child == peer && direction == NavigateDirection.PreviousSibling) { return(previous); } if (previous == peer && direction == NavigateDirection.NextSibling) { return(current); } } return(null); }
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"); }
// Return proxy representing the root of this WCP tree... private object InContextFragmentRoot(object unused) { AutomationPeer peer = Peer; AutomationPeer root = peer; if (root == null) { return(null); } while (true) { AutomationPeer parent = root.GetParent(); if (parent == null) { break; } root = parent; } return(StaticWrap(root, peer)); }