using ComPDFKit.PDFAnnotation; using ComPDFKitViewer; using ComPDFKitViewer.AnnotEvent; using ComPDFKitViewer.PdfViewer; using Microsoft.Win32; using PDF_Office.CustomControl; using PDF_Office.Helper; using PDF_Office.Model; using PDF_Office.Properties; using PDF_Office.ViewModels.PropertyPanel; using PDF_Office.Views.PropertyPanel.AnnotPanel; using PDFSettings; 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; using System.Windows; using System.Windows.Controls; using System.Windows.Media; namespace PDF_Office.ViewModels.Tools { public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware { public AnnotToolContentViewModel(IRegionManager regionManager) { region = regionManager; MyToolsCommand = new DelegateCommand(BtnMyTools_Click); PropertyRegionName = Guid.NewGuid().ToString(); BindingEvent(); InitDefaultValue(); } private Dictionary ToolExpandDict = new Dictionary(); public void BtnMyTools_Click(CustomIconToggleBtn annotBtn) { if(annotBtn.IsChecked == true) { AnnotHandlerEventArgs annotArgs = null; switch (annotBtn.Tag.ToString()) { case "SnapshotEdit": break; case "HighLight": annotArgs = GetHighLight(); break; case "UnderLine": annotArgs = GetUnderLine(); break; case "Squiggly": annotArgs = GetSquiggly(); break; case "Strikeout": annotArgs = GetStrikeout(); break; case "Freehand": annotArgs = GetFreehand(); break; case "Freetext": annotArgs = GetFreetext(); break; case "StickyNote": annotArgs = GetStickyNote(); break; case "Rect": annotArgs = GetRect(); break; case "Circle": annotArgs = GetCircle(); break; case "Arrow": case "Line": annotArgs = GetArrowLine(annotBtn.Tag.ToString()); break; case "Stamp": annotArgs = GetStamp(); break; case "Image": annotArgs = GetImage(annotBtn); break; case "Signature": break; case "Link": break; } if (annotArgs != null) { annotArgs.Author = Settings.Default.AppProperties.Description.Author; PDFViewer.SetMouseMode(MouseModes.AnnotCreate); PDFViewer.SetToolParam(annotArgs); } ShowPropertyPanel(); } else { PDFViewer.SetMouseMode(MouseModes.PanTool); viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent",null); ShowPropertyPanel(false); } } private void AnnotProperty_DefaultStored(object sender, object e) { } private void AnnotPropertyPanel_DataChanged(object sender, Dictionary e) { if (e != null) { foreach (AnnotArgsType argsType in e.Keys) { switch (argsType) { case AnnotArgsType.AnnotHighlight: if (e[argsType] is Color) { HighLightColor = new SolidColorBrush((Color)e[argsType]); } if (e[argsType] is double) { HighLightOpacity = (double)e[argsType]; } break; case AnnotArgsType.AnnotUnderline: if (e[argsType] is Color) { UnderLineColor = new SolidColorBrush((Color)e[argsType]); } if (e[argsType] is double) { underLineOpacity = (double)e[argsType]; } break; case AnnotArgsType.AnnotSquiggly: if (e[argsType] is Color) { SquigglyColor = new SolidColorBrush((Color)e[argsType]); } if (e[argsType] is double) { SquigglyOpacity = (double)e[argsType]; } break; case AnnotArgsType.AnnotStrikeout: if (e[argsType] is Color) { StrikeoutColor = new SolidColorBrush((Color)e[argsType]); } if (e[argsType] is double) { StrikeoutOpacity = (double)e[argsType]; } break; } } } } public IRegionManager region; public string PropertyRegionName { get; set; } public bool IsNavigationTarget(NavigationContext navigationContext) { return true; } public void OnNavigatedFrom(NavigationContext navigationContext) { } public void OnNavigatedTo(NavigationContext navigationContext) { navigationContext.Parameters.TryGetValue(ParameterNames.ViewContentViewModel, out viewContentViewModel); navigationContext.Parameters.TryGetValue(ParameterNames.PDFViewer, out PDFViewer); // navigationContext.Parameters.TryGetValue(ParameterNames.PropertyPanelContentViewModel, out propertyPanelContentViewModel); if (PDFViewer != null) { } } /// /// 展开显示属性面板 /// private void ShowPropertyPanel(bool show=true) { viewContentViewModel.IsPropertyOpen = show; } } }