Beispiel #1
0
        public Size GetViewportSize(Size availableSize)
        {
            SheetLayout sheetLayout = Excel.GetSheetLayout();

            if (Area == SheetArea.ColumnHeader)
            {
                double viewportWidth = sheetLayout.GetViewportWidth(ColumnViewportIndex);
                double headerHeight  = sheetLayout.HeaderHeight;
                viewportWidth = Math.Min(viewportWidth, availableSize.Width);
                return(new Size(viewportWidth, Math.Min(headerHeight, availableSize.Height)));
            }

            double headerWidth    = sheetLayout.HeaderWidth;
            double viewportHeight = sheetLayout.GetViewportHeight(RowViewportIndex);

            headerWidth = Math.Min(headerWidth, availableSize.Width);
            return(new Size(headerWidth, Math.Min(viewportHeight, availableSize.Height)));
        }
Beispiel #2
0
        void EndRowSplitting()
        {
            double             num2;
            HitTestInformation savedHitTestInformation = GetHitInfo();
            SheetLayout        layout = GetSheetLayout();
            int rowViewportIndex      = savedHitTestInformation.RowViewportIndex;

            IsWorking           = false;
            IsRowSplitting      = false;
            IsTouchRowSplitting = false;
            switch (savedHitTestInformation.HitTestType)
            {
            case HitTestType.RowSplitBar:
            case HitTestType.ColumnSplitBar:
                if (MousePosition.Y <= layout.GetVerticalSplitBarY(rowViewportIndex))
                {
                    num2 = layout.GetVerticalSplitBarY(rowViewportIndex) - MousePosition.Y;
                }
                else
                {
                    num2 = Math.Max(0.0, ((MousePosition.Y - layout.GetVerticalSplitBarY(rowViewportIndex)) - layout.GetVerticalSplitBarHeight(rowViewportIndex)));
                }
                if (num2 != 0.0)
                {
                    double deltaViewportHeight = (_rowSplittingTracker.Y1 - layout.GetVerticalSplitBarY(rowViewportIndex)) - (layout.GetVerticalSplitBarHeight(rowViewportIndex) / 2.0);
                    int    viewportIndex       = savedHitTestInformation.RowViewportIndex;
                    if (!RaiseRowViewportHeightChanging(viewportIndex, deltaViewportHeight))
                    {
                        AdjustRowViewport(rowViewportIndex, deltaViewportHeight);
                        RaiseRowViewportHeightChanged(viewportIndex, deltaViewportHeight);
                    }
                }
                break;

            case HitTestType.RowSplitBox:
                if (RowSplitBoxAlignment == SplitBoxAlignment.Leading)
                {
                    num2 = Math.Max(0.0, ((MousePosition.Y - layout.GetViewportY(rowViewportIndex)) - _defaultSplitBarSize));
                }
                else
                {
                    num2 = Math.Max(0.0, (((layout.GetViewportY(rowViewportIndex) + layout.GetViewportHeight(rowViewportIndex)) - MousePosition.Y) - _defaultSplitBarSize));
                }
                if (num2 > 0.0)
                {
                    double num3 = (_rowSplittingTracker.Y1 - layout.GetViewportY(rowViewportIndex)) - (_defaultSplitBarSize / 2.0);
                    int    num4 = (RowSplitBoxAlignment == SplitBoxAlignment.Leading) ? 0 : (GetViewportInfo().RowViewportCount - 1);
                    if (!RaiseRowViewportHeightChanging(num4, num3))
                    {
                        AddRowViewport(rowViewportIndex, num3);
                        RaiseRowViewportHeightChanged(num4, num3);
                        ShowCell(GetActiveRowViewportIndex(), GetActiveColumnViewportIndex(), ActiveSheet.ActiveRowIndex, ActiveSheet.ActiveColumnIndex, VerticalPosition.Nearest, HorizontalPosition.Nearest);
                    }
                }
                break;

            default:
                break;
            }
            _rowSplittingTracker.Opacity = 0.0;
        }
Beispiel #3
0
        void ContinueRowSplitting()
        {
            HitTestInformation savedHitTestInformation = GetHitInfo();
            SheetLayout        layout = GetSheetLayout();
            int rowViewportIndex      = savedHitTestInformation.RowViewportIndex;

            switch (savedHitTestInformation.HitTestType)
            {
            case HitTestType.RowSplitBar:
            case HitTestType.ColumnSplitBar:
                if (MousePosition.Y <= _rowSplittingTracker.Y1)
                {
                    _rowSplittingTracker.Y1 = Math.Max(MousePosition.Y, layout.GetViewportY(rowViewportIndex) + (layout.GetVerticalSplitBarHeight(rowViewportIndex) / 2.0));
                    break;
                }
                _rowSplittingTracker.Y1 = Math.Min(MousePosition.Y, (layout.GetViewportY(rowViewportIndex + 1) + layout.GetViewportHeight(rowViewportIndex + 1)) - (layout.GetVerticalSplitBarHeight(rowViewportIndex) / 2.0));
                break;

            case HitTestType.RowSplitBox:
                if (MousePosition.Y <= _rowSplittingTracker.Y1)
                {
                    _rowSplittingTracker.Y1 = Math.Max(MousePosition.Y, layout.GetViewportY(rowViewportIndex) + (_defaultSplitBarSize / 2.0));
                    break;
                }
                _rowSplittingTracker.Y1 = Math.Min(MousePosition.Y, (layout.GetViewportY(rowViewportIndex) + layout.GetViewportHeight(rowViewportIndex)) - (_defaultSplitBarSize / 2.0));
                break;
            }
            _rowSplittingTracker.Y2 = _rowSplittingTracker.Y1;
        }
Beispiel #4
0
        void StartRowSplitting()
        {
            if (Workbook.Protect)
            {
                return;
            }

            HitTestInformation savedHitTestInformation = GetHitInfo();
            SheetLayout        layout = GetSheetLayout();

            if (!IsTouching)
            {
                IsRowSplitting = true;
            }
            else
            {
                IsTouchRowSplitting = true;
            }
            IsWorking = true;
            if (_rowSplittingTracker == null)
            {
                // 动态分割线,创建后始终在可视树,通过Opacity控制是否显示
                _rowSplittingTracker        = new Line();
                _rowSplittingTracker.Stroke = BrushRes.BlackBrush;
                _trackersPanel.Children.Add(_rowSplittingTracker);
            }
            int rowViewportIndex = savedHitTestInformation.RowViewportIndex;

            _rowSplittingTracker.Opacity = 0.5;
            switch (savedHitTestInformation.HitTestType)
            {
            case HitTestType.RowSplitBar:
            case HitTestType.ColumnSplitBar:
                _rowSplittingTracker.StrokeThickness = _defaultSplitBarSize;
                _rowSplittingTracker.Y1 = layout.GetVerticalSplitBarY(rowViewportIndex) + (_defaultSplitBarSize / 2.0);
                _rowSplittingTracker.X1 = layout.X;
                _rowSplittingTracker.Y2 = _rowSplittingTracker.Y1;
                _rowSplittingTracker.X2 = layout.X + _availableSize.Width;
                return;

            case HitTestType.RowSplitBox:
                _rowSplittingTracker.StrokeThickness = _defaultSplitBarSize;
                if (RowSplitBoxAlignment == SplitBoxAlignment.Leading)
                {
                    _rowSplittingTracker.Y1 = layout.GetViewportY(rowViewportIndex) + (_defaultSplitBarSize / 2.0);
                }
                else
                {
                    _rowSplittingTracker.Y1 = (layout.GetViewportY(rowViewportIndex) + layout.GetViewportHeight(rowViewportIndex)) - (_defaultSplitBarSize / 2.0);
                }

                _rowSplittingTracker.X1 = layout.X;
                _rowSplittingTracker.Y2 = _rowSplittingTracker.Y1;
                _rowSplittingTracker.X2 = layout.X + _availableSize.Width;
                return;
            }
        }