コード例 #1
0
ファイル: Example1.cs プロジェクト: nanshuge-qa/UIAutomation
        private void PatternExample()
        {
            var root   = AutomationElement.RootElement;
            var window = UITree.Query(root).UsingTreeWalkerEngine()
                         // Query 1.
                         .FindChildren().Where()
                         .Name().Contains("Microsoft Visual Studio")
                         .And()
                         .Type().Is(ControlType.Window)
                         .Select().FirstResult();

            var windows = UITree.Query(root).UsingTreeWalkerEngine()
                          // Query 2.
                          .FindChildren().Where()
                          .Name().Contains("Microsoft Visual Studio")
                          .And()
                          .Type().Is(ControlType.Window)
                          .Select().AllResults();

            // Execute using the 'Window' pattern.
            window.Execute <WindowPattern>(p => p.SetWindowVisualState(WindowVisualState.Minimized));
            // Can also be called on a collection of UI components.
            windows.Execute <WindowPattern>((p, c) => p.SetWindowVisualState(WindowVisualState.Minimized));

            // Or, using the .Pattern() method (only available on single components).
            window.Pattern <WindowPattern>().SetWindowVisualState(WindowVisualState.Minimized);
        }
コード例 #2
0
ファイル: UIRoot.cs プロジェクト: gitchenjiangkun/RedDot
 private void Start()
 {
     Tree = new UITree(transform);
     Tree.SetRedDot(RedDot1);
     Tree.SetRedDot(RedDot2);
     Tree.SetRedDot(RedDot3);
 }
コード例 #3
0
 public UITree GetTreeNodeById(Guid?id, string type)
 {
     if (!string.IsNullOrEmpty(id.ToString()))
     {
         Guid guid = Guid.Parse(id.ToString());
         if (type.Contains("user"))
         {
             User result = new UserApiController().Repository.Query(user => user.ID == guid).FirstOrDefault();
             var  tree   = new UITree()
             {
                 id      = result.ID.ToString(),
                 text    = result.RealName,
                 iconCls = geticon("user"),
             };
             return(tree);
         }
         else if (type.Contains("organization") || type.Contains("department"))
         {
             Organization result = base.Get(guid);
             var          tree   = new UITree()
             {
                 id      = result.ID.ToString(),
                 text    = result.Name,
                 iconCls = geticon(result.OrgType),
             };
             return(tree);
         }
     }
     return(null);
 }
コード例 #4
0
        /// <summary>
        /// Gets another sample type structured data
        /// </summary>
        /// <param name="context">context</param>
        /// <returns>another sample type structured data</returns>
        public UITree GetAnotherTypeStructuredData(Context context)
        {
            var setProvider       = this.setProviderResolver.GetService(context);
            var structureProvider = this.structureProviderResolver.GetService(context);

            var descriptorTree = structureProvider.GetAnotherTypeDescriptorTree(context);

            return(UITree.Create <string, AnotherType>(descriptorTree, name => setProvider.GetAnotherTypeInstanceByName(context, name)));
        }
コード例 #5
0
 private void GetComponent()
 {
     _myTransform     = transform;
     _container       = _myTransform.Find("Container");
     toggle           = _container.Find("Toggle").GetComponent <Toggle>();
     icon             = _container.Find("IconContainer/Icon").GetComponent <Image>();
     text             = _container.Find("Text").GetComponent <Text>();
     _toggleTransform = toggle.transform.Find("Image");
     UITree           = _myTransform.parent.parent.parent.GetComponent <UITree>();
 }
コード例 #6
0
 private void Awake()
 {
     if (Instance != null && Instance != this)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
     }
 }
コード例 #7
0
        /// <summary>
        /// Lists sample type instances
        /// </summary>
        /// <param name="context">context</param>
        /// <returns>list of sample type instances</returns>
        public List <SampleType> ListSampleTypes(Context context)
        {
            var setProvider       = this.setProviderResolver.GetService(context);
            var structureProvider = this.structureProviderResolver.GetService(context);

            var descriptorsTree = structureProvider.GetSampleTypeDescriptorTree(context);
            var entityRootsTree = UITree
                                  .Create <string, SampleType>(descriptorsTree, name => setProvider.GetSampleTypeInstanceByName(context, name))
                                  .GetEntityRootsTree();

            return(entityRootsTree.Roots.Select(root => ((EntityTreeNode <SampleType>)root).Entity).ToList());
        }
コード例 #8
0
        public IEnumerable <UITree> GetOrganizationsAndUser(Guid?id)
        {
            List <UITree>       treelst = new List <UITree>();
            List <Organization> lst     = new List <Organization>();

            if (string.IsNullOrEmpty(id.ToString()))
            {
                lst.AddRange(Repository.Query(org => org.POrganizationID == null).OrderBy(org => org.Sort).ToList());
            }
            else
            {
                lst.AddRange(Repository.Query(org => org.POrganizationID == id).OrderBy(org => org.Sort).ToList());
            }
            foreach (var organization in lst)
            {
                var tree = new UITree()
                {
                    id         = organization.ID.ToString(),
                    text       = organization.Name,
                    iconCls    = geticon(organization.OrgType),
                    attributes = new { Type = organization.OrgType },
                };
                var orgchildren  = Repository.Query(org => org.POrganizationID == organization.ID).OrderBy(org => org.Sort).ToList();
                var userchildren = GetSubUsersByOrganizationID(organization.ID);
                tree.children.AddRange(userchildren);

                foreach (var child in orgchildren)
                {
                    var uitree = new UITree()
                    {
                        id         = child.ID.ToString(),
                        text       = child.Name,
                        iconCls    = geticon(child.OrgType),
                        attributes = new { Type = child.OrgType },
                    };

                    var userlst = GetSubUsersByOrganizationID(child.ID);
                    var orglst  = GetOrganizationsAndUser(child.ID).ToList();

                    uitree.children.AddRange(userlst);

                    uitree.children.AddRange(orglst);

                    tree.children.Add(uitree);
                }

                treelst.Add(tree);
            }

            return(treelst);
        }
コード例 #9
0
 public void Clear()
 {
     RemoveListener();
     text.text        = "Hierarchy";
     toggle.isOn      = true;
     icon.sprite      = null;
     TreeData         = null;
     UITree           = null;
     toggle           = null;
     icon             = null;
     text             = null;
     _toggleTransform = null;
     _myTransform     = null;
     _container       = null;
     _children.Clear();
 }
コード例 #10
0
ファイル: Example1.cs プロジェクト: nanshuge-qa/UIAutomation
        private void QueryExample()
        {
            var root   = AutomationElement.RootElement;
            var window = UITree.Query(root).UsingTreeWalkerEngine()
                         // Query 1.
                         .FindChildren().Where()
                         .Name().Contains("Microsoft Visual Studio")
                         .And()
                         .Type().Is(ControlType.Window)
                         .Select().FirstResult();

            var titleBar = UITree.Query(window).UsingDefaultEngine()
                           // Query 2
                           .FindChildren().Where()
                           .Type().Is(ControlType.TitleBar)
                           .Select().FirstResult();

            Console.WriteLine(titleBar.Element.Current.Name);
        }
コード例 #11
0
        public override UITree InitUITree()
        {
            UITree uiTree_launch = UIUtil.AutoCreateUITree(
                new UINode("Button_begin"),
                new UINode("Button_change"),
                new UINode("Button_set"),
                new UINode("Button_exit"),
                new UINode("Panel_logo",
                           new UINode("Image_gender"),
                           new UINode("Image_name"),
                           new UINode("Image_icon")));

            uiTree_launch["Button_begin"].BindEvent_Button(() =>
            {
                uiTree_launch["Image_icon"].ChangeSpriteColor(Color.red);
            });
            uiTree_launch["Button_exit"].BindEvent_Button(() =>
            {
                uiTree_launch["Image_icon"].ChangeSpriteColor(Color.yellow);
            });
            return(uiTree_launch);
        }
コード例 #12
0
        public IEnumerable <UITree> GetOrganizationsComboTree(Guid?id)
        {
            List <UITree>       treelst = new List <UITree>();
            List <Organization> lst     = new List <Organization>();

            if (string.IsNullOrEmpty(id.ToString()))
            {
                lst.AddRange(Repository.Query(org => org.POrganizationID == null).OrderBy(org => org.Sort).ToList());
            }
            else
            {
                lst.AddRange(Repository.Query(org => org.POrganizationID == id).OrderBy(org => org.Sort).ToList());
            }
            foreach (var organization in lst)
            {
                var tree = new UITree()
                {
                    id      = organization.ID.ToString(),
                    text    = organization.Name,
                    iconCls = "",
                };
                var orgchildren = Repository.Query(org => org.POrganizationID == organization.ID).OrderBy(org => org.Sort).ToList();
                foreach (var child in orgchildren)
                {
                    tree.children.Add(new UITree()
                    {
                        id       = child.ID.ToString(),
                        text     = child.Name,
                        iconCls  = "",
                        children = GetOrganizationsComboTree(child.ID).ToList(),
                    });
                }
                treelst.Add(tree);
            }

            return(treelst);
        }
コード例 #13
0
        public IEnumerable <UITree> GetMenusByModule(string modulecode, Guid?id)
        {
            if (string.IsNullOrEmpty(modulecode))
            {
                return(null);
            }
            var moduleMenus = Repository.Query(menu => menu.Module.Code == modulecode && menu.PMenuID == id).OrderBy(menu => menu.SortKey).ToList();

            List <UITree> menulst = new List <UITree>();

            foreach (Menu item in moduleMenus)
            {
                UITree menu = new UITree()
                {
                    id         = item.ID.ToString(),
                    text       = item.DisplayName,
                    iconCls    = item.IconCls,
                    attributes = new
                    {
                        URL      = string.Format("/{0}/{1}/{2}", item.Module.Code, item.Controller, item.Action),
                        Width    = item.Width,
                        Height   = item.Height,
                        OpenType = item.OpenModel
                    }
                };
                if (!item.IsLeaf)
                {
                    var sub = GetMenusByModule(modulecode, item.ID);
                    if (sub != null)
                    {
                        menu.children.AddRange(sub);
                    }
                }
                menulst.Add(menu);
            }
            return(menulst);
        }
コード例 #14
0
 /// <summary>
 ///     Gets a query set to search children using a tree walker engine.
 /// </summary>
 /// <returns></returns>
 private QueryWherePart Query()
 {
     return(UITree.Query(AutomationElement.RootElement).UsingTreeWalkerEngine().FindChildren());
 }
コード例 #15
0
ファイル: FormDev.cs プロジェクト: brezza92/PixelFarm
        private void cmdRBTreeTest_Click(object sender, EventArgs e)
        {
            GC.Collect();
            System.Diagnostics.Stopwatch st1 = new System.Diagnostics.Stopwatch();
            {
                List <UIElement> list1 = new List <UIElement>();
                st1.Start();
                for (int i = 0; i < 10000; ++i)
                {
                    Box box1 = new Box(30, 30);
                    list1.Add(box1);
                }
                st1.Stop();
                System.Diagnostics.Debug.WriteLine("list:" + st1.ElapsedMilliseconds);
                st1.Reset();
                list1.TrimExcess();
                list1.Clear();
                GC.Collect();
            }
            //---------------
            {
                LinkedList <UIElement> linkedList = new LinkedList <UIElement>();
                st1.Start();
                for (int i = 0; i < 10000; ++i)
                {
                    Box box1 = new Box(30, 30);
                    linkedList.AddLast(box1);
                }
                st1.Stop();
                System.Diagnostics.Debug.WriteLine("linked-list:" + st1.ElapsedMilliseconds);
                st1.Reset();
                linkedList.Clear();
                GC.Collect();
            }
            //---------------
            {
                var elemTree = new UITree();
                st1.Start();
                for (int i = 0; i < 10000; ++i)
                {
                    Box box1 = new Box(30, 30);
                    elemTree.Add(box1);
                }
                st1.Stop();
                System.Diagnostics.Debug.WriteLine("tree1:" + st1.ElapsedMilliseconds);
                st1.Reset();
                elemTree.Clear();
                GC.Collect();
                //---------------
            }
            {
                var elemTree = new RedBlackTree <RBNode <int> >();
                for (int i = 0; i < 10000; ++i)
                {
                    elemTree.Add(new RBNode <int>(i));
                }

                //find element at specfic position
                st1.Start();
                var node  = elemTree.GetNodeAt(500);
                var node2 = elemTree.GetNodeAt(10000 - 20);
                st1.Stop();
                //---------------
                st1.Reset();
                System.Diagnostics.Debug.WriteLine("tree1:" + st1.ElapsedMilliseconds);
            }
        }