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
Properties
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
#Gets or sets whether the Voronoi Over-dose warning message is displayed. This property is set once at Grasshopper startup to True.
Graphics
#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.
IsActiveInteraction
#Gets a value indicating whether or not there is an interaction object loaded in this canvas.
MarkovSuggestions
#ModifiersEnabled
#Gets or sets the modifiers enabled flag. When modifiers are disabled, only zooming and panning is still allowed.
TooltipDelay
#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.
ValidGraphics
#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.
ZoomFadeHigh
#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
#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.
Methods
AddTagArtist
#Add a Tag Artist instance to this canvas.
Parameters:
| artist (IGH_TagArtist) | Tag artist to add |
AddValidator
#Add a new drop validator to the canvas.
Parameters:
| validator (IGH_CanvasValidator) | Validator to add. |
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.
Parameters:
| size (Size) |
GenerateHiResImage
#public List<string> GenerateHiResImage(Rectangle rec, GH_ImageSettings settings, ref Size totalSize)
Generate a collection of hi-res images of the document.
Parameters:
| rec (Rectangle) | BoundingBox rectangle of export. |
| settings (GH_Canvas.GH_ImageSettings) | Hi-res settings. |
| totalSize (ref Size) |
Returns: List of file paths that indicate the individual images.
GenerateHiResImageTile
#Generate a single tile in a Hi-Res image export.
Parameters:
| vp (GH_Viewport) | Viewport override |
| bg (Color) | Background color override. |
Returns: A list of image tiles.
GetCanvasScreenBuffer
#Get a bitmap that resembles the current state of the canvas.
Parameters:
| modeOverride (GH_CanvasMode) | The mode to apply during the off-screen rendering. |
Returns: A Format24bppRgb bitmap similar to the current canvas display.
GetGraphicsObject
#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.
Parameters:
| setupDisplayTransform (bool) | If true, the display transform will be added to the graphics object. |
Returns: A non-drawing Graphics object on success or null on failure..
InstantiateNewObject
#InstantiateNewObject
#OnViewportChanged
#public void OnViewportChanged()
Ensure the canvas and document viewport data are synchronised and raises the ViewportChanged event.
ReevaluateMarkovSuggestions
#public void ReevaluateMarkovSuggestions()
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
#Remove all IGH_TagArtists from this canvas that match a certain ID.
Parameters:
| artistId (Guid) | ID of IGH_TagArtists to remove. |
Returns: The number of IGH_TagArtist instances removed.
RemoveTagArtist
#Remove a specific tag artist from this canvas. If the instance occurs multiple times in the TagArtist list, all instances will be removed.
Parameters:
| artist (IGH_TagArtist) | TagArtist to remove. |
Returns: The number of IGH_TagArtist instances removed.
RemoveValidator
#Remove a drop validator from the canvas.
Parameters:
| validator (IGH_CanvasValidator) | Validator to remove. |
ScheduleRegen
#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.
Parameters:
| 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
#Display the component Search dialog at the current mouse location. The dialog cannot be shown if ModifiersEnabled=False.
Returns: True on success, false on failure.
ShowComponentSearchBox
#Display the component Search dialog at the given coordinate. The dialog cannot be shown if ModifiersEnabled=False.
Parameters:
| at (Point) | Location (in screen space) for the center of the search box. |
Returns: True on success, false on failure.
ShowSearchDialog
#Display the Find dialog. If a Find dialog is already active for this canvas, nothing will happen.
Parameters:
| 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. |
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
CanvasPaintBegin
#Raised before a new paint operation starts. This event is always raised, even if the Canvas isn't visible.
CanvasPaintEnd
#Raised after a paint operation completes. This event is always raised, even if the Canvas isn't visible.
CanvasPostPaintWidgets
#Raised after widgets are drawn. This is the final event in the Drawing pipeline.
Document_ModifiedChanged
#Document_ObjectsAdded
#Document_ObjectsDeleted
#Document_SettingsChanged
#DocumentObjectMouseDown
#This event is raised whenever the left mouse button is pressed while over a Document object.
DocumentObjectsDeleted
#[EditorBrowsable(EditorBrowsableState.Never)]
public event GH_Canvas.DocumentObjectsDeletedEventHandler DocumentObjectsDeleted
ViewportChanged
#This event is raised whenever the viewport properties are modified, for example when the pan or zoom values are affected.
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.