private Atk.Object GetObjectAtRow(IRawElementProviderFragment provider, int target, ref int index) { if (provider == null) { return(null); } if (!IsListItem(provider)) { return(GetObjectAtRow(provider.Navigate(NavigateDirection.NextSibling), target, ref index)); } if (index == target) { return(AutomationBridge.GetAdapterForProviderLazy(provider)); } index++; if (IsExpanded(provider)) { Atk.Object result = GetObjectAtRow(provider.Navigate(NavigateDirection.FirstChild), target, ref index); if (index == target && result != null) { return(result); } } return(GetObjectAtRow(provider.Navigate(NavigateDirection.NextSibling), target, ref index)); }
private ISelectionItemProvider ChildItemAtIndex(int i) { Adapter parentAdapter = AutomationBridge.GetAdapterForProviderSemiLazy(ChildrenHolder); if (parentAdapter == null) { Log.Error("Can't get adapter for Selection ChildrenHolder"); return(null); } Adapter adapter = parentAdapter.RefAccessibleChild(i) as Adapter; if (adapter == null || adapter.Provider == null) { return(null); } ISelectionItemProvider ret = (ISelectionItemProvider)adapter.Provider.GetPatternProvider (SelectionItemPatternIdentifiers.Pattern.Id); if (ret != null) { return(ret); } IRawElementProviderFragment fragment = adapter.Provider as IRawElementProviderFragment; if (fragment != null) { fragment = fragment.Navigate(NavigateDirection.Parent); } if (fragment != null && (int)fragment.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id) == ControlType.DataItem.Id) { ret = (ISelectionItemProvider)fragment.GetPatternProvider (SelectionItemPatternIdentifiers.Pattern.Id); } return(ret); }
internal virtual void RequestChildren() { if (requestedChildren == true) return; requestedChildren = true; AutomationBridge.AddChildrenToParent (Provider); }
public override void RaiseAutomationEvent(AutomationEvent eventId, AutomationEventArgs e) { if (eventId != AutomationElementIdentifiers.MenuClosedEvent) { base.RaiseAutomationEvent(eventId, e); } TopLevelRootItem.Instance.RemoveChild(Parent); ((ParentAdapter)Parent).RemoveChild(this); AutomationBridge.HandleTotalElementRemoval(this.Provider); }
public Atk.Object GetRowHeader(int row) { if (tableProvider == null) { return(null); } IRawElementProviderSimple [] items = tableProvider.GetRowHeaders(); if (row < 0 || row >= items.Length) { return(null); } return(AutomationBridge.GetAdapterForProviderLazy(items [row])); }
public Atk.Object GetColumnHeader(int column) { if (tableProvider == null) { return(null); } IRawElementProviderSimple [] items = tableProvider.GetColumnHeaders(); if (column < 0 || column >= items.Length) { return(null); } return(AutomationBridge.GetAdapterForProviderLazy(items [column])); }
public Atk.Object RefAt(int row, int column) { if (!AreRowColInBounds(row, column)) { return(null); } IRawElementProviderSimple[] headers = null; if (tableProvider != null) { headers = tableProvider.GetColumnHeaders(); } // Some controls will have column headers that need to // be mapped to row 0 if (row == 0 && headers != null) { if (column >= headers.Length) { return(null); } return(AutomationBridge.GetAdapterForProviderSemiLazy( headers [column])); } // GetItem indexes through only items, not headers, so // we need to remap the row number if (headers != null) { row -= 1; } IRawElementProviderSimple item; try { item = GridProvider.GetItem(row, column); } catch (ArgumentOutOfRangeException e) { Log.Debug(e); return(null); } if (item == null) { return(null); } return(AutomationBridge.GetAdapterForProviderSemiLazy(item)); }
//HACK: when I finished this refactoring I realized that MenuItem should not inherit from ComponentParentAdapter, so //FIXME: to overcome the need of multiple inheritance, use an ImplementorHelper for selection related features and // remove this transformation (although it may be useful for the case in which menus are added/removed) internal override void AddOneChild(Atk.Object child) { if (NAccessibleChildren > 0) { Log.Error("MenuItem adapter should not have any children."); return; } var parentMenu = AutomationBridge.CreateAdapter <ParentMenu> (Provider); if (parentMenu == null) { return; } AutomationBridge.PerformTransformation <ParentMenu> (this, parentMenu).AddOneChild(child); }
internal override void RequestChildren() { base.RequestChildren(); IRawElementProviderFragment fragmentProvider = Provider as IRawElementProviderFragment; var child = fragmentProvider.Navigate(NavigateDirection.FirstChild); while (child != null) { if (ControlType.Menu.Id.Equals(child.GetPropertyValue(AEIds.ControlTypeProperty.Id))) { AutomationBridge.AddChildrenToParent(child); } child = child.Navigate(NavigateDirection.NextSibling); } }
//this kind of search will work regardless of the technique used for the hierarchy layout used for //the children (mono-level or multi-level), because in the provider side it's multi-level always private Adapter RefProviderChildByDepthSearch(int pos) { Adapter adapter = null; var frag = resource.Provider as IRawElementProviderFragment; var parent = frag; while (pos >= 0) { if (frag == null) { return(null); } frag = frag.Navigate(NavigateDirection.FirstChild); if (frag == null) { frag = parent.Navigate(NavigateDirection.NextSibling); } if (frag != null) { parent = frag; } else { if (parent != resource.Provider) { parent = parent.Navigate(NavigateDirection.Parent); frag = parent.Navigate(NavigateDirection.NextSibling); } else { return(null); } } adapter = AutomationBridge.GetAdapterForProviderSemiLazy(frag); //we need this check because there are some children providers that don't have an Adapter if (adapter != null) { pos--; } } return(adapter); }
public SplitButton(IRawElementProviderSimple provider) : base(provider) { Role = Atk.Role.Filler; button = AutomationBridge.CreateAdapter <Button> (provider); if (button != null) { button.ManagesRemoval = true; base.AddOneChild(button); } ec_button = AutomationBridge.CreateAdapter <ExpandCollapseButton> (provider); if (ec_button != null) { ec_button.ManagesRemoval = true; base.AddOneChild(ec_button); } }
public Atk.Object RefSelection(int i) { IRawElementProviderSimple[] selectedElements = GetSelection(); if (selectedElements.Length == 0 || (i < 0 || i >= selectedElements.Length)) { return(null); } IRawElementProviderSimple provider = selectedElements [i]; if (provider == null) { return(null); } if (provider is IRawElementProviderFragment && (int)provider.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id) == ControlType.DataItem.Id) { provider = ((IRawElementProviderFragment)provider).Navigate(NavigateDirection.FirstChild); } return(AutomationBridge.GetAdapterForProviderSemiLazy(provider)); }
internal override void PostInit() { base.PostInit(); if (balloonWindow) { fakeLabel = AutomationBridge.CreateAdapter <TextLabel> (Provider); if (fakeLabel != null) { AddOneChild(fakeLabel); } fakeImage = AutomationBridge.CreateAdapter <Image> (Provider); if (fakeImage != null) { AddOneChild(fakeImage); } } else { if (RefStateSet().ContainsState(Atk.StateType.Modal)) { Role = Atk.Role.Dialog; } } }