Initialize Borders from FlexGrid selection
Eliminate SelChange funtions during Initialization Eliminate Moving GridItem to the Left and Right on selection Fixed a bug where SelectedEditItem was null Eliminate SelChange funtions during Initialization Use FlexGrid CellRange (Selection) to Get and Set Range Borders Added Unknown value to GridLinePattern enum Set Range Borders based upon CellRange (Selection)
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Diagnostics;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using C1.Win.C1FlexGrid;
|
||||
|
||||
namespace Volian.Controls.Library
|
||||
{
|
||||
@@ -152,6 +153,51 @@ namespace Volian.Controls.Library
|
||||
HasColumns = c2 > c1;
|
||||
Invalidate();
|
||||
}
|
||||
public void InitializeBorder(VlnFlexGrid myFlexGrid, CellRange myRange)
|
||||
{
|
||||
_TopBorder = GridLinePattern.Unknown;
|
||||
_InsideHorizontalBorder = GridLinePattern.Unknown;
|
||||
_BottomBorder = GridLinePattern.Unknown;
|
||||
_LeftBorder = GridLinePattern.Unknown;
|
||||
_InsideVerticalBorder = GridLinePattern.Unknown;
|
||||
_RightBorder = GridLinePattern.Unknown;
|
||||
for (int r = myRange.r1; r <= myRange.r2; r++)
|
||||
for (int c = myRange.c1; c <= myRange.c2; c++)
|
||||
{
|
||||
CellRange cr = myFlexGrid.GetMergedRange(r, c);
|
||||
if (r == myRange.r1) // Top Border
|
||||
_TopBorder = CombinePattern(_TopBorder, myFlexGrid.MyBorders.HorizontalLines[cr.r1, cr.c1]);
|
||||
if (r == myRange.r1 && c == myRange.c1) // Left Border
|
||||
_LeftBorder = CombinePattern(_LeftBorder, myFlexGrid.MyBorders.VerticalLines[cr.r1, cr.c1]);
|
||||
if (r == myRange.r2) // Bottom Border
|
||||
_BottomBorder = CombinePattern(_BottomBorder, myFlexGrid.MyBorders.HorizontalLines[cr.r2+1, cr.c2]);
|
||||
if (r == myRange.r2 && c == myRange.c2) // Right Border
|
||||
_RightBorder = CombinePattern(_RightBorder, myFlexGrid.MyBorders.VerticalLines[cr.r2, cr.c2+1]);
|
||||
if (r == cr.r1 && c == cr.c1) // Look for inside lines
|
||||
{
|
||||
if (cr.r1 > myRange.r1 && cr.r1 < myRange.r2) // Inside Horizontal Top
|
||||
_InsideHorizontalBorder = CombinePattern(_InsideHorizontalBorder, myFlexGrid.MyBorders.HorizontalLines[cr.r1, cr.c1]);
|
||||
if (cr.r2 > myRange.r1 && cr.r2 < myRange.r2) // Inside Horizontal Bottom
|
||||
_InsideHorizontalBorder = CombinePattern(_InsideHorizontalBorder, myFlexGrid.MyBorders.HorizontalLines[cr.r2 +1, cr.c2]);
|
||||
if (cr.c1 > myRange.c1 && cr.c1 < myRange.c2) // Inside Vertical Left
|
||||
_InsideVerticalBorder = CombinePattern(_InsideVerticalBorder, myFlexGrid.MyBorders.VerticalLines[cr.r1, cr.c1]);
|
||||
if (cr.c2 > myRange.c1 && cr.c2 < myRange.c2) // Inside Vertical Right
|
||||
_InsideVerticalBorder = CombinePattern(_InsideVerticalBorder, myFlexGrid.MyBorders.VerticalLines[cr.r2, cr.c2 + 1]);
|
||||
}
|
||||
c = cr.c2;//Skip to the end of the merged cells
|
||||
}
|
||||
HasRows = (_InsideHorizontalBorder != GridLinePattern.Unknown);
|
||||
if (!HasRows) _InsideHorizontalBorder = GridLinePattern.None;
|
||||
HasColumns = (_InsideVerticalBorder != GridLinePattern.Unknown);
|
||||
if (!HasColumns) _InsideVerticalBorder = GridLinePattern.None;
|
||||
Invalidate();
|
||||
}
|
||||
private GridLinePattern CombinePattern(GridLinePattern oldPattern, GridLinePattern newPattern)
|
||||
{
|
||||
if (oldPattern == GridLinePattern.Unknown) return newPattern;
|
||||
if (oldPattern == newPattern) return oldPattern;
|
||||
return GridLinePattern.Mixed;
|
||||
}
|
||||
#endregion
|
||||
#region ctor
|
||||
public BorderSelectionPanel()
|
||||
|
Reference in New Issue
Block a user