コード例 #1
0
ファイル: TargetArea.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// Gets the target associated with a mouse location.
        /// </summary>
        /// <param name="mousePos">Mouse position.</param>
        /// <param name="target">Incoming target.</param>
        /// <returns>Target instance; otherwise null.</returns>
        public override Target FindTarget(Point mousePos, Target target)
        {
            // Is the mouse contained in the inside client rectangle?
            bool hotInside = _screenRect.Contains(mousePos);

            // Change in hot state?
            if (hotInside != _hotInside)
            {
                // Do we need to create the feedback indicators?
                if (hotInside)
                {
                    // Create the different indicator instances
                    _dropLeft   = new DropIndicators(_squares, false, true, false, false, false);
                    _dropRight  = new DropIndicators(_squares, false, false, true, false, false);
                    _dropTop    = new DropIndicators(_squares, false, false, false, true, false);
                    _dropBottom = new DropIndicators(_squares, false, false, false, false, true);

                    // Ask the window to be shown within the provided rectangle
                    _dropLeft.ShowRelative(_screenRect);
                    _dropRight.ShowRelative(_screenRect);
                    _dropTop.ShowRelative(_screenRect);
                    _dropBottom.ShowRelative(_screenRect);
                }
                else
                {
                    _active = 0;
                    Cleanup();
                }

                // Update state
                _hotInside = hotInside;
            }

            // Check the mouse position against the available drop indicators
            if (_hotInside)
            {
                int active = 0;

                // Can only test against indicators if hot zone not already defined
                if (target == null)
                {
                    // Find the newly active indicator
                    active = _dropLeft.ScreenMouseMove(mousePos);
                    if (active == 0)
                    {
                        active = _dropRight.ScreenMouseMove(mousePos);
                    }
                    if (active == 0)
                    {
                        active = _dropTop.ScreenMouseMove(mousePos);
                    }
                    if (active == 0)
                    {
                        active = _dropBottom.ScreenMouseMove(mousePos);
                    }
                }

                // Only interested in a change of active value
                if (_active != active)
                {
                    // Use new value
                    _active = active;

                    // If no longer need the indicators, remove them!
                    if (_active == 0)
                    {
                        _dropLeft.MouseReset();
                        _dropRight.MouseReset();
                        _dropTop.MouseReset();
                        _dropBottom.MouseReset();
                    }
                }

                // Use the current active hot zone
                switch (_active)
                {
                case 1:
                    target = _left;
                    break;

                case 2:
                    target = _right;
                    break;

                case 3:
                    target = _top;
                    break;

                case 4:
                    target = _bottom;
                    break;
                }
            }

            return(target);
        }
コード例 #2
0
ファイル: HotAreaInside.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// Find the new hot zone to use.
        /// </summary>
        /// <param name="mousePos">Screen mouse position.</param>
        /// <param name="hotZone">Incoming hot zone.</param>
        /// <param name="suppress">Suppress subsequent indicators.</param>
        /// <returns>New hot zone.</returns>
        public override HotZone FindHotZone(Point mousePos, HotZone hotZone, ref bool suppress)
        {
            // Is the mouse contained in the inside hot rectangle?
            bool hotInside = _insideRect.Contains(mousePos) && !suppress;

            // Change in hot state?
            if (hotInside != _hotInside)
            {
                // Do we need to create the feedback indicator?
                if (hotInside)
                {
                    // Create the indicator feedback
                    _drop = new DropIndicators(_squares, false, true, true, true, true);

                    // Ask the window to be shown within the provided rectangle
                    _drop.ShowRelative(_insideRect);
                }
                else
                {
                    _active = 0;
                    Cleanup();
                }

                // Update state
                _hotInside = hotInside;
            }

            // Check the mouse position against the available drop indicators
            if (_hotInside)
            {
                int active = 0;

                // Can only test against indicators if hot zone not already defined
                if (hotZone == null)
                {
                    // Find the newly active indicator
                    active = _drop.ScreenMouseMove(mousePos);
                }

                // Only interested in a change of active value
                if (_active != active)
                {
                    // Use new value
                    _active = active;

                    // If no longer need the indicators, remove them!
                    if (_active == 0)
                    {
                        _drop.MouseReset();
                    }
                }

                // Use the current active hot zone
                switch (_active)
                {
                case 1:
                    hotZone = _hotLeft;
                    break;

                case 2:
                    hotZone = _hotRight;
                    break;

                case 3:
                    hotZone = _hotTop;
                    break;

                case 4:
                    hotZone = _hotBottom;
                    break;
                }
            }

            return(hotZone);
        }
コード例 #3
0
ファイル: HotAreaTabbed.cs プロジェクト: zhaoyin/officeOBA
        /// <summary>
        /// Find the new hot zone to use.
        /// </summary>
        /// <param name="mousePos">Screen mouse position.</param>
        /// <param name="hotZone">Incoming hot zone.</param>
        /// <param name="suppress">Suppress subsequent indicators.</param>
        /// <returns>New hot zone.</returns>
        public override HotZone FindHotZone(Point mousePos, HotZone hotZone, ref bool suppress)
        {
            // Is the mouse contained in the inside hot rectangle?
            bool hotInside = _tabbedRect.Contains(mousePos) && !suppress;

            // Change in hot state?
            if (hotInside != _hotInside)
            {
                // Do we need to create the feedback indicator?
                if (hotInside)
                {
                    // Indicators depends on direction of zone
                    bool vert = (_zs.Direction == LayoutDirection.Vertical);

                    // Create the indicator feedback
                    _drop = new DropIndicators(_squares,
                                               !_disallowTabbed,
                                               !vert && !_disallowInsert,
                                               !vert && !_disallowInsert,
                                               vert && !_disallowInsert,
                                               vert && !_disallowInsert);

                    // Ask the window to be shown within the provided rectangle
                    _drop.ShowRelative(_tabbedRect);
                }
                else
                {
                    _active = 0;
                    Cleanup();
                }

                // Update state
                _hotInside = hotInside;
            }

            // Check the mouse position against the available drop indicators
            if (_hotInside)
            {
                int active = 0;

                // Can only test against indicators if hot zone not already defined
                if (hotZone == null)
                {
                    // Find the newly active indicator
                    active = _drop.ScreenMouseMove(mousePos);
                }

                // Only interested in a change of active value
                if (_active != active)
                {
                    // Use new value
                    _active = active;

                    // If no longer need the indicators, remove them!
                    if (_active == 0)
                    {
                        _drop.MouseReset();
                    }
                }

                // Use the current active hot zone
                switch (_active)
                {
                case 1:
                case 3:
                    hotZone = _hotLT;
                    break;

                case 2:
                case 4:
                    hotZone = _hotRB;
                    break;

                case 5:
                    hotZone = _hotMiddle;
                    break;
                }
            }

            // Do we suppress subsequenct indicators?
            if (_hotInside && _suppress)
            {
                suppress = true;
            }

            return(hotZone);
        }