This commit is contained in:
parent
05c97e9aed
commit
6a63b4634c
@ -1819,13 +1819,21 @@ namespace Volian.Controls.Library
|
|||||||
#region Table Grid Merge/Split
|
#region Table Grid Merge/Split
|
||||||
private void btnTblDgnSplitCells_ToRows_Click(object sender, EventArgs e)
|
private void btnTblDgnSplitCells_ToRows_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
// without the BeginUpdate/EndUpdate, you will see the table jump around while
|
||||||
|
// it is being adjusted
|
||||||
|
MyFlexGrid.BeginUpdate();
|
||||||
MyFlexGrid.SplitSelection(false);
|
MyFlexGrid.SplitSelection(false);
|
||||||
|
MyFlexGrid.EndUpdate();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private void btnTblDgnSplitCellsToCols_Click(object sender, EventArgs e)
|
private void btnTblDgnSplitCellsToCols_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
// without the BeginUpdate/EndUpdate, you will see the table jump around while
|
||||||
|
// it is being adjusted
|
||||||
|
MyFlexGrid.BeginUpdate();
|
||||||
MyFlexGrid.SplitSelection(true);
|
MyFlexGrid.SplitSelection(true);
|
||||||
|
MyFlexGrid.EndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnTblDgnMergeCells_Click(object sender, EventArgs e)
|
private void btnTblDgnMergeCells_Click(object sender, EventArgs e)
|
||||||
|
@ -1250,7 +1250,6 @@ namespace Volian.Controls.Library
|
|||||||
|
|
||||||
this.Size = new Size(wid + difW, height + difH);
|
this.Size = new Size(wid + difW, height + difH);
|
||||||
}
|
}
|
||||||
//this.Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConvertTextCellToRTF(int r, int c)
|
public void ConvertTextCellToRTF(int r, int c)
|
||||||
@ -1891,7 +1890,7 @@ namespace Volian.Controls.Library
|
|||||||
|
|
||||||
public void MergeSelection()
|
public void MergeSelection()
|
||||||
{
|
{
|
||||||
this.MergedRanges.Add(this.Selection);
|
this.MergedRanges.Add(this.Selection,true);
|
||||||
this.Invalidate();
|
this.Invalidate();
|
||||||
}
|
}
|
||||||
public bool IsInMergeRange()
|
public bool IsInMergeRange()
|
||||||
@ -1903,52 +1902,135 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
//Console.WriteLine("SplitSelection this.selection {0}", this.Selection);
|
//Console.WriteLine("SplitSelection this.selection {0}", this.Selection);
|
||||||
//Debug_WritelineMySelection();
|
//Debug_WritelineMySelection();
|
||||||
C1.Win.C1FlexGrid.CellRange sel = this.GetMergedRange(this.Selection.r1, this.Selection.c1);
|
//C1.Win.C1FlexGrid.CellRange sel = this.GetMergedRange(this.Selection.r1, this.Selection.c1);
|
||||||
|
//Console.WriteLine("SplitSelection myselection {0}", MySelection);
|
||||||
//foreach (CellRange sel in MySelection)
|
//foreach (CellRange sel in MySelection)
|
||||||
//{
|
//{
|
||||||
if (this.MergedRanges.Contains(sel))
|
// //Console.WriteLine("SplitSelection foreach sel {0}", sel);
|
||||||
this.MergedRanges.Remove(sel);
|
// if (sel.IsSingleCell)
|
||||||
else //split cells
|
// this.MergedRanges.Remove(sel);
|
||||||
{
|
// if (!(this.MergedRanges.Contains(sel)) && !didit)
|
||||||
|
// if (bSplitCols)
|
||||||
|
// SplitSelectionColumns();
|
||||||
|
// else
|
||||||
|
// SplitSelectionRows();
|
||||||
|
// didit = true;
|
||||||
|
//}
|
||||||
if (bSplitCols)
|
if (bSplitCols)
|
||||||
SplitSelectionColumns();
|
SplitSelectionColumns();
|
||||||
else
|
else
|
||||||
SplitSelectionRows();
|
SplitSelectionRows();
|
||||||
}
|
//Debug_WritelineMySelection();
|
||||||
|
//foreach (CellRange sel in MySelection)
|
||||||
|
//{
|
||||||
|
// //Console.WriteLine("SplitSelection foreach sel {0}", sel);
|
||||||
|
// if (this.MergedRanges.Contains(sel))
|
||||||
|
// SplitMergedRange(sel, bSplitCols);
|
||||||
//}
|
//}
|
||||||
this.Refresh();
|
//this.Refresh();
|
||||||
|
//RefreshMergeRangeCollection();
|
||||||
this.AdjustGridControlSize();
|
this.AdjustGridControlSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SplitMergedRange(CellRange sel, bool bSplitCols)
|
||||||
|
{
|
||||||
|
int sR = sel.r1;
|
||||||
|
int eR = sel.r2;
|
||||||
|
int sC = sel.c1;
|
||||||
|
int eC = sel.c2;
|
||||||
|
if (bSplitCols && (IsMergedCols(sel) && !IsMergedRows(sel)) ||
|
||||||
|
(!bSplitCols && (IsMergedRows(sel) && !IsMergedCols(sel))))
|
||||||
|
MergedRanges.Remove(sel);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CellRange saveSelection = Selection;
|
||||||
|
if (bSplitCols && IsMergedRows(sel))
|
||||||
|
{
|
||||||
|
MergedRanges.Remove(sel);
|
||||||
|
for (int c = sC; c <= eC; c++)
|
||||||
|
{
|
||||||
|
Select(sR, c, eR, c);
|
||||||
|
MergeSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!bSplitCols && IsMergedCols(sel))
|
||||||
|
{
|
||||||
|
MergedRanges.Remove(sel);
|
||||||
|
for (int r = sR; r <= eR; r++)
|
||||||
|
{
|
||||||
|
Select(r, sC, r, eC);
|
||||||
|
MergeSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Select(saveSelection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private bool IsMergedRows(CellRange sel)
|
||||||
|
{
|
||||||
|
return (sel.r1 != sel.r2);
|
||||||
|
}
|
||||||
|
private bool IsMergedCols(CellRange sel)
|
||||||
|
{
|
||||||
|
return (sel.c1 != sel.c2);
|
||||||
|
}
|
||||||
private void SplitSelectionColumns()
|
private void SplitSelectionColumns()
|
||||||
{
|
{
|
||||||
|
bool nonMergedInSelection = false;
|
||||||
//Console.WriteLine("SplitSelectionColumns this.selection {0}", this.Selection);
|
//Console.WriteLine("SplitSelectionColumns this.selection {0}", this.Selection);
|
||||||
//Debug_WritelineMySelection();
|
//Debug_WritelineMySelection();
|
||||||
CellRange cr = this.Selection;
|
CellRange cr = this.Selection;
|
||||||
int numSelCols = (cr.c2 - cr.c1) + 1;
|
int numSelCols = (cr.c2 - cr.c1) + 1;
|
||||||
|
foreach (CellRange sel in MySelection)
|
||||||
|
{
|
||||||
|
if (!this.MergedRanges.Contains(sel))
|
||||||
|
nonMergedInSelection = true;
|
||||||
|
}
|
||||||
// for each column in the selection, add a new column
|
// for each column in the selection, add a new column
|
||||||
|
if (nonMergedInSelection)
|
||||||
|
{
|
||||||
for (int c = cr.c2; c >= cr.c1; c--)
|
for (int c = cr.c2; c >= cr.c1; c--)
|
||||||
|
{
|
||||||
|
Select(cr.r1, c, cr.r2, c);
|
||||||
InsertColumnAfter();
|
InsertColumnAfter();
|
||||||
|
}
|
||||||
|
}
|
||||||
// include new columns in selection
|
// include new columns in selection
|
||||||
this.Select(cr.r1, cr.c1, cr.r2, cr.c2 + numSelCols);
|
this.Select(cr.r1, cr.c1, cr.r2, cr.c2 + ((nonMergedInSelection) ? numSelCols : 0));
|
||||||
|
//if a merged range is part of the selectin, try to split it
|
||||||
|
foreach (CellRange sel in MySelection)
|
||||||
|
{
|
||||||
|
//Console.WriteLine("SplitSelection foreach sel {0}", sel);
|
||||||
|
if (this.MergedRanges.Contains(sel))
|
||||||
|
SplitMergedRange(sel, true);
|
||||||
|
}
|
||||||
cr = this.Selection;
|
cr = this.Selection;
|
||||||
|
if (nonMergedInSelection)
|
||||||
|
{
|
||||||
for (int r = 0; r < this.Rows.Count; r++)
|
for (int r = 0; r < this.Rows.Count; r++)
|
||||||
for (int c = cr.c1; c <= cr.c2; c += 2)
|
for (int c = cr.c1; c <= cr.c2; c += 2)
|
||||||
{
|
{
|
||||||
if (!this.IsCellSelected(r, c))
|
if (!this.IsCellSelected(r, c))
|
||||||
{
|
{
|
||||||
//this.Select(r, c, r, c + 1);
|
CellRange crTmp = GetMergedRange(r, c);
|
||||||
|
if (crTmp.IsSingleCell)
|
||||||
|
{
|
||||||
CellRange tcr = this.GetCellRange(r, c, r, c + 1);
|
CellRange tcr = this.GetCellRange(r, c, r, c + 1);
|
||||||
this.MergedRanges.Add(tcr);
|
this.MergedRanges.Add(tcr);
|
||||||
|
this.Invalidate();
|
||||||
|
}
|
||||||
|
//CellRange tcr = this.GetCellRange(r, c, r, c + 1);
|
||||||
|
//this.MergedRanges.Add(tcr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//this.Select(cr);
|
|
||||||
// Adjust selected column widths
|
// Adjust selected column widths
|
||||||
for (int c = cr.c1; c <= cr.c2; c++)
|
for (int c = cr.c1; c <= cr.c2; c++)
|
||||||
{
|
{
|
||||||
int recWidth = this.GetCellRect(cr.r1, c).Width;
|
int recWidth = (Cols[c].Width < 0) ? Cols.DefaultSize : Cols[c].Width; // this.GetCellRect(cr.r1, c).Width;
|
||||||
this.Cols[c].Width = Math.Max(recWidth / 2, _minColSplitWidth);
|
int newWidth = Math.Max(recWidth / 2, _minColSplitWidth);
|
||||||
|
this.Cols[c].Width = newWidth;
|
||||||
//Console.WriteLine("Cell[{0},{1}].Width = {2}", cr.r1, c, recWidth);
|
//Console.WriteLine("Cell[{0},{1}].Width = {2}", cr.r1, c, recWidth);
|
||||||
|
//Console.WriteLine("Cell[{0},{1}].NewWidth = {2}", cr.r1, c, newWidth);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1962,21 +2044,32 @@ namespace Volian.Controls.Library
|
|||||||
for (int r = cr.r2; r >= cr.r1; r--)
|
for (int r = cr.r2; r >= cr.r1; r--)
|
||||||
{
|
{
|
||||||
//Console.WriteLine("Inserted new Row at [{0},{1}]", r, cr.c1);
|
//Console.WriteLine("Inserted new Row at [{0},{1}]", r, cr.c1);
|
||||||
|
Select(r, cr.c1, r, cr.c2);
|
||||||
InsertRowAfter();
|
InsertRowAfter();
|
||||||
}
|
}
|
||||||
// include new rows in selection
|
// include new rows in selection
|
||||||
this.Select(cr.r1, cr.c1, cr.r2 + numSelRows, cr.c2);
|
this.Select(cr.r1, cr.c1, cr.r2 + numSelRows, cr.c2);
|
||||||
|
//if a merged range is part of the selectin, try to split it
|
||||||
|
foreach (CellRange sel in MySelection)
|
||||||
|
{
|
||||||
|
//Console.WriteLine("SplitSelection foreach sel {0}", sel);
|
||||||
|
if (this.MergedRanges.Contains(sel))
|
||||||
|
SplitMergedRange(sel, false);
|
||||||
|
}
|
||||||
cr = this.Selection;
|
cr = this.Selection;
|
||||||
//Console.WriteLine(" After Insert [{0},{1}] - [{2},{3}]", cr.r1, cr.c1, cr.r2, cr.c2);
|
//Console.WriteLine(" After Insert [{0},{1}] - [{2},{3}]", cr.r1, cr.c1, cr.r2, cr.c2);
|
||||||
for (int c = 0; c < this.Cols.Count; c++)
|
for (int c = 0; c < this.Cols.Count; c++)
|
||||||
for (int r = cr.r1; r <= cr.r2; r += 2)
|
for (int r = cr.r1; r <= cr.r2; r += 2)
|
||||||
{
|
{
|
||||||
if (!this.IsCellSelected(r, c))
|
if (!this.IsCellSelected(r, c))
|
||||||
|
{
|
||||||
|
CellRange crTmp = GetMergedRange(r, c);
|
||||||
|
if (crTmp.IsSingleCell)
|
||||||
{
|
{
|
||||||
CellRange tcr = this.GetCellRange(r, c, r + 1, c);
|
CellRange tcr = this.GetCellRange(r, c, r + 1, c);
|
||||||
this.MergedRanges.Add(tcr);
|
this.MergedRanges.Add(tcr);
|
||||||
//Console.WriteLine("cellrange {0}", tcr);
|
this.Invalidate();
|
||||||
//Console.WriteLine("merge [{0},{1}] - [{2},{3}]", r, c, r + 1, c);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Adjust selected Row Heights
|
// Adjust selected Row Heights
|
||||||
@ -2106,9 +2199,9 @@ namespace Volian.Controls.Library
|
|||||||
if (left)
|
if (left)
|
||||||
{
|
{
|
||||||
if (inspos == cr.c1)
|
if (inspos == cr.c1)
|
||||||
tstr = this[cr.r1, cr.c1 + 1].ToString();
|
tstr = (this[cr.r1, cr.c1 + 1] == null)?"":this[cr.r1, cr.c1 + 1].ToString();
|
||||||
else
|
else
|
||||||
tstr = this[cr.r1, cr.c1].ToString();
|
tstr = (this[cr.r1, cr.c1] == null) ? "" : this[cr.r1, cr.c1].ToString();
|
||||||
newcol = cr.c1;
|
newcol = cr.c1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user