123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- 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<int> setPageRange;
- public List<int> 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<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
- if (PDFViewer == null)
- {
- return;
- }
- else
- {
- PageCount = PDFViewer.Document.PageCount;
- }
- }
- public ScanPropertyPanelViewModel(IEventAggregator eventAggregator)
- {
- setPageRange = new List<int>();
- events = eventAggregator;
- OCRCommand = new DelegateCommand(OCR);
- AreaCommand = new DelegateCommand(Area);
- UnknownCommand = new DelegateCommand(Unknown);
- }
- private void OCR()
- {
- try
- {
- events.GetEvent<ScanEvent>().Publish(new ScanEventArgs()
- {
- Unicode = App.mainWindowViewModel.SelectedItem.Unicode,
- PageRange = SetPageRange,
- Mode = ScanMode.OCR,
- ScanLanguage = ScanLanguageMode.ChineseS
- }
- );
- }
- catch
- {
- }
- }
- private void Area()
- {
- try
- {
- events.GetEvent<ScanEvent>().Publish(new ScanEventArgs()
- {
- Unicode = App.mainWindowViewModel.SelectedItem.Unicode,
- PageRange = SetPageRange,
- Mode = ScanMode.Area,
- ScanLanguage = ScanLanguageMode.ChineseS
- }
- );
- }
- catch
- {
- }
- }
- private void Unknown()
- {
- try
- {
- events.GetEvent<ScanEvent>().Publish(new ScanEventArgs()
- {
- Unicode = App.mainWindowViewModel.SelectedItem.Unicode,
- PageRange = SetPageRange,
- Mode = ScanMode.Unknown,
- ScanLanguage = ScanLanguageMode.ChineseS
- }
- );
- }
- catch
- {
- }
- }
- }
- }
|