Ejemplo n.º 1
0
        public void Commit(Point location)
        {
            Verify.State.IsTrue(IsActive);

            IsActive = false;
            bool docking = false;

            location = ViewHost.PointToScreen(location);
            if (HoveredDockGrid != null)
            {
                var dockResult = HoveredDockGrid.DockMarkers.HitTest(location);
                if (HoveredDockGrid.CanDock(ViewHost, dockResult))
                {
                    docking = true;
                    HoveredDockGrid.PerformDock(ViewHost, dockResult);
                }
                HoveredDockGrid.DockMarkers.Hide();
                HoveredDockGrid = null;
            }
            if (HoveredViewHost != null)
            {
                var host = HoveredViewHost;
                if (!docking)
                {
                    var dockResult = host.DockMarkers.HitTest(location);
                    if (host.CanDock(ViewHost, dockResult))
                    {
                        host.PerformDock(ViewHost, dockResult);
                    }
                }
                host.DockMarkers.Hide();
            }
        }
Ejemplo n.º 2
0
        private static Rectangle GetBounds(ViewHost dockHost, ViewHost dockClient)
        {
            var loc  = dockHost.PointToScreen(Point.Empty);
            var size = dockHost.Size;

            if (dockHost.IsDocumentWell)
            {
                if (dockClient.IsDocumentWell || (dockClient.ViewsCount == 1 && dockClient.GetView(0).IsDocument))
                {
                    return(new Rectangle(
                               loc.X + (size.Width - 112) / 2,
                               loc.Y + (size.Height - 112) / 2,
                               112, 112));
                }
                else
                {
                    return(new Rectangle(
                               loc.X + (size.Width - 184) / 2,
                               loc.Y + (size.Height - 184) / 2,
                               184, 184));
                }
            }
            else
            {
                return(new Rectangle(
                           loc.X + (size.Width - 112) / 2,
                           loc.Y + (size.Height - 112) / 2,
                           112, 112));
            }
        }
Ejemplo n.º 3
0
        public bool Start(Point location)
        {
            Verify.State.IsFalse(IsActive);

            _isActive = true;
            location  = _viewHost.PointToScreen(location);
            var grid = HitTestGrid(location);

            if (grid != null)
            {
                _hoveredGrid = grid;
                grid.DockMarkers.Show(_viewHost);
                grid.DockMarkers.UpdateHover(location);
            }
            var host = HitTestViewHost(location);

            if (host != null)
            {
                _hoveredHost = host;
                host.DockMarkers.Show(_viewHost);
                host.DockMarkers.UpdateHover(location);
            }
            return(true);
        }
Ejemplo n.º 4
0
        public void Update(Point location)
        {
            Verify.State.IsTrue(IsActive);

            switch (_viewHost.DockSide.Orientation)
            {
            case Orientation.Vertical:
            {
                var x = location.X - _resizeOffset;
                if (x < _minimumPosition)
                {
                    x = _minimumPosition;
                }
                else if (x > _maximumPosition)
                {
                    x = _maximumPosition;
                }
                location = new Point(x, 0);
            }
            break;

            case Orientation.Horizontal:
            {
                var y = location.Y - _resizeOffset;
                if (y < _minimumPosition)
                {
                    y = _minimumPosition;
                }
                else if (y > _maximumPosition)
                {
                    y = _maximumPosition;
                }
                location = new Point(0, y);
            }
            break;

            default:
                throw new ApplicationException("Unexpected ViewDockSide.Orientation: " + _viewHost.DockSide.Orientation);
            }
            location = _viewHost.PointToScreen(location);
            _splitterMarker.Location = location;
        }
Ejemplo n.º 5
0
        public void Update(Point location)
        {
            Verify.State.IsTrue(IsActive);

            bool gridHit = false;

            location = ViewHost.PointToScreen(location);
            var grid = HitTestGrid(location);

            if (grid != null)
            {
                if (HoveredDockGrid != null)
                {
                    if (HoveredDockGrid != grid)
                    {
                        HoveredDockGrid.DockMarkers.Hide();
                        HoveredDockGrid = grid;
                        grid.DockMarkers.Show(ViewHost);
                    }
                }
                else
                {
                    HoveredDockGrid = grid;
                    grid.DockMarkers.Show(ViewHost);
                }
                gridHit = grid.DockMarkers.UpdateHover(location);
            }
            else
            {
                if (HoveredDockGrid != null)
                {
                    HoveredDockGrid.DockMarkers.Hide();
                    HoveredDockGrid = null;
                }
            }
            var host = HitTestViewHost(location);

            if (host != null)
            {
                if (HoveredViewHost != null)
                {
                    if (HoveredViewHost != host)
                    {
                        HoveredViewHost.DockMarkers.Hide();
                        HoveredViewHost = host;
                        host.DockMarkers.Show(ViewHost);
                    }
                }
                else
                {
                    HoveredViewHost = host;
                    host.DockMarkers.Show(ViewHost);
                }
                if (!gridHit)
                {
                    host.DockMarkers.UpdateHover(location);
                }
                else
                {
                    host.DockMarkers.Unhover();
                }
            }
            else
            {
                if (HoveredViewHost != null)
                {
                    HoveredViewHost.DockMarkers.Hide();
                    HoveredViewHost = null;
                }
            }
        }