/// <summary> /// Update log view. /// </summary> private void Update() { // If file watcher is active, use delayed update. if (FileWatcherController.IsActive()) { lock (_lockUpdateTimer) { if (!_updateTimer.Enabled) { _updateTimer.Enabled = true; } } } else { lock (_lockUpdateTimer) { if (_updateTimer.Enabled) { _updateTimer.Enabled = false; } } _logView.Update(LogMessages()); } }
/// <summary> /// Updates main view list. /// </summary> /// <param name="forceUpdate">Force update even if file watcher controller is running.</param> private void UpdateList(bool forceUpdate) { // True if to update. _updateInfo = true; // If file watcher is active, use delayed update. if (FileWatcherController.IsActive()) { if (!_updateTimer.Enabled) { _updateTimer.Enabled = true; } if (forceUpdate) { _mainView.UpdateList(_fileWatcherSortedDictionary); } } else { if (_updateTimer.Enabled) { _updateTimer.Enabled = false; } _mainView.UpdateList(_fileWatcherSortedDictionary); } }
/// <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(); }