SilverScreen Solid Modeler

ShowError Event

ShowError Event

Previous topic Next topic  

ShowError Event

Previous topic Next topic JavaScript is required for the print function  

SilverSharpAPI

 

The ShowError Event

 

Synopsis

The ShowError event is raised whenever SilverSharp wishes to display an error message. A error message  is displayed in response to the SilverScreen API routine error_message, and otherwise whenever the CAD engine wishes to report an error condition.

 

 

Delegate

The ShowError delegate is declared as follows:

 

C# Code

 

 delegate void ShowErrorEventHandler(string message, string title);

 

 string message; // The error message to display

 string title;   // A title for the error message dialog

 

 

A delegate is similar to a C/C++ function pointer, but delegates are type-safe and can only refer to a method that matches the signature of the delegate. The ShowError delegate declares a function signature that must be used when installing an event handler for the ShowError event.

 

 

Event

The ShowError event is declared within Events as follows:

 

C# Code

 

 static event ShowErrorEventHandler ShowError;

 

 

ShowError allows your application to subscribe to or unsubscribe from the ShowError event.

 

 

Raise method

The method to raise the ShowError event is declared within Events as follows:

 

C# Code

 

 static void RaiseShowError(string message, string title)

   

 string message; // The error message to display

 string title;   // A title for the error message dialog

 

 

The SilverSharp assembly will automatically raise the ShowError event when an error message is to be displayed to the user. It would not be typical for a SilverSharp application to raise the event itself.

 

 

Remarks

It is not necessary for a SilverSharp application to establish a handler for the ShowError event, but it is typical to do so. The reporting of errors can be disabled with the State property CV_ERRORS when necessary, or messages can be quietly logged for later analysis.

 

 

See Also

Events, set_show_error_handler, error_message

 

Example

The following C# code for WPF shows a sample ShowError event handler. Note that the method declaration must match the delegate for this event in parameters and return type:

 

C# Code

   

 using SilverSharp;

 

 . . .

 

 void OnShowError(string message, string title)

    {

    System.Windows.MessageBox.Show(message, title);

    }

 

 

The following code shows how to subscribe to the ShowError event, assigning the above handler:

 

C# Code

   

 Events.ShowError += new ShowErrorEventHandler(this.OnShowError);

 

 

The following code shows how to unsubscribe from the ShowError event, removing the above handler:

 

C# Code

   

 Events.ShowError -= new ShowErrorEventHandler(this.OnShowError);

 

 

Note: See the Birdhouse SilverSharp sample application for a demonstration of the use of the ShowError event.