using ComPDFKitViewer; using ComPDFKitViewer.PdfViewer; using PDF_Office.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_Office.ViewModels.PropertyPanel.PDFEdit { public class ImageTextEditPropertyViewModel : PDFEditVM, INavigationAware { #region 变量 protected List TextEditEventList; public event EventHandler ClearCheckedAglin; #endregion #region Command public DelegateCommand ImgAlignCheckedCommand { get; set; } #endregion public ImageTextEditPropertyViewModel() { ImgAlignCheckedCommand = new DelegateCommand(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(ParameterNames.PDFViewer, out PDFViewer); navigationContext.Parameters.TryGetValue>(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); } } }