예제 #1
0
        private void UpdateBounds()
        {
            // TargetElement sometimes becomes null inside this method. Not sure how or why. -- MartinG
            // --> Copy the reference first and work with copy!
            var targetElement = _targetElement;

            if (targetElement != null && targetElement.IsVisible)
            {
                Point position = targetElement.PointToScreen(new Point(0, 0));
                position = DockHelper.ScreenToLogical(this, position);

                Left   = position.X;
                Top    = position.Y;
                Width  = targetElement.ActualWidth;
                Height = targetElement.ActualHeight;
            }
        }
        /// <summary>
        /// Gets the position of a <see cref="FloatWindow"/> if one would be shown at the current
        /// mouse position.
        /// </summary>
        /// <returns>The <see cref="FloatWindow"/> position.</returns>
        private Point GetFloatWindowPosition()
        {
            Debug.Assert(_dockControl != null);

            // Mouse position relative to DockControl in device-independent pixels.
            Point position = WindowsHelper.GetMousePosition(_dockControl);

            // Absolute mouse position in native screen coordinates.
            position = _dockControl.PointToScreen(position);

            // Absolute mouse position in device-independent pixels.
            position = DockHelper.ScreenToLogical(_dockControl, position);

            // Offset between window origin and mouse cursor.
            position -= _mouseOffset;

            return(position);
        }