コード例 #1
0
        void StartColumnSplitting()
        {
            if (Workbook.Protect)
            {
                return;
            }

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

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

            _columnSplittingTracker.Opacity = 0.5;
            switch (savedHitTestInformation.HitTestType)
            {
            case HitTestType.RowSplitBar:
            case HitTestType.ColumnSplitBar:
                _columnSplittingTracker.StrokeThickness = _defaultSplitBarSize;
                _columnSplittingTracker.X1 = layout.GetHorizontalSplitBarX(columnViewportIndex) + (_defaultSplitBarSize / 2.0);
                _columnSplittingTracker.Y1 = layout.Y;
                _columnSplittingTracker.X2 = _columnSplittingTracker.X1;
                _columnSplittingTracker.Y2 = layout.HeaderY + _availableSize.Height;
                return;

            case HitTestType.RowSplitBox:
                return;

            case HitTestType.ColumnSplitBox:
                _columnSplittingTracker.StrokeThickness = _defaultSplitBarSize;
                if (ColumnSplitBoxAlignment == SplitBoxAlignment.Leading)
                {
                    _columnSplittingTracker.X1 = layout.GetViewportX(columnViewportIndex) + (_defaultSplitBarSize / 2.0);
                }
                else
                {
                    _columnSplittingTracker.X1 = (layout.GetViewportX(columnViewportIndex) + layout.GetViewportWidth(columnViewportIndex)) - (_defaultSplitBarSize / 2.0);
                }

                _columnSplittingTracker.Y1 = layout.Y;
                _columnSplittingTracker.X2 = _columnSplittingTracker.X1;
                _columnSplittingTracker.Y2 = layout.HeaderY + _availableSize.Height;
                return;
            }
        }
コード例 #2
0
        void ContinueColumnSplitting()
        {
            HitTestInformation savedHitTestInformation = GetHitInfo();
            SheetLayout        layout = GetSheetLayout();
            int columnViewportIndex   = savedHitTestInformation.ColumnViewportIndex;

            switch (savedHitTestInformation.HitTestType)
            {
            case HitTestType.RowSplitBar:
            case HitTestType.ColumnSplitBar:
                if (MousePosition.X <= _columnSplittingTracker.X1)
                {
                    _columnSplittingTracker.X1 = Math.Max(MousePosition.X, layout.GetViewportX(columnViewportIndex) + (layout.GetHorizontalSplitBarWidth(columnViewportIndex) / 2.0));
                    break;
                }
                _columnSplittingTracker.X1 = Math.Min(MousePosition.X, (layout.GetViewportX(columnViewportIndex + 1) + layout.GetViewportWidth(columnViewportIndex + 1)) - (layout.GetHorizontalSplitBarWidth(columnViewportIndex) / 2.0));
                break;

            case HitTestType.ColumnSplitBox:
                if (MousePosition.X <= _columnSplittingTracker.X1)
                {
                    _columnSplittingTracker.X1 = Math.Max(MousePosition.X, layout.GetViewportX(columnViewportIndex) + (_defaultSplitBarSize / 2.0));
                    break;
                }
                _columnSplittingTracker.X1 = Math.Min(MousePosition.X, (layout.GetViewportX(columnViewportIndex) + layout.GetViewportWidth(columnViewportIndex)) - (_defaultSplitBarSize / 2.0));
                break;
            }
            _columnSplittingTracker.X2 = _columnSplittingTracker.X1;
        }
コード例 #3
0
        void EndColumnSplitting()
        {
            double             num2;
            HitTestInformation savedHitTestInformation = GetHitInfo();
            SheetLayout        layout = GetSheetLayout();
            int columnViewportIndex   = savedHitTestInformation.ColumnViewportIndex;

            IsWorking = false;
            IsTouchColumnSplitting = false;
            IsColumnSplitting      = false;
            switch (savedHitTestInformation.HitTestType)
            {
            case HitTestType.RowSplitBar:
            case HitTestType.ColumnSplitBar:
                if (MousePosition.X <= layout.GetHorizontalSplitBarX(savedHitTestInformation.ColumnViewportIndex))
                {
                    num2 = layout.GetHorizontalSplitBarX(savedHitTestInformation.ColumnViewportIndex) - MousePosition.X;
                }
                else
                {
                    num2 = Math.Max((double)0.0, (double)((MousePosition.X - layout.GetHorizontalSplitBarX(savedHitTestInformation.ColumnViewportIndex)) - layout.GetHorizontalSplitBarWidth(savedHitTestInformation.ColumnViewportIndex)));
                }
                if (num2 != 0.0)
                {
                    double deltaViewportWidth = (_columnSplittingTracker.X1 - layout.GetHorizontalSplitBarX(savedHitTestInformation.ColumnViewportIndex)) - (layout.GetHorizontalSplitBarWidth(savedHitTestInformation.ColumnViewportIndex) / 2.0);
                    int    viewportIndex      = savedHitTestInformation.ColumnViewportIndex;
                    if (!RaiseColumnViewportWidthChanging(viewportIndex, deltaViewportWidth))
                    {
                        AdjustColumnViewport(columnViewportIndex, deltaViewportWidth);
                        RaiseColumnViewportWidthChanged(viewportIndex, deltaViewportWidth);
                    }
                }
                break;

            case HitTestType.ColumnSplitBox:
                if (ColumnSplitBoxAlignment == SplitBoxAlignment.Leading)
                {
                    num2 = Math.Max(0.0, MousePosition.X - layout.GetViewportX(savedHitTestInformation.ColumnViewportIndex) - _defaultSplitBarSize);
                }
                else
                {
                    num2 = Math.Max(0.0, layout.GetViewportX(savedHitTestInformation.ColumnViewportIndex) + layout.GetViewportWidth(savedHitTestInformation.ColumnViewportIndex) - MousePosition.X - _defaultSplitBarSize);
                }

                if (num2 > 0.0)
                {
                    double num3 = (_columnSplittingTracker.X1 - layout.GetViewportX(columnViewportIndex)) - (_defaultSplitBarSize / 2.0);
                    int    num4 = (ColumnSplitBoxAlignment == SplitBoxAlignment.Leading) ? 0 : (GetViewportInfo().ColumnViewportCount - 1);
                    if (!RaiseColumnViewportWidthChanging(num4, num3))
                    {
                        AddColumnViewport(columnViewportIndex, num3);
                        RaiseColumnViewportWidthChanged(num4, num3);
                        ShowCell(GetActiveRowViewportIndex(), GetActiveColumnViewportIndex(), ActiveSheet.ActiveRowIndex, ActiveSheet.ActiveColumnIndex, VerticalPosition.Nearest, HorizontalPosition.Nearest);
                    }
                }
                break;

            default:
                break;
            }
            _columnSplittingTracker.Opacity = 0.0;
        }