public async void AddFilesToProject() { Project project = (Project)CurrentNode.GetParentDataItem(typeof(Project), true); var targetRoot = ((FilePath)GetFolderPath(CurrentNode.DataItem)).CanonicalPath; AddFileDialog fdiag = new AddFileDialog(GettextCatalog.GetString("Add files")); fdiag.CurrentFolder = !PreviousFolderPath.IsNullOrEmpty && !PreviousFolderPath.IsChildPathOf(project.ParentSolution.BaseDirectory) ? PreviousFolderPath : targetRoot; fdiag.SelectMultiple = true; fdiag.TransientFor = IdeApp.Workbench.RootWindow; fdiag.BuildActions = project.GetBuildActions(); string overrideAction = null; if (!fdiag.Run()) { return; } PreviousFolderPath = fdiag.SelectedFiles.Select(f => f.FullPath.ParentDirectory).FirstOrDefault(); var files = fdiag.SelectedFiles; overrideAction = fdiag.OverrideAction; ProjectFolder folder = CurrentNode.GetParentDataItem(typeof(ProjectFolder), true) as ProjectFolder; FilePath baseDirectory = folder != null ? folder.Path : project.BaseDirectory; IdeApp.ProjectOperations.AddFilesToProject(project, files, baseDirectory, overrideAction); await IdeApp.ProjectOperations.SaveAsync(project); }
public void AddFilesToProject() { var project = (FolderBasedProject)CurrentNode.GetParentDataItem(typeof(FolderBasedProject), true); var targetRoot = ((FilePath)GetPath(CurrentNode.DataItem)).CanonicalPath; var fdiag = new AddFileDialog(GettextCatalog.GetString("Add files")); fdiag.CurrentFolder = !PreviousFolderPath.IsNullOrEmpty ? PreviousFolderPath : targetRoot; fdiag.SelectMultiple = true; fdiag.TransientFor = IdeApp.Workbench.RootWindow; fdiag.BuildActions = project.GetBuildActions(); string overrideAction = null; if (!fdiag.Run()) { return; } PreviousFolderPath = fdiag.SelectedFiles.Select(f => f.FullPath.ParentDirectory).FirstOrDefault(); var files = fdiag.SelectedFiles; overrideAction = fdiag.OverrideAction; var folder = CurrentNode.GetParentDataItem(typeof(SystemFolder), true) as SystemFolder; FilePath baseDirectory = folder != null ? folder.Path : project.BaseDirectory; foreach (var file in files) { CopyFile(file, baseDirectory); } project.OnFilesAdded(files.ToList()); Tree.BuilderContext.GetTreeBuilder(CurrentNode).UpdateChildren(); }
public void AddFilesToProject() { Project project = (Project)CurrentNode.GetParentDataItem(typeof(Project), true); AddFileDialog fdiag = new AddFileDialog(GettextCatalog.GetString("Add files")); fdiag.CurrentFolder = GetFolderPath(CurrentNode.DataItem); fdiag.SelectMultiple = true; fdiag.TransientFor = IdeApp.Workbench.RootWindow; fdiag.BuildActions = project.GetBuildActions(); string overrideAction = null; if (!fdiag.Run()) { return; } var files = fdiag.SelectedFiles; overrideAction = fdiag.OverrideAction; ProjectFolder folder = CurrentNode.GetParentDataItem(typeof(ProjectFolder), true) as ProjectFolder; FilePath baseDirectory = folder != null ? folder.Path : project.BaseDirectory; IdeApp.ProjectOperations.AddFilesToProject(project, files, baseDirectory, overrideAction); IdeApp.ProjectOperations.Save(project); }
public void AddFilesToProject() { Project project = (Project)CurrentNode.GetParentDataItem(typeof(Project), true); AddFileDialog fdiag = new AddFileDialog(GettextCatalog.GetString("Add files")); fdiag.CurrentFolder = GetFolderPath(CurrentNode.DataItem); fdiag.SelectMultiple = true; fdiag.TransientFor = IdeApp.Workbench.RootWindow; fdiag.BuildActions = project.GetBuildActions(); string overrideAction = null; if (!fdiag.Run()) { return; } var files = fdiag.SelectedFiles; overrideAction = fdiag.OverrideAction; ProjectFolder folder = CurrentNode.GetParentDataItem(typeof(ProjectFolder), true) as ProjectFolder; FilePath baseDirectory = folder != null ? folder.Path : project.BaseDirectory; var addedFiles = IdeApp.ProjectOperations.AddFilesToProject(project, files, baseDirectory); //override the build action of the added files if needed if (!string.IsNullOrEmpty(overrideAction)) { foreach (var pf in addedFiles) { if (pf != null) { pf.BuildAction = overrideAction; } } } IdeApp.ProjectOperations.Save(project); }
protected void OnAddFileButtonClicked (object sender, EventArgs e) { var baseDirectory = GetSelectedDirectory (); var fileDialog = new AddFileDialog (GettextCatalog.GetString ("Add files")) { CurrentFolder = baseDirectory, SelectMultiple = true, TransientFor = IdeApp.Workbench.RootWindow, BuildActions = buildActions ?? project.GetBuildActions () }; if (defaultFilter != null) { fileDialog.Filters.Clear (); fileDialog.Filters.Add (defaultFilter); fileDialog.DefaultFilter = defaultFilter; } if (!fileDialog.Run ()) return; var buildAction = fileDialog.OverrideAction; if (buildActions != null && buildActions.Length > 0 && String.IsNullOrEmpty (buildAction)) buildAction = buildActions [0]; IdeApp.ProjectOperations.AddFilesToProject (project, fileDialog.SelectedFiles, baseDirectory, buildAction); IdeApp.ProjectOperations.SaveAsync (project); UpdateFileList (sender, e); }
public void AddFilesToProject() { Project project = (Project) CurrentNode.GetParentDataItem (typeof(Project), true); var targetRoot = ((FilePath) GetFolderPath (CurrentNode.DataItem)).CanonicalPath; AddFileDialog fdiag = new AddFileDialog (GettextCatalog.GetString ("Add files")); fdiag.CurrentFolder = !PreviousFolderPath.IsNullOrEmpty ? PreviousFolderPath : targetRoot; fdiag.SelectMultiple = true; fdiag.TransientFor = IdeApp.Workbench.RootWindow; fdiag.BuildActions = project.GetBuildActions (); string overrideAction = null; if (!fdiag.Run ()) return; PreviousFolderPath = fdiag.SelectedFiles.Select (f => f.FullPath.ParentDirectory).FirstOrDefault (); var files = fdiag.SelectedFiles; overrideAction = fdiag.OverrideAction; ProjectFolder folder = CurrentNode.GetParentDataItem (typeof(ProjectFolder), true) as ProjectFolder; FilePath baseDirectory = folder != null ? folder.Path : project.BaseDirectory; IdeApp.ProjectOperations.AddFilesToProject (project, files, baseDirectory, overrideAction); IdeApp.ProjectOperations.Save (project); }
public void AddFilesToProject() { Project project = (Project) CurrentNode.GetParentDataItem (typeof(Project), true); AddFileDialog fdiag = new AddFileDialog (GettextCatalog.GetString ("Add files")); fdiag.CurrentFolder = GetFolderPath (CurrentNode.DataItem); fdiag.SelectMultiple = true; fdiag.TransientFor = IdeApp.Workbench.RootWindow; fdiag.BuildActions = project.GetBuildActions (); string overrideAction = null; if (!fdiag.Run ()) return; var files = fdiag.SelectedFiles; overrideAction = fdiag.OverrideAction; ProjectFolder folder = CurrentNode.GetParentDataItem (typeof(ProjectFolder), true) as ProjectFolder; FilePath baseDirectory = folder != null ? folder.Path : project.BaseDirectory; IdeApp.ProjectOperations.AddFilesToProject (project, files, baseDirectory, overrideAction); IdeApp.ProjectOperations.Save (project); }
public void AddFilesToProject() { Project project = (Project) CurrentNode.GetParentDataItem (typeof(Project), true); AddFileDialog fdiag = new AddFileDialog (GettextCatalog.GetString ("Add files")); fdiag.CurrentFolder = GetFolderPath (CurrentNode.DataItem); fdiag.SelectMultiple = true; fdiag.TransientFor = IdeApp.Workbench.RootWindow; fdiag.BuildActions = project.GetBuildActions (); string overrideAction = null; if (!fdiag.Run ()) return; var files = fdiag.SelectedFiles; overrideAction = fdiag.OverrideAction; ProjectFolder folder = CurrentNode.GetParentDataItem (typeof(ProjectFolder), true) as ProjectFolder; FilePath baseDirectory = folder != null ? folder.Path : project.BaseDirectory; var addedFiles = IdeApp.ProjectOperations.AddFilesToProject (project, files, baseDirectory); //override the build action of the added files if needed if (!string.IsNullOrEmpty (overrideAction)) { foreach (var pf in addedFiles) if (pf != null) pf.BuildAction = overrideAction; } IdeApp.ProjectOperations.Save (project); }