public void WriteData(GridVirtual destinationGrid, Range destinationRange)
{
//Calculate the destination Range merging the source range
Range newRange = mSourceRange;
newRange.MoveTo(destinationRange.Start);
if (newRange.ColumnsCount > destinationRange.ColumnsCount)
newRange.ColumnsCount = destinationRange.ColumnsCount;
if (newRange.RowsCount > destinationRange.RowsCount)
newRange.RowsCount = destinationRange.RowsCount;
//Cut Data
if (CutMode == CutMode.CutOnPaste && mSourceGrid != null)
{
for (int sr = mSourceRange.Start.Row; sr <= mSourceRange.End.Row; sr++)
for (int sc = mSourceRange.Start.Column; sc <= mSourceRange.End.Column; sc++)
{
Position pos = new Position(sr, sc);
Cells.ICellVirtual cell = mSourceGrid.GetCell(sr, sc);
CellContext cellContext = new CellContext(mSourceGrid, pos, cell);
if (cell.Editor != null)
cell.Editor.ClearCell(cellContext);
}
}
int arrayRow = 0;
for (int r = newRange.Start.Row; r <= newRange.End.Row; r++, arrayRow++)
{
int arrayCol = 0;
for (int c = newRange.Start.Column; c <= newRange.End.Column; c++, arrayCol++)
{
Position posCell = new Position(r, c);
Cells.ICellVirtual cell = destinationGrid.GetCell(posCell);
CellContext cellContext = new CellContext(destinationGrid, posCell, cell);
if (cell != null && cell.Editor != null && mSourceValues[arrayRow, arrayCol] != null)
cell.Editor.SetCellValue(cellContext, mSourceValues[arrayRow, arrayCol] );
}
}
}