Notification

References
A 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

Notification

#Since v6.0
Creates a new instance that can be edited by any assembly.
public Notification()

Notification

#Since v6.0
Creates a new instance that can be edited by the given assemblies.
public Notification(
allowedAssemblies
The assemblies that will be allowed to edit the instance. If null or empty, any assembly will be able to edit this notification.
)
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.

Properties

AllowedAssemblies

#Since v6.0
The assemblies that can modify this instance.
public ICollection<Assembly> AllowedAssemblies { get; }
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.

AlternateButtonTitle

#Since v6.0
The localized title of the Alternate button.
public string AlternateButtonTitle { get; set; }
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.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

ButtonClicked

#Since v6.0
An Action that will be invoked whenever a button for the notification is clicked or the notification is closed.
public Action<ButtonType> ButtonClicked { get; set; }

CancelButtonTitle

#Since v6.0
The localized title of the Cancel button.
public string CancelButtonTitle { get; set; }
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.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

ConfirmButtonTitle

#Since v6.0
The localized title of the Confirm button.
public string ConfirmButtonTitle { get; set; }
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.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

DateUpdated

#Since v6.0
The date the notification was last modified.
public DateTime DateUpdated { get; }
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.

Description

#Since v6.0
The description of the notification. The description is displayed in the Notifications panel in Rhino.
public string Description { get; set; }
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

Message

#Since v6.0
The message of the notification. The message is shown only when the instance is displayed modally. It should contain details about the notification.
public string Message { get; set; }
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

MetadataCopy

#Since v6.0
A copy of all the metadata for this class.
public IDictionary<string, string> MetadataCopy { get; }
Remarks: Modifying the returned dictionary will have no effect on the metadata for this notification.

SeverityLevel

#Since v6.0
The severity of the notification. Changing the severity of the notification may change the way Rhino chooses to display the Notifications panel.
public Notification.Severity SeverityLevel { get; set; }
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

ShowEventId

#Since v6.0
A field used by Rhino for displaying notifications. Not intended for public use.
public Guid? ShowEventId { get; }

Title

#Since v6.0
The title of the notification. The title is displayed when the notification is displayed modally in Rhino.
public string Title { get; set; }
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

Indexers

this[]

#
Gets or sets metadata for this instance.
public string this[
key
The key to use to get or set metadata.
] { get; set; }
null if the key does not map to any metadata; otherwise returns the string representing the metadata.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

Methods

Editable

#Since v6.3
Determines whether an assembly can modify the instance. Any code that modifies an assembly protected notification must be wrapped in a ExecuteAssemblyProtectedCode(Action) method.
public bool Editable()
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.
Editable

ExecuteAssemblyProtectedCode<TResult>

#Since v6.3
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.
public static TResult ExecuteAssemblyProtectedCode<TResult>(
Func<TResult>
func
The code to run that modifies one or more notification objects
)
Remarks: This method is not thread-safe and should only be manipulated in UI thread.

ExecuteAssemblyProtectedCode

#Since v6.3
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.
public static void ExecuteAssemblyProtectedCode(
action
The code to run that modifies one or more notification objects
)
Remarks: This method is not thread-safe and should only be manipulated in UI thread.

HideModal

#Since v6.0
Tells Rhino to hide the notification if it is being currently shown as a modal.
public void HideModal()
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.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

RemoveMetadata

#Since v6.0
Removes metadata from this instance.
public bool RemoveMetadata(
key
The key of the metadata to remove.
)
true if the metada was removed; otherwise false.
InvalidOperationExceptionThrown if the calling assembly cannot modify this instance

ShowModal

#Since v6.0
Tells Rhino to display the notification modally.
public void ShowModal()
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.

ToString

#
Returns a readable string representation of the instance.
public override string ToString()
Object.ToString

Events

PropertyChanged

#Since v6.0
Triggered whenever a visible property of the instance changes.
public event PropertyChangedEventHandler PropertyChanged