public HighlightedRange(GridVirtual grid) { mGrid = grid; Grid.RangePaint += new RangePaintEventHandler(Grid_RangePaint); Region = new RangeRegion(); }
/// <summary> /// Constructor /// </summary> /// <param name="gridContainer"></param> /// <param name="containerType"></param> public GridSubPanelBase(GridVirtual gridContainer, GridSubPanelType containerType) { ContainerType = containerType; toolTip = new System.Windows.Forms.ToolTip(); ToolTipText = ""; m_GridContainer = gridContainer; }
public GridSubPanel(GridVirtual gridContainer, GridSubPanelType containerType) : base(gridContainer, containerType) { AllowDrop = true; //to remove flicker and use custom draw SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.SupportsTransparentBackColor, true); SetStyle(ControlStyles.ContainerControl, true); SetStyle(ControlStyles.Selectable, false); m_ControlsRepository = new ControlsRepository(this); TabStop = false; //The grid control is a special control and usually don't receive the focus with the Tab }
public RowsBase(GridVirtual grid) { mGrid = grid; m_HiddenRowsCoordinator = new StandardHiddenRowCoordinator(this); }
public GridSubPanelHidden(GridVirtual gridContainer) : base(gridContainer, GridSubPanelType.Hidden) { SetStyle(ControlStyles.Selectable, true); TabStop = true; }
private static int GetVisibleColumnCount(GridVirtual sourceGrid, Range sourceRange) { int visibleCount = 0; for (int c = sourceRange.Start.Column; c <= sourceRange.End.Column; c++) { if (sourceGrid.Columns.IsColumnVisible(c)) visibleCount++; } return visibleCount; }
/// <summary> /// Returns the Range struct from the specific instance /// </summary> /// <param name="p_Grid"></param> /// <returns></returns> public Range GetRange(GridVirtual p_Grid) { if (p_Grid.Columns.Count >= p_Grid.FixedColumns) return new Range(0, 0, p_Grid.Rows.Count-1, p_Grid.FixedColumns); else return Range.Empty; }
void Grid_RangePaint(GridVirtual sender, RangePaintEventArgs e) { DrawHighlight(e.GraphicsCache, e.DrawingRange); }
/// <summary> /// Calculate the destination range for the drop or paste operations. /// </summary> /// <param name="destinationGrid"></param> /// <param name="dropDestination"></param> /// <returns></returns> 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; }
public ColumnsSimpleBase(GridVirtual grid):base(grid) { mColumnWidth = grid.DefaultWidth; }
public RangeData(GridVirtual mSourceGrid) : this() { this.mSourceGrid = mSourceGrid; }
public void LoadData(GridVirtual sourceGrid, Range sourceRange, Position startDragPosition, CutMode cutMode) { LoadData(sourceGrid, sourceRange, Position.Empty, cutMode); }
/// <summary> /// Convert a range and an array of string into a string. Normally using a tab delimited for columns and a LineFeed for rows. /// </summary> /// <returns></returns> protected static string[,] DataToStringArray(GridVirtual sourceGrid, Range range) { int numberOfRows = range.End.Row - range.Start.Row + 1; int numberOfCols = range.End.Column - range.Start.Column + 1; string[,] values = new string[numberOfRows, numberOfCols]; int arrayRow = 0; for (int r = range.Start.Row; r <= range.End.Row; r++, arrayRow++) { int arrayCol = 0; for (int c = range.Start.Column; c <= range.End.Column; c++, arrayCol++) { String val = String.Empty; Position posCell = new Position(r, c); Cells.ICellVirtual cell = sourceGrid.GetCell(posCell); CellContext cellContext = new CellContext(sourceGrid, posCell, cell); if (cell != null && cell.Editor != null && cell.Editor.IsStringConversionSupported()) values[arrayRow, arrayCol] = cell.Editor.ValueToString(cell.Model.ValueModel.GetValue(cellContext)); else if (cell != null) values[arrayRow, arrayCol] = cellContext.DisplayText; } } return values; }
/// <summary> /// Write the current loaded array string in the specified grid range. This method use the cell editor to set the value. /// </summary> public void WriteData(GridVirtual sourceGrid, Position destinationPosition) { int sourceRow = this.SourceValues.GetUpperBound(0) ; int sourceColumn = this.SourceValues.GetUpperBound(1); var dataRow = 0; for (int r = destinationPosition.Row; r <= destinationPosition.Row + sourceRow; r++) { int dataColumn = 0; for (int c = destinationPosition.Column; c <= destinationPosition.Column + sourceColumn; c++) { Position posCell = new Position(r, c); Cells.ICellVirtual cell = sourceGrid.GetCell(posCell); CellContext cellContext = new CellContext(sourceGrid, posCell, cell); if (cell != null && cell.Editor != null && mSourceValues[dataRow, dataColumn] != null) cell.Editor.SetCellValue(cellContext, mSourceValues[dataRow, dataColumn] ); dataColumn++; } dataRow++; } /*int sourceRow = this.SourceValues.Length - 1; int sourceColumn = this.SourceValues.Rank - 1; //Calculate the destination Range merging the source range var destinationRange = new Range(destinationPosition, new Position(destinationPosition.Row + sourceRow, destinationPosition.Column + sourceColumn)); Range newRange = mSourceRange; newRange.MoveTo(destinationRange.Start); if (newRange.End.Column > destinationRange.End.Column) newRange.End = new Position(newRange.End.Row, destinationRange.End.Column); if (newRange.End.Row > destinationRange.End.Row) newRange.End.Row = destinationRange.End.Row; for (int r = newRange.Start.Row; r <= newRange.End.Row; r++) { int dataColumn = 0; for (int c = newRange.Start.Column; c <= newRange.End.Column ; c++) { //if (sourceGrid.Columns.IsColumnVisible(c) == false) // continue; Position posCell = new Position(r, c); Cells.ICellVirtual cell = sourceGrid.GetCell(posCell); CellContext cellContext = new CellContext(sourceGrid, posCell, cell); if (cell != null && cell.Editor != null && mSourceValues[r - newRange.Start.Row, dataColumn] != null) cell.Editor.SetCellValue(cellContext, mSourceValues[r - newRange.Start.Row, dataColumn] ); dataColumn++; } }*/ }
/// <summary> /// Load the data from a Tab delimited string of data. Each column is separated by a Tab and each row by a LineFeed character. /// </summary> public void LoadData(string data) { mSourceGrid = null; StringToData(data, out mSourceRange, out mSourceValues); mClipboardDataObject = new System.Windows.Forms.DataObject(); mClipboardDataObject.SetData(RANGEDATA_FORMAT, this); mClipboardDataObject.SetData(typeof(string), StringArrayToString(mSourceValues as string[,])); }
public ColumnsBase(GridVirtual grid) { mGrid = grid; }
/// <summary> /// Load the specified range data into a string array. This method use the cell editor to get the value. /// </summary> /// <param name="sourceGrid"></param> /// <param name="sourceRange"></param> /// <param name="startDragPosition">Starting drag position. Used only for calculating drop destination range.</param> /// <param name="cutMode">Cut mode. Can be used to remove the data from the source when pasting it to the destination or immediately.</param> public void LoadData(GridVirtual sourceGrid, Range sourceRange, Position startDragPosition, CutMode cutMode) { mSourceGrid = sourceGrid; mCutMode = cutMode; mStartDragPosition = startDragPosition; mSourceRange = sourceRange; mSourceValues = new string[mSourceRange.RowsCount, mSourceRange.ColumnsCount]; int arrayRow = 0; for (int r = mSourceRange.Start.Row; r <= mSourceRange.End.Row; r++, arrayRow++) { int arrayCol = 0; for (int c = mSourceRange.Start.Column; c <= mSourceRange.End.Column; c++, arrayCol++) { Position posCell = new Position(r, c); Cells.ICellVirtual cell = sourceGrid.GetCell(posCell); CellContext cellContext = new CellContext(sourceGrid, posCell, cell); if (cell != null && cell.Editor != null && cell.Editor.IsStringConversionSupported()) mSourceValues[arrayRow, arrayCol] = cell.Editor.ValueToString( cell.Model.ValueModel.GetValue(cellContext) ); else if (cell != null) mSourceValues[arrayRow, arrayCol] = cellContext.DisplayText; } } //Cut Data if (CutMode == CutMode.CutImmediately && sourceGrid != null) { sourceGrid.ClearValues(new RangeRegion(sourceRange)); //for (int sr = sourceRange.Start.Row; sr <= sourceRange.End.Row; sr++) // for (int sc = sourceRange.Start.Column; sc <= sourceRange.End.Column; sc++) // { // Position pos = new Position(sr, sc); // Cells.ICellVirtual cell = sourceGrid.GetCell(sr, sc); // CellContext cellContext = new CellContext(sourceGrid, pos, cell); // if (cell.Editor != null) // cell.Editor.ClearCell(cellContext); // } } mClipboardDataObject = new System.Windows.Forms.DataObject(); mClipboardDataObject.SetData(RANGEDATA_FORMAT, this); mClipboardDataObject.SetData(typeof(string), DataToString(mSourceValues, mSourceRange)); }
public RangePaintEventArgs(GridVirtual grid, DevAge.Drawing.GraphicsCache graphicsCache, Range drawingRange) { mGrid = grid; mGraphicsCache = graphicsCache; mDrawingRange = drawingRange; }
/// <summary> /// Load the data from a Tab delimited string of data. Each column is separated by a Tab and each row by a LineFeed character. /// </summary> public void LoadData(string data) { mSourceGrid = null; mCutMode = CutMode.None; mStartDragPosition = new Position(0, 0); StringToData(data, out mSourceRange, out mSourceValues); mClipboardDataObject = new System.Windows.Forms.DataObject(); mClipboardDataObject.SetData(RANGEDATA_FORMAT, this); mClipboardDataObject.SetData(typeof(string), DataToString(mSourceValues, mSourceRange)); }
/// <summary> /// Returns the Range struct from the specific instance /// </summary> /// <param name="p_Grid"></param> /// <returns></returns> public Range GetRange(GridVirtual p_Grid) { return p_Grid.CompleteRange; }
/// <summary> /// Constructor /// </summary> /// <param name="pGridVirtual"></param> /// <param name="pPosition"></param> /// <param name="pCell"></param> public CellContext(GridVirtual pGridVirtual, Position pPosition, Cells.ICellVirtual pCell) { Position = pPosition; Cell = pCell; Grid = pGridVirtual; }
/// <summary> /// Returns the Range struct from the specific instance /// </summary> /// <param name="p_Grid"></param> /// <returns></returns> public virtual Range GetRange(GridVirtual p_Grid) { return mRange; }
public RowsSimpleBase(GridVirtual grid):base(grid) { mRowHeight = grid.DefaultHeight; }
/// <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] ); } } }
/// <summary> /// Load the specified range data into a string array. This method use the cell editor to get the value. /// </summary> /// <param name="sourceGrid"></param> /// <param name="sourceRange"></param> /// <param name="cutMode">Cut mode. Can be used to remove the data from the source when pasting it to the destination or immediately.</param> public static RangeData LoadData(GridVirtual sourceGrid, Range sourceRange, CutMode cutMode) { RangeData data = new RangeData(sourceGrid); //mCutMode = cutMode; data.mSourceRange= sourceRange; data.mSourceValues = new object[sourceRange.RowsCount, GetVisibleColumnCount(sourceGrid, sourceRange)]; int arrayRow = 0; for (int r = sourceRange.Start.Row; r <= sourceRange.End.Row; r++, arrayRow++) { int arrayCol = 0; for (int c = sourceRange.Start.Column; c <= sourceRange.End.Column; c++) { if (sourceGrid.Columns.IsColumnVisible(c) == false) continue; Position posCell = new Position(r, c); Cells.ICellVirtual cell = sourceGrid.GetCell(posCell); CellContext cellContext = new CellContext(sourceGrid, posCell, cell); /*if (cell != null && cell.Editor != null && cell.Editor.IsStringConversionSupported()) data.mSourceValues[arrayRow, arrayCol] = cell.Editor.ValueToString( cell.Model.ValueModel.GetValue(cellContext) ); else if (cell != null) data.mSourceValues[arrayRow, arrayCol] = cellContext.DisplayText;*/ if (cell != null) data.mSourceValues[arrayRow, arrayCol] = cellContext.Value; arrayCol++; } } //Cut Data if (cutMode == CutMode.CutImmediately && sourceGrid != null) { sourceGrid.ClearValues(new RangeRegion(sourceRange)); } data.mClipboardDataObject = new System.Windows.Forms.DataObject(); data.mClipboardDataObject.SetData(RANGEDATA_FORMAT, data); string[,] values = DataToStringArray(sourceGrid, data.mSourceRange); data.mClipboardDataObject.SetData(typeof(string), StringArrayToString(values)); return data; }
/// <summary> /// Constructor /// </summary> /// <param name="pGridVirtual"></param> /// <param name="pPosition"></param> public CellContext(GridVirtual pGridVirtual, Position pPosition) { Position = pPosition; Grid = pGridVirtual; Cell = Grid.GetCell(Position); }
/// <summary> /// Constructor /// </summary> /// <param name="p_Grid"></param> public ColumnInfo(GridVirtual p_Grid) { m_Grid = p_Grid; m_width = Grid.DefaultWidth; }
/// <summary> /// Constructor /// </summary> /// <param name="grid"></param> public ColumnInfoCollection(GridVirtual grid):base(grid) { }
/// <summary> /// Constructor /// </summary> /// <param name="p_Grid"></param> public RowInfo(GridVirtual p_Grid) { m_Grid = p_Grid; m_Height = Grid.DefaultHeight; }