Notification
ReferencesA Notification instance can be used to inform the user about various events. For a Notification instance to be displayed in Rhino, it must be added to the NotificationCenter. When added, it will be displayed in the Notifications panel in Rhino. A Notification contains 1 to 3 buttons that are automatically wired to its ButtonClicked Action if it is not null. The buttons are displayed when the Notification is shown modally by either the user clicking on a particular notification in the Notifications panel, or by programatically showing it using ShowModal(). Currently, only process-wide notifications are supported; document specific notifications are not possible. Notification instances contain metadata that can be added, modified, or removed during its life. The metadata is important for LINQ queries and other patterns. For example, a particular action may require that multiple notifications be modified. Thus, a LINQ query can be performed on the NotificationCenter using metadata to retrieve related Notification objects and modify them as a batch. Notification objects implement IAssemblyRestrictedObject. By default, a Notification can be editedby any assembly, but explicitly specifing allowed assemblies in the constructor changes this behavior. Notification objects are not thread-safe and should only be manipulated in UI thread.
Constructors
public Notification()
Creates a new instance that can be edited by any assembly.
Creates a new instance that can be edited by the given assemblies.
Remarks: Specifying one or more assemblies limits certain operations with the notification object, throwing an InvalidOperationException if an assembly outside the ones passed tries to interact with it. Any code that tries to interact with a notification object that has restricted assemblies must be wrapped in a ExecuteAssemblyProtectedCode(Action). For performance reasons, it is imporant that such methods are kept as simple as possible.
Parameters:
| allowedAssemblies (IEnumerable<Assembly>) | The assemblies that will be allowed to edit the instance. If null or empty, any assembly will be able to edit this notification. |
Properties
The assemblies that can modify this instance.
Remarks: If empty, any assembly is allowed to edit the instance. You may specify additional assemblies that should have access to an instance at creation time.
The localized title of the Alternate button.
Remarks: Notifications can 1 to 3 buttons for user input. Each button can have a localized title. With the exception of the Cancel button, setting a button title to null (the default) will prevent that button from appearing in the interface. Note that in order for buttons other than the Cancel button to be displayed, you must set a ButtonClicked Action.
Exceptions:
| InvalidOperationException | Thrown if the calling assembly cannot modify this instance |
An Action that will be invoked whenever a button for the notification is clicked or the notification is closed.
The localized title of the Cancel button.
Remarks: Notifications can 1 to 3 buttons for user input. Each button can have a localized title. With the exception of the Cancel button, setting a button title to null (the default) will prevent that button from appearing in the interface. Note that in order for buttons other than the Cancel button to be displayed, you must set a ButtonClicked Action.
Exceptions:
| InvalidOperationException | Thrown if the calling assembly cannot modify this instance |
The localized title of the Confirm button.
Remarks: Notifications can 1 to 3 buttons for user input. Each button can have a localized title. With the exception of the Cancel button, setting a button title to null (the default) will prevent that button from appearing in the interface. Note that in order for buttons other than the Cancel button to be displayed, you must set a ButtonClicked Action.
Exceptions:
| InvalidOperationException | Thrown if the calling assembly cannot modify this instance |
The date the notification was last modified.
Remarks: Only visible elements of the notification will cause this property to change. Changes in metadata or other non-visible members will have no effect on this property.
The description of the notification. The description is displayed in the Notifications panel in Rhino.
Exceptions:
| InvalidOperationException | Thrown if the calling assembly cannot modify this instance |
The message of the notification. The message is shown only when the instance is displayed modally. It should contain details about the notification.
Exceptions:
| InvalidOperationException | Thrown if the calling assembly cannot modify this instance |
A copy of all the metadata for this class.
Remarks: Modifying the returned dictionary will have no effect on the metadata for this notification.
The severity of the notification. Changing the severity of the notification may change the way Rhino chooses to display the Notifications panel.
Exceptions:
| InvalidOperationException | Thrown if the calling assembly cannot modify this instance |
A field used by Rhino for displaying notifications. Not intended for public use.
The title of the notification. The title is displayed when the notification is displayed modally in Rhino.
Exceptions:
| InvalidOperationException | Thrown if the calling assembly cannot modify this instance |
Indexers
this[]
#Gets or sets metadata for this instance.
Parameters:
| key (string) | The key to use to get or set metadata. |
Returns: null if the key does not map to any metadata; otherwise returns the string representing the metadata.
Exceptions:
| InvalidOperationException | Thrown if the calling assembly cannot modify this instance |
Methods
Determines whether an assembly can modify the instance. Any code that modifies an assembly protected notification must be wrapped in a ExecuteAssemblyProtectedCode(Action) method.
Remarks: Before modifying a notification you are not sure you created (such as a notification returned from a LINQ query), you should call this method first to ensure you can indeed edit the object.
Implements: Editable
If a Notification object is only allowed to be modified by certain assemblies, then any code that interacts with it must be wrapped around this method, or a InvalidOperationException will be thrown. For performance reasons, the code wrapped by this method should be kept as simple as possible.
Remarks: This method is not thread-safe and should only be manipulated in UI thread.
Parameters:
| func (Func<TResult>) | The code to run that modifies one or more notification objects |
If a Notification object is only allowed to be modified by certain assemblies, then any code that interacts with it must be wrapped around this method, or a InvalidOperationException will be thrown. For performance reasons, the code wrapped by this method should be kept as simple as possible.
Remarks: This method is not thread-safe and should only be manipulated in UI thread.
Parameters:
| action (Action) | The code to run that modifies one or more notification objects |
public void HideModal()
Tells Rhino to hide the notification if it is being currently shown as a modal.
Remarks: If the notification is not being currently shown but is being queued by Rhino as a result of calling ShowModal(), then the notification will be dequeued. If the notification was never queued, then this method has no effect.
Exceptions:
| InvalidOperationException | Thrown if the calling assembly cannot modify this instance |
Removes metadata from this instance.
Parameters:
| key (string) | The key of the metadata to remove. |
Returns: true if the metada was removed; otherwise false.
Exceptions:
| InvalidOperationException | Thrown if the calling assembly cannot modify this instance |
public void ShowModal()
Tells Rhino to display the notification modally.
Remarks: The notification will only be displayed if/once the instance is added to the NotificationCenter. Rhino keeps a queue of notifications that need to be shown modally, so calling this method does not mean that this particular notification will be immediately displayed.
Events
Triggered whenever a visible property of the instance changes.