/// <summary> /// Enables or disables controls. /// </summary> private void UpdateControls() { _mainView.StartEnabled = false; _mainView.StopEnabled = false; _mainView.DeleteEnabled = false; _mainView.PropertiesEnabled = false; _mainView.StartAllEnabled = FileWatcherController.CanStartAllFileWatchers(); _mainView.StopAllEnabled = FileWatcherController.CanStopAllFileWatchers(); _mainView.NewEnabled = FileWatcherController.CanAddFileWatcherConfiguration(); _mainView.ExitEnabled = !FileWatcherController.IsActive(); }
/// <summary> /// Stops file watchers. /// </summary> private void StopAllFileWatchers() { // Avoid deadlock if all file watchers have invalid path by checking IsActive. while (!FileWatcherController.CanStopAllFileWatchers() && FileWatcherController.IsActive()) { // Wait for starting file watchers. _canStopAll.WaitOne(); } if (FileWatcherController.CanStopAllFileWatchers()) { FileWatcherController.StopAllFileWatchers(); } }
/// <summary> /// Enables or disables controls. /// </summary> /// <param name="selectedDaemon">Selected daemon name.</param> private void UpdateControls(string selectedDaemon) { _mainView.StartEnabled = FileWatcherController.CanStartFileWatcher(selectedDaemon); _mainView.StopEnabled = FileWatcherController.CanStopFileWatcher(selectedDaemon); _mainView.StartAllEnabled = FileWatcherController.CanStartAllFileWatchers(); _mainView.StopAllEnabled = FileWatcherController.CanStopAllFileWatchers(); _mainView.NewEnabled = FileWatcherController.CanAddFileWatcherConfiguration(); bool canEdit = FileWatcherController.CanEditFileWatcherConfiguration(); _mainView.DeleteEnabled = canEdit; _mainView.PropertiesEnabled = canEdit; _mainView.ExitEnabled = !FileWatcherController.IsActive(); }