示例#1
0
        public bool Start(Point location)
        {
            Verify.State.IsFalse(IsActive);
            Verify.State.IsTrue(_viewHost.Status == ViewHostStatus.AutoHide);
            Verify.State.IsTrue(_viewHost.Visible);

            _isActive = true;
            var         size = _viewHost.Size;
            Rectangle   bounds;
            var         side          = _viewHost.DockSide;
            var         grid          = side.Grid;
            var         rootCtlBounds = grid.RootControl.Bounds;
            Orientation orientation;

            switch (side.Side)
            {
            case AnchorStyles.Left:
                _minimumPosition = ViewConstants.MinimumHostWidth;
                _maximumPosition = grid.HorizontalClientSpace - ViewConstants.SideDockPanelBorderSize;
                bounds           = new Rectangle(
                    size.Width - ViewConstants.SideDockPanelBorderSize, 0,
                    ViewConstants.SideDockPanelBorderSize, size.Height);
                _resizeOffset = location.X - bounds.X;
                orientation   = Orientation.Horizontal;
                break;

            case AnchorStyles.Top:
                _minimumPosition = ViewConstants.MinimumHostHeight;
                _maximumPosition = grid.VerticalClientSpace - ViewConstants.SideDockPanelBorderSize;
                bounds           = new Rectangle(
                    0, size.Height - ViewConstants.SideDockPanelBorderSize,
                    size.Width, ViewConstants.SideDockPanelBorderSize);
                _resizeOffset = location.Y - bounds.Y;
                orientation   = Orientation.Vertical;
                break;

            case AnchorStyles.Right:
                _minimumPosition = size.Width - grid.HorizontalClientSpace;
                _maximumPosition = size.Width - ViewConstants.MinimumHostWidth;
                bounds           = new Rectangle(
                    0, 0,
                    ViewConstants.SideDockPanelBorderSize, size.Height);
                _resizeOffset = location.X - bounds.X;
                orientation   = Orientation.Horizontal;
                break;

            case AnchorStyles.Bottom:
                _minimumPosition = size.Height - grid.VerticalClientSpace;
                _maximumPosition = size.Height - ViewConstants.MinimumHostHeight;
                bounds           = new Rectangle(
                    0, 0,
                    size.Width, ViewConstants.SideDockPanelBorderSize);
                _resizeOffset = location.Y - bounds.Y;
                orientation   = Orientation.Vertical;
                break;

            default:
                throw new ApplicationException();
            }
            bounds.Location = _viewHost.PointToClient(bounds.Location);
            SpawnMarker(bounds, orientation);
            return(true);
        }