Skip to main content Skip to footer

Spread Windows Forms and Camera Shapes

Spread Windows Forms supports a unique feature known as a camera shape. This allows you to create a snapshot of a range of cells and use that as a shape in the Spread control. The cell range can also contain other shapes. You can use the following steps to create a camera shape.

  1. Create a camera shape object using the SpreadCameraShape class.
  2. Specify the range of cells that will become the shape with the Formula property.
  3. Set any other shape properties.
  4. Add the camera shape to the sheet.

The following properties are available in the SpreadCameraShape class.

Property

Description

Formula

Gets or sets a string formula that indicates the captured region.

Height

Overridden. Gets or sets the height of the object.

Left

Overridden. Gets or sets the x-coordinate of the object.

Location

Overridden. Gets or sets the location of the object.

Top

Overridden. Gets or sets the y-coordinate of the object.

ShadowColor

Gets or sets the color of the shadow of the object. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSShape)

ShadowDirection

Gets or sets the direction of the shadow. Set this property to display a shadow. (Inherited fromFarPoint.Win.Spread.DrawingSpace.PSShape)

ShadowOffset

Gets or sets the amount of offset of the shadow. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSShape)

ShadowOffsetX

Gets or sets the amount of horizontal offset of the shadow of the object. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSShape)

ShadowOffsetY

Gets or sets the amount of vertical offset of the shadow of the object. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSShape)

ShapeOutlineColor

Gets or sets the shape outline color for the object. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSObject)

ShapeOutlineStyle

Gets or sets the shape outline style for the object. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSObject)

ShapeOutlineThickness

Gets or sets the shape outline thickness for the object. (Inherited from FarPoint.Win.Spread.DrawingSpace.PSObject)

Size

Overridden. Gets or sets the size of the object.

Width

Overridden. Gets or sets the width of the object.

In general, properties that apply to the interior of the shape, do not apply to the camera shape. For a complete API list, refer to the SpreadCameraShape class: http://sphelp.grapecity.com/WebHelp/SpreadNet9/WF/webframe.html#FarPoint.Win.Spread~FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape.html. For more information about built-in shapes, refer to: http://sphelp.grapecity.com/WebHelp/SpreadNet9/WF/webframe.html#spwin-shape-types.html. The following example creates a custom shape and then uses the custom shape in a camera shape. SpreadWinCameraShape Camera Shape C#

public class myShape : FarPoint.Win.Spread.DrawingSpace.CustomShape  
{  
public override void OnPaintBackground(System.Drawing.Graphics g, System.Drawing.Rectangle rectInput)  
{  
System.Drawing.Color myColor = System.Drawing.Color.FromArgb(128, 120, 20, 100);  
System.Drawing.Drawing2D.HatchBrush myBrush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Trellis,  
System.Drawing.Color.White, myColor);  
g.FillPath(myBrush, (System.Drawing.Drawing2D.GraphicsPath)this.Shape);  
}  
}  

System.Drawing.Point[] ptsRect = {  
new System.Drawing.Point(1, 1),  
new System.Drawing.Point(1, 160),  
new System.Drawing.Point(160, 160),  
new System.Drawing.Point(160, 1)  
};  

System.Drawing.Drawing2D.GraphicsPath gpath = new System.Drawing.Drawing2D.GraphicsPath();  
gpath.AddPolygon(ptsRect);  
myShape pso = new myShape();  
pso.Shape = gpath;  
fpSpread1.ActiveSheet.AddShape(pso, 10, 2);  
fpSpread1.ActiveSheet.Cells[10, 1].Text = "Shape";  
FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape camera = new FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape();  
camera.Formula = "B10:D15";  
camera.Location = new System.Drawing.Point(10, 40);  
fpSpread1.ActiveSheet.AddShape(camera);  

VB

Public Class myShape  
Inherits FarPoint.Win.Spread.DrawingSpace.CustomShape  
Public Overrides Sub OnPaintBackground(ByVal g As System.Drawing.Graphics, ByVal rectInput As System.Drawing.Rectangle)  
Dim myColor As Color = Color.FromArgb(128, 120, 20, 100)  
Dim myBrush As System.Drawing.Drawing2D.HatchBrush = New System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Trellis,  
Color.White, myColor)  
g.FillPath(myBrush,  
CType(Me.Shape, System.Drawing.Drawing2D.GraphicsPath))  
End Sub  
End Class  

Dim ptsRect() As Point = {  
New Point(1, 1),  
New Point(1, 160),  
New Point(160, 160),  
New Point(160, 1)  
}  

Dim gpath As System.Drawing.Drawing2D.GraphicsPath = New System.Drawing.Drawing2D.GraphicsPath  
gpath.AddPolygon(ptsRect)  
Dim pso As New myShape  
pso.Shape = gpath  
FpSpread1.ActiveSheet.AddShape(pso, 10, 2)  
FpSpread1.ActiveSheet.Cells(10, 1).Text = "Shape"  
Dim camera As New FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape()  
camera.Formula = "B10:D15"  
camera.Location = New System.Drawing.Point(10, 40)  
FpSpread1.ActiveSheet.AddShape(camera)  

This example uses a built-in shape in the camera shape. C#

FarPoint.Win.Spread.DrawingSpace.LightningBoltShape ls = new FarPoint.Win.Spread.DrawingSpace.LightningBoltShape();  
ls.BackColor = System.Drawing.Color.DarkTurquoise;  
fpSpread1.ActiveSheet.AddShape(ls, 10, 2);  
fpSpread1.ActiveSheet.Cells[10, 1].Text = "Shape";  
FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape camera = new FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape();  
camera.Formula = "B10:D18";  
camera.ShadowColor = System.Drawing.Color.Red;  
camera.ShadowDirection = FarPoint.Win.Spread.DrawingSpace.ShadowDirection.Right;  
camera.ShapeOutlineStyle = System.Drawing.Drawing2D.DashStyle.Dot;  
camera.ShapeOutlineThickness = 2;  
camera.ShapeOutlineColor = System.Drawing.Color.Fuchsia;  
camera.Location = new System.Drawing.Point(10, 40);  
fpSpread1.ActiveSheet.AddShape(camera);  

VB

Dim ls As New FarPoint.Win.Spread.DrawingSpace.LightningBoltShape()  
ls.BackColor = System.Drawing.Color.DarkTurquoise  
FpSpread1.ActiveSheet.AddShape(ls, 10, 2)  
FpSpread1.ActiveSheet.Cells(10, 1).Text = "Shape"  
Dim camera As New FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape()  
camera.Formula = "B10:D18"  
camera.ShadowColor = System.Drawing.Color.Red  
camera.ShadowDirection = FarPoint.Win.Spread.DrawingSpace.ShadowDirection.Right  
camera.ShapeOutlineStyle = System.Drawing.Drawing2D.DashStyle.Dot  
camera.ShapeOutlineThickness = 2  
camera.ShapeOutlineColor = System.Drawing.Color.Fuchsia  
camera.Location = New System.Drawing.Point(10, 40)  
FpSpread1.ActiveSheet.AddShape(camera)  

You can also use the designer to create a camera shape. SpreadWinDesignCamera Spread Designer Select a block of cells. Then from the Insert menu, select the Camera Shape icon to create a camera shape. The camera shape can include other shapes. Use the Drawing Tools menu to customize the image. The BackColor and ForeColor options under the DrawingTools menu do not apply to the camera shape. In general, properties that apply to the interior of the shape, do not apply to the camera shape. SpreadWinDesignDrawing Drawing Tools The following options are available in the DrawingTools menu:

Item

Description

BackColor

This allows you to set the backcolor for a built-in shape.

ForeColor

This allows you to set the forecolor for a built-in shape.

OutLineColor

This allows you to set the outline color of the shape.

Thickness

This allows you to change the width of the shape outline.

OutlineStyle

This allows you to set the outline border type.

DropShadow

This allows you to specify whether to have a shadow around the edges of the shape.

Bring To Front

This allows you to specify whether to place this shape over others.

Send To Back

This allows you to specify whether to place this shape behind others.

Rotate

This allows you to select typical amounts of rotation for a shape.

Flip

This allows you to flip a shape either horizontally or vertically.

Scale

This allows you to resize a shape proportionally by selecting a scaling factor.

Set Picture

This allows you to select an image and the image properties for a built-in shape.

Clear Picture

This allows you to remove an image from a built-in shape.

Nudge

The arrows to the right side of the Drawing Tools menu allow you to move the shape.

MESCIUS inc.

comments powered by Disqus