Exemple #1
0
        /// <summary>
        /// Gets the number of rows
        /// </summary>
        /// <param name="control">The UI Automation element</param>
        /// <returns>
        /// The number of rows
        /// </returns>
        internal static int GetRowCount(AutomationElement control)
        {
            /* move to next state */
            TablePattern pat = (TablePattern)CommonUIAPatternHelpers.CheckPatternSupport(TablePattern.Pattern, control);

            return(pat.Current.RowCount);
        }
        // </Snippet101>

        // <Snippet102>
        ///--------------------------------------------------------------------
        /// <summary>
        /// Obtains a table items primary row or column header.
        /// </summary>
        /// <param name="tableItem">
        /// The table item of interest.
        /// </param>
        /// <returns>
        /// The table item header.
        /// </returns>
        ///--------------------------------------------------------------------
        private AutomationElement GetTableItemHeader(TableItemPattern tableItem)
        {
            if (tableItem == null)
            {
                throw new ArgumentException("Target element cannot be null.");
            }

            TablePattern tablePattern = GetTablePattern(tableItem.Current.ContainingGrid);

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

            AutomationElement[] tableHeaders =
                GetPrimaryHeaders(tablePattern);

            if (tableHeaders == null)
            {
                // Indeterminate headers.
                return(null);
            }

            if (tablePattern.Current.RowOrColumnMajor == RowOrColumnMajor.ColumnMajor)
            {
                return(tableHeaders[tableItem.Current.Column]);
            }

            if (tablePattern.Current.RowOrColumnMajor == RowOrColumnMajor.RowMajor)
            {
                return(tableHeaders[tableItem.Current.Row]);
            }

            return(null);
        }
        // </Snippet1025>

        // <Snippet103>
        ///--------------------------------------------------------------------
        /// <summary>
        /// Gets the current property values from target.
        /// </summary>
        /// <param name="tablePattern">
        /// A TablePattern control pattern obtained from
        /// an automation element representing a target control.
        /// </param>
        ///--------------------------------------------------------------------
        private void GetRowColumnCounts(TablePattern tablePattern)
        {
            if (tablePattern == null)
            {
                throw new ArgumentException("Target element cannot be null.");
            }

            Console.WriteLine(tablePattern.Current.RowCount.ToString());
            Console.WriteLine(tablePattern.Current.ColumnCount.ToString());
        }
Exemple #4
0
 /// -------------------------------------------------------------------
 /// <summary>
 /// Get the tablepattern on the element
 /// </summary>
 /// -------------------------------------------------------------------
 public TableTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, TypeOfControl typeOfControl, IApplicationCommands commands)
     :
     base(element, TestSuite, priority, typeOfControl, TypeOfPattern.Table, dirResults, testEvents, commands)
 {
     m_pattern = (TablePattern)GetPattern(m_le, m_useCurrent, TablePattern.Pattern);
     if (m_pattern == null)
     {
         throw new Exception(Helpers.PatternNotSupported);
     }
 }
Exemple #5
0
        public AutomationElement [] GetRowHeaders(bool log)
        {
            if (log)
            {
                procedureLogger.Action(string.Format("Get the row headers of {0}.", this.NameAndType));
            }

            TablePattern tp = (TablePattern)element.GetCurrentPattern(TablePattern.Pattern);

            return(tp.Current.GetRowHeaders());
        }
Exemple #6
0
        public static bool TryGetTablePattern(this AutomationElement element, out TablePattern result)
        {
            if (element.TryGetCurrentPattern(System.Windows.Automation.TablePattern.Pattern, out var pattern))
            {
                result = (TablePattern)pattern;
                return(true);
            }

            result = null;
            return(false);
        }
Exemple #7
0
        // Changes for the sake of speeding up the code - End

        private void SetCounts()
        {
            object basePattern;

            if (PurpleElement.TryGetCurrentPattern(TablePattern.Pattern, out basePattern))
            {
                TablePattern gridItem = (BasePattern)basePattern as TablePattern;
                if (gridItem != null)
                {
                    _rowCount = gridItem.Current.RowCount;
                    _colCount = gridItem.Current.ColumnCount;
                }
            }
        }
Exemple #8
0
        public string GetValueNew(int row, int column)
        {
            string somenonsense = "";

            if (PElementPattern)
            {
                TablePattern gridItem = (BasePattern)basePattern2 as TablePattern;
                if (gridItem != null)
                {
                    var tableitem = gridItem.GetItem(row, column);
                    somenonsense = tableitem.Current.Name;
                }
            }
            return(somenonsense);
        }
Exemple #9
0
        public string GetValue(int row, int column)
        {
            string somenonsense = "";
            object basePattern;

            if (PurpleElement.TryGetCurrentPattern(TablePattern.Pattern, out basePattern))
            {
                TablePattern gridItem = (BasePattern)basePattern as TablePattern;
                if (gridItem != null)
                {
                    var tableitem = gridItem.GetItem(row, column);
                    somenonsense = tableitem.Current.Name;
                }
            }
            return(somenonsense);
        }
Exemple #10
0
 public int GiveCard(TablePattern patt, int index, bool remove)
 {
     if (localDeck.Cards.Count > 0)
     {
         localDeck.Cards[index].isOnScreen = false;
         patt.AddCard(localDeck.Cards[index]);
         if (remove)
         {
             Destroy(localDeck.Cards[index].gameobj);
             localDeck.Cards.RemoveAt(index);
             localDeck.Render();
         }
         return(0);
     }
     return(-1);
 }
        ///--------------------------------------------------------------------
        /// <summary>
        /// Obtains an array of table headers.
        /// </summary>
        /// <param name="tablePattern">
        /// The TablePattern object of interest.
        /// </param>
        /// <returns>
        /// The table row or column primary headers.
        /// </returns>
        ///--------------------------------------------------------------------
        private AutomationElement[] GetPrimaryHeaders(
            TablePattern tablePattern)
        {
            if (tablePattern.Current.RowOrColumnMajor ==
                RowOrColumnMajor.RowMajor)
            {
                return(tablePattern.Current.GetRowHeaders());
            }

            if (tablePattern.Current.RowOrColumnMajor ==
                RowOrColumnMajor.ColumnMajor)
            {
                return(tablePattern.Current.GetColumnHeaders());
            }

            return(null);
        }
    //храним ссылки на все руки, которые отрисовали, на все колоды и все Паттерны
    //При рисовании новой колоды/руки учитываем кол-во уже отрисованых колод/рук
    static public bool Render(TablePattern pattern, Vector3 position)
    {
        //вводим настройки для данного типа рендера.

        float x      = 5;     //z - x * Cards.Count + y * i
        float y      = 0;     //-5.5f
        float z      = -0.1f; //31f - 0.1f * i
        float constX = 2.5f - 2.5f;
        float constY = -5.5f;
        float constZ = 31f;

        position += new Vector3(constX, constY, constZ);
        Quaternion rotation = Quaternion.AngleAxis(-90, new Vector3(1, 0, 0));

        RpcLoad(pattern.localDeck.Cards, position, rotation, pattern.parrent, x, y, z, Game.UNO);
        pattern.isNewCards = false;
        return(true);
    }
        // </Snippet101>

        // <Snippet1015>
        ///--------------------------------------------------------------------
        /// <summary>
        /// Obtains a TablePattern control pattern from an
        /// AutomationElement.
        /// </summary>
        /// <param name="targetControl">
        /// The AutomationElement of interest.
        /// </param>
        /// <returns>
        /// A TablePattern object.
        /// </returns>
        ///--------------------------------------------------------------------
        private TablePattern GetTablePattern(
            AutomationElement targetControl)
        {
            TablePattern tablePattern = null;

            try
            {
                tablePattern =
                    targetControl.GetCurrentPattern(
                        TablePattern.Pattern)
                    as TablePattern;
            }
            // Object doesn't support the
            // TablePattern control pattern
            catch (InvalidOperationException)
            {
                return(null);
            }

            return(tablePattern);
        }
        public void TablePatternCachedTest()
        {
            CacheRequest req = new CacheRequest();

            req.Add(TablePattern.Pattern);
            req.Add(TableItemPattern.Pattern);
            req.Add(GridPattern.Pattern);
            req.Add(GridItemPattern.Pattern);
            req.Add(GridPattern.RowCountProperty);
            req.Add(GridPattern.ColumnCountProperty);
            req.Add(GridItemPattern.RowProperty);
            req.Add(GridItemPattern.ColumnProperty);
            req.Add(GridItemPattern.ContainingGridProperty);
            req.Add(TablePattern.RowHeadersProperty);
            req.Add(TablePattern.ColumnHeadersProperty);
            req.Add(TableItemPattern.RowHeaderItemsProperty);
            req.Add(TableItemPattern.ColumnHeaderItemsProperty);
            using (req.Activate())
            {
                AutomationElement itemsView = ExplorerTargetTests.explorerHost.Element.FindFirst(TreeScope.Subtree,
                                                                                                 new PropertyCondition(AutomationElement.ClassNameProperty, "UIItemsView"));
                Assert.IsNotNull(itemsView);

                // TablePattern test
                TablePattern table = (TablePattern)itemsView.GetCachedPattern(TablePattern.Pattern);
                Assert.IsTrue(table.Cached.ColumnCount > 0);
                Assert.IsTrue(table.Cached.RowCount > 0);
                Assert.IsTrue(table.Cached.GetRowHeaders().Length == 0);
                Assert.IsTrue(table.Cached.GetColumnHeaders().Length > 0);

                AutomationElement tableItemElement = table.GetItem(0, 0);
                TableItemPattern  tableItem        = (TableItemPattern)tableItemElement.GetCachedPattern(TableItemPattern.Pattern);
                Assert.AreEqual(tableItem.Cached.Row, 0);
                Assert.AreEqual(tableItem.Cached.Column, 0);
                Assert.AreEqual(tableItem.Cached.ContainingGrid, itemsView);
                Assert.IsTrue(tableItem.Cached.GetColumnHeaderItems().Length == 1);
                Assert.IsTrue(tableItem.Cached.GetRowHeaderItems().Length == 0);
            }
        }
        public void TablePatternTest()
        {
            AutomationElement itemsView = ExplorerTargetTests.explorerHost.Element.FindFirst(TreeScope.Subtree,
                                                                                             new PropertyCondition(AutomationElement.ClassNameProperty, "UIItemsView"));

            Assert.IsNotNull(itemsView);

            // TablePattern test
            TablePattern table = (TablePattern)itemsView.GetCurrentPattern(TablePattern.Pattern);

            Assert.IsTrue(table.Current.ColumnCount > 0);
            Assert.IsTrue(table.Current.RowCount > 0);
            Assert.IsTrue(table.Current.GetRowHeaders().Length == 0);
            Assert.IsTrue(table.Current.GetColumnHeaders().Length > 0);

            AutomationElement tableItemElement = table.GetItem(0, 0);
            TableItemPattern  tableItem        = (TableItemPattern)tableItemElement.GetCurrentPattern(TableItemPattern.Pattern);

            Assert.AreEqual(tableItem.Current.Row, 0);
            Assert.AreEqual(tableItem.Current.Column, 0);
            Assert.AreEqual(tableItem.Current.ContainingGrid, itemsView);
            Assert.IsTrue(tableItem.Current.GetColumnHeaderItems().Length == 1);
            Assert.IsTrue(tableItem.Current.GetRowHeaderItems().Length == 0);
        }
        // </Snippet102>

        // <Snippet103>
        ///--------------------------------------------------------------------
        /// <summary>
        /// Event handler for table item focus change.
        /// Can be used to track traversal of individual table items
        /// within a table.
        /// </summary>
        /// <param name="src">Object that raised the event.</param>
        /// <param name="e">Event arguments.</param>
        ///--------------------------------------------------------------------
        private void OnTableItemFocusChange(
            object src, AutomationFocusChangedEventArgs e)
        {
            // Make sure the element still exists. Elements such as tooltips
            // can disappear before the event is processed.
            AutomationElement sourceElement;

            try
            {
                sourceElement = src as AutomationElement;
            }
            catch (ElementNotAvailableException)
            {
                return;
            }

            // Get a TableItemPattern from the source of the event.
            TableItemPattern tableItemPattern =
                GetTableItemPattern(sourceElement);

            if (tableItemPattern == null)
            {
                return;
            }

            // Get a TablePattern from the container of the current element.
            TablePattern tablePattern =
                GetTablePattern(tableItemPattern.Current.ContainingGrid);

            if (tablePattern == null)
            {
                return;
            }

            AutomationElement tableItem = null;

            try
            {
                tableItem = tablePattern.GetItem(
                    tableItemPattern.Current.Row,
                    tableItemPattern.Current.Column);
            }
            catch (ArgumentOutOfRangeException)
            {
                // If the requested row coordinate is larger than the RowCount
                // or the column coordinate is larger than the ColumnCount.
                // -- OR --
                // If either of the requested row or column coordinates
                // is less than zero.
                // TO DO: error handling.
            }

            // Further event processing can be done at this point.
            // For the purposes of this sample we can just record item properties.
            string controlType =
                tableItem.Current.ControlType.LocalizedControlType;

            AutomationElement[] columnHeaders =
                tableItemPattern.Current.GetColumnHeaderItems();
            AutomationElement[] rowHeaders =
                tableItemPattern.Current.GetRowHeaderItems();
            int itemRow        = tableItemPattern.Current.Row;
            int itemColumn     = tableItemPattern.Current.Column;
            int itemRowSpan    = tableItemPattern.Current.RowSpan;
            int itemColumnSpan = tableItemPattern.Current.ColumnSpan;
        }
Exemple #17
0
 protected override void CustomFixtureSetUp()
 {
     base.CustomFixtureSetUp();
     gridPattern  = (GridPattern)table1Element.GetCurrentPattern(GridPattern.Pattern);
     tablePattern = (TablePattern)table1Element.GetCurrentPattern(TablePattern.Pattern);
 }
Exemple #18
0
        /// <summary>
        /// Gets the row headers.
        /// </summary>
        /// <param name="control">The UI Automation element</param>
        /// <returns>
        /// An array of Row Header elements
        /// </returns>
        internal static AutomationElement[] GetRowHeaders(AutomationElement control)
        {
            TablePattern pat = (TablePattern)CommonUIAPatternHelpers.CheckPatternSupport(TablePattern.Pattern, control);

            return(pat.Current.GetRowHeaders());
        }
Exemple #19
0
        /// <summary>
        ///     Gets the number of columns
        /// </summary>
        /// <param name = "control">The UI Automation element</param>
        /// <returns>The number of columns</returns>
        internal static int GetColumnCount(AutomationElement control)
        {
            TablePattern pat = (TablePattern)CommonUIAPatternHelpers.CheckPatternSupport(TablePattern.Pattern, control);

            return(pat.Current.ColumnCount);
        }
Exemple #20
0
        /// <summary>
        /// Gets the item at the specified cell.
        /// </summary>
        /// <param name="control">The UI Automation element</param>
        /// <param name="row">The row of the item to retrieve.</param>
        /// <param name="column">The column of the item to retrieve.</param>
        /// <returns>
        /// The Automation Element at the supplied row/column intersection
        /// </returns>
        internal static AutomationElement GetItem(AutomationElement control, int row, int column)
        {
            TablePattern pat = (TablePattern)CommonUIAPatternHelpers.CheckPatternSupport(TablePattern.Pattern, control);

            return(pat.GetItem(row, column));
        }
 public TablePatternPropertyObject(TablePattern pattern)
 {
     this._pattern = pattern;
 }
Exemple #22
0
        /// <summary>
        /// Gets the primary direction of traversal.
        /// </summary>
        /// <param name="control">The UI Automation element.</param>
        /// <returns></returns>
        internal static RowOrColumnMajor GetRowOrColumnMajor(AutomationElement control)
        {
            TablePattern pat = (TablePattern)CommonUIAPatternHelpers.CheckPatternSupport(TablePattern.Pattern, control);

            return(pat.Current.RowOrColumnMajor);
        }