123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- using ComPDFKitViewer;
- using ComPDFKitViewer.AnnotEvent;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Office.CustomControl;
- using PDF_Office.Helper;
- using PDF_Office.ViewModels.PropertyPanel.AnnotPanel;
- using PDF_Office.Views.PropertyPanel.AnnotPanel;
- using PDFSettings.Settings;
- using Prism.Commands;
- using Prism.Events;
- using Prism.Regions;
- using Prism.Services.Dialogs;
- using System;
- using System.Collections.Generic;
- using System.Windows.Media;
- namespace PDF_Office.ViewModels.Tools
- {
- /// <summary>
- /// 改变工具栏注释属性值,主要用来传参数:注释属性和同步工具栏对应图标的属性(颜色)
- /// </summary>
- public class AnnotPropertyPanel
- {
- public bool IsAddLink = false;
- public bool IsLocationLink = false;
- public AnnotAttribEvent AnnotEvent { get; set; }
- public List<AnnotAttribEvent> AnnotEvents = new List<AnnotAttribEvent>();
- public AnnotHandlerEventArgs annot;
- public List<AnnotHandlerEventArgs> annotlists;
- public bool IsTextFill { get; private set; }
- public void SetIsTextFill(bool isTextFill)
- {
- IsTextFill = isTextFill;
- }
- public event EventHandler<Dictionary<AnnotArgsType, object>> DataChanged;
- public event EventHandler<Dictionary<AnnotArgsType, object>> AnnotTypeChanged;
- public event EventHandler<object> DefaultStored;
- public AnnotPropertyPanel()
- { }
- //外部UI控件选中状态
- public static bool IsSolidStyle(DashStyle LineDash)
- {
- bool isSolid = true;
- if (LineDash == null || LineDash.Dashes.Count == 0)
- {
- return isSolid;
- }
- foreach (var item in LineDash.Dashes)
- {
- if (item > 0)
- {
- isSolid = false;
- break;
- }
- }
- return isSolid;
- }
- public static DashStyle GetLineDashStyle(bool isSolid)
- {
- DashStyle newDash = new DashStyle();
- if (isSolid == false)
- {
- newDash.Dashes.Add(2);
- newDash.Dashes.Add(2);
- }
- else
- {
- newDash = DashStyles.Solid;
- }
- return newDash;
- }
- //单个属性更改
- public void UpdateAnnotAAttrib(AnnotAttrib annotAttrib, object obj)
- {
- if (annotlists != null && annotlists.Count > 1)
- {
- foreach (var itemevent in AnnotEvents)
- {
- itemevent?.UpdateAttrib(annotAttrib, obj);
- itemevent?.UpdateAnnot();
- }
- }
- else
- {
- AnnotEvent?.UpdateAttrib(annotAttrib, obj);
- AnnotEvent?.UpdateAnnot();
- }
- }
- //多个属性更改
- public void UpdateAnnotAllAttribs(Dictionary<AnnotAttrib, object> AnnotAttribDir)
- {
- if (annotlists != null && annotlists.Count > 1)
- {
- foreach (var itemevent in AnnotEvents)
- {
- foreach (var item in AnnotAttribDir)
- {
- itemevent?.UpdateAttrib(item.Key, item.Value);
- }
- itemevent?.UpdateAnnot();
- }
- }
- else
- {
- foreach (var item in AnnotAttribDir)
- {
- AnnotEvent?.UpdateAttrib(item.Key, item.Value);
- }
- AnnotEvent?.UpdateAnnot();
- }
- }
- //是否为多选
- public bool IsMultiSelected
- { get { return (annotlists != null && annotlists.Count > 1); } }
- /// <summary>
- /// 更新多个属性,触发到工具栏注释工具,改变工具图标下的颜色值
- /// </summary>
- public void InvokeToMyTools(object sender, Dictionary<AnnotArgsType, object> keyValues)
- {
- DataChanged?.Invoke(sender, keyValues);
- }
- /// <summary>
- /// 更新单个属性
- /// </summary>
- public void InvokeToMyTools(AnnotArgsType argsType, object obj)
- {
- Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
- changeData[argsType] = obj;
- DataChanged?.Invoke(null, changeData);
- }
- //同一属性面板,切换注释工具
- public void AnnotTypeChangedInvoke(object sender, Dictionary<AnnotArgsType, object> keyValues)
- {
- AnnotTypeChanged?.Invoke(sender, keyValues);
- }
- }
- public sealed partial class AnnotToolContentViewModel
- {
- #region 属性
- #region 注释工具
- //高亮
- private Brush highLightColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
- public Brush HighLightColor
- { get { return highLightColor; } set { SetProperty(ref highLightColor, value); } }
- //
- private double highLightOpacity = 1;
- public double HighLightOpacity
- { get { return highLightOpacity; } set { SetProperty(ref highLightOpacity, value); } }
- //
- private Brush underLine = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
- public Brush UnderLineColor
- { get { return underLine; } set { SetProperty(ref underLine, value); } }
- //
- private double underLineOpacity = 1;
- public double UnderLineOpacity
- { get { return underLineOpacity; } set { SetProperty(ref underLineOpacity, value); } }
- //
- private Brush squigglyColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
- public Brush SquigglyColor
- { get { return squigglyColor; } set { SetProperty(ref squigglyColor, value); } }
- //
- private double squigglyOpacity = 1;
- public double SquigglyOpacity
- { get { return squigglyOpacity; } set { SetProperty(ref squigglyOpacity, value); } }
- //
- private Brush strikeoutColor = new SolidColorBrush(Color.FromRgb(0xFF, 0xBB, 0x00));
- public Brush StrikeoutColor
- { get { return strikeoutColor; } set { SetProperty(ref strikeoutColor, value); } }
- //
- private double strikeoutOpacity = 1;
- public double StrikeoutOpacity
- { get { return strikeoutOpacity; } set { SetProperty(ref strikeoutOpacity, value); } }
- private bool btnSelecttoolIsChecked = false;
- public bool BtnSelecttoolIsChecked
- {
- get { return btnSelecttoolIsChecked; }
- set
- {
- SetProperty(ref btnSelecttoolIsChecked, value);
- }
- }
- private bool btnLinkIsChecked = false;
- public bool BtnLinkIsChecked
- {
- get { return btnLinkIsChecked; }
- set
- {
- SetProperty(ref btnLinkIsChecked, value);
- }
- }
- private bool btnHandIsChecked = false;
- public bool BtnHandIsChecked
- {
- get { return btnHandIsChecked; }
- set
- {
- SetProperty(ref btnHandIsChecked, value);
- }
- }
- private bool btnShowAnnotIsChecked = true;
- public bool BtnShowAnnotIsChecked
- {
- get { return btnShowAnnotIsChecked; }
- set
- {
- SetProperty(ref btnShowAnnotIsChecked, value);
- }
- }
- private string _strAnnotToolChecked = "";
- public string StrAnnotToolChecked
- {
- get { return _strAnnotToolChecked; }
- set
- {
- SetProperty(ref _strAnnotToolChecked, value);
- }
- }
-
- #endregion 注释工具
- #endregion 属性
- public string PropertyRegionName { get; set; }
- private IEventAggregator events;
- public IDialogService dialogs;
- public IRegionManager region;
- public OpenFileInfo OpenFileInfo = null;
- public CPDFViewer PDFViewer;
- private ViewContentViewModel viewContentViewModel;
- private AnnotPropertyPanel propertyPanel = new AnnotPropertyPanel();
- private Dictionary<string, AnnotArgsType> ToolExpandDict = new Dictionary<string, AnnotArgsType>();
- private Dictionary<string, string> ToolTipDict = new Dictionary<string, string>();
- private List<Tuple<int, int>> AnnotSignatures = new List<Tuple<int, int>>();
- private StickyNotePopup customStickyPopup;
- string Unicode = "";
- //private bool isHiddenAnnot = true;
- private bool isAddBookMark = true;
- private bool IsNoSelectMenu = false;
- private bool isRightMenuAddAnnot = false;
- private PopMenu HightAnnotPopMenu;
- private PopMenu FreeHandAnnotPopMenu;
- private PopMenu FreeTextAnnotPopMenu;
- private PopMenu StrickNoteAnnotPopMenu;
- private PopMenu ShapeAnnotPopMenu;
- private PopMenu LinkAnnotPopMenu;
- private PopMenu StampAnnotPopMenu;
- private PopMenu MultiAnnotPopMenu;
- #region 事件
- public DelegateCommand<CustomIconToggleBtn> MyToolsCommand { get; set; }
- private SnapshotEditMenuViewModel snapshotEditMenuViewModel = new SnapshotEditMenuViewModel();
- public SnapshotEditMenuViewModel SnapshotEditMenuViewModel { get => snapshotEditMenuViewModel; set => snapshotEditMenuViewModel = value; }
- public DelegateCommand<object> SetAddAnnotationCommand { get; set; }
- public DelegateCommand AddBookMarkCommand { get; set; }
- public DelegateCommand<object> HandCommand { get; set; }
- #region 注释 - 右键菜单
- //公共
- public DelegateCommand<object> AnnotDefaultValue_MenuCommand { get; set; }
- public DelegateCommand<object> AnnotColorPalette_MenuCommand { get; set; }
- public DelegateCommand<object> AnnotAddNoteText_MenuCommand { get; set; }
- //高亮、下划线、删除
- public DelegateCommand<object> HightAnnotCopyText_MenuCommand { get; set; }
- //手绘
- public DelegateCommand<object> FreeHandLineStyle_MenuCommand { get; set; }
- //文本
- public DelegateCommand<object> FreeTextFontFamily_MenuCommand { get; set; }
- public DelegateCommand<object> FreeTextAglin_MenuCommand { get; set; }
- //便签
- public DelegateCommand<object> StrikeNoteEditStrike_MenuCommand { get; set; }
- //形状
- public DelegateCommand<object> ShapeLineStyle_MenuCommand { get; set; }
- public DelegateCommand<object> ShapeLineDirect_MenuCommand { get; set; }
- //图章
- public DelegateCommand<object> StampExportPicture_MenuCommand { get; set; }
- //ESC
- public DelegateCommand EscCommand { get; set; }
- //链接
- public DelegateCommand<object> Link_MenuCommand { get; set; }
- #endregion 注释 - 右键菜单
- #endregion 事件
- }
- public enum AddAnnotType
- {
- AnnotFreehand,//绘制
- AnnotFreeText = 1,//文本
- AnnotSticky,//便签
- AnnotSquare,//矩形
- AnnotCircle,//椭圆形
- AnnotArrow,//箭头
- AnnotLine,//直线
- AnnotLink,//链接
- AnnotStamp,//图章
- AnnotAutograph //签名
- }
- }
|