public MoveTo ( |
||
p_StartPosition | ||
return | void |
/// <summary> /// Write the current loaded array string in the specified grid range. This method use the cell editor to set the value. /// </summary> /// <param name="destinationGrid"></param> /// <param name="destinationRange"></param> 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]); } } } }
public Range FindDestinationRange(GridVirtual destinationGrid, Position dropDestination) { if (dropDestination.IsEmpty()) { return(Range.Empty); } Position destinationStart = new Position(dropDestination.Row + (mSourceRange.Start.Row - mStartDragPosition.Row), dropDestination.Column + (mSourceRange.Start.Column - mStartDragPosition.Column)); destinationStart = Position.Max(destinationStart, new Position(0, 0)); Range destination = mSourceRange; destination.MoveTo(destinationStart); destination = destination.Intersect(destinationGrid.CompleteRange); return(destination); }