public void AddFileMonitor(string filepath) { foreach (var fileMonitor in FileMonitors) { if (!fileMonitor.FilePath.Equals(filepath, StringComparison.InvariantCultureIgnoreCase)) { continue; } // Already being monitored SelectedFile = fileMonitor; return; } var monitorViewModel = new FileMonitorViewModel ( filepath, Path.GetFileName(filepath), Settings.Default.DefaultEncoding, Settings.Default.BufferedRead ); monitorViewModel.Renamed += MonitorViewModelOnRenamed; monitorViewModel.Updated += MonitorViewModelOnUpdated; FileMonitors.Add(monitorViewModel); SelectedFile = monitorViewModel; }
private static void MonitorViewModelOnRenamed(FileMonitorViewModel renamedFileMonitor) { var filepath = renamedFileMonitor.FilePath; renamedFileMonitor.FileName = Path.GetFileName(filepath); }
private void MonitorViewModelOnUpdated(FileMonitorViewModel fileMonitorViewModel) { _lastUpdateDateTime = DateTime.Now; _lastUpdatedViewModel = fileMonitorViewModel; RefreshLastUpdatedText(); }