#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. #endregion public MainViewModel(IOptionService optionService, IDirectoryService directoryService, IAppService infoService, IThemeService themeService) { // Initialize services _docLib = DocLib.Instance; _optionService = optionService; _directoryService = directoryService; _themeService = themeService; _infoService = infoService; // Initialize commands GetDirectory = ReactiveCommand.Create(BrowseDirectory); ReadPDF = ReactiveCommand.Create(() => { _th = new Thread(() => StartReading()); _th.IsBackground = true; _th.Start(); }, this.IsValid()); ChangeTheme = ReactiveCommand.Create(() => { themeService.ChangeTheme(); CurrentThemeName = themeService.GetCurrentThemeName(); }); ChangeLanguage = ReactiveCommand.Create(() => { infoService.ChangeLanguage(); CurrentLanguageName = infoService.GetCurrentLanguage(); UpdateStringResources(); }); // Initialize variables PrecisionOCR = new ObservableCollection <RecognitionPrecision>(Enum.GetValues(typeof(RecognitionPrecision)).Cast <RecognitionPrecision>()); LanguageOCR = new ObservableCollection <RecognitionLanguage>(Enum.GetValues(typeof(RecognitionLanguage)).Cast <RecognitionLanguage>()); Options = new SearchOptions("", "", PrecisionOCR.FirstOrDefault(), LanguageOCR.FirstOrDefault(), false, true, false, true, false, false); Results = new ObservableCollection <QueryResult>(); Stats = new ResultStats("0/0", true, 0, "0"); ResultInfo = infoService.GetSearchInfo(SearchInfo.Init); StatusName = infoService.GetSearchStatus(SearchStatus.Ready); CurrentThemeName = themeService.GetCurrentThemeName(); CurrentLanguageName = infoService.GetCurrentLanguage(); ItemsReady = false; // Subscribe for events and set validation rules ErrorsChanged += OnValidationErrorsChanged; this.ValidationRule(x => x.Options.Keyword, key => !string.IsNullOrEmpty(key), "Keyword cannot be empty!"); this.ValidationRule(x => x.Options.Path, key => !string.IsNullOrEmpty(key) && Directory.Exists(key), "Path has to be valid!"); // Get assembly version AppVersion = infoService.GetVersion(); }