Ejemplo n.º 1
0
        public static void UserCreateProject(LiteExtensionHost extensionHost)
        {
            var solution = extensionHost.CurrentSolution;

            using (var dlg = new CreateProjectDialog(solution))
            {
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string projectDirectory = Path.Combine(dlg.Directory, Path.GetFileNameWithoutExtension(dlg.FileName));

                    if (dlg.CreateSolutionDirectory)
                    {
                        projectDirectory = Path.Combine(projectDirectory, Path.GetFileNameWithoutExtension(dlg.FileName));
                    }

                    if (System.IO.Directory.Exists(projectDirectory))
                    {
                        if (MessageBox.Show(LiteDevelopApplication.Current.MuiProcessor.GetString("CreateProjectDialog.FolderAlreadyExists", "folder=" + projectDirectory), "LiteDevelop", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                        {
                            return;
                        }
                    }
                    else
                    {
                        System.IO.Directory.CreateDirectory(projectDirectory);
                    }

                    var projectTemplate = dlg.Template as ProjectTemplate;
                    var result          = projectTemplate.CreateProject(extensionHost.FileService, new FilePath(projectDirectory, Path.GetFileName(dlg.FileName)));

                    result.Project.Save(extensionHost.CreateOrGetReporter("Build"));

                    if (solution == null)
                    {
                        string solutionDirectory = dlg.CreateSolutionDirectory ? Path.GetDirectoryName(projectDirectory) : projectDirectory;

                        solution          = Solution.CreateSolution(result.Project.Name);
                        solution.FilePath = new FilePath(solutionDirectory, Path.GetFileNameWithoutExtension(dlg.FileName) + ".sln");
                        solution.Settings.StartupProjects.Add(result.Project.ProjectGuid);
                        solution.Save(extensionHost.CreateOrGetReporter("Build"));
                        extensionHost.DispatchSolutionCreated(new SolutionEventArgs(solution));
                        solution.Nodes.Add(new ProjectEntry(result.Project));
                        extensionHost.DispatchSolutionLoad(new SolutionEventArgs(solution));
                    }
                    else
                    {
                        solution.Nodes.Add(new ProjectEntry(result.Project));
                    }


                    for (int i = 0; i < result.CreatedFiles.Count; i++)
                    {
                        result.CreatedFiles[i].ExtensionToUse.OpenFile(result.CreatedFiles[i].File as OpenedFile);
                    }
                }
            }
        }
        public static void UserCreateProject(LiteExtensionHost extensionHost)
        {
            var solution = extensionHost.CurrentSolution;

               using (var dlg = new CreateProjectDialog(solution))
               {
               if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
               {
                   var projectDirectory = new FilePath(dlg.Directory, dlg.FileName);

                   if (dlg.CreateSolutionDirectory)
                       projectDirectory = projectDirectory.Combine(projectDirectory.FileName);

                   if (System.IO.Directory.Exists(projectDirectory.FullPath))
                   {
                       if (MessageBox.Show(LiteDevelopApplication.Current.MuiProcessor.GetString("CreateProjectDialog.FolderAlreadyExists", "folder=" + projectDirectory), "LiteDevelop", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                           return;
                   }
                   else
                   {
                       System.IO.Directory.CreateDirectory(projectDirectory.FullPath);
                   }

                   bool newSolution = solution == null;
                   if (newSolution)
                   {
                       var solutionDirectory = dlg.CreateSolutionDirectory ? projectDirectory.ParentDirectory : projectDirectory;

                       solution = Solution.CreateSolution(projectDirectory.FileName);
                       solution.FilePath = solutionDirectory.Combine(projectDirectory.FileName + ".sln");
                   }

                   var projects = dlg.Template.Create(new FileCreationContext()
                       {
                           CurrentProject = null,
                           CurrentSolution = solution,
                           FilePath = projectDirectory,
                           FileService = extensionHost.FileService,
                           ProgressReporter = extensionHost.CreateOrGetReporter("Build"),
                       }).Cast<Project>();

                   if (newSolution)
                       extensionHost.DispatchSolutionCreated(new SolutionEventArgs(solution));

                   foreach (var project in projects)
                       solution.Nodes.Add(new ProjectEntry(project));

                   if (newSolution)
                       extensionHost.DispatchSolutionLoad(new SolutionEventArgs(solution));
               }
               }
        }
Ejemplo n.º 3
0
 private void newProjectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     CreateProjectDialog.UserCreateProject(_extensionHost);
 }
Ejemplo n.º 4
0
        public static void UserCreateProject(LiteExtensionHost extensionHost)
        {
            var solution = extensionHost.CurrentSolution;

            using (var dlg = new CreateProjectDialog(solution))
            {
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string projectDirectory = Path.Combine(dlg.Directory, Path.GetFileNameWithoutExtension(dlg.FileName));

                    if (dlg.CreateSolutionDirectory)
                        projectDirectory = Path.Combine(projectDirectory, Path.GetFileNameWithoutExtension(dlg.FileName));

                    if (System.IO.Directory.Exists(projectDirectory))
                    {
                        if (MessageBox.Show(LiteDevelopApplication.Current.MuiProcessor.GetString("CreateProjectDialog.FolderAlreadyExists", "folder=" + projectDirectory), "LiteDevelop", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                            return;
                    }
                    else
                    {
                        System.IO.Directory.CreateDirectory(projectDirectory);
                    }

                    var projectTemplate = dlg.Template as ProjectTemplate;
                    var result = projectTemplate.CreateProject(extensionHost.FileService, new FilePath(projectDirectory, Path.GetFileName(dlg.FileName)));

                    result.Project.Save(extensionHost.CreateOrGetReporter("Build"));

                    if (solution == null)
                    {
                        string solutionDirectory = dlg.CreateSolutionDirectory ? Path.GetDirectoryName(projectDirectory) : projectDirectory;

                        solution = Solution.CreateSolution(result.Project.Name);
                        solution.FilePath = new FilePath(solutionDirectory, Path.GetFileNameWithoutExtension(dlg.FileName) + ".sln");
                        solution.Settings.StartupProjects.Add(result.Project.ProjectGuid);
                        solution.Save(extensionHost.CreateOrGetReporter("Build"));
                        extensionHost.DispatchSolutionCreated(new SolutionEventArgs(solution));
                        solution.Nodes.Add(new ProjectEntry(result.Project));
                        extensionHost.DispatchSolutionLoad(new SolutionEventArgs(solution));
                    }
                    else
                        solution.Nodes.Add(new ProjectEntry(result.Project));

                    for (int i = 0; i < result.CreatedFiles.Count; i++)
                    {
                        result.CreatedFiles[i].ExtensionToUse.OpenFile(result.CreatedFiles[i].File as OpenedFile);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public static void UserCreateProject(LiteExtensionHost extensionHost)
        {
            var solution = extensionHost.CurrentSolution;

            using (var dlg = new CreateProjectDialog(solution))
            {
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var projectDirectory = new FilePath(dlg.Directory, dlg.FileName);

                    if (dlg.CreateSolutionDirectory)
                    {
                        projectDirectory = projectDirectory.Combine(projectDirectory.FileName);
                    }

                    if (System.IO.Directory.Exists(projectDirectory.FullPath))
                    {
                        if (MessageBox.Show(LiteDevelopApplication.Current.MuiProcessor.GetString("CreateProjectDialog.FolderAlreadyExists", "folder=" + projectDirectory), "LiteDevelop", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                        {
                            return;
                        }
                    }
                    else
                    {
                        System.IO.Directory.CreateDirectory(projectDirectory.FullPath);
                    }

                    bool newSolution = solution == null;
                    if (newSolution)
                    {
                        var solutionDirectory = dlg.CreateSolutionDirectory ? projectDirectory.ParentDirectory : projectDirectory;

                        solution          = Solution.CreateSolution(projectDirectory.FileName);
                        solution.FilePath = solutionDirectory.Combine(projectDirectory.FileName + ".sln");
                    }

                    var projects = dlg.Template.Create(new FileCreationContext()
                    {
                        CurrentProject   = null,
                        CurrentSolution  = solution,
                        FilePath         = projectDirectory,
                        FileService      = extensionHost.FileService,
                        ProgressReporter = extensionHost.CreateOrGetReporter("Build"),
                    }).Cast <Project>();

                    if (newSolution)
                    {
                        extensionHost.DispatchSolutionCreated(new SolutionEventArgs(solution));
                    }

                    foreach (var project in projects)
                    {
                        solution.Nodes.Add(new ProjectEntry(project));
                    }

                    if (newSolution)
                    {
                        extensionHost.DispatchSolutionLoad(new SolutionEventArgs(solution));
                    }
                }
            }
        }