Table of Contents

Class GraphicBlock

Namespace
Sage.CRM.Blocks
Assembly
SageCRMNet.dll

Graphic Blocks are more powerful than standard static images because variables can be used in their creation. These variables may represent live data from a database or incorporate details of the current user such as their privileges or settings. Graphics created by the Graphics Block are recreated every time they are requested so, where variables are used, the graphic is based on real time data.

public class GraphicBlock : SageCrmBlock
Inheritance
GraphicBlock
Derived
Inherited Members

Constructors

GraphicBlock()

Initializes a new instance of GraphicBlock.

public GraphicBlock()

GraphicBlock(string)

Initializes a new instance of GraphicBlock.

public GraphicBlock(string blockName)

Parameters

blockName string

Block Name.

Properties

Border

Controls the thickness of the border around the image. The default value is 0.

public int Border { get; set; }

Property Value

int

Description

Specifies the description of the image. For browser users with image loading switched off, the description specified in this parameter takes its place.

public string Description { get; set; }

Property Value

string

HSpace

Controls the horizontal space above and below the image. The default value is 0.

public int HSpace { get; set; }

Property Value

int

ImageHeight

Specifies the height of the image. Dimensions in pixels. This is the height of the box in which the image is loaded. The default value is 0.

public int ImageHeight { get; set; }

Property Value

int

ImageWidth

Specifies the width of the image. Dimensions in pixels. This is the width of the box in which the image is loaded. The default value is 0.

public int ImageWidth { get; set; }

Property Value

int

SaveAsGifs

Determines whether an image should be stored as a GIF (256 colors) or a JPEG image (16m colors). If the server's display adapter is set to allow for 16m colors, this property is set to false by default, otherwise it is set to true.

public bool SaveAsGifs { get; set; }

Property Value

bool

Value

public string Value { get; set; }

Property Value

string

VSpace

Controls the vertical space above and below the image. The default value is 0.

public int VSpace { get; set; }

Property Value

int

Methods

Animation(string, string)

The Graphics Block supports animation. Frames contained in an animation can be shown at varying intervals using the Delay mode. Using 'Add', the current state of the image is saved as a frame to be shown after the specified delay. The whole animation can be looped for a definite or indefinite number of times. This animation technique can also be used for charts. The delay is specified where 100=1 second and indefinite loops can be obtained by setting the Loop valueto 0.

public bool Animation(string mode, string value)

Parameters

mode string
value string

Returns

bool

Arc(int, int, int, int, int, int, int, int)

Draws an elliptically curved line. The arc traverses the perimeter of an ellipse that is bound by the points (X1,Y1) and (X2,Y2). The arc is drawn following the perimeter of the ellipse, counter clockwise, from the starting point to the ending point. The starting point is defined by the intersection of the ellipse and a line defined by the center of the ellipse and (X3,Y3). The ending point is defined by the intersection of the ellipse and a line defined by the center of the ellipse and (X4, Y4).

public bool Arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)

Parameters

x1 int
y1 int
x2 int
y2 int
x3 int
y3 int
x4 int
y4 int

Returns

bool

Brush(string, string)

Changes the color and pattern used when drawing the background or filling in graphical shapes. The pattern can be one of a predetermined list using the Style mode or can be from an image using the Load mode.

public bool Brush(string mode, string value)

Parameters

mode string
value string

Returns

bool

Chord(int, int, int, int, int, int, int, int)

Creates a shape that is defined by an arc and a line that joins the endpoints of the arc. The chord consists of a portion of an ellipse that is bound by the points (X1,Y1) and (X2,Y2). The ellipse is bisected by a line that runs between the points (X3,Y3) and (X4,Y4). The perimeter of the chord runs counter clockwise from (X3, Y3), counterclockwise along the ellipse to (X4,Y4), and straight back to (X3,Y3). If (X3,Y3) and (X4,Y4) are not on the surface of the ellipse, the corresponding corners on the chord are the closest points on the perimeter that intersect the line.

public bool Chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)

Parameters

x1 int
y1 int
x2 int
y2 int
x3 int
y3 int
x4 int
y4 int

Returns

bool

Effect(string, string)

Changes GraphicBlock effects.

public bool Effect(string property, string value)

Parameters

property string

See Sage.Graphics.EffectProperties for values

value string

Returns

bool

Examples

Sage.CRM.SageCrmGraphicBlock Graphic1; Graphic1 = GetGraphicBlock(); Graphic1.Effect('Zoom','200'); Graphic1.Effect('Transparent','True'); Graphic1.Effect('Dither','Floyd'); Graphic1.Effect('Merge','c:\winnt\winnt.bmp, White,0,0'); Graphic1.Effect('DisplayErrors','false'); Graphic1.Effect('Clear',''); Graphic1.Effect('ChangeColor','White,Red');

Ellipse(int, int, int, int)

Draws a circle or ellipse. Specify the bounding rectangle by giving the top left point at pixel coordinates (X1, Y1) and the bottom right point at (X2, Y2).If the bounding rectangle is a square, a circle is drawn. The ellipse is drawn using the current pen width and color.

public bool Ellipse(int x1, int y1, int x2, int y2)

Parameters

x1 int
y1 int
x2 int
y2 int

Returns

bool

~GraphicBlock()

Destructor for GraphicBlock class.

protected ~GraphicBlock()

Font(string, string)

Allows for various changes to be carried out on the current font depending on the value specified in Mode. These changes then take effect with TextOut commands. To ensure success, use True Type fonts.

public bool Font(string property, string value)

Parameters

property string

See Sage.Graphics.FontProperties for available property values

value string

Returns

bool

Examples

Graphic1 = new GraphicBlock(); Graphic1.Font('Name','Times New Roman'); Graphic1.Font('Color','Blue'); Graphic1.Font('Size','24'); Graphic1.Font('Bold','True'); Graphic1.Font('StrikeOut','True'); Graphic1.Font('Rotate','45');

GradientFill(string, string, string, int)

Fills the graphic with a gradient of colors starting from the color specified in startColor and ending with the one specified in endColor. Gradients usually look better in 24 bit JPEG images, as the colors that can be used with GIFs is more limiting.

public bool GradientFill(string startColor, string endColor, string direction, int colors)

Parameters

startColor string
endColor string
direction string

See Sage.Grahics.GradientDirection for options

colors int

Colors is a numeric parameter that specifies the number of colors to use when creating your gradient. This defaults to 64. The more colors used, the better the gradient effect.

Returns

bool

LineTo(int, int)

Draws a line from the current pen position up to, but not including the points specified by the numbers in X and Y. This method also changes the pen position to the co-ordinates specified in (X,Y). The line is drawn using the current pen width and color.

public bool LineTo(int x, int y)

Parameters

x int
y int

Returns

bool

LoadBMP(string)

This method is the same as the LoadImage Graphic block method except that it enables you to specifically load a bitmap file. Loads the file specified as the new image. The ImageWidth and ImageHeight changes to the dimensions of the new image.

public bool LoadBMP(string fileName)

Parameters

fileName string

Absolute server address of a BMP file to load.

Returns

bool

LoadImage(string)

Loads the file specified as the new image. The ImageWidth and ImageHeight changes to the dimensions of the new image. The following image formats are supported: BMP (Windows Bitmap), ICO (Icon), GIF (256 color compressed image), JPG (24 bit color compressed image), WMF / EMF (Windows / Enhanced Metafile).

public bool LoadImage(string fileName)

Parameters

fileName string

Name of the image file. If you store the image in the Img folder of the CRM directory, you need only name the file. Otherwise, you must include the complete path.

Returns

bool

LoadJPG(string)

This method is the same as the LoadImage method except that it enables you to specifically load a JPEG file. Loads the file specified in text as the new image. The ImageWidth and ImageHeight changes to the dimensions of the new image.

public bool LoadJPG(string fileName)

Parameters

fileName string

Absolute server address of JPG file to load.

Returns

bool

MoveTo(int, int)

Changes the pen position to co-ordinates specified in (X,Y). Use MoveTo to set the current pen position before calling LineTo.

public bool MoveTo(int x, int y)

Parameters

x int
y int

Returns

bool

Pen(string, string)

Allows for various changes to be carried out on the current pen, depending on the value specified in Mode. Any line drawing commands, such as Arc and Rectangle, used after this command are affected.

public bool Pen(string property, string value)

Parameters

property string

See Sage.Graphics.PenProperties for allowed values.

value string

Returns

bool

Examples

Graphic1 = new GraphicBlock(); Graphic1.Pen('Style','DashDot'); Graphic1.Pen('Color','Blue'); Graphic1.Pen('Width','3');

PieShape(int, int, int, int, int, int, int, int)

Draws a pie-shaped wedge on the image. The wedge is defined by the ellipse bound by the rectangle determined by the points (X1, Y1) and (X2, Y2). The section drawn is determined by two lines radiating from the center of the ellipse through the points (X3, Y3) and (X4, Y4).

public bool PieShape(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)

Parameters

x1 int
y1 int
x2 int
y2 int
x3 int
y3 int
x4 int
y4 int

Returns

bool

Rectangle(int, int, int, int)

Draws a rectangle. Specify the rectangle by giving the top left point at pixel coordinates (X1, Y1) and the bottom right point at (X2, Y2).The rectangle is drawn using the current pen width and color.

public bool Rectangle(int x1, int y1, int x2, int y2)

Parameters

x1 int
y1 int
x2 int
y2 int

Returns

bool

Resize(int, int)

Specifies the new width and height of your image. Unlike ImageWidth and ImageHeight, the image is scaled to this new size. You should not set the ImageWidth and ImageHeight properties in the same block as they take precedence. Note that WAP WBMP files are currently restricted to a maximum size of 96x96.

public bool Resize(int width, int height)

Parameters

width int

Width to resize to.

height int

Height to resize to.

Returns

bool

Rotate(int)

Use this function to rotate an image by a specified number of degree points. The corners of a rotated image are colored in the current brush color.

public bool Rotate(int angle)

Parameters

angle int

0-360, corresponds to degrees.

Returns

bool

RoundRect(int, int, int, int, int, int)

Use RoundRect to draw a rounded rectangle. The rectangle has edges defined by the points (X1,Y1), (X2,Y1), (X2,Y2), (X1,Y2), but the corners are shaved to create a rounded appearance. The curve of the rounded corners matches the curvature of an ellipse with width X3 and height Y3. The rounded rectangle is drawn using the current pen width and color.

public bool RoundRect(int x1, int y1, int x2, int y2, int x3, int y3)

Parameters

x1 int
y1 int
x2 int
y2 int
x3 int
y3 int

Returns

bool

SaveAsJPG(string)

Saves the current image in the JPEG image file format. Images are stored using 16 million colors. Note that JPEG images do not have an option for transparency or animation.

public bool SaveAsJPG(string fileName)

Parameters

fileName string

File Name to save as. The system checks if a file of the same name exists. If it does and it contains the same extension (for example .gif or .jpg) only then does the save command overwrite the previous file.

Returns

bool

SaveAsWBMP(string)

Saves the current image in the WBMP image file format. This is the format used for images in WAP devices. The saved image is a version of the one currently being used but monochrome with a maximum resolution of 96x96 pixels and no transparency or animation.

public bool SaveAsWBMP(string fileName)

Parameters

fileName string

File name to save as.

Returns

bool

Script(string)

public int Script(string text)

Parameters

text string

Returns

int

SetFlipHorizontal()

Flips the image horizontally.

public bool SetFlipHorizontal()

Returns

bool

SetFlipVertical()

Flips the image vertically.

public bool SetFlipVertical()

Returns

bool

SetFontColor(string)

Enables the color of the current font to be changed depending on the value specified. This is the same as using the Font(Mode, Value) except it refers only to the color mode. It is quicker to use if this is the only mode you are resetting.

public bool SetFontColor(string color)

Parameters

color string

Color of font to use.

Returns

bool

SetFontSize(int)

Enables the size of the current font to be changed depending on the value specified. This is the same as using the Font(Mode, Value) except it refers only to the size mode. It is quicker to use if this is the only mode you are resetting.

public bool SetFontSize(int size)

Parameters

size int

Size in pixels.

Returns

bool

SetGrayscaleOn()

Converts an image to grayscale. It does not reduce the number of colors in use.

public bool SetGrayscaleOn()

Returns

bool

SetMonochrome(bool)

Converts an image to and from using only two colors, black and white. Note that when an image is set to monochrome, the changes that occur are irreversible unless theimage is redrawn.

public bool SetMonochrome(bool state)

Parameters

state bool

Returns

bool

SetPenColor(string)

Enables the color of the current pen to be changed depending on the value specified. This is the same as using the Pen(Mode, Value) except it refers only to the color property.

public bool SetPenColor(string color)

Parameters

color string

Color of pen to use

Returns

bool

SetPenWidth(int)

Enables the width of the current pen to be changed depending on the value specified. This is the same as using the Pen(Mode, Value) except it refers only to the width property.

public bool SetPenWidth(int width)

Parameters

width int

Width of pen in pixels.

Returns

bool

TextOut(int, int, string, bool)

You use TextOut to write some text in your image. As an option, the text can be made transparent. By default, the text creates a blank rectangle where it is placed. It is written in coordinates specified in (X,Y) and is written in the current font color and size.

public bool TextOut(int x, int y, string text, bool isTransparent)

Parameters

x int
y int
text string
isTransparent bool

Returns

bool

TextOutCenter(int, int, int, int, string, bool, bool)

Writes text to your image in much the same way as TextOut but can center it in a rectangle area defined by the parameters passed to it. If Ellipse is set to true, it can also add '…' to the end of text if that text cannot fit into the rectangle without being truncated.

public bool TextOutCenter(int left, int top, int right, int bottom, string text, bool isTransparent, bool isEllipse)

Parameters

left int
top int
right int
bottom int
text string
isTransparent bool
isEllipse bool

Returns

bool