Esempio n. 1
0
        public override void CloseIfAllViewsClosed()
        {
            if (registeredViews.Count == 0)
            {
                bool wasDirty = this.IsDirty;
                FileService.OpenedFileClosed(this);

                FileClosed.RaiseEvent(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))
                    {
                        ParserService.BeginParse(this.FileName);
                    }
                    else
                    {
                        ParserService.ClearParseInformation(this.FileName);
                    }
                }
            }
        }
Esempio n. 2
0
 internal FileServiceOpenedFile(byte[] fileData)
 {
     this.FileName = null;
     SetData(fileData);
     IsUntitled = true;
     MakeDirty();
     fileChangeWatcher = new FileChangeWatcher(this);
 }
Esempio n. 3
0
 /// <summary>
 /// Renames or moves a file, raising the appropriate events. This method may show message boxes.
 /// </summary>
 public static 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();
     }
 }
Esempio n. 4
0
        public override void CloseIfAllViewsClosed()
        {
            if (registeredViews.Count == 0)
            {
                FileService.OpenedFileClosed(this);

                if (fileChangeWatcher != null)
                {
                    fileChangeWatcher.Dispose();
                    fileChangeWatcher = null;
                }
            }
        }
Esempio n. 5
0
 internal FileServiceOpenedFile(string fileName)
 {
     this.FileName     = fileName;
     IsUntitled        = false;
     fileChangeWatcher = new FileChangeWatcher(this);
 }
Esempio n. 6
0
		public override void CloseIfAllViewsClosed()
		{
			if (registeredViews.Count == 0) {
				bool wasDirty = this.IsDirty;
				FileService.OpenedFileClosed(this);
				
				FileClosed.RaiseEvent(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))
						ParserService.BeginParse(this.FileName);
					else
						ParserService.ClearParseInformation(this.FileName);
				}
			}
		}
Esempio n. 7
0
		internal FileServiceOpenedFile(byte[] fileData)
		{
			this.FileName = null;
			SetData(fileData);
			IsUntitled = true;
			MakeDirty();
			fileChangeWatcher = new FileChangeWatcher(this);
		}
Esempio n. 8
0
		internal FileServiceOpenedFile(FileName fileName)
		{
			this.FileName = fileName;
			IsUntitled = false;
			fileChangeWatcher = new FileChangeWatcher(this);
		}
Esempio n. 9
0
		public override void CloseIfAllViewsClosed()
		{
			if (registeredViews.Count == 0) {
				FileService.OpenedFileClosed(this);
				
				if (fileChangeWatcher != null) {
					fileChangeWatcher.Dispose();
					fileChangeWatcher = null;
				}
			}
		}