123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- 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<CustomIconToggleBtn>(BtnMyTools_Click);
- PropertyRegionName = Guid.NewGuid().ToString();
- BindingEvent();
- InitDefaultValue();
- }
- private Dictionary<string, bool> ToolExpandDict = new Dictionary<string, bool>();
- 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<AnnotArgsType, object> 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<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
- navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
- // navigationContext.Parameters.TryGetValue<PropertyPanelContentViewModel>(ParameterNames.PropertyPanelContentViewModel, out propertyPanelContentViewModel);
-
- if (PDFViewer != null)
- {
- }
- }
- /// <summary>
- /// 展开显示属性面板
- /// </summary>
- private void ShowPropertyPanel(bool show=true)
- {
- viewContentViewModel.IsPropertyOpen = show;
- }
- }
-
- }
|