public FileInfo GetLastFile() { if (_settingsHandler.GetAttachLastFileFromLocation()) { var pathToSearch = _settingsHandler.GetLastFileToAttachLocation(); var directoryInfo = new DirectoryInfo(pathToSearch); if (directoryInfo != null) { var latestFile = directoryInfo.GetFiles().OrderByDescending(f => f.LastWriteTime).FirstOrDefault(); return(latestFile); } } return(null); }
public SettingsViewModel(ISettingsHandler settingsHandler, IDisplayHandler displayHandler, IOpenFileDialog openFileDialog) { _settingsHandler = settingsHandler ?? throw new ArgumentException("Parameter cannot be null", nameof(settingsHandler)); _displayHandler = displayHandler ?? throw new ArgumentException("Parameter cannot be null", nameof(displayHandler)); _openFileDialog = openFileDialog ?? throw new ArgumentException("Parameter cannot be null", nameof(openFileDialog)); _checkInterval = settingsHandler.GetCheckInterval(); _autoStart = settingsHandler.GetAutoStart(); _attachLastFileFromLocation = settingsHandler.GetAttachLastFileFromLocation(); _lastFileToAttachLocation = settingsHandler.GetLastFileToAttachLocation(); var displays = _displayHandler.Get().Select(d => new DisplayViewModel(d, SaveDisplaySettings)); _displays = new ObservableCollection <DisplayViewModel>(displays); _isExpanded = settingsHandler.GetSettingsIsExpanded(); }