示例#1
0
        /// <summary>
        ///     Click to generate the solution
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            EnvDTE.DTE    dte = null;
            List <string> list_selected_solution = new List <string>();

            foreach (var i in SolutionName.SelectedItems)
            {
                // Display wait cursor
                using (new WaitCursor())
                {
                    dte = fileGenerator.GenerateSolution(@SolutionPath.Text, i.ToString());
                }
                string folder_path = Path.GetFullPath(Path.Combine(Path.Combine(Path.Combine(@SolutionPath.Text, StringHelper.UpperString(i.ToString())), StringHelper.UpperString(i.ToString())), "Model"));
                Directory.CreateDirectory(folder_path);
                string file_path = Path.GetFullPath(Path.Combine(folder_path, Path.GetFileName(@XMLPath.Text)));
                // Copy the XML to the solution folder
                File.Copy(@XMLPath.Text, file_path);
                // Add to project
                System.Threading.Thread.Sleep(1000);
                EnvDTE.Project project = fileGenerator.GetProjectByName(dte.Solution, StringHelper.UpperString(i.ToString()));
                project.ProjectItems.AddFromFile(file_path);
            }
            dte.Quit();
            FlexibleMessageBox.Show("Solution generated successfully", "Message");

            Close();
        }
 /// <summary>
 /// Dispose of resources
 /// </summary>
 /// <param name="disposing">If true managed resources will be disposed as well</param>
 private void Dispose(bool disposing)
 {
     MessageFilter.Revoke();
     if (extensibility != null)
     {
         extensibility.Quit();
     }
 }
示例#3
0
        private void RemoveToolBoxItems()
        {
            EnvDTE.DTE dte = null;

            dte = LoadDTE();              // load the root object of VS.NET
            if (dte == null)
            {
                return;
            }

            try
            {
                EnvDTE.ToolBoxTab dataTab = FindDataTab(dte);;
                if (dataTab == null)
                {
                    return;
                }

                // only delete Ingres toolbox tabs, don't delete "Data" tab
                if (dataTab.Name == "Advantage Ingres" ||
                    dataTab.Name == "Ingres")
                {
                    System.Windows.Forms.MessageBox.Show(
                        "Deleted toolbox tab " + dataTab.Name, "Debugging");
                    dataTab.Delete();
                    return;
                }

                dataTab.Activate();

                RemoveItemFromTab(dataTab, "IngresDataAdapter");
                RemoveItemFromTab(dataTab, "IngresConnection");
                RemoveItemFromTab(dataTab, "IngresCommand");
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(
                    "RemoveToolBoxItems threw Exception" +
                    ex.ToString() + ".  Exiting...", "Debugging");
            }
            finally
            {
                try
                {
                    if (dte != null)
                    {
                        dte.Quit();                          // shut down the IDE
                        System.Windows.Forms.MessageBox.Show(
                            "EnvDTE Quit complete", "Debugging");
                    }
                }
                catch (Exception) {}
            }
        }          // RemoveToolBoxItems
        public static bool BuildSolution()
        {
            Type   type = Type.GetTypeFromProgID("VisualStudio.DTE");
            object obj  = Activator.CreateInstance(type, true);

            EnvDTE.DTE dte = (EnvDTE.DTE)obj;

            try
            {
                dte.MainWindow.Visible = false; // optional if you want to See VS doing its thing
                dte.Solution.Open(assemblyPath);
                var solution = dte.Solution;
                solution.SolutionBuild.Build(true);
                dte.Quit();
                return(true);
            }catch (Exception e)
            {
                Debug.Log("Failed to open/build project: " + e.Message);
                dte.Quit();
                return(false);
            }
        }
        public static void AddScript(string script)
        {
            Type   type = Type.GetTypeFromProgID("VisualStudio.DTE");
            object obj  = Activator.CreateInstance(type, true);

            EnvDTE.DTE dte = (EnvDTE.DTE)obj;

            try
            {
                dte.MainWindow.Visible = false; // optional if you want to See VS doing its thing
                dte.Solution.Open(assemblyPath);
                var solution = dte.Solution;
                solution.Projects.Item(1).ProjectItems.AddFromFile(script);
                dte.ExecuteCommand("File.SaveAll");
                solution.SolutionBuild.Build(true);
            }catch (Exception e)
            {
                Debug.Log("Failed to add file to solution: " + e.Message);
            }

            dte.Quit();
        }
示例#6
0
        private static void CreateProjectFile1()
        {
            System.Type type = System.Type.GetTypeFromProgID("VisualStudio.DTE.11.0");
            Object      obj  = System.Activator.CreateInstance(type, true);

            EnvDTE.DTE dte = (EnvDTE.DTE)obj;
            dte.MainWindow.Visible = true; // optional if you want to See VS doing its thing

            // create a new solution
            dte.Solution.Create(@"C:\NewSolution\", "NewSolution");
            var solution = dte.Solution;

            // create a C# WinForms app
            solution.AddFromTemplate(@"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ProjectTemplatesCache\CSharp\Windows\1033\WindowsApplication\csWindowsApplication.vstemplate",
                                     @"C:\NewSolution\WinFormsApp", "WinFormsApp");

            // create a C# class library
            solution.AddFromTemplate(@"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ProjectTemplatesCache\CSharp\Windows\1033\ClassLibrary\csClassLibrary.vstemplate",
                                     @"C:\NewSolution\ClassLibrary", "ClassLibrary");

            // save and quit
            dte.ExecuteCommand("File.SaveAll");
            dte.Quit();
        }
        public static bool CreateSolution(string path, string name)
        {
            Type   type = Type.GetTypeFromProgID("VisualStudio.DTE");
            object obj  = Activator.CreateInstance(type, true);

            EnvDTE.DTE dte = (EnvDTE.DTE)obj;
            try
            {
                dte.MainWindow.Visible = false; // optional if you want to See VS doing its thing

                string template = System.IO.Path.GetFullPath("../Data/assemblyFiles/MyTemplate.vstemplate");
                dte.Solution.AddFromTemplate(template, path, name);

                //create a new solution
                dte.Solution.Create(path, name + ".sln");
                var            solution = dte.Solution;
                EnvDTE.Project project  = solution.AddFromFile(path + "\\" + name + ".csproj");

                // create a C# class library
                System.IO.Directory.CreateDirectory(path + "\\Assets");
                project.ProjectItems.AddFromDirectory(path + "\\Assets");
                assemblyPath = path + "\\" + name + ".sln";


                solution.SolutionBuild.Build(true);
                // save and quit
                dte.ExecuteCommand("File.SaveAll");
                dte.Quit();
                return(true);
            }
            catch (Exception e)
            {
                Debug.Log("Error creating project: " + e.Message);
                return(false);
            }
        }
示例#8
0
 void EnvDTE._DTE.Quit()
 {
     dte.Quit();
 }
 public void Shutdown()
 {
     _dte.Quit();
 }
示例#10
0
        private void AddToolBoxItems()
        {
            EnvDTE.DTE dte = null;

            object oInstallPath = Context.Parameters["InstallPath"];

            if (oInstallPath == null)
            {
                System.Windows.Forms.MessageBox.Show(
                    "InstallPath is null.  Exiting...", "Debugging");
                return;
            }
            string installPath = (string)oInstallPath;
            string dllPath     =
                System.IO.Path.Combine(installPath, "Ingres.Client.dll");

            System.Windows.Forms.MessageBox.Show(
                "dllPath is \"" + dllPath + "\"", "Debugging");


            dte = LoadDTE();              // load the root object of VS.NET
            if (dte == null)
            {
                return;
            }

            try
            {
                EnvDTE.ToolBoxTab dataTab = FindDataTab(dte);;
                if (dataTab == null)
                {
                    dataTab = AddDataTab(dte);
                }
//					return;

                dataTab.Activate();

                RemoveItemFromTab(dataTab, "IngresDataAdapter");
                RemoveItemFromTab(dataTab, "IngresConnection");
                RemoveItemFromTab(dataTab, "IngresCommand");

                AddItemToTab(dataTab, "IngresCommand", dllPath);
                AddItemToTab(dataTab, "IngresConnection", dllPath);
                AddItemToTab(dataTab, "IngresDataAdapter", dllPath);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(
                    "Ingres .NET Data Provider " +
                    "Install.AddToolBoxItems threw Exception" +
                    ex.ToString() + ".  Continuing...",
                    "Ingres .NET Data Provider Install");
            }
            finally
            {
                try
                {
                    if (dte != null)
                    {
                        dte.Quit();                          // shut down the IDE
                        System.Windows.Forms.MessageBox.Show(
                            "EnvDTE Quit complete", "Debugging");
                    }
                }
                catch (Exception) {}
            }
        }          // AddToolBoxItems