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:
parent
81b22109e6
commit
a03970cd09
@ -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()
|
||||
|
@ -200,6 +200,8 @@ namespace Volian.Controls.Library
|
||||
private string _OrigRtf; // used to store original rtf to allow for 'escape' key restore
|
||||
void MyFlexGrid_SelChange(object sender, EventArgs e)
|
||||
{
|
||||
if (Initializing) return;
|
||||
//Volian.Base.Library.vlnStackTrace.ShowStackLocal("MyFlexGrid_SelChange {0}",MyFlexGrid.Selection);
|
||||
RTBLastFocus = false;
|
||||
MyStepRTB.Visible = false; // Hide the editor if the Selection Changes
|
||||
if (MyFlexGrid.Selection.IsSingleCell && MyFlexGrid.Row >= 0 && MyFlexGrid.Col >= 0)
|
||||
@ -268,8 +270,6 @@ namespace Volian.Controls.Library
|
||||
this.MyStepRTB.RoInsert += new StepRTBRoEvent(MyStepRTB_RoInsert);
|
||||
this.MyFlexGrid.AdjustPastedText += new VlnFlexGridPasteEvent(MyFlexGrid_AdjustPastedText);
|
||||
}
|
||||
|
||||
|
||||
void MyStepRTB_RoInsert(object sender, StepRTBRoEventArgs args)
|
||||
{
|
||||
if (MyFlexGrid.IsRoTable)
|
||||
@ -302,8 +302,9 @@ namespace Volian.Controls.Library
|
||||
//_MyStepRTB.Font = MyStepData.Font.WindowsFont;
|
||||
//ItemWidth = (int)GetTableWidth(MyStepRTB.Font, MyItemInfo.MyContent.Text, true);
|
||||
//ItemWidth = MyFlexGrid.Width;
|
||||
ItemLocation = new Point(50, _MyParentEditItem.Bottom);
|
||||
ItemLocation = TableLocation(_MyParentEditItem, MyStepSectionLayoutData, ItemWidth);
|
||||
//ItemLocation = new Point(50, _MyParentEditItem.Bottom);
|
||||
Point newLocation = TableLocation(_MyParentEditItem, MyStepSectionLayoutData, ItemWidth);
|
||||
if (!newLocation.Equals(ItemLocation)) ItemLocation = newLocation;
|
||||
}
|
||||
public override void SetToolTip(string tip)
|
||||
{
|
||||
@ -483,10 +484,12 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
VE_Font vefont = MyItemInfo.GetItemFont();
|
||||
MyFlexGrid.Font = vefont.WindowsFont;
|
||||
Initializing = true;
|
||||
MyFlexGrid.ParseTableFromText(valtext);
|
||||
MyFlexGrid.AutoSizeCols();
|
||||
MyFlexGrid.AutoSizeRows();
|
||||
MyFlexGrid.MakeRTFcells();
|
||||
Initializing = false;
|
||||
}
|
||||
private bool FinishSave(string searchableText)
|
||||
{
|
||||
|
@ -459,7 +459,7 @@ namespace Volian.Controls.Library
|
||||
/// </summary>
|
||||
public void ItemShow()
|
||||
{
|
||||
if (_SelectedItemInfo != null && SelectedEditItem.BeingDisposed == false)
|
||||
if (_SelectedEditItem != null && SelectedEditItem.BeingDisposed == false)
|
||||
{
|
||||
SelectedEditItem.ItemShow();
|
||||
OnItemSelectedChanged(this, new ItemSelectedChangedEventArgs(SelectedEditItem));
|
||||
|
@ -158,17 +158,17 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MyFlexGrid_SelChange(object sender, EventArgs e)
|
||||
{
|
||||
if (MyFlexGrid.Selection.c1 < 0 || MyFlexGrid.Selection.r1 < 0)
|
||||
return;
|
||||
if (MyFlexGrid.Selection.c1 >= MyFlexGrid.Cols.Count-1 || MyFlexGrid.Selection.r1 >= MyFlexGrid.Rows.Count-1)
|
||||
return;
|
||||
C1.Win.C1FlexGrid.CellRange cr = MyFlexGrid.GetEvenSelection();
|
||||
rbnBorderSelectionPanel.InitializeBorder(MyFlexGrid.MyBorders, cr.r1, cr.c1, cr.r2, cr.c2);
|
||||
if ((MyEditItem as GridItem).Initializing) return;
|
||||
//C1.Win.C1FlexGrid.CellRange cr = MyFlexGrid.GetEvenSelection();
|
||||
//rbnBorderSelectionPanel.InitializeBorder(MyFlexGrid.MyBorders, cr.r1, cr.c1, cr.r2, cr.c2);
|
||||
rbnBorderSelectionPanel.InitializeBorder(MyFlexGrid, MyFlexGrid.Selection);
|
||||
}
|
||||
|
||||
void _MyEditItem_Leave(object sender, EventArgs e)
|
||||
{
|
||||
// The following two lines were replaced by the third line so that the Ribbon KeyTips will work properly.
|
||||
@ -186,7 +186,6 @@ namespace Volian.Controls.Library
|
||||
MyFlexGrid.SelChange -= new EventHandler(MyFlexGrid_SelChange);
|
||||
}
|
||||
}
|
||||
|
||||
void _MyEditItem_Enter(object sender, EventArgs e)
|
||||
{
|
||||
// The following two lines were replaced by the third line so that the Ribbon KeyTips will work properly.
|
||||
@ -205,7 +204,6 @@ namespace Volian.Controls.Library
|
||||
Console.WriteLine("Turn on SelChange");
|
||||
}
|
||||
}
|
||||
|
||||
void MyFlexGrid_CopyOptionChanged(object sender, EventArgs args)
|
||||
{
|
||||
btnTblDgnPaste.Enabled = true;
|
||||
@ -234,7 +232,6 @@ namespace Volian.Controls.Library
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _MyStepRTB_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
SetButtonAndMenuEnabling(false);
|
||||
@ -1929,13 +1926,10 @@ namespace Volian.Controls.Library
|
||||
|
||||
private void rbnBorderSelectionPanel_BordersChanged(object sender, EventArgs args)
|
||||
{
|
||||
C1.Win.C1FlexGrid.CellRange cr = MyFlexGrid.GetEvenSelection();
|
||||
//foreach (C1.Win.C1FlexGrid.CellRange cr in MyFlexGrid.MySelection)
|
||||
//{
|
||||
MyFlexGrid.MyBorders.SetRange(cr.r1, cr.c1, cr.r2, cr.c2, rbnBorderSelectionPanel.TopBorder, rbnBorderSelectionPanel.InsideHorizontalBorder,
|
||||
rbnBorderSelectionPanel.BottomBorder, rbnBorderSelectionPanel.LeftBorder, rbnBorderSelectionPanel.InsideVerticalBorder, rbnBorderSelectionPanel.RightBorder);
|
||||
//}
|
||||
MyEditItem.Invalidate();
|
||||
//C1.Win.C1FlexGrid.CellRange cr = MyFlexGrid.GetEvenSelection();
|
||||
MyFlexGrid.SetBorders(MyFlexGrid.Selection, rbnBorderSelectionPanel.TopBorder, rbnBorderSelectionPanel.InsideHorizontalBorder,
|
||||
rbnBorderSelectionPanel.BottomBorder, rbnBorderSelectionPanel.LeftBorder, rbnBorderSelectionPanel.InsideVerticalBorder, rbnBorderSelectionPanel.RightBorder);
|
||||
MyEditItem.Invalidate();
|
||||
MyFlexGrid.Invalidate();
|
||||
}
|
||||
private void btnTblNoBorder_Click(object sender, EventArgs e)
|
||||
|
@ -438,6 +438,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
public enum GridLinePattern : int
|
||||
{
|
||||
Unknown = -1,
|
||||
None = 0,
|
||||
Single = 1,
|
||||
Double = 2,
|
||||
|
@ -92,6 +92,38 @@ namespace Volian.Controls.Library
|
||||
get { return _MyItemInfo; }
|
||||
set { _MyItemInfo = value; }
|
||||
}
|
||||
public void SetBorders(CellRange myRange,
|
||||
GridLinePattern top, GridLinePattern middle, GridLinePattern bottom,
|
||||
GridLinePattern left, GridLinePattern center, GridLinePattern right)
|
||||
{
|
||||
for (int r = myRange.r1; r <= myRange.r2; r++)
|
||||
for (int c = myRange.c1; c <= myRange.c2; c++)
|
||||
{
|
||||
CellRange cr = GetMergedRange(r, c);
|
||||
if (r == myRange.r1) // Top Border
|
||||
if(top != GridLinePattern.Mixed) MyBorders.HorizontalLines[cr.r1, cr.c1]=top;
|
||||
if (r == myRange.r1 && c == myRange.c1) // Left Border
|
||||
if(left != GridLinePattern.Mixed) MyBorders.VerticalLines[cr.r1, cr.c1]=left;
|
||||
if (r == myRange.r2) // Bottom Border
|
||||
if(bottom != GridLinePattern.Mixed) MyBorders.HorizontalLines[cr.r2 + 1, cr.c2]=bottom;
|
||||
if (r == myRange.r2 && c == myRange.c2) // Right Border
|
||||
if(right != GridLinePattern.Mixed) MyBorders.VerticalLines[cr.r2, cr.c2 + 1] = right;
|
||||
if (r == cr.r1 && c == cr.c1) // Look for inside lines
|
||||
{
|
||||
if (cr.r1 > myRange.r1 && cr.r1 < myRange.r2) // Inside Horizontal Top
|
||||
if(middle != GridLinePattern.Mixed) MyBorders.HorizontalLines[cr.r1, cr.c1]=middle;
|
||||
if (cr.r2 > myRange.r1 && cr.r2 < myRange.r2) // Inside Horizontal Bottom
|
||||
if(middle != GridLinePattern.Mixed) MyBorders.HorizontalLines[cr.r2 + 1, cr.c2]=middle;
|
||||
if (cr.c1 > myRange.c1 && cr.c1 < myRange.c2) // Inside Vertical Left
|
||||
if(center != GridLinePattern.Mixed) MyBorders.VerticalLines[cr.r1, cr.c1]=center;
|
||||
if (cr.c2 > myRange.c1 && cr.c2 < myRange.c2) // Inside Vertical Right
|
||||
if(center != GridLinePattern.Mixed) MyBorders.VerticalLines[cr.r2, cr.c2 + 1]=center;
|
||||
}
|
||||
c = cr.c2;//Skip to the end of the merged cells
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public bool HasVScroll
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user