ShapFillPropertyViewModel.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. using ComPDFKitViewer.AnnotEvent;
  2. using ComPDFKitViewer;
  3. using Prism.Mvvm;
  4. using Prism.Regions;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Media;
  12. using Prism.Commands;
  13. using System.Windows.Controls;
  14. using ComPDFKit.PDFAnnotation;
  15. using PDF_Master.Helper;
  16. using System.Diagnostics;
  17. using PDF_Master.Model;
  18. using PDF_Master.ViewModels.Tools;
  19. using Microsoft.Office.Interop.Excel;
  20. using Point = System.Windows.Point;
  21. using static Dropbox.Api.UsersCommon.AccountType;
  22. using PDF_Master.Model.AnnotPanel;
  23. using PDFSettings;
  24. using PDF_Master.ViewModels.Tools.AnnotManager;
  25. using Prism.Common;
  26. using ComPDFKitViewer.PdfViewer;
  27. using PDF_Master.CustomControl.CompositeControl;
  28. using Microsoft.Office.Interop.Word;
  29. namespace PDF_Master.ViewModels.FillAndSign.PropertyPanel
  30. {
  31. public class ShapFillPropertyViewModel : BindableBase, INavigationAware
  32. {
  33. public AnnotAttribEvent AnnotEvent { get; set; }
  34. private AnnotHandlerEventArgs Annot;
  35. private AnnotTransfer PropertyPanel;
  36. private FillAndSignContentViewModel fillAndSignContentViewModel;
  37. public List<List<Point>> updatapath = new List<List<Point>>();
  38. private Geometry dataPath = null;
  39. private bool IsFillAndSign = false;
  40. public string shape = "";
  41. public string Shape
  42. {
  43. get { return shape; }
  44. set
  45. {
  46. SetProperty(ref shape, value);
  47. }
  48. }
  49. public string shapeType = "";
  50. public string ShapeType
  51. {
  52. get { return shapeType; }
  53. set
  54. {
  55. SetProperty(ref shapeType, value);
  56. }
  57. }
  58. public Geometry DataPath
  59. {
  60. get { return dataPath; }
  61. set
  62. {
  63. SetProperty(ref dataPath, value);
  64. }
  65. }
  66. private void InitColorItems()
  67. {
  68. }
  69. private Brush selectColor = new SolidColorBrush(Color.FromArgb(0xff, 0x26, 0x25, 0x29));
  70. public Brush SelectColor
  71. {
  72. get { return selectColor; }
  73. set
  74. {
  75. SetProperty(ref selectColor, value);
  76. UPDataColor();
  77. }
  78. }
  79. private double fillOpacity = 1;
  80. public double FillOpacity
  81. {
  82. get { return fillOpacity; }
  83. set
  84. {
  85. SetProperty(ref fillOpacity, value);
  86. //if (!fillAndSignContentViewModel.isFirst)
  87. //{
  88. // fillAndSignContentViewModel.FillOpacity = value;
  89. // //if (FillAndSignContentViewModel.IsEdit)
  90. // {
  91. // PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, fillOpacity);
  92. // }
  93. // //else
  94. // {
  95. // if (IsFillAndSign) { fillAndSignContentViewModel.SetStamp(); }
  96. // }
  97. //}
  98. }
  99. }
  100. private bool _isMultiSelected = false;
  101. public bool IsMultiSelected
  102. {
  103. get { return _isMultiSelected; }
  104. set
  105. {
  106. SetProperty(ref _isMultiSelected, value);
  107. if (value) { ShapeType = "General Properties"; }
  108. }
  109. }
  110. private bool _isSelected = false;
  111. public bool IsSelected
  112. {
  113. get { return _isSelected; }
  114. set => SetProperty(ref _isSelected, value);
  115. }
  116. private double lineWidthMultiple = 1;
  117. private double lineWidth = 1;
  118. public double LineWidth
  119. {
  120. get { return lineWidth; }
  121. set
  122. {
  123. SetProperty(ref lineWidth, value);
  124. }
  125. }
  126. private Brush _shapeColortColor = new SolidColorBrush(Color.FromArgb(0xff, 0x26, 0x25, 0x29));
  127. public Brush ShapeColorColor
  128. {
  129. get { return _shapeColortColor; }
  130. set { SetProperty(ref _shapeColortColor, value); }
  131. }
  132. List<ColorItem> shapeColorItems = new List<ColorItem>();
  133. public List<ColorItem> ShapeColorItems
  134. {
  135. get { return shapeColorItems; }
  136. set
  137. {
  138. SetProperty(ref shapeColorItems, value);
  139. }
  140. }
  141. private void InitShapeColorList()
  142. {
  143. ShapeColorItems = new List<ColorItem>();
  144. ColorItem colorItem = new ColorItem(Color.FromArgb(0xff, 0xfc, 0x1f, 0x1f), 0);
  145. ShapeColorItems.Add(colorItem);
  146. colorItem = new ColorItem(Color.FromArgb(0xff, 0x26, 0x25, 0x29), 1);
  147. ShapeColorItems.Add(colorItem);
  148. colorItem = new ColorItem(Color.FromArgb(0xff, 0x29, 0x53, 0x93), 2);
  149. ShapeColorItems.Add(colorItem);
  150. colorItem = new ColorItem(Color.FromArgb(0xff, 0x1e, 0x89, 0x56), 3);
  151. ShapeColorItems.Add(colorItem);
  152. }
  153. private DefaultAnnotProperty GetAnnotDefault(AnnotArgsType annotArgsType, string savaKey = "")
  154. {
  155. var Annot = SettingHelper.GetAnnotDefaultProperty(annotArgsType, savaKey);
  156. if (Annot == null)
  157. {
  158. Annot = new DefaultAnnotProperty();
  159. Annot.AnnotToolType = annotArgsType;
  160. }
  161. return Annot;
  162. }
  163. public DelegateCommand<object> SelectedThickCommand { get; set; }
  164. public DelegateCommand<object> SelectedColorCommand { get; set; }
  165. //public DelegateCommand<object> LineStyleCommand { get; set; }
  166. public DelegateCommand<object> SelectedLineWidthValueCommand { get; set; }
  167. public DelegateCommand<object> SharpsTypeCommand { get; set; }
  168. public DelegateCommand<object> ThicknessChangedCommand { get; set; }
  169. public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
  170. public ShapFillPropertyViewModel()
  171. {
  172. InitShapeColorList();
  173. SelectedThickCommand = new DelegateCommand<object>(SelectedThick_Command);
  174. SelectedColorCommand = new DelegateCommand<object>(SelectedColor_Command);
  175. SelectedLineWidthValueCommand = new DelegateCommand<object>(SelectedLineWitdh_Command);
  176. //LineStyleCommand = new DelegateCommand<object>(LineStyle_Command);
  177. SharpsTypeCommand = new DelegateCommand<object>(SharpsType_Command);
  178. ThicknessChangedCommand = new DelegateCommand<object>(ThicknessChanged_Command);
  179. SelectedOpacityValueCommand = new DelegateCommand<object>(SelectedOpacityValue);
  180. }
  181. private void InitFillAndSignProperty()
  182. {
  183. if (fillAndSignContentViewModel.isFirst)
  184. {
  185. SelectColor = fillAndSignContentViewModel.SelectColor;
  186. FillOpacity = fillAndSignContentViewModel.FillOpacity;
  187. LineWidth = fillAndSignContentViewModel.LineWidth;
  188. }
  189. fillAndSignContentViewModel.isFirst = false;
  190. }
  191. private DefaultAnnotProperty GetAnnotDefault(AnnotArgsType annotArgsType)
  192. {
  193. var Annot = SettingHelper.GetAnnotDefaultProperty(annotArgsType, "FillAndSign");
  194. if (Annot == null)
  195. {
  196. Annot = new DefaultAnnotProperty();
  197. Annot.AnnotToolType = annotArgsType;
  198. }
  199. return Annot;
  200. }
  201. private void SharpsType_Command(object obj)
  202. {
  203. if (obj != null)
  204. {
  205. var tag = (string)obj;
  206. SharpsType(tag, obj);
  207. }
  208. }
  209. private void SharpsType(string tag, object obj, bool isFromToolsBtn = false)
  210. {
  211. fillAndSignContentViewModel.LineWidthMultiple = 1;
  212. Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
  213. lineWidthMultiple = 1;
  214. //PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Width, 60);
  215. //PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Height, 60);
  216. switch (tag)
  217. {
  218. case "HookShape":
  219. var hookShape = new PathGeometry();
  220. hookShape.AddGeometry(Geometry.Parse("M0.599976 7.0286L5.57775 11.8L13.4 1.40002"));
  221. DataPath = hookShape;
  222. //if (FillAndSignContentViewModel.IsEdit)
  223. {
  224. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, LineWidth * fillAndSignContentViewModel.LineWidthMultiple);
  225. updatapath = fillAndSignContentViewModel.keyShape[tag];
  226. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Path, updatapath);
  227. if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count >= 1)
  228. {
  229. foreach (var annot in PropertyPanel.annotlists)
  230. {
  231. foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
  232. {
  233. if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
  234. {
  235. point.Shape = "HookShape";
  236. }
  237. }
  238. }
  239. }
  240. }
  241. //PropertyPanel.UpdateAnnotAAttrib();
  242. //fillAndSignContentViewModel.ShapePoints = 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) } };
  243. //fillAndSignContentViewModel.SetStamp();
  244. //changeData[AnnotArgsType.AnnotLine] = tag;
  245. break;
  246. case "ForkShape":
  247. var forkShape = new PathGeometry();
  248. forkShape.AddGeometry(Geometry.Parse("M3.19995 3.20001L12.8 12.8 M12.8 3.20001L3.20005 12.8"));
  249. DataPath = forkShape;
  250. // if (FillAndSignContentViewModel.IsEdit)
  251. {
  252. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, LineWidth * fillAndSignContentViewModel.LineWidthMultiple);
  253. updatapath = fillAndSignContentViewModel.keyShape[tag];
  254. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Path, updatapath);
  255. if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count >= 1)
  256. {
  257. foreach (var annot in PropertyPanel.annotlists)
  258. {
  259. foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
  260. {
  261. if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
  262. {
  263. point.Shape = "ForkShape";
  264. }
  265. }
  266. }
  267. }
  268. }
  269. //fillAndSignContentViewModel.ShapePoints = new List<List<Point>> { new List<Point> { new Point(3.19995, 3.20001), new Point(12.8, 12.8) }, new List<Point> { new Point(12.8, 3.20001), new Point(3.20005, 12.8) } };
  270. //fillAndSignContentViewModel.SetStamp();
  271. //changeData[AnnotArgsType.AnnotLine] = tag;
  272. break;
  273. case "RectShape":
  274. {
  275. RectangleGeometry rectPath = new RectangleGeometry();
  276. rectPath.Rect = new Rect(0, 5, 28, 22);
  277. DataPath = rectPath;
  278. //if (FillAndSignContentViewModel.IsEdit)
  279. {
  280. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, LineWidth * fillAndSignContentViewModel.LineWidthMultiple);
  281. updatapath = fillAndSignContentViewModel.keyShape[tag];
  282. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Path, updatapath);
  283. if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count >= 1)
  284. {
  285. foreach (var annot in PropertyPanel.annotlists)
  286. {
  287. foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
  288. {
  289. if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
  290. {
  291. point.Shape = "RectShape";
  292. }
  293. }
  294. }
  295. }
  296. }
  297. //fillAndSignContentViewModel.ShapePoints = new List<List<Point>> { new List<Point> { new Point(0.19995, 5), new Point(28, 5), new Point(28, 27), new Point(0.19995, 27), new Point(0.19995, 5) } };
  298. //fillAndSignContentViewModel.SetStamp();
  299. // changeData[AnnotArgsType.AnnotSquare] = tag;
  300. }
  301. break;
  302. case "LineShape":
  303. {
  304. var lineShape = new PathGeometry();
  305. lineShape.AddGeometry(Geometry.Parse(" M0,10L20,10"));
  306. DataPath = lineShape;
  307. // if (FillAndSignContentViewModel.IsEdit)
  308. {
  309. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, LineWidth * fillAndSignContentViewModel.LineWidthMultiple);
  310. updatapath = fillAndSignContentViewModel.keyShape[tag];
  311. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Path, updatapath);
  312. if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count >= 1)
  313. {
  314. foreach (var annot in PropertyPanel.annotlists)
  315. {
  316. foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
  317. {
  318. if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
  319. {
  320. point.Shape = "LineShape";
  321. }
  322. }
  323. }
  324. }
  325. }
  326. //fillAndSignContentViewModel.ShapePoints = new List<List<Point>> { new List<Point> { new Point(12.19995, 10), new Point(36, 10) } };
  327. //fillAndSignContentViewModel.SetStamp();
  328. //changeData[AnnotArgsType.AnnotLine] = tag;
  329. }
  330. break;
  331. case "DotShape":
  332. {
  333. //fillAndSignContentViewModel.LineWidthMultiple = 5;
  334. EllipseGeometry circlePath = new EllipseGeometry();
  335. circlePath.RadiusX = 2.4;
  336. circlePath.RadiusY = 2.4;
  337. circlePath.Center = new Point(2.4, 2.4);
  338. DataPath = circlePath;
  339. // if (FillAndSignContentViewModel.IsEdit)
  340. {
  341. lineWidthMultiple = 5;
  342. updatapath = fillAndSignContentViewModel.keyShape[tag];
  343. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, LineWidth * 5);
  344. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Path, updatapath);
  345. if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count >= 1)
  346. {
  347. foreach (var annot in PropertyPanel.annotlists)
  348. {
  349. foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
  350. {
  351. if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
  352. {
  353. point.Shape = "DotShape";
  354. }
  355. }
  356. }
  357. }
  358. }
  359. //fillAndSignContentViewModel.ShapePoints = new List<List<Point>> { new List<Point> { new Point(0.19995, 1.19995), new Point(0.19995, -1.19995) }, new List<Point> { new Point(-0.25995, 0.89995), new Point(0.25995, -0.89995) }, new List<Point> { new Point(-1.19995, 0.19995), new Point(0.19995, 1.19995) } };
  360. //fillAndSignContentViewModel.SetStamp();
  361. //changeData[AnnotArgsType.AnnotCircle] = tag;
  362. }
  363. break;
  364. }
  365. //if (isFromToolsBtn == false)
  366. // PropertyPanel.AnnotTypeChangedInvoke(this, changeData);
  367. }
  368. private string UPDateShapeType(string tag)
  369. {
  370. switch (tag)
  371. {
  372. case "DotShape":
  373. return "Dot";
  374. case "LineShape":
  375. return "Line";
  376. case "RectShape":
  377. return "Rectangle";
  378. case "ForkShape":
  379. return "Fork";
  380. case "HookShape":
  381. return "Hook";
  382. default:
  383. return "General Properties";
  384. }
  385. }
  386. private void InitShapesType(string tag)
  387. {
  388. ShapeType = UPDateShapeType(tag);
  389. fillAndSignContentViewModel.LineWidthMultiple = 1;
  390. switch (tag)
  391. {
  392. case "HookShape":
  393. var hookShape = new PathGeometry();
  394. hookShape.AddGeometry(Geometry.Parse("M0.599976 7.0286L5.57775 11.8L13.4 1.40002"));
  395. DataPath = hookShape;
  396. break;
  397. case "ForkShape":
  398. var forkShape = new PathGeometry();
  399. forkShape.AddGeometry(Geometry.Parse("M3.19995 3.20001L12.8 12.8 M12.8 3.20001L3.20005 12.8"));
  400. DataPath = forkShape;
  401. break;
  402. case "RectShape":
  403. {
  404. RectangleGeometry rectPath = new RectangleGeometry();
  405. rectPath.Rect = new Rect(0, 5, 28, 22);
  406. DataPath = rectPath;
  407. }
  408. break;
  409. case "LineShape":
  410. {
  411. var lineShape = new PathGeometry();
  412. lineShape.AddGeometry(Geometry.Parse(" M0,10L20,10"));
  413. DataPath = lineShape;
  414. }
  415. break;
  416. case "DotShape":
  417. {
  418. //fillAndSignContentViewModel.LineWidthMultiple = 5;
  419. EllipseGeometry circlePath = new EllipseGeometry();
  420. circlePath.RadiusX = 2.4;
  421. circlePath.RadiusY = 2.4;
  422. circlePath.Center = new Point(2.4, 2.4);
  423. DataPath = circlePath;
  424. }
  425. break;
  426. }
  427. //if (isFromToolsBtn == false)
  428. // PropertyPanel.AnnotTypeChangedInvoke(this, changeData);
  429. }
  430. private void SelectedThick_Command(object obj)
  431. {
  432. if (obj is double)
  433. {
  434. var tran = (double)obj;
  435. //BorderOpacity = tran;
  436. SelectColor.Opacity = tran;
  437. //AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, tran);
  438. //AnnotEvent?.UpdateAnnot();
  439. }
  440. }
  441. private void ThicknessChanged_Command(object obj)
  442. {
  443. if (obj != null)
  444. {
  445. var item = (ComboBoxItem)obj;
  446. var content = (string)item.Content;
  447. if (content != null)
  448. {
  449. var intData = int.Parse(content);
  450. LineWidth = intData;
  451. UPDataLineWidth();
  452. }
  453. }
  454. }
  455. private void UPDataLineWidth()
  456. {
  457. if (!fillAndSignContentViewModel.isFirst)
  458. {
  459. fillAndSignContentViewModel.LineWidth = LineWidth;
  460. //if (FillAndSignContentViewModel.IsEdit)
  461. {
  462. if (!fillAndSignContentViewModel.IsClickNull)
  463. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, LineWidth * lineWidthMultiple);
  464. }
  465. // else
  466. {
  467. if (IsFillAndSign) { fillAndSignContentViewModel.SetStamp(); }
  468. }
  469. }
  470. }
  471. private void UPDataColor()
  472. {
  473. if (!fillAndSignContentViewModel.isFirst)
  474. {
  475. var newColor = (ShapeColorColor as SolidColorBrush).Color;
  476. var oldColor = (SelectColor as SolidColorBrush).Color;
  477. if (newColor.A != oldColor.A || newColor.B != oldColor.B || newColor.R != oldColor.R || newColor.G != oldColor.G)
  478. {
  479. ShapeColorColor = SelectColor;
  480. fillAndSignContentViewModel.SelectColor = SelectColor;
  481. //if (FillAndSignContentViewModel.IsEdit)
  482. {
  483. // PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, LineWidth * lineWidthMultiple);
  484. if (!fillAndSignContentViewModel.IsClickNull)
  485. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Color, (selectColor as SolidColorBrush).Color);
  486. }
  487. //else
  488. {
  489. if (IsFillAndSign) { fillAndSignContentViewModel.SetStamp(); }
  490. }
  491. }
  492. }
  493. }
  494. private void UPDataOpacity()
  495. {
  496. if (!fillAndSignContentViewModel.isFirst)
  497. {
  498. fillAndSignContentViewModel.FillOpacity = FillOpacity;
  499. //if (FillAndSignContentViewModel.IsEdit)
  500. {
  501. if (!fillAndSignContentViewModel.IsClickNull)
  502. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, fillOpacity);
  503. }
  504. //else
  505. {
  506. if (IsFillAndSign) { fillAndSignContentViewModel.SetStamp(); }
  507. }
  508. }
  509. }
  510. private void SelectedColor_Command(object obj)
  511. {
  512. if (obj != null)
  513. {
  514. var colorValue = (Color)obj;
  515. if (colorValue != null)
  516. {
  517. SelectColor = new SolidColorBrush(colorValue);
  518. UPDataColor();
  519. SelectColor.Opacity = FillOpacity;
  520. Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
  521. changeData[AnnotArgsType.AnnotFreehand] = obj;
  522. //PropertyPanel.DataChangedInvoke(this, changeData);
  523. }
  524. }
  525. }
  526. private void SelectedLineWitdh_Command(object obj)
  527. {
  528. if (obj != null)
  529. {
  530. double colorValue = (double)obj;
  531. UPDataLineWidth();
  532. }
  533. }
  534. private void SelectedOpacityValue(object obj)
  535. {
  536. if (obj != null)
  537. {
  538. FillOpacity = (double)obj;
  539. SelectColor.Opacity = FillOpacity;
  540. UPDataOpacity();
  541. //AnnotEvent?.UpdateAttrib(AnnotAttrib.Transparency, FillOpacity);
  542. //AnnotEvent?.UpdateAnnot();
  543. Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
  544. changeData[AnnotArgsType.AnnotFreehand] = FillOpacity;
  545. //PropertyPanel.DataChangedInvoke(this, changeData);
  546. }
  547. }
  548. private void BindingPDFViewerHandler()
  549. {
  550. //来自PDFViewer的响应事件
  551. if (fillAndSignContentViewModel.PDFViewer != null)
  552. {
  553. fillAndSignContentViewModel.PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
  554. fillAndSignContentViewModel.PDFViewer.AnnotActiveHandler += PDFViewer_AnnotActiveHandler;
  555. }
  556. }
  557. private void UnBindingPDFViewerHandler()
  558. {
  559. if (fillAndSignContentViewModel.PDFViewer != null)
  560. {
  561. fillAndSignContentViewModel.PDFViewer.AnnotActiveHandler -= PDFViewer_AnnotActiveHandler;
  562. }
  563. }
  564. private void PDFViewer_AnnotActiveHandler(object sender, AnnotAttribEvent e)
  565. {
  566. if (e != null) { }
  567. else
  568. {
  569. if (fillAndSignContentViewModel.PDFViewer.MouseMode == MouseModes.AnnotCreate) { IsSelected = true; }
  570. }
  571. }
  572. public bool IsNavigationTarget(NavigationContext navigationContext)
  573. {
  574. return true;
  575. }
  576. public void OnNavigatedFrom(NavigationContext navigationContext)
  577. {
  578. UnBindingPDFViewerHandler();
  579. }
  580. public void OnNavigatedTo(NavigationContext navigationContext)
  581. {
  582. string shape = "";
  583. navigationContext.Parameters.TryGetValue<AnnotTransfer>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
  584. navigationContext.Parameters.TryGetValue<FillAndSignContentViewModel>("FillAndSignContentViewModel", out fillAndSignContentViewModel);
  585. navigationContext.Parameters.TryGetValue<string>("Shape", out shape);
  586. bool isFillAndSign = false;
  587. navigationContext.Parameters.TryGetValue<bool>("IsFillAndSign", out isFillAndSign);
  588. IsFillAndSign = isFillAndSign;
  589. InitShapesType(shape);
  590. //FillAndSignContentViewModel.IsEdit = false;
  591. if (PropertyPanel != null)
  592. {
  593. AnnotEvent = PropertyPanel.AnnotEvent;
  594. Annot = PropertyPanel.annot;
  595. var stampAnnotArgs = Annot as StampAnnotArgs;
  596. if (PropertyPanel.annotlists != null && PropertyPanel.annotlists.Count > 1)
  597. {
  598. IsMultiSelected = true;
  599. }
  600. else
  601. {
  602. IsMultiSelected = false;
  603. }
  604. IsSelected = !FillAndSignContentViewModel.IsEdit;
  605. InitFillAndSignProperty();
  606. if (IsMultiSelected)
  607. {
  608. ShapeColorColor = new SolidColorBrush(Colors.Transparent);
  609. }
  610. else
  611. {
  612. GetAnnotProperty(shape);
  613. }
  614. BindingPDFViewerHandler();
  615. }
  616. }
  617. private void GetAnnotProperty(string shape)
  618. {
  619. if (Annot is FreehandAnnotArgs)
  620. {
  621. var annot = Annot as FreehandAnnotArgs;
  622. if (annot != null)
  623. {
  624. try
  625. {
  626. foreach (var point in fillAndSignContentViewModel.viewContentViewModel.FillAndSign)
  627. {
  628. if (annot.PageIndex == point.PageIndex && annot.AnnotIndex == point.AnnotIndex)
  629. {
  630. lineWidthMultiple = 1;
  631. if (point.Shape == "DotShape")
  632. {
  633. lineWidthMultiple = 5;
  634. LineWidth = annot.LineWidth / 5;
  635. }
  636. else { LineWidth = annot.LineWidth; }
  637. SelectColor = new SolidColorBrush(annot.InkColor);
  638. FillOpacity = annot.Transparency;
  639. InitShapesType(point.Shape);
  640. Shape = point.Shape;
  641. }
  642. }
  643. }
  644. catch
  645. {
  646. }
  647. }
  648. }
  649. }
  650. }
  651. }