/// <summary>
        /// Delete the entire project from the server
        /// </summary>
        public static void DeleteProject()
        {
            if (ProjectID == 0)
            {
                DialogResult dialogResult = MessageBox.Show("Please open a project first", "Open Project", MessageBoxButtons.OK);
                return;
            }

            DialogResult dialogResult2 = MessageBox.Show("Warning! This will delete your project locally and from QuantConnect's servers. Are you sure you want to proceed?", "Delete Project From QuantConnect", MessageBoxButtons.YesNo);

            if (dialogResult2 == DialogResult.Yes)
            {
                //Close Visual Studio
                Solution4 soln = (Solution4)QCPluginPackage.ApplicationObject.Solution;
                soln.Close();

                if (ProjectName != "")
                {
                    System.IO.Directory.Delete(Directory + ProjectID + " - " + ProjectName, true);
                }

                //Delete project
                API.ProjectDelete(ProjectID);

                //Reset Project Details:
                ProjectName = "";
                ProjectID   = 0;
                SetButtonsState(false);
            }
            else if (dialogResult2 == DialogResult.No)
            {
                return;
            }
        }
示例#2
0
        public static string GenerateSolution()
        {
            DTE2   dte;
            object obj;
            string outputfolder = "";

            try
            {
                if (SolutionGenerator.SelectedType == CompType.Addon)
                {
                    SolutionGenerator.TemplateFileName = "CSharpAddon.zip";
                }
                else // interpreter
                {
                    SolutionGenerator.TemplateFileName = "CSharpInterpreter.zip";
                }

                // Prefer latest VS
                System.Type type = null;
                if (type == null)
                {
                    type = System.Type.GetTypeFromProgID("VisualStudio.DTE.14.0");
                }
                if (type == null)
                {
                    type = System.Type.GetTypeFromProgID("VisualStudio.DTE.12.0");
                }
                if (type == null)
                {
                    type = System.Type.GetTypeFromProgID("VisualStudio.DTE.11.0");
                }
                if (type == null)
                {
                    type = System.Type.GetTypeFromProgID("VisualStudio.DTE.10.0");
                }

                obj = Activator.CreateInstance(type, true);
                dte = (DTE2)obj;
                Solution4 sln = (Solution4)dte.Solution;

                outputfolder = Path.Combine(TargetFolder, SolutionName);
                string solutionName = SolutionName + ".sln";

                if (Directory.Exists(outputfolder))
                {
                    Directory.Delete(outputfolder, true);
                }

                // Unpack the sufficent template project
                Stream TemplateStream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(
                    System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".Templates." + SolutionGenerator.TemplateFileName);
                FileStream FileWriter = new FileStream(Path.Combine(SolutionGenerator.ProjectTemplateLocation, SolutionGenerator.TemplateFileName), FileMode.Create);
                using (TemplateStream)
                    using (FileWriter)
                    {
                        TemplateStream.CopyTo(FileWriter);
                    }

                sln.Create(outputfolder, solutionName);

                string TemplatePath = sln.GetProjectTemplate(SolutionGenerator.TemplateFileName, "CSharp");
                sln.AddFromTemplate(TemplatePath, outputfolder, SolutionName, false);
                var project       = sln.Projects.Item(1);
                var dotNetVersion = new FrameworkName(".NETFramework", new Version(4, 0));
                var fullname      = dotNetVersion.FullName;
                project.Properties.Item("TargetFrameworkMoniker").Value = dotNetVersion.FullName;
                sln.Close();
            }
            finally
            {
                obj = dte = null;
            }
            return(outputfolder);
        }