void ShowActivationDialog_Click(object sender, RoutedEventArgs e) { var activationDialog = new ActivationDialog { Owner = this }; // ((ViewModelBase)activationDialog.DataContext).DisplayState = this; activationDialog.ShowDialog(); }
// Global exception handling // (event handler registered in App.xaml) void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { if (e.Exception is NotLicensedException) { ShowErrorMessageBox("You don't have a license for this feature"); e.Handled = true; // Redirect them to the activation dialog so they can install a valid license var activationDialog = new ActivationDialog { Owner = MainWindow }; activationDialog.ShowDialog(); } else { //All other exceptions string exceptionMessage = e.Exception != null ? e.Exception.Message : e.ToString(); ShowErrorMessageBox("An error occurred: " + exceptionMessage); e.Handled = false; } }
private bool DoLicenseCheck(bool initMode) { if ( !licenceChecked ) { if ( initMode ) // this allows attach to happen before OnLoad, ensuring that // window exists before attempting to show a licence dialog return true; ValidateLicense(); } while ( !licenceValid ) { ActivationDialog dlg=new ActivationDialog(); dlg.TrialExpiryDate=licenceExpiryDate; DialogResult ret=dlg.ShowDialog(this.ParentForm); if ( ret == DialogResult.OK ) ValidateLicense(); else return false; } return true; }