示例#1
0
        private void OnTargetChanged(IInputElement oldTarget, IInputElement newTarget)
        {
            IInputElement[] oldTargetPath = oldTarget != null?oldTarget.GetPathFromRoot().ToArray() : new IInputElement[0];

            IInputElement[] newTargetPath = newTarget != null?newTarget.GetPathFromRoot().ToArray() : new IInputElement[0];

            int splitIndex = 0;

            while (splitIndex < oldTargetPath.Length && splitIndex < newTargetPath.Length && oldTargetPath[splitIndex] == newTargetPath[splitIndex])
            {
                splitIndex++;
            }

            int timestamp = presentationSource.GetTimestamp();

            for (int i = oldTargetPath.Length - 1; i >= splitIndex; i--)
            {
                oldTargetPath[i].RaiseEvent(new MouseEventArgs(Mouse.MouseLeaveEvent, oldTargetPath[i], this, timestamp, Position));
            }

            for (int i = splitIndex; i < newTargetPath.Length; i++)
            {
                newTargetPath[i].RaiseEvent(new MouseEventArgs(Mouse.MouseEnterEvent, newTargetPath[i], this, timestamp, Position));
            }

            Cursor = QueryCursor(timestamp);
        }
示例#2
0
        private void OnTargetChanged(IInputElement oldTarget, IInputElement newTarget)
        {
            IInputElement[] oldTargetPath = oldTarget != null ? oldTarget.GetPathFromRoot().ToArray() : new IInputElement[0];
            IInputElement[] newTargetPath = newTarget != null ? newTarget.GetPathFromRoot().ToArray() : new IInputElement[0];

            int splitIndex = 0;
            while (splitIndex < oldTargetPath.Length && splitIndex < newTargetPath.Length && oldTargetPath[splitIndex] == newTargetPath[splitIndex])
            {
                splitIndex++;
            }

            int timestamp = presentationSource.GetTimestamp();

            for (int i = oldTargetPath.Length - 1; i >= splitIndex; i--)
            {
                oldTargetPath[i].RaiseEvent(new MouseEventArgs(Mouse.MouseLeaveEvent, oldTargetPath[i], this, timestamp, Position));
            }

            for (int i = splitIndex; i < newTargetPath.Length; i++)
            {
                newTargetPath[i].RaiseEvent(new MouseEventArgs(Mouse.MouseEnterEvent, newTargetPath[i], this, timestamp, Position));
            }

            Cursor = QueryCursor(timestamp);
        }