Beispiel #1
0
        /// <summary>
        /// Creates TreeNode for the AutomationElement
        /// </summary>
        public static TreeNode CreateNodeForAutomationElement(AutomationElement element, AutomationElementTreeControl parentControl)
        {
//            System.Diagnostics.Debug.WriteLine("CreateNodeForAutomationElement...");

            TreeNode node = new TreeNode(TreeHelper.GetAutomationElementTreeNodeText(element));
            node.Tag = new AutomationElementTreeNode(element, node, parentControl);

            if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsContentElementProperty))
            {
                node.ForeColor = Color.Black; //.NodeFont = new Font(FontFamily.GenericSerif, 10, FontStyle.Bold);
            }
            else
            {
                node.ForeColor = Color.DarkGray;
            }


            /*************************************************/
            // this is only for test purposes, it makes the creation of each TreeNode slower
            //DateTime now = DateTime.Now;
            //DateTime endTime = now.AddMilliseconds(400);

            //while (DateTime.Now < endTime) ;
            /*************************************************/

//            System.Diagnostics.Debug.WriteLine("CreateNodeForAutomationElement EXIT");

            return node;
        }
        internal AutomationElementTreeNode(AutomationElement element, TreeNode node, AutomationElementTreeControl automationElementTreeControl)
        {
            Debug.Assert(element != null);
            this.AutomationElement = element;

            this.TreeNode = node;
            this.AutomationElementTreeControl = automationElementTreeControl;
        }
        internal AutomationElementTreeNode(AutomationElement element, TreeNode node, AutomationElementTreeControl automationElementTreeControl)
        {
            Debug.Assert(element != null);
            this.AutomationElement = element;

            this.TreeNode = node;
            this.AutomationElementTreeControl = automationElementTreeControl;
        }
        /// <summary>
        /// creates appropriate ElementHighLighter according to the id
        /// </summary>
        /// <returns>new instance of ElementHighLighter</returns>
        public static ElementHighlighter CreateHighlighterById(string id, AutomationElementTreeControl treeControl)
        {
            Debug.Assert(id != null);

            switch (id.ToUpper())
            {
                case BoundingRectangle: return new BoundingRectangleElementHighLighter(treeControl);
                case FadingBoundingRectangle: return new FadingBoundingRectangleElementHighLighter(treeControl);
                case BoundingRectangleAndRays: return new RaysAndBoundingRectangleElementHighlighter(treeControl);

                default:
                    throw new ArgumentException(String.Format("Invalid argument value {0}", id));
            }
        }
 public ElementHighlighter(AutomationElementTreeControl treeControl)
 {
     Debug.Assert(treeControl != null);
     this._treeControl = treeControl;
 }
        public RaysAndBoundingRectangleElementHighlighter(AutomationElementTreeControl treeControl) : base(treeControl)
        {
            _topLeftVerticalRay = new ScreenRectangle();
            _topLeftHorizontalRay = new ScreenRectangle();
            _topRightVerticalRay = new ScreenRectangle();
            _topRightHorizontalRay = new ScreenRectangle();
            _bottomLeftVerticalRay = new ScreenRectangle();
            _bottomLeftHorizontalRay = new ScreenRectangle();
            _bottomRightVerticalRay = new ScreenRectangle();
            _bottomRightHorizontalRay = new ScreenRectangle();

            this._rays = new ScreenRectangle[] { _topLeftVerticalRay , _topLeftHorizontalRay ,
                _topRightVerticalRay , _topRightHorizontalRay ,
                _bottomLeftVerticalRay , _bottomLeftHorizontalRay ,
                _bottomRightVerticalRay , _bottomRightHorizontalRay };

            double boundingRectOpacity = base._rectangle.Opacity;

            foreach (ScreenRectangle ray in this._rays)
            {
                ray.Color = Drawing.Color.Blue;
                ray.Opacity = boundingRectOpacity;
            }
        }
 public FadingBoundingRectangleElementHighLighter(AutomationElementTreeControl treeControl) : base(treeControl) { }
 public BoundingRectangleElementHighLighter(AutomationElementTreeControl treeControl) : base(treeControl)
 {
     _rectangle.Color = Drawing.Color.Red;
     _rectangle.Opacity = 0.8;
 }
        /// <summary>
        /// this will stop highlighting, release all handlers and references.
        /// </summary>
        public void Dispose()
        {
            if (!_isDisposed)
            {
                StopHighlighting();
                OnDispose();

                _treeControl = null;
                _isDisposed = true;
            }
        }
Beispiel #10
0
        /// <summary>
        /// Creates TreeNode for the AutomationElement
        /// </summary>
        public static TreeNode CreateNodeForAutomationElement(AutomationElement element, AutomationElementTreeControl parentControl)
        {
//            System.Diagnostics.Debug.WriteLine("CreateNodeForAutomationElement...");

            TreeNode node = new TreeNode(TreeHelper.GetAutomationElementTreeNodeText(element));

            node.Tag = new AutomationElementTreeNode(element, node, parentControl);

            if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsContentElementProperty))
            {
                node.ForeColor = Color.Black; //.NodeFont = new Font(FontFamily.GenericSerif, 10, FontStyle.Bold);
            }
            else
            {
                node.ForeColor = Color.DarkGray;
            }


            /*************************************************/
            // this is only for test purposes, it makes the creation of each TreeNode slower
            //DateTime now = DateTime.Now;
            //DateTime endTime = now.AddMilliseconds(400);

            //while (DateTime.Now < endTime) ;
            /*************************************************/

//            System.Diagnostics.Debug.WriteLine("CreateNodeForAutomationElement EXIT");

            return(node);
        }
Beispiel #11
0
 public FocusTracer(AutomationElementTreeControl TreeControl)
 {
     this._treeControl = TreeControl;
 }
Beispiel #12
0
 /// <summary>
 /// initialize with tree control
 /// </summary>
 public HoverMode(AutomationElementTreeControl TreeControl)
 {
     this._treeControl = TreeControl;
 }