private void Btn_Ok(object sender, RoutedEventArgs e) { //Loading the selected project from the dialog VsProject blazorProject = ProjectsCombo.SelectedItem as VsProject; //Checking to make sure a target blazor project has been selected. if (blazorProject == null) { MessageBox.Show("You must have a Blazor Project selected before continuing."); return; } //Checking to make sure that we've got a source *.aspx file to convert if (FormToMigrate == null) { MessageBox.Show("There has been a problem - there is no source *.aspx file selected to migrate."); this.Close(); } try { //Updating the dialog to not accept input while the migration is processing ButtonOk.Content = "Processing"; ButtonOk.IsEnabled = false; ButtonCancel.IsEnabled = false; //Creating the migration process logic. Notice that we pass in a copy of the visual studio actions that code factory uses for visual studio automation. //In addition we pass a reference to the dialog itself. //We have implemented an interface on the dialog that allows the background thread to call into this dialog and update the migration status. var migrationProcess = new WebFormToBlazorServerMigration(_visualStudioActions, this); //Starting the migration process on a background thread and letting the dialog keep processing UI updates. Task.Run(() => migrationProcess.MigrateSingleASPXFile(FormToMigrate, blazorProject));// .StartMigration(webformProject, blazorProject, migrationSteps)) } catch (Exception unhandledError) { //Displaying the error that was not managed during the migration process. MessageBox.Show($"The following unhandled error occured while performing the setup operations. '{unhandledError.Message}'", "Unhandled Setup Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Process the ok button click event. /// </summary> /// <param name="sender">Hosting user control.</param> /// <param name="e">We dont use the routing args with this implementation.</param> private void ButtonOk_Click(object sender, RoutedEventArgs e) { //Loading the selected projects from the dialog VsProject webformProject = ComboboxWebFormsProject.SelectedItem as VsProject; VsProject blazorProject = ComboboxBlazorProject.SelectedItem as VsProject; //Checking that a source webforms project has been selected. if (webformProject == null) { MessageBox.Show("You must select a Webforms Project before continuing."); return; } //Checking to make sure a target blazor project has been selected. if (blazorProject == null) { MessageBox.Show("You must have a Blazor Project selected before continuing."); return; } //Checking to make sure the same project was not selected. if (webformProject.Name == blazorProject.Name) { MessageBox.Show("The web forms project and the blazor project cannot be the same."); return; } bool migrationStepsSelected = false; migrationStepsSelected = CheckBoxMigrateAspxPages.IsChecked.GetResult() | CheckBoxMigrateBundling.IsChecked.GetResult() | CheckBoxMigrateConfiguration.IsChecked.GetResult() | CheckBoxMigrateHttpModules.IsChecked.GetResult() | CheckBoxMigrateLogic.IsChecked.GetResult() | CheckBoxMigrateStaticFiles.IsChecked.GetResult() | CheckBoxStartupProcess.IsChecked.GetResult(); if (!migrationStepsSelected) { MessageBox.Show("You have to select a migration step in order to continue."); return; } try { var migrationSteps = new MigrationSteps(CheckBoxStartupProcess.IsChecked.GetResult(), CheckBoxMigrateHttpModules.IsChecked.GetResult(), CheckBoxMigrateStaticFiles.IsChecked.GetResult(), CheckBoxMigrateBundling.IsChecked.GetResult(), CheckBoxMigrateAspxPages.IsChecked.GetResult(), CheckBoxMigrateConfiguration.IsChecked.GetResult(), CheckBoxMigrateLogic.IsChecked.GetResult()); //Creating an empty observable collection. This will be updated during the execution of the migration process. StepStatus = new ObservableCollection <MigrationStepStatus>(); //Updating the dialog to not accept input while the migration is processing ButtonOk.Content = "Processing"; ButtonOk.IsEnabled = false; ButtonCancel.IsEnabled = false; //Creating the migration process logic. Notice that we pass in a copy of the visual studio actions that code factory uses for visual studio automation. //In addition we pass a reference to the dialog itself. //We have implemented an interface on the dialog that allows the background thread to call into this dialog and update the migration status. var migrationProcess = new WebFormToBlazorServerMigration(_visualStudioActions, this); //Updating the UI to begin the migration process. SetupStatusForMigration(migrationSteps); //Starting the migration process on a background thread and letting the dialog keep processing UI updates. Task.Run(() => migrationProcess.StartMigration(webformProject, blazorProject, migrationSteps)); } catch (Exception unhandledError) { //Displaying the error that was not managed during the migration process. MessageBox.Show($"The following unhandled error occured while performing the setup operations. '{unhandledError.Message}'", "Unhandled Setup Error", MessageBoxButton.OK, MessageBoxImage.Error); } }