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"); } }
public static void AddDocumentToWatcher(DocumentWatcher d) { if (!Watchers.Contains(d)) { Watchers.Add(d); } }
public static void RemoveDocumentFromWatcher(DocumentWatcher d) { Watchers.Remove(d); }