C2018-031 added CheckAndFixBorderArrays() that will correct the table border arrays only if needed, prior to editing a table.
This commit is contained in:
parent
0fc87fdbaa
commit
d0ce429883
@ -243,6 +243,16 @@ namespace Volian.Controls.Library
|
||||
return pn;
|
||||
}
|
||||
#endregion
|
||||
#region checkborderarrays
|
||||
// C2018-031 Adjust the Horizontal and Vertical cell border arrays if needed
|
||||
public void CheckAndFixBorderArraySize(int grdRows, int grdCols, GridLinePattern defaultLinePattern)
|
||||
{
|
||||
if (HorizontalLines.Columns != grdCols || HorizontalLines.Rows != grdRows + 1)
|
||||
HorizontalLines = new LinePatternArray(defaultLinePattern, grdRows + 1, grdCols, HorizontalLines.Lines);
|
||||
if (VerticalLines.Columns != grdCols + 1 || VerticalLines.Rows != grdRows)
|
||||
VerticalLines = new LinePatternArray(defaultLinePattern, grdRows, grdCols + 1, VerticalLines.Lines);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
[Serializable]
|
||||
public class LinePatternArray
|
||||
@ -281,6 +291,22 @@ namespace Volian.Controls.Library
|
||||
for (int c = 0; c < Columns; c++)
|
||||
Lines[r * Columns + c] = defaultLinePattern;
|
||||
}
|
||||
// C2018-031 used to automatically adjust the cell border arrays
|
||||
public LinePatternArray(GridLinePattern defaultLinePattern, int rows, int columns, GridLinePattern[] lnsAry)
|
||||
{
|
||||
Rows = rows;
|
||||
Columns = columns;
|
||||
Lines = new GridLinePattern[rows * columns];
|
||||
for (int r = 0; r < Rows; r++)
|
||||
for (int c = 0; c < Columns; c++)
|
||||
{
|
||||
int idx = r * Columns + c;
|
||||
if (idx < lnsAry.Length)
|
||||
Lines[idx] = lnsAry[idx];
|
||||
else
|
||||
Lines[idx] = defaultLinePattern;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Array Access
|
||||
public GridLinePattern this[int r, int c]
|
||||
@ -289,7 +315,7 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
int indx = r * Columns + c;
|
||||
if (indx < Lines.Length) return Lines[r * Columns + c];
|
||||
_MyLog.WarnFormat("GridLinePattern: Lines Array Access out-of-bounds ({0}, {1}) within ({2}, {3})", r, c, Rows, Columns);
|
||||
_MyLog.WarnFormat("GridLinePattern: Lines Array Access out-of-bounds ({0}, {1}) within ({2}, {3})", r, c, Rows, Columns);
|
||||
return GridLinePattern.Single;
|
||||
}
|
||||
set { Lines[r * Columns + c] = value; }
|
||||
|
@ -1356,6 +1356,7 @@ namespace Volian.Controls.Library
|
||||
Rectangle bounds = e.Bounds;
|
||||
int row = e.Row;
|
||||
int col = e.Col;
|
||||
MyBorders.CheckAndFixBorderArraySize(this.Rows.Count, this.Cols.Count, GridLinePattern.Single); // C2018-031 check the cell border arrays
|
||||
CellRange cr = GetMergedRange(row, col);
|
||||
GridLinePattern topSide = MyBorders.HorizontalLines[cr.r1,cr.c1];
|
||||
GridLinePattern rightOfTopSide = cr.c2 == Cols.Count - 1 ? GridLinePattern.None : MyBorders.HorizontalLines[cr.r1, cr.c2 + 1];
|
||||
|
Loading…
x
Reference in New Issue
Block a user