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 CreateFromScanner { get; set; } #endregion public HomeFilesContentViewModel() { OpenFileCommand = new DelegateCommand(OpenFile); CreateBlackPDFCommand = new DelegateCommand(CreatBlankPDF); CreateFromOtherFile = new DelegateCommand(createFromOtherFile); CreateFromScanner = new DelegateCommand(createFromScanner); InitString(); } #region 函数逻辑 /// /// 从扫描仪创建 /// private void createFromScanner(string args) { if (homeContentViewModel != null) { DataTrackingHelper.SendEvent(DataTrackingHelper.EventType.Home, "Create_Btn", "Import From Scanner"); homeContentViewModel.createFromScanner(""); } } /// /// 打开文件 /// public void OpenFile() { if (homeContentViewModel != null) { homeContentViewModel.OpenFile(); } } /// /// 创建空白文档 /// public void CreatBlankPDF() { if (homeContentViewModel != null) { DataTrackingHelper.SendEvent(DataTrackingHelper.EventType.Home, "Create_Btn", "New Blank Page"); homeContentViewModel.CreatBlankPDF(); } } /// /// 从其他格式文件创建PDF /// 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(ParameterNames.HomeContentViewModel, out homeContentViewModel); } public bool IsNavigationTarget(NavigationContext navigationContext) { return true; } public void OnNavigatedFrom(NavigationContext navigationContext) { } #endregion } }