1771 lines
60 KiB
C#
1771 lines
60 KiB
C#
![]() |
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Diagnostics;
|
|||
|
using CPF.Drawing;
|
|||
|
using CPF.Input;
|
|||
|
using CPF.ReoGrid.Actions;
|
|||
|
using CPF.ReoGrid.Common;
|
|||
|
using CPF.ReoGrid.Core;
|
|||
|
using CPF.ReoGrid.Data;
|
|||
|
using CPF.ReoGrid.Drawing;
|
|||
|
using CPF.ReoGrid.Events;
|
|||
|
using CPF.ReoGrid.Graphics;
|
|||
|
using CPF.ReoGrid.Interaction;
|
|||
|
using CPF.ReoGrid.Rendering;
|
|||
|
using CPF.ReoGrid.Utility;
|
|||
|
|
|||
|
namespace CPF.ReoGrid.Views
|
|||
|
{
|
|||
|
internal class CellsViewport : Viewport, IRangeSelectableView, IViewport, IView, IUserVisual
|
|||
|
{
|
|||
|
public CellsViewport(IViewportController vc) : base(vc)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public override void DrawView(CellDrawingContext dc)
|
|||
|
{
|
|||
|
bool flag = this.sheet.rows.Count <= 0 || this.sheet.cols.Count < 0;
|
|||
|
if (!flag)
|
|||
|
{
|
|||
|
bool flag2 = (this.sheet.HasSettings(WorksheetSettings.View_ShowGridLine) && dc.DrawMode == DrawMode.View && this.scaleFactor >= 0.4f) || ((dc.DrawMode == DrawMode.Print || dc.DrawMode == DrawMode.Preview) && this.sheet.PrintSettings != null && this.sheet.PrintSettings.ShowGridLines);
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
this.DrawGuideLines(dc);
|
|||
|
}
|
|||
|
this.DrawContent(dc);
|
|||
|
this.DrawSelection(dc);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
internal void DrawContent(CellDrawingContext dc)
|
|||
|
{
|
|||
|
int num = this.visibleRegion.endRow + (dc.FullCellClip ? 0 : 1);
|
|||
|
int num2 = this.visibleRegion.endCol + (dc.FullCellClip ? 0 : 1);
|
|||
|
List<Cell> list = new List<Cell>(5);
|
|||
|
for (int i = this.visibleRegion.startRow; i < num; i++)
|
|||
|
{
|
|||
|
RowHeader rowHeader = this.sheet.rows[i];
|
|||
|
bool flag = rowHeader.InnerHeight <= 0;
|
|||
|
if (!flag)
|
|||
|
{
|
|||
|
int j = this.visibleRegion.startCol;
|
|||
|
while (j < num2)
|
|||
|
{
|
|||
|
Cell cell = this.sheet.cells[i, j];
|
|||
|
bool flag2 = cell == null;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
this.DrawCellBackground(dc, i, j, cell, false);
|
|||
|
j++;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag3 = string.IsNullOrEmpty(cell.DisplayText);
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
bool flag4 = cell.Rowspan == 1 && cell.Colspan == 1;
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
this.DrawCellBackground(dc, i, j, cell, false);
|
|||
|
j++;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag5 = cell.IsStartMergedCell || (cell.IsEndMergedCell && !this.visibleRegion.Contains(cell.MergeStartPos));
|
|||
|
if (flag5)
|
|||
|
{
|
|||
|
this.DrawCellBackground(dc, cell.MergeStartPos.Row, cell.MergeStartPos.Col, this.sheet.GetCell(cell.MergeStartPos), false);
|
|||
|
Debug.Assert(cell.MergeEndPos.Col >= j);
|
|||
|
j = cell.MergeEndPos.Col + 1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag6 = cell.Rowspan == 0 || (cell.Colspan == 0 && ((cell.MergeStartPos.Row < this.visibleRegion.startRow && cell.MergeEndPos.Row > this.visibleRegion.endRow) || (cell.MergeStartPos.Col < this.visibleRegion.startCol && cell.MergeEndPos.Col > this.visibleRegion.endCol)));
|
|||
|
if (flag6)
|
|||
|
{
|
|||
|
Cell cell2 = this.sheet.GetCell(cell.MergeStartPos);
|
|||
|
bool flag7 = !list.Contains(cell2);
|
|||
|
if (flag7)
|
|||
|
{
|
|||
|
this.DrawCellBackground(dc, cell2.Row, cell2.Column, cell2, false);
|
|||
|
list.Add(cell2);
|
|||
|
}
|
|||
|
Debug.Assert(cell.MergeEndPos.Col >= j);
|
|||
|
j = cell.MergeEndPos.Col + 1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
j++;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
j++;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
list.Clear();
|
|||
|
int num3 = this.visibleRegion.startRow;
|
|||
|
while (num3 < num && num3 <= this.sheet.cells.MaxRow)
|
|||
|
{
|
|||
|
RowHeader rowHeader2 = this.sheet.rows[num3];
|
|||
|
bool flag8 = rowHeader2.InnerHeight <= 0;
|
|||
|
if (!flag8)
|
|||
|
{
|
|||
|
int num4 = this.visibleRegion.startCol;
|
|||
|
while (num4 < num2 && num4 <= this.sheet.cells.MaxCol)
|
|||
|
{
|
|||
|
Cell cell3 = this.sheet.cells[num3, num4];
|
|||
|
bool flag9 = cell3 != null && cell3.Width > 1f && cell3.Height > 1f;
|
|||
|
if (flag9)
|
|||
|
{
|
|||
|
bool flag10 = !string.IsNullOrEmpty(cell3.DisplayText) || cell3.body != null;
|
|||
|
bool flag11 = cell3.Rowspan == 1 && cell3.Colspan == 1 && flag10;
|
|||
|
if (flag11)
|
|||
|
{
|
|||
|
this.DrawCell(dc, cell3);
|
|||
|
num4++;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag12 = cell3.IsStartMergedCell && flag10;
|
|||
|
if (flag12)
|
|||
|
{
|
|||
|
this.DrawCell(dc, cell3);
|
|||
|
num4 = cell3.MergeEndPos.Col + 1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag13 = cell3.IsEndMergedCell && !this.visibleRegion.Contains(cell3.MergeStartPos);
|
|||
|
if (flag13)
|
|||
|
{
|
|||
|
Cell cell4 = this.sheet.GetCell(cell3.MergeStartPos);
|
|||
|
bool flag14 = !string.IsNullOrEmpty(cell4.DisplayText) || cell4.body != null;
|
|||
|
if (flag14)
|
|||
|
{
|
|||
|
this.DrawCell(dc, this.sheet.GetCell(cell3.MergeStartPos));
|
|||
|
}
|
|||
|
num4 = cell3.MergeEndPos.Col + 1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag15 = (cell3.MergeStartPos.Row < this.visibleRegion.startRow && cell3.MergeEndPos.Row > this.visibleRegion.endRow) || (cell3.MergeStartPos.Col < this.visibleRegion.startCol && cell3.MergeEndPos.Col > this.visibleRegion.endCol);
|
|||
|
if (flag15)
|
|||
|
{
|
|||
|
Cell cell5 = this.sheet.GetCell(cell3.MergeStartPos);
|
|||
|
bool flag16 = !list.Contains(cell5);
|
|||
|
if (flag16)
|
|||
|
{
|
|||
|
bool flag17 = !string.IsNullOrEmpty(cell5.DisplayText) || cell5.body != null;
|
|||
|
if (flag17)
|
|||
|
{
|
|||
|
this.DrawCell(dc, cell5);
|
|||
|
}
|
|||
|
list.Add(cell5);
|
|||
|
}
|
|||
|
num4 = cell3.MergeEndPos.Col + 1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
num4++;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
num4++;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
num3++;
|
|||
|
}
|
|||
|
Stopwatch stopwatch = new Stopwatch();
|
|||
|
stopwatch.Reset();
|
|||
|
stopwatch.Start();
|
|||
|
int num5 = this.visibleRegion.endCol + (dc.FullCellClip ? 0 : 1);
|
|||
|
int k = this.visibleRegion.startCol;
|
|||
|
while (k <= num5)
|
|||
|
{
|
|||
|
int num6 = (k == this.sheet.cols.Count) ? this.sheet.cols[k - 1].Right : this.sheet.cols[k].Left;
|
|||
|
bool flag18 = k < this.sheet.cols.Count;
|
|||
|
if (!flag18)
|
|||
|
{
|
|||
|
goto IL_6EC;
|
|||
|
}
|
|||
|
ColumnHeader columnHeader = this.sheet.cols[k];
|
|||
|
bool flag19 = !columnHeader.IsVisible;
|
|||
|
if (!flag19)
|
|||
|
{
|
|||
|
goto IL_6EC;
|
|||
|
}
|
|||
|
IL_867:
|
|||
|
k++;
|
|||
|
continue;
|
|||
|
IL_6EC:
|
|||
|
int l = this.visibleRegion.startRow;
|
|||
|
while (l <= this.visibleRegion.endRow)
|
|||
|
{
|
|||
|
int num7 = (l == this.sheet.rows.Count) ? this.sheet.rows[l - 1].Bottom : this.sheet.rows[l].Top;
|
|||
|
ReoGridVBorder reoGridVBorder = this.sheet.vBorders[l, k];
|
|||
|
bool flag20 = reoGridVBorder != null && reoGridVBorder.Span > 0 && reoGridVBorder.Style != null;
|
|||
|
if (flag20)
|
|||
|
{
|
|||
|
int num8 = l + Math.Min(reoGridVBorder.Span - 1, this.visibleRegion.endRow);
|
|||
|
bool flag21 = dc.FullCellClip && num8 >= this.visibleRegion.endRow - 1;
|
|||
|
if (flag21)
|
|||
|
{
|
|||
|
num8 = this.visibleRegion.endRow - 1;
|
|||
|
}
|
|||
|
int bottom = this.sheet.rows[num8].Bottom;
|
|||
|
BorderPainter.Instance.DrawLine(dc.Graphics.PlatformGraphics, (float)num6 * this.scaleFactor, (float)num7 * this.scaleFactor, (float)num6 * this.scaleFactor, (float)bottom * this.scaleFactor, reoGridVBorder.Style);
|
|||
|
l += reoGridVBorder.Span;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
l++;
|
|||
|
}
|
|||
|
}
|
|||
|
goto IL_867;
|
|||
|
}
|
|||
|
int num9 = this.visibleRegion.endRow + (dc.FullCellClip ? 0 : 1);
|
|||
|
int m = this.visibleRegion.startRow;
|
|||
|
while (m <= num9)
|
|||
|
{
|
|||
|
bool flag22 = m < this.sheet.rows.Count;
|
|||
|
if (!flag22)
|
|||
|
{
|
|||
|
goto IL_8F1;
|
|||
|
}
|
|||
|
RowHeader rowHeader3 = this.sheet.rows[m];
|
|||
|
bool flag23 = !rowHeader3.IsVisible;
|
|||
|
if (!flag23)
|
|||
|
{
|
|||
|
goto IL_8F1;
|
|||
|
}
|
|||
|
IL_AB4:
|
|||
|
m++;
|
|||
|
continue;
|
|||
|
IL_8F1:
|
|||
|
int num10 = (m == this.sheet.rows.Count) ? this.sheet.rows[m - 1].Bottom : this.sheet.rows[m].Top;
|
|||
|
int n = this.visibleRegion.startCol;
|
|||
|
while (n <= this.visibleRegion.endCol)
|
|||
|
{
|
|||
|
int num11 = (n == this.sheet.cols.Count) ? this.sheet.cols[n - 1].Right : this.sheet.cols[n].Left;
|
|||
|
ReoGridHBorder reoGridHBorder = this.sheet.hBorders[m, n];
|
|||
|
bool flag24 = reoGridHBorder != null && reoGridHBorder.Span > 0 && reoGridHBorder.Style != null;
|
|||
|
if (flag24)
|
|||
|
{
|
|||
|
int num12 = n + Math.Min(reoGridHBorder.Span - 1, this.visibleRegion.endCol);
|
|||
|
bool flag25 = dc.FullCellClip && num12 >= this.visibleRegion.endCol - 1;
|
|||
|
if (flag25)
|
|||
|
{
|
|||
|
num12 = this.visibleRegion.endCol - 1;
|
|||
|
}
|
|||
|
int right = this.sheet.cols[num12].Right;
|
|||
|
BorderPainter.Instance.DrawLine(dc.Graphics.PlatformGraphics, (float)num11 * this.scaleFactor, (float)num10 * this.scaleFactor, (float)right * this.scaleFactor, (float)num10 * this.scaleFactor, reoGridHBorder.Style);
|
|||
|
n += reoGridHBorder.Span;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
n++;
|
|||
|
}
|
|||
|
}
|
|||
|
goto IL_AB4;
|
|||
|
}
|
|||
|
stopwatch.Stop();
|
|||
|
bool flag26 = stopwatch.ElapsedMilliseconds > 1000L;
|
|||
|
if (flag26)
|
|||
|
{
|
|||
|
Debug.WriteLine(string.Format("draw border ({0} ms.)", stopwatch.ElapsedMilliseconds));
|
|||
|
}
|
|||
|
bool flag27 = dc.DrawMode == DrawMode.View;
|
|||
|
if (flag27)
|
|||
|
{
|
|||
|
bool flag28 = this.sheet.HasSettings(WorksheetSettings.View_ShowPageBreaks) && this.sheet.pageBreakRows != null && this.sheet.pageBreakCols != null && this.sheet.pageBreakRows.Count > 0 && this.sheet.pageBreakCols.Count > 0;
|
|||
|
if (flag28)
|
|||
|
{
|
|||
|
float val = (float)this.sheet.cols[this.sheet.pageBreakCols[0]].Left * this.scaleFactor;
|
|||
|
float val2 = (float)this.sheet.rows[this.sheet.pageBreakRows[0]].Top * this.scaleFactor;
|
|||
|
float val3 = (float)this.sheet.cols[this.sheet.pageBreakCols[this.sheet.pageBreakCols.Count - 1] - 1].Right * this.scaleFactor;
|
|||
|
float val4 = (float)this.sheet.rows[this.sheet.pageBreakRows[this.sheet.pageBreakRows.Count - 1] - 1].Bottom * this.scaleFactor;
|
|||
|
foreach (int num13 in this.sheet.pageBreakRows)
|
|||
|
{
|
|||
|
float num14 = (float)((num13 >= this.sheet.rows.Count) ? this.sheet.rows[num13 - 1].Bottom : this.sheet.rows[num13].Top) * this.scaleFactor;
|
|||
|
bool flag29 = this.sheet.userPageBreakRows != null && this.sheet.userPageBreakRows.Contains(num13);
|
|||
|
dc.Graphics.DrawLine(Math.Max(base.ScrollViewLeft * this.scaleFactor, val), num14, Math.Min(base.ScrollViewLeft * this.scaleFactor + this.bounds.Width, val3), num14, Color.Blue, 2f, flag29 ? LineStyles.Solid : LineStyles.Dash);
|
|||
|
}
|
|||
|
foreach (int num15 in this.sheet.pageBreakCols)
|
|||
|
{
|
|||
|
float num16 = (float)((num15 >= this.sheet.cols.Count) ? this.sheet.cols[num15 - 1].Right : this.sheet.cols[num15].Left) * this.scaleFactor;
|
|||
|
bool flag30 = this.sheet.userPageBreakCols != null && this.sheet.userPageBreakCols.Contains(num15);
|
|||
|
dc.Graphics.DrawLine(num16, Math.Max(base.ScrollViewTop * this.scaleFactor, val2), num16, Math.Min(base.ScrollViewTop * this.scaleFactor + this.bounds.Height, val4), Color.Blue, 2f, flag30 ? LineStyles.Solid : LineStyles.Dash);
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag31 = this.sheet.pageBreakAdjustCol > -1 && this.sheet.pageBreakAdjustFocusIndex > -1;
|
|||
|
if (flag31)
|
|||
|
{
|
|||
|
bool flag32 = this.sheet.pageBreakAdjustFocusIndex < this.sheet.cols.Count;
|
|||
|
float num17;
|
|||
|
if (flag32)
|
|||
|
{
|
|||
|
num17 = (float)this.sheet.cols[this.sheet.pageBreakAdjustFocusIndex].Left;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
num17 = (float)this.sheet.cols[this.sheet.cols.Count - 1].Right;
|
|||
|
}
|
|||
|
num17 *= this.scaleFactor;
|
|||
|
dc.Graphics.FillRectangle(HatchStyles.Percent50, Color.Gray, Color.Transparent, num17 - 1f, base.ScrollViewTop * this.scaleFactor, 3f, base.ScrollViewTop + this.Height);
|
|||
|
}
|
|||
|
bool flag33 = this.sheet.pageBreakAdjustRow > -1 && this.sheet.pageBreakAdjustFocusIndex > -1;
|
|||
|
if (flag33)
|
|||
|
{
|
|||
|
bool flag34 = this.sheet.pageBreakAdjustFocusIndex < this.sheet.rows.Count;
|
|||
|
float num18;
|
|||
|
if (flag34)
|
|||
|
{
|
|||
|
num18 = (float)this.sheet.rows[this.sheet.pageBreakAdjustFocusIndex].Top;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
num18 = (float)this.sheet.rows[this.sheet.rows.Count - 1].Bottom;
|
|||
|
}
|
|||
|
num18 *= this.scaleFactor;
|
|||
|
dc.Graphics.FillRectangle(HatchStyles.Percent50, Color.Gray, Color.Transparent, base.ScrollViewLeft * this.scaleFactor, num18 - 1f, base.ScrollViewLeft + this.Width, 3f);
|
|||
|
}
|
|||
|
bool flag35 = this.sheet.highlightRanges != null;
|
|||
|
if (flag35)
|
|||
|
{
|
|||
|
foreach (HighlightRange highlightRange in this.sheet.highlightRanges)
|
|||
|
{
|
|||
|
bool flag36 = highlightRange.HighlightColor.A > 0 && this.visibleRegion.IsOverlay(highlightRange);
|
|||
|
if (flag36)
|
|||
|
{
|
|||
|
this.DrawHighlightRange(dc, highlightRange);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
HighlightRange focusHighlightRange = this.sheet.focusHighlightRange;
|
|||
|
bool flag37 = focusHighlightRange != null && focusHighlightRange.HighlightColor.A > 0 && this.visibleRegion.IsOverlay(focusHighlightRange);
|
|||
|
if (flag37)
|
|||
|
{
|
|||
|
Rect scaledAndClippedRangeRect = CellsViewport.GetScaledAndClippedRangeRect(this, focusHighlightRange.StartPos, focusHighlightRange.EndPos, 1f);
|
|||
|
scaledAndClippedRangeRect.Inflate(-1f, -1f);
|
|||
|
dc.Renderer.DrawRunningFocusRect(scaledAndClippedRangeRect.X, scaledAndClippedRangeRect.Y, scaledAndClippedRangeRect.Right, scaledAndClippedRangeRect.Bottom, focusHighlightRange.HighlightColor, focusHighlightRange.RunnerOffset);
|
|||
|
focusHighlightRange.RunnerOffset += 2;
|
|||
|
bool flag38 = focusHighlightRange.RunnerOffset > 9;
|
|||
|
if (flag38)
|
|||
|
{
|
|||
|
focusHighlightRange.RunnerOffset = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag39 = this.sheet.traceDependentArrows != null && this.sheet.traceDependentArrows.Count > 0;
|
|||
|
if (flag39)
|
|||
|
{
|
|||
|
IRenderer renderer = dc.Renderer;
|
|||
|
float num19 = 4f * this.scaleFactor;
|
|||
|
float num20 = num19 / 2f + 1f;
|
|||
|
IRenderer renderer2 = renderer;
|
|||
|
LineCapStyles startCap = LineCapStyles.Ellipse;
|
|||
|
float num21 = num19 - 1f;
|
|||
|
float num22 = num19 - 1f;
|
|||
|
renderer2.BeginCappedLine(startCap, new Size(ref num21, ref num22), LineCapStyles.Arrow, new Size(ref num20, ref num19), Color.Blue, 1f);
|
|||
|
foreach (Cell cell6 in this.sheet.traceDependentArrows.Keys)
|
|||
|
{
|
|||
|
List<Cell> list2 = this.sheet.traceDependentArrows[cell6];
|
|||
|
foreach (Cell cell7 in list2)
|
|||
|
{
|
|||
|
bool flag40 = this.visibleRegion.Contains(cell6.InternalPos) && this.visibleRegion.Contains(cell7.InternalPos);
|
|||
|
if (flag40)
|
|||
|
{
|
|||
|
Point scaledTracePoint = this.GetScaledTracePoint(cell6.InternalPos);
|
|||
|
Point scaledTracePoint2 = this.GetScaledTracePoint(cell7.InternalPos);
|
|||
|
renderer.DrawCappedLine(scaledTracePoint.X, scaledTracePoint.Y, scaledTracePoint2.X, scaledTracePoint2.Y);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
renderer.EndCappedLine();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private Point GetScaledTracePoint(CellPosition startPos)
|
|||
|
{
|
|||
|
Rect cellBounds = this.sheet.GetCellBounds(startPos);
|
|||
|
Point location = cellBounds.Location;
|
|||
|
location.X += Math.Min(cellBounds.Width, 30f) / 2f;
|
|||
|
location.Y += Math.Min(cellBounds.Height, 30f) / 2f;
|
|||
|
location.X *= this.scaleFactor;
|
|||
|
location.Y *= this.scaleFactor;
|
|||
|
return location;
|
|||
|
}
|
|||
|
|
|||
|
internal static Rect GetScaledAndClippedRangeRect(IViewport view, CellPosition startPos, CellPosition endPos, float borderWidth)
|
|||
|
{
|
|||
|
Worksheet worksheet = view.ViewportController.Worksheet;
|
|||
|
Rect rangeBounds = worksheet.GetRangeBounds(startPos, endPos);
|
|||
|
RowHeader rowHeader = worksheet.rows[startPos.Row];
|
|||
|
ColumnHeader columnHeader = worksheet.cols[startPos.Col];
|
|||
|
RowHeader rowHeader2 = worksheet.rows[endPos.Row];
|
|||
|
ColumnHeader columnHeader2 = worksheet.cols[endPos.Col];
|
|||
|
int num = columnHeader2.Right - columnHeader.Left;
|
|||
|
int num2 = rowHeader2.Bottom - rowHeader.Top;
|
|||
|
float num3 = (float)columnHeader.Left * view.ScaleFactor;
|
|||
|
float num4 = (float)rowHeader.Top * view.ScaleFactor;
|
|||
|
float num5 = (float)num * view.ScaleFactor;
|
|||
|
float num6 = (float)num2 * view.ScaleFactor;
|
|||
|
Rect scaledRangeRect = new Rect(ref num3, ref num4, ref num5, ref num6);
|
|||
|
return CellsViewport.GetClippedRangeRect(view, scaledRangeRect, borderWidth);
|
|||
|
}
|
|||
|
|
|||
|
private static Rect GetClippedRangeRect(IViewport view, Rect scaledRangeRect, float borderWidth)
|
|||
|
{
|
|||
|
float num = view.ScrollViewTop * view.ScaleFactor;
|
|||
|
float num2 = view.ScrollViewLeft * view.ScaleFactor;
|
|||
|
float num3 = view.Height + num + borderWidth;
|
|||
|
float num4 = view.Width + num2 + borderWidth;
|
|||
|
bool flag = scaledRangeRect.Y < num - borderWidth;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
float num5 = scaledRangeRect.Height - num + scaledRangeRect.Y + borderWidth;
|
|||
|
bool flag2 = num5 < 0f;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
num5 = 0f;
|
|||
|
}
|
|||
|
scaledRangeRect.Height = num5;
|
|||
|
scaledRangeRect.Y = num - borderWidth;
|
|||
|
}
|
|||
|
bool flag3 = scaledRangeRect.X < num2 - borderWidth;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
float num6 = scaledRangeRect.Width - num2 + scaledRangeRect.X + borderWidth;
|
|||
|
bool flag4 = num6 < 0f;
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
num6 = 0f;
|
|||
|
}
|
|||
|
scaledRangeRect.Width = num6;
|
|||
|
scaledRangeRect.X = num2 - borderWidth;
|
|||
|
}
|
|||
|
bool flag5 = scaledRangeRect.Bottom > num3;
|
|||
|
if (flag5)
|
|||
|
{
|
|||
|
float num7 = num3 - scaledRangeRect.Y;
|
|||
|
bool flag6 = num7 < 0f;
|
|||
|
if (flag6)
|
|||
|
{
|
|||
|
num7 = 0f;
|
|||
|
}
|
|||
|
scaledRangeRect.Height = num7;
|
|||
|
}
|
|||
|
bool flag7 = scaledRangeRect.Right > num4;
|
|||
|
if (flag7)
|
|||
|
{
|
|||
|
float num8 = num4 - scaledRangeRect.X;
|
|||
|
bool flag8 = num8 < 0f;
|
|||
|
if (flag8)
|
|||
|
{
|
|||
|
num8 = 0f;
|
|||
|
}
|
|||
|
scaledRangeRect.Width = num8;
|
|||
|
}
|
|||
|
return scaledRangeRect;
|
|||
|
}
|
|||
|
|
|||
|
private void DrawHighlightRange(CellDrawingContext dc, HighlightRange range)
|
|||
|
{
|
|||
|
IGraphics graphics = dc.Graphics;
|
|||
|
Color highlightColor = range.HighlightColor;
|
|||
|
float num = range.Hover ? 2f : 1f;
|
|||
|
Rect scaledRangeBounds = this.sheet.GetScaledRangeBounds(range);
|
|||
|
Rect clippedRangeRect = CellsViewport.GetClippedRangeRect(this, scaledRangeBounds, num);
|
|||
|
graphics.DrawRectangle(clippedRangeRect, highlightColor, num, LineStyles.Solid);
|
|||
|
graphics.FillRectangle(scaledRangeBounds.X - 1f, scaledRangeBounds.Y - 1f, 5f, 5f, highlightColor);
|
|||
|
graphics.FillRectangle(scaledRangeBounds.Right - 3f, scaledRangeBounds.Y - 1f, 5f, 5f, highlightColor);
|
|||
|
graphics.FillRectangle(scaledRangeBounds.X - 1f, scaledRangeBounds.Bottom - 3f, 5f, 5f, highlightColor);
|
|||
|
graphics.FillRectangle(scaledRangeBounds.Right - 3f, scaledRangeBounds.Bottom - 3f, 5f, 5f, highlightColor);
|
|||
|
}
|
|||
|
|
|||
|
private void DrawGuideLines(CellDrawingContext dc)
|
|||
|
{
|
|||
|
IRenderer renderer = dc.Renderer;
|
|||
|
int num = this.visibleRegion.endRow + (dc.FullCellClip ? 0 : 1);
|
|||
|
int num2 = this.visibleRegion.endCol + (dc.FullCellClip ? 0 : 1);
|
|||
|
renderer.BeginDrawLine(1f, this.sheet.controlAdapter.ControlStyle.Colors[ControlAppearanceColors.GridLine]);
|
|||
|
for (int i = this.visibleRegion.startRow; i <= num; i++)
|
|||
|
{
|
|||
|
float num3 = (float)((i >= this.sheet.rows.Count) ? this.sheet.rows[this.sheet.rows.Count - 1].Bottom : this.sheet.rows[i].Top);
|
|||
|
float num4 = num3 * this.scaleFactor;
|
|||
|
for (int j = this.visibleRegion.startCol; j < num2; j++)
|
|||
|
{
|
|||
|
int left = this.sheet.cols[j].Left;
|
|||
|
while (j < num2)
|
|||
|
{
|
|||
|
ReoGridHBorder reoGridHBorder = this.sheet.hBorders[i, j];
|
|||
|
bool flag = reoGridHBorder != null && reoGridHBorder.Span >= 0;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
bool flag2 = i > 0;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
Cell cell = this.sheet.cells[i, j];
|
|||
|
bool flag3 = cell != null && cell.InnerStyle.BackColor.A > 0;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
j++;
|
|||
|
}
|
|||
|
int num5 = (j == 0) ? left : this.sheet.cols[j - 1].Right;
|
|||
|
renderer.DrawLine((float)left * this.scaleFactor, num4, (float)num5 * this.scaleFactor, num4);
|
|||
|
}
|
|||
|
}
|
|||
|
for (int k = this.visibleRegion.startCol; k <= num2; k++)
|
|||
|
{
|
|||
|
float num6 = (float)((k == this.sheet.cols.Count) ? this.sheet.cols[k - 1].Right : this.sheet.cols[k].Left);
|
|||
|
float num7 = num6 * this.scaleFactor;
|
|||
|
for (int l = this.visibleRegion.startRow; l < num; l++)
|
|||
|
{
|
|||
|
int top = this.sheet.rows[l].Top;
|
|||
|
while (l < num)
|
|||
|
{
|
|||
|
ReoGridVBorder reoGridVBorder = this.sheet.vBorders[l, k];
|
|||
|
bool flag4 = reoGridVBorder != null && reoGridVBorder.Span >= 0;
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
bool flag5 = k > 0;
|
|||
|
if (flag5)
|
|||
|
{
|
|||
|
Cell cell2 = this.sheet.cells[l, k];
|
|||
|
bool flag6 = cell2 != null && cell2.InnerStyle.BackColor.A > 0;
|
|||
|
if (flag6)
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
l++;
|
|||
|
}
|
|||
|
int num8 = (l == 0) ? top : this.sheet.rows[l - 1].Bottom;
|
|||
|
renderer.DrawLine(num7, (float)top * this.scaleFactor, num7, (float)num8 * this.scaleFactor);
|
|||
|
}
|
|||
|
}
|
|||
|
renderer.EndDrawLine();
|
|||
|
}
|
|||
|
|
|||
|
private void DrawCell(CellDrawingContext dc, Cell cell)
|
|||
|
{
|
|||
|
bool flag = cell == null;
|
|||
|
if (!flag)
|
|||
|
{
|
|||
|
bool flag2 = cell.IsMergedCell && (cell.Width <= 1f || cell.Height <= 1f);
|
|||
|
if (!flag2)
|
|||
|
{
|
|||
|
bool flag3 = cell.body != null;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
dc.Cell = cell;
|
|||
|
IGraphics graphics = dc.Graphics;
|
|||
|
graphics.PushTransform();
|
|||
|
bool flag4 = this.scaleFactor != 1f;
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
graphics.ScaleTransform(this.scaleFactor, this.scaleFactor);
|
|||
|
}
|
|||
|
graphics.TranslateTransform(dc.Cell.Left, dc.Cell.Top);
|
|||
|
cell.body.OnPaint(dc);
|
|||
|
graphics.PopTransform();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag5 = !string.IsNullOrEmpty(cell.DisplayText);
|
|||
|
if (flag5)
|
|||
|
{
|
|||
|
this.DrawCellBackground(dc, cell.InternalRow, cell.InternalCol, cell, false);
|
|||
|
this.DrawCellText(dc, cell);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
internal void DrawCellText(CellDrawingContext dc, Cell cell)
|
|||
|
{
|
|||
|
IGraphics graphics = dc.Graphics;
|
|||
|
RichText richText = cell.Data as RichText;
|
|||
|
bool flag = richText != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
bool flag2 = cell.IsMergedCell || cell.InnerStyle.TextWrapMode == TextWrapMode.WordBreak;
|
|||
|
bool flag3 = !flag2 && dc.AllowCellClip;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
bool flag4 = cell.InternalCol < this.sheet.cols.Count - 1;
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
bool flag5 = cell.RenderHorAlign == ReoGridRenderHorAlign.Left || cell.RenderHorAlign == ReoGridRenderHorAlign.Center;
|
|||
|
if (flag5)
|
|||
|
{
|
|||
|
Cell cell2 = this.sheet.cells[cell.InternalRow, cell.InternalCol + 1];
|
|||
|
flag2 = (cell2 != null && richText.TextSize.Width > cell.Width && !string.IsNullOrEmpty(cell2.DisplayText));
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag6 = !flag2 && cell.InternalCol > 0 && (cell.RenderHorAlign == ReoGridRenderHorAlign.Right || cell.RenderHorAlign == ReoGridRenderHorAlign.Center);
|
|||
|
if (flag6)
|
|||
|
{
|
|||
|
Cell cell3 = this.sheet.cells[cell.InternalRow, cell.InternalCol - 1];
|
|||
|
bool flag7 = cell3 != null && richText.TextSize.Width > cell.Width && !string.IsNullOrEmpty(cell3.DisplayText);
|
|||
|
}
|
|||
|
}
|
|||
|
Rect bounds = cell.Bounds * this.scaleFactor;
|
|||
|
richText.Draw(graphics, bounds);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag8 = !cell.RenderColor.IsTransparent;
|
|||
|
Color textColor;
|
|||
|
if (flag8)
|
|||
|
{
|
|||
|
textColor = cell.RenderColor;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag9 = cell.InnerStyle.HasStyle(PlainStyleFlag.TextColor);
|
|||
|
if (flag9)
|
|||
|
{
|
|||
|
textColor = cell.InnerStyle.TextColor;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag10 = !this.sheet.controlAdapter.ControlStyle.TryGetColor(ControlAppearanceColors.GridText, out textColor);
|
|||
|
if (flag10)
|
|||
|
{
|
|||
|
textColor = Color.Black;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
bool fontDirty = cell.FontDirty;
|
|||
|
if (fontDirty)
|
|||
|
{
|
|||
|
this.sheet.UpdateCellFont(cell, UpdateFontReason.FontChanged);
|
|||
|
}
|
|||
|
float width = cell.Width * this.scaleFactor;
|
|||
|
float num = (float)Math.Floor((double)(cell.Height * this.scaleFactor)) - 1f;
|
|||
|
float num2 = base.ScrollViewLeft * this.scaleFactor;
|
|||
|
float num3 = cell.Top * this.scaleFactor;
|
|||
|
float width2 = this.Width;
|
|||
|
Rect clip = new Rect(ref num2, ref num3, ref width2, ref num);
|
|||
|
bool flag11 = cell.IsMergedCell || cell.InnerStyle.TextWrapMode == TextWrapMode.WordBreak || dc.AllowCellClip;
|
|||
|
bool flag12 = !flag11;
|
|||
|
if (flag12)
|
|||
|
{
|
|||
|
bool flag13 = cell.InternalCol < this.sheet.cols.Count - 1;
|
|||
|
if (flag13)
|
|||
|
{
|
|||
|
bool flag14 = cell.RenderHorAlign == ReoGridRenderHorAlign.Left || cell.RenderHorAlign == ReoGridRenderHorAlign.Center;
|
|||
|
if (flag14)
|
|||
|
{
|
|||
|
Cell cell4 = this.sheet.cells[cell.InternalRow, cell.InternalCol + 1];
|
|||
|
flag11 = (cell4 != null && cell.TextBounds.Right > cell.Right && !string.IsNullOrEmpty(cell4.DisplayText));
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag15 = !flag11 && cell.InternalCol > 0 && (cell.RenderHorAlign == ReoGridRenderHorAlign.Right || cell.RenderHorAlign == ReoGridRenderHorAlign.Center);
|
|||
|
if (flag15)
|
|||
|
{
|
|||
|
Cell cell5 = this.sheet.cells[cell.InternalRow, cell.InternalCol - 1];
|
|||
|
flag11 = (cell5 != null && cell5.TextBounds.Left < cell.Left && !string.IsNullOrEmpty(cell5.DisplayText));
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag16 = flag11;
|
|||
|
if (flag16)
|
|||
|
{
|
|||
|
clip = cell.Bounds;
|
|||
|
clip.X *= this.scaleFactor;
|
|||
|
clip.Y *= this.scaleFactor;
|
|||
|
clip.Width = width;
|
|||
|
clip.Height = num;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
flag11 = (cell.TextBoundsHeight > num);
|
|||
|
}
|
|||
|
bool flag17 = flag11;
|
|||
|
if (flag17)
|
|||
|
{
|
|||
|
graphics.PushClip(clip);
|
|||
|
}
|
|||
|
dc.Renderer.DrawCellText(cell, textColor, dc.DrawMode, this.scaleFactor);
|
|||
|
bool flag18 = flag11;
|
|||
|
if (flag18)
|
|||
|
{
|
|||
|
dc.Graphics.PopClip();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
internal void DrawCellBackground(CellDrawingContext dc, int row, int col, Cell cell, bool refPosition = false)
|
|||
|
{
|
|||
|
bool flag = cell == null;
|
|||
|
WorksheetRangeStyle worksheetRangeStyle;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
StyleParentKind styleParentKind = StyleParentKind.Own;
|
|||
|
worksheetRangeStyle = StyleUtility.FindCellParentStyle(this.sheet, row, col, out styleParentKind);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
worksheetRangeStyle = cell.InnerStyle;
|
|||
|
}
|
|||
|
bool flag2 = worksheetRangeStyle.BackColor.A > 0;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
CellPosition cellPosition = new CellPosition(row, col);
|
|||
|
Rect rect = (cell == null) ? CellsViewport.GetScaledAndClippedRangeRect(this, cellPosition, cellPosition, 1f) : CellsViewport.GetScaledAndClippedRangeRect(this, cellPosition, new CellPosition(row + (int)cell.Rowspan - 1, col + (int)cell.Colspan - 1), 1f);
|
|||
|
bool flag3 = cell != null && refPosition;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
float num = 0f;
|
|||
|
float num2 = 0f;
|
|||
|
rect.Location = new Point(ref num, ref num2);
|
|||
|
}
|
|||
|
bool flag4 = rect.Width > 0f && rect.Height > 0f;
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
IGraphics graphics = dc.Graphics;
|
|||
|
bool flag5 = worksheetRangeStyle.FillPatternColor.A > 0;
|
|||
|
if (flag5)
|
|||
|
{
|
|||
|
graphics.FillRectangle(worksheetRangeStyle.FillPatternStyle, worksheetRangeStyle.FillPatternColor, worksheetRangeStyle.BackColor, rect);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
graphics.FillRectangle(rect, worksheetRangeStyle.BackColor);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void DrawSelection(CellDrawingContext dc)
|
|||
|
{
|
|||
|
bool flag = !this.sheet.SelectionRange.IsEmpty && dc.DrawMode == DrawMode.View && this.sheet.SelectionStyle > WorksheetSelectionStyle.None;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
IGraphics graphics = dc.Graphics;
|
|||
|
ControlAppearanceStyle controlStyle = this.sheet.workbook.controlAdapter.ControlStyle;
|
|||
|
float selectionBorderWidth = controlStyle.SelectionBorderWidth;
|
|||
|
Rect scaledAndClippedRangeRect = CellsViewport.GetScaledAndClippedRangeRect(this, this.sheet.SelectionRange.StartPos, this.sheet.SelectionRange.EndPos, selectionBorderWidth);
|
|||
|
bool flag2 = scaledAndClippedRangeRect.Width > 0f || scaledAndClippedRangeRect.Height > 0f;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
Color color = controlStyle.Colors[ControlAppearanceColors.SelectionFill];
|
|||
|
bool flag3 = this.sheet.SelectionStyle == WorksheetSelectionStyle.Default;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
RangePosition rangeIfMergedCell = this.sheet.GetRangeIfMergedCell(this.sheet.focusPos);
|
|||
|
Rect scaledAndClippedRangeRect2 = CellsViewport.GetScaledAndClippedRangeRect(this, rangeIfMergedCell.StartPos, rangeIfMergedCell.EndPos, 0f);
|
|||
|
Color color2 = controlStyle.Colors[ControlAppearanceColors.SelectionBorder];
|
|||
|
graphics.FillRectangle(scaledAndClippedRangeRect, color);
|
|||
|
bool flag4 = color2.A > 0;
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
graphics.DrawRectangle(scaledAndClippedRangeRect, color2, selectionBorderWidth, LineStyles.Solid);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag5 = this.sheet.SelectionStyle == WorksheetSelectionStyle.FocusRect;
|
|||
|
if (flag5)
|
|||
|
{
|
|||
|
graphics.DrawRectangle(scaledAndClippedRangeRect, Color.Black, 1f, LineStyles.Dot);
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag6 = this.sheet.HasSettings(WorksheetSettings.Edit_DragSelectionToFillSerial);
|
|||
|
if (flag6)
|
|||
|
{
|
|||
|
Color color3 = controlStyle.Colors[ControlAppearanceColors.GridBackground];
|
|||
|
float num = scaledAndClippedRangeRect.Right - selectionBorderWidth;
|
|||
|
float num2 = scaledAndClippedRangeRect.Bottom - selectionBorderWidth;
|
|||
|
float num3 = selectionBorderWidth + 2f;
|
|||
|
float num4 = selectionBorderWidth + 2f;
|
|||
|
Rect rect = new Rect(ref num, ref num2, ref num3, ref num4);
|
|||
|
graphics.DrawRectangle(rect, color3);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public override bool OnMouseDown(Point location, MouseButtons buttons, InputModifiers modifiers)
|
|||
|
{
|
|||
|
bool flag = false;
|
|||
|
bool flag2 = !flag && this.sheet.selectionMode != WorksheetSelectionMode.None && !this.sheet.HasSettings(WorksheetSettings.Edit_Readonly);
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
bool flag3 = !flag && this.sheet.HasSettings(WorksheetSettings.Edit_DragSelectionToFillSerial);
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
bool flag4 = CellsViewport.SelectDragCornerHitTest(this.sheet, location);
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
this.sheet.operationStatus = OperationStatus.DragSelectionFillSerial;
|
|||
|
this.sheet.lastMouseMoving = location;
|
|||
|
this.sheet.draggingSelectionRange = this.sheet.selectionRange;
|
|||
|
this.sheet.focusMovingRangeOffset = this.sheet.selectionRange.EndPos;
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag5 = !flag && this.sheet.HasSettings(WorksheetSettings.Edit_DragSelectionToMoveCells);
|
|||
|
if (flag5)
|
|||
|
{
|
|||
|
Rect rangePhysicsBounds = this.sheet.GetRangePhysicsBounds(this.sheet.selectionRange);
|
|||
|
float num = rangePhysicsBounds.Width;
|
|||
|
rangePhysicsBounds.Width = num - 1f;
|
|||
|
num = rangePhysicsBounds.Height;
|
|||
|
rangePhysicsBounds.Height = num - 1f;
|
|||
|
bool flag6 = GraphicsToolkit.PointOnRectangleBounds(rangePhysicsBounds, location, 2f / this.scaleFactor, 9999999.0);
|
|||
|
if (flag6)
|
|||
|
{
|
|||
|
this.sheet.draggingSelectionRange = this.sheet.selectionRange;
|
|||
|
this.sheet.operationStatus = OperationStatus.SelectionRangeMovePrepare;
|
|||
|
CellPosition posByPoint = CellsViewport.GetPosByPoint(this, location);
|
|||
|
this.sheet.lastMouseMoving.Y = (float)this.sheet.selectionRange.Row;
|
|||
|
this.sheet.lastMouseMoving.X = (float)this.sheet.selectionRange.Col;
|
|||
|
bool flag7 = posByPoint.Row < this.sheet.selectionRange.Row;
|
|||
|
if (flag7)
|
|||
|
{
|
|||
|
posByPoint.Row = this.sheet.selectionRange.Row;
|
|||
|
}
|
|||
|
bool flag8 = posByPoint.Col < this.sheet.selectionRange.Col;
|
|||
|
if (flag8)
|
|||
|
{
|
|||
|
posByPoint.Col = this.sheet.selectionRange.Col;
|
|||
|
}
|
|||
|
bool flag9 = posByPoint.Row > this.sheet.selectionRange.EndRow;
|
|||
|
if (flag9)
|
|||
|
{
|
|||
|
posByPoint.Row = this.sheet.selectionRange.EndRow;
|
|||
|
}
|
|||
|
bool flag10 = posByPoint.Col > this.sheet.selectionRange.EndCol;
|
|||
|
if (flag10)
|
|||
|
{
|
|||
|
posByPoint.Col = this.sheet.selectionRange.EndCol;
|
|||
|
}
|
|||
|
this.sheet.focusMovingRangeOffset.Row = posByPoint.Row - this.sheet.selectionRange.Row;
|
|||
|
this.sheet.focusMovingRangeOffset.Col = posByPoint.Col - this.sheet.selectionRange.Col;
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
this.SetFocus();
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag11 = !flag && this.sheet.HasSettings(WorksheetSettings.Behavior_AllowUserChangingPageBreaks | WorksheetSettings.View_ShowPageBreaks);
|
|||
|
if (flag11)
|
|||
|
{
|
|||
|
int num2 = this.sheet.FindBreakIndexOfColumnByPixel(location);
|
|||
|
bool flag12 = num2 >= 0;
|
|||
|
if (flag12)
|
|||
|
{
|
|||
|
this.sheet.pageBreakAdjustCol = num2;
|
|||
|
this.sheet.pageBreakAdjustFocusIndex = this.sheet.pageBreakCols[num2];
|
|||
|
this.sheet.lastMouseMoving.X = (float)this.sheet.pageBreakAdjustFocusIndex;
|
|||
|
this.sheet.operationStatus = OperationStatus.AdjustPageBreakColumn;
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
this.SetFocus();
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
bool flag13 = !flag;
|
|||
|
if (flag13)
|
|||
|
{
|
|||
|
int num3 = this.sheet.FindBreakIndexOfRowByPixel(location);
|
|||
|
bool flag14 = num3 >= 0;
|
|||
|
if (flag14)
|
|||
|
{
|
|||
|
this.sheet.pageBreakAdjustRow = num3;
|
|||
|
this.sheet.pageBreakAdjustFocusIndex = this.sheet.pageBreakRows[num3];
|
|||
|
this.sheet.lastMouseMoving.Y = (float)this.sheet.pageBreakAdjustFocusIndex;
|
|||
|
this.sheet.operationStatus = OperationStatus.AdjustPageBreakRow;
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
this.SetFocus();
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag15 = !flag;
|
|||
|
if (flag15)
|
|||
|
{
|
|||
|
int rowByPoint = CellsViewport.GetRowByPoint(this, location.Y);
|
|||
|
Debug.Assert(rowByPoint >= 0 && rowByPoint < this.sheet.rows.Count);
|
|||
|
bool flag16 = rowByPoint != -1;
|
|||
|
if (flag16)
|
|||
|
{
|
|||
|
int colByPoint = CellsViewport.GetColByPoint(this, location.X);
|
|||
|
Debug.Assert(colByPoint >= 0 && colByPoint < this.sheet.cols.Count);
|
|||
|
bool flag17 = colByPoint != -1;
|
|||
|
if (flag17)
|
|||
|
{
|
|||
|
CellPosition cellPosition = new CellPosition(rowByPoint, colByPoint);
|
|||
|
Cell cell = this.sheet.cells[rowByPoint, colByPoint];
|
|||
|
bool flag18 = cell != null || this.sheet.HasCellMouseDown;
|
|||
|
if (flag18)
|
|||
|
{
|
|||
|
bool flag19 = cell != null && !cell.IsValidCell;
|
|||
|
if (flag19)
|
|||
|
{
|
|||
|
cell = this.sheet.GetMergedCellOfRange(cell);
|
|||
|
}
|
|||
|
bool flag20 = (cell != null && cell.body != null) || this.sheet.HasCellMouseDown;
|
|||
|
if (flag20)
|
|||
|
{
|
|||
|
Rect cellBounds = this.sheet.GetCellBounds(cellPosition);
|
|||
|
Worksheet sheet = this.sheet;
|
|||
|
Cell cell2 = cell;
|
|||
|
CellPosition cellPosition2 = cellPosition;
|
|||
|
float num = location.X - cellBounds.Left;
|
|||
|
float num4 = location.Y - cellBounds.Top;
|
|||
|
CellMouseEventArgs cellMouseEventArgs = new CellMouseEventArgs(sheet, cell2, cellPosition2, new Point(ref num, ref num4), location, buttons, 1);
|
|||
|
this.sheet.RaiseCellMouseDown(cellMouseEventArgs);
|
|||
|
bool flag21 = cell != null && cell.body != null;
|
|||
|
if (flag21)
|
|||
|
{
|
|||
|
bool flag22 = cell.body.OnMouseDown(cellMouseEventArgs);
|
|||
|
if (flag22)
|
|||
|
{
|
|||
|
flag = true;
|
|||
|
this.sheet.IgnoreMouseDoubleClick = true;
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
bool flag23 = cell.body.AutoCaptureMouse() || cellMouseEventArgs.Capture;
|
|||
|
if (flag23)
|
|||
|
{
|
|||
|
this.SetFocus();
|
|||
|
this.sheet.mouseCapturedCell = cell;
|
|||
|
this.sheet.operationStatus = OperationStatus.CellBodyCapture;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag24 = !flag;
|
|||
|
if (flag24)
|
|||
|
{
|
|||
|
this.SetFocus();
|
|||
|
bool flag25 = this.sheet.selectionMode > WorksheetSelectionMode.None;
|
|||
|
if (flag25)
|
|||
|
{
|
|||
|
bool flag26 = buttons == MouseButtons.Left || !this.sheet.selectionRange.Contains(rowByPoint, colByPoint);
|
|||
|
if (flag26)
|
|||
|
{
|
|||
|
switch (this.sheet.selectionMode)
|
|||
|
{
|
|||
|
case WorksheetSelectionMode.Range:
|
|||
|
this.sheet.operationStatus = OperationStatus.RangeSelect;
|
|||
|
break;
|
|||
|
case WorksheetSelectionMode.Row:
|
|||
|
this.sheet.operationStatus = OperationStatus.FullRowSelect;
|
|||
|
break;
|
|||
|
case WorksheetSelectionMode.Column:
|
|||
|
this.sheet.operationStatus = OperationStatus.FullColumnSelect;
|
|||
|
break;
|
|||
|
case WorksheetSelectionMode.SingleRow:
|
|||
|
this.sheet.operationStatus = OperationStatus.FullSingleRowSelect;
|
|||
|
break;
|
|||
|
case WorksheetSelectionMode.SingleColumn:
|
|||
|
this.sheet.operationStatus = OperationStatus.FullSingleColumnSelect;
|
|||
|
break;
|
|||
|
}
|
|||
|
this.sheet.SelectRangeStartByMouse(this.PointToController(location), modifiers);
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag27 = buttons == MouseButtons.Right;
|
|||
|
if (flag27)
|
|||
|
{
|
|||
|
this.sheet.controlAdapter.ShowContextMenuStrip(ViewTypes.None, this.PointToController(location));
|
|||
|
}
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return flag;
|
|||
|
}
|
|||
|
|
|||
|
public override bool OnMouseMove(Point location, MouseButtons buttons)
|
|||
|
{
|
|||
|
bool flag = false;
|
|||
|
switch (this.sheet.operationStatus)
|
|||
|
{
|
|||
|
case OperationStatus.Default:
|
|||
|
{
|
|||
|
bool flag2 = false;
|
|||
|
bool flag3 = this.sheet.selectionMode != WorksheetSelectionMode.None && !this.sheet.HasSettings(WorksheetSettings.Edit_Readonly);
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
bool flag4 = this.sheet.HasSettings(WorksheetSettings.Edit_DragSelectionToFillSerial);
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
bool flag5 = CellsViewport.SelectDragCornerHitTest(this.sheet, location);
|
|||
|
if (flag5)
|
|||
|
{
|
|||
|
this.sheet.controlAdapter.ChangeCursor(CursorStyle.Cross);
|
|||
|
flag2 = true;
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag6 = !flag && this.sheet.HasSettings(WorksheetSettings.Edit_DragSelectionToMoveCells);
|
|||
|
if (flag6)
|
|||
|
{
|
|||
|
Rect rangePhysicsBounds = this.sheet.GetRangePhysicsBounds(this.sheet.SelectionRange);
|
|||
|
float num = rangePhysicsBounds.Width;
|
|||
|
rangePhysicsBounds.Width = num - 1f;
|
|||
|
num = rangePhysicsBounds.Height;
|
|||
|
rangePhysicsBounds.Height = num - 1f;
|
|||
|
bool flag7 = GraphicsToolkit.PointOnRectangleBounds(rangePhysicsBounds, location, 2f / this.scaleFactor, 9999999.0);
|
|||
|
bool flag8 = flag7;
|
|||
|
if (flag8)
|
|||
|
{
|
|||
|
this.sheet.controlAdapter.ChangeCursor(CursorStyle.Move);
|
|||
|
flag2 = true;
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag9 = !flag && this.sheet.highlightRanges != null;
|
|||
|
if (flag9)
|
|||
|
{
|
|||
|
foreach (HighlightRange highlightRange in this.sheet.highlightRanges)
|
|||
|
{
|
|||
|
Rect rangePhysicsBounds2 = this.sheet.GetRangePhysicsBounds(highlightRange);
|
|||
|
float num = rangePhysicsBounds2.Width;
|
|||
|
rangePhysicsBounds2.Width = num - 1f;
|
|||
|
num = rangePhysicsBounds2.Height;
|
|||
|
rangePhysicsBounds2.Height = num - 1f;
|
|||
|
bool flag10 = GraphicsToolkit.PointOnRectangleBounds(rangePhysicsBounds2, location, 2f, 9999999.0);
|
|||
|
bool flag11 = flag10;
|
|||
|
if (flag11)
|
|||
|
{
|
|||
|
this.sheet.controlAdapter.ChangeCursor(CursorStyle.Move);
|
|||
|
flag2 = true;
|
|||
|
}
|
|||
|
bool flag12 = flag10 != highlightRange.Hover;
|
|||
|
if (flag12)
|
|||
|
{
|
|||
|
highlightRange.Hover = flag10;
|
|||
|
flag = true;
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag13 = !flag && this.sheet.HasSettings(WorksheetSettings.Behavior_AllowUserChangingPageBreaks | WorksheetSettings.View_ShowPageBreaks);
|
|||
|
if (flag13)
|
|||
|
{
|
|||
|
int num2 = this.sheet.FindBreakIndexOfColumnByPixel(location);
|
|||
|
bool flag14 = num2 >= 0;
|
|||
|
if (flag14)
|
|||
|
{
|
|||
|
this.sheet.controlAdapter.ChangeCursor(CursorStyle.ResizeHorizontal);
|
|||
|
flag2 = true;
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
int num3 = this.sheet.FindBreakIndexOfRowByPixel(location);
|
|||
|
bool flag15 = num3 >= 0;
|
|||
|
if (flag15)
|
|||
|
{
|
|||
|
this.sheet.controlAdapter.ChangeCursor(CursorStyle.ResizeVertical);
|
|||
|
flag2 = true;
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag16 = !flag;
|
|||
|
if (flag16)
|
|||
|
{
|
|||
|
CellPosition posByPoint = CellsViewport.GetPosByPoint(this, location);
|
|||
|
bool flag17 = posByPoint != this.sheet.hoverPos;
|
|||
|
if (flag17)
|
|||
|
{
|
|||
|
this.sheet.HoverPos = posByPoint;
|
|||
|
}
|
|||
|
bool flag18 = !this.sheet.hoverPos.IsEmpty;
|
|||
|
if (flag18)
|
|||
|
{
|
|||
|
Cell cell = this.sheet.cells[this.sheet.hoverPos.Row, this.sheet.hoverPos.Col];
|
|||
|
bool flag19 = cell != null || this.sheet.HasCellMouseMove;
|
|||
|
if (flag19)
|
|||
|
{
|
|||
|
bool flag20 = cell != null && !cell.IsValidCell;
|
|||
|
if (flag20)
|
|||
|
{
|
|||
|
cell = this.sheet.GetMergedCellOfRange(cell);
|
|||
|
}
|
|||
|
bool flag21 = (cell != null && cell.body != null) || this.sheet.HasCellMouseMove;
|
|||
|
if (flag21)
|
|||
|
{
|
|||
|
Rect cellBounds = this.sheet.GetCellBounds(this.sheet.hoverPos);
|
|||
|
Worksheet sheet = this.sheet;
|
|||
|
Cell cell2 = cell;
|
|||
|
CellPosition hoverPos = this.sheet.hoverPos;
|
|||
|
float num = location.X - cellBounds.Left;
|
|||
|
float num4 = location.Y - cellBounds.Top;
|
|||
|
CellMouseEventArgs cellMouseEventArgs = new CellMouseEventArgs(sheet, cell2, hoverPos, new Point(ref num, ref num4), location, buttons, 1);
|
|||
|
this.sheet.RaiseCellMouseMove(cellMouseEventArgs);
|
|||
|
bool flag22 = cell != null && cell.body != null;
|
|||
|
if (flag22)
|
|||
|
{
|
|||
|
cell.body.OnMouseMove(cellMouseEventArgs);
|
|||
|
}
|
|||
|
bool flag23 = cellMouseEventArgs.CursorStyle > CursorStyle.PlatformDefault;
|
|||
|
if (flag23)
|
|||
|
{
|
|||
|
flag2 = true;
|
|||
|
this.sheet.controlAdapter.ChangeCursor(cellMouseEventArgs.CursorStyle);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag24 = !flag2;
|
|||
|
if (flag24)
|
|||
|
{
|
|||
|
this.sheet.controlAdapter.ChangeCursor(CursorStyle.Selection);
|
|||
|
}
|
|||
|
}
|
|||
|
return flag;
|
|||
|
}
|
|||
|
case OperationStatus.RangeSelect:
|
|||
|
case OperationStatus.FullRowSelect:
|
|||
|
case OperationStatus.FullColumnSelect:
|
|||
|
{
|
|||
|
bool flag25 = buttons == MouseButtons.Left;
|
|||
|
if (flag25)
|
|||
|
{
|
|||
|
Point location2 = this.PointToController(location);
|
|||
|
this.sheet.SelectRangeEndByMouse(location2);
|
|||
|
}
|
|||
|
return flag;
|
|||
|
}
|
|||
|
case OperationStatus.AdjustRowHeight:
|
|||
|
case OperationStatus.AdjustColumnWidth:
|
|||
|
return flag;
|
|||
|
case OperationStatus.DragSelectionFillSerial:
|
|||
|
{
|
|||
|
CellPosition posByPoint2 = CellsViewport.GetPosByPoint(this, location);
|
|||
|
bool flag26 = this.sheet.focusMovingRangeOffset != posByPoint2;
|
|||
|
if (flag26)
|
|||
|
{
|
|||
|
this.sheet.focusMovingRangeOffset = posByPoint2;
|
|||
|
int num5 = Math.Min(this.sheet.selectionRange.Row, posByPoint2.Row);
|
|||
|
int num6 = Math.Min(this.sheet.selectionRange.Col, posByPoint2.Col);
|
|||
|
int num7 = Math.Max(this.sheet.selectionRange.EndRow, posByPoint2.Row);
|
|||
|
int num8 = Math.Max(this.sheet.selectionRange.EndCol, posByPoint2.Col);
|
|||
|
Rect rangePhysicsBounds3 = this.sheet.GetRangePhysicsBounds(this.sheet.selectionRange);
|
|||
|
bool flag27 = true;
|
|||
|
bool flag28 = location.X <= rangePhysicsBounds3.X;
|
|||
|
if (flag28)
|
|||
|
{
|
|||
|
bool flag29 = location.Y < rangePhysicsBounds3.Y;
|
|||
|
if (flag29)
|
|||
|
{
|
|||
|
flag27 = (Math.Abs(rangePhysicsBounds3.X - location.X) > Math.Abs(rangePhysicsBounds3.Y - location.Y));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag30 = location.Y > rangePhysicsBounds3.Bottom;
|
|||
|
if (flag30)
|
|||
|
{
|
|||
|
flag27 = (Math.Abs(rangePhysicsBounds3.X - location.X) > Math.Abs(rangePhysicsBounds3.Bottom - location.Y));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag31 = location.X >= rangePhysicsBounds3.Right;
|
|||
|
if (flag31)
|
|||
|
{
|
|||
|
bool flag32 = location.Y < rangePhysicsBounds3.Y;
|
|||
|
if (flag32)
|
|||
|
{
|
|||
|
flag27 = (Math.Abs(rangePhysicsBounds3.Right - location.X) > Math.Abs(rangePhysicsBounds3.Y - location.Y));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag33 = location.Y > rangePhysicsBounds3.Bottom;
|
|||
|
if (flag33)
|
|||
|
{
|
|||
|
flag27 = (Math.Abs(rangePhysicsBounds3.Right - location.X) > Math.Abs(rangePhysicsBounds3.Bottom - location.Y));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
flag27 = false;
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag34 = flag27;
|
|||
|
if (flag34)
|
|||
|
{
|
|||
|
num5 = this.sheet.selectionRange.Row;
|
|||
|
num7 = this.sheet.selectionRange.EndRow;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
num6 = this.sheet.selectionRange.Col;
|
|||
|
num8 = this.sheet.selectionRange.EndCol;
|
|||
|
}
|
|||
|
this.sheet.draggingSelectionRange = this.sheet.FixRange(new RangePosition(num5, num6, num7 - num5 + 1, num8 - num6 + 1));
|
|||
|
this.sheet.ScrollToCell(posByPoint2);
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
case OperationStatus.SelectionRangeMove:
|
|||
|
{
|
|||
|
CellPosition posByPoint3 = CellsViewport.GetPosByPoint(this, location);
|
|||
|
bool flag35 = this.sheet.lastMouseMoving.Y != (float)posByPoint3.Row || this.sheet.lastMouseMoving.X != (float)posByPoint3.Col;
|
|||
|
if (flag35)
|
|||
|
{
|
|||
|
this.sheet.lastMouseMoving.Y = (float)posByPoint3.Row;
|
|||
|
this.sheet.lastMouseMoving.X = (float)posByPoint3.Col;
|
|||
|
this.sheet.draggingSelectionRange = new RangePosition(posByPoint3.Row - this.sheet.focusMovingRangeOffset.Row, posByPoint3.Col - this.sheet.focusMovingRangeOffset.Col, this.sheet.selectionRange.Rows, this.sheet.selectionRange.Cols);
|
|||
|
bool flag36 = this.sheet.draggingSelectionRange.Row < 0;
|
|||
|
if (flag36)
|
|||
|
{
|
|||
|
this.sheet.draggingSelectionRange.Row = 0;
|
|||
|
}
|
|||
|
bool flag37 = this.sheet.draggingSelectionRange.Col < 0;
|
|||
|
if (flag37)
|
|||
|
{
|
|||
|
this.sheet.draggingSelectionRange.Col = 0;
|
|||
|
}
|
|||
|
bool flag38 = this.sheet.draggingSelectionRange.EndRow >= this.sheet.RowCount;
|
|||
|
if (flag38)
|
|||
|
{
|
|||
|
this.sheet.draggingSelectionRange.Row = this.sheet.RowCount - this.sheet.draggingSelectionRange.Rows;
|
|||
|
}
|
|||
|
bool flag39 = this.sheet.draggingSelectionRange.EndCol >= this.sheet.ColumnCount;
|
|||
|
if (flag39)
|
|||
|
{
|
|||
|
this.sheet.draggingSelectionRange.Col = this.sheet.ColumnCount - this.sheet.draggingSelectionRange.Cols;
|
|||
|
}
|
|||
|
this.sheet.ScrollToCell(posByPoint3);
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
}
|
|||
|
return true;
|
|||
|
}
|
|||
|
case OperationStatus.SelectionRangeMovePrepare:
|
|||
|
{
|
|||
|
bool flag40 = buttons == MouseButtons.Left && this.sheet.HasSettings(WorksheetSettings.Edit_DragSelectionToMoveCells) && this.sheet.draggingSelectionRange != RangePosition.Empty;
|
|||
|
if (flag40)
|
|||
|
{
|
|||
|
this.sheet.operationStatus = OperationStatus.SelectionRangeMove;
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
return flag;
|
|||
|
}
|
|||
|
case OperationStatus.AdjustPageBreakRow:
|
|||
|
{
|
|||
|
bool flag41 = buttons == MouseButtons.Left && this.sheet.pageBreakAdjustRow > -1;
|
|||
|
if (flag41)
|
|||
|
{
|
|||
|
int row = this.sheet.FindRowIndexMiddle(location.Y);
|
|||
|
int num9 = this.sheet.FixPageBreakRowIndex(this.sheet.pageBreakAdjustRow, row);
|
|||
|
bool flag42 = this.sheet.lastMouseMoving.Y != (float)num9;
|
|||
|
if (flag42)
|
|||
|
{
|
|||
|
this.sheet.pageBreakAdjustFocusIndex = num9;
|
|||
|
this.sheet.lastMouseMoving.Y = (float)num9;
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
}
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
return flag;
|
|||
|
}
|
|||
|
case OperationStatus.AdjustPageBreakColumn:
|
|||
|
{
|
|||
|
bool flag43 = buttons == MouseButtons.Left && this.sheet.pageBreakAdjustCol > -1;
|
|||
|
if (flag43)
|
|||
|
{
|
|||
|
int col = this.sheet.FindColIndexMiddle(location.X);
|
|||
|
int num10 = this.sheet.FixPageBreakColIndex(this.sheet.pageBreakAdjustCol, col);
|
|||
|
bool flag44 = this.sheet.lastMouseMoving.X != (float)num10;
|
|||
|
if (flag44)
|
|||
|
{
|
|||
|
this.sheet.pageBreakAdjustFocusIndex = num10;
|
|||
|
this.sheet.lastMouseMoving.X = (float)num10;
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
}
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
return flag;
|
|||
|
}
|
|||
|
case OperationStatus.CellBodyCapture:
|
|||
|
{
|
|||
|
bool flag45 = this.sheet.mouseCapturedCell != null && this.sheet.mouseCapturedCell.body != null;
|
|||
|
if (flag45)
|
|||
|
{
|
|||
|
int top = this.sheet.rows[this.sheet.mouseCapturedCell.InternalRow].Top;
|
|||
|
int left = this.sheet.cols[this.sheet.mouseCapturedCell.InternalCol].Left;
|
|||
|
Worksheet sheet2 = this.sheet;
|
|||
|
Cell mouseCapturedCell = this.sheet.mouseCapturedCell;
|
|||
|
float num = location.X - (float)left;
|
|||
|
float num4 = location.Y - (float)top;
|
|||
|
CellMouseEventArgs e = new CellMouseEventArgs(sheet2, mouseCapturedCell, new Point(ref num, ref num4), location, buttons, 1);
|
|||
|
flag = this.sheet.mouseCapturedCell.body.OnMouseMove(e);
|
|||
|
}
|
|||
|
return flag;
|
|||
|
}
|
|||
|
}
|
|||
|
this.sheet.controlAdapter.ChangeCursor(CursorStyle.PlatformDefault);
|
|||
|
return flag;
|
|||
|
}
|
|||
|
|
|||
|
public override bool OnMouseUp(Point location, MouseButtons buttons, InputModifiers modifiers)
|
|||
|
{
|
|||
|
bool flag = false;
|
|||
|
OperationStatus operationStatus = this.sheet.operationStatus;
|
|||
|
OperationStatus operationStatus2 = operationStatus;
|
|||
|
switch (operationStatus2)
|
|||
|
{
|
|||
|
case OperationStatus.RangeSelect:
|
|||
|
case OperationStatus.FullRowSelect:
|
|||
|
case OperationStatus.FullColumnSelect:
|
|||
|
{
|
|||
|
CellPosition posByPoint = CellsViewport.GetPosByPoint(this, location);
|
|||
|
bool flag2 = this.sheet.lastChangedSelectionRange != this.sheet.selectionRange;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
this.sheet.lastChangedSelectionRange = this.sheet.selectionRange;
|
|||
|
this.sheet.selEnd = posByPoint;
|
|||
|
bool flag3 = this.sheet.whenRangePicked != null;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
bool flag4 = this.sheet.whenRangePicked(this.sheet, this.sheet.selectionRange);
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
this.sheet.EndPickRange();
|
|||
|
}
|
|||
|
}
|
|||
|
this.sheet.RaiseSelectionRangeChanged(new RangeEventArgs(this.sheet.selectionRange));
|
|||
|
}
|
|||
|
int row = posByPoint.Row;
|
|||
|
int col = posByPoint.Col;
|
|||
|
Cell cell = this.sheet.cells[row, col];
|
|||
|
bool flag5 = (cell != null && cell.body != null) || this.sheet.HasCellMouseUp;
|
|||
|
if (flag5)
|
|||
|
{
|
|||
|
int top = this.sheet.rows[row].Top;
|
|||
|
int left = this.sheet.cols[col].Left;
|
|||
|
Worksheet sheet = this.sheet;
|
|||
|
Cell cell2 = cell;
|
|||
|
CellPosition cellPosition = posByPoint;
|
|||
|
float num = location.X - (float)left;
|
|||
|
float num2 = location.Y - (float)top;
|
|||
|
CellMouseEventArgs cellMouseEventArgs = new CellMouseEventArgs(sheet, cell2, cellPosition, new Point(ref num, ref num2), location, buttons, 1);
|
|||
|
this.sheet.RaiseCellMouseUp(cellMouseEventArgs);
|
|||
|
bool flag6 = cell != null && cell.body != null;
|
|||
|
if (flag6)
|
|||
|
{
|
|||
|
flag = cell.body.OnMouseUp(cellMouseEventArgs);
|
|||
|
}
|
|||
|
}
|
|||
|
this.sheet.operationStatus = OperationStatus.Default;
|
|||
|
return true;
|
|||
|
}
|
|||
|
case OperationStatus.FullSingleRowSelect:
|
|||
|
case OperationStatus.FullSingleColumnSelect:
|
|||
|
case OperationStatus.AdjustRowHeight:
|
|||
|
case OperationStatus.AdjustColumnWidth:
|
|||
|
case OperationStatus.RangePicker:
|
|||
|
break;
|
|||
|
case OperationStatus.DragSelectionFillSerial:
|
|||
|
{
|
|||
|
this.sheet.operationStatus = OperationStatus.Default;
|
|||
|
bool flag7 = this.sheet.draggingSelectionRange.Rows > this.sheet.selectionRange.Rows || this.sheet.draggingSelectionRange.Cols > this.sheet.selectionRange.Cols;
|
|||
|
if (flag7)
|
|||
|
{
|
|||
|
RangePosition empty = RangePosition.Empty;
|
|||
|
bool flag8 = this.sheet.draggingSelectionRange.Rows == this.sheet.selectionRange.Rows;
|
|||
|
if (flag8)
|
|||
|
{
|
|||
|
empty = new RangePosition(this.sheet.draggingSelectionRange.Row, this.sheet.draggingSelectionRange.Col + this.sheet.selectionRange.Cols, this.sheet.draggingSelectionRange.Rows, this.sheet.draggingSelectionRange.Cols - this.sheet.selectionRange.Cols);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag9 = this.sheet.draggingSelectionRange.Cols == this.sheet.selectionRange.Cols;
|
|||
|
if (flag9)
|
|||
|
{
|
|||
|
empty = new RangePosition(this.sheet.draggingSelectionRange.Row + this.sheet.selectionRange.Rows, this.sheet.draggingSelectionRange.Col, this.sheet.draggingSelectionRange.Rows - this.sheet.selectionRange.Rows, this.sheet.draggingSelectionRange.Cols);
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag10 = empty != RangePosition.Empty;
|
|||
|
if (flag10)
|
|||
|
{
|
|||
|
this.sheet.DoAction(new AutoFillSerialAction(this.sheet.SelectionRange, empty));
|
|||
|
}
|
|||
|
}
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
return true;
|
|||
|
}
|
|||
|
case OperationStatus.SelectionRangeMove:
|
|||
|
{
|
|||
|
bool flag11 = this.sheet.selectionRange != this.sheet.draggingSelectionRange;
|
|||
|
if (flag11)
|
|||
|
{
|
|||
|
RangePosition selectionRange = this.sheet.selectionRange;
|
|||
|
RangePosition draggingSelectionRange = this.sheet.draggingSelectionRange;
|
|||
|
try
|
|||
|
{
|
|||
|
bool flag12 = this.sheet.CheckRangeReadonly(selectionRange);
|
|||
|
if (flag12)
|
|||
|
{
|
|||
|
throw new RangeContainsReadonlyCellsException(selectionRange);
|
|||
|
}
|
|||
|
bool flag13 = this.sheet.CheckRangeReadonly(draggingSelectionRange);
|
|||
|
if (flag13)
|
|||
|
{
|
|||
|
throw new RangeContainsReadonlyCellsException(draggingSelectionRange);
|
|||
|
}
|
|||
|
bool flag14 = modifiers.HasFlag(InputModifiers.Control);
|
|||
|
BaseWorksheetAction action;
|
|||
|
if (flag14)
|
|||
|
{
|
|||
|
action = new CopyRangeAction(selectionRange, draggingSelectionRange.StartPos);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
action = new MoveRangeAction(selectionRange, draggingSelectionRange.StartPos);
|
|||
|
}
|
|||
|
this.sheet.DoAction(action);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
this.sheet.NotifyExceptionHappen(ex);
|
|||
|
}
|
|||
|
}
|
|||
|
this.sheet.focusMovingRangeOffset = CellPosition.Empty;
|
|||
|
this.sheet.draggingSelectionRange = RangePosition.Empty;
|
|||
|
this.sheet.operationStatus = OperationStatus.Default;
|
|||
|
this.sheet.controlAdapter.ChangeCursor(CursorStyle.PlatformDefault);
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
return true;
|
|||
|
}
|
|||
|
case OperationStatus.SelectionRangeMovePrepare:
|
|||
|
this.sheet.operationStatus = OperationStatus.Default;
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
return true;
|
|||
|
case OperationStatus.AdjustPageBreakRow:
|
|||
|
{
|
|||
|
bool flag15 = this.sheet.pageBreakAdjustRow > -1;
|
|||
|
if (flag15)
|
|||
|
{
|
|||
|
int num3 = this.sheet.pageBreakRows[this.sheet.pageBreakAdjustRow];
|
|||
|
bool flag16 = num3 >= 0;
|
|||
|
if (flag16)
|
|||
|
{
|
|||
|
bool flag17 = num3 != this.sheet.pageBreakAdjustFocusIndex;
|
|||
|
if (flag17)
|
|||
|
{
|
|||
|
this.sheet.ChangeRowPageBreak(num3, this.sheet.pageBreakAdjustFocusIndex, true);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
this.sheet.pageBreakAdjustRow = -1;
|
|||
|
this.sheet.pageBreakAdjustFocusIndex = -1;
|
|||
|
this.sheet.operationStatus = OperationStatus.Default;
|
|||
|
return true;
|
|||
|
}
|
|||
|
case OperationStatus.AdjustPageBreakColumn:
|
|||
|
{
|
|||
|
bool flag18 = this.sheet.pageBreakAdjustCol > -1;
|
|||
|
if (flag18)
|
|||
|
{
|
|||
|
int num4 = this.sheet.pageBreakCols[this.sheet.pageBreakAdjustCol];
|
|||
|
bool flag19 = num4 >= 0;
|
|||
|
if (flag19)
|
|||
|
{
|
|||
|
bool flag20 = num4 != this.sheet.pageBreakAdjustFocusIndex;
|
|||
|
if (flag20)
|
|||
|
{
|
|||
|
this.sheet.ChangeColumnPageBreak(num4, this.sheet.pageBreakAdjustFocusIndex, true);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
this.sheet.pageBreakAdjustCol = -1;
|
|||
|
this.sheet.pageBreakAdjustFocusIndex = -1;
|
|||
|
this.sheet.operationStatus = OperationStatus.Default;
|
|||
|
return true;
|
|||
|
}
|
|||
|
default:
|
|||
|
if (operationStatus2 == OperationStatus.CellBodyCapture)
|
|||
|
{
|
|||
|
bool flag21 = this.sheet.mouseCapturedCell != null;
|
|||
|
if (flag21)
|
|||
|
{
|
|||
|
bool flag22 = this.sheet.mouseCapturedCell.body != null;
|
|||
|
if (flag22)
|
|||
|
{
|
|||
|
int top2 = this.sheet.rows[this.sheet.mouseCapturedCell.InternalRow].Top;
|
|||
|
int left2 = this.sheet.cols[this.sheet.mouseCapturedCell.InternalCol].Left;
|
|||
|
Worksheet sheet2 = this.sheet;
|
|||
|
Cell mouseCapturedCell = this.sheet.mouseCapturedCell;
|
|||
|
float num = location.X - (float)left2;
|
|||
|
float num2 = location.Y - (float)top2;
|
|||
|
CellMouseEventArgs e = new CellMouseEventArgs(sheet2, mouseCapturedCell, new Point(ref num, ref num2), location, buttons, 1);
|
|||
|
flag = this.sheet.mouseCapturedCell.body.OnMouseUp(e);
|
|||
|
bool flag23 = flag;
|
|||
|
if (flag23)
|
|||
|
{
|
|||
|
this.sheet.RequestInvalidate();
|
|||
|
}
|
|||
|
}
|
|||
|
this.sheet.mouseCapturedCell = null;
|
|||
|
}
|
|||
|
this.sheet.operationStatus = OperationStatus.Default;
|
|||
|
return flag;
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
CellPosition posByPoint2 = CellsViewport.GetPosByPoint(this, location);
|
|||
|
int row2 = posByPoint2.Row;
|
|||
|
int col2 = posByPoint2.Col;
|
|||
|
Cell cell3 = this.sheet.cells[row2, col2];
|
|||
|
bool flag24 = (cell3 != null && cell3.body != null) || this.sheet.HasCellMouseUp;
|
|||
|
if (flag24)
|
|||
|
{
|
|||
|
int top3 = this.sheet.rows[row2].Top;
|
|||
|
int left3 = this.sheet.cols[col2].Left;
|
|||
|
Worksheet sheet3 = this.sheet;
|
|||
|
Cell cell4 = cell3;
|
|||
|
CellPosition cellPosition2 = posByPoint2;
|
|||
|
float num = location.X - (float)left3;
|
|||
|
float num2 = location.Y - (float)top3;
|
|||
|
CellMouseEventArgs cellMouseEventArgs2 = new CellMouseEventArgs(sheet3, cell4, cellPosition2, new Point(ref num, ref num2), location, buttons, 1);
|
|||
|
this.sheet.RaiseCellMouseUp(cellMouseEventArgs2);
|
|||
|
bool flag25 = cell3 != null && cell3.body != null;
|
|||
|
if (flag25)
|
|||
|
{
|
|||
|
flag = cell3.body.OnMouseUp(cellMouseEventArgs2);
|
|||
|
}
|
|||
|
}
|
|||
|
return flag;
|
|||
|
}
|
|||
|
|
|||
|
public override bool OnMouseDoubleClick(Point location, MouseButtons buttons)
|
|||
|
{
|
|||
|
bool flag = !this.sheet.focusPos.IsEmpty;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
CellPosition r = CellsViewport.GetPosByPoint(this, location);
|
|||
|
bool flag2 = !r.IsEmpty && r.Row < this.sheet.rows.Count && r.Col < this.sheet.cols.Count;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
Cell cell = this.sheet.cells[r.Row, r.Col];
|
|||
|
bool flag3 = cell != null && !cell.IsValidCell;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
r = cell.MergeStartPos;
|
|||
|
}
|
|||
|
}
|
|||
|
bool flag4 = this.sheet.focusPos == r;
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
this.sheet.StartEdit();
|
|||
|
this.sheet.controlAdapter.EditControlApplySystemMouseDown();
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
internal static int GetColByPoint(IViewport view, float x)
|
|||
|
{
|
|||
|
Worksheet sheet = view.ViewportController.Worksheet;
|
|||
|
bool flag = sheet.cols.Count <= 0 || x < (float)sheet.cols[0].Right;
|
|||
|
int result;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
result = 0;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
GridRegion visibleRegion = view.VisibleRegion;
|
|||
|
bool flag2 = visibleRegion.endCol <= visibleRegion.startCol;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
result = visibleRegion.startCol;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
result = ArrayHelper.QuickFind((visibleRegion.endCol - visibleRegion.startCol + 1) / 2, 0, sheet.cols.Count - 1, delegate(int i)
|
|||
|
{
|
|||
|
ColumnHeader columnHeader = sheet.cols[i];
|
|||
|
bool flag3 = (float)columnHeader.Right < x;
|
|||
|
int result2;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
result2 = 1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag4 = (float)columnHeader.Left > x;
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
result2 = -1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
result2 = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
return result2;
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
internal static int GetRowByPoint(IViewport view, float y)
|
|||
|
{
|
|||
|
Worksheet sheet = view.ViewportController.Worksheet;
|
|||
|
bool flag = sheet.rows.Count <= 0 || y < (float)sheet.rows[0].Bottom;
|
|||
|
int result;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
result = 0;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
GridRegion visibleRegion = view.VisibleRegion;
|
|||
|
bool flag2 = visibleRegion.endRow <= visibleRegion.startRow;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
result = visibleRegion.startRow;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
|||
|
try
|
|||
|
{
|
|||
|
result = ArrayHelper.QuickFind((visibleRegion.endRow - visibleRegion.startRow + 1) / 2, 0, sheet.rows.Count - 1, delegate(int i)
|
|||
|
{
|
|||
|
RowHeader rowHeader = sheet.rows[i];
|
|||
|
bool flag4 = (float)rowHeader.Bottom < y;
|
|||
|
int result2;
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
result2 = 1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag5 = (float)rowHeader.Top > y;
|
|||
|
if (flag5)
|
|||
|
{
|
|||
|
result2 = -1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
result2 = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
return result2;
|
|||
|
});
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
stopwatch.Stop();
|
|||
|
long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
|
|||
|
bool flag3 = elapsedMilliseconds > 1L;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
Debug.WriteLine("finding row index takes " + elapsedMilliseconds.ToString() + " ms.");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
public static CellPosition GetPosByPoint(IViewport view, Point p)
|
|||
|
{
|
|||
|
return new CellPosition(CellsViewport.GetRowByPoint(view, p.Y), CellsViewport.GetColByPoint(view, p.X));
|
|||
|
}
|
|||
|
|
|||
|
public static bool TryGetCellPositionToControl(IView view, CellPosition pos, out Point p)
|
|||
|
{
|
|||
|
bool flag = view == null;
|
|||
|
bool result;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
p = default(Point);
|
|||
|
result = false;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Worksheet worksheet = view.ViewportController.Worksheet;
|
|||
|
bool flag2 = worksheet == null;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
p = default(Point);
|
|||
|
result = false;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
pos = worksheet.FixPos(pos);
|
|||
|
IViewport viewport = view as IViewport;
|
|||
|
bool flag3 = viewport == null;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
float num = (float)worksheet.cols[pos.Col].Left * view.ScaleFactor + view.Left;
|
|||
|
float num2 = (float)worksheet.rows[pos.Row].Top * view.ScaleFactor + view.Top;
|
|||
|
p = new Point(ref num, ref num2);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
float num = (float)worksheet.cols[pos.Col].Left * view.ScaleFactor + viewport.Left - viewport.ScrollViewLeft * view.ScaleFactor;
|
|||
|
float num2 = (float)worksheet.rows[pos.Row].Top * view.ScaleFactor + viewport.Top - viewport.ScrollViewTop * view.ScaleFactor;
|
|||
|
p = new Point(ref num, ref num2);
|
|||
|
}
|
|||
|
result = true;
|
|||
|
}
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
internal static bool SelectDragCornerHitTest(Worksheet sheet, Point location)
|
|||
|
{
|
|||
|
Rect rangePhysicsBounds = sheet.GetRangePhysicsBounds(sheet.SelectionRange);
|
|||
|
float num = rangePhysicsBounds.Width;
|
|||
|
rangePhysicsBounds.Width = num - 1f;
|
|||
|
num = rangePhysicsBounds.Height;
|
|||
|
rangePhysicsBounds.Height = num - 1f;
|
|||
|
float selectionBorderWidth = sheet.controlAdapter.ControlStyle.SelectionBorderWidth;
|
|||
|
num = rangePhysicsBounds.Right - selectionBorderWidth;
|
|||
|
float num2 = rangePhysicsBounds.Bottom - selectionBorderWidth;
|
|||
|
float num3 = selectionBorderWidth + 2f;
|
|||
|
float num4 = selectionBorderWidth + 2f;
|
|||
|
return new Rect(ref num, ref num2, ref num3, ref num4).Contains(location);
|
|||
|
}
|
|||
|
|
|||
|
public override string ToString()
|
|||
|
{
|
|||
|
return string.Format("CellsViewport[{0}]", this.ViewBounds);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|