예제 #1
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);
        }
예제 #2
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
        }
예제 #3
0
        private static void HandleRowProperty(ProxySimple el, IntPtr hwnd, int eventId)
        {
            IGridItemProvider gridItem = el.GetPatternProvider(GridItemPattern.Pattern) as IGridItemProvider;

            if (gridItem == null)
            {
                return;
            }

            RaisePropertyChangedEvent(el, GridItemPattern.RowProperty, gridItem.Row);
        }
예제 #4
0
        public int GetRowExtentAt(int row, int column)
        {
            if (!AreRowColInBounds(row, column))
            {
                return(-1);
            }

            IGridItemProvider g = null;

            if (tableProvider != null)
            {
                IRawElementProviderSimple[] headers
                    = tableProvider.GetColumnHeaders();
                if (headers != null && headers.Length > 0)
                {
                    if (row == 0)
                    {
                        g = headers [column].AutomationPeer.GetPattern(PatternInterface.GridItem)
                            as IGridItemProvider;
                        return((g == null) ? 0 : g.RowSpan);
                    }
                    row--;
                }
            }

            IRawElementProviderSimple item;

            try {
                item = GridProvider.GetItem(row, column);
            } catch (ArgumentOutOfRangeException e) {
                Log.Debug(e);
                return(-1);
            }
            if (item == null)
            {
                return(-1);
            }

            g = (IGridItemProvider)item.AutomationPeer.GetPattern(PatternInterface.GridItem);
            if (g != null)
            {
                return(g.RowSpan);
            }
            return(1);
        }
예제 #5
0
        public void StatusBarPanelIGridItemProviderColumnSpanTest()
        {
            StatusBar statusBar = new StatusBar();
            IRawElementProviderFragmentRoot rootProvider =
                (IRawElementProviderFragmentRoot)GetProviderFromControl(statusBar);

            statusBar.Panels.Add("Panel");
            IRawElementProviderFragment childProvider =
                rootProvider.Navigate(NavigateDirection.FirstChild);

            IGridItemProvider gridItemProvider = (IGridItemProvider)
                                                 childProvider.GetPatternProvider(GridItemPatternIdentifiers.Pattern.Id);

            Assert.IsNotNull(gridItemProvider,
                             "Not returning GridItemPatternIdentifiers.");

            Assert.AreEqual(1, gridItemProvider.ColumnSpan, "ColumnSpan value");
        }
예제 #6
0
        public int GetColumnExtentAt(int row, int column)
        {
            if (!AreRowColInBounds(row, column))
            {
                return(-1);
            }

            IGridItemProvider g = null;

            if (tableProvider != null)
            {
                IRawElementProviderSimple[] headers
                    = tableProvider.GetColumnHeaders();
                if (headers != null && headers.Length > 0)
                {
                    if (row == 0)
                    {
                        g = headers [column].GetPatternProvider(
                            GridItemPatternIdentifiers.Pattern.Id)
                            as IGridItemProvider;
                        return((g == null) ? 0 : g.ColumnSpan);
                    }
                    row -= 1;
                }
            }

            IRawElementProviderSimple item;

            try {
                item = GridProvider.GetItem(row, column);
            } catch (ArgumentOutOfRangeException e) {
                Log.Debug(e);
                return(-1);
            }

            g = (IGridItemProvider)item.GetPatternProvider(GridItemPatternIdentifiers.Pattern.Id);
            if (g != null)
            {
                return(g.ColumnSpan);
            }
            return(-1);
        }
예제 #7
0
        public void ListItemIGridItemProviderTest()
        {
            IRawElementProviderFragmentRoot dataGridProvider;
            IRawElementProviderFragment     child;

            GetDataGridAndFirstListItem(out dataGridProvider, out child);

            IGridProvider gridProvider = (IGridProvider)
                                         dataGridProvider.GetPatternProvider(GridPatternIdentifiers.Pattern.Id);

            SelectionRange range = calendar.GetDisplayRange(false);

            int numChildren = (range.End - range.Start).Days;

            for (int i = 0; i < numChildren && child != null; i++)
            {
                TestProperty(child,
                             AutomationElementIdentifiers.ControlTypeProperty,
                             ControlType.ListItem.Id);

                IGridItemProvider itemProvider = child.GetPatternProvider(
                    GridItemPatternIdentifiers.Pattern.Id) as IGridItemProvider;
                Assert.IsNotNull(itemProvider,
                                 "Does not implement IGridItemProvider");

                int row = itemProvider.Row;
                int col = itemProvider.Column;
                Assert.AreEqual(gridProvider.GetItem(row, col),
                                child, "Child found via navigation is reporting incorrect row and/or column values");

                Assert.AreEqual(1, itemProvider.RowSpan,
                                "Child reporting larger RowSpan than expected");
                Assert.AreEqual(1, itemProvider.ColumnSpan,
                                "Child reporting larger ColumnSpan than expected");

                Assert.AreEqual(dataGridProvider, itemProvider.ContainingGrid,
                                "Child's ContainingGrid is not its DataGrid parent.");

                child = ((IRawElementProviderFragment)child)
                        .Navigate(NavigateDirection.NextSibling);
            }
        }
예제 #8
0
        public void IGridItemProvider_Methods()
        {
            AutomationPeer        calendarAutomationPeer = null;
            DateTime              date           = new DateTime(2000, 2, 2);
            List <AutomationPeer> buttonChildren = null;

            CreateAsyncTest(calendar,
                            () => {
                calendarAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(calendar);
                Assert.IsNotNull(calendarAutomationPeer, "#0");

                buttonChildren = GetButtonChildren();

                Assert.IsNotNull(buttonChildren.Count, "#1");
                Assert.AreEqual(12, buttonChildren.Count, "#2");
            },
                            () => { calendar.SelectedDate = date; },
                            () => {
                int count = 0;
                foreach (AutomationPeer peer in (from c in calendarAutomationPeer.GetChildren()
                                                 where c.GetType() == typeof(CalendarButtonAutomationPeer)
                                                 select c))
                {
                    FrameworkElementAutomationPeer feap = peer as FrameworkElementAutomationPeer;
                    Assert.IsNotNull("#3");

                    IGridItemProvider gridItem = (IGridItemProvider)peer.GetPattern(PatternInterface.GridItem);
                    Assert.IsNotNull(gridItem, "#4");

                    Assert.AreEqual(feap.Owner.GetValue(Grid.ColumnProperty), gridItem.Column, "#5");
                    Assert.AreEqual((int)feap.Owner.GetValue(Grid.RowProperty), gridItem.Row, "#6");
                    Assert.AreEqual(1, gridItem.ColumnSpan, "#7");
                    Assert.AreEqual(1, gridItem.RowSpan, "#8");
                    Assert.AreEqual(calendarAutomationPeer, new PeerFromProvider().GetPeerFromProvider(gridItem.ContainingGrid), "#9");

                    count++;
                }
                Assert.AreEqual(12, count, "#10");
            });
        }
예제 #9
0
        public int GetRowAtIndex(int index)
        {
            if (index <= 0)
            {
                return(-1);
            }

            // Map from Atk's 1-based system to UIA's 0-based
            // indicies
            index--;

            int ret = 0;

            if (tableProvider != null)
            {
                IRawElementProviderSimple[] headers
                    = tableProvider.GetColumnHeaders();
                if (headers != null && headers.Length > 0)
                {
                    if (index >= headers.Length)
                    {
                        ret = 1;
                    }
                }
            }

            Adapter child = RefProviderChildByDepthSearch(index);

            if (child != null && child.Provider != null)
            {
                IGridItemProvider g = (IGridItemProvider)child.Provider.GetPatternProvider(GridItemPatternIdentifiers.Pattern.Id);
                if (g != null)
                {
                    ret += g.Row;
                }
                return(ret);
            }
            return(-1);
        }
예제 #10
0
        public void StatusBarPanelIGridItemProviderContainingGridTest()
        {
            StatusBar statusBar = new StatusBar();
            IRawElementProviderFragmentRoot rootProvider =
                (IRawElementProviderFragmentRoot)GetProviderFromControl(statusBar);

            statusBar.Panels.Add("Panel");
            IRawElementProviderFragment childProvider =
                rootProvider.Navigate(NavigateDirection.FirstChild);

            IGridItemProvider gridItemProvider = (IGridItemProvider)
                                                 childProvider.GetPatternProvider(GridItemPatternIdentifiers.Pattern.Id);

            Assert.IsNotNull(gridItemProvider,
                             "Not returning GridItemPatternIdentifiers.");

            IRawElementProviderSimple parentProvider = (IRawElementProviderSimple)
                                                       childProvider.Navigate(NavigateDirection.Parent);
            IRawElementProviderSimple itemProvider = gridItemProvider.ContainingGrid;

            Assert.AreSame(parentProvider, itemProvider, "ContainingGrid value");
        }
예제 #11
0
        public int GetColumnAtIndex(int index)
        {
            if (index < 0)
            {
                return(-1);
            }

            int     num_invalid_elements = 0;
            Adapter child = RefProviderChildByDepthSearch(index, out num_invalid_elements);

            if (child != null && child.Peer != null)
            {
                IGridItemProvider g = (IGridItemProvider)child.Peer.GetPattern(PatternInterface.GridItem);
                if (g != null)
                {
                    return(g.Column);
                }
                else
                {
                    if (index < num_invalid_elements)
                    {
                        return(-1);
                    }

                    //this is needed because some columnsheader cells don't implement IGridItem!!
                    if (tableProvider != null)
                    {
                        var headers = tableProvider.GetColumnHeaders();
                        if (index < headers.Length + num_invalid_elements)
                        {
                            return(index - num_invalid_elements);
                        }
                    }
                }
            }
            return(-1);
        }
예제 #12
0
        public int GetRowAtIndex(int index)
        {
            if (index < 0)
            {
                return(-1);
            }

            int     num_invalid_elements = 0;
            Adapter child = RefProviderChildByDepthSearch(index, out num_invalid_elements);

            if (tableProvider != null)
            {
                IRawElementProviderSimple[] headers
                    = tableProvider.GetColumnHeaders();
                if (headers != null && headers.Length > 0 || num_invalid_elements > 0)
                {
                    if (index < headers.Length + num_invalid_elements)
                    {
                        return(-1);
                    }
                }
            }

            int ret = 0;

            if (child != null && child.Peer != null)
            {
                IGridItemProvider g = (IGridItemProvider)child.Peer.GetPattern(PatternInterface.GridItem);
                if (g != null)
                {
                    ret += g.Row;
                }
                return(ret);
            }
            return(-1);
        }
예제 #13
0
        public int GetColumnAtIndex(int index)
        {
            if (index <= 0)
            {
                return(0);
            }

            // Map from Atk's 1-based system to UIA's 0-based
            // indicies
            index--;

            Adapter child = RefProviderChildByDepthSearch(index);

            if (child != null && child.Provider != null)
            {
                IGridItemProvider g = (IGridItemProvider)child.Provider.GetPatternProvider(GridItemPatternIdentifiers.Pattern.Id);
                if (g == null)                  // ie, if a group header
                {
                    return(0);
                }
                return(g.Column);
            }
            return(-1);
        }
예제 #14
0
 public GridItemPatternWrapper(IGridItemProvider provider)
 {
     this.provider = provider;
 }
예제 #15
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        private GridItemProviderWrapper(AutomationPeer peer, IGridItemProvider iface)
        {
            _peer  = peer;
            _iface = iface;
        }
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------
 
        #region Constructors

        private GridItemProviderWrapper( AutomationPeer peer, IGridItemProvider iface )
        {
            _peer = peer;
            _iface = iface;
        }
예제 #17
0
        private IRawElementProviderFragmentRoot ColumnCellTest(SWF.DataGridViewColumn column,
                                                               SWF.DataGridViewCell cell,
                                                               bool cellChildrenExpected,
                                                               SWF.DataGridViewCell newCell)
        {
            SWF.DataGridView datagridview = GetControlInstance() as SWF.DataGridView;
            datagridview.Size = new Size(200, 200);
            datagridview.AllowUserToAddRows = false;

            datagridview.Columns.Add(column);

            IRawElementProviderFragmentRoot provider
                = GetProviderFromControl(datagridview) as IRawElementProviderFragmentRoot;

            Assert.IsNotNull(provider, "Missing DataGridView provider");

            IRawElementProviderFragmentRoot header = null;
            IRawElementProviderFragment     child  = provider.Navigate(NavigateDirection.FirstChild);

            Assert.IsNotNull(child, "FirstChild is null");
            int childCount = 0;

            while (child != null)
            {
                childCount++;
                if ((int)child.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id)
                    == ControlType.Header.Id)
                {
                    header = child as IRawElementProviderFragmentRoot;
                }
                child = child.Navigate(NavigateDirection.NextSibling);
            }
            Assert.IsNotNull(header, "Header is missing");
            Assert.AreEqual(1, childCount, "Children (Header)");

            // Exposes BNC #478840
            TestChildPatterns(header);

            SWF.DataGridViewRow row = new SWF.DataGridViewRow();
            row.Cells.Add(cell);
            datagridview.Rows.Add(row);

            IRawElementProviderFragment dataItem = null;

            childCount = 0;
            child      = provider.Navigate(NavigateDirection.FirstChild);
            while (child != null)
            {
                childCount++;
                if ((int)child.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id)
                    == ControlType.DataItem.Id)
                {
                    dataItem = child;
                }
                child = child.Navigate(NavigateDirection.NextSibling);
            }
            Assert.IsNotNull(dataItem, "DataItem is missing");
            Assert.AreEqual(2, childCount, "Children (Header/DataItem)");

            IRawElementProviderFragment buttonChild = dataItem.Navigate(NavigateDirection.FirstChild);

            Assert.IsNotNull(buttonChild, "DataItem.Child missing");
            TestPatterns(buttonChild);

            Assert.AreEqual(dataItem,
                            buttonChild.Navigate(NavigateDirection.Parent),
                            "DataItem != ButtonChild.Parent");

            IGridItemProvider gridItemProvider
                = (IGridItemProvider)buttonChild.GetPatternProvider(GridItemPatternIdentifiers.Pattern.Id);

            Assert.IsNotNull(gridItemProvider,
                             "Child should support IGridItemProvider");

            Assert.IsNotNull(gridItemProvider.ContainingGrid,
                             "ContainingGrid should not be null");

            // http://msdn.microsoft.com/en-us/library/system.windows.automation.provider.igriditemprovider.containinggrid.aspx
            Assert.IsNotNull(gridItemProvider.ContainingGrid.GetPatternProvider(GridPatternIdentifiers.Pattern.Id),
                             "ContainingGrid must implement GridPatternProvider");

            childCount = 0;
            child      = buttonChild.Navigate(NavigateDirection.FirstChild);
            while (child != null)
            {
                childCount++;
                child = child.Navigate(NavigateDirection.NextSibling);
            }
            if (!cellChildrenExpected)
            {
                Assert.AreEqual(0, childCount, "No children expected.");
            }
            else
            {
                Assert.Greater(childCount, 0, "Children expected.");
            }

            TestChildPatterns(provider);

            if (newCell != null)
            {
                // Lets add a new row, to make sure everything is ok.
                SWF.DataGridViewRow newRow = new SWF.DataGridViewRow();
                newRow.Cells.Add(newCell);

                datagridview.Rows.Add(newRow);

                TestChildPatterns(provider);
            }

            // Exposes BNC #513476
            cell.ReadOnly = false;
            Assert.IsTrue((bool)dataItem.GetPropertyValue(AutomationElementIdentifiers.IsEnabledProperty.Id));

            cell.ReadOnly = true;
            Assert.IsTrue((bool)dataItem.GetPropertyValue(AutomationElementIdentifiers.IsEnabledProperty.Id));
            cell.ReadOnly = false;

            datagridview.Enabled = false;
            Assert.IsFalse((bool)dataItem.GetPropertyValue(AutomationElementIdentifiers.IsEnabledProperty.Id));

            datagridview.Enabled = true;
            Assert.IsTrue((bool)dataItem.GetPropertyValue(AutomationElementIdentifiers.IsEnabledProperty.Id));

            return(provider);
        }
예제 #18
0
		public GridItemPatternWrapper (IGridItemProvider provider)
		{
			this.provider = provider;
		}