示例#1
0
文件: MenuItem.cs 项目: mono/uia2atk
		public MenuItem (IRawElementProviderSimple provider) : base (provider)
		{
			if (provider == null)
				throw new ArgumentNullException ("provider");

			if ((provider as IRawElementProviderFragment) == null)
				throw new ArgumentException ("Provider for ParentMenu should be IRawElementProviderFragment");

			textExpert = TextImplementorFactory.GetImplementor (this, provider);

			Role = Atk.Role.MenuItem;

			string name = (string) provider.GetPropertyValue (AutomationElementIdentifiers.NameProperty.Id);
			if (!String.IsNullOrEmpty (name))
				Name = name;

			invokeProvider = (IInvokeProvider)
				provider.GetPatternProvider (InvokePatternIdentifiers.Pattern.Id);
			toggleProvider = (IToggleProvider)
				provider.GetPatternProvider (TogglePatternIdentifiers.Pattern.Id);
			selectionItemProvider = (ISelectionItemProvider)
				provider.GetPatternProvider (SelectionItemPatternIdentifiers.Pattern.Id);
			expandCollapseProvider = (IExpandCollapseProvider)
				provider.GetPatternProvider (ExpandCollapsePatternIdentifiers.Pattern.Id);

			actionExpert.Add ("click", "click", null, DoClick);
		}
示例#2
0
        public TreeItem(IRawElementProviderSimple provider) : base(provider)
        {
            invokeProvider        = (IInvokeProvider)provider.GetPatternProvider(InvokePatternIdentifiers.Pattern.Id);
            selectionItemProvider = (ISelectionItemProvider)provider.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id);

            expandCollapseProvider = provider.GetPatternProvider(
                ExpandCollapsePatternIdentifiers.Pattern.Id) as IExpandCollapseProvider;

            textExpert   = TextImplementorFactory.GetImplementor(this, provider);
            actionExpert = new ActionImplementorHelper();

            // TODO: Localize the name?s
            actionExpert.Add("click", "click", null, DoClick);
            if (ToggleProvider != null)
            {
                actionExpert.Add("toggle", "toggle", null, DoToggle);
            }
            if (invokeProvider != null)
            {
                actionExpert.Add("invoke", "invoke", null, DoInvoke);
            }

            IRawElementProviderFragment fragment = Provider as IRawElementProviderFragment;

            if (fragment != null && fragment.Navigate(NavigateDirection.FirstChild) != null)
            {
                AddExpandContractAction();
            }

            Role = (ToggleProvider != null? Atk.Role.CheckBox: Atk.Role.TableCell);

            imageExpert        = new ImageImplementorHelper(this);
            editableTextExpert = new EditableTextImplementorHelper(this, this, textExpert);
        }
示例#3
0
        private readonly ITextProvider2 publicITextProvider2;                                      // AccessibleObject as ITextProvider2

        /// <summary>
        ///  Create a new wrapper.
        /// </summary>
        internal InternalAccessibleObject(AccessibleObject accessibleImplemention)
        {
            // Get all the casts done here to catch any issues early
            publicIAccessible                     = (IAccessible)accessibleImplemention;
            publicIEnumVariant                    = (Oleaut32.IEnumVariant)accessibleImplemention;
            publicIOleWindow                      = (Ole32.IOleWindow)accessibleImplemention;
            publicIReflect                        = (IReflect)accessibleImplemention;
            publicIServiceProvider                = (Ole32.IServiceProvider)accessibleImplemention;
            publicIAccessibleEx                   = (IAccessibleEx)accessibleImplemention;
            publicIRawElementProviderSimple       = (IRawElementProviderSimple)accessibleImplemention;
            publicIRawElementProviderFragment     = (IRawElementProviderFragment)accessibleImplemention;
            publicIRawElementProviderFragmentRoot = (IRawElementProviderFragmentRoot)accessibleImplemention;
            publicIInvokeProvider                 = (IInvokeProvider)accessibleImplemention;
            publicIValueProvider                  = (IValueProvider)accessibleImplemention;
            publicIRangeValueProvider             = (IRangeValueProvider)accessibleImplemention;
            publicIExpandCollapseProvider         = (IExpandCollapseProvider)accessibleImplemention;
            publicIToggleProvider                 = (IToggleProvider)accessibleImplemention;
            publicITableProvider                  = (ITableProvider)accessibleImplemention;
            publicITableItemProvider              = (ITableItemProvider)accessibleImplemention;
            publicIGridProvider                   = (IGridProvider)accessibleImplemention;
            publicIGridItemProvider               = (IGridItemProvider)accessibleImplemention;
            publicILegacyIAccessibleProvider      = (ILegacyIAccessibleProvider)accessibleImplemention;
            publicISelectionProvider              = (ISelectionProvider)accessibleImplemention;
            publicISelectionItemProvider          = (ISelectionItemProvider)accessibleImplemention;
            publicIScrollItemProvider             = (IScrollItemProvider)accessibleImplemention;
            publicIRawElementProviderHwndOverride = (IRawElementProviderHwndOverride)accessibleImplemention;
            publicIMultiViewProvider              = (IMultipleViewProvider)accessibleImplemention;
            publicITextProvider                   = (ITextProvider)accessibleImplemention;
            publicITextProvider2                  = (ITextProvider2)accessibleImplemention;
            // Note: Deliberately not holding onto AccessibleObject to enforce all access through the interfaces
        }
示例#4
0
        public int GetSelectedRows(out int [] selected)
        {
            ISelectionProvider selection
                = (ISelectionProvider)resource.Provider.GetPatternProvider(SelectionPatternIdentifiers.Pattern.Id);

            if (selection == null)
            {
                selected = new int [0];
                return(0);
            }

            IRawElementProviderSimple [] items = selection.GetSelection();
            List <int> selectedItems           = new List <int> ();

            foreach (IRawElementProviderSimple item in items)
            {
                ISelectionItemProvider selectionItem
                    = (ISelectionItemProvider)item.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id);
                IGridItemProvider gridItem
                    = (IGridItemProvider)item.GetPatternProvider(GridItemPatternIdentifiers.Pattern.Id);
                if (selectionItem != null && gridItem != null)
                {
                    if (selectionItem.IsSelected)
                    {
                        selectedItems.Add(gridItem.Row);
                    }
                }
            }

            selected = selectedItems.ToArray();
            return(selectedItems.Count);
        }
示例#5
0
        public DirectoryTree2()
        {
            #region ContextMenu
            this.AddHandler(TreeViewItem.MouseRightButtonUpEvent, new MouseButtonEventHandler(
                                (MouseButtonEventHandler) delegate(object sender, MouseButtonEventArgs args)
            {
                TreeViewItem sourceItem = UITools.GetParentTreeViewItem(args.OriginalSource as FrameworkElement);
                if (sourceItem != null)
                {
                    if (!sourceItem.IsSelected)
                    {
                        TreeViewItemAutomationPeer peer   = new TreeViewItemAutomationPeer(sourceItem);
                        ISelectionItemProvider invokeProv = peer.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider;
                        invokeProv.Select();
                    }

                    if (sourceItem.IsSelected)
                    {
                        if (ContextMenuCommand != null && ContextMenuCommand.CanExecute(this.SelectedItem))
                        {
                            ContextMenuCommand.Execute(this.SelectedItem);
                        }
                    }
                }
            }));

            #endregion

            W7TreeViewItemUtils.SetIsEnabled(this, true);
        }
示例#6
0
文件: TreeItem.cs 项目: mono/uia2atk
		public TreeItem (IRawElementProviderSimple provider) : base (provider)
		{
			invokeProvider = (IInvokeProvider)provider.GetPatternProvider(InvokePatternIdentifiers.Pattern.Id);
			selectionItemProvider = (ISelectionItemProvider)provider.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id);

			expandCollapseProvider = provider.GetPatternProvider (
				ExpandCollapsePatternIdentifiers.Pattern.Id) as IExpandCollapseProvider;

			textExpert = TextImplementorFactory.GetImplementor (this, provider);
			actionExpert = new ActionImplementorHelper ();

			// TODO: Localize the name?s
			actionExpert.Add ("click", "click", null, DoClick);
			if (ToggleProvider != null)
				actionExpert.Add ("toggle", "toggle", null, DoToggle);
			if (invokeProvider != null)
				actionExpert.Add ("invoke", "invoke", null, DoInvoke);

			IRawElementProviderFragment fragment = Provider as IRawElementProviderFragment;
			if (fragment != null && fragment.Navigate (NavigateDirection.FirstChild) != null)
				AddExpandContractAction ();

			Role = (ToggleProvider != null? Atk.Role.CheckBox: Atk.Role.TableCell);

			imageExpert = new ImageImplementorHelper (this);
			editableTextExpert = new EditableTextImplementorHelper (this, this, textExpert);
		}
示例#7
0
        public virtual void AccordionItemPeerSelectAlreadySelected()
        {
            Accordion acc = new Accordion();

            acc.SelectionMode = AccordionSelectionMode.One;
            AccordionItem first = new AccordionItem {
                Header = "First"
            };
            AccordionItem second = new AccordionItem {
                Header = "Second"
            };

            acc.Items.Add(first);
            acc.Items.Add(second);

            ISelectionItemProvider provider = null;

            TestAsync(
                acc,
                () => second.IsSelected = true,
                () => Assert.IsFalse(first.IsSelected, "First item should not be selected!"),
                () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(first) as ISelectionItemProvider,
                () => provider.Select(),
                () => Thread.Sleep(40),
                () => Assert.IsTrue(first.IsSelected, "First item should be selected!"),
                () => Assert.IsFalse(second.IsSelected, "Second item should not be selected!"));
        }
        internal static object GetPropertyValue(this AutomationPeer itemPeer, int id)
        {
            if (AutomationElementIdentifiers.NameProperty.Id == id)
            {
                return(itemPeer.GetName());
            }
            else if (AutomationElementIdentifiers.AutomationIdProperty.Id == id)
            {
                return(itemPeer.GetAutomationId());
            }
            else if (AutomationElementIdentifiers.ControlTypeProperty.Id == id)
            {
                return(AutomationPeerExtensions.GetControlType(itemPeer).Id);
            }
            else if (SelectionItemPatternIdentifiers.IsSelectedProperty.Id == id)
            {
                ISelectionItemProvider selectionItemProvider = itemPeer.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider;

                if (selectionItemProvider == null)
                {
                    return(null);
                }

                return(selectionItemProvider.IsSelected);
            }

            return(null);
        }
示例#9
0
        public void ISelectionItemProviderTest()
        {
            IRawElementProviderSimple childProvider
                = ProviderFactory.GetProvider(tabPage1);

            ISelectionItemProvider sel_item_prov
                = (ISelectionItemProvider)childProvider.GetPatternProvider(
                      SelectionItemPatternIdentifiers.Pattern.Id);

            Assert.IsNotNull(sel_item_prov, "Not returning SelectionItemPatternIdentifiers");

            // Test IsSelected property
            tabControl.SelectTab(0);
            Assert.IsTrue(sel_item_prov.IsSelected, "IsSelected should return true when tab is selected");

            tabControl.SelectTab(1);
            Assert.IsFalse(sel_item_prov.IsSelected, "IsSelected should return false when tab is not selected");

            // Test .Select method and eventing
            bridge.ResetEventLists();

            sel_item_prov.Select();
            Assert.IsTrue(sel_item_prov.IsSelected,
                          "IsSelected should return true when tab is selected through ISelectionItem interface");

            Assert.AreEqual(1, bridge.AutomationPropertyChangedEvents.Count,
                            "No events fired for selection changed");

            Assert.AreEqual(1, bridge.GetAutomationEventCount(SelectionItemPatternIdentifiers.ElementSelectedEvent),
                            "IsSelected property change not fired");
        }
示例#10
0
        public virtual void AccordionItemPeerRemoveSelectionNoAccordion()
        {
            Accordion acc = new Accordion();

            acc.SelectionMode = AccordionSelectionMode.ZeroOrMore;
            AccordionItem first = new AccordionItem {
                Header = "First"
            };
            AccordionItem second = new AccordionItem {
                Header = "Second"
            };

            acc.Items.Add(first);
            acc.Items.Add(second);

            ISelectionItemProvider provider = null;

            TestAsync(
                acc,
                () => first.IsSelected = true,
                () => provider         = FrameworkElementAutomationPeer.CreatePeerForElement(first) as ISelectionItemProvider,
                () => provider.RemoveFromSelection(),
                () => Thread.Sleep(40),
                () => Assert.IsFalse(first.IsSelected, "Item should be not selected!"));
        }
示例#11
0
        public ListItem(IRawElementProviderSimple provider) : base(provider)
        {
            invokeProvider        = (IInvokeProvider)provider.GetPatternProvider(InvokePatternIdentifiers.Pattern.Id);
            selectionItemProvider = (ISelectionItemProvider)provider.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id);
            if (selectionItemProvider == null)
            {
                throw new ArgumentException("ListItem should always implement ISelectionItemProvider");
            }
            toggleProvider = (IToggleProvider)provider.GetPatternProvider(TogglePatternIdentifiers.Pattern.Id);

            textExpert         = TextImplementorFactory.GetImplementor(this, provider);
            imageExpert        = new ImageImplementorHelper(this);
            actionExpert       = new ActionImplementorHelper();
            editableTextExpert = new EditableTextImplementorHelper(this, this, textExpert);

            // TODO: Localize the name?s
            actionExpert.Add("click", "click", null, DoClick);
            if (toggleProvider != null)
            {
                actionExpert.Add("toggle", "toggle", null, DoToggle);
            }
            if (invokeProvider != null)
            {
                actionExpert.Add("invoke", "invoke", null, DoInvoke);
            }
            Role = (toggleProvider != null? Atk.Role.CheckBox: Atk.Role.ListItem);
        }
示例#12
0
        public bool SelectAllSelection()
        {
            List <AutomationPeer> children = adapter.GetChildren();

            if (children == null)
            {
                return(true);
            }

            foreach (AutomationPeer child in children)
            {
                ISelectionItemProvider childItem = child.GetPattern(
                    PatternInterface.SelectionItem) as ISelectionItemProvider;
                if (childItem == null)
                {
                    // Ignore this, as there could be
                    // non-SelectionItem children
                    continue;
                }

                try {
                    if (!childItem.IsSelected)
                    {
                        childItem.AddToSelection();
                    }
                } catch (InvalidOperationException e) {
                    Log.Debug(e);
                    return(false);
                }
            }

            return(true);
        }
示例#13
0
        public static async Task <bool> SimulateSelectItemAsync(
            this ComboBox comboBox,
            JoinableTaskFactory joinableTaskFactory,
            string itemText,
            bool mustExist = true
            )
        {
            await joinableTaskFactory.SwitchToMainThreadAsync();

            if (comboBox.Text == itemText)
            {
                return(true);
            }

            if (!await comboBox.SimulateExpandAsync(joinableTaskFactory))
            {
                return(false);
            }

            var peer = new ComboBoxAutomationPeer(comboBox);

            var children     = peer.GetChildren().OfType <ListBoxItemAutomationPeer>().ToList();
            var existingItem = children.Find(x => x.GetName() == itemText);

            if (existingItem is null)
            {
                if (mustExist)
                {
                    throw new InvalidOperationException(
                              $"Item '{itemText}' was not found in the combo box."
                              );
                }

                // Collapse the combo box, and then set the value explicitly
                if (
                    !await comboBox.SimulateCollapseAsync(joinableTaskFactory) ||
                    !await comboBox.SimulateSetTextAsync(joinableTaskFactory, itemText)
                    )
                {
                    return(false);
                }

                return(true);
            }
            else
            {
                ISelectionItemProvider selectionItemProvider = existingItem;
                selectionItemProvider.Select();

                // Wait for changes to propagate
                await Task.Yield();

                if (!await comboBox.SimulateCollapseAsync(joinableTaskFactory))
                {
                    return(false);
                }

                return(true);
            }
        }
示例#14
0
        void ISelectionItemProvider.AddToSelection()
        {
            if (!IsEnabled())
            {
                throw new ElementNotEnabledException();
            }

            ISelectionProvider selectionProvider = SelectionProvider;

            if (selectionProvider == null)
            {
                return;
            }

            ISelectionItemProvider selectionItemProvider = (ISelectionItemProvider)this;

            if (!selectionProvider.CanSelectMultiple)
            {
                IRawElementProviderSimple[] selection = selectionProvider.GetSelection();
                if (selection == null || selection.Length == 0)
                {
                    selectionItemProvider.Select();
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
            else
            {
                selectionItemProvider.Select();
            }
        }
示例#15
0
        public bool ClearSelection()
        {
            IRawElementProviderSimple[] selection
                = selectionProvider.GetSelection();
            if (selection == null || selection.Length == 0)
            {
                return(true);
            }

            bool result = true;

            foreach (IRawElementProviderSimple item in selection)
            {
                AutomationPeer         itemPeer = item.AutomationPeer;
                ISelectionItemProvider selItem  = itemPeer.GetPattern(
                    PatternInterface.SelectionItem) as ISelectionItemProvider;
                if (selItem == null)
                {
                    continue;
                }

                try {
                    if (selItem.IsSelected)
                    {
                        selItem.RemoveFromSelection();
                    }
                } catch (InvalidOperationException e) {
                    Log.Debug(e);
                    result = false;
                }
            }

            return(result);
        }
示例#16
0
        public void SelectionItemProvider_AddToSelection()
        {
            RadioButton radioButton = CreateConcreteFrameworkElement() as RadioButton;

            StackPanel stackPanel = new StackPanel();

            stackPanel.Children.Add(radioButton);
            TestPanel.Children.Add(stackPanel);

            Enqueue(() => {
                AutomationPeer peer
                    = FrameworkElementAutomationPeer.CreatePeerForElement(radioButton);

                ISelectionItemProvider selectionItem
                    = peer.GetPattern(PatternInterface.SelectionItem)
                      as ISelectionItemProvider;
                Assert.IsNotNull(selectionItem);

                radioButton.IsEnabled = false;
                try {
                    selectionItem.AddToSelection();
                    Assert.Fail("InvalidOperationException not raised when disabled");
                } catch (InvalidOperationException) { }

                radioButton.IsEnabled = true;
                try {
                    selectionItem.AddToSelection();
                    Assert.Fail("InvalidOperationException not raised when enabled");
                } catch (InvalidOperationException) { }
            });
            EnqueueTestComplete();
        }
        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);
        }
        public bool SelectAllSelection()
        {
            if (!selectionProvider.CanSelectMultiple)
            {
                return(false);
            }

            var child = ChildrenHolder.Navigate(NavigateDirection.FirstChild);

            while (child != null)
            {
                ISelectionItemProvider selectionItemProvider =
                    (ISelectionItemProvider)child.GetPatternProvider(
                        SelectionItemPatternIdentifiers.Pattern.Id);

                if (selectionItemProvider != null)
                {
                    try {
                        selectionItemProvider.AddToSelection();
                    } catch (InvalidOperationException e) {
                        Log.Debug(e);
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
                child = child.Navigate(NavigateDirection.NextSibling);
            }
            return(true);
        }
        public bool ClearSelection()
        {
            var  selectedElements = GetSelection();
            bool result           = true;

            if (selectedElements.Length == 0)
            {
                return(true);
            }
            for (int i = 0; i < selectedElements.Length; i++)
            {
                ISelectionItemProvider selectionItemProvider =
                    (ISelectionItemProvider)selectedElements[i].GetPatternProvider
                        (SelectionItemPatternIdentifiers.Pattern.Id);

                if (selectionItemProvider != null)
                {
                    try {
                        selectionItemProvider.RemoveFromSelection();
                    } catch (InvalidOperationException e) {
                        Log.Debug(e);
                        result = false;
                    }
                }
            }

            return(result);
        }
示例#20
0
        public MenuItem(IRawElementProviderSimple provider) : base(provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            if ((provider as IRawElementProviderFragment) == null)
            {
                throw new ArgumentException("Provider for ParentMenu should be IRawElementProviderFragment");
            }

            textExpert = TextImplementorFactory.GetImplementor(this, provider);

            Role = Atk.Role.MenuItem;

            string name = (string)provider.GetPropertyValue(AutomationElementIdentifiers.NameProperty.Id);

            if (!String.IsNullOrEmpty(name))
            {
                Name = name;
            }

            invokeProvider = (IInvokeProvider)
                             provider.GetPatternProvider(InvokePatternIdentifiers.Pattern.Id);
            toggleProvider = (IToggleProvider)
                             provider.GetPatternProvider(TogglePatternIdentifiers.Pattern.Id);
            selectionItemProvider = (ISelectionItemProvider)
                                    provider.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id);
            expandCollapseProvider = (IExpandCollapseProvider)
                                     provider.GetPatternProvider(ExpandCollapsePatternIdentifiers.Pattern.Id);

            actionExpert.Add("click", "click", null, DoClick);
        }
示例#21
0
        public bool AddRowSelection(int row)
        {
            if (row < 0 || row >= NRows)
            {
                return(false);
            }

            if (GridProvider == null)
            {
                return(false);
            }

            if (tableProvider != null)
            {
                IRawElementProviderSimple[] headers
                    = tableProvider.GetColumnHeaders();
                if (headers != null && headers.Length > 0)
                {
                    // In UIA, header rows cannot be selected
                    if (row == 0)
                    {
                        return(false);
                    }
                    row -= 1;
                }
            }

            IRawElementProviderSimple item;

            try {
                // UIA doesn't support row selection, so we select the first cell
                item = GridProvider.GetItem(row, 0);
            } catch (ArgumentOutOfRangeException e) {
                Log.Debug(e);
                return(false);
            }

            if (item == null)
            {
                return(false);
            }

            ISelectionItemProvider selectionItem
                = (ISelectionItemProvider)item.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id);

            if (selectionItem == null)
            {
                return(false);
            }

            try {
                selectionItem.AddToSelection();
            } catch (InvalidOperationException e) {
                Log.Debug(e);
                return(false);
            }

            return(true);
        }
示例#22
0
		protected override void InitializeAdditionalProviders ()
		{
			selProvider = (ISelectionItemProvider)Provider.GetPatternProvider (SelectionItemPatternIdentifiers.Pattern.Id);
			if (selProvider == null)
				throw new ArgumentException ("The provider for RadioButton should implement the SelectionItem pattern");
			imageImplementor = new ImageImplementorHelper (this);
			actionName = "click";
		}
示例#23
0
        public bool RemoveRowSelection(int row)
        {
            if (row < 0 || row >= NRows)
            {
                return(false);
            }

            if (GridProvider == null)
            {
                return(false);
            }

            if (tableProvider != null)
            {
                IRawElementProviderSimple[] headers
                    = tableProvider.GetColumnHeaders();
                if (headers != null && headers.Length > 0)
                {
                    // In UIA, header rows cannot be selected
                    if (row == 0)
                    {
                        return(false);
                    }
                    row--;
                }
            }

            IRawElementProviderSimple item = null;

            try {
                item = GridProvider.GetItem(row, 0);
            } catch (ArgumentOutOfRangeException e) {
                Log.Debug(e);
            }

            if (item == null)
            {
                return(false);
            }

            ISelectionItemProvider selectionItem
                = (ISelectionItemProvider)item.AutomationPeer.GetPattern(PatternInterface.SelectionItem);

            if (selectionItem == null)
            {
                return(false);
            }

            try {
                selectionItem.RemoveFromSelection();
            } catch (InvalidOperationException e) {
                Log.Debug(e);
                return(false);
            }

            return(true);
        }
示例#24
0
文件: TabPage.cs 项目: mono/uia2atk
		public TabPage (IRawElementProviderSimple provider): base (provider)
		{
			Role = Atk.Role.PageTab;
			selectionItemProvider = (ISelectionItemProvider)provider.GetPatternProvider (
			  SelectionItemPatternIdentifiers.Pattern.Id);
			if (selectionItemProvider == null)
				throw new ArgumentException (
				  "Provider for TabPage should implement ISelectionItemProvider");
		}
示例#25
0
 protected override void InitializeAdditionalProviders()
 {
     selProvider = (ISelectionItemProvider)Provider.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id);
     if (selProvider == null)
     {
         throw new ArgumentException("The provider for RadioButton should implement the SelectionItem pattern");
     }
     imageImplementor = new ImageImplementorHelper(this);
     actionName       = "click";
 }
示例#26
0
        public virtual void AccordionItemPeerAddSelectionNoAccordion()
        {
            AccordionItem          item     = new AccordionItem();
            ISelectionItemProvider provider = null;

            TestAsync(
                item,
                () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider,
                () => provider.AddToSelection());
        }
示例#27
0
        public virtual void AccordionItemPeerSelectionContainerNoParent()
        {
            AccordionItem          item     = new AccordionItem();
            ISelectionItemProvider provider = null;

            TestAsync(
                item,
                () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider,
                () => Assert.IsNull(provider.SelectionContainer, "AccordionItemAutomationPeer should not have a SelectionContainer!"));
        }
示例#28
0
        public virtual void AccordionItemPeerIsISelectionItemProvider()
        {
            AccordionItem          item     = new AccordionItem();
            ISelectionItemProvider provider = null;

            TestAsync(
                item,
                () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider,
                () => Assert.IsNotNull(provider, "AccordionItemAutomationPeer should implement ISelectionItemProvider!"));
        }
示例#29
0
 public TabPage(IRawElementProviderSimple provider) : base(provider)
 {
     Role = Atk.Role.PageTab;
     selectionItemProvider = (ISelectionItemProvider)provider.GetPatternProvider(
         SelectionItemPatternIdentifiers.Pattern.Id);
     if (selectionItemProvider == null)
     {
         throw new ArgumentException(
                   "Provider for TabPage should implement ISelectionItemProvider");
     }
 }
示例#30
0
        public virtual void AccordionItemPeerSelectNoAccordion()
        {
            AccordionItem          item     = new AccordionItem();
            ISelectionItemProvider provider = null;

            TestAsync(
                item,
                () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider,
                () => provider.Select(),
                () => Assert.IsTrue(item.IsSelected, "Item should be selected!"));
        }
示例#31
0
        private static void HandleIsSelectedProperty(ProxySimple el, IntPtr hwnd, int eventId)
        {
            ISelectionItemProvider selectionItem = el.GetPatternProvider(SelectionItemPattern.Pattern) as ISelectionItemProvider;

            if (selectionItem == null)
            {
                return;
            }

            RaisePropertyChangedEvent(el, SelectionItemPattern.IsSelectedProperty, selectionItem.IsSelected);
        }
示例#32
0
        /// <summary>Removes the current element from the collection of selected items.</summary>
        /// <exception cref="T:System.Windows.Automation.ElementNotAvailableException">UI Automation element is no longer available.</exception>
        // Token: 0x06002878 RID: 10360 RVA: 0x000BC788 File Offset: 0x000BA988
        void ISelectionItemProvider.RemoveFromSelection()
        {
            TreeViewItemAutomationPeer treeViewItemAutomationPeer = this.GetWrapperPeer() as TreeViewItemAutomationPeer;

            if (treeViewItemAutomationPeer != null)
            {
                ISelectionItemProvider selectionItemProvider = treeViewItemAutomationPeer;
                selectionItemProvider.RemoveFromSelection();
                return;
            }
            base.ThrowElementNotAvailableException();
        }
示例#33
0
        public virtual void AccordionItemPeerIsSelected()
        {
            AccordionItem          item     = new AccordionItem();
            ISelectionItemProvider provider = null;

            TestAsync(
                item,
                () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider,
                () => Assert.IsFalse(provider.IsSelected, "AccordionItemAutomationPeer should not be selected!"),
                () => item.IsSelected = true,
                () => Assert.IsTrue(provider.IsSelected, "AccordionItemAutomationPeer should be selected!"));
        }
示例#34
0
        public virtual void AccordionItemPeerSupportsSelection()
        {
            AccordionItem item = new AccordionItem();
            AccordionItemAutomationPeer peer     = null;
            ISelectionItemProvider      provider = null;

            TestAsync(
                item,
                () => peer     = FrameworkElementAutomationPeer.CreatePeerForElement(item) as AccordionItemAutomationPeer,
                () => provider = peer.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider,
                () => Assert.IsNotNull(provider, "ISelectionItemProvider peer should not be null!"));
        }
示例#35
0
		public ComboBoxItem (IRawElementProviderSimple provider) : base (provider)
		{
			int controlType = (int) provider.GetPropertyValue (AutomationElementIdentifiers.ControlTypeProperty.Id);
			selectionItemProvider = (ISelectionItemProvider)provider.GetPatternProvider (
			  SelectionItemPatternIdentifiers.Pattern.Id);
			if (selectionItemProvider == null)
				throw new ArgumentException (
				  String.Format ("Provider for ComboBoxItem (control type {0}) should implement ISelectionItemProvider", controlType));

			textExpert = TextImplementorFactory.GetImplementor (this, provider);
			
			//FIXME: take in account ComboBox style changes at runtime
			if (ParentIsSimple ())
				Role = Atk.Role.TableCell;
			else
				Role = Atk.Role.MenuItem;
		}
示例#36
0
文件: ListItem.cs 项目: mono/uia2atk
		public ListItem (IRawElementProviderSimple provider) : base (provider)
		{
			invokeProvider = (IInvokeProvider)provider.GetPatternProvider(InvokePatternIdentifiers.Pattern.Id);
			selectionItemProvider = (ISelectionItemProvider)provider.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id);
			if (selectionItemProvider == null)
				throw new ArgumentException ("ListItem should always implement ISelectionItemProvider");
			toggleProvider = (IToggleProvider) provider.GetPatternProvider (TogglePatternIdentifiers.Pattern.Id);

			textExpert = TextImplementorFactory.GetImplementor (this, provider);
			imageExpert = new ImageImplementorHelper (this);
			actionExpert = new ActionImplementorHelper ();
			editableTextExpert = new EditableTextImplementorHelper (this, this, textExpert);

			// TODO: Localize the name?s
			actionExpert.Add ("click", "click", null, DoClick);
			if (toggleProvider != null)
				actionExpert.Add ("toggle", "toggle", null, DoToggle);
			if (invokeProvider != null)
				actionExpert.Add ("invoke", "invoke", null, DoInvoke);
			Role = (toggleProvider != null? Atk.Role.CheckBox: Atk.Role.ListItem);
		}
示例#37
0
		public SelectionItemPatternWrapper (ISelectionItemProvider provider)
		{
			this.provider = provider;
		}
示例#38
0
文件: MenuItem.cs 项目: mono/uia2atk
		public override void RaiseAutomationPropertyChangedEvent (AutomationPropertyChangedEventArgs e)
		{
			if (e.Property.Id == AutomationElementIdentifiers.IsOffscreenProperty.Id) {
				selected = (bool) e.NewValue ? false : selected;
				NotifyStateChange (Atk.StateType.Showing);
			} else if (e.Property.Id == AutomationElementIdentifiers.HasKeyboardFocusProperty.Id) {
				NotifyStateChange (Atk.StateType.Selected, (bool) e.NewValue);
				base.RaiseAutomationPropertyChangedEvent (e);
			} else if (e.Property == AutomationElementIdentifiers.IsTogglePatternAvailableProperty) {
				toggleProvider = (IToggleProvider)
					Provider.GetPatternProvider (TogglePatternIdentifiers.Pattern.Id);
				NotifyStateChange (Atk.StateType.Checked, Checked);
			} else if (e.Property == AutomationElementIdentifiers.IsInvokePatternAvailableProperty) {
				invokeProvider = (IInvokeProvider)
					Provider.GetPatternProvider (InvokePatternIdentifiers.Pattern.Id);
			} else if (e.Property == AutomationElementIdentifiers.IsExpandCollapsePatternAvailableProperty) {
				expandCollapseProvider = (IExpandCollapseProvider)
					Provider.GetPatternProvider (ExpandCollapsePatternIdentifiers.Pattern.Id);
			} else if (e.Property == AutomationElementIdentifiers.IsSelectionItemPatternAvailableProperty) {
				selectionItemProvider = (ISelectionItemProvider)
					Provider.GetPatternProvider (SelectionItemPatternIdentifiers.Pattern.Id);
				NotifyStateChange (Atk.StateType.Checked, SelectionItemSelected);
			} else {
				base.RaiseAutomationPropertyChangedEvent (e);
			}
		}
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------
 
        #region Constructors

        private SelectionItemProviderWrapper( AutomationPeer peer, ISelectionItemProvider iface )
        {
            _peer = peer;
            _iface = iface;
        }