GH_Canvas
The GH_Canvas is the control that handles all mouse and paint events for a single loaded document.
Inheritance Hierarchy
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
Grasshopper.GUI.Canvas.GH_Canvas
Namespace: Grasshopper.GUI.Canvas
Assembly: Grasshopper (in Grasshopper.dll)
Syntax
public class GH_Canvas : Control
The GH_Canvas type exposes the following members.
Constructors
Name
Description
Public Method
GH_Canvas
Initializes a new instance of the GH_Canvas class
Properties
Name
Description
Public Property
ActiveInteraction
Gets or sets the currently active interaction object.
Public Property
ActiveObject
Gets or sets the currently active object.
Public Property
ActiveWidget
Gets or sets the currently active widget.
Public Property
CursorCanvasPosition
Gets the location of the cursor in Canvas coordinates.
Public Property
CursorControlPosition
Gets the location of the cursor in Control coordinates.
Public Property
Static Member
DisplayVoronoiWarning
Gets or sets whether the Voronoi Over-dose warning message is displayed. This property is set once at Grasshopper startup to True.
Public Property
Document
Gets or sets the document currently loaded in this canvas.
Public Property
DrawingMode
Gets the current drawing mode for this canvas.
Public Property
HasControlWithFocus
Gets whether or not this canvas has a child control on it with focus.
Public Property
IsActiveInteraction
Gets a value indicating whether or not there is an interaction object loaded in this canvas.
Public Property
IsActiveObject
Gets a value indicating whether or not an object is currently activated.
Public Property
IsActiveWidget
Gets a value indicating whether or not a widget is currently activated.
Public Property
IsDocument
Gets a value indicating whether or not a document is currently loaded in this canvas.
Public Property
MarkovSuggestions
Public Property
ModifiersEnabled
Gets or sets the modifiers enabled flag. When modifiers are disabled, only zooming and panning is still allowed.
Public Property
Static Member
NavigationPanDown
Gets or sets the special key for panning down.
Public Property
Static Member
NavigationPanLeft
Gets or sets the special key for panning left.
Public Property
Static Member
NavigationPanPixels
Gets or sets the number of pixels for each pan operation.
Public Property
Static Member
NavigationPanRight
Gets or sets the special key for panning right.
Public Property
Static Member
NavigationPanUp
Gets or sets the special key for panning up.
Public Property
Static Member
NavigationZoomFactor
Gets or sets the zoom factor for navigation zoom operations.
Public Property
Static Member
NavigationZoomIn
Gets or sets the special key for zooming in.
Public Property
Static Member
NavigationZoomOut
Gets or sets the special key for zooming in.
Public Property
Painter
Gets the painter object that handles most of the drawing logic for this canvas.
Public Property
Painting
Gets whether this canvas is currently busy painting itself.
Public Property
RecordPreviewBoundary
Public Property
TagArtistIDs
Gets all the TagArtist IDs in this Canvas.
Public Property
Static Member
ThumbnailSize
Gets the thumbnail size for documents.
Public Property
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.
Public Property
Validator
Provides access to all the validators associated with this canvas.
Public Property
Viewport
Gets the viewport that determines the panning and zooming for this canvas.
Public Property
Widgets
Gets a list of all the widgets on this canvas.
Public Property
Static Member
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.
Public Property
Static Member
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.
Public Property
Static Member
ZoomFadeMedium
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
Name
Description
Public Method
AddTagArtist
Add a Tag Artist instance to this canvas.
Public Method
AddValidator
Add a new drop validator to the canvas.
Public Method
AutoSaveDocument
Public Method
CanvasOldSchoolMenu
Public Method
CreateMRUPanels
Create new MRU panels. This function only does something if there is no document loaded in the canvas.
Public Method
CreatePreview
Render this canvas to a thumbnail preview.
Public Method
DestroyMRUPanels
Destroy any MRU panels that might be in existence.
Protected method
Dispose
Releases the unmanaged resources used by the GH_Canvas and optionally releases the managed resources
(Overrides Control.Dispose(Boolean).)
Public Method
GenerateHiResImage
Generate a collection of hi-res images of the document.
Public Method
GenerateHiResImageTile
Generate a single tile in a Hi-Res image export.
Public Method
GetCanvasScreenBuffer
Get a bitmap that resembles the current state of the canvas.
Public Method
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.
Public Method
HideMRUPanels
Hide all existing MRU panels by sliding them out of view.
Public Method
InstantiateNewObject(Guid, PointF, Boolean)
Public Method
InstantiateNewObject(Guid, String, PointF, Boolean)
Public Method
Navigate
Perform a single navigation step.
Protected method
OnPaint
(Overrides Control.OnPaint(PaintEventArgs).)
Protected method
OnPaintBackground
(Overrides Control.OnPaintBackground(PaintEventArgs).)
Public Method
OnViewportChanged
Ensure the canvas and document viewport data are synchronised and raises the ViewportChanged event.
Public Method
ReevaluateMarkovSuggestions
Public Method
RemoveAllTagArtists
Remove all IGH_TagArtists from this canvas. Do not use this method unless you want to screw over everyone else.
Public Method
RemoveTagArtist(Guid)
Remove all IGH_TagArtists from this canvas that match a certain ID.
Public Method
RemoveTagArtist(IGH_TagArtist)
Remove a specific tag artist from this canvas. If the instance occurs multiple times in the TagArtist list, all instances will be removed.
Public Method
RemoveValidator
Remove a drop validator from the canvas.
Public Method
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.
Public Method
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.
Public Method
ShowComponentSearchBox.
Display the component Search dialog at the current mouse location. The dialog cannot be shown if ModifiersEnabled=False.
Public Method
ShowComponentSearchBox(Point)
Display the component Search dialog at the given coordinate. The dialog cannot be shown if ModifiersEnabled=False.
Public Method
ShowMRUPanels
Show any hidden MRU panels by sliding them back into view.
Public Method
ShowNavigationPane
Displays the quick-navigation popup pane at the cursor.
Public Method
ShowSearchDialog
Display the Find dialog. If a Find dialog is already active for this canvas, nothing will happen.
Public Method
StartAutoPan
Start the auto-panning timer.
Public Method
StopAutoPan
Stop the auto-panning timer.
Public Method
UpdateDocumentPreview
Call this method to update the preview thumbnail for the currently loaded document. If no document is currently loaded, nothing will happen.
Events
Name
Description
Public Event
CanvasPaintBackground
Raised after the background has been drawn.
Public Event
CanvasPaintBegin
Raised before a new paint operation starts. This event is always raised, even if the Canvas isn’t visible.
Public Event
CanvasPaintEnd
Raised after a paint operation completes. This event is always raised, even if the Canvas isn’t visible.
Public Event
CanvasPostPaintGroups
Raised after group drawing completes.
Public Event
CanvasPostPaintObjects
Raised after object drawing completes.
Public Event
CanvasPostPaintOverlay
Raised after object overlay drawing completes.
Public Event
CanvasPostPaintWidgets
Raised after widgets are drawn. This is the final event in the Drawing pipeline.
Public Event
CanvasPostPaintWires
Raised after wire drawing completes.
Public Event
CanvasPrePaintGroups
Raised before group drawing starts.
Public Event
CanvasPrePaintObjects
Raised before object drawing starts.
Public Event
CanvasPrePaintOverlay
Raised before object overlay drawing starts.
Public Event
CanvasPrePaintWidgets
Raised before Widgets are drawn.
Public Event
CanvasPrePaintWires
Raised before wire drawing starts.
Public Event
Document_ModifiedChanged
Public Event
Document_ObjectsAdded
Public Event
Document_ObjectsDeleted
Public Event
Document_SettingsChanged
Public Event
DocumentChanged
This event is raised whenever a different document is loaded into this canvas.
Public Event
DocumentObjectMouseDown
This event is raised whenever the left mouse button is pressed while over a Document object.
Public Event
ModifiersChanged
This event is raised whenever the ModifiersEnabled property changes.
Public Event
Static Member
NavigationSettingsChanged
Raised whenever any of the shared navigation properties changed.
Public Event
ViewportChanged
This event is raised whenever the viewport properties are modified, for example when the pan or zoom values are affected.
Public Event
Static Member
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.
Fields
Name
Description
Public Field
Static Member
ScheduleInactive
Defines the delay used to indicate the absence of a schedule.
Public Field
Static Member
ThumbnailHeight
Public Field
Static Member
ThumbnailWidth
ExtensionMethods
Name
Description
Public Extension Method
ToEto
(Defined by EtoExtensions.)