Displaying a confirmation dialog
You can display a message box or a confirmation dialog using the ICommonUI
object. The ICommonUI
object can be obtained from the Window.UI
property of the IApplication
object.
Message box
To display a message box, you can use the ShowMessageBox
method of the ICommonUI
object.
public void ShowMessageBox(ICommandContext c, ICommandParams p)
{
//Display a message box
c.App.Window.UI.ShowMessageBox("message here");
}
Notification dialog
To display a notification dialog, you can use the ShowInformationDialog
method of the ICommonUI
object.
public void ShowInformationDialog(ICommandContext c, ICommandParams p)
{
//Display the notification dialog
c.App.Window.UI.ShowInformationDialog("message here");
}
Confirmation dialog
The confirmation dialog can use the ShowConfirmDialog
method of the ICommonUI
object. The return value can be used to evaluate the user's confirmation result.
public void ShowInformationDialog(ICommandContext c, ICommandParams p)
{
if ( c.App.Window.UI.ShowConfirmDialog("Are you sure you want to execute?") )
{
//If the dialog is OK
} else {
//If you want to cancel
}
}