123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- using Microsoft.Office.Interop.Word;
- using Microsoft.Win32;
- using PDF_Master.Helper;
- using PDF_Master.Model;
- using PDFReader_WPF.Helper;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Regions;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace PDF_Master.ViewModels.HomePanel.PDFTools
- {
- public class HomeFilesContentViewModel : BindableBase, INavigationAware
- {
- #region 文案
- private string T_openPDFTitle;
- public string T_OpenPDFTitle
- {
- get { return T_openPDFTitle; }
- set
- {
- SetProperty(ref T_openPDFTitle, value);
- }
- }
- private string T_openPDFBtn;
- public string T_OpenPDFBtn
- {
- get { return T_openPDFBtn; }
- set
- {
- SetProperty(ref T_openPDFBtn, value);
- }
- }
- private string T_openPDFDropTip;
- public string T_OpenPDFDropTip
- {
- get { return T_openPDFDropTip; }
- set
- {
- SetProperty(ref T_openPDFDropTip, value);
- }
- }
- private string T_createPDFTitle;
- public string T_CreatePDFTitle
- {
- get { return T_createPDFTitle; }
- set
- {
- SetProperty(ref T_createPDFTitle, value);
- }
- }
- private string T_createPDFNewFromFilesBtn;
- public string T_CreatePDFNewFromFilesBtn
- {
- get { return T_createPDFNewFromFilesBtn; }
- set
- {
- SetProperty(ref T_createPDFNewFromFilesBtn, value);
- }
- }
- private string T_createPDFNewBlankPageBtn;
- public string T_CreatePDFNewBlankPageBtn
- {
- get { return T_createPDFNewBlankPageBtn; }
- set
- {
- SetProperty(ref T_createPDFNewBlankPageBtn, value);
- }
- }
- private string T_createPDFFromScannerBtn;
- public string T_CreatePDFFromScannerBtn
- {
- get { return T_createPDFFromScannerBtn; }
- set
- {
- SetProperty(ref T_createPDFFromScannerBtn, value);
- }
- }
- private void InitString()
- {
- T_OpenPDFTitle = App.HomePageLoader.GetString("HomeBtn_OpenPDFTitle");
- T_OpenPDFBtn = App.HomePageLoader.GetString("HomeBtn_OpenPDFBtn");
- T_OpenPDFDropTip = App.HomePageLoader.GetString("HomeBtn_OpenPDFDropTip");
- T_CreatePDFTitle = App.HomePageLoader.GetString("HomeBtn_CreatePDFTitle");
- T_CreatePDFNewFromFilesBtn = App.HomePageLoader.GetString("HomeBtn_CreatePDFNewFromFilesBtn");
- T_CreatePDFNewBlankPageBtn = App.HomePageLoader.GetString("HomeBtn_CreatePDFNewBlankPageBtn");
- T_CreatePDFFromScannerBtn = App.HomePageLoader.GetString("HomeBtn_CreatePDFFromScannerBtn");
- }
- #endregion
- #region 属性和参数
- HomeContentViewModel homeContentViewModel = null;
- private int creatGridRowIndex = 0;
- public int CreatGridRowIndex
- {
- get { return creatGridRowIndex; }
- set
- {
- SetProperty(ref creatGridRowIndex, value);
- }
- }
- private int creatGridColumnIndex = 1;
- public int CreatGridColumnIndex
- {
- get { return creatGridColumnIndex; }
- set
- {
- SetProperty(ref creatGridColumnIndex, value);
- }
- }
- #endregion
- #region 委托声明
- public DelegateCommand OpenFileCommand { get; set; }
- public DelegateCommand CreateBlackPDFCommand { get; set; }
- public DelegateCommand CreateFromOtherFile { get; set; }
- public DelegateCommand<string> CreateFromScanner { get; set; }
- #endregion
- public HomeFilesContentViewModel()
- {
- OpenFileCommand = new DelegateCommand(OpenFile);
- CreateBlackPDFCommand = new DelegateCommand(CreatBlankPDF);
- CreateFromOtherFile = new DelegateCommand(createFromOtherFile);
- CreateFromScanner = new DelegateCommand<string>(createFromScanner);
- InitString();
- }
- #region 函数逻辑
- /// <summary>
- /// 从扫描仪创建
- /// </summary>
- private void createFromScanner(string args)
- {
- if (homeContentViewModel != null)
- {
- DataTrackingHelper.SendEvent(DataTrackingHelper.EventType.Home, "Create_Btn", "Import From Scanner");
- homeContentViewModel.createFromScanner("");
- }
- }
- /// <summary>
- /// 打开文件
- /// </summary>
- public void OpenFile()
- {
- if (homeContentViewModel != null)
- {
- homeContentViewModel.OpenFile();
- }
- }
- /// <summary>
- /// 创建空白文档
- /// </summary>
- public void CreatBlankPDF()
- {
- if (homeContentViewModel != null)
- {
- DataTrackingHelper.SendEvent(DataTrackingHelper.EventType.Home, "Create_Btn", "New Blank Page");
- homeContentViewModel.CreatBlankPDF();
- }
- }
- /// <summary>
- /// 从其他格式文件创建PDF
- /// </summary>
- private void createFromOtherFile()
- {
- if (homeContentViewModel != null)
- {
- DataTrackingHelper.SendEvent(DataTrackingHelper.EventType.Home, "Create_Btn", "New From File");
- homeContentViewModel.createFromOtherFile();
- }
- }
- #endregion
- #region 框架行为
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- navigationContext.Parameters.TryGetValue<HomeContentViewModel>(ParameterNames.HomeContentViewModel, out homeContentViewModel);
- }
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- }
- #endregion
- }
- }
|