void CheckRenamedFile(object sender, FileRenameEventArgs e) { if (e.IsDirectory) { foreach (IViewContent content in ViewContentCollection) { if (content.FileName != null && FileUtility.IsBaseDirectory(e.SourceFile, content.FileName)) { content.FileName = FileUtility.RenameBaseDirectory(content.FileName, e.SourceFile, e.TargetFile); } } } else { foreach (IViewContent content in ViewContentCollection) { if (content.FileName != null && FileUtility.IsEqualFileName(content.FileName, e.SourceFile)) { content.FileName = e.TargetFile; content.TitleName = Path.GetFileName(e.TargetFile); return; } } } }
/// <summary> /// Renames anchors without document. /// </summary> internal static void FileRenamed(FileRenameEventArgs e) { FileName sourceFile = new FileName(e.SourceFile); FileName targetFile = new FileName(e.TargetFile); foreach (PermanentAnchor anchor in permanentAnchors) { if (anchor.CurrentDocument == null) { if (e.IsDirectory) { if (FileUtility.IsBaseDirectory(e.SourceFile, anchor.FileName)) { anchor.SetFileName(new FileName(FileUtility.RenameBaseDirectory(anchor.FileName, e.SourceFile, e.TargetFile))); } } else { if (anchor.FileName == sourceFile) { anchor.SetFileName(targetFile); } } } } }
private void OnFileCopied(FileRenameEventArgs e) { if (FileCopied != null) { FileCopied(this, e); } }
void FileServiceFileRenamed(object sender, FileRenameEventArgs e) { string oldName = e.SourceFile; string newName = e.TargetFile; foreach (ISolutionFileItem fileItem in this.AllItems.OfType <ISolutionFileItem>()) { if (FileUtility.IsBaseDirectory(oldName, fileItem.FileName)) { string newFullName = FileUtility.RenameBaseDirectory(fileItem.FileName, oldName, newName); fileItem.FileName = FileName.Create(newFullName); } } foreach (IProject project in this.Projects) { if (FileUtility.IsBaseDirectory(project.Directory, oldName)) { foreach (ProjectItem item in project.Items) { if (FileUtility.IsBaseDirectory(oldName, item.FileName)) { SD.GetRequiredService <IProjectServiceRaiseEvents>().RaiseProjectItemRemoved(new ProjectItemEventArgs(project, item)); item.FileName = FileName.Create(FileUtility.RenameBaseDirectory(item.FileName, oldName, newName)); SD.GetRequiredService <IProjectServiceRaiseEvents>().RaiseProjectItemAdded(new ProjectItemEventArgs(project, item)); } } } } }
void CheckRenamedFile(object sender, FileRenameEventArgs e) { if (e.IsDirectory) { foreach (OpenedFile file in FileService.OpenedFiles) { if (file.FileName != null && FileUtility.IsBaseDirectory(e.SourceFile, file.FileName)) { file.FileName = FileUtility.RenameBaseDirectory(file.FileName, e.SourceFile, e.TargetFile); } } } else { foreach (OpenedFile file in FileService.OpenedFiles) { if (file.FileName != null && FileUtility.IsEqualFileName(file.FileName, e.SourceFile)) { file.FileName = e.TargetFile; return; } } } }
/// <summary> /// Respond to changes in filenames by updating points in the history /// to reflect the change. /// </summary> /// <param name="sender"/> /// <param name="e"><see cref="FileRenameEventArgs"/> describing /// the file rename.</param> private static void FileService_FileRenamed(object sender, FileRenameEventArgs e) { foreach (INavigationPoint p in history) { if (p.FileName.Equals(e.SourceFile)) { p.FileNameChanged(e.TargetFile); } } }
void FileServiceFileRenamed(object sender, FileRenameEventArgs e) { if (FileUtility.IsEqualFileName(Path.GetDirectoryName(e.SourceFile), Path.GetDirectoryName(e.TargetFile))) { CallVisitor(new FileRenameTreeNodeVisitor(e.SourceFile, e.TargetFile)); } else { CallVisitor(new FileRemoveTreeNodeVisitor(e.SourceFile)); } }
static void FileServiceFileRenamed(object sender, FileRenameEventArgs e) { if (OpenSolution == null) { return; } string oldName = e.SourceFile; string newName = e.TargetFile; long x = 0; foreach (ISolutionFolderContainer container in OpenSolution.SolutionFolderContainers) { foreach (SolutionItem item in container.SolutionItems.Items) { string oldFullName = Path.Combine(OpenSolution.Directory, item.Name); ++x; if (FileUtility.IsBaseDirectory(oldName, oldFullName)) { string newFullName = FileUtility.RenameBaseDirectory(oldFullName, oldName, newName); item.Name = item.Location = FileUtility.GetRelativePath(OpenSolution.Directory, newFullName); } } } long y = 0; foreach (IProject project in OpenSolution.Projects) { if (FileUtility.IsBaseDirectory(project.Directory, oldName)) { foreach (ProjectItem item in project.Items) { ++y; if (FileUtility.IsBaseDirectory(oldName, item.FileName)) { OnProjectItemRemoved(new ProjectItemEventArgs(project, item)); item.FileName = FileUtility.RenameBaseDirectory(item.FileName, oldName, newName); OnProjectItemAdded(new ProjectItemEventArgs(project, item)); } } } } }
/// <summary> /// Checks that the rename/overwrite operation is possible. /// </summary> public static bool CheckRenameOrReplacePossible(FileRenameEventArgs e, bool replaceAllowed = false) { if (e.IsDirectory && Directory.Exists(e.SourceFile)) { if (!replaceAllowed && Directory.Exists(e.TargetFile)) { MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}")); return(false); } } else if (File.Exists(e.SourceFile)) { if (!replaceAllowed && File.Exists(e.TargetFile)) { MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}")); return(false); } } return(true); }
void FileRenamed(object sender, FileRenameEventArgs e) { if (!e.IsDirectory) { // source and target are populated. if (NAntBuildFile.IsBuildFile(e.SourceFile) && NAntBuildFile.IsBuildFile(e.TargetFile)) { treeView.RenameBuildFile(e.SourceFile, e.TargetFile); } else if (NAntBuildFile.IsBuildFile(e.SourceFile)) { treeView.RemoveBuildFile(e.SourceFile); } else { AddBuildFile(e.TargetFile); } } }
void CheckRenamedFile(object sender, FileRenameEventArgs e) { if (e.IsDirectory) { foreach (OpenedFile file in FileService.OpenedFiles) { if (file.FileName != null && FileUtility.IsBaseDirectory(e.SourceFile, file.FileName)) { file.FileName = new FileName(FileUtility.RenameBaseDirectory(file.FileName, e.SourceFile, e.TargetFile)); } } } else { OpenedFile file = FileService.GetOpenedFile(e.SourceFile); if (file != null) { file.FileName = new FileName(e.TargetFile); } } Editor.PermanentAnchorService.FileRenamed(e); }
/// <summary> /// Respond to changes in filenames by updating points in the history /// to reflect the change. /// </summary> /// <param name="sender"/> /// <param name="e"><see cref="FileRenameEventArgs"/> describing /// the file rename.</param> static void FileService_FileRenamed(object sender, FileRenameEventArgs e) { foreach (INavigationPoint p in history) { if (p.FileName.Equals(e.SourceFile)) { p.FileNameChanged(e.TargetFile); } } }
internal void FileRenamed(object sender, FileRenameEventArgs e) { for (int i = 0; i < recentFiles.Count; ++i) { string file = recentFiles[i].ToString(); if (e.SourceFile == file) { recentFiles.RemoveAt(i); recentFiles.Insert(i, FileName.Create(e.TargetFile)); break; } } }
void FileServiceFileRenamed(object sender, FileRenameEventArgs e) { CallVisitor(new FileRenameTreeNodeVisitor(e.SourceFile, e.TargetFile)); }
static void OnFileRenamed(FileRenameEventArgs e) { if (FileRenamed != null) { FileRenamed(null, e); } }
/// <summary> /// Renames anchors without document. /// </summary> internal static void FileRenamed(FileRenameEventArgs e) { FileName sourceFile = new FileName(e.SourceFile); FileName targetFile = new FileName(e.TargetFile); foreach (PermanentAnchor anchor in permanentAnchors) { if (anchor.CurrentDocument == null) { if (e.IsDirectory) { if (FileUtility.IsBaseDirectory(e.SourceFile, anchor.FileName)) { anchor.SetFileName(new FileName(FileUtility.RenameBaseDirectory(anchor.FileName, e.SourceFile, e.TargetFile))); } } else { if (anchor.FileName == sourceFile) anchor.SetFileName(targetFile); } } } }