当前位置: 首页>>代码示例>>C#>>正文


C# AutomationElement.GetCurrentPattern方法代码示例

本文整理汇总了C#中System.Windows.Automation.AutomationElement.GetCurrentPattern方法的典型用法代码示例。如果您正苦于以下问题:C# AutomationElement.GetCurrentPattern方法的具体用法?C# AutomationElement.GetCurrentPattern怎么用?C# AutomationElement.GetCurrentPattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Automation.AutomationElement的用法示例。


在下文中一共展示了AutomationElement.GetCurrentPattern方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: executePattern

 public void executePattern(AutomationElement subject, AutomationPattern inPattern)
 {
     switch (inPattern.ProgrammaticName)
     {
         case "InvokePatternIdentifiers.Pattern":
             {
                 InvokePattern invoke = (InvokePattern)subject.GetCurrentPattern(InvokePattern.Pattern);
                 invoke.Invoke();
                 break;
             }
         case "SelectionItemPatternIdentifiers.Pattern":
             {
                 SelectionItemPattern select = (SelectionItemPattern)subject.GetCurrentPattern(SelectionItemPattern.Pattern);
                 select.Select();
                 break;
             }
         case "TogglePatternIdentifiers.Pattern":
             {
                 TogglePattern toggle = (TogglePattern)subject.GetCurrentPattern(TogglePattern.Pattern);
                 toggle.Toggle();
                 break;
             }
         case "ExpandCollapsePatternIdentifiers.Pattern":
             {
                 ExpandCollapsePattern exColPat = (ExpandCollapsePattern)subject.GetCurrentPattern(ExpandCollapsePattern.Pattern);
                 // exColPat.Expand();
                 break;
             }
     }
 }
开发者ID:jdennis925,项目名称:guiwalker,代码行数:30,代码来源:PatternManager.cs

示例2: ScrollItemPatternWrapper

        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        internal ScrollItemPatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
            base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            Comment("Creating ScrollItemTests");

            _pattern = (ScrollItemPattern)GetPattern(m_le, m_useCurrent, ScrollItemPattern.Pattern);
            if (_pattern == null)
                ThrowMe(CheckType.IncorrectElementConfiguration, Helpers.PatternNotSupported + ": ScrollItemPattern");

            // Find the ScrollPattern
            _container = m_le;

            while (_container != null && !(bool)_container.GetCurrentPropertyValue(AutomationElement.IsScrollPatternAvailableProperty))
                _container = TreeWalker.ControlViewWalker.GetParent(_container);

            // Check to see if we actual found the container of the scrollitem
            if (_container == null)
                ThrowMe(CheckType.IncorrectElementConfiguration, "Element does not have a container with ScrollPattern");

            Comment("Found scroll container: " + Library.GetUISpyLook(_container));

            _scrollPattern = (ScrollPattern)_container.GetCurrentPattern(ScrollPattern.Pattern) as ScrollPattern;

        }
开发者ID:jeffras,项目名称:uiverify,代码行数:28,代码来源:ScrollItemTests.cs

示例3: MultipleViewTests

		/// -------------------------------------------------------------------
		/// <summary></summary>
		/// -------------------------------------------------------------------
		public MultipleViewTests(AutomationElement element, TestPriorities priority, string dirResults, bool testEvents, TypeOfControl typeOfControl, IApplicationCommands commands)
            :
            base(element, TestSuite, priority, typeOfControl, TypeOfPattern.MultipleView, dirResults, testEvents, commands)
        {
            m_pattern = (MultipleViewPattern)element.GetCurrentPattern(MultipleViewPattern.Pattern);
            if (m_pattern == null)
                throw new Exception(Helpers.PatternNotSupported);
        }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:11,代码来源:MultipleViewTests.cs

示例4: TogglePatternWrapper

        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        protected TogglePatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
            base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            _pattern = (TogglePattern)element.GetCurrentPattern(TogglePattern.Pattern);

            if (_pattern == null)
                throw new Exception("TogglePattern: " + Helpers.PatternNotSupported);
        }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:12,代码来源:ToggleTests.cs

示例5: Check

        public static void Check(AutomationElement element)
        {
            // element.SetFocus();
            //SendKeys.SendWait(" ");

            TogglePattern togglePattern = element.GetCurrentPattern(TogglePattern.Pattern) as TogglePattern;

               togglePattern.Toggle();
        }
开发者ID:tankxiao,项目名称:tankproject,代码行数:9,代码来源:AutomationBuild.cs

示例6: GetDataGridContent

        /// <summary>
        /// Gets the content of the AutomationElement of control type DataGrid.
        /// </summary>
        /// <param name="dataGrid">A data grid control.</param>
        /// <returns>A data table containing the contents of the passed data grid.</returns>
        public static DataTable GetDataGridContent(AutomationElement dataGrid, string tableName = "DataGrid")
        {
            if (dataGrid.Current.ControlType != ControlType.DataGrid)
            {
                throw new Exception("Invalid control type passed to GetDataGridContent.");
            }

            try
            {
                GridPattern gp = (GridPattern)dataGrid.GetCurrentPattern(GridPattern.Pattern);
                TablePattern tp = (TablePattern)dataGrid.GetCurrentPattern(TablePattern.Pattern);
                AutomationElement[] headers = tp.Current.GetColumnHeaders();
                DataTable dt = new DataTable(tableName);

                foreach (AutomationElement columnHeader in headers)
                {
                    dt.Columns.Add(columnHeader.Current.Name, typeof(String));
                }

                int colCount = gp.Current.ColumnCount;
                int rowCount = gp.Current.RowCount;

                for (int r = 0; r < rowCount; r++)
                {
                    DataRow dr = dt.NewRow();

                    for (int c = 0; c < colCount; c++)
                    {
                        dr[c] = gp.GetItem(r, c).Current.Name;
                    }
                    dt.Rows.Add(dr);
                }
                return dt;
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                return new DataTable();
            }
        }
开发者ID:DDLSTraining,项目名称:GhostBuster,代码行数:45,代码来源:AEHelper.cs

示例7: GetText

        public static string GetText(AutomationElement element)
        {
            string content = string.Empty;

            TextPattern txtPattern = element.GetCurrentPattern(TextPattern.Pattern) as TextPattern;

            if (txtPattern != null)
            {
                content = txtPattern.DocumentRange.GetText(-1);
            }

            return content;
        }
开发者ID:tankxiao,项目名称:tankproject,代码行数:13,代码来源:AutomationBuild.cs

示例8: EmptyTextFromChild

 private void EmptyTextFromChild(AutomationElement element)
 {
     if (element.GetSupportedPatterns().Contains(ValuePattern.Pattern))
     {
         ((ValuePattern)element.GetCurrentPattern(ValuePattern.Pattern)).SetValue(string.Empty);
     }
     else if (element.GetSupportedPatterns().Contains(TextPattern.Pattern))
     {
         TextPatternRange document =
             ((TextPattern)Element.GetCurrentPattern(TextPattern.Pattern)).DocumentRange;
         AutomationElement[] children = document.GetChildren();
         foreach (var child in children)
         {
             EmptyTextFromChild(child);
         }
     }
 }
开发者ID:pako4u2k,项目名称:wipflash,代码行数:17,代码来源:RichTextBox.cs

示例9: SelectionItemPatternWrapper

        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        internal SelectionItemPatternWrapper(AutomationElement element, string testSuite, TestPriorities priority, TypeOfControl typeOfControl, TypeOfPattern typeOfPattern, string dirResults, bool testEvents, IApplicationCommands commands)
            :
            base(element, testSuite, priority, typeOfControl, typeOfPattern, dirResults, testEvents, commands)
        {
            _pattern = (SelectionItemPattern)GetPattern(m_le, m_useCurrent, SelectionItemPattern.Pattern);
            if (_pattern == null)
                throw new Exception(Helpers.PatternNotSupported + ": SelectionItemPattern");

            _selectionContainer = _pattern.Current.SelectionContainer;

            if (_selectionContainer != null)
            {
                _selectionPattern = _selectionContainer.GetCurrentPattern(SelectionPattern.Pattern) as SelectionPattern;
                if (_selectionPattern == null)
                    throw new ArgumentException("Could not find the SelectionContainer's SelectionPattern");
            }

        }
开发者ID:TestStack,项目名称:UIAVerify,代码行数:21,代码来源:SelectionItemTests.cs

示例10: ExplorerHost

        public ExplorerHost()
        {
            // Start up Explorer and find it
            System.Diagnostics.Process.Start("cmd.exe", "/c start %SystemDrive%\\windows\\system32");

            // Wait briefly
            System.Threading.Thread.Sleep(2000 /* ms */);

            // Find it
            _element = AutomationElement.RootElement.FindFirst(TreeScope.Children,
                new PropertyCondition(AutomationElement.NameProperty, "system32"));
            if (_element == null)
            {
                throw new InvalidOperationException();
            }

            _hwnd = _element.Current.NativeWindowHandle;

            _windowPattern = (WindowPattern)_element.GetCurrentPattern(WindowPattern.Pattern);
        }
开发者ID:RyuaNerin,项目名称:UIAComWrapper,代码行数:20,代码来源:ExplorerHost.cs

示例11: GetWindowPattern

        private static WindowPattern GetWindowPattern(AutomationElement targetControl)
        {
            WindowPattern windowPattern = null;

            try
            {
                windowPattern = targetControl.GetCurrentPattern(WindowPattern.Pattern)
                    as WindowPattern;
            }
            catch (InvalidOperationException)
            {
                // object doesn't support the WindowPattern control pattern 
                return null;
            }
            // Make sure the element is usable. 
            if (false == windowPattern.WaitForInputIdle(10000))
            {
                // Object not responding in a timely manner 
                return null;
            }
            return windowPattern;
        }
开发者ID:sakthijas,项目名称:ProtoTest.Golem,代码行数:22,代码来源:PurpleWindow.cs

示例12: GetComboBoxContent

        /// <summary>
        /// Gets the first selected content of the AutomationElement of control type ComboBox.
        /// </summary>
        /// <param name="comboBoxControl">A combobox control.</param>
        /// <returns>Only the first selected item in text format.</returns>
        public static string GetComboBoxContent(AutomationElement comboBoxControl)
        {
            if (comboBoxControl.Current.ControlType != ControlType.ComboBox)
            {
                throw new Exception("Invalid control type passed to GetRadioButtonCheckState.");
            }

            try
            {
                SelectionPattern sp = (SelectionPattern)comboBoxControl.GetCurrentPattern(SelectionPattern.Pattern);
                AutomationElement[] selected = sp.Current.GetSelection();
                if (selected.Length > 0)
                {
                    return selected[0].Current.Name;
                }
                return String.Empty;
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                return String.Empty;
            }
        }
开发者ID:DDLSTraining,项目名称:GhostBuster,代码行数:28,代码来源:AEHelper.cs

示例13: Select

 protected void Select(AutomationElement element)
 {
     SelectionItemPattern select = (SelectionItemPattern)element.GetCurrentPattern(SelectionItemPattern.Pattern);
     select.Select();
 }
开发者ID:kingofcrabs,项目名称:LuminexDriver,代码行数:5,代码来源:WindowOp.cs

示例14: Click

 protected void Click(AutomationElement element)
 {
     var click = element.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
     click.Invoke();
 }
开发者ID:kingofcrabs,项目名称:LuminexDriver,代码行数:5,代码来源:WindowOp.cs

示例15: GetPatternObject

        /// -------------------------------------------------------------------
        /// <summary>HELPER: Obtains the pattern object and returns true or false depending on success</summary>
        /// -------------------------------------------------------------------
        private static bool GetPatternObject(AutomationElement element, AutomationPattern automationPattern, ref object patternObj)
        {
            bool succeeded = true;
            try
            {
                patternObj = element.GetCurrentPattern(automationPattern);
            }
            catch (InvalidOperationException exception)
            {
                Dump(exception.ToString(), true, element);
                succeeded = false;
            }
            return succeeded;

        }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:18,代码来源:stress.cs


注:本文中的System.Windows.Automation.AutomationElement.GetCurrentPattern方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。