Ejemplo n.º 1
0
        public static void UserCreateFile(LiteExtensionHost extensionHost, Project currentProject, string directory)
        {
            using (var dlg = new CreateFileDialog(currentProject))
            {
                if (!string.IsNullOrEmpty(directory))
                {
                    dlg.Directory = directory;
                }

                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var result = (dlg.Template as FileTemplate).CreateFile(extensionHost.FileService, currentProject, new FilePath(dlg.FileName));

                    foreach (var createdFile in result.CreatedFiles)
                    {
                        var openedFile = createdFile.File as OpenedFile;
                        openedFile.Save(extensionHost.CreateOrGetReporter("Build"));

                        if (currentProject != null)
                        {
                            currentProject.ProjectFiles.Add(new ProjectFileEntry(openedFile));
                        }

                        createdFile.ExtensionToUse.OpenFile(openedFile);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void UserCreateFile(LiteExtensionHost extensionHost, Project currentProject, string directory)
        {
            using (var dlg = new CreateFileDialog(currentProject))
            {
                if (!string.IsNullOrEmpty(directory))
                {
                    dlg.Directory = directory;
                }

                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var filePath = new FilePath(dlg.FileName);
                    var files    = dlg.Template.Create(new FileCreationContext()
                    {
                        CurrentProject   = currentProject,
                        CurrentSolution  = extensionHost.CurrentSolution,
                        FilePath         = filePath,
                        FileService      = extensionHost.FileService,
                        ProgressReporter = extensionHost.CreateOrGetReporter("Build"),
                    });

                    foreach (var createdFile in files)
                    {
                        extensionHost.FileService.SelectFileHandler(
                            extensionHost.ExtensionManager.GetFileHandlers(createdFile.FilePath),
                            createdFile.FilePath).OpenFile((OpenedFile)createdFile);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private void newFileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     CreateFileDialog.UserCreateFile(_extensionHost);
 }
        public static void UserCreateFile(LiteExtensionHost extensionHost, Project currentProject, string directory)
        {
            using (var dlg = new CreateFileDialog(currentProject))
            {
                if (!string.IsNullOrEmpty(directory))
                {
                    dlg.Directory = directory;
                }

                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var filePath = new FilePath(dlg.FileName);
                    var files = dlg.Template.Create(new FileCreationContext()
                        {
                            CurrentProject = currentProject,
                            CurrentSolution = extensionHost.CurrentSolution,
                            FilePath = filePath,
                            FileService = extensionHost.FileService,
                            ProgressReporter = extensionHost.CreateOrGetReporter("Build"),
                        });

                    foreach (var createdFile in files)
                    {
                        extensionHost.FileService.SelectFileHandler(
                            extensionHost.ExtensionManager.GetFileHandlers(createdFile.FilePath),
                            createdFile.FilePath).OpenFile((OpenedFile)createdFile);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public static void UserCreateFile(LiteExtensionHost extensionHost, Project currentProject, string directory)
        {
            using (var dlg = new CreateFileDialog(currentProject))
            {
                if (!string.IsNullOrEmpty(directory))
                {
                    dlg.Directory = directory;
                }

                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    var result = (dlg.Template as FileTemplate).CreateFile(extensionHost.FileService, currentProject, new FilePath(dlg.FileName));

                    foreach (var createdFile in result.CreatedFiles)
                    {
                        var openedFile = createdFile.File as OpenedFile;
                        openedFile.Save(extensionHost.CreateOrGetReporter("Build"));

                        if (currentProject != null)
                        {
                            currentProject.ProjectFiles.Add(new ProjectFileEntry(openedFile));
                        }

                        createdFile.ExtensionToUse.OpenFile(openedFile);
                    }
                }
            }
        }