コード例 #1
0
 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;
             }
         }
     }
 }
コード例 #2
0
        /// <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);
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: FileService.cs プロジェクト: olesar/Altaxo
 private void OnFileCopied(FileRenameEventArgs e)
 {
     if (FileCopied != null)
     {
         FileCopied(this, e);
     }
 }
コード例 #4
0
ファイル: Solution.cs プロジェクト: cffjfz/SharpDevelop
        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));
                        }
                    }
                }
            }
        }
コード例 #5
0
 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;
             }
         }
     }
 }
コード例 #6
0
ファイル: NavigationService.cs プロジェクト: olesar/Altaxo
 /// <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);
         }
     }
 }
コード例 #7
0
 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));
     }
 }
コード例 #8
0
ファイル: ProjectService.cs プロジェクト: carlhuth/GenXSource
        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));
                        }
                    }
                }
            }
        }
コード例 #9
0
ファイル: FileHelpers.cs プロジェクト: olesar/Altaxo
 /// <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);
 }
コード例 #10
0
        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);
                }
            }
        }
コード例 #11
0
ファイル: WpfWorkbench.cs プロジェクト: Amichai/SharpDevelop
 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);
 }
コード例 #12
0
		/// <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);
				}
			}
		}
コード例 #13
0
ファイル: RecentOpen.cs プロジェクト: Rpinski/SharpDevelop
		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;
				}
			}
		}
コード例 #14
0
 void FileServiceFileRenamed(object sender, FileRenameEventArgs e)
 {
     CallVisitor(new FileRenameTreeNodeVisitor(e.SourceFile, e.TargetFile));
 }
コード例 #15
0
		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;
					}
				}
			}
		}
コード例 #16
0
		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));
			}
		}
コード例 #17
0
ファイル: FileService.cs プロジェクト: Gameman/PlayStudio
 static void OnFileRenamed(FileRenameEventArgs e)
 {
     if (FileRenamed != null)
     {
         FileRenamed(null, e);
     }
 }
コード例 #18
0
ファイル: WpfWorkbench.cs プロジェクト: pluraldj/SharpDevelop
		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);
		}
コード例 #19
0
		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;
					}
				}
			}
		}
コード例 #20
0
		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);
				}
			}
		}
コード例 #21
0
		void FileServiceFileRenamed(object sender, FileRenameEventArgs e)
		{
			CallVisitor(new FileRenameTreeNodeVisitor(e.SourceFile, e.TargetFile));
		}
コード例 #22
0
		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));
						}
					}
				}
			}
		}
コード例 #23
0
		/// <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);
					}
				}
			}
		}