Exemple #1
0
        public void Commit(Point e)
        {
            Verify.State.IsTrue(IsActive);

            KillMarker();
            _isActive = false;
            switch (_viewHost.DockSide.Side)
            {
            case AnchorStyles.Left:
            {
                var x = e.X - _resizeOffset;
                if (x < _minimumPosition)
                {
                    x = _minimumPosition;
                }
                else if (x > _maximumPosition)
                {
                    x = _maximumPosition;
                }
                _viewHost.Width = x + ViewConstants.SideDockPanelBorderSize;
            }
            break;

            case AnchorStyles.Top:
            {
                var y = e.Y - _resizeOffset;
                if (y < _minimumPosition)
                {
                    y = _minimumPosition;
                }
                else if (y > _maximumPosition)
                {
                    y = _maximumPosition;
                }
                _viewHost.Height = y + ViewConstants.SideDockPanelBorderSize;
            }
            break;

            case AnchorStyles.Right:
            {
                var x = e.X - _resizeOffset;
                if (x < _minimumPosition)
                {
                    x = _minimumPosition;
                }
                else if (x > _maximumPosition)
                {
                    x = _maximumPosition;
                }
                var w  = _viewHost.Width - x;
                var dw = _viewHost.Width - w;
                _viewHost.SetBounds(_viewHost.Left + dw, 0, w, 0, BoundsSpecified.X | BoundsSpecified.Width);
            }
            break;

            case AnchorStyles.Bottom:
            {
                var y = e.Y - _resizeOffset;
                if (y < _minimumPosition)
                {
                    y = _minimumPosition;
                }
                else if (y > _maximumPosition)
                {
                    y = _maximumPosition;
                }
                var h  = _viewHost.Height - y;
                var dh = _viewHost.Height - h;
                _viewHost.SetBounds(0, _viewHost.Top + dh, 0, h, BoundsSpecified.Y | BoundsSpecified.Height);
            }
            break;

            default:
                throw new ApplicationException("Unexpected ViewDockSide.Side: " + _viewHost.DockSide.Side);
            }
        }