Render Object Shadows

In the 2009 v3 release of Reports for WinForms, support was added for shadows cast by render objects. The new public interface IShadow, is implemented by a public structure Shadow, and exposed by a non-ambient public property Shadow.

It includes the following sub-properties:

 

Property

Description

Transparency

Gets or sets the transparency of the shadow, in percent. A value of 0 defines a solid (non-transparent) shadow, a value of 100 (which is the default) defines a fully transparent (invisible) shadow.

Size

Gets or sets the size of the shadow relative to the size of the object, in percent. A value of 100 (which is the default) indicates that the shadow has the same size as the object.

Distance

Gets or sets the distance that the shadow's center is offset from the the object's center. Note that only absolute Unit values (such as "0.5in" or "4mm") can be assigned to this property. The default is 2mm.

Angle

Gets or sets the angle, in degrees, of the shadow. The angle is measured relative to the three o'clock position clockwise. The default is 45.

Color

Gets or sets the color of the shadow. The default is Black.

 

The following sample code defines a shadow on a render object:

      Visual Basic

Dim doc As C1PrintDocument = C1PrintDocument1

Dim rt As New RenderText("Sample Shadow")

rt.Width = Unit.Auto

rt.Style.Shadow.Transparency = 20

rt.Style.Shadow.Color = Color.BurlyWood

doc.Body.Children.Add(rt)

      C#

C1PrintDocument doc = c1PrintDocument1;

RenderText rt = new RenderText("Sample Shadow");

rt.Width = Unit.Auto;

rt.Style.Shadow.Transparency = 20;

rt.Style.Shadow.Color = Color.BurlyWood;

doc.Body.Children.Add(rt);

Note that while you do not need to create a Shadow object when setting shadow properties, you may choose to do so, for example, like this:

      Visual Basic

Dim doc As C1PrintDocument = C1PrintDocument1

Dim rt As New RenderText("Sample Shadow")

rt.Width = Unit.Auto

rt.Style.Shadow = New Shadow(20, 100, "1mm", 45, Color.CadetBlue)

doc.Body.Children.Add(rt)

      C#

C1PrintDocument doc = c1PrintDocument1;

RenderText rt = new RenderText("Sample Shadow");

rt.Width = Unit.Auto;

rt.Style.Shadow = new Shadow(20, 100, "1mm", 45, Color.CadetBlue);

doc.Body.Children.Add(rt);

Note: Shadows do NOT affect the objects' sizes for layout purposes.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.