public override void CloseIfAllViewsClosed() { if (registeredViews.Count == 0) { bool wasDirty = this.IsDirty; fileService.OpenedFileClosed(this); FileClosed(this, EventArgs.Empty); if (fileChangeWatcher != null) { fileChangeWatcher.Dispose(); fileChangeWatcher = null; } if (wasDirty) { // We discarded some information when closing the file, // so we need to re-parse it. if (File.Exists(this.FileName)) { SD.ParserService.ParseAsync(this.FileName).FireAndForget(); } else { SD.ParserService.ClearParseInformation(this.FileName); } } } }
internal FileServiceOpenedFile(FileService fileService, FileName fileName) { this.fileService = fileService; this.FileName = fileName; IsUntitled = false; fileChangeWatcher = new FileChangeWatcher(this); }
internal FileServiceOpenedFile(FileService fileService, FileName fileName) { this.fileService = fileService; this.FileName = fileName; IsUntitled = false; fileChangeWatcher = new FileChangeWatcher(this); }
internal FileServiceOpenedFile(FileService fileService, byte[] fileData) { this.fileService = fileService; this.FileName = null; SetData(fileData); IsUntitled = true; MakeDirty(); fileChangeWatcher = new FileChangeWatcher(this); }
internal FileServiceOpenedFile(FileService fileService, byte[] fileData) { this.fileService = fileService; this.FileName = null; SetData(fileData); IsUntitled = true; MakeDirty(); fileChangeWatcher = new FileChangeWatcher(this); }
/// <summary> /// Renames or moves a file, raising the appropriate events. This method may show message boxes. /// </summary> public bool RenameFile(string oldName, string newName, bool isDirectory) { if (FileUtility.IsEqualFileName(oldName, newName)) { return(false); } FileChangeWatcher.DisableAllChangeWatchers(); try { FileRenamingEventArgs eargs = new FileRenamingEventArgs(oldName, newName, isDirectory); OnFileRenaming(eargs); if (eargs.Cancel) { return(false); } if (!eargs.OperationAlreadyDone) { try { if (isDirectory && Directory.Exists(oldName)) { if (Directory.Exists(newName)) { MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}")); return(false); } Directory.Move(oldName, newName); } else if (File.Exists(oldName)) { if (File.Exists(newName)) { MessageService.ShowMessage(StringParser.Parse("${res:Gui.ProjectBrowser.FileInUseError}")); return(false); } File.Move(oldName, newName); } } catch (Exception e) { if (isDirectory) { MessageService.ShowHandledException(e, "Can't rename directory " + oldName); } else { MessageService.ShowHandledException(e, "Can't rename file " + oldName); } return(false); } } OnFileRenamed(new FileRenameEventArgs(oldName, newName, isDirectory)); return(true); } finally { FileChangeWatcher.EnableAllChangeWatchers(); } }
/// <summary> /// Renames or moves a file, raising the appropriate events. This method may show message boxes. /// </summary> public bool RenameFile(string oldName, string newName, bool isDirectory) { if (FileUtility.IsEqualFileName(oldName, newName)) { return(false); } FileChangeWatcher.DisableAllChangeWatchers(); try { FileRenamingEventArgs eargs = new FileRenamingEventArgs(oldName, newName, isDirectory); OnFileRenaming(eargs); if (eargs.Cancel) { return(false); } if (!eargs.OperationAlreadyDone) { try { if (FileHelpers.CheckRenameOrReplacePossible(eargs)) { if (isDirectory) { Directory.Move(oldName, newName); } else { File.Move(oldName, newName); } } } catch (Exception e) { if (isDirectory) { MessageService.ShowHandledException(e, "Can't rename directory " + oldName); } else { MessageService.ShowHandledException(e, "Can't rename file " + oldName); } return(false); } } OnFileRenamed(new FileRenameEventArgs(oldName, newName, isDirectory)); return(true); } finally { FileChangeWatcher.EnableAllChangeWatchers(); } }
/// <summary> /// Renames or moves a file, raising the appropriate events. This method may show message boxes. /// </summary> public bool RenameFile(string oldName, string newName, bool isDirectory) { if (string.Equals(FileUtility.NormalizePath(oldName), FileUtility.NormalizePath(newName), StringComparison.Ordinal)) { return(false); } FileChangeWatcher.DisableAllChangeWatchers(); try { FileRenamingEventArgs eargs = new FileRenamingEventArgs(oldName, newName, isDirectory); OnFileRenaming(eargs); if (eargs.Cancel) { return(false); } if (!eargs.OperationAlreadyDone) { try { if (isDirectory) { Directory.Move(oldName, newName); } else { File.Move(oldName, newName); } } catch (Exception e) { if (isDirectory) { MessageService.ShowHandledException(e, "Can't rename directory " + oldName); } else { MessageService.ShowHandledException(e, "Can't rename file " + oldName); } return(false); } } OnFileRenamed(new FileRenameEventArgs(oldName, newName, isDirectory)); return(true); } finally { FileChangeWatcher.EnableAllChangeWatchers(); } }
public override void CloseIfAllViewsClosed() { if (registeredViews.Count == 0) { bool wasDirty = this.IsDirty; fileService.OpenedFileClosed(this); FileClosed(this, EventArgs.Empty); if (fileChangeWatcher != null) { fileChangeWatcher.Dispose(); fileChangeWatcher = null; } if (wasDirty) { // We discarded some information when closing the file, // so we need to re-parse it. if (File.Exists(this.FileName)) SD.ParserService.ParseAsync(this.FileName).FireAndForget(); else SD.ParserService.ClearParseInformation(this.FileName); } } }