This commit is contained in:
@@ -22,6 +22,39 @@ namespace Volian.Controls.Library
|
||||
public delegate string VlnFlexGridPasteEvent(object sender, VlnFlexGridPasteEventArgs args);
|
||||
public partial class VlnFlexGrid : C1.Win.C1FlexGrid.C1FlexGrid
|
||||
{
|
||||
public static GridCopyInfo MyCopyInfo = new GridCopyInfo();
|
||||
|
||||
public void CopyToCopiedFlexGrid(GridCopyOption myCopyOption)
|
||||
{
|
||||
MyCopyInfo.MyCopiedFlexGrid = new VlnFlexGrid(); //make a copy of the grid being copied
|
||||
using (StringReader sr = new StringReader(this.GetXMLData()))
|
||||
{
|
||||
MyCopyInfo.MyCopiedFlexGrid.ReadXml(sr);
|
||||
sr.Close();
|
||||
}
|
||||
//FlipCopied(); // create a flipped version of the grid
|
||||
MyCopyInfo.MyCopyOption = myCopyOption;
|
||||
OnCopyOptionChanged(this, new EventArgs());
|
||||
switch (MyCopyInfo.MyCopyOption)
|
||||
{
|
||||
case GridCopyOption.Row:
|
||||
MyCopyInfo.MyCopiedCellRange = MyCopyInfo.MyCopiedFlexGrid.GetCellRange(Selection.r1, 0, Selection.r2, Cols.Count - 1);
|
||||
break;
|
||||
case GridCopyOption.Column:
|
||||
MyCopyInfo.MyCopiedCellRange = MyCopyInfo.MyCopiedFlexGrid.GetCellRange(0, Selection.c1, Rows.Count - 1, Selection.c2);
|
||||
break;
|
||||
case GridCopyOption.Selection:
|
||||
MyCopyInfo.MyCopiedCellRange = MyCopyInfo.MyCopiedFlexGrid.GetCellRange(Selection.r1, Selection.c1, Selection.r2, Selection.c2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
public event VlnFlexGridEvent CopyOptionChanged;
|
||||
public void OnCopyOptionChanged(object sender, EventArgs args)
|
||||
{
|
||||
if (CopyOptionChanged != null) CopyOptionChanged(sender, args);
|
||||
}
|
||||
//[XmlElement("MyBorders")]
|
||||
//[Browsable(false)]
|
||||
//[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
@@ -627,7 +660,7 @@ namespace Volian.Controls.Library
|
||||
// draw the RTF text
|
||||
if (e.Bounds.Width > 0 && e.Bounds.Height > 0)
|
||||
{
|
||||
_rtf.Width = e.Bounds.Width - 3;
|
||||
_rtf.Width = e.Bounds.Width - 1;
|
||||
_rtf.Rtf = rtfText;
|
||||
CellRange cr = GetMergedRange(e.Row, e.Col);
|
||||
cr.UserData = _rtf.Height;
|
||||
@@ -635,6 +668,7 @@ namespace Volian.Controls.Library
|
||||
int hDiff = e.Bounds.Height - _rtf.Height;
|
||||
if (hDiff < 0)
|
||||
{
|
||||
Console.WriteLine("{0}, {1}, {2}, {3}, {4}", hDiff, e.Bounds.Height, _rtf.Height, e.Row, e.Col);
|
||||
Rows[e.Row].Height = _rtf.Height + 4;
|
||||
AdjustGridControlSize();
|
||||
hDiff = 0;
|
||||
@@ -896,6 +930,8 @@ namespace Volian.Controls.Library
|
||||
/// </summary>
|
||||
public void AdjustGridControlSize()
|
||||
{
|
||||
//Console.WriteLine("AdjustGridControlSize");
|
||||
//Volian.Base.Library.vlnStackTrace.ShowStackLocal("AdjustGridControlSize", 3);
|
||||
if (Parent is GridItem ? (Parent as GridItem).Initializing : false ) return;
|
||||
int difW = this.Width - this.ClientSize.Width;
|
||||
int difH = this.Height - this.ClientSize.Height;
|
||||
@@ -1041,6 +1077,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
private void AdjustCellHeightWidth(int r, int c)
|
||||
{
|
||||
Console.WriteLine("AdjustCellHeightWidth");
|
||||
StepRTB trtb = new StepRTB();
|
||||
string tstr = null;
|
||||
bool dummyCharWidth = false;
|
||||
@@ -2167,144 +2204,266 @@ namespace Volian.Controls.Library
|
||||
|
||||
#endregion //Grid Add and Remove Row / Column
|
||||
|
||||
#region Clipboard
|
||||
#region Copy/Paste
|
||||
|
||||
public void ClipBoardCopyRow()
|
||||
public void CopyRow()
|
||||
{
|
||||
this.SelectionMode = SelectionModeEnum.Row;
|
||||
this.Select(this.Selection.r1, 0, this.Selection.r2, this.Cols.Count - 1, true);
|
||||
DialogResult dr = MessageBox.Show("Copy these Rows?", "Copy Rows", MessageBoxButtons.YesNo);
|
||||
if (dr == DialogResult.Yes)
|
||||
_clpbrdCpyPste.Put(this.Selection);
|
||||
this.SelectionMode = SelectionModeEnum.Default;
|
||||
}
|
||||
|
||||
public void ClipBoardCopyColumn()
|
||||
{
|
||||
this.SelectionMode = SelectionModeEnum.Column;
|
||||
this.Select(0, this.Selection.c1, this.Rows.Count - 1, this.Selection.c2, true);
|
||||
DialogResult dr = MessageBox.Show("Copy these columns?", "Copy Columns", MessageBoxButtons.YesNo);
|
||||
if (dr == DialogResult.Yes)
|
||||
_clpbrdCpyPste.Put(this.Selection);
|
||||
this.SelectionMode = SelectionModeEnum.Default;
|
||||
}
|
||||
|
||||
public void ClipBoardCopySelection()
|
||||
{
|
||||
this.Select(this.Selection.r1, this.Selection.c1, this.Selection.r2, this.Selection.c2);
|
||||
DialogResult dr = MessageBox.Show("Copy Selected Cells?", "Copy Selection", MessageBoxButtons.YesNo);
|
||||
if (dr == DialogResult.Yes)
|
||||
_clpbrdCpyPste.Put(this.Selection);
|
||||
}
|
||||
|
||||
|
||||
private void CopyTextFromCellRange(ArrayList arylst, int srow, int scol, int erow, int ecol)
|
||||
{
|
||||
StepRTB trtb = new StepRTB();
|
||||
int aryidx = 0;
|
||||
for (int r = srow; r <= erow; r++)
|
||||
DialogResult dr = DialogResult.Yes;
|
||||
SelectRow();
|
||||
if (Selection.r1 != Selection.r2)
|
||||
{
|
||||
for (int c = scol; c <= ecol; c++)
|
||||
{
|
||||
if (aryidx >= arylst.Count)
|
||||
trtb.Text = "";
|
||||
else
|
||||
{
|
||||
trtb.Rtf = OnAdjustPastedText(this, new VlnFlexGridPasteEventArgs((string)(arylst[aryidx++])));
|
||||
trtb.AdjustWidthForContent();
|
||||
}
|
||||
this[r, c] = trtb.Rtf;
|
||||
//this.ConvertTextCellToRTF(r, c);
|
||||
this.AdjustCellHeightWidth(r, c);
|
||||
}
|
||||
//dr = MessageBox.Show("You selected a row that includes merged cells.\n\nThese additional rows must be included.\n\nCopy these rows?", "Copy Rows", MessageBoxButtons.YesNo);
|
||||
dr = MessageBox.Show("Your selection was expanded due to merged cell regions.\n\nContinue with the copy?", "Copy Rows", MessageBoxButtons.YesNo);
|
||||
}
|
||||
FixTableCellsHeightWidth();
|
||||
if (dr == DialogResult.Yes)
|
||||
CopyToCopiedFlexGrid(GridCopyOption.Row);
|
||||
}
|
||||
|
||||
public void CopyColumn()
|
||||
{
|
||||
SelectCol();
|
||||
DialogResult dr = DialogResult.Yes;
|
||||
if (Selection.c1 != Selection.c2)
|
||||
{
|
||||
//dr = MessageBox.Show("You selected a column that includes merged cells.\n\nThese additional columns must be included.\n\nCopy these columns?", "Copy Columns", MessageBoxButtons.YesNo);
|
||||
dr = MessageBox.Show("Your selection was expanded due to merged cell regions.\n\nContinue with the copy?", "Copy Columns", MessageBoxButtons.YesNo);
|
||||
}
|
||||
if (dr == DialogResult.Yes)
|
||||
CopyToCopiedFlexGrid(GridCopyOption.Column);
|
||||
}
|
||||
|
||||
public void CopyCellSelection()
|
||||
{
|
||||
DialogResult dr = DialogResult.Yes;
|
||||
CellRange cr = Selection;
|
||||
MakeSelectionEven();
|
||||
if (!cr.Equals(Selection))
|
||||
{
|
||||
dr = MessageBox.Show("Your selection was expanded due to merged cell regions.\n\nContinue with the copy?", "Copy Selection", MessageBoxButtons.YesNo);
|
||||
}
|
||||
if (dr == DialogResult.Yes)
|
||||
CopyToCopiedFlexGrid(GridCopyOption.Selection);
|
||||
}
|
||||
|
||||
public enum enmPastePos : int
|
||||
{
|
||||
Before = 1, Replace = 0, After = -1
|
||||
}
|
||||
|
||||
public void ClipBoardPasteRows(enmPastePos pp)
|
||||
public void PasteRows(enmPastePos pp)
|
||||
{
|
||||
// Get a list of strings representing the text (rtf text) in each cell
|
||||
// that was saved to the clipboard (row/column order)
|
||||
ArrayList aryCellList = _clpbrdCpyPste.Get();
|
||||
if (MyCopyInfo.MyCopiedFlexGrid == null || MyCopyInfo.MyCopyOption != GridCopyOption.Row) return;
|
||||
int rowsToAdd = MyCopyInfo.MyCopiedCellRange.r2 - MyCopyInfo.MyCopiedCellRange.r1 + 1;
|
||||
int colsToAdd = Math.Max((MyCopyInfo.MyCopiedCellRange.c2 - MyCopyInfo.MyCopiedCellRange.c1 + 1) - Cols.Count, 0);
|
||||
int rowOffset = Selection.r1 + (pp == enmPastePos.After ? 1 : 0) - MyCopyInfo.MyCopiedCellRange.r1;
|
||||
int selR1 = Selection.r1;
|
||||
|
||||
if (aryCellList != null && aryCellList.Count > 0)
|
||||
// If the rows we are copying has more columns than the current table, then append then needed columns to the grid
|
||||
if (colsToAdd > 0)
|
||||
{
|
||||
// Since we're pasting an entire row, make sure the current selection includes
|
||||
// all the columns to ensure proper logic path when inserting a new (empty) row
|
||||
this.SelectionMode = SelectionModeEnum.Row;
|
||||
this.Select(this.Selection.r1, 0, this.Selection.r2, this.Cols.Count - 1, true);
|
||||
this.SelectionMode = SelectionModeEnum.Default;
|
||||
// get row/column starting position in which new rows will be added
|
||||
int startrow = this.Selection.r1 + ((pp == enmPastePos.After) ? 1 : 0);
|
||||
int startcol = this.Selection.c1;
|
||||
// get the number of rows needed based on what was save to the clipboard
|
||||
int numrows = Math.Max(1, (aryCellList.Count / this.Cols.Count));
|
||||
// insert that number of new rows.
|
||||
if (pp != enmPastePos.Replace) // insert new rows before or after
|
||||
for (int r = 0; r < numrows; r++)
|
||||
if (pp == enmPastePos.After) // create new rows after
|
||||
this.InsertRowAfter();
|
||||
else
|
||||
this.InsertRowBefore();
|
||||
// copy each grid cell text (aryCellList) into the newly inserted rows
|
||||
CopyTextFromCellRange(aryCellList, startrow, startcol, startrow + numrows - 1, startcol + this.Cols.Count - 1);
|
||||
this.AdjustGridControlSize();
|
||||
Cols.Add(colsToAdd);
|
||||
AdjustMergedColumns(Cols.Count - 1, false, false);
|
||||
}
|
||||
|
||||
switch (pp)
|
||||
{
|
||||
case enmPastePos.Before:
|
||||
//this.Rows.InsertRange(Selection.r1,rowsToAdd);
|
||||
this.Rows.InsertRange(selR1, rowsToAdd);
|
||||
AdjustMergedRows(selR1, true, false);
|
||||
break;
|
||||
case enmPastePos.After:
|
||||
if (selR1 < Rows.Count - 1)
|
||||
{
|
||||
//this.Rows.InsertRange(Selection.r1 + 1, rowsToAdd);
|
||||
this.Rows.InsertRange(selR1 + 1, rowsToAdd);
|
||||
}
|
||||
else
|
||||
this.Rows.Add(rowsToAdd);
|
||||
AdjustMergedRows(selR1 + 1, false, false);
|
||||
break;
|
||||
case enmPastePos.Replace:
|
||||
if (rowsToAdd > Rows.Count - Selection.r1)
|
||||
{
|
||||
this.Rows.Add(rowsToAdd - (Rows.Count - Selection.r1));
|
||||
AdjustMergedRows(selR1, false, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
RemoveMergedRanges(MyCopyInfo.MyCopiedCellRange.r1 + rowOffset, MyCopyInfo.MyCopiedCellRange.c1, MyCopyInfo.MyCopiedCellRange.r2 + rowOffset, MyCopyInfo.MyCopiedCellRange.c2);
|
||||
|
||||
for (int r = MyCopyInfo.MyCopiedCellRange.r1; r <= MyCopyInfo.MyCopiedCellRange.r2; r++)
|
||||
{
|
||||
Rows[r + rowOffset].Height = MyCopyInfo.MyCopiedFlexGrid.Rows[r].Height;
|
||||
for (int c = MyCopyInfo.MyCopiedCellRange.c1; c <= Math.Min(MyCopyInfo.MyCopiedCellRange.c2 + colsToAdd, Cols.Count - 1); c++)
|
||||
{
|
||||
CellRange crm = MyCopyInfo.MyCopiedFlexGrid.GetMergedRange(r, c);
|
||||
if (r == crm.r1 && c == crm.c1)
|
||||
{
|
||||
Cols[c].Width = Math.Max(Cols[c].Width, MyCopyInfo.MyCopiedFlexGrid.Cols[c].Width);
|
||||
CellRange cr = GetCellRange(crm.r1 + rowOffset, crm.c1, crm.r2 + rowOffset, crm.c2);
|
||||
if ((crm.r2 > crm.r1) || (crm.c2 > crm.c1))
|
||||
MergedRanges.Add(cr);
|
||||
this[r + rowOffset, c] = MyCopyInfo.MyCopiedFlexGrid[r, c];
|
||||
MatchStyle(crm, cr);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.AdjustGridControlSize();
|
||||
}
|
||||
|
||||
public void ClipBoardPasteColumns(enmPastePos pp)
|
||||
{
|
||||
// Get a list of strings representing the text (rtf text) in each cell
|
||||
// that was saved to the clipboard (row/column order)
|
||||
ArrayList aryCellList = _clpbrdCpyPste.Get();
|
||||
private void MatchStyle(CellRange crm, CellRange cr)
|
||||
{
|
||||
if (crm.Style != null)
|
||||
{
|
||||
ChangeCellAlign(cr, crm.Style.TextAlign);
|
||||
ChangeCellBorder(cr, crm.Style.Border.Style);
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// cr.Style = null; // - didn't like the null
|
||||
//}
|
||||
}
|
||||
|
||||
if (aryCellList != null && aryCellList.Count > 0)
|
||||
private void RemoveMergedRanges(int r1, int c1, int r2, int c2)
|
||||
{
|
||||
for (int r = r1; r <= r2; r++)
|
||||
for (int c = c1; c <= c2; c++)
|
||||
{
|
||||
CellRange cr = GetMergedRange(r, c);
|
||||
if (cr.r1 < cr.r2 || cr.c1 < cr.c2)
|
||||
MergedRanges.Remove(cr);
|
||||
}
|
||||
}
|
||||
|
||||
public void PasteColumns(enmPastePos pp)
|
||||
{
|
||||
if (MyCopyInfo.MyCopiedFlexGrid == null || MyCopyInfo.MyCopyOption != GridCopyOption.Column) return;
|
||||
|
||||
int colsToAdd = MyCopyInfo.MyCopiedCellRange.c2 - MyCopyInfo.MyCopiedCellRange.c1 + 1;
|
||||
int rowsToAdd = Math.Max((MyCopyInfo.MyCopiedCellRange.r2 - MyCopyInfo.MyCopiedCellRange.r1 + 1) - Rows.Count, 0);
|
||||
int colOffset = Selection.c1 + (pp == enmPastePos.After ? 1 : 0) - MyCopyInfo.MyCopiedCellRange.c1;
|
||||
int selC1 = Selection.c1;
|
||||
|
||||
// If the columns we are copying has more rows than the current table, then append the needed rows to the grid
|
||||
if (rowsToAdd > 0)
|
||||
{
|
||||
// Since we're pasting an entire column, make sure the current selection includes
|
||||
// all the rows to ensure proper logic path when inserting a new (empty) column
|
||||
this.SelectionMode = SelectionModeEnum.Column;
|
||||
this.Select(0, this.Selection.c1, this.Rows.Count - 1, this.Selection.c2, true);
|
||||
this.SelectionMode = SelectionModeEnum.Default;
|
||||
// get row/column starting position in which new rows will be added
|
||||
int startrow = 0;//grd.Selection.r1+((pp == enmPastePos.After) ? 1 : 0);
|
||||
int startcol = this.Selection.c1 + ((pp == enmPastePos.After) ? 1 : 0);
|
||||
// get the number of columns needed based on what was save to the clipboard
|
||||
int numcols = Math.Max(1, (aryCellList.Count / this.Rows.Count));
|
||||
// insert that number of new columns.
|
||||
if (pp != enmPastePos.Replace) // insert new columns before or after
|
||||
for (int c = 0; c < numcols; c++)
|
||||
if (pp == enmPastePos.After) // create new columns after
|
||||
this.InsertColumnAfter();
|
||||
else
|
||||
this.InsertColumnBefore();
|
||||
// copy each grid cell text (aryCellList) into the newly inserted colmns
|
||||
this.CopyTextFromCellRange(aryCellList, startrow, startcol, startrow + this.Rows.Count - 1, startcol + numcols - 1);
|
||||
this.AdjustGridControlSize();
|
||||
Rows.Add(rowsToAdd);
|
||||
AdjustMergedRows(Rows.Count, false, false);
|
||||
}
|
||||
|
||||
switch (pp)
|
||||
{
|
||||
case enmPastePos.Before:
|
||||
//this.Cols.InsertRange(Selection.c1, colsToAdd);
|
||||
this.Cols.InsertRange(selC1, colsToAdd);
|
||||
AdjustMergedColumns(selC1, true, false);
|
||||
break;
|
||||
case enmPastePos.After:
|
||||
//if (Selection.c1 < Cols.Count - 1)
|
||||
// this.Cols.InsertRange(Selection.c1 + 1, colsToAdd);
|
||||
if (selC1 < Cols.Count - 1)
|
||||
this.Cols.InsertRange(selC1 + 1, colsToAdd);
|
||||
else
|
||||
this.Cols.Add(colsToAdd);
|
||||
AdjustMergedColumns(selC1 + 1, false, false);
|
||||
break;
|
||||
case enmPastePos.Replace:
|
||||
//if (colsToAdd > Cols.Count - Selection.c1)
|
||||
// this.Cols.Add(colsToAdd - (Cols.Count - Selection.c1));
|
||||
if (colsToAdd > Cols.Count - selC1)
|
||||
{
|
||||
this.Cols.Add(colsToAdd - (Cols.Count - selC1));
|
||||
AdjustMergedColumns(selC1, true, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
RemoveMergedRanges(MyCopyInfo.MyCopiedCellRange.r1, MyCopyInfo.MyCopiedCellRange.c1 + colOffset, MyCopyInfo.MyCopiedCellRange.r2, MyCopyInfo.MyCopiedCellRange.c2 + colOffset);
|
||||
|
||||
for (int c = MyCopyInfo.MyCopiedCellRange.c1; c <= MyCopyInfo.MyCopiedCellRange.c2; c++)
|
||||
{
|
||||
Cols[c + colOffset].Width = MyCopyInfo.MyCopiedFlexGrid.Cols[c].Width;
|
||||
for (int r = MyCopyInfo.MyCopiedCellRange.r1; r <= Math.Min(MyCopyInfo.MyCopiedCellRange.r2 + rowsToAdd, Rows.Count - 1); r++)
|
||||
{
|
||||
CellRange crm = MyCopyInfo.MyCopiedFlexGrid.GetMergedRange(r, c);
|
||||
if (r == crm.r1 && c == crm.c1)
|
||||
{
|
||||
Rows[r].Height = Math.Max(Rows[r].Height, MyCopyInfo.MyCopiedFlexGrid.Rows[r].Height);
|
||||
CellRange cr = GetCellRange(crm.r1, crm.c1 + colOffset, crm.r2, crm.c2 + colOffset);
|
||||
if ((crm.r2 > crm.r1) || (crm.c2 > crm.c1))
|
||||
MergedRanges.Add(cr);
|
||||
this[r, c + colOffset] = MyCopyInfo.MyCopiedFlexGrid[r, c];
|
||||
MatchStyle(crm, cr);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.AdjustGridControlSize();
|
||||
}
|
||||
|
||||
public void ClipBoardPasteIntoSelection()
|
||||
{
|
||||
// Get a list of strings representing the text (rtf text) in each cell
|
||||
// that was saved to the clipboard (row/column order)
|
||||
ArrayList aryCellList = _clpbrdCpyPste.Get();
|
||||
public void PasteCopiedCells()
|
||||
{
|
||||
// Warn the user that this type of paste will replace the currently selected (highlighted) table cells and give the option to abort.
|
||||
DialogResult dr = MessageBox.Show("This will replace the cells that are currently selected (highlighted). \n\nContinue with the paste?","Paste Table Cells",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
|
||||
if (dr == DialogResult.No) return;
|
||||
|
||||
if (aryCellList != null && aryCellList.Count > 0)
|
||||
{
|
||||
// copy each grid cell text (aryCellList) into the selected cells
|
||||
this.CopyTextFromCellRange(aryCellList, this.Selection.r1, this.Selection.c1, this.Selection.r2, this.Selection.c2);
|
||||
this.AdjustGridControlSize();
|
||||
}
|
||||
}
|
||||
int nSelRows = Selection.r2 - Selection.r1 + 1;
|
||||
int nSelCols = Selection.c2 - Selection.c1 + 1;
|
||||
int nCpyRows = MyCopyInfo.MyCopiedCellRange.r2 - MyCopyInfo.MyCopiedCellRange.r1 + 1;
|
||||
int nCpyCols = MyCopyInfo.MyCopiedCellRange.c2 - MyCopyInfo.MyCopiedCellRange.c1 + 1;
|
||||
int colsToAdd = Math.Max(nCpyCols - nSelCols, 0);
|
||||
int rowsToAdd = Math.Max(nCpyRows - nSelRows, 0);
|
||||
int rowOffset = Selection.r1 - MyCopyInfo.MyCopiedCellRange.r1;
|
||||
int colOffset = Selection.c1 - MyCopyInfo.MyCopiedCellRange.c1;
|
||||
int selR2 = Selection.r2;
|
||||
int selC2 = Selection.c2;
|
||||
// If there are more cells to copy than what is seleceted in the target table
|
||||
// Add extra rows and columns as needed
|
||||
if (rowsToAdd > 0)
|
||||
{
|
||||
if (selR2 < Rows.Count - 1)
|
||||
this.Rows.InsertRange(selR2 + 1, rowsToAdd);
|
||||
else
|
||||
this.Rows.Add(rowsToAdd);
|
||||
AdjustMergedRows(selR2 + 1, false, false);
|
||||
}
|
||||
|
||||
#endregion //Clipboard
|
||||
#region Selection
|
||||
if (colsToAdd > 0)
|
||||
{
|
||||
if (selC2 < Cols.Count - 1)
|
||||
this.Cols.InsertRange(selC2 + 1, colsToAdd);
|
||||
else
|
||||
this.Cols.Add(colsToAdd);
|
||||
AdjustMergedColumns(selC2 + 1, false, false);
|
||||
}
|
||||
|
||||
RemoveMergedRanges(MyCopyInfo.MyCopiedCellRange.r1 + rowOffset, MyCopyInfo.MyCopiedCellRange.c1 + colOffset, MyCopyInfo.MyCopiedCellRange.r2 + rowOffset, MyCopyInfo.MyCopiedCellRange.c2 + colOffset);
|
||||
|
||||
for (int c = MyCopyInfo.MyCopiedCellRange.c1; c <= Math.Min(MyCopyInfo.MyCopiedCellRange.c2, Cols.Count - 1 - colOffset); c++)
|
||||
Cols[c + colOffset].Width = Math.Max(MyCopyInfo.MyCopiedFlexGrid.Cols[c].Width, Cols[c + colOffset].Width);
|
||||
|
||||
for (int r = MyCopyInfo.MyCopiedCellRange.r1; r <= Math.Min(MyCopyInfo.MyCopiedCellRange.r2, Rows.Count - 1 - rowOffset); r++)
|
||||
{
|
||||
Rows[r + rowOffset].Height = Math.Max(MyCopyInfo.MyCopiedFlexGrid.Rows[r].Height, Rows[r + rowOffset].Height);
|
||||
for (int c = MyCopyInfo.MyCopiedCellRange.c1; c <= Math.Min(MyCopyInfo.MyCopiedCellRange.c2, Cols.Count - 1 - colOffset); c++)
|
||||
{
|
||||
CellRange crm = MyCopyInfo.MyCopiedFlexGrid.GetMergedRange(r, c);
|
||||
if (r == crm.r1 && c == crm.c1)
|
||||
{
|
||||
CellRange cr = GetCellRange(crm.r1 + rowOffset, crm.c1 + colOffset, crm.r2 + rowOffset, crm.c2 + colOffset);
|
||||
if ((crm.r2 > crm.r1) || (crm.c2 > crm.c1))
|
||||
MergedRanges.Add(cr);
|
||||
this[r + rowOffset, c + colOffset] = MyCopyInfo.MyCopiedFlexGrid[r, c];
|
||||
MatchStyle(crm, cr);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.AdjustGridControlSize();
|
||||
}
|
||||
|
||||
#endregion // Copy/Paste
|
||||
#region Selection
|
||||
public bool SelectNextCell()
|
||||
{
|
||||
int r = this.Row;
|
||||
@@ -3331,8 +3490,29 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowMySelection()
|
||||
{
|
||||
int r1 = MySelection[0].r1;
|
||||
int r2 = MySelection[0].r2;
|
||||
int c1 = MySelection[0].c1;
|
||||
int c2 = MySelection[0].c2;
|
||||
foreach (CellRange cr in MySelection)
|
||||
{
|
||||
r1 = Math.Min(r1, cr.r1);
|
||||
c1 = Math.Min(c1, cr.c1);
|
||||
r2 = Math.Max(r2, cr.r2);
|
||||
c2 = Math.Max(c2, cr.c2);
|
||||
}
|
||||
Select(r1,c1,r2,c2);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// This is used for storing the grid selection for copy/past Row/Column
|
||||
/// </summary>
|
||||
public enum GridCopyOption { Row, Column, Selection };
|
||||
|
||||
#region RTF Class for Cell rendering
|
||||
class RTF : StepRTB //RichTextBox
|
||||
{
|
||||
@@ -3741,7 +3921,8 @@ namespace Volian.Controls.Library
|
||||
class TableClipBoardFuncts
|
||||
{
|
||||
DataFormats.Format dfmtTableCellRange = DataFormats.GetFormat("TableCellRange");
|
||||
|
||||
private SelectedTableCells mySeldTableCellsObject;
|
||||
private DataObject myDataObject;
|
||||
public TableClipBoardFuncts()
|
||||
{
|
||||
//mySeldTableCellsObject = new DataObject(dfmtTableCellRange.Name, seldTableCells);
|
||||
@@ -3754,6 +3935,18 @@ namespace Volian.Controls.Library
|
||||
// This is saved as one RTF string.
|
||||
Clipboard.SetDataObject(cr.Clip, true); // the "true" make the copy persistent
|
||||
//Console.WriteLine("\nClip: '{0}' \n'{1}'", cr.Clip,cr.DataDisplay);
|
||||
//mySeldTableCellsObject = new SelectedTableCells();
|
||||
//mySeldTableCellsObject.CpbrdCellRange = cr;
|
||||
// myDataObject = new DataObject(dfmtTableCellRange.Name, mySeldTableCellsObject);
|
||||
// try
|
||||
// {
|
||||
// Clipboard.SetDataObject(myDataObject); //,true);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine(ex.Message);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
public ArrayList Get()
|
||||
@@ -3764,6 +3957,27 @@ namespace Volian.Controls.Library
|
||||
return GetCellStrings(jj);
|
||||
}
|
||||
|
||||
//public CellRange get_cr_Paste()
|
||||
//{
|
||||
// mySeldTableCellsObject = new SelectedTableCells();
|
||||
// CellRange cr = new CellRange();
|
||||
// SelectedTableCells sc;
|
||||
// IDataObject myRetrievedObject = Clipboard.GetDataObject();
|
||||
// try
|
||||
// {
|
||||
// //object obj = myRetrievedObject.GetData(dfmtTableCellRange.Name);
|
||||
// object obj = myRetrievedObject.GetData("TableCellRange");
|
||||
// //sc = (SelectedTableCells)myRetrievedObject.GetData(dfmtTableCellRange.Name);
|
||||
// sc = (SelectedTableCells)obj;
|
||||
// cr = sc.CpbrdCellRange;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine(ex.Message);
|
||||
// }
|
||||
// return cr;
|
||||
//}
|
||||
|
||||
private ArrayList GetCellStrings(string instr)
|
||||
{
|
||||
// The table cells placed on the clipboard is saved as one long RTF string.
|
||||
@@ -3886,4 +4100,43 @@ namespace Volian.Controls.Library
|
||||
_Text = text;
|
||||
}
|
||||
}
|
||||
public class GridCopyInfo
|
||||
{
|
||||
private int _Bozo = 5;
|
||||
[XmlIgnore]
|
||||
public int Bozo
|
||||
{
|
||||
get { return _Bozo; }
|
||||
set { _Bozo = value; }
|
||||
}
|
||||
|
||||
private GridCopyOption _MyCopyOption = GridCopyOption.Selection;
|
||||
|
||||
public GridCopyOption MyCopyOption
|
||||
{
|
||||
get { return _MyCopyOption; }
|
||||
set
|
||||
{
|
||||
Console.WriteLine("MyCopyOption = {0}", _MyCopyOption);
|
||||
if (_MyCopyOption != value)
|
||||
Console.WriteLine("Changed Option to {0}", value);
|
||||
_MyCopyOption = value;
|
||||
}
|
||||
}
|
||||
private VlnFlexGrid _MyCopiedFlexGrid = null;
|
||||
|
||||
public VlnFlexGrid MyCopiedFlexGrid
|
||||
{
|
||||
get { return _MyCopiedFlexGrid; }
|
||||
set { _MyCopiedFlexGrid = value; }
|
||||
}
|
||||
private CellRange _MyCopiedCellRange;
|
||||
|
||||
public CellRange MyCopiedCellRange
|
||||
{
|
||||
get { return _MyCopiedCellRange; }
|
||||
set { _MyCopiedCellRange = value; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user