123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- using ComPDFKitViewer.AnnotEvent;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Office.Model;
- using PDF_Office.Model.AnnotPanel;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Regions;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PDF_Office.ViewModels.PropertyPanel.AnnotPanel
- {
- class SignatureAnnotPropertyViewModel : BindableBase, INavigationAware
- {
- private CPDFViewer PDFViewer;
- private IDialogService dialogs;
- public DelegateCommand ShowDialogCommand { get; set; }
- public ObservableCollection<Signature> SignatureList { get; set; }
- public SignatureAnnotPropertyViewModel(IDialogService dialogService)
- {
- dialogs = dialogService;
- ShowDialogCommand = new DelegateCommand(ShowDialog);
- SignatureList = new ObservableCollection<Signature>();
- }
- public void SetSignature(Signature signature)
- {
- switch (signature.Type)
- {
- case SignatureType.TextType:
- case SignatureType.ImageType:
- StampAnnotArgs stampArgs = new StampAnnotArgs();
- stampArgs.Opacity = 1;
- stampArgs.Type = StampType.IMAGE_STAMP;
- stampArgs.ImagePath = signature.SourcePath;
- PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
- PDFViewer.SetToolParam(stampArgs);
- break;
- case SignatureType.Drawing:
- break;
- default:
- break;
- }
- }
- private void ShowDialog()
- {
- bool result = true;
- DialogParameters value = new DialogParameters();
- value.Add(ParameterNames.PDFViewer, PDFViewer);
- dialogs.ShowDialog(DialogNames.SignatureCreateDialog, value, e =>
- {
- if (e.Result != ButtonResult.OK)
- {
- result = false;
- }
- SignatureCreateDialogViewModel DialogVM = e.Parameters.GetValue<SignatureCreateDialogViewModel>(ParameterNames.DataModel);
- if (DialogVM != null)
- {
- CreateSignature(DialogVM);
- }
- });
- if (!result)
- {
- return;
- }
- }
- /// <summary>
- /// 创建签名,并保存到APP缓存
- /// </summary>
- /// <param name="viewModel"></param>
- private void CreateSignature(SignatureCreateDialogViewModel viewModel)
- {
- Signature Signature = new Signature();
- Signature.SourcePath = viewModel.SaveToPath;
- Signature.Type = (SignatureType)viewModel.TabItemIndex;
- SignatureList.Add(Signature);
- }
- 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;
- }
- }
- }
- }
|