Exemplo 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);
     }
 }
Exemplo n.º 2
0
        void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            var path = @"C:\Dev\vs2015\xamlpowertoys2015\XamlPowerToys.Fakes\bin\Debug\XamlPowerToys.Fakes.dll";

            var resolver = new DefaultAssemblyResolver();

            resolver.AddSearchDirectory(System.IO.Path.GetDirectoryName(path));

            var reader = new ReaderParameters {
                AssemblyResolver = resolver
            };

            var assemblyDefinition = AssemblyDefinition.ReadAssembly(path, reader);

            var typeDefinition = assemblyDefinition.MainModule.GetType("XamlPowerToys.Fakes.People.PersonEditorViewModel");

            //var typeDefinition = assemblyDefinition.MainModule.GetType("XamlPowerToys.Fakes.Books.BooksDetailPageViewModel");

            var classEntity = new ClassEntity(assemblyDefinition, typeDefinition, ProjectType.Xamarin, "");

            LoadPropertyInformation(assemblyDefinition, typeDefinition, classEntity);

            var emptyConverterList = new List <String>();

            var vm   = new CreateFormViewModel(classEntity, emptyConverterList);
            var view = new CreateFormView();

            this.DataContext = vm;
            this.rootGrid.Children.Add(view);
        }
Exemplo n.º 3
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);
     }
 }