CPF/CPF.ReoGrid/Views/CellsForegroundView.cs

79 lines
2.9 KiB
C#
Raw Permalink Normal View History

2024-06-24 10:15:59 +08:00
using System;
using CPF.Drawing;
using CPF.ReoGrid.Graphics;
using CPF.ReoGrid.Rendering;
using CPF.ReoGrid.Utility;
namespace CPF.ReoGrid.Views
{
internal class CellsForegroundView : Viewport
{
public CellsForegroundView(IViewportController vc) : base(vc)
{
}
public override IView GetViewByPoint(Point p)
{
return null;
}
public override void Draw(CellDrawingContext dc)
{
Worksheet worksheet = base.ViewportController.Worksheet;
bool flag = worksheet == null || worksheet.controlAdapter == null;
if (!flag)
{
IGraphics graphics = dc.Graphics;
ControlAppearanceStyle controlStyle = worksheet.workbook.controlAdapter.ControlStyle;
switch (worksheet.operationStatus)
{
case OperationStatus.AdjustRowHeight:
{
bool flag2 = worksheet.currentRowHeightChanging >= 0;
if (flag2)
{
RowHeader rowHeader = worksheet.rows[worksheet.currentRowHeightChanging];
float num = (float)rowHeader.Top * this.scaleFactor;
float num2 = ((float)rowHeader.Top + worksheet.headerAdjustNewValue) * this.scaleFactor;
float x = base.ScrollViewLeft * this.scaleFactor;
float x2 = base.ScrollViewLeft * this.scaleFactor + this.Width;
graphics.DrawLine(x, num, x2, num, Color.Black, 1f, LineStyles.Dot);
graphics.DrawLine(x, num2, x2, num2, Color.Black, 1f, LineStyles.Dot);
}
break;
}
case OperationStatus.AdjustColumnWidth:
{
bool flag3 = worksheet.currentColWidthChanging >= 0;
if (flag3)
{
ColumnHeader columnHeader = worksheet.cols[worksheet.currentColWidthChanging];
float num3 = (float)columnHeader.Left * this.scaleFactor;
float num4 = ((float)columnHeader.Left + worksheet.headerAdjustNewValue) * this.scaleFactor;
float y = base.ScrollViewTop * this.scaleFactor;
float y2 = base.ScrollViewTop * this.scaleFactor + this.Height;
graphics.DrawLine(num3, y, num3, y2, Color.Black, 1f, LineStyles.Dot);
graphics.DrawLine(num4, y, num4, y2, Color.Black, 1f, LineStyles.Dot);
}
break;
}
case OperationStatus.DragSelectionFillSerial:
case OperationStatus.SelectionRangeMove:
case OperationStatus.SelectionRangeMovePrepare:
{
bool flag4 = worksheet.draggingSelectionRange != RangePosition.Empty && dc.DrawMode == DrawMode.View && worksheet.HasSettings(WorksheetSettings.Edit_DragSelectionToMoveCells);
if (flag4)
{
Rect scaledAndClippedRangeRect = CellsViewport.GetScaledAndClippedRangeRect(this, worksheet.draggingSelectionRange.StartPos, worksheet.draggingSelectionRange.EndPos, controlStyle.SelectionBorderWidth);
scaledAndClippedRangeRect.Offset(-1f, -1f);
Color color = controlStyle.Colors[ControlAppearanceColors.SelectionBorder];
dc.Graphics.DrawRectangle(scaledAndClippedRangeRect, ColorUtility.FromAlphaColor(byte.MaxValue, color), controlStyle.SelectionBorderWidth, LineStyles.Solid);
}
break;
}
}
}
}
}
}