12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910 |
- using ComPDFKitViewer.AnnotEvent;
- using ComPDFKitViewer.PdfViewer;
- using PDF_Master.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;
- using System.Windows;
- using System.Windows.Controls;
- using PDF_Master.ViewModels.Tools;
- using ComPDFKitViewer;
- using PDF_Master.Helper;
- using PDF_Master.Properties;
- using PDFSettings;
- using System.Windows.Media;
- using ComPDFKit.PDFDocument.Action;
- using ComPDFKit.PDFDocument;
- using System.Diagnostics;
- using ComPDFKit.PDFAnnotation;
- using PDF_Master.ViewModels.BOTA;
- using PDF_Master.Views.BOTA;
- using System.Windows.Forms;
- using Control = System.Windows.Controls.Control;
- using Microsoft.Office.Interop.Word;
- using Point = System.Windows.Point;
- using System.Windows.Ink;
- using PDF_Master.EventAggregators;
- using System.Management.Instrumentation;
- using Prism.Events;
- using System.Windows.Input;
- using ContextMenu = System.Windows.Controls.ContextMenu;
- using MenuItem = System.Windows.Controls.MenuItem;
- using System.Drawing;
- using Color = System.Windows.Media.Color;
- using Brush = System.Windows.Media.Brush;
- using FontFamily = System.Windows.Media.FontFamily;
- using ToolTip = System.Windows.Controls.ToolTip;
- using ContentControl = System.Windows.Controls.ContentControl;
- using MouseEventArgs = System.Windows.Input.MouseEventArgs;
- using Pen = System.Windows.Media.Pen;
- using PDF_Master.Model.PropertyPanel.AnnotPanel;
- using RadioButton = System.Windows.Controls.RadioButton;
- using Style = System.Windows.Style;
- using PDF_Master.CustomControl;
- using System.Windows.Controls.Primitives;
- using Window = System.Windows.Window;
- using Task = System.Threading.Tasks.Task;
- using Size = System.Windows.Size;
- using System.Windows.Markup;
- using Prism.Services.Dialogs;
- using PDF_Master.ViewModels.Tools.AnnotManager;
- using PDF_Master.Model.FillAndSign;
- using System.Windows.Shapes;
- using Dropbox.Api.TeamLog;
- using KeyEventArgs = System.Windows.Input.KeyEventArgs;
- namespace PDF_Master.ViewModels.FillAndSign
- {
- public class FillAndSignContentViewModel : BindableBase, INavigationAware
- {
- #region
- public CPDFViewer PDFViewer;
- private AnnotTransfer propertyPanel = new AnnotTransfer();
- public ViewContentViewModel viewContentViewModel;
- private bool isRightMenuAddAnnot = false;
- private IEventAggregator events;
- public List<List<Point>> ShapePoints = new List<List<Point>>();
- public string Shape = "HookShape";
- private bool IsFillAndSign
- { get; set; } = true;
- private PopMenu FreeHandAnnotPopMenu;
- private PopMenu FreeTextAnnotPopMenu;
- private PopMenu MultiAnnotPopMenu;
- public bool isFirst = true;
- private IRegionManager regions { get; set; }
- private Dictionary<string, AnnotArgsType> ToolExpandDict = new Dictionary<string, AnnotArgsType>();
- public static bool IsEdit = false;
- public static bool IsSignPoint = false;
- public Brush SelectColor = new SolidColorBrush(Color.FromArgb(0xff, 0x26, 0x25, 0x29));
- public double FillOpacity = 1;
- public double LineWidth = 2;
- public double LineWidthMultiple = 1;
- public bool IsSelectShape = false;
- public bool IsCopyShape = true;
- public bool IsClickNull = false;
- private List<string> ShapeNames = new List<string>();
- private string DateOrText = "";
- private bool _HookShapeIsCheck = false;
- public bool HookShapeIsCheck
- {
- get { return _HookShapeIsCheck; }
- set { SetProperty(ref _HookShapeIsCheck, value); }
- }
- public Dictionary<string, List<List<Point>>> keyShape = new Dictionary<string, List<List<Point>>>();
- private void InitkeyShape()
- {
- keyShape["HookShape"] = new List<List<Point>> { new List<Point> { new Point(2, 12.2028), new Point(9.77817, 19.981), new Point(22.5061, 2.30333) } };
- keyShape["ForkShape"] = new List<List<Point>> { new List<Point> { new Point(5, 5), new Point(23, 23) }, new List<Point> { new Point(23, 5), new Point(5, 23) } };
- keyShape["RectShape"] = new List<List<Point>> { new List<Point> { new Point(1.40002, 1.40002), new Point(20, 1.40002) }, new List<Point> { new Point(20, 1.40002), new Point(20, 20) }, new List<Point> { new Point(20, 20), new Point(1.40002, 20) }, new List<Point> { new Point(1.40002, 20), new Point(1.40002, 1.40002) } };
- keyShape["LineShape"] = new List<List<Point>> { new List<Point> { new Point(3.19995, 14), new Point(25.127, 14) } };
- keyShape["DotShape"] = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.19995), new Point(3.19995, 3.19995) } };
- }
- #endregion
- public DelegateCommand<object> AnnotDefaultValue_MenuCommand { get; set; }
- public DelegateCommand<object> FreeTextFontFamily_MenuCommand { get; set; }
- public DelegateCommand<object> AnnotColorPalette_MenuCommand { get; set; }
- public DelegateCommand<object> FreeTextAglin_MenuCommand { get; set; }
- #region Command
- public DelegateCommand<object> CheckCommand { get; set; }
- /// <summary>
- /// 按钮名称和属性面板映射字典
- /// </summary>
- public Dictionary<string, string> btnToProperty = new Dictionary<string, string>();
- private IDialogService dialogs;
- #endregion
- string Unicode = "";
- public FillAndSignContentViewModel(IRegionManager regionManager, IEventAggregator events) { }
- public FillAndSignContentViewModel(IRegionManager regionManager, IEventAggregator events, IDialogService dialogService)
- {
- dialogs = dialogService;
- regions = regionManager;
- this.events = events;
- Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
- CheckCommand = new DelegateCommand<object>(CheckedEvent);
- ToolExpandDict.Add("Freetext", AnnotArgsType.AnnotFreeText);
- InitDictionary();
- InitkeyShape();
- AnnotDefaultValue_MenuCommand = new DelegateCommand<object>(AnnotDefaultValues_Menu);
- AnnotColorPalette_MenuCommand = new DelegateCommand<object>(AnnotColorPalette_Menu);
- FreeTextFontFamily_MenuCommand = new DelegateCommand<object>(FreeTextFontFamily_Menu);
- FreeTextAglin_MenuCommand = new DelegateCommand<object>(FreeTextAglin_Menu);
- InitSelectFreeHandAnnotMenu();
- InitSelectFreeTextAnnotMenu();
- InitSelectMultiAnnotMenu();
- SubscribeEvent();
- InitShapeList();
- InitFillAndSignProperty();
- }
- #region 事件聚合器(来自AnnotToolContentViewModel)
- private void SubscribeEvent()
- {
- events.GetEvent<FillAndSignEvent>().Subscribe(FromFillAndSign, e => e.AppUnicode == Unicode);
- }
- private void FromFillAndSign(FillAndSigntEventArgs obj)
- {
- if (viewContentViewModel.CurrentBar != "TabItemAnnotation")
- {
- return;
- }
- if (obj != null)
- {
- if (string.IsNullOrEmpty(obj.Action) == false)
- {
- if (obj.Action == "Clear")
- {
- viewContentViewModel.FillAndSign.Clear();
- }
- else
- {
- if (obj.Annots != null && obj.Annots.Count > 0)
- {
- if (obj.Annots[0].EventType == AnnotArgsType.AnnotFreehand)
- {
- IsFillAndSign = false;
- GetFreehand(obj.Annots);
- }
- else if (obj.Annots[0].EventType == AnnotArgsType.AnnotFreeText)
- {
- GetFreetext(obj.Annots);
- }
- }
- }
- }
- }
- }
- private void InitFillAndSignProperty()
- {
- var FreehandDefault = GetAnnotDefault(AnnotArgsType.AnnotFreehand, "FillAndSign");
- SelectColor = new SolidColorBrush(FreehandDefault.BorderColor != Color.FromArgb(0, 0, 0, 0) ? FreehandDefault.BorderColor : Color.FromArgb(0xff, 0x26, 0x25, 0x29));
- FillOpacity = FreehandDefault.Opacity > 0 ? FreehandDefault.Opacity : 1;
- LineWidth =/* FreehandDefault.Thickness > 0 ? FreehandDefault.Thickness :*/ 2;
- }
- #endregion 事件聚合器
- private System.Windows.Controls.Primitives.Popup popup = null;
- private async void AnnotColorPalette_Menu(object obj)
- {
- if (obj as CusMenuItem != null)
- {
- var menu = obj as CusMenuItem;
- var annot = menu.Parameter as AnnotHandlerEventArgs;
- if (annot != null)
- {
- var item = new ColorDropBoxPop();
- item.DataContext = menu;
- item.ColorSelected -= AnnotMenu_ColorSelected;
- item.ColorSelected += AnnotMenu_ColorSelected;
- if (popup == null)
- popup = new System.Windows.Controls.Primitives.Popup();
- ContentControl window = null;
- if (PDFViewer.Parent as ContentControl != null)
- window = PDFViewer.Parent as ContentControl;
- else
- window = App.Current.MainWindow;
- popup.Child = item;
- popup.PlacementRectangle = new Rect(Mouse.GetPosition(window), new Size(item.Width, item.Height));
- popup.Placement = System.Windows.Controls.Primitives.PlacementMode.MousePoint;
- popup.PlacementTarget = window;
- popup.IsOpen = true;
- Window parentWnd = Window.GetWindow(App.Current.MainWindow);
- if (parentWnd != null)
- {
- parentWnd.MouseDown -= parentWnd_MouseDown;
- parentWnd.MouseDown += parentWnd_MouseDown;
- }
- while (popup.IsOpen)
- await Task.Delay(20);
- parentWnd.MouseDown -= parentWnd_MouseDown;
- popup = null;
- }
- }
- }
- private void AnnotMenu_ColorSelected(object sender, Color e)
- {
- if (sender != null)
- {
- var menu = (sender as FrameworkElement).DataContext as CusMenuItem;
- if (menu == null) return;
- var annot = menu.Parameter as AnnotHandlerEventArgs;
- if (annot != null)
- {
- if (annot is FreehandAnnotArgs || annot is StickyAnnotArgs || annot is LineAnnotArgs)
- {
- var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
- AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
- AnnotEvent?.UpdateAnnot();
- }
- else if (annot is FreeTextAnnotArgs)
- {
- var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
- if (menu.tag.ToString() == "FontColor")
- AnnotEvent?.UpdateAttrib(AnnotAttrib.FontColor, e);
- else
- AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, e);
- AnnotEvent?.UpdateAnnot();
- }
- else if (annot is SquareAnnotArgs || annot is CircleAnnotArgs)
- {
- var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
- if (menu.tag.ToString() == "FillColor")
- AnnotEvent?.UpdateAttrib(AnnotAttrib.FillColor, e);
- else
- AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
- AnnotEvent?.UpdateAnnot();
- }
- else if (annot is TextHighlightAnnotArgs || annot is TextUnderlineAnnotArgs || annot is TextStrikeoutAnnotArgs)
- {
- var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
- AnnotEvent?.UpdateAttrib(AnnotAttrib.Color, e);
- AnnotEvent?.UpdateAnnot();
- }
- }
- }
- }
- private void parentWnd_MouseDown(object sender, MouseButtonEventArgs e)
- {
- var ui = Mouse.DirectlyOver as FrameworkElement;
- if (ui != null)
- {
- if (popup != null)
- {
- popup.IsOpen = false;
- }
- }
- }
- private void FreeTextFontFamily_Menu(object obj)
- {
- if (obj as CusMenuItem != null)
- {
- var menu = obj as CusMenuItem;
- var annot = menu.Parameter as AnnotHandlerEventArgs;
- if (annot != null)
- {
- var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
- AnnotEvent?.UpdateAttrib(AnnotAttrib.FontName, menu.tag.ToString());
- AnnotEvent?.UpdateAnnot();
- }
- }
- }
- private void FreeTextAglin_Menu(object obj)
- {
- if (obj as CusMenuItem != null)
- {
- var menu = obj as CusMenuItem;
- var annot = menu.Parameter as AnnotHandlerEventArgs;
- var tag = menu.control.Tag;
- if (annot != null && tag != null)
- {
- var strTag = tag.ToString();
- var AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(annot, annot.GetAnnotAttrib());
- if (strTag == "Left")
- {
- AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Left);
- }
- else if (strTag == "Center")
- {
- AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Center);
- }
- else if (strTag == "Right")
- {
- AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Right);
- }
- else if (strTag == "Justify")
- {
- AnnotEvent?.UpdateAttrib(AnnotAttrib.TextAlign, TextAlignment.Justify);
- }
- AnnotEvent?.UpdateAnnot();
- }
- }
- }
- private void AnnotDefaultValues_Menu(object obj)
- {
- if (obj as CusMenuItem != null)
- {
- var menu = obj as CusMenuItem;
- var annot = menu.Parameter as AnnotHandlerEventArgs;
- if (annot != null)
- {
- if (annot is FreehandAnnotArgs)
- {
- var freeHand = annot as FreehandAnnotArgs;
- var color = freeHand.InkColor;
- //Settings.Default.AppProperties.Annotate.FreeHandColor = color;
- var FreehandDefault = GetAnnotDefault(AnnotArgsType.AnnotFreehand, "FillAndSign");
- FreehandDefault.BorderColor = color;
- FreehandDefault.Opacity = freeHand.Transparency;
- FreehandDefault.Thickness = freeHand.LineWidth;
- foreach (var point in viewContentViewModel.FillAndSign)
- {
- if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
- {
- if (point.Shape == "DotShape")
- {
- FreehandDefault.Thickness = FreehandDefault.Thickness / 5;
- }
- }
- }
- FreehandDefault.SaveKey = "FillAndSign";
- var isSolid = AnnotTransfer.IsSolidStyle(freeHand.LineDash);
- if (isSolid)
- {
- FreehandDefault.DashArray = null;
- }
- else
- {
- FreehandDefault.DashArray = new List<double>();
- foreach (var item in freeHand.LineDash.Dashes)
- {
- FreehandDefault.DashArray.Add(item);
- }
- }
- SettingHelper.SetAnnotDefaultProperty(FreehandDefault);
- }
- else if (annot is FreeTextAnnotArgs)
- {
- var freeText = annot as FreeTextAnnotArgs;
- Settings.Default.AppProperties.Annotate.TextAnnoteColor = freeText.FontColor;
- Settings.Default.AppProperties.Annotate.TextFontFamaily = freeText.FontName;
- Settings.Default.AppProperties.Annotate.TextAlign = freeText.Align;
- var FreeTextDefalut = GetAnnotDefault(AnnotArgsType.AnnotFreeText);
- FreeTextDefalut.ForgoundColor = freeText.FontColor;
- FreeTextDefalut.FontFamily = freeText.FontName;
- FreeTextDefalut.TextAlign = freeText.Align;
- FreeTextDefalut.FontSize = freeText.FontSize;
- FreeTextDefalut.FontWeight = freeText.IsBold?FontWeights.Bold:FontWeights.Normal;
- FreeTextDefalut.FontStyle = freeText.IsItalic?FontStyles.Italic:FontStyles.Normal;
- FreeTextDefalut.BackgroundColor = freeText.BgColor;
- FreeTextDefalut.Opacity = (annot as FreeTextAnnotArgs).Transparency;
- SettingHelper.SetAnnotDefaultProperty(FreeTextDefalut);
- }
- }
- }
- }
- private DefaultAnnotProperty GetAnnotDefault(AnnotArgsType annotArgsType, string savaKey = "")
- {
- var Annot = SettingHelper.GetAnnotDefaultProperty(annotArgsType, savaKey);
- if (Annot == null)
- {
- Annot = new DefaultAnnotProperty();
- Annot.AnnotToolType = annotArgsType;
- }
- return Annot;
- }
- private void CheckedEvent(object e)
- {
- var control = e as Control;
- IsEdit = false;
- //NavigateToProperty(control.Name);
- //不创建注释,属于注释模板
- bool isTemplateAnnot = false;
- bool isSnapshotEdit = false;
- AnnotHandlerEventArgs annotArgs = null;
- if (!ServiceHelper.IAPBeforeFunction())
- {
- return;
- }
- var tag = control.Name;
- FindAnnotTypeKey(control.Name, ref annotArgs);
- if (control.Name == "RbtnSign") { isTemplateAnnot = true; }
- if (tag == "SnapshotEdit")
- {
- isSnapshotEdit = true;
- }
- else if (tag == "Signature" || tag == "Stamp")
- {
- isTemplateAnnot = true;
- }
- if (annotArgs != null)
- {
- annotArgs.Author = Settings.Default.AppProperties.Description.Author;
- PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
- PDFViewer.SetToolParam(annotArgs);
- isRightMenuAddAnnot = false;
- }
- //当不是注释模板,且无创建注释时,属性面板显示为空内容
- if (isTemplateAnnot == false && annotArgs == null)
- {
- PDFViewer.SetMouseMode(MouseModes.PanTool);
- viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
- }
- else
- {
- if (isSnapshotEdit == true)
- {
- ShowPropertyPanel(false);
- isSnapshotEdit = false;
- }
- else
- {
- ShowPropertyPanel(true);
- }
- }
- }
- private void InitCheckedEvent(string e)
- {
- IsEdit = false;
- //NavigateToProperty(control.Name);
- //不创建注释,属于注释模板
- bool isTemplateAnnot = false;
- bool isSnapshotEdit = false;
- AnnotHandlerEventArgs annotArgs = null;
- var tag = e;
- FindAnnotTypeKey(e, ref annotArgs);
- if (e == "RbtnSign") { isTemplateAnnot = true; }
- if (tag == "SnapshotEdit")
- {
- isSnapshotEdit = true;
- }
- else if (tag == "Signature" || tag == "Stamp")
- {
- isTemplateAnnot = true;
- }
- if (annotArgs != null)
- {
- annotArgs.Author = Settings.Default.AppProperties.Description.Author;
- PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
- PDFViewer.SetToolParam(annotArgs);
- isRightMenuAddAnnot = false;
- }
- //当不是注释模板,且无创建注释时,属性面板显示为空内容
- if (isTemplateAnnot == false && annotArgs == null)
- {
- PDFViewer.SetMouseMode(MouseModes.PanTool);
- viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
- }
- else
- {
- if (isSnapshotEdit == true)
- {
- ShowPropertyPanel(false);
- isSnapshotEdit = false;
- }
- else
- {
- ShowPropertyPanel(true);
- }
- }
- }
- private List<string> ShapeList = new List<string>();
- private void InitShapeList()
- {
- ShapeList.Add("HookShape");
- ShapeList.Add("ForkShape");
- ShapeList.Add("RectShape");
- ShapeList.Add("LineShape");
- ShapeList.Add("DotShape");
- ShapeList.Add("Sign");
- }
- //注释工具
- private void FindAnnotTypeKey(string tag, ref AnnotHandlerEventArgs annotArgs, bool isRightMenuAdd = false)
- {
- LineWidthMultiple = 1;
- IsSignPoint = false;
- Shape = "None";
- switch (tag)
- {
- case "RbtnDate":
- DateOrText = "Freetext";
- annotArgs = GetFreetext();
- break;
- case "RbtnText"://文本
- DateOrText = "";
- annotArgs = GetFreetext();
- break;
- case "Freetext"://文本
- annotArgs = GetFreetext();
- break;
- case "RbtnSign"://签名
- Shape = "Sign";
- PDFViewer.SetMouseMode(MouseModes.PanTool);
- annotArgs = GetSignature();
- //清空其他注释
- break;
- case "RbtnTick"://勾
- Shape = "HookShape";
- ShapePoints = keyShape[Shape];
- annotArgs = GetStamp();
- break;
- case "RbtnFork"://叉
- Shape = "ForkShape";
- ShapePoints = keyShape[Shape];
- annotArgs = GetStamp();
- break;
- case "RbtnRectangle"://矩形
- Shape = "RectShape";
- ShapePoints = keyShape[Shape];
- annotArgs = GetStamp();
- break;
- case "RbtnLine"://下划线
- Shape = "LineShape";
- ShapePoints = keyShape[Shape];
- annotArgs = GetStamp();
- break;
- case "RbtnPoint":
- IsSignPoint = true;
- Shape = "DotShape";
- ShapePoints = keyShape[Shape];
- LineWidthMultiple = 5;
- annotArgs = GetStamp();
- break;
- default://图章
- break;
- }
- }
- /// <summary>
- /// 签名
- /// </summary>
- /// <returns></returns>
- private AnnotHandlerEventArgs GetSignature()
- {
- AddToPropertyPanel("SignatureAnnotProperty");
- return null;
- }
- /// <summary>
- /// 图章
- /// </summary>
- /// <returns></returns>
- private AnnotHandlerEventArgs GetStamp(List<AnnotHandlerEventArgs> selectedArgs = null)
- {
- StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
- stampAnnotArgs.SetInkData(ShapePoints, LineWidth * LineWidthMultiple, (SelectColor as SolidColorBrush).Color);
- //PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
- //PDFViewer.SetToolParam(stampArgs);
- //StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
- //stampAnnotArgs.Opacity = 1;
- //stampAnnotArgs.StampText = "APPROVED";
- //stampAnnotArgs.Type = StampType.STANDARD_STAMP;
- // stampAnnotArgs.Type = StampType.STANDARD_STAMP;
- stampAnnotArgs.IsContinueMode = true;
- stampAnnotArgs.IsSignPoint = IsSignPoint;
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotStamp);
- List<AnnotHandlerEventArgs> stampAnnotArgsList = new List<AnnotHandlerEventArgs>();
- if (stampAnnotArgs != null)
- stampAnnotArgsList.Add(stampAnnotArgs);
- //if (selectedArgs != null) {
- //var annot = selectedArgs[0];
- //if (annot != null)
- //{
- // foreach (var item in selectedArgs)
- // {
- // selectedArgs[selectedArgs.IndexOf(item)] = stampAnnotArgs;
- // }
- // AddToPropertyPanel("ShapFillProperty", "", selectedArgs, annotAttribsList);
- // return stampAnnotArgs;
- //}
- // }
- AddToPropertyPanel("ShapFillProperty", "", stampAnnotArgsList, annotAttribsList);
- return stampAnnotArgs;
- }
- public void SetStamp()
- {
- StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
- double lineWidthMultiple = LineWidthMultiple;
- if (Shape == "DotShape") { LineWidthMultiple = 5; }
- stampAnnotArgs.SetInkData(ShapePoints, LineWidth * LineWidthMultiple, (SelectColor as SolidColorBrush).Color);
- LineWidthMultiple = lineWidthMultiple;
- //PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
- //PDFViewer.SetToolParam(stampArgs);
- //StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
- //stampAnnotArgs.Opacity = 1;
- //stampAnnotArgs.StampText = "APPROVED";
- //stampAnnotArgs.Type = StampType.STANDARD_STAMP;
- stampAnnotArgs.IsContinueMode = true;
- stampAnnotArgs.IsSignPoint = IsSignPoint;
- stampAnnotArgs.Opacity = FillOpacity;
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotStamp);
- List<AnnotHandlerEventArgs> stampAnnotArgsList = new List<AnnotHandlerEventArgs>();
- if (stampAnnotArgs != null)
- stampAnnotArgsList.Add(stampAnnotArgs);
- //AddToPropertyPanel("ShapFillProperty", "", stampAnnotArgsList, annotAttribsList);
- bool isTemplateAnnot = false;
- bool isSnapshotEdit = false;
- AnnotHandlerEventArgs annotArgs = stampAnnotArgs;
- if (annotArgs != null)
- {
- annotArgs.Author = Settings.Default.AppProperties.Description.Author;
- PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
- PDFViewer.SetToolParam(annotArgs);
- isRightMenuAddAnnot = false;
- }
- //当不是注释模板,且无创建注释时,属性面板显示为空内容
- if (isTemplateAnnot == false && annotArgs == null)
- {
- PDFViewer.SetMouseMode(MouseModes.PanTool);
- viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
- }
- else
- {
- if (isSnapshotEdit == true)
- {
- ShowPropertyPanel(false);
- isSnapshotEdit = false;
- }
- else
- {
- ShowPropertyPanel(true);
- }
- }
- }
- /// <summary>
- /// 手绘
- /// </summary>
- /// <param name="selectedArgs"></param>
- /// <returns></returns>
- private AnnotHandlerEventArgs GetFreehand(List<AnnotHandlerEventArgs> selectedArgs = null)
- {
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- List<AnnotHandlerEventArgs> newSelectedArgs = new List<AnnotHandlerEventArgs>();
- FreehandAnnotArgs freehandArgs = null;
- if (selectedArgs == null || selectedArgs.Count == 0)
- {
- freehandArgs = new FreehandAnnotArgs();
- var annotate = Settings.Default.AppProperties.Annotate;
- if (annotate != null)
- {
- freehandArgs.InkColor = annotate.FreeHandColor;
- }
- else
- {
- freehandArgs.InkColor = Color.FromRgb(0x38, 0xE0, 0x2E);
- }
- freehandArgs.RawPointList = new List<List<Point>> { new List<Point> { new Point(0.599976, 7.0286), new Point(5.57775, 11.8), new Point(13.4, 1.40002) } };
- freehandArgs.Transparency = 1;
- freehandArgs.LineWidth = 2;
- if (freehandArgs != null)
- {
- selectedArgs = new List<AnnotHandlerEventArgs>();
- selectedArgs.Add(freehandArgs);
- }
- }
- else
- {
- //if (IsCopyShape && !IsSelectShape)
- //{
- // ShapeNames.Clear();
- //}
- freehandArgs = selectedArgs[0] as FreehandAnnotArgs;
- foreach (var item in selectedArgs)
- {
- //if (ListPoint((item as FreehandAnnotArgs).RawPointList, ShapePoints)){
- foreach (var point in viewContentViewModel.FillAndSign)
- {
- if ((item as FreehandAnnotArgs).PageIndex == point.PageIndex && (item as FreehandAnnotArgs).AnnotIndex == point.AnnotIndex)
- {
- //if (IsCopyShape && !IsSelectShape)
- //{
- // ShapeNames.Add(point.Shape);
- // Trace.WriteLine("woshi什么" + point.Shape);
- //}
- newSelectedArgs.Add(item);
- break;
- }
- }
- }
- //IsCopyShape = true;
- //freehandArgs.RawPointList = ShapePoints;
- //freehandArgs.InkColor = (SelectColor as SolidColorBrush).Color;
- //freehandArgs.Transparency = 1;
- //freehandArgs.LineWidth = LineWidth;
- annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
- annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
- annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
- annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
- annotAttribsList[AnnotAttrib.Path] = freehandArgs.RawPointList;
- annotAttribsList[AnnotAttrib.Width] = freehandArgs.Width;
- annotAttribsList[AnnotAttrib.Height] = freehandArgs.Height;
- AddToPropertyPanel("ShapFillProperty", "Freehand", newSelectedArgs, annotAttribsList);
- //GetStamp();
- return freehandArgs;
- }
- //annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
- //annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
- //annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
- //annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
- //AddToPropertyPanel("ShapFillProperty", "Freehand", selectedArgs, annotAttribsList);
- return freehandArgs;
- }
- /// <summary>
- /// 文本
- /// </summary>
- /// <param name="selectedfreetextArgs"></param>
- /// <returns></returns>
- private AnnotHandlerEventArgs GetFreetext(List<AnnotHandlerEventArgs> selectedArgs = null)
- {
- Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
- FreeTextAnnotArgs freetextArgs = null;
- TextAlignment textAlignment;
- if (selectedArgs == null || selectedArgs.Count == 0)
- {
- freetextArgs = new FreeTextAnnotArgs();
- freetextArgs.Align = TextAlignment.Left;
- freetextArgs.BgColor = Colors.Transparent;
- freetextArgs.FontName = Settings.Default.AppProperties.Annotate.TextFontFamaily;
- freetextArgs.FontColor = Colors.Black;
- freetextArgs.FontSize = 14;
- freetextArgs.Transparency = 1;
- freetextArgs.LineColor = Colors.Black;
- freetextArgs.LineWidth = 0;
- freetextArgs.TextContent = string.Empty;
- DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotFreeText);
- if (annotProperty != null)
- {
- freetextArgs.Align = annotProperty.TextAlign;
- freetextArgs.BgColor = annotProperty.BackgroundColor;
- freetextArgs.FontName = annotProperty.FontFamily;
- freetextArgs.FontColor = annotProperty.ForgoundColor;
- freetextArgs.FontSize = annotProperty.FontSize;
- freetextArgs.Transparency = annotProperty.Opacity;
- freetextArgs.LineColor = annotProperty.BorderColor;
- freetextArgs.LineWidth = annotProperty.Thickness;
- freetextArgs.TextContent = annotProperty.NoteText;
- freetextArgs.IsBold = annotProperty.FontWeight==FontWeights.Bold;
- freetextArgs.IsItalic = annotProperty.FontStyle==FontStyles.Italic;
- }
- int align = (int)Settings.Default.AppProperties.Annotate.TextAlign;
- if (align == 0)
- textAlignment = TextAlignment.Left;
- else if (align == 1)
- textAlignment = TextAlignment.Center;
- else
- textAlignment = TextAlignment.Right;
- if (freetextArgs != null)
- {
- selectedArgs = new List<AnnotHandlerEventArgs>();
- selectedArgs.Add(freetextArgs);
- }
- }
- else
- {
- freetextArgs = selectedArgs[0] as FreeTextAnnotArgs;
- textAlignment = freetextArgs.Align;
- }
- annotAttribsList[AnnotAttrib.Color] = freetextArgs.LineColor;
- annotAttribsList[AnnotAttrib.FillColor] = freetextArgs.BgColor;
- annotAttribsList[AnnotAttrib.Thickness] = freetextArgs.LineWidth;
- annotAttribsList[AnnotAttrib.Transparency] = freetextArgs.Transparency;
- annotAttribsList[AnnotAttrib.FontColor] = freetextArgs.FontColor;
- annotAttribsList[AnnotAttrib.FontSize] = freetextArgs.FontSize;
- annotAttribsList[AnnotAttrib.FontName] = freetextArgs.FontName;
- annotAttribsList[AnnotAttrib.IsItalic] = freetextArgs.IsItalic;
- annotAttribsList[AnnotAttrib.IsBold] = freetextArgs.IsBold;
- annotAttribsList[AnnotAttrib.TextAlign] = textAlignment;
- annotAttribsList[AnnotAttrib.NoteText] = freetextArgs.TextContent;
- annotAttribsList[AnnotAttrib.Text] = freetextArgs.TextContent;
- AddToPropertyPanel("FreetextAnnotProperty", DateOrText, selectedArgs, annotAttribsList);
- return freetextArgs;
- }
- /// <summary>
- /// 导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线
- /// </summary>
- /// <param name="viewContent">对应的注释面板</param>
- /// <param name="toolTag">导航到同一个注释xaml时,需要区分某个注释;比如高亮、删除线、下划线</param>
- /// <param name="annot">注释</param>
- /// <param name="annotAttribsList">更改注释属性的键值对,更改值后会自动记录undoRedo容器里</param>
- private void AddToPropertyPanel(string viewContent, string toolTag = null, List<AnnotHandlerEventArgs> annots = null, Dictionary<AnnotAttrib, object> annotAttribsList = null, AnnotAttribEvent annotAttribEvent = null, bool isUpData = false)
- {
- if (annots != null && annots.Count != 0)
- {
- propertyPanel.annotlists = annots;
- propertyPanel.annot = annots[0];
- }
- else
- {
- propertyPanel.annotlists = null;
- propertyPanel.annot = null;
- }
- if (annotAttribsList != null && annotAttribsList.Count != 0 && annots != null && annots.Count != 0)
- {
- if (annots.Count > 1)
- {
- if (propertyPanel.AnnotEvents == null)
- propertyPanel.AnnotEvents = new List<AnnotAttribEvent>();
- propertyPanel.AnnotEvents.Clear();
- foreach (var itemAnnot in annots)
- {
- var eventitem = AnnotAttribEvent.GetAnnotAttribEvent(itemAnnot, annotAttribsList);
- eventitem.ClearChangeAttribute();
- propertyPanel.AnnotEvents.Add(eventitem);
- }
- }
- var eventitem1 = AnnotAttribEvent.GetAnnotAttribEvent(annots[0], annotAttribsList);
- eventitem1.ClearChangeAttribute();
- propertyPanel.AnnotEvent = eventitem1;
- if (annots[0] is LinkAnnotArgs && annotAttribEvent != null)
- {
- propertyPanel.AnnotEvent = annotAttribEvent;
- }
- }
- if (toolTag == "Freetext")
- {
- propertyPanel.SetIsTextFill(true);
- }
- else
- {
- propertyPanel.SetIsTextFill(false);
- }
- if (string.IsNullOrEmpty(viewContent) == false)
- {
- if (isUpData) { return; }
- if (viewContent == "ShapFillProperty")
- {
- NavigateToProperty(viewContent, propertyPanel); return;
- }
- viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
- }
- }
- private void NavigateToProperty(string btnName, AnnotTransfer annotPropertyPanel)
- {
- NavigationParameters values = new NavigationParameters();
- values.Add(ParameterNames.PDFViewer, PDFViewer);
- values.Add(ParameterNames.PropertyPanelContentViewModel, annotPropertyPanel);
- values.Add("IsFillAndSign", IsFillAndSign);
- values.Add("Shape", Shape);
- values.Add("FillAndSignContentViewModel", this);
- regions.RequestNavigate(RegionNames.PropertyRegionName, btnName, values);
- viewContentViewModel.IsPropertyOpen = true;
- }
- /// <summary>
- /// 初始化按钮名称-属性面板字典
- /// </summary>
- private void InitDictionary()
- {
- btnToProperty["RbtnText"] = "TextFillProperty";
- btnToProperty["RbtnTick"] = "ShapFillProperty";
- btnToProperty["RbtnFork"] = "ShapFillProperty";
- btnToProperty["RbtnRectangle"] = "ShapFillProperty";
- btnToProperty["RbtnLine"] = "ShapFillProperty";
- btnToProperty["RbtnPoint"] = "ShapFillProperty";
- btnToProperty["RbtnDate"] = "DateFillProperty";
- btnToProperty["RbtnSign"] = "";
- }
- /// <summary>
- /// 手绘
- /// </summary>
- ///
- public string T_RightMenuAnnotCopy = App.MainPageLoader.GetString("ViewRightMenuAnnot_Copy");
- public string T_RightMenuAnnotCut = App.MainPageLoader.GetString("ViewRightMenuAnnot_Cut");
- public string T_RightMenuAnnotPaste = App.MainPageLoader.GetString("ViewRightMenuAnnot_Paste");
- public string T_RightMenuAnnotDelete = App.MainPageLoader.GetString("ViewRightMenuAnnot_Delete");
- public string T_RightMenuAnnotDefault = App.MainPageLoader.GetString("ViewRightMenuAnnot_Default");
- public string T_RightMenuFreetextAnnotFontColor = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnot_FontColor");
- public string T_RightMenuFreetextAnnotFillColor = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnot_FillColor");
- public string T_RightMenuFreetextAnnotFont = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnot_Font");
- public string T_RightMenuFreetextAnnotFontCourierNew = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotFont_CourierNew");
- public string T_RightMenuFreetextAnnotFontHelvetica = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotFont_Helvetica");
- public string T_RightMenuFreetextAnnotFontTimesNewRoman = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotFont_TimesNewRoman");
- public string T_RightMenuFreetextAnnotTextAlignment = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnot_TextAlignment");
- public string T_RightMenuFreetextAnnotTextAlignmentAlignLeft = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotTextAlignment_AlignLeft");
- public string T_RightMenuFreetextAnnotTextAlignmentAlignCenter = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotTextAlignment_AlignCenter");
- public string T_RightMenuFreetextAnnotTextAlignmentAlignRight = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotTextAlignment_AlignRight");
- public string T_RightMenuFreetextAnnotTextAlignmentFullyJustified = App.MainPageLoader.GetString("ViewRightMenuFreetextAnnotTextAlignment_FullyJustified");
- private void InitSelectFreeHandAnnotMenu()
- {
- var popMenu = new ContextMenu();
- PopMenu pop = new PopMenu(popMenu);
- var menuItem = new MenuItem();
- menuItem.Name = "FreeHandCopy";
- menuItem.Header = T_RightMenuAnnotCopy;
- pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
- menuItem = new MenuItem();
- menuItem.Name = "FreeHandCut";
- menuItem.Header = T_RightMenuAnnotCut;
- pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
- menuItem = new MenuItem();
- menuItem.Name = "FreeHandPaste";
- menuItem.Header = T_RightMenuAnnotPaste;
- pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
- menuItem = new MenuItem();
- menuItem.Name = "FreeHandDelete";
- menuItem.Header = T_RightMenuAnnotDelete;
- pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
- pop.AddItem(GetSeparator());
- menuItem = new MenuItem();
- menuItem.Name = "FreeHandDefault";
- menuItem.Header = T_RightMenuAnnotDefault;
- pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
- FreeHandAnnotPopMenu = pop;
- }
- /// <summary>
- /// 文本
- /// </summary>
- private void InitSelectFreeTextAnnotMenu()
- {
- var popMenu = new ContextMenu();
- PopMenu pop = new PopMenu(popMenu);
- var menuItem = new MenuItem();
- menuItem.Name = "FreeTextCopy";
- menuItem.Header = T_RightMenuAnnotCopy;
- pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
- menuItem = new MenuItem();
- menuItem.Name = "FreeTextCut";
- menuItem.Header = T_RightMenuAnnotCut;
- pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
- menuItem = new MenuItem();
- menuItem.Name = "FreeTextPaste";
- menuItem.Header = T_RightMenuAnnotPaste;
- pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Paste);
- menuItem = new MenuItem();
- menuItem.Name = "FreeTextDelete";
- menuItem.Header = T_RightMenuAnnotDelete;
- pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
- pop.AddItem(GetSeparator());
- menuItem = new MenuItem();
- menuItem.Name = "FreeTextColor";
- menuItem.Header = T_RightMenuFreetextAnnotFontColor;
- menuItem.Tag = "FontColor";
- pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
- menuItem = new MenuItem();
- menuItem.Name = "FreeTextColor";
- menuItem.Header = T_RightMenuFreetextAnnotFillColor;
- menuItem.Tag = "FillColor";
- pop.BindingEvent(pop.AddItem(menuItem), AnnotColorPalette_MenuCommand);
- menuItem = new MenuItem();
- menuItem.Name = "FreeTextFontFamily";
- menuItem.Header = T_RightMenuFreetextAnnotFont;
- pop.AddItem(menuItem);
- var family = TextFont.GetFamily();
- foreach (var item in family)
- {
- RadioButton familyRdioBtn = new RadioButton();
- familyRdioBtn.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
- familyRdioBtn.Background = new SolidColorBrush(Colors.Transparent);
- familyRdioBtn.Name = item.ValueStr;
- familyRdioBtn.Tag = item.ValueStr;
- familyRdioBtn.GroupName = "FontFamily";
- familyRdioBtn.Content = item.Content;
- pop.BindingEvent(pop.AddChild("FreeTextFontFamily", familyRdioBtn), FreeTextFontFamily_MenuCommand);
- }
- menuItem = new MenuItem();
- menuItem.Name = "FreeTextAglin";
- menuItem.Header = T_RightMenuFreetextAnnotTextAlignment;
- pop.AddItem(menuItem);
- var radioButton = new RadioButton();
- radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
- radioButton.Background = new SolidColorBrush(Colors.Transparent);
- radioButton.Name = "FreeTextAglinLeft";
- radioButton.Tag = "Left";
- radioButton.GroupName = "Aglin";
- radioButton.Content = T_RightMenuFreetextAnnotTextAlignmentAlignLeft;
- pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
- radioButton = new RadioButton();
- radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
- radioButton.Background = new SolidColorBrush(Colors.Transparent);
- radioButton.Name = "FreeTextAglinCenter";
- radioButton.Tag = "Center";
- radioButton.GroupName = "Aglin";
- radioButton.Content = T_RightMenuFreetextAnnotTextAlignmentAlignCenter;
- pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
- radioButton = new RadioButton();
- radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
- radioButton.Background = new SolidColorBrush(Colors.Transparent);
- radioButton.Name = "FreeTextAglinRight";
- radioButton.Tag = "Right";
- radioButton.GroupName = "Aglin";
- radioButton.Content = T_RightMenuFreetextAnnotTextAlignmentAlignRight;
- pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
- radioButton = new RadioButton();
- radioButton.Style = App.Current.Resources["MenuRadioBtnStyle"] as Style;
- radioButton.Background = new SolidColorBrush(Colors.Transparent);
- radioButton.Name = "FreeTextAglinJustify";
- radioButton.Tag = "Justify";
- radioButton.GroupName = "Aglin";
- radioButton.Content = T_RightMenuFreetextAnnotTextAlignmentFullyJustified;
- pop.BindingEvent(pop.AddChild("FreeTextAglin", radioButton), FreeTextAglin_MenuCommand);
- menuItem = new MenuItem();
- menuItem.Name = "FreeHandDefault";
- menuItem.Header = T_RightMenuAnnotDefault;
- pop.BindingEvent(pop.AddItem(menuItem), AnnotDefaultValue_MenuCommand);
- FreeTextAnnotPopMenu = pop;
- }
- /// <summary>
- /// 多选注释
- /// </summary>
- private void InitSelectMultiAnnotMenu()
- {
- var popMenu = new ContextMenu();
- PopMenu pop = new PopMenu(popMenu);
- var menuItem = new MenuItem();
- menuItem.Name = "MultiCopy";
- menuItem.Header = T_RightMenuAnnotCopy;
- pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Copy);
- menuItem = new MenuItem();
- menuItem.Name = "MultiCut";
- menuItem.Header = T_RightMenuAnnotCut;
- pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Cut);
- menuItem = new MenuItem();
- menuItem.Name = "MultiDelete";
- menuItem.Header = T_RightMenuAnnotDelete;
- pop.BindingEvent(pop.AddItem(menuItem), ApplicationCommands.Delete);
- MultiAnnotPopMenu = pop;
- }
- private Separator GetSeparator()
- {
- Separator separator = new Separator();
- separator.Height = 1;
- separator.BorderBrush = new SolidColorBrush(Color.FromArgb(0x33, 0x00, 0x00, 0x00));
- separator.BorderThickness = new Thickness(1);
- return separator;
- }
- private void BindingPDFViewerHandler()
- {
- //来自PDFViewer的响应事件
- if (PDFViewer != null)
- {
- PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
- PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
- PDFViewer.AnnotCommandHandler -= PDFViewer_AnnotCommandHandler;
- PDFViewer.AnnotCommandHandler += PDFViewer_AnnotCommandHandler;
- PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
- PDFViewer.AnnotEditHandler += PDFViewer_AnnotEditHandler;
- PDFViewer.AnnotHoverHandler -= PDFViewer_AnnotHoverHandler;
- PDFViewer.AnnotHoverHandler += PDFViewer_AnnotHoverHandler;
- //CommandManager.AddPreviewExecutedHandler(PDFViewer, PreviewExcute);
- KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
- KeyEventsHelper.KeyDown += ShortCut_KeyDown;
- }
- }
- private void UnBindingPDFViewerHandler()
- {
- if (PDFViewer != null)
- {
- PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
- PDFViewer.AnnotEditHandler -= PDFViewer_AnnotEditHandler;
- PDFViewer.AnnotCommandHandler -= PDFViewer_AnnotCommandHandler;
- PDFViewer.AnnotHoverHandler -= PDFViewer_AnnotHoverHandler;
- KeyEventsHelper.KeyDown -= ShortCut_KeyDown;
- }
- }
- private void ShortCut_KeyDown(object sender, KeyEventArgs e)
- {
- //if (!PDFViewer.ToolManager.HasTool)
- //{
- // HookShapeIsCheck = true;
- // HookShapeIsCheck = false;
- //}
- }
- //在注释工具的状态下,右键菜单
- private void PDFViewer_AnnotCommandHandler(object sender, AnnotCommandArgs e)
- {
- if (e.AnnotEventArgsList == null || (PDFViewer != null && PDFViewer.MouseMode == MouseModes.FormEditTool))
- return;
- //if ((UIElement)sender != null)
- //{
- // CommandManager.AddPreviewExecutedHandler((UIElement)sender, PreviewExcute);
- //}
- 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.AnnotFreehand:
- e.PopupMenu = FreeHandAnnotPopMenu.OpenMenu(selectedAnnot, sender);
- break;
- case AnnotArgsType.AnnotFreeText:
- e.PopupMenu = FreeTextAnnotPopMenu.OpenMenu(selectedAnnot, sender);
- break;
- }
- }
- else
- {
- bool isHigh = true;//是否为高亮
- foreach (var item in e.AnnotEventArgsList)
- {
- if (isHightAnnot(item) == false)
- {
- isHigh = false;
- break;
- }
- }
- MultiAnnotPopMenu.SetVisual("MultiCopy", !isHigh);
- MultiAnnotPopMenu.SetVisual("MultiCut", !isHigh);
- e.PopupMenu = MultiAnnotPopMenu.OpenMenu(e.AnnotEventArgsList, sender);//SelectMultiAnnotMenu(e.AnnotEventArgsList, isHigh);
- }
- }
- if (e.PopupMenu != null)
- {
- e.Handle = true;
- }
- }
- else
- {
- if (e.PressOnSelectedText || e.CommandTarget == TargetType.ImageSelection)
- {
- if (e.PopupMenu != null)
- {
- e.Handle = true;
- }
- }
- else
- {
- e.PopupMenu = ViewerContextMenu(sender);
- if (e.PopupMenu != null)
- {
- e.Handle = true;
- }
- }
- }
- break;
- }
- }
- private void PDFViewer_AnnotHoverHandler(object sender, AnnotHoverData e)
- {
- if (e != null && e.DrawContext != null)
- {
- Rect hoverRect = new Rect(
- e.PaintRect.Left - 2,
- e.PaintRect.Top - 2,
- e.PaintRect.Width + 4,
- e.PaintRect.Height + 4);
- Pen hoverPen = new Pen(new SolidColorBrush(Color.FromArgb(0xff, 0x11, 0x8A, 0xff)), 1);
- hoverPen.DashStyle = DashStyles.Dash;
- e.DrawContext?.DrawRectangle(null, hoverPen, hoverRect);
- }
- CloseAnnotToolTip();
- }
- private Rect oldRect = new Rect(0, 0, 0, 0);
- private void CloseAnnotToolTip()
- {
- if (PDFViewer.ToolTip != null && PDFViewer.ToolTip is ToolTip)
- {
- ToolTip oldTips = (ToolTip)PDFViewer.ToolTip;
- oldTips.IsOpen = false;
- oldTips.Visibility = Visibility.Collapsed;
- PDFViewer.ToolTip = null;
- PDFViewer.MouseMove -= PDFViewer_MouseMove;
- oldRect = new Rect(0, 0, 0, 0);
- }
- }
- private void PDFViewer_MouseMove(object sender, MouseEventArgs e)
- {
- if (sender != null && PDFViewer.ToolTip != null && PDFViewer.Parent != null)
- {
- var newPoint = e.GetPosition(PDFViewer.Parent as ContentControl);
- var isOutw = newPoint.X > (oldRect.X + oldRect.Width + 4);
- var isOuth = newPoint.Y > (oldRect.Y + oldRect.Height + 4);
- if (newPoint.X < oldRect.X || newPoint.Y < oldRect.Y || isOutw || isOuth)
- {
- CloseAnnotToolTip();
- }
- }
- }
- private ContextMenu ViewerContextMenu(object sender)
- {
- ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
- ViewerContextMenu_Loaded(contextMenu, sender);
- return contextMenu;
- }
- private void ViewerContextMenu_Loaded(object sender, object e, Visibility visibility = Visibility.Collapsed)
- {
- ContextMenu contextMenu = sender as ContextMenu;
- contextMenu.DataContext = viewContentViewModel;
- if (contextMenu.Items.Count > 0)
- {
- int index = PDFViewer.CurrentIndex;
- //检测是否已存在相同数据
- CPDFBookmark list = PDFViewer.Document.GetBookmarkList().FirstOrDefault(q => q.PageIndex == index);
- foreach (var item in contextMenu.Items)
- {
- if (item is Separator separator)
- {
- separator.Visibility = visibility;
- }
- if (item is MenuItem menuItem1)
- {
- //if (menuItem1.Tag.ToString() == "DisplayAnnot" || menuItem1.Tag.ToString() == "HiddenAnnot")
- //{
- // SetMenuItemVisibility(menuItem1, "DisplayAnnot", "HiddenAnnot", isHiddenAnnot);
- //}
- switch (menuItem1.Tag.ToString())
- {
- case "Paste":
- //粘贴
- //if (!ApplicationCommands.Paste.CanExecute(null, (UIElement)sender))
- //{
- // menuItem1.IsEnabled = false;
- // menuItem1.Opacity = 0.5;
- //}
- //else
- //{
- // menuItem1.IsEnabled = true;
- // menuItem1.Opacity = 1;
- //}
- menuItem1.CommandTarget = (UIElement)e;
- menuItem1.Command = ApplicationCommands.Paste;
- break;
- case "AddAnnotation":
- menuItem1.Visibility = visibility;
- break;
- case "HiddenAnnot":
- menuItem1.Visibility = visibility;
- break;
- case "DisplayAnnot":
- menuItem1.Visibility = visibility;
- break;
- case "AddBookMark":
- menuItem1.Visibility = visibility;
- break;
- case "DelBookMark":
- menuItem1.Visibility = visibility;
- break;
- case "ToolMode":
- menuItem1.Visibility = visibility;
- break;
- case "ReadModel":
- menuItem1.Visibility = visibility;
- break;
- case "UnReadModel":
- menuItem1.Visibility = visibility;
- break;
- case "ViewZoom":
- menuItem1.Visibility = visibility;
- break;
- case "PageDisplay":
- menuItem1.Visibility = visibility;
- break;
- case "Select":
- menuItem1.Click -= Select_Click;
- menuItem1.Click += Select_Click;
- break;
- case "Print":
- menuItem1.Command = viewContentViewModel.PrintCommand;
- break;
- }
- }
- }
- }
- }
- private void Select_Click(object sender, RoutedEventArgs e)
- {
- if (viewContentViewModel.OpenBOTA == false)
- {
- viewContentViewModel.OpenBOTA = true;
- }
- bool isBook = IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, "TabItemSearch");
- if (isBook == false)
- {
- bOTAContent.TabItemSearch.IsSelected = true;
- }
- }
- private bool IsBOTATabItemShow(out BOTAContentViewModel bOTAContentViewModel, out BOTAContent bOTAContent, string tabItemText)
- {
- bool isTabItem = false;
- bOTAContentViewModel = null;
- bOTAContent = null;
- if (regions.Regions.ContainsRegionWithName(viewContentViewModel.BOTARegionName))
- {
- var views = regions.Regions[viewContentViewModel.BOTARegionName].Views;
- var model = views.FirstOrDefault(q => q is BOTAContent);
- if (model is BOTAContent bOTAContent1)
- {
- bOTAContent = bOTAContent1;
- bOTAContentViewModel = bOTAContent.DataContext as BOTAContentViewModel;
- if (bOTAContentViewModel.CurrentBar == tabItemText)
- {
- isTabItem = true;
- }
- }
- //foreach (var item in views)
- //{
- // if (item is BOTAContent bOTAContent1)
- // {
- // bOTAContent = bOTAContent1;
- // bOTAContentViewModel = bOTAContent.DataContext as BOTAContentViewModel;
- // if (bOTAContentViewModel.CurrentBar == tabItemText)
- // {
- // isTabItem = true;
- // break;
- // }
- // }
- //}
- }
- return isTabItem;
- }
- 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 PDFViewer_AnnotEditHandler(object sender, List<AnnotEditEvent> e)
- {
- bool IsAdd = false;
- if (e != null && e.Count > 0)
- {
- int i = 0;
- Dictionary<int, List<int>> selectAnnotDicts = new Dictionary<int, List<int>>();
- for (i = 0; i < e.Count; i++)
- {
- AnnotEditEvent editEvent = e[i];
- int pageindex = editEvent.PageIndex;
- int annotindex = editEvent.AnnotIndex;
- switch (editEvent.EditAction)
- {
- case ActionType.Add:
- IsAdd = true;
- if (selectAnnotDicts.ContainsKey(editEvent.PageIndex) == false)
- {
- selectAnnotDicts.Add(editEvent.PageIndex, new List<int>());
- selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
- }
- else
- {
- selectAnnotDicts[editEvent.PageIndex].Add(editEvent.AnnotIndex);
- }
- //if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreehand)
- //{
- // //if (IsSelectShape)
- // //{
- // if (ShapeNames.Count == 0) { continue; }
- // if (ShapeNames[i] == "Freehand") { continue; }
- // try
- // {
- // viewContentViewModel.FillAndSign.Add(new FillAndSignIsShape(pageindex, annotindex, ShapeNames[i]));
- // //PDFViewer.SelectAnnotation(pageindex, annotindex);
- // continue;
- // }
- // catch { continue; }
- // //}
- //}
- if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotStamp)
- {
- if (Shape != "None")
- {
- if (Shape == "Sign")
- {
- viewContentViewModel.AnnotSignatures.Add(new Tuple<int, int>(pageindex, annotindex));
- continue;
- }
- else
- {
- viewContentViewModel.FillAndSign.Add(new FillAndSignIsShape(pageindex, annotindex, Shape));
- PDFViewer.SelectAnnotation(pageindex, annotindex);
- }
- }
- }
- if (editEvent.EditAnnotArgs.EventType == AnnotArgsType.AnnotFreehand && i == 0)
- {
- PDFViewer.SelectAnnotation(pageindex, annotindex);
- }
- //else
- //{
- // foreach (var point in viewContentViewModel.FillAndSign)
- // {
- // if (pageindex == point.PageIndex && annotindex == point.AnnotIndex)
- // {
- // point.Shape= Shape;
- // }
- // }
- //}
- break;
- case ActionType.Del:
- break;
- }
- }
- if (i > 1 && IsAdd)
- {
- PDFViewer.SelectAnnotation(selectAnnotDicts);
- }
- }
- }
- //选中和非选中注释,右键菜单
- private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
- {
- if (e != null)
- {
- IsClickNull = false;
- var annot = e.AnnotItemsList[0];
- if (annot != null)
- {
- if (e.AnnotItemsList.Count == 1)
- {
- //IsEdit = false;
- //IsAnnotCreateReset:是否为创建注释的状态
- if (e.IsAnnotCreateReset == false)
- {
- GetSelectedAnnots(e);
- //记录这次选中的注释,之后创建注释会跟随上次选中注释的属性值
- //PDFViewer.SetToolParam(annot);
- }
- else
- {
- //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)
- {
- lastAnnot = item;
- continue;
- }
- lastAnnot = item;
- isDifferentAnnotTyle = true;
- break;
- }
- }
- if (isDifferentAnnotTyle)
- viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
- else
- GetSelectedAnnots(e);
- }
- }
- }
- else
- {
- if (PDFViewer.MouseMode != MouseModes.AnnotCreate)
- {
- viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
- }
- else { IsClickNull = true; }
- }
- }
- private bool isShapAnnot(AnnotHandlerEventArgs annot)
- {
- if (annot.EventType == AnnotArgsType.AnnotCircle ||
- annot.EventType == AnnotArgsType.AnnotSquare ||
- annot.EventType == AnnotArgsType.AnnotLine
- )
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private void GetSelectedAnnots(AnnotAttribEvent e)
- {
- IsEdit = true;
- var annot = e.AnnotItemsList[0];
- switch (annot.EventType)
- {
- case AnnotArgsType.AnnotFreeText:
- GetFreetext(e.AnnotItemsList);
- break;
- case AnnotArgsType.AnnotFreehand:
- bool isDifferen = false;
- foreach (var point in viewContentViewModel.FillAndSign)
- {
- if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
- {
- isDifferen = true;
- break;
- }
- else
- {
- isDifferen = false;
- }
- }
- if (!isDifferen)
- {
- foreach (var point in viewContentViewModel.AnnotSignatures)
- {
- if (annot.PageIndex == point.Item1 && annot.AnnotIndex == point.Item2)
- {
- isDifferen = true;
- break;
- }
- else
- {
- isDifferen = false;
- }
- }
- if (isDifferen)
- {
- viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null); return;
- }
- viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null); return;
- }
- GetFreehand(e.AnnotItemsList);
- break;
- }
- }
- public void ShowPropertyPanel(bool show = true)
- {
- viewContentViewModel.IsPropertyOpen = show;
- }
- //private void PreviewExcute(object sender, ExecutedRoutedEventArgs e)
- //{
- // if (e.Command == ApplicationCommands.Paste)
- // {
- // ShapeNames.Clear();
- // Trace.WriteLine("几次" + 1);
- // var items = PDFViewer.GetCopyAnnotData();
- // foreach (var item in items)
- // {
- // bool IsShape = false;
- // foreach (var point in viewContentViewModel.FillAndSign)
- // {
- // if ((item as FreehandAnnotArgs).PageIndex == point.PageIndex && (item as FreehandAnnotArgs).AnnotIndex == point.AnnotIndex)
- // {
- // ShapeNames.Add(point.Shape);
- // Trace.WriteLine("woshi什么" + point.Shape);
- // IsShape = true;
- // continue;
- // }
- // }
- // if (!IsShape) {
- // ShapeNames.Add("Freehand");
- // Trace.WriteLine("woshi什么" + "Freehand");
- // }
- // }
- // }
- // if (e.Command == ApplicationCommands.Copy)
- // {
- // IsCopyShape = false;
- // }
- //}
- //private void PreviewExcuteView(object sender, ExecutedRoutedEventArgs e)
- //{
- // if (e.Command == ApplicationCommands.Paste)
- // {
- // IsSelectShape = true;
- // }
- // if (e.Command == ApplicationCommands.Copy)
- // {
- // IsCopyShape = false;
- // }
- //}
- public void ExitAnnotationTool()
- {
- PDFViewer.DisableClearSelectAnnot(false);
- PDFViewer.ClearSelectAnnots();
- PDFViewer.SetMouseMode(MouseModes.PanTool);
- if (PDFViewer.MouseMode != MouseModes.AnnotCreate)
- {
- PDFViewer.SetMouseMode(MouseModes.AnnotCreate);
- var annotArgs = new SelectToolArgs();
- PDFViewer.SetToolParam(annotArgs);
- }
- viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
- ShowPropertyPanel(false);
- }
- #region Navigation
- public bool IsNavigationTarget(NavigationContext navigationContext)
- {
- return true;
- }
- public void OnNavigatedFrom(NavigationContext navigationContext)
- {
- UnBindingPDFViewerHandler();
- ContextMenu contextMenu = App.Current.FindResource("ViewerContextMenu") as ContextMenu;
- ViewerContextMenu_Loaded(contextMenu, null, Visibility.Visible);
- viewContentViewModel.SelectedPrpoertyPanel("PropertyPanelContent", null);
- PDFViewer.SetMouseMode(MouseModes.PanTool);
- ShowPropertyPanel(false);
- }
- public void OnNavigatedTo(NavigationContext navigationContext)
- {
-
- IsFillAndSign = true;
- navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
- navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
- BindingPDFViewerHandler();
- ExitAnnotationTool();
- HookShapeIsCheck = true;
- HookShapeIsCheck = false;
- //ShowPropertyPanel(false);
- //PDFViewer.SetMouseMode(MouseModes.PanTool);
- // InitCheckedEvent("RbtnTick");
- IsEdit = false;
- }
- #endregion
- }
- }
|