Ejemplo n.º 1
0
 public void Generate()
 {
     Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
     try {
         var xamlFileClassName = Path.GetFileNameWithoutExtension(_dte2.ActiveDocument.Name);
         using (var typeReflector = new TypeReflector()) {
             var typeReflectorResult = typeReflector.SelectClassFromAllReferencedAssemblies(_activeProject, xamlFileClassName, "Data Form Generator", _projectType, _projectFrameworkVersion);
             if (typeReflectorResult != null)
             {
                 var win  = new XamlPowerToysWindow();
                 var vm   = new CreateFormViewModel(typeReflectorResult.ClassEntity, typeReflectorResult.AvailableConverters, ApplyChanges);
                 var view = new CreateFormView();
                 win.DataContext = vm;
                 win.rootGrid.Children.Add(view);
                 win.ShowDialog();
                 if (vm.SelectedAction == SelectedAction.Generate)
                 {
                     InsertXaml(vm.ResultXaml);
                 }
             }
         }
     } catch (Exception ex) {
         DialogAssistant.ShowExceptionMessage(ex);
     }
 }
Ejemplo n.º 2
0
 public void Generate()
 {
     try {
         var xamlFileClassName   = Path.GetFileNameWithoutExtension(_dte2.ActiveDocument.Name);
         var typeReflector       = new TypeReflector();
         var typeReflectorResult = typeReflector.SelectClassFromAllReferencedAssemblies(_activeProject, xamlFileClassName, "Data Form Generator", _projectType, _projectFrameworkVersion);
         if (typeReflectorResult != null)
         {
             var win  = new XamlPowerToysWindow();
             var vm   = new CreateFormViewModel(typeReflectorResult.ClassEntity, typeReflectorResult.AvailableConverters);
             var view = new CreateFormView();
             win.DataContext = vm;
             win.rootGrid.Children.Add(view);
             win.ShowDialog();
             var ts = (TextSelection)_dte2.ActiveDocument.Selection;
             ts.Insert(vm.ResultXaml);
             _dte2.ExecuteCommand("Edit.FormatDocument");
         }
     } catch (Exception ex) {
         DialogAssistant.ShowExceptionMessage(ex);
     }
 }