12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using ComPDFKitViewer.PdfViewer;
- using PDF_Office.Model;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Regions;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography.X509Certificates;
- namespace PDF_Office.ViewModels.Tools
- {
- public class ToolsBarContentViewModel : BindableBase,INavigationAware
- {
- private CPDFViewer PDFViewer;
- private ViewContentViewModel viewContentViewModel;
- public IDialogService dialogs;
- /// <summary>
- /// 是否是第一次加载
- /// </summary>
- private bool isFirstLoad = true;
- public DelegateCommand CompressCommand { get; set; }
- public DelegateCommand SetPasswordCommand { get; set; }
- public DelegateCommand CancelPasswordCommand { get; set; }
- public ToolsBarContentViewModel(IDialogService dialogService)
- {
- dialogs= dialogService;
- CompressCommand = new DelegateCommand(OpenCompressDialog);
- SetPasswordCommand = new DelegateCommand(OpenSetPasswordDialog);
- CancelPasswordCommand = new DelegateCommand(OpenCancelPasswordDialog);
- }
- private void OpenCompressDialog()
- {
- DialogParameters value = new DialogParameters();
- value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
- dialogs.ShowDialog(DialogNames.CompressDialog, value, e => { });
- }
- private void OpenSetPasswordDialog()
- {
- DialogParameters value = new DialogParameters();
- value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
- dialogs.ShowDialog(DialogNames.SetPasswordDialog, value, e => { });
- }
- private void OpenCancelPasswordDialog()
- {
- DialogParameters value = new DialogParameters();
- value.Add(ParameterNames.PDFDocument, PDFViewer.Document);
- dialogs.ShowDialog(DialogNames.DeleteSafetySettingsDialog, value, e => { });
- }
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
- navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
- if (PDFViewer != null)
- {
- isFirstLoad = false;
- }
- }
- }
- }
|