本文整理汇总了C#中GridVirtual.RangeToSize方法的典型用法代码示例。如果您正苦于以下问题:C# GridVirtual.RangeToSize方法的具体用法?C# GridVirtual.RangeToSize怎么用?C# GridVirtual.RangeToSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridVirtual
的用法示例。
在下文中一共展示了GridVirtual.RangeToSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Export
public virtual System.Drawing.Bitmap Export(GridVirtual grid, Range rangeToExport)
{
System.Drawing.Bitmap bitmap = null;
try
{
System.Drawing.Size size = grid.RangeToSize(rangeToExport);
bitmap = new System.Drawing.Bitmap(size.Width, size.Height);
using (System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(bitmap))
{
Export(grid, graphic, rangeToExport, new System.Drawing.Point(0, 0));
}
}
catch (Exception)
{
if (bitmap != null)
{
bitmap.Dispose();
bitmap = null;
}
throw;
}
return bitmap;
}
示例2: Export
public virtual void Export(GridVirtual grid, System.Drawing.Graphics graphics,
Range rangeToExport, System.Drawing.Point destinationLocation)
{
if (rangeToExport.IsEmpty())
return;
System.Drawing.Point cellPoint = destinationLocation;
System.Drawing.Point deltaPoint = destinationLocation;
using (DevAge.Drawing.GraphicsCache graphicsCache = new DevAge.Drawing.GraphicsCache(graphics))
{
for (int r = rangeToExport.Start.Row; r <= rangeToExport.End.Row; r++)
{
int rowHeight = grid.Rows.GetHeight(r);
for (int c = rangeToExport.Start.Column; c <= rangeToExport.End.Column; c++)
{
Rectangle cellRectangle;
Position pos = new Position(r, c);
Size cellSize = new Size(grid.Columns.GetWidth(c), rowHeight);
Range range = grid.PositionToCellRange(pos);
//support for RowSpan or ColSpan
//Note: for now I draw only the merged cell at the first position
// (this can cause a problem if you export partial range that contains a partial merged cells)
if ( range.ColumnsCount > 1 || range.RowsCount > 1)
{
//Is the first position
if (range.Start == pos)
{
Size rangeSize = grid.RangeToSize(range);
cellRectangle = new Rectangle(cellPoint,
rangeSize);
}
else
cellRectangle = Rectangle.Empty;
}
else
{
cellRectangle = new Rectangle(cellPoint, cellSize);
}
if (cellRectangle.IsEmpty == false)
{
Cells.ICellVirtual cell = grid.GetCell(pos);
CellContext context = new CellContext(grid, pos, cell);
ExportCell(context, graphicsCache, cellRectangle);
}
cellPoint = new Point(cellPoint.X + cellSize.Width, cellPoint.Y);
}
cellPoint = new Point(destinationLocation.X, cellPoint.Y + rowHeight);
}
}
}