Пример #1
0
        /// <summary>
        /// Mouse timer event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ontimerMouseElapsedEvent(object sender, ElapsedEventArgs e)
        {
            lock (_elementSetterLock)
            {
                if (this.timerMouse != null && this.IsStarted)
                {
                    NativeMethods.GetCursorPos(out Point p);

                    if (LastMousePoint.Equals(p) && this.POIPoint.Equals(p) == false)
                    {
                        var element = GetElementBasedOnScope(A11yAutomation.NormalizedElementFromPoint(p.X, p.Y, this.TreeViewMode));

                        if (element != null && element.IsRootElement() == false && element.IsSameUIElement(this.SelectedElementRuntimeId, this.SelectedBoundingRectangle, this.SelectedControlTypeId, this.SelectedName) == false && !POIPoint.Equals(p))
                        {
                            this.SelectedElementRuntimeId  = element.RuntimeId;
                            this.SelectedBoundingRectangle = element.BoundingRectangle;
                            this.SelectedControlTypeId     = element.ControlTypeId;
                            this.SelectedName = element.Name;
                            this.SetElement?.Invoke(element);
                        }
                        else
                        {
                            element?.Dispose();
                            element = null;
                        }

                        POIPoint = p;
                    }

                    LastMousePoint = p;

                    this.timerMouse?.Start(); // make sure that it is enabled.
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Mouse timer event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ontimerMouseElapsedEvent(object sender, ElapsedEventArgs e)
        {
            lock (_elementSetterLock)
            {
                if (this.timerMouse != null && this.IsStarted)
                {
                    NativeMethods.GetCursorPos(out Point p);

                    if (LastMousePoint.Equals(p) && !this.POIPoint.Equals(p))
                    {
                        var element = GetElementBasedOnScope(A11yAutomation.NormalizedElementFromPoint(p.X, p.Y, this.TreeViewMode));
                        if (!SelectElementIfItIsEligible(element))
                        {
                            element?.Dispose();
                        }
                        POIPoint = p;
                    }

                    LastMousePoint = p;

                    this.timerMouse?.Start(); // make sure that it is enabled.
                }
            }
        }