using ComPDFKitViewer.PdfViewer; using PDF_Master.EventAggregators; using PDF_Master.Model; using Prism.Commands; using Prism.Events; using Prism.Mvvm; using Prism.Regions; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PDF_Master.ViewModels.PropertyPanel.Scan { class ScanPropertyPanelViewModel : BindableBase, INavigationAware { private int pageCount; public int PageCount { get { return pageCount; } set { SetProperty(ref pageCount, value); } } private List setPageRange; public List SetPageRange { get { return setPageRange; } set { SetProperty(ref setPageRange, value); } } private CPDFViewer PDFViewer; public IEventAggregator events; public DelegateCommand OCRCommand { get; set; } public DelegateCommand AreaCommand { get; set; } public DelegateCommand UnknownCommand { get; set; } public bool IsNavigationTarget(NavigationContext navigationContext) { return true; } public void OnNavigatedFrom(NavigationContext navigationContext) { return; } public void OnNavigatedTo(NavigationContext navigationContext) { navigationContext.Parameters.TryGetValue(ParameterNames.PDFViewer, out PDFViewer); if (PDFViewer == null) { return; } else { PageCount = PDFViewer.Document.PageCount; } } public ScanPropertyPanelViewModel(IEventAggregator eventAggregator) { setPageRange = new List(); events = eventAggregator; OCRCommand = new DelegateCommand(OCR); AreaCommand = new DelegateCommand(Area); UnknownCommand = new DelegateCommand(Unknown); } private void OCR() { try { events.GetEvent().Publish(new ScanEventArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, PageRange = SetPageRange, Mode = ScanMode.OCR, ScanLanguage = ScanLanguageMode.ChineseS } ); } catch (Exception e) { } } private void Area() { try { events.GetEvent().Publish(new ScanEventArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, PageRange = SetPageRange, Mode = ScanMode.Area, ScanLanguage = ScanLanguageMode.ChineseS } ); } catch (Exception e) { } } private void Unknown() { try { events.GetEvent().Publish(new ScanEventArgs() { Unicode = App.mainWindowViewModel.SelectedItem.Unicode, PageRange = SetPageRange, Mode = ScanMode.Unknown, ScanLanguage = ScanLanguageMode.ChineseS } ); } catch (Exception e) { } } } }