Example #1
0
 public static void CheckForChangedDocuments()
 {
     try
     {
         // for loop because async modifications stuff
         for (int i = 0; i < Watchers.Count; i++)
         {
             DocumentWatcher watcher = Watchers[i];
             if (watcher != null && watcher.IsEnabled && watcher.Document.FilePath.IsFile())
             {
                 FileInfo fInfo = new FileInfo(watcher.Document.FilePath);
                 if (watcher.Document.FileSizeBytes != fInfo.Length)
                 {
                     watcher.FileContentsChanged?.Invoke();
                 }
                 if (PreferencesG.CHECK_FILENAME_CHANGES_IN_DOCUMENT_WATCHER && watcher.Document.FileName != fInfo.Name)
                 {
                     watcher.FileNameChanged?.Invoke(fInfo.Name);
                 }
                 watcher.Document.PreviewSetReadOnly(fInfo.IsReadOnly);
             }
         }
     }
     catch (Exception e)
     {
         Information.Show($"Exception in File Watcher: {e.Message}", "FileWatcher");
     }
 }
Example #2
0
 public static void AddDocumentToWatcher(DocumentWatcher d)
 {
     if (!Watchers.Contains(d))
     {
         Watchers.Add(d);
     }
 }
Example #3
0
 public static void RemoveDocumentFromWatcher(DocumentWatcher d)
 {
     Watchers.Remove(d);
 }