Ejemplo n.º 1
0
 private int DeleteFilesForNotepad(Notepad notepad)
 {
     int numDeleted = 0;
     try
     {
         lock (notepad.FileLock)
         {
             foreach (
                 string filename in
                     Directory.GetFiles(SavedTextDirectory, string.Format("{0} *.txt", notepad.NotepadId)))
             {
                 try
                 {
                     File.Delete(Path.Combine(SavedTextDirectory, filename));
                 }
                 catch (Exception ex)
                 {
                     Log("Exception trying to delete notepad at " + filename, ex);
                 }
                 numDeleted++;
             }
         }
     }
     catch (Exception ex)
     {
         Log("Exception when deleting files for notepad " + notepad.NotepadId, ex);
     }
     return numDeleted;
 }
Ejemplo n.º 2
0
 public bool SaveSnapshot(Notepad notepad)
 {
     try
     {
         string text = notepad.GetWindowText();
         string notepadTitle = notepad.GetNotepadTitle();
         string filename = string.Format("{0} {1}.txt", notepad.NotepadId, notepadTitle);
         string fullpath = Path.Combine(SavedTextDirectory, filename);
         DeleteFilesForNotepad(notepad);
         lock (notepad.FileLock)
         {
             File.WriteAllText(fullpath, text);
         }
         return true;
     }
     catch (Notepad.NotepadDeadException)
     {
     }
     catch (Exception ex)
     {
         Log("Exception saving notepad snapshot", ex, notepad.Pid);
     }
     return false;
 }
Ejemplo n.º 3
0
 public Notepad RegisterNewNotepad(Notepad notepad)
 {
     Notepad gotten = _notepads.GetOrAdd(notepad.NotepadId, notepad);
     if (!object.ReferenceEquals(gotten, notepad))
     {
         gotten.Pid = notepad.Pid;
     }
     NotepadCountMayHaveChanged();
     return gotten;
 }
Ejemplo n.º 4
0
 public void OnProcessExit(Notepad notepad, int exitCode)
 {
     if (exitCode == 0 && !_sessionEnded)
     {
         DeleteFilesForNotepad(notepad);
     }
     Notepad removed;
     _notepads.TryRemove(notepad.NotepadId, out removed);
     NotepadCountMayHaveChanged();
 }
Ejemplo n.º 5
0
 public void OnPingFailure(Notepad notepad)
 {
     Notepad removed;
     _notepads.TryRemove(notepad.NotepadId, out removed);
     NotepadCountMayHaveChanged();
 }
Ejemplo n.º 6
0
 public NotepadHookInstalledEventArgs(Notepad notepad)
 {
     this.Notepad = notepad;
 }