public MainWindowViewModel(Window windowForLanguageSupport, LeftSideViewModel leftSideViewModel,RightSideViewModel rightSideViewModel) { _windowForLanguageSupport = windowForLanguageSupport; _rightSideViewModel = rightSideViewModel; leftSideViewModel.RecoginedEvent += _leftSideViewModel_RecoginedEvent; _rightSideViewModel.LanguageEvent += _rightSideViewModel_LanguageEvent; leftSideViewModel.ExitEvent += LeftSideViewModelOnExitEvent; ChangeLanguage(); //var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); //var culturesName = cultures.Select(cultureInfo => cultureInfo.ThreeLetterWindowsLanguageName).ToList(); //var uniqueCultures = culturesName.Distinct().ToArray(); var filesName = new List<string>(); var path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\(a9t9)OcrDesktop\tessdata"; if (Directory.Exists(path)) { string[] filePaths = Directory.GetFiles(path, @"*.traineddata"); filesName.AddRange(filePaths.Select(f => new FileInfo(f)).Select(fi => fi.Name.Split('.')[0])); _rightSideViewModel.OcrLanguages = new ObservableCollection<string>(filesName); } else _rightSideViewModel.OcrLanguages = new ObservableCollection<string>(new List<string>()); _rightSideViewModel.CurrentOcrLanguage = "eng"; CloseWindowCommand = new RelayCommand(CloseWindow); MaximizeWindowCommand = new RelayCommand(MaximizeWindow); MinimizeWindowCommand = new RelayCommand(MinimizeWindow); }
public MainWindowViewModel(Window windowForLanguageSupport, LeftSideViewModel leftSideViewModel, RightSideViewModel rightSideViewModel) { _windowForLanguageSupport = windowForLanguageSupport; _rightSideViewModel = rightSideViewModel; leftSideViewModel.RecoginedEvent += _leftSideViewModel_RecoginedEvent; _rightSideViewModel.LanguageEvent += _rightSideViewModel_LanguageEvent; leftSideViewModel.ExitEvent += LeftSideViewModelOnExitEvent; ChangeLanguage(); //var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); //var culturesName = cultures.Select(cultureInfo => cultureInfo.ThreeLetterWindowsLanguageName).ToList(); //var uniqueCultures = culturesName.Distinct().ToArray(); var filesName = new List <string>(); var path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\(a9t9)OcrDesktop\tessdata"; if (Directory.Exists(path)) { string[] filePaths = Directory.GetFiles(path, @"*.traineddata"); filesName.AddRange(filePaths.Select(f => new FileInfo(f)).Select(fi => fi.Name.Split('.')[0])); _rightSideViewModel.OcrLanguages = new ObservableCollection <string>(filesName); } else { _rightSideViewModel.OcrLanguages = new ObservableCollection <string>(new List <string>()); } _rightSideViewModel.CurrentOcrLanguage = "eng"; CloseWindowCommand = new RelayCommand(CloseWindow); MaximizeWindowCommand = new RelayCommand(MaximizeWindow); MinimizeWindowCommand = new RelayCommand(MinimizeWindow); }
//I'm a newbie in mvvm, so i don't know how to move this to mvvm model :) private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { Height = Properties.Settings.Default.Height; Width = Properties.Settings.Default.Width; var tess = new TesseractOcr("eng"); var leftVm = new LeftSideViewModel(tess); LeftSideControl.DataContext = leftVm; var rightVm = new RightSideViewModel(tess); RightSideControl.DataContext = rightVm; var view = new MainWindowViewModel(this, leftVm, rightVm); DataContext = view; MenuItemFile.DataContext = leftVm; MenuItemHelp.DataContext = leftVm; MenuItemSave.DataContext = rightVm; //not yet MenuItemLanguage.DataContext = rightVm; }