226 lines
4.9 KiB
C#
226 lines
4.9 KiB
C#
using System;
|
|
using CPF.ReoGrid.Core;
|
|
using CPF.ReoGrid.Data;
|
|
|
|
namespace CPF.ReoGrid
|
|
{
|
|
[Serializable]
|
|
public class PartialGrid
|
|
{
|
|
public int Rows
|
|
{
|
|
get
|
|
{
|
|
return this.rows;
|
|
}
|
|
set
|
|
{
|
|
this.rows = value;
|
|
}
|
|
}
|
|
|
|
public int Columns
|
|
{
|
|
get
|
|
{
|
|
return this.cols;
|
|
}
|
|
set
|
|
{
|
|
this.cols = value;
|
|
}
|
|
}
|
|
|
|
public Index4DArray<Cell> Cells
|
|
{
|
|
get
|
|
{
|
|
return this.cells;
|
|
}
|
|
set
|
|
{
|
|
this.cells = value;
|
|
}
|
|
}
|
|
|
|
internal Index4DArray<ReoGridHBorder> HBorders
|
|
{
|
|
get
|
|
{
|
|
return this.hBorders;
|
|
}
|
|
set
|
|
{
|
|
this.hBorders = value;
|
|
}
|
|
}
|
|
|
|
internal Index4DArray<ReoGridVBorder> VBorders
|
|
{
|
|
get
|
|
{
|
|
return this.vBorders;
|
|
}
|
|
set
|
|
{
|
|
this.vBorders = value;
|
|
}
|
|
}
|
|
|
|
public PartialGrid()
|
|
{
|
|
}
|
|
|
|
public PartialGrid(int initRows, int initCols)
|
|
{
|
|
this.rows = initRows;
|
|
this.cols = initCols;
|
|
}
|
|
|
|
public PartialGrid(object[,] data)
|
|
{
|
|
this.cells = new Index4DArray<Cell>();
|
|
this.rows = data.GetLength(0);
|
|
this.cols = data.GetLength(1);
|
|
for (int i = 0; i < this.rows; i++)
|
|
{
|
|
for (int j = 0; j < this.cols; j++)
|
|
{
|
|
this.cells[i, j] = new Cell(null)
|
|
{
|
|
InternalRow = i,
|
|
InternalCol = j,
|
|
Rowspan = 1,
|
|
Colspan = 1,
|
|
InnerData = data[i, j]
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
bool flag = obj is PartialGrid;
|
|
bool result;
|
|
if (flag)
|
|
{
|
|
result = this.Equals((PartialGrid)obj, PartialGridCopyFlag.All);
|
|
}
|
|
else
|
|
{
|
|
result = base.Equals(obj);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public bool Equals(PartialGrid anotherPartialGrid, PartialGridCopyFlag flag)
|
|
{
|
|
bool flag2 = anotherPartialGrid.rows != this.rows || anotherPartialGrid.cols != this.cols;
|
|
bool result;
|
|
if (flag2)
|
|
{
|
|
result = false;
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < this.rows; i++)
|
|
{
|
|
for (int j = 0; j < this.cols; j++)
|
|
{
|
|
Cell cell = this.cells[i, j];
|
|
Cell cell2 = anotherPartialGrid.cells[i, j];
|
|
bool flag3 = (flag & PartialGridCopyFlag.CellData) == PartialGridCopyFlag.CellData;
|
|
if (flag3)
|
|
{
|
|
bool flag4 = (cell == null && cell2 != null) || (cell2 == null && cell != null) || cell.InnerData == null || cell2.InnerData != null || cell2.InnerData == null || cell.InnerData != null;
|
|
if (flag4)
|
|
{
|
|
return false;
|
|
}
|
|
bool flag5 = Convert.ToString(cell.DisplayText) != Convert.ToString(cell2.DisplayText);
|
|
if (flag5)
|
|
{
|
|
return false;
|
|
}
|
|
bool flag6 = !string.Equals(cell.InnerFormula, cell2.InnerFormula, StringComparison.CurrentCultureIgnoreCase);
|
|
if (flag6)
|
|
{
|
|
return false;
|
|
}
|
|
bool flag7 = cell.DataFormat != cell2.DataFormat;
|
|
if (flag7)
|
|
{
|
|
return false;
|
|
}
|
|
bool flag8 = (cell.DataFormatArgs == null && cell2.DataFormatArgs != null) || (cell.DataFormatArgs != null && cell2.DataFormatArgs == null);
|
|
if (flag8)
|
|
{
|
|
return false;
|
|
}
|
|
bool flag9 = !cell.DataFormatArgs.Equals(cell2.DataFormatArgs);
|
|
if (flag9)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
bool flag10 = (flag & PartialGridCopyFlag.CellStyle) == PartialGridCopyFlag.CellStyle && object.Equals(cell.InnerStyle, cell2.InnerStyle);
|
|
if (flag10)
|
|
{
|
|
return false;
|
|
}
|
|
bool flag11 = (flag & PartialGridCopyFlag.HBorder) == PartialGridCopyFlag.HBorder;
|
|
if (flag11)
|
|
{
|
|
ReoGridHBorder reoGridHBorder = this.hBorders[i, j];
|
|
ReoGridHBorder reoGridHBorder2 = anotherPartialGrid.hBorders[i, j];
|
|
bool flag12 = (reoGridHBorder == null && reoGridHBorder2 != null) || (reoGridHBorder2 == null && reoGridHBorder != null);
|
|
if (flag12)
|
|
{
|
|
return false;
|
|
}
|
|
bool flag13 = reoGridHBorder.Span != reoGridHBorder2.Span || !reoGridHBorder.Style.Equals(reoGridHBorder2.Style) || !reoGridHBorder.Pos.Equals(reoGridHBorder2.Pos);
|
|
if (flag13)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
bool flag14 = (flag & PartialGridCopyFlag.VBorder) == PartialGridCopyFlag.VBorder;
|
|
if (flag14)
|
|
{
|
|
ReoGridVBorder reoGridVBorder = this.vBorders[i, j];
|
|
ReoGridVBorder reoGridVBorder2 = anotherPartialGrid.vBorders[i, j];
|
|
bool flag15 = (reoGridVBorder == null && reoGridVBorder2 != null) || (reoGridVBorder2 == null && reoGridVBorder != null);
|
|
if (flag15)
|
|
{
|
|
return false;
|
|
}
|
|
bool flag16 = reoGridVBorder.Span != reoGridVBorder2.Span || !reoGridVBorder.Style.Equals(reoGridVBorder2.Style) || !reoGridVBorder.Pos.Equals(reoGridVBorder2.Pos);
|
|
if (flag16)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
result = true;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
|
|
private int rows;
|
|
|
|
private int cols;
|
|
|
|
private Index4DArray<Cell> cells;
|
|
|
|
private Index4DArray<ReoGridHBorder> hBorders;
|
|
|
|
private Index4DArray<ReoGridVBorder> vBorders;
|
|
}
|
|
}
|