[]
        
(Showing Draft Content)

C1.WPF.Excel.XLPictureShape.-ctor

XLPictureShape Constructor

XLPictureShape(WriteableBitmap, int, int)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(WriteableBitmap img, int x, int y)
Parameters
Type Name Description
WriteableBitmap img

The image contained in the new XLPictureShape.

int x

The horizontal position of the new shape with respect to the cell, in twips.

int y

The vertical position of the new shape with respect to the cell, in twips.

Examples

The code below adds an image to a cell. The image is rendered in its original size, and is indented from the top left corner of the cell by 30 twips:

// get sheet and cell
XLSheet sheet = c1ExcelBook1.Sheets[0];
XLCell  cell  = sheet[row, col];

// build XLPictureShape
XLPictureShape pic = new XLPictureShape(image, 30, 30);

// assign XLPictureShape to cell
cell.Value = pic;

XLPictureShape(WriteableBitmap, int, int, int, int)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(WriteableBitmap img, int x, int y, int width, int height)
Parameters
Type Name Description
WriteableBitmap img

The image contained in the new XLPictureShape.

int x

The horizontal position of the image with respect to the cell, in twips.

int y

The vertical position of the image with respect to the cell, in twips.

int width

The width of the image, in twips.

int height

The height of the image, in twips.

Examples

The code below adds an image to a cell. The image is drawn within a rectangle centered on a cell with a 60 twip edge around it:

// get sheet and cell
XLSheet sheet = c1ExcelBook1.Sheets[0];
XLCell  cell  = sheet[row, col];

// calculate cell size to align picture
Rectangle rc = new Rectangle(0, 0
    sheet.Columns[col].Width, 
    sheet.Rows[row].Height);

// add 60 twip edge
rc.Inflate(-60, -60);

// build XLPictureShape
XLPictureShape pic = new XLPictureShape(image, 
    rc.X, rc.Y, rc.Width, rc.Height);

// assign XLPictureShape to cell
cell.Value = pic;

XLPictureShape(WriteableBitmap, Rect)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(WriteableBitmap img, Rect rc)
Parameters
Type Name Description
WriteableBitmap img

The image contained in the new XLPictureShape.

Rect rc

The rectangle that specifies the image size and position with respect to the cell, in twips.

Examples

The code below adds an image to a cell. The image is drawn within a rectangle centered on a cell with a 60 twip edge around it:

// get sheet and cell
XLSheet sheet = c1ExcelBook1.Sheets[0];
XLCell  cell  = sheet[row, col];

// calculate cell size to align picture
Rectangle rc = new Rectangle(0, 0
    sheet.Columns[col].Width, 
    sheet.Rows[row].Height);

// add 60 twip edge
rc.Inflate(-60, -60);

// build XLPictureShape
XLPictureShape pic = new XLPictureShape(image, rc);

// assign XLPictureShape to cell
cell.Value = pic;

XLPictureShape(WriteableBitmap)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(WriteableBitmap img)
Parameters
Type Name Description
WriteableBitmap img

The image contained in the new XLPictureShape.

XLPictureShape(WriteableBitmap, Size, HorizontalAlignment, VerticalAlignment, ImageScaling)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(WriteableBitmap img, Size cellSize, HorizontalAlignment align, VerticalAlignment valign, ImageScaling scale)
Parameters
Type Name Description
WriteableBitmap img

The WriteableBitmap contained in the new XLPictureShape.

Size cellSize

The size of the cell that will contain the image, in pixels (used for aligning the image).

HorizontalAlignment align

A HorizontalAlignment value that specifies the position of the image in the cell.

VerticalAlignment valign

A VerticalAlignment value that specifies the position of the image in the cell.

ImageScaling scale

An ImageScaling value that specifies the image scaling within the cell.

Remarks

This constructor automatically calculates the image size, position, and clipping based on the cell and image sizes and on the given alignment and scaling parameters.

XLPictureShape(XLSheet, WriteableBitmap, double, double, double, double)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(XLSheet sheet, WriteableBitmap img, double x, double y, double width, double height)
Parameters
Type Name Description
XLSheet sheet

XLSheet object that owns the new shape.

WriteableBitmap img

The image contained in the new XLPictureShape.

double x

The horizontal position of the image with respect to the sheet, in twips.

double y

The vertical position of the image with respect to the sheet, in twips.

double width

The width of the image, in twips.

double height

The height of the image, in twips.

XLPictureShape(C1Bitmap, int, int)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(C1Bitmap bmp, int x, int y)
Parameters
Type Name Description
C1Bitmap bmp

The specified bitmap object contained in the new XLPictureShape.

int x

The horizontal position of the new shape with respect to the cell, in twips.

int y

The vertical position of the new shape with respect to the cell, in twips.

XLPictureShape(C1Bitmap, int, int, int, int)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(C1Bitmap bmp, int x, int y, int width, int height)
Parameters
Type Name Description
C1Bitmap bmp

The specified bitmap object contained in the new XLPictureShape.

int x

The horizontal position of the image with respect to the cell, in twips.

int y

The vertical position of the image with respect to the cell, in twips.

int width

The width of the image, in twips.

int height

The height of the image, in twips.

XLPictureShape(C1Bitmap, Rect)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(C1Bitmap bmp, Rect rc)
Parameters
Type Name Description
C1Bitmap bmp

The specified bitmap object contained in the new XLPictureShape.

Rect rc

The rectangle that specifies the image size and position with respect to the cell, in twips.

XLPictureShape(C1Bitmap)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(C1Bitmap bmp)
Parameters
Type Name Description
C1Bitmap bmp

The specified bitmap object contained in the new XLPictureShape.

XLPictureShape(C1Bitmap, Size, HorizontalAlignment, VerticalAlignment, ImageScaling)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(C1Bitmap bmp, Size cellSize, HorizontalAlignment align, VerticalAlignment valign, ImageScaling scale)
Parameters
Type Name Description
C1Bitmap bmp

The specified bitmap object contained in the new XLPictureShape.

Size cellSize

The size of the cell that will contain the image, in pixels (used for aligning the image).

HorizontalAlignment align

A horizontal content alignment value that specifies the position of the image in the cell.

VerticalAlignment valign

A VerticalAlignment value that specifies the position of the image in the cell.

ImageScaling scale

An ImageScaling value that specifies the image scaling within the cell.

Remarks

This constructor automatically calculates the image size, position, and clipping based on the cell and image sizes and on the given alignment and scaling parameters.

XLPictureShape(XLSheet, C1Bitmap, double, double, double, double)

Initializes a new instance of an XLPictureShape.

Declaration
public XLPictureShape(XLSheet sheet, C1Bitmap bmp, double x, double y, double width, double height)
Parameters
Type Name Description
XLSheet sheet

XLSheet object that owns the new shape.

C1Bitmap bmp

The specified bitmap object contained in the new XLPictureShape.

double x

The horizontal position of the image with respect to the sheet, in twips.

double y

The vertical position of the image with respect to the sheet, in twips.

double width

The width of the image, in twips.

double height

The height of the image, in twips.