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); } } } }
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); } } } }