public override void NextBtnCommandAction(Object param)
        {
            switch (CurrentUiStepId)
            {
            case 0:
                CurrentUiStepId = 1;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                if (SelectDbContextUC == null)
                {
                    SelectDbContextViewModel dataContext = new SelectDbContextViewModel(Dte);
                    dataContext.UiCommandCaption3 = "NameSpace: " + (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                    string folder = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                    if (!string.IsNullOrEmpty(folder))
                    {
                        dataContext.UiCommandCaption3 = dataContext.UiCommandCaption3 + "." + folder.Replace("\\", ".");
                    }
                    SelectDbContextUC = new UserControlSelectSource(dataContext);
                    dataContext.IsReady.IsReadyEvent += SelectDbContextViewModel_IsReady;
                    dataContext.UiCommandButtonClicked.ButtonClickedEvent += SelectDbContextViewModel_ButtonClicked;
                }
                (SelectDbContextUC.DataContext as SelectDbContextViewModel).DoAnaliseDbContext();

                this.CurrentUserControl = SelectDbContextUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 1:
                CurrentUiStepId = 2;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                if (SelectSourceEntityUC == null)
                {
                    SelectEntityForGivenDbContextViewModel dataContext = new SelectEntityForGivenDbContextViewModel(Dte);
                    dataContext.IsReady.IsReadyEvent += SelectEntityForGivenDbContextViewModel_IsReady;
                    dataContext.UiCommandButtonClicked.ButtonClickedEvent += SelectEntityForGivenDbContextViewModel_ButtonClicked;
                    SelectSourceEntityUC = new UserControlSelectSource(dataContext);
                }
                (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedDbContext =
                    (SelectDbContextUC.DataContext as SelectDbContextViewModel).SelectedCodeElement;
                if ((SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedCodeElement != null)
                {
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).DoAnalize();
                }
                else
                {
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).CheckIsReady();
                }
                this.CurrentUserControl = SelectSourceEntityUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 2:
                CurrentUiStepId = 3;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                if (SelectForeignKeyUC == null)
                {
                    SelectForeignKeyViewModel dataContext = new SelectForeignKeyViewModel(Dte);
                    dataContext.IsReady.IsReadyEvent += SelectForeignKeyViewModel_IsReady;
                    SelectForeignKeyUC = new UserControlSelectForeignKey(dataContext);
                    dataContext.PrincipalKeyButtonClicked.ButtonClickedEvent += UiBtnCommandPrincipalKey_ButtonClicked;
                    dataContext.ForeignKeyButtonClicked.ButtonClickedEvent   += UiBtnCommandForeignKey_ButtonClicked;
                }
                (SelectForeignKeyUC.DataContext as SelectForeignKeyViewModel).SelectedDbContext =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedDbContext;
                (SelectForeignKeyUC.DataContext as SelectForeignKeyViewModel).SelectedEntity =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedCodeElement;
                (SelectForeignKeyUC.DataContext as SelectForeignKeyViewModel).DoAnaliseEx();
                this.CurrentUserControl = SelectForeignKeyUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 3:
                CurrentUiStepId = 4;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                if (CreateForeignKeyUC == null)
                {
                    CreateForeignKeyViewModel dataContext = new CreateForeignKeyViewModel(Dte, TextTemplating);
                    string TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    dataContext.TemplateFolder                = Path.Combine(TemplatesFld, "ForeignKeyTmplts");
                    dataContext.TemplateOneToOneFolder        = Path.Combine(TemplatesFld, "ForeignKeyTmplts", "OneToOne");
                    dataContext.TemplateOneToCollectionFolder = Path.Combine(TemplatesFld, "ForeignKeyTmplts", "OneToCollection");
                    dataContext.IsReady.IsReadyEvent         += SelectForeignKeyViewModel_IsReady;
                    CreateForeignKeyUC = new UserControlCreateForeignKey(dataContext);
                }
                (CreateForeignKeyUC.DataContext as CreateForeignKeyViewModel).SelectedDbContext =
                    (SelectForeignKeyUC.DataContext as SelectForeignKeyViewModel).SelectedDbContext;
                (CreateForeignKeyUC.DataContext as CreateForeignKeyViewModel).SelectedEntity =
                    (SelectForeignKeyUC.DataContext as SelectForeignKeyViewModel).SelectedEntity;

                string navName = null;
                if (param is FluentAPIForeignKey)
                {
                    if ((param as FluentAPIForeignKey) != null)
                    {
                        navName = (param as FluentAPIForeignKey).NavigationName;
                    }
                }
                (CreateForeignKeyUC.DataContext as CreateForeignKeyViewModel).DoAnalise(navName);
                if (string.IsNullOrEmpty(navName))
                {
                    (CreateForeignKeyUC.DataContext as CreateForeignKeyViewModel).SelectedForeignKey =
                        (SelectForeignKeyUC.DataContext as SelectForeignKeyViewModel).SelectedForeignKey;
                }

                this.CurrentUserControl = CreateForeignKeyUC;
                this.OnPropertyChanged("CurrentUserControl");

                break;

            case 4:
                CurrentUiStepId = 1;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                NextBtnCommandAction(param);
                break;

            case 100:
                CurrentUiStepId = 101;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                if (T4SelectTemplateUC == null)
                {
                    Selectt4TemplateViewModel dataContext = new Selectt4TemplateViewModel();
                    string TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    dataContext.TemplateFolder        = Path.Combine(TemplatesFld, "DbContextTmplts");
                    dataContext.IsReady.IsReadyEvent += Selectt4TemplateViewModel_IsReady;
                    T4SelectTemplateUC = new UserControlT4SelectTemplate(dataContext);
                }
                (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).DoAnalise();
                this.CurrentUserControl = T4SelectTemplateUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 101:
                CurrentUiStepId = 102;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                string templatePath101 = Path.Combine(
                    (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).TemplateFolder,
                    (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).SelectedTemplate);
                if (T4Editor == null)
                {
                    T4EditorViewModel dataContext = new T4EditorViewModel((T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).TemplateFolder);
                    dataContext.T4SelectedTemplate = (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).SelectedTemplate;
                    dataContext.T4TempateCaption   = (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).SelectedTemplate;
                    T4Editor = new UserControlT4Editor(dataContext);
                }
                else
                {
                    if (!templatePath101.Equals((T4Editor.DataContext as T4EditorViewModel).T4TempatePath, StringComparison.OrdinalIgnoreCase))
                    {
                        (T4Editor.DataContext as T4EditorViewModel).T4SelectedTemplate = (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).SelectedTemplate;
                        (T4Editor.DataContext as T4EditorViewModel).T4TempateCaption   = (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).SelectedTemplate;
                        (T4Editor.DataContext as T4EditorViewModel).T4TempatePath      = templatePath101;
                        (T4Editor.DataContext as T4EditorViewModel).ReadTemplate();
                    }
                }
                if (!(T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).ShowT4Template)
                {
                    NextBtnCommandAction(param);
                    return;
                }
                this.CurrentUserControl = T4Editor;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 102:
                CurrentUiStepId = 103;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                if (GenerateDbContextUC == null)
                {
                    GenerateDbContextViewModel dataContext = new GenerateDbContextViewModel();
                    dataContext.IsReady.IsReadyEvent += GenerateDbContext_IsReady;
                    GenerateDbContextUC = new UserControlGenerate(dataContext);
                }
                (GenerateDbContextUC.DataContext as GenerateDbContextViewModel).GenText =
                    (T4Editor.DataContext as T4EditorViewModel).T4TempateText;

                string nameSpace102 = (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                string folder102    = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                if (!string.IsNullOrEmpty(folder102))
                {
                    nameSpace102 = nameSpace102 + "." + folder102.Replace("\\", ".");
                }
                (GenerateDbContextUC.DataContext as GenerateDbContextViewModel).DoGenerateDbContext(Dte, TextTemplating, (T4Editor.DataContext as T4EditorViewModel).T4TempatePath, nameSpace102, (SelectDbContextUC.DataContext as SelectDbContextViewModel).UiCommandProppertyName);
                this.CurrentUserControl = GenerateDbContextUC;
                this.OnPropertyChanged("CurrentUserControl");

                break;

            case 103:
                (SelectDbContextUC.DataContext as SelectDbContextViewModel).CollectProjectClasses((SelectDbContextUC.DataContext as SelectDbContextViewModel).SelectedProject);
                CurrentUiStepId = 0;
                NextBtnCommandAction(param);
                break;

            case 200:
                CurrentUiStepId = 201;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                if (CreatePrimKeyUC == null)
                {
                    CreatePrimaryKeyViewModel dataContext = new CreatePrimaryKeyViewModel(Dte, TextTemplating);
                    string TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    dataContext.TemplateFolder = Path.Combine(TemplatesFld, "HasKeyTmplst");
                    CreatePrimKeyUC            = new UserControlCreatePrimKey(dataContext);
                }
                (CreatePrimKeyUC.DataContext as CreatePrimaryKeyViewModel).SelectedDbContext =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedDbContext;
                (CreatePrimKeyUC.DataContext as CreatePrimaryKeyViewModel).SelectedEntity =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedCodeElement;
                (CreatePrimKeyUC.DataContext as CreatePrimaryKeyViewModel).DoAnalise();
                this.CurrentUserControl = CreatePrimKeyUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 201:
                CurrentUiStepId = 1;
                NextBtnCommandAction(param);
                break;

            case 300:
                CurrentUiStepId = 301;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                if (CreatePrimKeyUC == null)
                {
                    CreatePrimaryKeyViewModel dataContext = new CreatePrimaryKeyViewModel(Dte, TextTemplating);
                    string TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    dataContext.TemplateFolder = Path.Combine(TemplatesFld, "HasKeyTmplst");
                    CreatePrimKeyUC            = new UserControlCreatePrimKey(dataContext);
                }
                (CreatePrimKeyUC.DataContext as CreatePrimaryKeyViewModel).SelectedDbContext =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedDbContext;
                //(CreatePrimKeyUC.DataContext as CreatePrimaryKeyViewModel).SelectedEntity =
                //(SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedCodeElement;
                (CreatePrimKeyUC.DataContext as CreatePrimaryKeyViewModel).DoAnalise();
                this.CurrentUserControl = CreatePrimKeyUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 301:
                CurrentUiStepId = 4;
                PrevBtnCommandAction(param);
                break;


            default:
                break;
            }
        }
Exemple #2
0
        public override void NextBtnCommandAction(Object param)
        {
            switch (CurrentUiStepId)
            {
            case 0:
                CurrentUiStepId = 1;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                if (SelectDbContextUC == null)
                {
                    SelectDbContextViewModel dataContext = new SelectDbContextViewModel(Dte);
                    dataContext.UiCommandButtonVisibility = Visibility.Collapsed;
                    dataContext.UiCommandCaption3         = "NameSpace: " + (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                    string folder = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                    if (!string.IsNullOrEmpty(folder))
                    {
                        dataContext.UiCommandCaption3 = dataContext.UiCommandCaption3 + "." + folder.Replace("\\", ".");
                    }
                    SelectDbContextUC = new UserControlSelectSource(dataContext);
                    dataContext.IsReady.IsReadyEvent += SelectDbContextViewModel_IsReady;
                }
                (SelectDbContextUC.DataContext as SelectDbContextViewModel).DoAnaliseDbContext();
                this.CurrentUserControl = SelectDbContextUC;
                this.OnPropertyChanged("CurrentUserControl");


                break;

            case 1:
                CurrentUiStepId = 2;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                if (SelectSourceEntityUC == null)
                {
                    SelectEntityForGivenDbContextViewModel dataContext = new SelectEntityForGivenDbContextViewModel(Dte);
                    dataContext.UiCommandButtonVisibility = Visibility.Collapsed;
                    dataContext.IsReady.IsReadyEvent     += SelectEntityForGivenDbContextViewModel_IsReady;
                    SelectSourceEntityUC = new UserControlSelectSource(dataContext);
                }
                (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedDbContext =
                    (SelectDbContextUC.DataContext as SelectDbContextViewModel).SelectedCodeElement;
                (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).CheckIsReady();
                OnDbContextChanged();
                this.CurrentUserControl = SelectSourceEntityUC;
                this.OnPropertyChanged("CurrentUserControl");

                break;

            case 2:
                CurrentUiStepId = 3;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                if (SelectExistingUC == null)
                {
                    SelectExistingViewModel dataContext = new SelectExistingViewModel(Dte);
                    dataContext.IsReady.IsReadyEvent += SelectEntityForGivenDbContextViewModel_IsReady;
                    SelectExistingUC = new UserControlSelectExisting(dataContext);
                }
                (SelectExistingUC.DataContext as SelectExistingViewModel).CurrentDbContext = CurrentDbContext;
                (SelectExistingUC.DataContext as SelectExistingViewModel).SelectedEntity   =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedCodeElement;

                (SelectExistingUC.DataContext as SelectExistingViewModel).DestinationProject      = (InvitationUC.DataContext as InvitationViewModel).DestinationProject;
                (SelectExistingUC.DataContext as SelectExistingViewModel).DefaultProjectNameSpace = (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                (SelectExistingUC.DataContext as SelectExistingViewModel).DestinationFolder       = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                (SelectExistingUC.DataContext as SelectExistingViewModel).DbSetProppertyName      = (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedProppertyName;

                (SelectExistingUC.DataContext as SelectExistingViewModel).DoAnalize();
                this.CurrentUserControl = SelectExistingUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 3:
                CurrentUiStepId = 4;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                SaveBtnEnabled  = false;
                if (CreateViewUC == null)
                {
                    CreateViewViewModel dataContext = new CreateViewViewModel(Dte);
                    dataContext.IsReady.IsReadyEvent   += SelectEntityForGivenDbContextViewModel_IsReady;
                    dataContext.DestinationProject      = (InvitationUC.DataContext as InvitationViewModel).DestinationProject;
                    dataContext.DefaultProjectNameSpace = (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                    dataContext.DestinationFolder       = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                    CreateViewUC = new UserControlCreateView(dataContext);
                }
                (CreateViewUC.DataContext as CreateViewViewModel).SelectedDbContext =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedDbContext;
                (CreateViewUC.DataContext as CreateViewViewModel).SelectedEntity =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedCodeElement;
                (CreateViewUC.DataContext as CreateViewViewModel).CurrentDbContext = CurrentDbContext;
                (CreateViewUC.DataContext as CreateViewViewModel).DestinationDbSetProppertyName =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedProppertyName;
                ModelViewSerializable srcModel = null;
                if ((SelectExistingUC.DataContext as SelectExistingViewModel).IsSelectExisting)
                {
                    srcModel = (SelectExistingUC.DataContext as SelectExistingViewModel).SelectedModel;
                }
                (CreateViewUC.DataContext as CreateViewViewModel).DoAnalize(srcModel);
                this.CurrentUserControl = CreateViewUC;
                this.OnPropertyChanged("CurrentUserControl");

                break;

            case 4:
                string checkErrorsText = (CreateViewUC.DataContext as CreateViewViewModel).SelectedModel.CheckCorrect();
                if (!string.IsNullOrEmpty(checkErrorsText))
                {
                    (CreateViewUC.DataContext as CreateViewViewModel).CheckErrorsText = checkErrorsText;
                    return;
                }

                CurrentUiStepId = 5;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                SaveBtnEnabled  = false;
                if (T4EditorUC == null)
                {
                    string            TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    string            templatePath = Path.Combine(TemplatesFld, "ViewModelTmplst");
                    T4EditorViewModel dataContext  = new T4EditorViewModel(templatePath);
                    dataContext.IsReady.IsReadyEvent += T4EditorViewModel_IsReady;
                    T4EditorUC = new UserControlT4Editor(dataContext);
                }
                (T4EditorUC.DataContext as T4EditorViewModel).CheckIsReady();
                this.CurrentUserControl = T4EditorUC;
                this.OnPropertyChanged("CurrentUserControl");

                break;

            case 5:
                CurrentUiStepId = 6;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                IVsThreadedWaitDialog2 aDialog = null;
                bool aDialogStarted            = false;
                if (this.DialogFactory != null)
                {
                    this.DialogFactory.CreateInstance(out aDialog);
                    if (aDialog != null)
                    {
                        aDialogStarted = aDialog.StartWaitDialog("Generation started", "VS is Busy", "Please wait", null, "Generation started", 0, false, true) == VSConstants.S_OK;
                    }
                }

                if (GenerateUC == null)
                {
                    GenerateViewModel generateViewModel = new GenerateViewModel();
                    generateViewModel.IsReady.IsReadyEvent += GenerateViewModel_IsReady;
                    GenerateUC = new UserControlGenerate(generateViewModel);
                }
                (GenerateUC.DataContext as GenerateViewModel).GenText = (T4EditorUC.DataContext as T4EditorViewModel).T4TempateText;
                try
                {
                    (CreateViewUC.DataContext as CreateViewViewModel).SelectedModel.RootEntityDbContextPropertyName =
                        (CreateViewUC.DataContext as CreateViewViewModel).DestinationDbSetProppertyName;
                    (GenerateUC.DataContext as GenerateViewModel).DoGenerateViewModel(Dte, TextTemplating, null,
                                                                                      (T4EditorUC.DataContext as T4EditorViewModel).T4TempatePath,
                                                                                      (CreateViewUC.DataContext as CreateViewViewModel).SelectedModel);
                    NextBtnEnabled = true;
                    if (aDialogStarted)
                    {
                        int iOut;
                        aDialog.EndWaitDialog(out iOut);
                    }
                    MessageBox.Show(SuccessNotification, "Done", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception e)
                {
                    if (aDialogStarted)
                    {
                        int iOut;
                        aDialog.EndWaitDialog(out iOut);
                    }
                    MessageBox.Show("Error: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    this.CurrentUserControl = GenerateUC;
                    this.OnPropertyChanged("CurrentUserControl");
                }
                break;

            case 6:
                CurrentUiStepId = 7;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                SaveBtnEnabled  = false;
                if (T4EditorPageUC == null)
                {
                    string            TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    string            templatePath = Path.Combine(TemplatesFld, "ViewPageModelTmplst");
                    T4EditorViewModel dataContext  = new T4EditorViewModel(templatePath);
                    dataContext.IsReady.IsReadyEvent += T4EditorViewModel_IsReady;
                    T4EditorPageUC = new UserControlT4Editor(dataContext);
                }
                (T4EditorPageUC.DataContext as T4EditorViewModel).CheckIsReady();
                this.CurrentUserControl = T4EditorPageUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 7:
                CurrentUiStepId = 8;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                IVsThreadedWaitDialog2 aaDialog = null;
                bool aaDialogStarted            = false;
                if (this.DialogFactory != null)
                {
                    this.DialogFactory.CreateInstance(out aaDialog);
                    if (aaDialog != null)
                    {
                        aaDialogStarted = aaDialog.StartWaitDialog("Generation started", "VS is Busy", "Please wait", null, "Generation started", 0, false, true) == VSConstants.S_OK;
                    }
                }
                if (GeneratePageUC == null)
                {
                    GenerateViewPageModel generateViewModel = new GenerateViewPageModel();
                    generateViewModel.IsReady.IsReadyEvent += GenerateViewModel_IsReady;
                    GeneratePageUC = new UserControlGenerate(generateViewModel);
                }
                (GeneratePageUC.DataContext as GenerateViewPageModel).GenText = (T4EditorPageUC.DataContext as T4EditorViewModel).T4TempateText;
                try
                {
                    (GeneratePageUC.DataContext as GenerateViewPageModel).GeneratedModelView =
                        (GenerateUC.DataContext as GenerateViewModel).GeneratedModelView;
                    (GeneratePageUC.DataContext as GenerateViewPageModel).DoGenerateViewPageModel(Dte, TextTemplating, null,
                                                                                                  (T4EditorPageUC.DataContext as T4EditorViewModel).T4TempatePath);
                    if (aaDialogStarted)
                    {
                        int iOut;
                        aaDialog.EndWaitDialog(out iOut);
                    }
                }
                catch (Exception e)
                {
                    if (aaDialogStarted)
                    {
                        int iOut;
                        aaDialog.EndWaitDialog(out iOut);
                    }
                    MessageBox.Show("Error: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    this.CurrentUserControl = GeneratePageUC;
                    this.OnPropertyChanged("CurrentUserControl");
                }
                break;

            case 8:
                CurrentUiStepId = 1;
                NextBtnCommandAction(param);
                break;

            default:
                break;
            }
        }