• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Automation.CacheRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



CacheRequest类属于System.Windows.Automation命名空间,在下文中一共展示了CacheRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetTabsOfWindow

		public IEnumerable<ITab> GetTabsOfWindow(IntPtr hWnd)
		{
			var notepadPlusPlusWindow = AutomationElement.FromHandle(hWnd);

			var cacheRequest = new CacheRequest();
			cacheRequest.Add(AutomationElement.NameProperty);
			cacheRequest.Add(AutomationElement.LocalizedControlTypeProperty);
			cacheRequest.Add(SelectionItemPattern.Pattern);
			cacheRequest.Add(SelectionItemPattern.SelectionContainerProperty);
			cacheRequest.TreeScope = TreeScope.Element;

			AutomationElement tabBarElement;

			using (cacheRequest.Activate())
			{
				tabBarElement = notepadPlusPlusWindow.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.LocalizedControlTypeProperty, "tab"));
			}

			if(tabBarElement == null)
				yield break;

			var tabElements = tabBarElement.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.LocalizedControlTypeProperty, "tab item"));

			for (var tabIndex = 0; tabIndex < tabElements.Count; tabIndex++)
			{
				yield return new NotepadPlusPlusTab(tabElements[tabIndex]);
			}
		}
开发者ID:olivierdagenais,项目名称:GoToWindow,代码行数:28,代码来源:NotepadPlusPlusTabsFinder.cs


示例2: PushPopTest

        public void PushPopTest()
        {
            CacheRequest defaultCR = CacheRequest.Current;
            CacheRequest target = new CacheRequest();
            target.TreeScope = TreeScope.Children;
            target.Push();
            CacheRequest target2 = new CacheRequest();
            target2.TreeScope = TreeScope.Subtree;
            target2.Push();

            // Try to change target2 - this should fail
            try
            {
                target2.TreeScope = TreeScope.Descendants;

                Assert.Fail("exception expected");
            }
            catch (System.InvalidOperationException)
            {
            }

            target2.Pop();
            target.Pop();
            Assert.AreEqual(CacheRequest.Current, defaultCR);
        }
开发者ID:RyuaNerin,项目名称:UIAComWrapper,代码行数:25,代码来源:CacheRequestTest.cs


示例3: GridPatternCachedTest

        public void GridPatternCachedTest()
        {
            CacheRequest req = new CacheRequest();
            req.Add(GridItemPattern.Pattern);
            req.Add(GridPattern.Pattern);
            req.Add(GridPattern.RowCountProperty);
            req.Add(GridPattern.ColumnCountProperty);
            req.Add(GridItemPattern.RowProperty);
            req.Add(GridItemPattern.ColumnProperty);
            req.Add(GridItemPattern.ContainingGridProperty);

            using (req.Activate())
            {
                AutomationElement itemsView = ExplorerTargetTests.explorerHost.Element.FindFirst(TreeScope.Subtree,
                    new PropertyCondition(AutomationElement.ClassNameProperty, "UIItemsView"));
                Assert.IsNotNull(itemsView);

                // Try out the Grid Pattern
                GridPattern grid = (GridPattern)itemsView.GetCachedPattern(GridPattern.Pattern);
                Assert.IsTrue(grid.Cached.ColumnCount > 0);
                Assert.IsTrue(grid.Cached.RowCount > 0);

                // GridItem
                AutomationElement gridItemElement = grid.GetItem(0, 0);
                Assert.IsNotNull(gridItemElement);
                GridItemPattern gridItem = (GridItemPattern)gridItemElement.GetCachedPattern(GridItemPattern.Pattern);
                Assert.AreEqual(gridItem.Cached.Row, 0);
                Assert.AreEqual(gridItem.Cached.Column, 0);
                Assert.AreEqual(gridItem.Cached.ContainingGrid, itemsView);
            }
        }
开发者ID:RyuaNerin,项目名称:UIAComWrapper,代码行数:31,代码来源:ExplorerTargetTests.cs


示例4: AutomationElementModeTest

 public void AutomationElementModeTest()
 {
     CacheRequest target = new CacheRequest(); 
     target.AutomationElementMode = AutomationElementMode.Full;
     AutomationElementMode actual = target.AutomationElementMode;
     Assert.AreEqual(AutomationElementMode.Full, actual);
 }
开发者ID:RyuaNerin,项目名称:UIAComWrapper,代码行数:7,代码来源:CacheRequestTest.cs


示例5: BuildCacheRequest

 public static CacheRequest BuildCacheRequest(TreeScope treeScope, params AutomationProperty[] properties)
 {
     var cr = new CacheRequest { TreeScope = treeScope };
      foreach (var property in properties)
     cr.Add(property);
      return cr;
 }
开发者ID:softek,项目名称:WinUIScraper,代码行数:7,代码来源:AutomationExtensions.cs


示例6: TreeScopeTest

 public void TreeScopeTest()
 {
     CacheRequest target = new CacheRequest();
     TreeScope expected = TreeScope.Subtree;
     TreeScope actual;
     target.TreeScope = expected;
     actual = target.TreeScope;
     Assert.AreEqual(expected, actual);
 }
开发者ID:jeffras,项目名称:uiverify,代码行数:9,代码来源:CacheRequestTest.cs


示例7: TreeFilterTest

 public void TreeFilterTest()
 {
     CacheRequest target = new CacheRequest();
     PropertyCondition expected = new PropertyCondition(AutomationElement.NameProperty, "foo");
     PropertyCondition actual;
     target.TreeFilter = expected;
     actual = (PropertyCondition)target.TreeFilter;
     Assert.AreEqual(expected.Flags, actual.Flags);
     Assert.AreEqual(expected.Property, actual.Property);
     Assert.AreEqual(expected.Value, actual.Value);
 }
开发者ID:RyuaNerin,项目名称:UIAComWrapper,代码行数:11,代码来源:CacheRequestTest.cs


示例8: GetLastChild

 public AutomationElement GetLastChild(AutomationElement element, CacheRequest request)
 {
     Utility.ValidateArgumentNonNull(element, "element");
     Utility.ValidateArgumentNonNull(request, "request");
     try
     {
         return AutomationElement.Wrap(this._obj.GetLastChildElementBuildCache(
             element.NativeElement,
             request.NativeCacheRequest));
     }
     catch (System.Runtime.InteropServices.COMException e)
     {
         Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
     }
 }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:15,代码来源:TreeWalker.cs


示例9: MyTestInitialize

 public void MyTestInitialize()
 {
     // Get all children of the desktop for our target collection
     CacheRequest cacheReq = new CacheRequest();
     cacheReq.Add(AutomationElement.NameProperty);
     cacheReq.Add(AutomationElement.NativeWindowHandleProperty);
     using (cacheReq.Activate())
     {
         this.testColl = AutomationElement.RootElement.FindAll(
             TreeScope.Children,
             Condition.TrueCondition);
         Assert.IsNotNull(this.testColl);
         Assert.IsTrue(this.testColl.Count > 0);
     }
 }
开发者ID:jeffras,项目名称:uiverify,代码行数:15,代码来源:AutomationElementCollectionTest.cs


示例10: ExpandCollapsePatternCachedTest

        public void ExpandCollapsePatternCachedTest()
        {
            using (AppHost host = new AppHost("rundll32.exe", "shell32.dll,Control_RunDLL intl.cpl"))
            {
                CacheRequest req = new CacheRequest();
                req.Add(ExpandCollapsePattern.Pattern);
                req.Add(ExpandCollapsePattern.ExpandCollapseStateProperty);
                using (req.Activate())
                {
                    // Find a well-known combo box
                    AutomationElement combo = host.Element.FindFirst(TreeScope.Subtree,
                        new PropertyCondition(AutomationElement.AutomationIdProperty, "1021"));
                    Assert.IsNotNull(combo);

                    ExpandCollapsePattern expando = (ExpandCollapsePattern)combo.GetCachedPattern(ExpandCollapsePattern.Pattern);
                    Assert.AreEqual(expando.Cached.ExpandCollapseState, ExpandCollapseState.Collapsed);
                }
            }
        }
开发者ID:RyuaNerin,项目名称:UIAComWrapper,代码行数:19,代码来源:ScenarioTests.cs


示例11: TablePatternCachedTest

        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);
            }
        }
开发者ID:RyuaNerin,项目名称:UIAComWrapper,代码行数:38,代码来源:ExplorerTargetTests.cs


示例12: Navigate

        // Called by the treewalker classes to navigate - we call through to the
        // provider wrapper, which gets the navigator code to do its stuff
        internal AutomationElement Navigate(NavigateDirection direction, Condition condition, CacheRequest request)
        {
            CheckElement();

            UiaCoreApi.UiaCacheRequest cacheRequest;
            if (request == null)
                cacheRequest = CacheRequest.DefaultUiaCacheRequest;
            else
                cacheRequest = request.GetUiaCacheRequest();

            UiaCoreApi.UiaCacheResponse response = UiaCoreApi.UiaNavigate(_hnode, direction, condition, cacheRequest);
            return CacheHelper.BuildAutomationElementsFromResponse(cacheRequest, response);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:15,代码来源:AutomationElement.cs


示例13: Normalize

        internal AutomationElement Normalize(Condition condition, CacheRequest request )
        {
            CheckElement();

            UiaCoreApi.UiaCacheRequest cacheRequest;
            if (request == null)
                cacheRequest = CacheRequest.DefaultUiaCacheRequest;
            else
                cacheRequest = request.GetUiaCacheRequest();

            // Normalize against the treeview condition, not the one in the cache request...
            UiaCoreApi.UiaCacheResponse response = UiaCoreApi.UiaGetUpdatedCache(_hnode, cacheRequest, UiaCoreApi.NormalizeState.Custom, condition);
            return CacheHelper.BuildAutomationElementsFromResponse(cacheRequest, response);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:14,代码来源:AutomationElement.cs


示例14: SubscribeToEvents

        protected internal void SubscribeToEvents(HasControlInputCmdletBase cmdlet,
                                                  AutomationElement inputObject,
                                                  AutomationEvent eventType,
                                                  AutomationProperty prop)
        {
            AutomationEventHandler uiaEventHandler;
            AutomationPropertyChangedEventHandler uiaPropertyChangedEventHandler;
            StructureChangedEventHandler uiaStructureChangedEventHandler;
            AutomationFocusChangedEventHandler uiaFocusChangedEventHandler;

            // 20130109
            if (null == CurrentData.Events) {
                CurrentData.InitializeEventCollection();
            }

            try {

                CacheRequest cacheRequest = new CacheRequest();
                cacheRequest.AutomationElementMode = AutomationElementMode.Full; //.None;
                cacheRequest.TreeFilter = Automation.RawViewCondition;
                cacheRequest.Add(AutomationElement.NameProperty);
                cacheRequest.Add(AutomationElement.AutomationIdProperty);
                cacheRequest.Add(AutomationElement.ClassNameProperty);
                cacheRequest.Add(AutomationElement.ControlTypeProperty);
                //cacheRequest.Add(AutomationElement.ProcessIdProperty);
                // cache patterns?

                // cacheRequest.Activate();
                cacheRequest.Push();

                switch (eventType.ProgrammaticName) {
                    case "InvokePatternIdentifiers.InvokedEvent":
                        this.WriteVerbose(cmdlet, "subscribing to the InvokedEvent handler");
                        Automation.AddAutomationEventHandler(
                            InvokePattern.InvokedEvent,
                            inputObject,
                            TreeScope.Element, // TreeScope.Subtree, // TreeScope.Element,
                            // uiaEventHandler = new AutomationEventHandler(OnUIAutomationEvent));
                            //uiaEventHandler = new AutomationEventHandler(handler));
                            //uiaEventHandler = new AutomationEventHandler(((EventCmdletBase)cmdlet).AutomationEventHandler));
                            uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "TextPatternIdentifiers.TextChangedEvent":
                        this.WriteVerbose(cmdlet, "subscribing to the TextChangedEvent handler");
                        Automation.AddAutomationEventHandler(
                            TextPattern.TextChangedEvent,
                            inputObject,
                            TreeScope.Element,
                            // uiaEventHandler = new AutomationEventHandler(OnUIAutomationEvent));
                            //uiaEventHandler = new AutomationEventHandler(handler));
                            //uiaEventHandler = new AutomationEventHandler(((EventCmdletBase)cmdlet).AutomationEventHandler));
                            uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "TextPatternIdentifiers.TextSelectionChangedEvent":
                        this.WriteVerbose(cmdlet, "subscribing to the TextSelectionChangedEvent handler");
                        Automation.AddAutomationEventHandler(
                            TextPattern.TextSelectionChangedEvent,
                            inputObject,
                            TreeScope.Element,
                            // uiaEventHandler = new AutomationEventHandler(OnUIAutomationEvent));
                            //uiaEventHandler = new AutomationEventHandler(handler));
                            //uiaEventHandler = new AutomationEventHandler(((EventCmdletBase)cmdlet).AutomationEventHandler));
                            uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "WindowPatternIdentifiers.WindowOpenedProperty":
                        this.WriteVerbose(cmdlet, "subscribing to the WindowOpenedEvent handler");
                        Automation.AddAutomationEventHandler(
                            WindowPattern.WindowOpenedEvent,
                            inputObject,
                            TreeScope.Subtree,
                            // uiaEventHandler = new AutomationEventHandler(OnUIAutomationEvent));
                            //uiaEventHandler = new AutomationEventHandler(handler));
                            //uiaEventHandler = new AutomationEventHandler(((EventCmdletBase)cmdlet).AutomationEventHandler));
                            uiaEventHandler = new AutomationEventHandler(cmdlet.AutomationEventHandler));
                        UIAHelper.WriteEventToCollection(cmdlet, uiaEventHandler);
                        // 20130327
                        //this.WriteObject(cmdlet, uiaEventHandler);
                        if (cmdlet.PassThru) { cmdlet.WriteObject(cmdlet, uiaEventHandler); } else { cmdlet.WriteObject(cmdlet, true); }
                        break;
                    case "AutomationElementIdentifiers.AutomationPropertyChangedEvent":
                        if (prop != null) {
                            this.WriteVerbose(cmdlet, "subscribing to the AutomationPropertyChangedEvent handler");
                            Automation.AddAutomationPropertyChangedEventHandler(
                                inputObject,
                                TreeScope.Subtree,
                                uiaPropertyChangedEventHandler =
                                    // new AutomationPropertyChangedEventHandler(OnUIAutomationPropertyChangedEvent),
                                    //new AutomationPropertyChangedEventHandler(handler),
//.........这里部分代码省略.........
开发者ID:JosefNemec,项目名称:STUPS,代码行数:101,代码来源:HasControlInputCmdletBase.cs


示例15: GetUpdatedCache

 public AutomationElement GetUpdatedCache(CacheRequest request)
 {
     try
     {
         return AutomationElement.Wrap(this._obj.BuildUpdatedCache(request.NativeCacheRequest));
     }
     catch (System.Runtime.InteropServices.COMException e)
     {
         Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
     }
 }
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:11,代码来源:AutomationElement.cs


示例16: GetUpdatedAEWhenStructureChanged

 public AutomationElement GetUpdatedAEWhenStructureChanged(AutomationElement mainWidow, AutomationPattern patternToCache = null, AutomationProperty propertyToCache = null)
 {
     CacheRequest cacheRequest = new CacheRequest();
     cacheRequest.TreeScope = TreeScope.Element | TreeScope.Descendants | TreeScope.Children;
     cacheRequest.AutomationElementMode = AutomationElementMode.Full;
     cacheRequest.TreeFilter = System.Windows.Automation.Automation.RawViewCondition;
     if (patternToCache != null)
     {
         cacheRequest.Add(patternToCache);
     }
     else
     {
         cacheRequest.Add(SelectionPattern.Pattern);
         cacheRequest.Add(WindowPattern.Pattern);
         cacheRequest.Add(InvokePattern.Pattern);
         cacheRequest.Add(TogglePattern.Pattern);
         cacheRequest.Add(ExpandCollapsePattern.Pattern);
         cacheRequest.Add(ValuePattern.Pattern);
         cacheRequest.Add(SelectionItemPattern.Pattern);
     }
     if (propertyToCache != null)
     {
         cacheRequest.Add(propertyToCache);
     }
     else
     {
         cacheRequest.Add(AutomationElement.NameProperty);
         cacheRequest.Add(AutomationElement.AutomationIdProperty);
         cacheRequest.Add(AutomationElement.ClassNameProperty);
         cacheRequest.Add(AutomationElement.ControlTypeProperty);
     }
     AutomationElement updatedElement;
     using (cacheRequest.Activate())
     {
         updatedElement = mainWidow.GetUpdatedCache(cacheRequest);
     }
     return updatedElement;
 }
开发者ID:Gnail-nehc,项目名称:Black,代码行数:38,代码来源:AppUnderTest.cs


示例17: MultipleViewPatternTest

        public void MultipleViewPatternTest()
        {
            CacheRequest req = new CacheRequest();
            req.Add(MultipleViewPattern.Pattern);
            req.Add(MultipleViewPattern.CurrentViewProperty);
            req.Add(MultipleViewPattern.SupportedViewsProperty);

            using (req.Activate())
            {
                AutomationElement itemsView = ExplorerTargetTests.explorerHost.Element.FindFirst(TreeScope.Subtree,
                    new PropertyCondition(AutomationElement.ClassNameProperty, "UIItemsView"));
                Assert.IsNotNull(itemsView);

                MultipleViewPattern multiView = (MultipleViewPattern)itemsView.GetCachedPattern(MultipleViewPattern.Pattern);
                int[] supportedViews = multiView.Cached.GetSupportedViews();
                Assert.IsNotNull(supportedViews.Length > 0);
                bool inSupportedViews = false;
                foreach (int view in supportedViews)
                {
                    if (view == multiView.Cached.CurrentView)
                    {
                        inSupportedViews = true;
                        break;
                    }
                    string viewName = multiView.GetViewName(view);
                    Assert.IsTrue(viewName.Length > 0);
                }
                Assert.IsTrue(inSupportedViews);
            }
        }
开发者ID:RyuaNerin,项目名称:UIAComWrapper,代码行数:30,代码来源:ExplorerTargetTests.cs


示例18: GetUpdatedCache

        /// <summary>
        /// Get an AutomationElement with updated cached values
        /// </summary>
        /// <param name="request">CacheRequest object describing the properties and other information to fetch</param>
        /// <returns>Returns a new AutomationElement, which refers to the same UI as this element, but which is
        /// populated with properties specified in the CacheRequest.</returns>
        /// <remarks>
        /// Unlike other methods, such as FromHandle, FromPoint, this method takes
        /// an explicit CacheRequest as a parameter, and ignores the currently
        /// active CacheRequest.
        /// </remarks>
        public AutomationElement GetUpdatedCache(CacheRequest request)
        {
            Misc.ValidateArgumentNonNull(request, "request");
            CheckElement();

            UiaCoreApi.UiaCacheRequest cacheRequest = request.GetUiaCacheRequest();

            // Don't normalize when getting updated cache...
            UiaCoreApi.UiaCacheResponse response = UiaCoreApi.UiaGetUpdatedCache(_hnode, cacheRequest, UiaCoreApi.NormalizeState.None, null);
            return CacheHelper.BuildAutomationElementsFromResponse(cacheRequest, response);
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:22,代码来源:AutomationElement.cs


示例19: CacheRequestActivation

 internal CacheRequestActivation(CacheRequest request)
 {
     this._request = request;
 }
开发者ID:apetrovskiy,项目名称:STUPS,代码行数:4,代码来源:CacheRequest.cs


示例20: RandomCache

        /// -------------------------------------------------------------------
        /// <summary>HELPER: Generates a random cache</summary>
        /// -------------------------------------------------------------------
        static CacheRequest RandomCache()
        {
            Random rnd = new Random((int)DateTime.Now.Ticks);
            StringBuilder sb = new StringBuilder();
            CacheRequest cache = new CacheRequest();
            AutomationPattern p1;
            AutomationProperty p2;
            ArrayList propertyList = null;
            ArrayList patternList = null;

            PopulateAutomationElementProperties(ref propertyList, ref patternList);

            try
            {
                // Decide whether to add patterns
                if (rnd.Next(2) == 0)
                {
                    // Add up to two patterns
                    int maxIndex = rnd.Next(2);
                    for (int index = 0; index < maxIndex; index++)
                    {
                        try
                        {

                            if (null != (p1 = (AutomationPattern)patternList[rnd.Next(patternList.Count)]))
                            {
                                sb.Append(p1.ProgrammaticName + ":");
                                cache.Add(p1);
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                // Decide whether to add properties
                if (rnd.Next(2) == 0)
                {
                    // Add up to three AutomationProperty
                    int maxIndex = rnd.Next(3);
                    for (int index = 0; index < maxIndex; index++)
                    {
                        try
                        {
                            if (null != (p2 = (AutomationProperty)propertyList[(rnd.Next(propertyList.Count))]))
                            {
                                sb.Append(p2.ProgrammaticName + ":");
                                cache.Add(p2);
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }

                switch (rnd.Next(2))
                {
                    case 0:
                        cache.AutomationElementMode = AutomationElementMode.Full;
                        sb.Append(AutomationElementMode.Full + ":");
                        break;
                    case 1:
                        cache.AutomationElementMode = AutomationElementMode.None;
                        sb.Append(AutomationElementMode.None + ":");
                        break;
                    default:
                        throw new Exception("Bad test code(AutomationElementMode)");
                }

                switch (rnd.Next(6))
                {
                    case 0:
                        cache.TreeScope = TreeScope.Ancestors;
                        sb.Append(TreeScope.Ancestors + ":");
                        break;
                    case 1:
                        cache.TreeScope = TreeScope.Children;
                        sb.Append(TreeScope.Children + ":");
                        break;
                    case 2:
                        cache.TreeScope = TreeScope.Descendants;
                        sb.Append(TreeScope.Descendants + ":");
                        break;
                    case 3:
                        cache.TreeScope = TreeScope.Element;
                        sb.Append(TreeScope.Element + ":");
                        break;
                    case 4:
                        cache.TreeScope = TreeScope.Parent;
                        sb.Append(TreeScope.Parent + ":");
                        break;
                    case 5:
                        cache.TreeScope = TreeScope.Subtree;
                        sb.Append(TreeScope.Subtree + ":");
                        break;
                    default:
//.........这里部分代码省略.........
开发者ID:geeksree,项目名称:cSharpGeeks,代码行数:101,代码来源:stress.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Automation.ControlType类代码示例发布时间:2022-05-26
下一篇:
C# Automation.AutomationProperty类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap