Ejemplo n.º 1
0
        private void OnLocationChanged(object sender, EventArgs e)
        {
            var win = (HostWindow)sender;

            if (!win.IsLoaded || !TabControl.IsTabDragging || TabControl.Items.Count > 1)
            {
                return;
            }

            var absolutePoint = MouseUtilities.GetScreenPosition();

            var windowUnder = win.FindWindowUnderAt(absolutePoint);

            if (windowUnder == null)
            {
                return;
            }

            // The screen position relative to the main window
            var relativePoint = windowUnder.PointFromScreen(absolutePoint);

            if (TryDockToWindow(windowUnder, relativePoint, TabControl.SelectedItem as TabViewModelBase))
            {
                win.Close();
            }
        }
Ejemplo n.º 2
0
        public void OnMouseMove(MouseEventArgs e)
        {
            if (!_needsRestore)
            {
                return;
            }

            _needsRestore = false;

            var position = e.GetPosition(_window);
            var bounds   = _window.RestoreBounds;

            var percentHorizontal = position.X / _window.ActualWidth;
            var targetHorizontal  = bounds.Width * percentHorizontal;

            var percentVertical = position.Y / _window.ActualHeight;
            var targetVertical  = bounds.Height * percentVertical;

            var screenPosition = MouseUtilities.GetScreenPosition();

            _window.Left = screenPosition.X - targetHorizontal;
            _window.Top  = screenPosition.Y - targetVertical;

            _window.WindowState = WindowState.Normal;

            _window.DragMove();
        }