123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using ComPDFKitViewer;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Master.Model;
- using Prism.Commands;
- using Prism.Mvvm;
- using Prism.Regions;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PDF_Master.ViewModels.PropertyPanel.PDFEdit
- {
- public class ImageTextEditPropertyViewModel : PDFEditVM, INavigationAware
- {
- #region 变量
- protected List<ComPDFKitViewer.PDFEditEvent> TextEditEventList;
- public event EventHandler ClearCheckedAglin;
- #endregion
- #region Command
- public DelegateCommand<object> ImgAlignCheckedCommand { get; set; }
- #endregion
- public ImageTextEditPropertyViewModel()
- {
- ImgAlignCheckedCommand = new DelegateCommand<object>(ImgAlignChecked);
- }
- #region Command实现
- private void ImgAlignChecked(object obj)
- {
- if (obj != null)
- {
- switch ((string)obj)
- {
- case "AlignLeft":
- PDFViewer.SetPDFEditAligment(AlignModes.AlignLeft);
- break;
- case "AlignHorizonCenter":
- PDFViewer.SetPDFEditAligment(AlignModes.AlignHorizonCenter);
- break;
- case "AlignRight":
- PDFViewer.SetPDFEditAligment(AlignModes.AlignRight);
- break;
- case "DistributeHorizontal":
- PDFViewer.SetPDFEditAligment(AlignModes.DistributeHorizontal);
- break;
- case "AlignTop":
- PDFViewer.SetPDFEditAligment(AlignModes.AlignTop);
- break;
- case "AlignVerticalCenter":
- PDFViewer.SetPDFEditAligment(AlignModes.AlignVerticalCenter);
- break;
- case "AlignBottom":
- PDFViewer.SetPDFEditAligment(AlignModes.AlignBottom);
- break;
- case "DistributeVertical":
- PDFViewer.SetPDFEditAligment(AlignModes.DistributeVertical);
- break;
- }
- }
- }
- #endregion
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
- navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
- navigationContext.Parameters.TryGetValue<List<PDFEditEvent>>(ParameterNames.AnnotEvent, out TextEditEventList);
- if (PDFViewer != null)
- {
-
- if (TextEditEventList != null && TextEditEventList.Count > 0)
- {
- TextEditEvent = TextEditEventList[0];
-
- if (TextEditEventList.Count == 2)
- {
- IsLayoutAlign = true;
- IsLayoutAvgAlign = false;
- }
- else if (TextEditEventList.Count > 2)
- {
- IsLayoutAlign = true;
- IsLayoutAvgAlign = true;
- }
- else
- {
- IsLayoutAlign = false;
- IsLayoutAvgAlign = false;
- }
-
- }
- }
- }
-
- public bool IsNavigationTarget(NavigationContext navigationContext) { return true; }
-
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
-
- ClearCheckedAglin?.Invoke(null, null);
- }
- }
- }
|