GH_Capsule

References
public class GH_Capsule : IDisposable
Class used to draw standard Grasshopper interface boxes.

Fields

DefaultHighlight

#
public const int DefaultHighlight = 8
The default size (in pixel units) of the highlight bar.

DefaultRadius

#
public const int DefaultRadius = 3
The default radius (in pixel units) of the rounded corners.

Properties

Box

#
public Rectangle Box { get; }
Gets the outline box for this Capsule.

Box_Content

#
public Rectangle Box_Content { get; }
Gets the content box for this Capsule. Text and icons are drawn inside this box.

Font

#
public Font Font { get; set; }
Gets or sets the Font to use for text rendering.

Highlight

#
public int Highlight { get; }
Gets the highlight size for this Capsule. Zero or negative means there is no highlight.

HighlightShape

#
public GraphicsPath HighlightShape { get; }
Gets the graphics path that describes the highlight bar shape of the capsule.

InputGrips

#
public List<Point> InputGrips { get; }
Gets the list of locally defined input grip locations.

JaggedLeft

#
public bool JaggedLeft { get; }
Gets whether the left edge of this capsule is jagged.

JaggedRight

#
public bool JaggedRight { get; }
Gets whether the right edge of this capsule is jagged.

MaxRadius

#
public int MaxRadius { get; }
Gets the largest radius defined for this capsule.

OutlineShape

#
public GraphicsPath OutlineShape { get; }
Gets the graphics path that describes the outer edge of the capsule.

OutputGrips

#
public List<Point> OutputGrips { get; }
Gets the list of locally defined output grip locations.

Palette

#
public GH_Palette Palette { get; set; }
Gets or sets the palette for this Capsule.

Radius

#
public int Radius[int index] { get; }
Gets the radius of the rounded corners of this Capsule.
index (int)Corner index.

0 = upper left

1 = upper right

2 = lower right

3 = lower left

RenderEngine

#
public GH_CapsuleRenderEngine RenderEngine { get; }
Gets the RenderEngine associated with this capsule. You typically don't need to go this far, just use one of the Render() overloads on GH_Capsule directly.
Remarks: Do not store pointers to the RenderEngine, always call this property anew.

Text

#
public string Text { get; set; }
Gets or sets the text to render in the content box.

TextOrientation

#
public GH_Orientation TextOrientation { get; set; }
Gets or sets the orientation of the text within the content box.

Methods

AddInputGrip

#
public void AddInputGrip(float X, float Y)
Add an input grip to this UI Box.
X (float)X coordinate of grip.
Y (float)Y coordinate of grip.

AddInputGrip

#
public void AddInputGrip(float Y)
Add an input grip to this UI Box. This is the recommended overload.
Y (float)Y coordinate of grip.

AddInputGrip

#
public void AddInputGrip(Point P)
Add an input grip to this UI Box.
P (Point)Coordinate of grip.

AddInputGrip

#
public void AddInputGrip(PointF P)
Add an input grip to this UI Box.
P (PointF)Coordinate of grip.

AddOutputGrip

#
public void AddOutputGrip(float X, float Y)
Add an output grip to this UI Box.
X (float)X coordinate of grip.
Y (float)Y coordinate of grip.

AddOutputGrip

#
public void AddOutputGrip(float Y)
Add an output grip to this UI Box. This is the recommended overload.
Y (float)Y coordinate of grip.

AddOutputGrip

#
public void AddOutputGrip(Point P)
Add an output grip to this UI Box.
P (Point)Coordinate of grip.

AddOutputGrip

#
public void AddOutputGrip(PointF P)
Add an output grip to this UI Box.
P (PointF)Coordinate of grip.

Contains

#
public bool Contains(PointF pt)
Test a point for capsule containment.
pt (PointF)Point to test.
True if the point is on the interior of the capsule.

CreateCapsule

#
public static GH_Capsule CreateCapsule(Rectangle box, GH_Palette palette, int radius, int highlight)
Create a new blank capsule.
box (Rectangle)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
palette (GH_Palette)Colour palette to apply.
radius (int)Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateCapsule

#
public static GH_Capsule CreateCapsule(Rectangle box, GH_Palette palette, int[] radii, int highlight)
Create a new blank capsule.
box (Rectangle)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
palette (GH_Palette)Colour palette to apply.
radii (int[])Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateCapsule

#
public static GH_Capsule CreateCapsule(Rectangle box, GH_Palette palette)
Create a new blank capsule with default radius and highlight dimensions.
box (Rectangle)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
palette (GH_Palette)Colour palette to apply.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateCapsule

#
public static GH_Capsule CreateCapsule(RectangleF box, GH_Palette palette, int radius, int highlight)
Create a new blank capsule.
box (RectangleF)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
palette (GH_Palette)Colour palette to apply.
radius (int)Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateCapsule

#
public static GH_Capsule CreateCapsule(RectangleF box, GH_Palette palette, int[] radii, int highlight)
Create a new blank capsule.
box (RectangleF)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
palette (GH_Palette)Colour palette to apply.
radii (int[])Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateCapsule

#
public static GH_Capsule CreateCapsule(RectangleF box, GH_Palette palette)
Create a new blank capsule with default radius and highlight dimensions.
box (RectangleF)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
palette (GH_Palette)Colour palette to apply.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(Rectangle box, Rectangle textbox, GH_Palette palette, string text, Font font, GH_Orientation orientation, int radius, int highlight)
Create a new capsule with content text.
box (Rectangle)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (Rectangle)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
font (Font)Font to draw text with.
orientation (GH_Orientation)Orientation of text within box.
radius (int)Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(Rectangle box, Rectangle textbox, GH_Palette palette, string text, Font font, GH_Orientation orientation, int[] radii, int highlight)
Create a new capsule with content text.
box (Rectangle)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (Rectangle)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
font (Font)Font to draw text with.
orientation (GH_Orientation)Orientation of text within box.
radii (int[])Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(Rectangle box, Rectangle textbox, GH_Palette palette, string text, Font font, GH_Orientation orientation)
Create a new capsule with content text.
box (Rectangle)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (Rectangle)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
font (Font)Font to draw text with.
orientation (GH_Orientation)Orientation of text within box.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(Rectangle box, Rectangle textbox, GH_Palette palette, string text, Font font, int radius, int highlight)
Create a new capsule with content text.
box (Rectangle)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (Rectangle)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
font (Font)Font to draw text with.
radius (int)Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(Rectangle box, Rectangle textbox, GH_Palette palette, string text, Font font, int[] radii, int highlight)
Create a new capsule with content text.
box (Rectangle)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (Rectangle)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
font (Font)Font to draw text with.
radii (int[])Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(Rectangle box, Rectangle textbox, GH_Palette palette, string text, Font font)
Create a new capsule with content text.
box (Rectangle)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (Rectangle)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
font (Font)Font to draw text with.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(Rectangle box, Rectangle textbox, GH_Palette palette, string text, int radius, int highlight)
Create a new capsule with content text.
box (Rectangle)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (Rectangle)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
radius (int)Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(Rectangle box, Rectangle textbox, GH_Palette palette, string text, int[] radii, int highlight)
Create a new capsule with content text.
box (Rectangle)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (Rectangle)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
radii (int[])Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(Rectangle box, Rectangle textbox, GH_Palette palette, string text)
Create a new capsule with content text.
box (Rectangle)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (Rectangle)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(RectangleF box, RectangleF textbox, GH_Palette palette, string text, Font font, GH_Orientation orientation, int radius, int highlight)
Create a new capsule with content text.
box (RectangleF)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (RectangleF)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
font (Font)Font to draw text with.
orientation (GH_Orientation)Orientation of text within box.
radius (int)Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(RectangleF box, RectangleF textbox, GH_Palette palette, string text, Font font, GH_Orientation orientation, int[] radii, int highlight)
Create a new capsule with content text.
box (RectangleF)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (RectangleF)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
font (Font)Font to draw text with.
orientation (GH_Orientation)Orientation of text within box.
radii (int[])Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(RectangleF box, RectangleF textbox, GH_Palette palette, string text, Font font, GH_Orientation orientation)
Create a new capsule with content text.
box (RectangleF)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (RectangleF)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
font (Font)Font to draw text with.
orientation (GH_Orientation)Orientation of text within box.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(RectangleF box, RectangleF textbox, GH_Palette palette, string text, Font font, int radius, int highlight)
Create a new capsule with content text.
box (RectangleF)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (RectangleF)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
font (Font)Font to draw text with.
radius (int)Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(RectangleF box, RectangleF textbox, GH_Palette palette, string text, Font font, int[] radii, int highlight)
Create a new capsule with content text.
box (RectangleF)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (RectangleF)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
font (Font)Font to draw text with.
radii (int[])Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(RectangleF box, RectangleF textbox, GH_Palette palette, string text, Font font)
Create a new capsule with content text.
box (RectangleF)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (RectangleF)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
font (Font)Font to draw text with.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(RectangleF box, RectangleF textbox, GH_Palette palette, string text, int radius, int highlight)
Create a new capsule with content text.
box (RectangleF)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (RectangleF)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
radius (int)Radius of rounded corners. A radius of zero or lower disables corner fillets.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(RectangleF box, RectangleF textbox, GH_Palette palette, string text, int[] radii, int highlight)
Create a new capsule with content text.
box (RectangleF)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (RectangleF)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
radii (int[])Radii of rounded corners. This array must contain at least 4 integers. Radii are defined clockwise, starting at the upper left corner.
highlight (int)Height of the highlight bar. A value of zero or lower disables the highlight.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

CreateTextCapsule

#
public static GH_Capsule CreateTextCapsule(RectangleF box, RectangleF textbox, GH_Palette palette, string text)
Create a new capsule with content text.
box (RectangleF)Box for capsule dimensions. The box will be grown until it is at least 3 pixels wide and high.
textbox (RectangleF)Box into which the text will be drawn.
palette (GH_Palette)Colour palette to apply.
text (string)Text to display inside the capsule.
A new instance of GH_Capsule. Caller is responsible for disposing of the object.

Dispose

#
public void Dispose()

Dispose

#
protected virtual void Dispose(bool disposing)
disposing (bool)

Render

#
public void Render(Graphics G, bool selected, bool locked, bool hidden)
Render the capsule onto a graphics context.
G (Graphics)Graphics object to draw with. Zoom factor is implied by the G.Transform property.
selected (bool)If true, the capsule will be drawn with selected colours.
locked (bool)If True, the capcule will be drawn in Locked style.
hidden (bool)If True, the capsule will be drawn in Hidden style.

Render

#
public void Render(Graphics G, Color colour)
Have this capsule draw itself onto a Graphics surface with a custom colour override.
G (Graphics)Graphics object to draw with. Zoom factor is implied by the G.Transform property.
colour (Color)Base colour for the capsule. Other colours will be derived from the base colour. If you want full control over every colour involved, then use the overload that allows you to supply a custom Style instead.

Render

#
public void Render(Graphics G, GH_PaletteStyle style)
Have this capsule draw itself onto a Graphics surface with a custom Style override.
G (Graphics)Graphics object to draw with. Zoom factor is implied by the G.Transform property.
style (GH_PaletteStyle)Style to draw capsule with.

Render

#
public void Render(Graphics G, Image icon, bool selected, bool locked, bool hidden)
Render the capsule onto a graphics context.
G (Graphics)Graphics object to draw with. Zoom factor is implied by the G.Transform property.
icon (Image)Icon to render in center of content/bounding box.
selected (bool)If true, the capsule will be drawn with selected colours.
locked (bool)If True, the capcule will be drawn in Locked style.
hidden (bool)If True, the capsule will be drawn in Hidden style.

Render

#
public void Render(Graphics G, Image icon, Color colour)
Have this capsule draw itself onto a Graphics surface with a custom colour override.
G (Graphics)Graphics object to draw with. Zoom factor is implied by the G.Transform property.
icon (Image)Icon to render in center of content/bounding box.
colour (Color)Base colour for the capsule. Other colours will be derived from the base colour. If you want full control over every colour involved, then use the overload that allows you to supply a custom Style instead.

Render

#
public void Render(Graphics G, Image icon, GH_PaletteStyle style)
Have this capsule draw itself onto a Graphics surface with a custom Style override.
G (Graphics)Graphics object to draw with. Zoom factor is implied by the G.Transform property.
icon (Image)Icon to render in center of content/bounding box.
style (GH_PaletteStyle)Style to draw capsule with.

SetJaggedEdges

#
public void SetJaggedEdges(bool left, bool right)
Assign left and right jagged edges.
left (bool)
right (bool)