123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783 |
- using ComPDFKit.PDFAnnotation;
- using ComPDFKit.PDFDocument.Action;
- using ComPDFKit.PDFDocument;
- using ComPDFKitViewer;
- using ComPDFKitViewer.AnnotEvent;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Office.CustomControl;
- using PDF_Office.EventAggregators;
- using PDF_Office.Helper;
- using PDF_Office.Properties;
- using PDF_Office.ViewModels.BOTA;
- using PDF_Office.Views.BOTA;
- using PDFSettings;
- 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.Controls.Primitives;
- using System.Windows.Media;
- using System.Diagnostics;
- namespace PDF_Office.ViewModels.Tools
- {
- public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
- {
- #region 事件绑定和解绑
- private void BindingEvent()
- {
- //属性面板与注释工具栏绑定:属性面板的属性变化,会同步注释工具栏的属性值
- //比如在属性面板里更改注释颜色,会同时更新工具栏对应的工具颜色
- propertyPanel.DataChanged -= AnnotPropertyPanel_DataChanged;
- propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
- propertyPanel.DefaultStored -= AnnotProperty_DefaultStored;
- propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
- propertyPanel.AnnotTypeChanged -= AnnotPropertyPanel_AnnotTypeChanged;
- propertyPanel.AnnotTypeChanged += AnnotPropertyPanel_AnnotTypeChanged;
- }
- private void UnBindingEvent()
- {
- propertyPanel.DataChanged -= AnnotPropertyPanel_DataChanged;
- propertyPanel.DefaultStored -= AnnotProperty_DefaultStored;
- propertyPanel.AnnotTypeChanged -= AnnotPropertyPanel_AnnotTypeChanged;
- }
- private void BindingPDFViewerHandler()
- {
- //来自PDFViewer的响应事件
- if (PDFViewer != null)
- {
- PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
- PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
- PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
- PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
- PDFViewer.AnnotCommandHandler -= PDFViewer_AnnotCommandHandler;
- PDFViewer.AnnotCommandHandler += PDFViewer_AnnotCommandHandler;
- PDFViewer.WidgetClickHander -= PDFViewer_WidgetClickHander;
- PDFViewer.WidgetClickHander += PDFViewer_WidgetClickHander;
- PDFViewer.SnapshotCommandHandler -= PDFViewer_SnapshotCommandHandler;
- PDFViewer.SnapshotCommandHandler += PDFViewer_SnapshotCommandHandler;
- PDFViewer.PDFActionHandler -= PDFViewer_PDFActionHandler;
- PDFViewer.PDFActionHandler += PDFViewer_PDFActionHandler;
- }
- }
- private void PDFViewer_PDFActionHandler(object sender, ComPDFKit.PDFDocument.Action.CPDFAction action)
- {
- if (action == null)
- {
- return;
- }
- switch (action.ActionType)
- {
- case C_ACTION_TYPE.ACTION_TYPE_GOTO:
- if (PDFViewer != null)
- {
- CPDFGoToAction gotoAction = action as CPDFGoToAction;
- CPDFDestination dest = gotoAction.GetDestination(PDFViewer.Document);
- if (dest != null)
- {
- PDFViewer.GoToPage(dest.PageIndex, new System.Windows.Point(0, 0));
- }
- }
- break;
- case C_ACTION_TYPE.ACTION_TYPE_URI:
- {
- CPDFUriAction uriAction = action as CPDFUriAction;
- string uri = uriAction.GetUri();
- try
- {
- if (!string.IsNullOrEmpty(uri))
- {
- Process.Start(uri);
- }
- }
- catch (Exception ex)
- {
- }
- }
- break;
- }
- }
- private void UnBindingPDFViewerHandler()
- {
- if (PDFViewer != null)
- {
- PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
- PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
- PDFViewer.AnnotCommandHandler -= PDFViewer_AnnotCommandHandler;
- PDFViewer.WidgetClickHander -= PDFViewer_WidgetClickHander;
- PDFViewer.SnapshotCommandHandler -= PDFViewer_SnapshotCommandHandler;
- }
- }
- #endregion 事件绑定和解绑
- #region PDFViewer事件
- //选中和非选中注释
- private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
- {
- if (e != null)
- {
- var annot = e.AnnotItemsList[0];
- if (annot != null)
- {
- if (e.AnnotItemsList.Count == 1)
- {
- //IsAnnotCreateReset:是否为创建注释的状态
- if (e.IsAnnotCreateReset == false)
- {
- GetSelectedAnnots(e);
- //PDFViewer.SetToolParam(annot);
- }
- else
- {
- switch (annot.EventType)
- {
- case AnnotArgsType.AnnotLink:
- //viewContentViewModel.IsCreateLink = false;
- GetLink(e.AnnotItemsList, e);
- PDFViewer.SetToolParam(annot);
- break;
- }
- //TODO: 设计已重新调整为(仅限高亮注释):修改注释后,会作用到之后添加的注释中。因此先把此逻辑“创建注释后,会自动回到默认值”注释掉
- if (annot.EventType != AnnotArgsType.AnnotStrikeout &&
- annot.EventType != AnnotArgsType.AnnotUnderline &&
- annot.EventType != AnnotArgsType.AnnotHighlight &&
- annot.EventType != AnnotArgsType.AnnotSquiggly &&
- annot.EventType != AnnotArgsType.AnnotLink &&
- annot.EventType != AnnotArgsType.AnnotFreehand &&
- annot.EventType != AnnotArgsType.AnnotSticky
- )
- {
- if (ToolExpandDict.ContainsValue(e.AnnotItemsList[0].EventType))
- {
- foreach (var item in ToolExpandDict)
- {
- if (item.Value == e.AnnotItemsList[0].EventType)
- {
- annot = null;//新建注释时,回到默认值
- FindAnnotTypeKey(item.Key, ref annot);
- break;
- }
- }
- }
- }
- //else
- PDFViewer.SetToolParam(annot);
- //设计重新调整,阅读页空白处,右键菜单,添加链接,和pro mac一样的效果,不显示属性栏
- if (isRightMenuAddAnnot)
- {
- ShowPropertyPanel(false);
- }
- else
- {
- ShowPropertyPanel();
- }
- }
- }
- else
- {
- bool isDifferentAnnotTyle = false;
- var lastAnnot = annot;
- foreach (var item in e.AnnotItemsList)
- {
- if (lastAnnot.EventType != item.EventType)
- {
- if ((isShapAnnot(annot) == true && isShapAnnot(item) == true) || (isHightAnnot(annot) == true && isHightAnnot(item) == true))
- {
- lastAnnot = item;
- continue;
- }
- lastAnnot = item;
- isDifferentAnnotTyle = true;
- break;
- }
- }
- if (isDifferentAnnotTyle)
- viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
- else
- GetSelectedAnnots(e);
- }
- }
- //注释列表同步选中
- var list = e.GetPageAnnotsIndex();
- bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
- if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true && bOTAContent.TabItemAnnotation.IsSelected == true && list != null && list.Count > 0)
- {
- if (list.Keys.Count == 0)
- {
- return;
- }
- var pageindex = new List<int>(list.Keys);
- List<int> annotes = new List<int>();
- list.TryGetValue(pageindex[0], out annotes);
- int annoteindex = annotes[0];
- AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
- if (viewModel != null)
- {
- viewModel.ScrollToAnnot(pageindex[0], annoteindex, annotation.AnnotationList);
- }
- }
- }
- else
- {
- viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
- }
- }
- private bool isShapAnnot(AnnotHandlerEventArgs annot)
- {
- if (annot.EventType == AnnotArgsType.AnnotCircle ||
- annot.EventType == AnnotArgsType.AnnotSquare ||
- annot.EventType == AnnotArgsType.AnnotLine
- )
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private bool isHightAnnot(AnnotHandlerEventArgs annot)
- {
- if (annot.EventType == AnnotArgsType.AnnotUnderline ||
- annot.EventType == AnnotArgsType.AnnotSquiggly ||
- annot.EventType == AnnotArgsType.AnnotHighlight ||
- annot.EventType == AnnotArgsType.AnnotStrikeout
- )
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private void GetSelectedAnnots(AnnotAttribEvent e)
- {
- var annot = e.AnnotItemsList[0];
- switch (annot.EventType)
- {
- case AnnotArgsType.AnnotHighlight:
- GetHighLight(e.AnnotItemsList);
- break;
- case AnnotArgsType.AnnotUnderline:
- GetUnderLine(e.AnnotItemsList);
- break;
- case AnnotArgsType.AnnotStrikeout:
- GetStrikeout(e.AnnotItemsList);
- break;
- case AnnotArgsType.AnnotSquiggly:
- GetSquiggly(e.AnnotItemsList);
- break;
- case AnnotArgsType.AnnotFreehand:
- GetFreehand(e.AnnotItemsList);
- break;
- case AnnotArgsType.AnnotFreeText:
- GetFreetext(e.AnnotItemsList);
- break;
- case AnnotArgsType.AnnotSquare:
- GetRect(e.AnnotItemsList);
- break;
- case AnnotArgsType.AnnotCircle:
- GetCircle(e.AnnotItemsList);
- break;
- case AnnotArgsType.AnnotLine:
- bool isLine = true;
- if (e.Attribs.ContainsKey(AnnotAttrib.LineStart))
- {
- if ((C_LINE_TYPE)e.Attribs[AnnotAttrib.LineStart] != C_LINE_TYPE.LINETYPE_UNKNOWN && (C_LINE_TYPE)e.Attribs[AnnotAttrib.LineStart] != C_LINE_TYPE.LINETYPE_NONE)
- {
- isLine = false;
- }
- }
- if (e.Attribs.ContainsKey(AnnotAttrib.LineEnd))
- {
- if ((C_LINE_TYPE)e.Attribs[AnnotAttrib.LineEnd] != C_LINE_TYPE.LINETYPE_UNKNOWN && (C_LINE_TYPE)e.Attribs[AnnotAttrib.LineEnd] != C_LINE_TYPE.LINETYPE_NONE)
- {
- isLine = false;
- }
- }
- if (isLine)
- GetArrowLine("Line", e.AnnotItemsList);
- else
- GetArrowLine("Arrow", e.AnnotItemsList);
- break;
- case AnnotArgsType.AnnotLink:
- //viewContentViewModel.IsCreateLink = false;
- GetLink(e.AnnotItemsList, e);
- break;
- case AnnotArgsType.AnnotSticky:
- GetStickyNote(e.AnnotItemsList);
- break;
- }
- }
- //在注释工具的状态下,右键菜单
- private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
- {
- if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
- return;
- switch (e.CommandType)
- {
- case CommandType.Context:
- if (e.AnnotEventArgsList.Count > 0)
- {
- if (App.mainWindowViewModel.SelectedItem.IsInReadctonMode && e.AnnotEventArgsList[0].EventType == AnnotArgsType.AnnotRedaction)
- {
- //绑定标记密文处右键菜单
- events.GetEvent<RedactionCommandEvent>().Publish(new RedactionCommandEventArgs() { UniCode = App.mainWindowViewModel.SelectedItem.Unicode, Sender = sender, args = e });
- }
- else
- {
- if (e.AnnotEventArgsList.Count == 1)
- {
- var selectedAnnot = e.AnnotEventArgsList[0];
- switch (selectedAnnot.EventType)
- {
- case AnnotArgsType.AnnotHighlight:
- case AnnotArgsType.AnnotUnderline:
- case AnnotArgsType.AnnotStrikeout:
- case AnnotArgsType.AnnotSquiggly:
- e.PopupMenu = SelectHightAnnotMenu(selectedAnnot);
- break;
- case AnnotArgsType.AnnotFreehand:
- e.PopupMenu = SelectFreeHandAnnotMenu(sender);
- break;
- case AnnotArgsType.AnnotFreeText:
- e.PopupMenu = SelectFreeTextAnnotMenu(sender);
- break;
- case AnnotArgsType.AnnotSticky:
- e.PopupMenu = SelectStrickNoteAnnotMenu(sender);
- break;
- case AnnotArgsType.AnnotSquare:
- case AnnotArgsType.AnnotLine:
- case AnnotArgsType.AnnotCircle:
- e.PopupMenu = SelectShapeAnnotMenu(sender);
- break;
- case AnnotArgsType.AnnotLink:
- e.PopupMenu = SelectHightAnnotMenu(sender);
- break;
- case AnnotArgsType.AnnotStamp:
- e.PopupMenu = SelectHightAnnotMenu(sender);
- break;
- }
- }
- else
- {
- bool isHigh = true;//是否为高亮
- foreach (var item in e.AnnotEventArgsList)
- {
- if (isHightAnnot(item) == false)
- {
- isHigh = false;
- break;
- }
- }
- e.PopupMenu = SelectMultiAnnotMenu(sender, isHigh);
- }
- }
- if (e.PopupMenu != null)
- {
- e.Handle = true;
- }
- }
- else
- {
- if (e.PressOnSelectedText || e.CommandTarget == TargetType.ImageSelection)
- {
- e.PopupMenu = NoneSelectAnnotContextMenu(sender, e);
- if (e.PopupMenu != null)
- {
- e.Handle = true;
- }
- }
- else
- {
- e.PopupMenu = ViewerContextMenu();
- if (e.PopupMenu != null)
- {
- e.Handle = true;
- }
- }
- }
- break;
- }
- }
- private void PDFViewer_SnapshotCommandHandler(object sender, SnapshotCommandArgs e)
- {
- SnapshotEditToolArgs snapToolArgs = (SnapshotEditToolArgs)PDFViewer.ToolManager.CurrentAnnotArgs;
- SnapshotEditMenuViewModel.SnapToolArgs = snapToolArgs;
- SnapshotEditMenuViewModel.PDFViewer = PDFViewer;
- SnapshotEditMenuViewModel.SnapToolEvent -= SnapshotEditMenuViewModel_SnapToolEvent; ;
- SnapshotEditMenuViewModel.SnapToolEvent += SnapshotEditMenuViewModel_SnapToolEvent;
- var popMenu = App.Current.FindResource("SnapshotContextMenu") as ContextMenu;
- if (e.HitSnapshotTool && e.SnapshotRect.Width > 0 && e.SnapshotRect.Height > 0)
- {
- e.PopupMenu = popMenu;
- e.Handle = true;
- if (popMenu != null && popMenu.Items.Count == 5)
- {
- //复制
- MenuItem menuItem = popMenu.Items[0] as MenuItem;
- menuItem.CommandTarget = PDFViewer;
- menuItem.Command = SnapshotEditMenuViewModel.SnapCopyCommand;
- //导出
- menuItem = popMenu.Items[1] as MenuItem;
- menuItem.CommandTarget = PDFViewer;
- if (menuItem.Items.Count == 3)
- {
- MenuItem menuItem1 = menuItem.Items[0] as MenuItem;
- menuItem1.CommandTarget = PDFViewer;
- menuItem1.Command = SnapshotEditMenuViewModel.ExportPNGCommand;
- menuItem1 = menuItem.Items[1] as MenuItem;
- menuItem1.CommandTarget = PDFViewer;
- menuItem1.Command = SnapshotEditMenuViewModel.ExportJPGCommand;
- menuItem1 = menuItem.Items[2] as MenuItem;
- menuItem1.CommandTarget = PDFViewer;
- menuItem1.Command = SnapshotEditMenuViewModel.ExportPDFCommand;
- }
- //裁剪
- menuItem = popMenu.Items[2] as MenuItem;
- menuItem.CommandTarget = PDFViewer;
- menuItem.Command = SnapshotEditMenuViewModel.CroppingCommand;
- //缩放至所选区域
- menuItem = popMenu.Items[3] as MenuItem;
- menuItem.CommandTarget = PDFViewer;
- menuItem.Visibility = Visibility.Collapsed;
- //menuItem.Command = snapshotEditMenuViewModel.CroppingCommand;
- //打印
- menuItem = popMenu.Items[4] as MenuItem;
- menuItem.CommandTarget = PDFViewer;
- menuItem.Command = SnapshotEditMenuViewModel.PrintCommand;
- }
- }
- }
- private void SnapshotEditMenuViewModel_SnapToolEvent(object sender, KeyValuePair<string, object> e)
- {
- switch (e.Key)
- {
- case "CloseSnap":
- {
- #region to do
- //var item = PDFViewerTab.SelectedItem as TabItem;
- //if (item == null)
- //{
- // ClearSelectedToolPanel();
- // return;
- //}
- //Grid grid = item.Content as Grid;
- //if (grid == null || grid.Children.Count == 0)
- //{
- // ClearSelectedToolPanel();
- // return;
- //}
- //PDFViewerCtrl pdfViewer = grid.Children[0] as PDFViewerCtrl;
- //if (pdfViewer == null)
- //{
- // ClearSelectedToolPanel();
- // return;
- //}
- #endregion to do
- switch (PDFViewer.MouseMode)
- {
- case MouseModes.SelectTextTool:
- break;
- default:
- BtnSelecttoolIsChecked = false;
- BtnHandIsChecked = true;
- PDFViewer.EnableZoom(true);
- PDFViewer.EnableScroll(true);
- break;
- }
- }
- break;
- default:
- break;
- }
- }
- private void PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
- {
- if (e != null && e.Count > 0)
- {
- for (int i = 0; i < e.Count; i++)
- {
- AnnotEditEvent editEvent = e[i];
- switch (editEvent.EditAction)
- {
- case ActionType.Add:
- bool isTabItemAnnotation = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemAnnotation");
- if (viewContentViewModel.OpenBOTA == true && isTabItemAnnotation == true)
- {
- AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
- if (viewModel != null)
- {
- int pageindex = editEvent.PageIndex;
- int annotindex = editEvent.AnnotIndex;
- viewModel.UpdateAddedAnnot(pageindex, annotindex);
- }
- }
- break;
- case ActionType.Del:
- isTabItemAnnotation = IsBOTATabItemShow(out bOTAContentViewModel, out bOTAContent, "TabItemAnnotation");
- if (isTabItemAnnotation)
- {
- AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
- if (viewModel != null)
- {
- int pageindex = editEvent.PageIndex;
- int annotindex = editEvent.AnnotIndex;
- viewModel.UpdateModifiedAnnot(pageindex, annotindex, true);
- }
- }
- break;
- case ActionType.Modify:
- isTabItemAnnotation = IsBOTATabItemShow(out bOTAContentViewModel, out bOTAContent, "TabItemAnnotation");
- if (bOTAContent.TabItemAnnotation.IsSelected)
- {
- AnnotationContentViewModel viewModel = GetAnnotationContentViewModel(bOTAContentViewModel, out AnnotationContent annotation);
- if (viewModel != null)
- {
- int pageindex = editEvent.PageIndex;
- int annotindex = editEvent.AnnotIndex;
- viewModel.UpdateModifiedAnnot(pageindex, annotindex, false);
- }
- }
- break;
- case ActionType.TextEdit:
- break;
- default:
- break;
- }
- }
- }
- }
- private void PDFViewer_WidgetClickHander(object sender, WidgetArgs e)
- {
- }
- #endregion PDFViewer事件
- #region BindingEvent事件
- private void AnnotProperty_DefaultStored(object sender, object e)
- {
- }
- private void AnnotPropertyPanel_AnnotTypeChanged(object sender, Dictionary<AnnotArgsType, object> e)
- {
- if (e != null)
- {
- AnnotHandlerEventArgs annotArgs = null;
- foreach (AnnotArgsType argsType in e.Keys)
- {
- switch (argsType)
- {
- case AnnotArgsType.AnnotSquare:
- annotArgs = GetRect();
- break;
- case AnnotArgsType.AnnotCircle:
- annotArgs = GetCircle();
- break;
- case AnnotArgsType.AnnotLine:
- var LineTag = e[argsType] as string;
- annotArgs = GetArrowLine(LineTag);
- break;
- }
- if (annotArgs != null)
- {
- annotArgs.Author = Settings.Default.AppProperties.Description.Author;
- PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
- PDFViewer.SetToolParam(annotArgs);
- }
- ShowPropertyPanel();
- }
- }
- }
- 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;
- case AnnotArgsType.AnnotFreehand:
- if (e[argsType] is Color)
- {
- // FreehandPath.Fill = new SolidColorBrush((Color)e[argsType]);
- }
- if (e[argsType] is double)
- {
- // FreehandPath.Opacity = (double)e[argsType];
- }
- break;
- case AnnotArgsType.AnnotErase:
- if (e[argsType] is ToggleButton)
- {
- ToggleButton clickBtn = e[argsType] as ToggleButton;
- if (clickBtn.IsChecked == true)
- {
- if (clickBtn.Tag.ToString() == "PenBtn")
- {
- CustomIconToggleBtn btn = new CustomIconToggleBtn();
- btn.Tag = "Freehand"; btn.IsChecked = true;
- BtnMyTools_Click(btn);
- break;
- }
- EraseArgs eraseArgs = new EraseArgs();
- eraseArgs.UIBorderColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
- eraseArgs.UIFillColor = Color.FromArgb(0x1A, 0x00, 0x00, 0x00);
- eraseArgs.Thickness = 10;
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotErase);
- if (annotProperty != null)
- {
- eraseArgs.Thickness = annotProperty.Thickness;
- }
- PDFViewer.ClearSelectAnnots(false);
- PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
- PDFViewer.SetToolParam(eraseArgs);
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- annotAttribsList[AnnotAttrib.Color] = eraseArgs.UIBorderColor;
- annotAttribsList[AnnotAttrib.FillColor] = eraseArgs.UIFillColor;
- annotAttribsList[AnnotAttrib.Thickness] = eraseArgs.Thickness;
- List<AnnotHandlerEventArgs> eraseArgsList = new List<AnnotHandlerEventArgs>();
- if (eraseArgs != null)
- eraseArgsList.Add(eraseArgs);
- AddToPropertyPanel("FreehandAnnotProperty", "Freehand", eraseArgsList, annotAttribsList);
- }
- }
- break;
- }
- }
- }
- }
- #endregion BindingEvent事件
- }
- }
|