コード例 #1
0
        void OnResizerDragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
        {
            LayoutGridResizerControl splitter = sender as LayoutGridResizerControl;
            var rootVisual = this.FindVisualTreeRoot() as Visual;

            var    trToWnd          = TransformToAncestor(rootVisual);
            Vector transformedDelta = trToWnd.Transform(new Point(e.HorizontalChange, e.VerticalChange)) -
                                      trToWnd.Transform(new Point());

            double delta;

            if (_side == AnchorSide.Right || _side == AnchorSide.Left)
            {
                delta = Canvas.GetLeft(_resizerGhost) - _initialStartPoint.X;
            }
            else
            {
                delta = Canvas.GetTop(_resizerGhost) - _initialStartPoint.Y;
            }

            if (_side == AnchorSide.Right)
            {
                if (_model.AutoHideWidth == 0.0)
                {
                    _model.AutoHideWidth = _internalHost.ActualWidth - delta;
                }
                else
                {
                    _model.AutoHideWidth -= delta;
                }

                _internalGrid.ColumnDefinitions[1].Width = new GridLength(_model.AutoHideWidth, GridUnitType.Pixel);
            }
            else if (_side == AnchorSide.Left)
            {
                if (_model.AutoHideWidth == 0.0)
                {
                    _model.AutoHideWidth = _internalHost.ActualWidth + delta;
                }
                else
                {
                    _model.AutoHideWidth += delta;
                }

                _internalGrid.ColumnDefinitions[0].Width = new GridLength(_model.AutoHideWidth, GridUnitType.Pixel);
            }
            else if (_side == AnchorSide.Top)
            {
                if (_model.AutoHideHeight == 0.0)
                {
                    _model.AutoHideHeight = _internalHost.ActualHeight + delta;
                }
                else
                {
                    _model.AutoHideHeight += delta;
                }

                _internalGrid.RowDefinitions[0].Height = new GridLength(_model.AutoHideHeight, GridUnitType.Pixel);
            }
            else if (_side == AnchorSide.Bottom)
            {
                if (_model.AutoHideHeight == 0.0)
                {
                    _model.AutoHideHeight = _internalHost.ActualHeight - delta;
                }
                else
                {
                    _model.AutoHideHeight -= delta;
                }

                _internalGrid.RowDefinitions[1].Height = new GridLength(_model.AutoHideHeight, GridUnitType.Pixel);
            }

            HideResizerOverlayWindow();

            IsResizing = false;
            InvalidateMeasure();

            LayoutSetting.AddDefaultAutoHideWidthAnchorable(_model.Title, _model.AutoHideWidth.ToString());
            LayoutSetting.AddDefaultAutoHideHeighAnchorable(_model.Title, _model.AutoHideHeight.ToString());
        }