示例#1
0
        Task ShowActivationDialogAsync(HideezMiddleware.IPC.Messages.ShowActivationCodeUiMessage obj)
        {
            try
            {
                if (activationView == null)
                {
                    UIDispatcher.Invoke(() =>
                    {
                        if (MainWindow is MetroWindow metroWindow)
                        {
                            var vm = _viewModelLocator.ActivationViewModel;
                            vm.Initialize(obj.DeviceId);
                            activationView         = new ActivationDialog(vm);
                            activationView.Closed += ActivationView_Closed;
                            OnActivateMainWindow();
                            metroWindow.ShowMetroDialogAsync(activationView);
                        }
                    });
                }

                if (activationView != null)
                {
                    UIDispatcher.Invoke(() =>
                    {
                        ((ActivationViewModel)activationView.DataContext).UpdateViewModel(obj.DeviceId);
                    });
                }
            }
            catch { }

            return(Task.CompletedTask);
        }
示例#2
0
        void ShowActivationDialog_Click(object sender, RoutedEventArgs e)
        {
            var activationDialog = new ActivationDialog {
                Owner = this
            };

            //	((ViewModelBase)activationDialog.DataContext).DisplayState = this;
            activationDialog.ShowDialog();
        }
示例#3
0
 void ActivationView_Closed(object sender, EventArgs e)
 {
     lock (activationDialogLock)
     {
         if (activationView != null)
         {
             activationView.Closed -= ActivationView_Closed;
             activationView         = null;
         }
     }
 }
示例#4
0
        Task HideActivationDialogAsync(HideActivationCodeUi message)
        {
            try
            {
                UIDispatcher.Invoke(() =>
                {
                    try
                    {
                        activationView?.Close();
                        activationView = null;
                    }
                    catch { }
                });
            }
            catch { }

            return(Task.CompletedTask);
        }
示例#5
0
        // 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;
            }
        }
示例#6
0
        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;
        }