[DesignerGenerated] public class GH_Canvas : Control
The GH_Canvas is the control that handles all mouse and paint events for a single loaded document.

Constructors

GH_Canvas

#
public GH_Canvas()

Fields

ScheduleInactive

#
public const int ScheduleInactive = -1
Defines the delay used to indicate the absence of a schedule.

ThumbnailHeight

#
public static readonly int ThumbnailHeight

ThumbnailWidth

#
public static readonly int ThumbnailWidth

Properties

ActiveInteraction

#
public IGH_MouseInteraction ActiveInteraction { get; set; }
Gets or sets the currently active interaction object.

ActiveObject

#
public IGH_DocumentObject ActiveObject { get; set; }
Gets or sets the currently active object.

ActiveWidget

#
public IGH_Widget ActiveWidget { get; set; }
Gets or sets the currently active widget.

CursorCanvasPosition

#
public PointF CursorCanvasPosition { get; }
Gets the location of the cursor in Canvas coordinates.

CursorControlPosition

#
public Point CursorControlPosition { get; }
Gets the location of the cursor in Control coordinates.

DisplayVoronoiWarning

#
public static bool DisplayVoronoiWarning { get; set; }
Gets or sets whether the Voronoi Over-dose warning message is displayed. This property is set once at Grasshopper startup to True.

Document

#
public GH_Document Document { get; set; }
Gets or sets the document currently loaded in this canvas.

DrawingMode

#
public GH_CanvasMode DrawingMode { get; }
Gets the current drawing mode for this canvas.

Graphics

#
[Browsable(false)] public Graphics Graphics { get; }
Gets the graphics object with which this Canvas is redrawn. This object only exists during redraws, if you need the Graphics object for this canvas outside of updates, call GetGraphicsObject() instead.

HasControlWithFocus

#
public bool HasControlWithFocus { get; }
Gets whether or not this canvas has a child control on it with focus.

IsActiveInteraction

#
public bool IsActiveInteraction { get; }
Gets a value indicating whether or not there is an interaction object loaded in this canvas.

IsActiveObject

#
public bool IsActiveObject { get; }
Gets a value indicating whether or not an object is currently activated.

IsActiveWidget

#
public bool IsActiveWidget { get; }
Gets a value indicating whether or not a widget is currently activated.

IsDocument

#
public bool IsDocument { get; }
Gets a value indicating whether or not a document is currently loaded in this canvas.

MarkovSuggestions

#
public List<IGH_ObjectProxy> MarkovSuggestions { get; }

ModifiersEnabled

#
public bool ModifiersEnabled { get; set; }
Gets or sets the modifiers enabled flag. When modifiers are disabled, only zooming and panning is still allowed.

Painter

#
public GH_Painter Painter { get; }
Gets the painter object that handles most of the drawing logic for this canvas.

Painting

#
public bool Painting { get; }
Gets whether this canvas is currently busy painting itself.

RecordPreviewBoundary

#
public bool RecordPreviewBoundary { get; set; }

TagArtistIDs

#
public List<Guid> TagArtistIDs { get; }
Gets all the TagArtist IDs in this Canvas.

ThumbnailSize

#
public static Size ThumbnailSize { get; }
Gets the thumbnail size for documents.

TooltipDelay

#
public int TooltipDelay { get; }
Gets the delay (in milliseconds) required for a tooltip popup. This delay is a user setting stored under the Canvas:TooltipDelay field of the core settings.

Validator

#
public IGH_CanvasValidator Validator { get; }
Provides access to all the validators associated with this canvas.

ValidGraphics

#
[Browsable(false)] public bool ValidGraphics { get; set; }
Gets or sets the Valid Graphics flag. Even if the flag is set to true, though, the property may still return false if there is a problem with the internal graphics object.

Viewport

#
public GH_Viewport Viewport { get; }
Gets the viewport that determines the panning and zooming for this canvas.

Widgets

#
public List<IGH_Widget> Widgets { get; }
Gets a list of all the widgets on this canvas.

ZoomFadeHigh

#
public static int ZoomFadeHigh { get; }
Gets the ZUI fade alpha value for the high zoom level threshold. This static field gets set on every Canvas paint start. The high threshold is typically used for ZUI elements that only appear when zoomed in.

ZoomFadeLow

#
public static int ZoomFadeLow { get; }
Gets the ZUI fade alpha value for the low zoom level threshold. This static field gets set on every Canvas paint start. The low threshold is typically used for fading of icons and object names.

ZoomFadeMedium

#
public static int ZoomFadeMedium { get; }
Gets the ZUI fade alpha value for the medium zoom level threshold. This static field gets set on every Canvas paint start. The medium threshold is typically used for non-informative UI elements such as highlights.

Methods

AddTagArtist

#
public void AddTagArtist(IGH_TagArtist artist)
Add a Tag Artist instance to this canvas.
artist (IGH_TagArtist)Tag artist to add

AddValidator

#
public void AddValidator(IGH_CanvasValidator validator)
Add a new drop validator to the canvas.
validator (IGH_CanvasValidator)Validator to add.

AutoSaveDocument

#
public void AutoSaveDocument(GH_AutoSaveTrigger trigger)
trigger (GH_AutoSaveTrigger)

CanvasOldSchoolMenu

#
public ToolStripDropDownMenu CanvasOldSchoolMenu()

CreateMRUPanels

#
public void CreateMRUPanels()
Create new MRU panels. This function only does something if there is no document loaded in the canvas.

CreatePreview

#
public Bitmap CreatePreview(Size size)
Render this canvas to a thumbnail preview.
size (Size)

DestroyMRUPanels

#
public void DestroyMRUPanels()
Destroy any MRU panels that might be in existence.

Dispose

#
protected override void Dispose(bool disposing)
disposing (bool)
Control.Dispose

GenerateHiResImage

#
public List<string> GenerateHiResImage(Rectangle rec, GH_ImageSettings settings, ref Size totalSize)
Generate a collection of hi-res images of the document.
rec (Rectangle)BoundingBox rectangle of export.
settings (GH_Canvas.GH_ImageSettings)Hi-res settings.
totalSize (ref Size)
List of file paths that indicate the individual images.

GenerateHiResImageTile

#
public Bitmap GenerateHiResImageTile(GH_Viewport vp, Color bg)
Generate a single tile in a Hi-Res image export.
vp (GH_Viewport)Viewport override
bg (Color)Background color override.
A list of image tiles.

GetCanvasScreenBuffer

#
public Bitmap GetCanvasScreenBuffer(GH_CanvasMode modeOverride)
Get a bitmap that resembles the current state of the canvas.
modeOverride (GH_CanvasMode)The mode to apply during the off-screen rendering.
A Format24bppRgb bitmap similar to the current canvas display.

GetGraphicsObject

#
public Graphics GetGraphicsObject(bool setupDisplayTransform)
Gets a graphics object for this control. You are not allowed to draw with this object, use it only for visibility testing and such. If you're inside a canvas update, use the Graphics() property instead. You must dispose of the Graphics object returned by this method or resources will be leaked.
setupDisplayTransform (bool)If true, the display transform will be added to the graphics object.
A non-drawing Graphics object on success or null on failure..

HideMRUPanels

#
public void HideMRUPanels()
Hide all existing MRU panels by sliding them out of view.

InstantiateNewObject

#
public bool InstantiateNewObject(Guid id, PointF at, bool update)
id (Guid)
at (PointF)
update (bool)

InstantiateNewObject

#
public bool InstantiateNewObject(Guid id, string init_code, PointF at, bool update)
id (Guid)
init_code (string)
at (PointF)
update (bool)

OnPaint

#
protected override void OnPaint(PaintEventArgs e)
e (PaintEventArgs)
Control.OnPaint

OnPaintBackground

#
protected override void OnPaintBackground(PaintEventArgs e)
e (PaintEventArgs)

OnViewportChanged

#
public void OnViewportChanged()
Ensure the canvas and document viewport data are synchronised and raises the ViewportChanged event.

ReevaluateMarkovSuggestions

#
public void ReevaluateMarkovSuggestions()

Regen

#
[EditorBrowsable(EditorBrowsableState.Never)] public void Regen()
obsoleteThis method is obsolete, use Refresh() instead. Or better yet, use Invalidate().

RemoveAllTagArtists

#
public void RemoveAllTagArtists()
Remove all IGH_TagArtists from this canvas. Do not use this method unless you want to screw over everyone else.

RemoveTagArtist

#
public int RemoveTagArtist(Guid artistId)
Remove all IGH_TagArtists from this canvas that match a certain ID.
artistId (Guid)ID of IGH_TagArtists to remove.
The number of IGH_TagArtist instances removed.

RemoveTagArtist

#
public int RemoveTagArtist(IGH_TagArtist artist)
Remove a specific tag artist from this canvas. If the instance occurs multiple times in the TagArtist list, all instances will be removed.
artist (IGH_TagArtist)TagArtist to remove.
The number of IGH_TagArtist instances removed.

RemoveValidator

#
public void RemoveValidator(IGH_CanvasValidator validator)
Remove a drop validator from the canvas.
validator (IGH_CanvasValidator)Validator to remove.

ScheduleRegen

#
public void ScheduleRegen(int delay)
Schedule a regen to occur after the specified number of milliseconds have elapsed. If a Regen is called in this time frame, the schedule will be cleared. Only a single schedule can be active at any time, so any call to ScheduleRegen will clear existing schedules.
delay (int)Number of milliseconds to wait until repainting the canvas. intervals equal to or less than zero will be ignored.

SetSmartTextRenderingHint

#
public void SetSmartTextRenderingHint()
When this method is called during a redraw, the TextRenderingHint of the associated graphics object will be set to either GH_CrispText or GH_SmoothText depending on zoom level.

ShowComponentSearchBox

#
public bool ShowComponentSearchBox()
Display the component Search dialog at the current mouse location. The dialog cannot be shown if ModifiersEnabled=False.
True on success, false on failure.

ShowComponentSearchBox

#
public bool ShowComponentSearchBox(Point at)
Display the component Search dialog at the given coordinate. The dialog cannot be shown if ModifiersEnabled=False.
at (Point)Location (in screen space) for the center of the search box.
True on success, false on failure.

ShowMRUPanels

#
public void ShowMRUPanels()
Show any hidden MRU panels by sliding them back into view.

ShowNavigationPane

#
public void ShowNavigationPane()
Displays the quick-navigation popup pane at the cursor.

ShowSearchDialog

#
public void ShowSearchDialog(bool centerOnCursor)
Display the Find dialog. If a Find dialog is already active for this canvas, nothing will happen.
centerOnCursor (bool)If true, the dialog will be centered on the cursor, otherwise it will be put in the upper left corner of the canvas.

StartAutoPan

#
public void StartAutoPan()
Start the auto-panning timer.

StopAutoPan

#
public void StopAutoPan()
Stop the auto-panning timer.

UpdateDocumentPreview

#
public void UpdateDocumentPreview()
Call this method to update the preview thumbnail for the currently loaded document. If no document is currently loaded, nothing will happen.

Events

CanvasPaintBackground

#
public event GH_Canvas.CanvasPaintBackgroundEventHandler CanvasPaintBackground
Raised after the background has been drawn.

CanvasPaintBegin

#
public event GH_Canvas.CanvasPaintBeginEventHandler CanvasPaintBegin
Raised before a new paint operation starts. This event is always raised, even if the Canvas isn't visible.

CanvasPaintEnd

#
public event GH_Canvas.CanvasPaintEndEventHandler CanvasPaintEnd
Raised after a paint operation completes. This event is always raised, even if the Canvas isn't visible.

CanvasPostPaintGroups

#
public event GH_Canvas.CanvasPostPaintGroupsEventHandler CanvasPostPaintGroups
Raised after group drawing completes.

CanvasPostPaintObjects

#
public event GH_Canvas.CanvasPostPaintObjectsEventHandler CanvasPostPaintObjects
Raised after object drawing completes.

CanvasPostPaintOverlay

#
public event GH_Canvas.CanvasPostPaintOverlayEventHandler CanvasPostPaintOverlay
Raised after object overlay drawing completes.

CanvasPostPaintWidgets

#
public event GH_Canvas.CanvasPostPaintWidgetsEventHandler CanvasPostPaintWidgets
Raised after widgets are drawn. This is the final event in the Drawing pipeline.

CanvasPostPaintWires

#
public event GH_Canvas.CanvasPostPaintWiresEventHandler CanvasPostPaintWires
Raised after wire drawing completes.

CanvasPrePaintGroups

#
public event GH_Canvas.CanvasPrePaintGroupsEventHandler CanvasPrePaintGroups
Raised before group drawing starts.

CanvasPrePaintObjects

#
public event GH_Canvas.CanvasPrePaintObjectsEventHandler CanvasPrePaintObjects
Raised before object drawing starts.

CanvasPrePaintOverlay

#
public event GH_Canvas.CanvasPrePaintOverlayEventHandler CanvasPrePaintOverlay
Raised before object overlay drawing starts.

CanvasPrePaintWidgets

#
public event GH_Canvas.CanvasPrePaintWidgetsEventHandler CanvasPrePaintWidgets
Raised before Widgets are drawn.

CanvasPrePaintWires

#
public event GH_Canvas.CanvasPrePaintWiresEventHandler CanvasPrePaintWires
Raised before wire drawing starts.

Document_ModifiedChanged

#
public event GH_Canvas.Document_ModifiedChangedEventHandler Document_ModifiedChanged

Document_ObjectsAdded

#
public event GH_Canvas.Document_ObjectsAddedEventHandler Document_ObjectsAdded

Document_ObjectsDeleted

#
public event GH_Canvas.Document_ObjectsDeletedEventHandler Document_ObjectsDeleted

Document_SettingsChanged

#
public event GH_Canvas.Document_SettingsChangedEventHandler Document_SettingsChanged

DocumentChanged

#
public event GH_Canvas.DocumentChangedEventHandler DocumentChanged
This event is raised whenever a different document is loaded into this canvas.

DocumentObjectMouseDown

#
public event GH_Canvas.DocumentObjectMouseDownEventHandler DocumentObjectMouseDown
This event is raised whenever the left mouse button is pressed while over a Document object.

DocumentObjectsDeleted

#

ModifiersChanged

#
public event GH_Canvas.ModifiersChangedEventHandler ModifiersChanged
This event is raised whenever the ModifiersEnabled property changes.

ViewportChanged

#
public event GH_Canvas.ViewportChangedEventHandler ViewportChanged
This event is raised whenever the viewport properties are modified, for example when the pan or zoom values are affected.

WidgetListCreated

#
public static event GH_Canvas.WidgetListCreatedEventHandler WidgetListCreated
This event is raised once for every GH_Canvas object that is created anew. The event is Shared (static) because it is raised inside the constructor of a GH_Canvas object and therefor cannot be registered on an instance.