private void AddFileMonitor(string filepath) { var existingMonitor = FileMonitors.FirstOrDefault(m => string.Equals(m.FilePath, filepath, StringComparison.CurrentCultureIgnoreCase)); if (existingMonitor != null) { // Already being monitored SelectedItem = existingMonitor; return; } var monitorViewModel = new FileMonitorViewModel(filepath, GetFileNameForPath(filepath), Settings.Default.DefaultEncoding, Settings.Default.BufferedRead); monitorViewModel.Renamed += MonitorViewModelOnRenamed; monitorViewModel.Updated += MonitorViewModelOnUpdated; FileMonitors.Add(monitorViewModel); SelectedItem = monitorViewModel; }
private void Dispatcher_ShutdownStarted(object sender, EventArgs e) { FileMonitorViewModel vm = this.DataContext as FileMonitorViewModel; if (vm != null) { AppSettings appSettings = new AppSettings(); appSettings.InputDir = vm.InputDir; appSettings.OutputDir = vm.OutputDir; Registry.AppRegistry.SaveSettings(appSettings); } IDisposable disposable = this.DataContext as IDisposable; if (disposable != null) { disposable.Dispose(); } }
private void MonitorViewModelOnRenamed(FileMonitorViewModel renamedViewModel) { var filepath = renamedViewModel.FilePath; renamedViewModel.FileName = GetFileNameForPath(filepath); }
private void MonitorViewModelOnUpdated(FileMonitorViewModel obj) { _lastUpdateDateTime = DateTime.Now; _lastUpdatedViewModel = obj; RefreshLastUpdatedText(); }