DefaultSettingParam.cs 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972
  1. using ComPDFKit.Measure;
  2. using ComPDFKit.PDFAnnotation;
  3. using ComPDFKitViewer.Helper;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Globalization;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Documents;
  12. using System.Windows.Media;
  13. namespace ComPDFKit.Tool.SettingParam
  14. {
  15. public class DefaultSettingParam
  16. {
  17. public bool IsShowLink = false;
  18. public bool IsShowWidget = false;
  19. #region Measure
  20. public bool IsOpenMeasure { get; set; } = false;
  21. public bool IsCreateSquarePolygonMeasure = false;
  22. private LineMeasureParam lineMeasureParamDef;
  23. public LineMeasureParam LineMeasureParamDef
  24. {
  25. get
  26. {
  27. LineMeasureParam Param = new LineMeasureParam();
  28. if (lineMeasureParamDef.CopyTo(Param))
  29. {
  30. return Param;
  31. }
  32. return null;
  33. }
  34. private set
  35. {
  36. value.CopyTo(lineMeasureParamDef);
  37. }
  38. }
  39. private PolyLineMeasureParam polyLineMeasureParamDef;
  40. public PolyLineMeasureParam PolyLineMeasureParamDef
  41. {
  42. get
  43. {
  44. PolyLineMeasureParam Param = new PolyLineMeasureParam();
  45. if (polyLineMeasureParamDef.CopyTo(Param))
  46. {
  47. return Param;
  48. }
  49. return null;
  50. }
  51. private set
  52. {
  53. value.CopyTo(polyLineMeasureParamDef);
  54. }
  55. }
  56. private PolygonMeasureParam polygonMeasureParamDef;
  57. public PolygonMeasureParam PolygonMeasureParamDef
  58. {
  59. get
  60. {
  61. PolygonMeasureParam Param = new PolygonMeasureParam();
  62. if (polygonMeasureParamDef.CopyTo(Param))
  63. {
  64. return Param;
  65. }
  66. return null;
  67. }
  68. private set
  69. {
  70. value.CopyTo(polygonMeasureParamDef);
  71. }
  72. }
  73. private void InitLineMeasure()
  74. {
  75. lineMeasureParamDef = new LineMeasureParam();
  76. lineMeasureParamDef.measureInfo = new CPDFMeasureInfo
  77. {
  78. Unit = CPDFMeasure.CPDF_CM,
  79. Precision = CPDFMeasure.PRECISION_VALUE_TWO,
  80. RulerBase = 1,
  81. RulerBaseUnit = CPDFMeasure.CPDF_CM,
  82. RulerTranslate = 1,
  83. RulerTranslateUnit = CPDFMeasure.CPDF_CM,
  84. CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH,
  85. };
  86. }
  87. private void InitPolyLineMeasure()
  88. {
  89. polyLineMeasureParamDef = new PolyLineMeasureParam();
  90. polyLineMeasureParamDef.measureInfo = new CPDFMeasureInfo
  91. {
  92. Unit = CPDFMeasure.CPDF_CM,
  93. Precision = CPDFMeasure.PRECISION_VALUE_TWO,
  94. RulerBase = 1,
  95. RulerBaseUnit = CPDFMeasure.CPDF_CM,
  96. RulerTranslate = 1,
  97. RulerTranslateUnit = CPDFMeasure.CPDF_CM,
  98. CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH,
  99. };
  100. }
  101. private void InitPolygonMeasure()
  102. {
  103. polygonMeasureParamDef = new PolygonMeasureParam();
  104. polygonMeasureParamDef.measureInfo = new CPDFMeasureInfo
  105. {
  106. Unit = CPDFMeasure.CPDF_CM,
  107. Precision = CPDFMeasure.PRECISION_VALUE_TWO,
  108. RulerBase = 1,
  109. RulerBaseUnit = CPDFMeasure.CPDF_CM,
  110. RulerTranslate = 1,
  111. RulerTranslateUnit = CPDFMeasure.CPDF_CM,
  112. CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH | CPDFCaptionType.CPDF_CAPTION_AREA,
  113. };
  114. }
  115. #endregion
  116. #region Annot
  117. private CircleParam circleParamDef;
  118. public CircleParam CircleParamDef
  119. {
  120. get
  121. {
  122. CircleParam Param = new CircleParam();
  123. if (circleParamDef.CopyTo(Param))
  124. {
  125. return Param;
  126. }
  127. return null;
  128. }
  129. private set
  130. {
  131. value.CopyTo(circleParamDef);
  132. }
  133. }
  134. private FreeTextParam freeTextParamDef;
  135. public FreeTextParam FreeTextParamDef
  136. {
  137. get
  138. {
  139. FreeTextParam Param = new FreeTextParam();
  140. if (freeTextParamDef.CopyTo(Param))
  141. {
  142. return Param;
  143. }
  144. return null;
  145. }
  146. private set
  147. {
  148. value.CopyTo(freeTextParamDef);
  149. }
  150. }
  151. private HighlightParam highlightParamDef;
  152. public HighlightParam HighlightParamDef
  153. {
  154. get
  155. {
  156. HighlightParam Param = new HighlightParam();
  157. if (highlightParamDef.CopyTo(Param))
  158. {
  159. return Param;
  160. }
  161. return null;
  162. }
  163. private set
  164. {
  165. value.CopyTo(highlightParamDef);
  166. }
  167. }
  168. private InkParam inkParamDef;
  169. public InkParam InkParamDef
  170. {
  171. get
  172. {
  173. InkParam Param = new InkParam();
  174. if (inkParamDef.CopyTo(Param))
  175. {
  176. return Param;
  177. }
  178. return null;
  179. }
  180. private set
  181. {
  182. value.CopyTo(inkParamDef);
  183. }
  184. }
  185. private LineParam lineParamDef;
  186. public LineParam LineParamDef
  187. {
  188. get
  189. {
  190. LineParam Param = new LineParam();
  191. if (lineParamDef.CopyTo(Param))
  192. {
  193. return Param;
  194. }
  195. return null;
  196. }
  197. private set
  198. {
  199. value.CopyTo(lineParamDef);
  200. }
  201. }
  202. private LinkParam linkParamDef;
  203. public LinkParam LinkParamDef
  204. {
  205. get
  206. {
  207. LinkParam Param = new LinkParam();
  208. if (linkParamDef.CopyTo(Param))
  209. {
  210. return Param;
  211. }
  212. return null;
  213. }
  214. private set
  215. {
  216. value.CopyTo(linkParamDef);
  217. }
  218. }
  219. private RedactParam redactParamDef;
  220. public RedactParam RedactParamDef
  221. {
  222. get
  223. {
  224. RedactParam Param = new RedactParam();
  225. if (redactParamDef.CopyTo(Param))
  226. {
  227. return Param;
  228. }
  229. return null;
  230. }
  231. private set
  232. {
  233. value.CopyTo(redactParamDef);
  234. }
  235. }
  236. private SquareParam squareParamDef;
  237. public SquareParam SquareParamDef
  238. {
  239. get
  240. {
  241. SquareParam Param = new SquareParam();
  242. if (squareParamDef.CopyTo(Param))
  243. {
  244. return Param;
  245. }
  246. return null;
  247. }
  248. private set
  249. {
  250. value.CopyTo(squareParamDef);
  251. }
  252. }
  253. private SquigglyParam squigglyParamDef;
  254. public SquigglyParam SquigglyParamDef
  255. {
  256. get
  257. {
  258. SquigglyParam Param = new SquigglyParam();
  259. if (squigglyParamDef.CopyTo(Param))
  260. {
  261. return Param;
  262. }
  263. return null;
  264. }
  265. private set
  266. {
  267. value.CopyTo(squigglyParamDef);
  268. }
  269. }
  270. private StampParam stampParamDef;
  271. public StampParam StampParamDef
  272. {
  273. get
  274. {
  275. StampParam Param = new StampParam();
  276. if (stampParamDef.CopyTo(Param))
  277. {
  278. return Param;
  279. }
  280. return null;
  281. }
  282. private set
  283. {
  284. value.CopyTo(stampParamDef);
  285. }
  286. }
  287. private StickyNoteParam stickyNoteParamDef;
  288. public StickyNoteParam StickyNoteParamDef
  289. {
  290. get
  291. {
  292. StickyNoteParam Param = new StickyNoteParam();
  293. if (stickyNoteParamDef.CopyTo(Param))
  294. {
  295. return Param;
  296. }
  297. return null;
  298. }
  299. private set
  300. {
  301. value.CopyTo(stickyNoteParamDef);
  302. }
  303. }
  304. private StrikeoutParam strikeoutParamDef;
  305. public StrikeoutParam StrikeoutParamDef
  306. {
  307. get
  308. {
  309. StrikeoutParam Param = new StrikeoutParam();
  310. if (strikeoutParamDef.CopyTo(Param))
  311. {
  312. return Param;
  313. }
  314. return null;
  315. }
  316. private set
  317. {
  318. value.CopyTo(strikeoutParamDef);
  319. }
  320. }
  321. private UnderlineParam underlineParamDef;
  322. public UnderlineParam UnderlineParamDef
  323. {
  324. get
  325. {
  326. UnderlineParam Param = new UnderlineParam();
  327. if (underlineParamDef.CopyTo(Param))
  328. {
  329. return Param;
  330. }
  331. return null;
  332. }
  333. private set
  334. {
  335. value.CopyTo(underlineParamDef);
  336. }
  337. }
  338. private SoundParam soundParamDef;
  339. public SoundParam SoundParamDef
  340. {
  341. get
  342. {
  343. SoundParam Param = new SoundParam();
  344. if (soundParamDef.CopyTo(Param))
  345. {
  346. return Param;
  347. }
  348. return null;
  349. }
  350. private set
  351. {
  352. value.CopyTo(soundParamDef);
  353. }
  354. }
  355. private void InitUnderline()
  356. {
  357. underlineParamDef = new UnderlineParam();
  358. }
  359. private void InitStrikeout()
  360. {
  361. strikeoutParamDef = new StrikeoutParam();
  362. }
  363. private void InitStamp()
  364. {
  365. stampParamDef = new StampParam();
  366. }
  367. private void InitSquiggly()
  368. {
  369. squigglyParamDef = new SquigglyParam();
  370. }
  371. private void InitSquare()
  372. {
  373. squareParamDef = new SquareParam();
  374. }
  375. private void InitRedact()
  376. {
  377. redactParamDef = new RedactParam();
  378. }
  379. private void InitLink()
  380. {
  381. linkParamDef = new LinkParam();
  382. }
  383. private void InitLine()
  384. {
  385. lineParamDef = new LineParam();
  386. }
  387. private void InitInk()
  388. {
  389. inkParamDef = new InkParam();
  390. }
  391. private void Inithighlight()
  392. {
  393. highlightParamDef = new HighlightParam();
  394. }
  395. private void InitFreeText()
  396. {
  397. freeTextParamDef = new FreeTextParam();
  398. freeTextParamDef.Alignment = C_TEXT_ALIGNMENT.ALIGNMENT_LEFT;
  399. freeTextParamDef.Transparency = 255;
  400. byte[] lineColor = { 255, 0, 0 };
  401. freeTextParamDef.LineColor = lineColor;
  402. freeTextParamDef.LineWidth = 1;
  403. freeTextParamDef.FontName = "Arial";
  404. byte[] fontColor = { 255, 0, 0 };
  405. freeTextParamDef.FontColor = fontColor;
  406. freeTextParamDef.FontSize = 14;
  407. }
  408. private void InitCircle()
  409. {
  410. circleParamDef = new CircleParam();
  411. }
  412. private void InitStickyNote()
  413. {
  414. stickyNoteParamDef = new StickyNoteParam();
  415. stickyNoteParamDef.Transparency = 255;
  416. stickyNoteParamDef.StickyNoteColor = new byte[3] { 255, 0, 0 };
  417. }
  418. private void InitSound()
  419. {
  420. soundParamDef = new SoundParam();
  421. }
  422. #endregion
  423. #region Widget
  424. private CheckBoxParam checkBoxParamDef;
  425. public CheckBoxParam CheckBoxParamDef
  426. {
  427. get
  428. {
  429. CheckBoxParam Param = new CheckBoxParam();
  430. if (checkBoxParamDef.CopyTo(Param))
  431. {
  432. return Param;
  433. }
  434. return null;
  435. }
  436. private set
  437. {
  438. value.CopyTo(checkBoxParamDef);
  439. }
  440. }
  441. private ComboBoxParam comboBoxParamDef;
  442. public ComboBoxParam ComboBoxParamDef
  443. {
  444. get
  445. {
  446. ComboBoxParam Param = new ComboBoxParam();
  447. if (comboBoxParamDef.CopyTo(Param))
  448. {
  449. return Param;
  450. }
  451. return null;
  452. }
  453. private set
  454. {
  455. value.CopyTo(comboBoxParamDef);
  456. }
  457. }
  458. private ListBoxParam listBoxParamDef;
  459. public ListBoxParam ListBoxParamDef
  460. {
  461. get
  462. {
  463. ListBoxParam Param = new ListBoxParam();
  464. if (listBoxParamDef.CopyTo(Param))
  465. {
  466. return Param;
  467. }
  468. return null;
  469. }
  470. private set
  471. {
  472. value.CopyTo(listBoxParamDef);
  473. }
  474. }
  475. private PushButtonParam pushButtonParamDef;
  476. public PushButtonParam PushButtonParamDef
  477. {
  478. get
  479. {
  480. PushButtonParam Param = new PushButtonParam();
  481. if (pushButtonParamDef.CopyTo(Param))
  482. {
  483. return Param;
  484. }
  485. return null;
  486. }
  487. private set
  488. {
  489. value.CopyTo(pushButtonParamDef);
  490. }
  491. }
  492. private RadioButtonParam radioButtonParamDef;
  493. public RadioButtonParam RadioButtonParamDef
  494. {
  495. get
  496. {
  497. RadioButtonParam Param = new RadioButtonParam();
  498. if (radioButtonParamDef.CopyTo(Param))
  499. {
  500. return Param;
  501. }
  502. return null;
  503. }
  504. private set
  505. {
  506. value.CopyTo(radioButtonParamDef);
  507. }
  508. }
  509. private SignatureParam signatureParamDef;
  510. public SignatureParam SignatureParamDef
  511. {
  512. get
  513. {
  514. SignatureParam Param = new SignatureParam();
  515. if (signatureParamDef.CopyTo(Param))
  516. {
  517. return Param;
  518. }
  519. return null;
  520. }
  521. private set
  522. {
  523. value.CopyTo(signatureParamDef);
  524. }
  525. }
  526. private TextBoxParam textBoxParamDef;
  527. public TextBoxParam TextBoxParamDef
  528. {
  529. get
  530. {
  531. TextBoxParam Param = new TextBoxParam();
  532. if (textBoxParamDef.CopyTo(Param))
  533. {
  534. return Param;
  535. }
  536. return null;
  537. }
  538. private set
  539. {
  540. value.CopyTo(textBoxParamDef);
  541. }
  542. }
  543. private void InitCheckBox()
  544. {
  545. checkBoxParamDef = new CheckBoxParam();
  546. }
  547. private void InitComboBox()
  548. {
  549. comboBoxParamDef = new ComboBoxParam();
  550. }
  551. private void InitListBox()
  552. {
  553. listBoxParamDef = new ListBoxParam();
  554. }
  555. private void InitPushButton()
  556. {
  557. pushButtonParamDef = new PushButtonParam();
  558. }
  559. private void InitRadioButton()
  560. {
  561. radioButtonParamDef = new RadioButtonParam();
  562. }
  563. private void InitSignature()
  564. {
  565. signatureParamDef = new SignatureParam();
  566. }
  567. private void InitTextBox()
  568. {
  569. textBoxParamDef = new TextBoxParam();
  570. }
  571. #endregion
  572. #region PDFEdit
  573. private ImageEditParam imageEditParamDef;
  574. public ImageEditParam ImageEditParamDef
  575. {
  576. get
  577. {
  578. ImageEditParam Param = new ImageEditParam();
  579. if (imageEditParamDef.CopyTo(Param))
  580. {
  581. return Param;
  582. }
  583. return null;
  584. }
  585. private set
  586. {
  587. value.CopyTo(imageEditParamDef);
  588. }
  589. }
  590. private TextEditParam textEditParamDef;
  591. public TextEditParam TextEditParamDef
  592. {
  593. get
  594. {
  595. TextEditParam Param = new TextEditParam();
  596. if (textEditParamDef.CopyTo(Param))
  597. {
  598. return Param;
  599. }
  600. return null;
  601. }
  602. private set
  603. {
  604. value.CopyTo(textEditParamDef);
  605. }
  606. }
  607. private void InitTextEdit()
  608. {
  609. textEditParamDef = new TextEditParam();
  610. }
  611. private void InitImageEdit()
  612. {
  613. imageEditParamDef = new ImageEditParam();
  614. }
  615. #endregion
  616. public DefaultSettingParam()
  617. {
  618. #region Measure
  619. InitLineMeasure();
  620. InitPolyLineMeasure();
  621. InitPolygonMeasure();
  622. #endregion
  623. #region Annot
  624. InitUnderline();
  625. InitStrikeout();
  626. InitStamp();
  627. InitSquiggly();
  628. InitSquare();
  629. InitRedact();
  630. InitLink();
  631. InitLine();
  632. InitInk();
  633. Inithighlight();
  634. InitFreeText();
  635. InitCircle();
  636. InitStickyNote();
  637. InitSound();
  638. #endregion
  639. #region Widget
  640. InitCheckBox();
  641. InitComboBox();
  642. InitListBox();
  643. InitPushButton();
  644. InitRadioButton();
  645. InitSignature();
  646. InitTextBox();
  647. #endregion
  648. #region PDFEdit
  649. InitTextEdit();
  650. InitImageEdit();
  651. #endregion
  652. }
  653. public bool SetAnnotParam(AnnotParam annotParam)
  654. {
  655. bool IsOK = false;
  656. if (annotParam == null)
  657. {
  658. return IsOK;
  659. }
  660. switch (annotParam.CurrentType)
  661. {
  662. case C_ANNOTATION_TYPE.C_ANNOTATION_NONE:
  663. break;
  664. case C_ANNOTATION_TYPE.C_ANNOTATION_UNKOWN:
  665. break;
  666. case C_ANNOTATION_TYPE.C_ANNOTATION_TEXT:
  667. if (annotParam is StickyNoteParam)
  668. {
  669. StickyNoteParamDef = annotParam as StickyNoteParam;
  670. IsOK = true;
  671. }
  672. break;
  673. case C_ANNOTATION_TYPE.C_ANNOTATION_LINK:
  674. if (annotParam is LinkParam)
  675. {
  676. LinkParamDef = annotParam as LinkParam;
  677. IsOK = true;
  678. }
  679. break;
  680. case C_ANNOTATION_TYPE.C_ANNOTATION_FREETEXT:
  681. if (annotParam is FreeTextParam)
  682. {
  683. FreeTextParamDef = annotParam as FreeTextParam;
  684. IsOK = true;
  685. }
  686. break;
  687. case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
  688. if (annotParam is LineParam)
  689. {
  690. LineParamDef = annotParam as LineParam;
  691. IsOK = true;
  692. }
  693. else if (annotParam is LineMeasureParam)
  694. {
  695. LineMeasureParamDef = annotParam as LineMeasureParam;
  696. IsOK = true;
  697. }
  698. break;
  699. case C_ANNOTATION_TYPE.C_ANNOTATION_SQUARE:
  700. if (annotParam is SquareParam)
  701. {
  702. SquareParamDef = annotParam as SquareParam;
  703. IsOK = true;
  704. }
  705. break;
  706. case C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE:
  707. if (annotParam is CircleParam)
  708. {
  709. CircleParamDef = annotParam as CircleParam;
  710. IsOK = true;
  711. }
  712. break;
  713. case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
  714. if (annotParam is PolygonMeasureParam)
  715. {
  716. PolygonMeasureParamDef = annotParam as PolygonMeasureParam;
  717. IsOK = true;
  718. }
  719. break;
  720. case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
  721. if (annotParam is PolyLineMeasureParam)
  722. {
  723. PolyLineMeasureParamDef = annotParam as PolyLineMeasureParam;
  724. IsOK = true;
  725. }
  726. break;
  727. case C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT:
  728. if (annotParam is HighlightParam)
  729. {
  730. HighlightParamDef = annotParam as HighlightParam;
  731. IsOK = true;
  732. }
  733. break;
  734. case C_ANNOTATION_TYPE.C_ANNOTATION_UNDERLINE:
  735. if (annotParam is UnderlineParam)
  736. {
  737. UnderlineParamDef = annotParam as UnderlineParam;
  738. IsOK = true;
  739. }
  740. break;
  741. case C_ANNOTATION_TYPE.C_ANNOTATION_SQUIGGLY:
  742. if (annotParam is SquigglyParam)
  743. {
  744. SquigglyParamDef = annotParam as SquigglyParam;
  745. IsOK = true;
  746. }
  747. break;
  748. case C_ANNOTATION_TYPE.C_ANNOTATION_STRIKEOUT:
  749. if (annotParam is StrikeoutParam)
  750. {
  751. StrikeoutParamDef = annotParam as StrikeoutParam;
  752. IsOK = true;
  753. }
  754. break;
  755. case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
  756. if (annotParam is StampParam)
  757. {
  758. StampParamDef = annotParam as StampParam;
  759. IsOK = true;
  760. }
  761. break;
  762. case C_ANNOTATION_TYPE.C_ANNOTATION_CARET:
  763. break;
  764. case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
  765. if (annotParam is InkParam)
  766. {
  767. InkParamDef = annotParam as InkParam;
  768. IsOK = true;
  769. }
  770. break;
  771. case C_ANNOTATION_TYPE.C_ANNOTATION_POPUP:
  772. break;
  773. case C_ANNOTATION_TYPE.C_ANNOTATION_FILEATTACHMENT:
  774. break;
  775. case C_ANNOTATION_TYPE.C_ANNOTATION_SOUND:
  776. if (annotParam is SoundParam)
  777. {
  778. SoundParamDef = annotParam as SoundParam;
  779. IsOK = true;
  780. }
  781. break;
  782. case C_ANNOTATION_TYPE.C_ANNOTATION_MOVIE:
  783. break;
  784. case C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET:
  785. if (annotParam is WidgetParm)
  786. {
  787. IsOK = SetWidgetParam(annotParam as WidgetParm);
  788. }
  789. break;
  790. case C_ANNOTATION_TYPE.C_ANNOTATION_SCREEN:
  791. break;
  792. case C_ANNOTATION_TYPE.C_ANNOTATION_PRINTERMARK:
  793. break;
  794. case C_ANNOTATION_TYPE.C_ANNOTATION_TRAPNET:
  795. break;
  796. case C_ANNOTATION_TYPE.C_ANNOTATION_WATERMARK:
  797. break;
  798. case C_ANNOTATION_TYPE.C_ANNOTATION_3D:
  799. break;
  800. case C_ANNOTATION_TYPE.C_ANNOTATION_RICHMEDIA:
  801. break;
  802. case C_ANNOTATION_TYPE.C_ANNOTATION_REDACT:
  803. if (annotParam is RedactParam)
  804. {
  805. RedactParamDef = annotParam as RedactParam;
  806. IsOK = true;
  807. }
  808. break;
  809. case C_ANNOTATION_TYPE.C_ANNOTATION_INTERCHANGE:
  810. break;
  811. default:
  812. break;
  813. }
  814. return IsOK;
  815. }
  816. private bool SetWidgetParam(WidgetParm formParm)
  817. {
  818. bool IsOK = false;
  819. if (formParm == null)
  820. {
  821. return IsOK;
  822. }
  823. switch (formParm.WidgetType)
  824. {
  825. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_NONE:
  826. break;
  827. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
  828. if (formParm is PushButtonParam)
  829. {
  830. PushButtonParamDef = formParm as PushButtonParam;
  831. IsOK = true;
  832. }
  833. break;
  834. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_CHECKBOX:
  835. if (formParm is CheckBoxParam)
  836. {
  837. CheckBoxParamDef = formParm as CheckBoxParam;
  838. IsOK = true;
  839. }
  840. break;
  841. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
  842. if (formParm is RadioButtonParam)
  843. {
  844. RadioButtonParamDef = formParm as RadioButtonParam;
  845. IsOK = true;
  846. }
  847. break;
  848. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_TEXTFIELD:
  849. if (formParm is TextBoxParam)
  850. {
  851. TextBoxParamDef = formParm as TextBoxParam;
  852. IsOK = true;
  853. }
  854. break;
  855. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_COMBOBOX:
  856. if (formParm is ComboBoxParam)
  857. {
  858. ComboBoxParamDef = formParm as ComboBoxParam;
  859. IsOK = true;
  860. }
  861. break;
  862. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_LISTBOX:
  863. if (formParm is ListBoxParam)
  864. {
  865. ListBoxParamDef = formParm as ListBoxParam;
  866. IsOK = true;
  867. }
  868. break;
  869. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS:
  870. if (formParm is SignatureParam)
  871. {
  872. SignatureParamDef = formParm as SignatureParam;
  873. IsOK = true;
  874. }
  875. break;
  876. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_UNKNOWN:
  877. break;
  878. default:
  879. break;
  880. }
  881. return IsOK;
  882. }
  883. public bool SetPDFEditParamm(PDFEditParam editParam)
  884. {
  885. switch (editParam.EditType)
  886. {
  887. case PDFPage.CPDFEditType.EditText:
  888. if (editParam is TextEditParam)
  889. {
  890. TextEditParamDef = editParam as TextEditParam;
  891. return true;
  892. }
  893. break;
  894. default:
  895. break;
  896. }
  897. return false;
  898. }
  899. }
  900. public class DefaultDrawParam
  901. {
  902. #region ShowAnnot
  903. private SolidColorBrush showLinkBrush;
  904. public SolidColorBrush ShowLinkBrush
  905. {
  906. get { return showLinkBrush.Clone(); }
  907. set { showLinkBrush = value; }
  908. }
  909. private Pen showLinkePen;
  910. public Pen ShowLinkePen
  911. {
  912. get { return showLinkePen.Clone(); }
  913. set { showLinkePen = value; }
  914. }
  915. #endregion
  916. #region AnnotSelectedRect
  917. private SolidColorBrush annotMoveBrush;
  918. public SolidColorBrush AnnotMoveBrush
  919. {
  920. get { return annotMoveBrush.Clone(); }
  921. set { annotMoveBrush = value; }
  922. }
  923. private Pen annotMovePen;
  924. public Pen AnnotMovePen
  925. {
  926. get { return annotMovePen.Clone(); }
  927. set { annotMovePen = value; }
  928. }
  929. private SolidColorBrush annotRectFillBrush;
  930. public SolidColorBrush AnnotRectFillBrush
  931. {
  932. get { return annotRectFillBrush.Clone(); }
  933. set { annotRectFillBrush = value; }
  934. }
  935. private Pen annotRectLinePen;
  936. public Pen AnnotRectLinePen
  937. {
  938. get { return annotRectLinePen.Clone(); }
  939. set { annotRectLinePen = value; }
  940. }
  941. private Pen annotRectHoverPen;
  942. public Pen AnnotRectHoverPen
  943. {
  944. get { return annotRectHoverPen.Clone(); }
  945. set { annotRectHoverPen = value; }
  946. }
  947. private Pen annotPointPen;
  948. public Pen AnnotPointPen
  949. {
  950. get { return annotPointPen.Clone(); }
  951. set { annotPointPen = value; }
  952. }
  953. private SolidColorBrush annotPointBorderBrush;
  954. public SolidColorBrush AnnotPointBorderBrush
  955. {
  956. get { return annotPointBorderBrush.Clone(); }
  957. set { annotPointBorderBrush = value; }
  958. }
  959. #endregion
  960. #region PDFEdit
  961. private SolidColorBrush caretBrush;
  962. public SolidColorBrush CaretBrush
  963. {
  964. get { return caretBrush.Clone(); }
  965. set { caretBrush = value; }
  966. }
  967. private Pen caretPen;
  968. public Pen CaretPen
  969. {
  970. get { return caretPen.Clone(); }
  971. set { caretPen = value; }
  972. }
  973. private SolidColorBrush pDFEditMoveBrush;
  974. public SolidColorBrush PDFEditMoveBrush
  975. {
  976. get { return pDFEditMoveBrush.Clone(); }
  977. set { pDFEditMoveBrush = value; }
  978. }
  979. private Pen pDFEditMovePen;
  980. public Pen PDFEditMovePen
  981. {
  982. get { return pDFEditMovePen.Clone(); }
  983. set { pDFEditMovePen = value; }
  984. }
  985. private Pen pDFEditMoveRectPen;
  986. public Pen PDFEditMoveRectPen
  987. {
  988. get { return pDFEditMoveRectPen.Clone(); }
  989. set { pDFEditMoveRectPen = value; }
  990. }
  991. #region Not selected state
  992. private SolidColorBrush pDFEditRectFillBrush;
  993. public SolidColorBrush PDFEditRectFillBrush
  994. {
  995. get { return pDFEditRectFillBrush.Clone(); }
  996. set { pDFEditRectFillBrush = value; }
  997. }
  998. private Pen pDFEditRectLinePen;
  999. public Pen PDFEditRectLinePen
  1000. {
  1001. get { return pDFEditRectLinePen.Clone(); }
  1002. set { pDFEditRectLinePen = value; }
  1003. }
  1004. private Pen pDFEditPointPen;
  1005. public Pen PDFEditPointPen
  1006. {
  1007. get { return pDFEditPointPen.Clone(); }
  1008. set { pDFEditPointPen = value; }
  1009. }
  1010. private SolidColorBrush pDFEditPointBorderBrush;
  1011. public SolidColorBrush PDFEditPointBorderBrush
  1012. {
  1013. get { return pDFEditPointBorderBrush.Clone(); }
  1014. set { pDFEditPointBorderBrush = value; }
  1015. }
  1016. #endregion
  1017. #region Selected state
  1018. private SolidColorBrush sPDFEditRectFillBrush;
  1019. public SolidColorBrush SPDFEditRectFillBrush
  1020. {
  1021. get { return sPDFEditRectFillBrush.Clone(); }
  1022. set { sPDFEditRectFillBrush = value; }
  1023. }
  1024. private Pen sPDFEditRectLinePen;
  1025. public Pen SPDFEditRectLinePen
  1026. {
  1027. get { return sPDFEditRectLinePen.Clone(); }
  1028. set { sPDFEditRectLinePen = value; }
  1029. }
  1030. private Pen sPDFEditPointPen;
  1031. public Pen SPDFEditPointPen
  1032. {
  1033. get { return sPDFEditPointPen.Clone(); }
  1034. set { sPDFEditPointPen = value; }
  1035. }
  1036. private SolidColorBrush sPDFEditPointBorderBrush;
  1037. public SolidColorBrush SPDFEditPointBorderBrush
  1038. {
  1039. get { return sPDFEditPointBorderBrush.Clone(); }
  1040. set { sPDFEditPointBorderBrush = value; }
  1041. }
  1042. private SolidColorBrush sPDFEditCropBorderBrush;
  1043. public SolidColorBrush SPDFEditCropBorderBrush
  1044. {
  1045. get { return sPDFEditCropBorderBrush.Clone(); }
  1046. set { sPDFEditCropBorderBrush = value; }
  1047. }
  1048. #endregion
  1049. #region Hover state
  1050. private SolidColorBrush pDFEditRectFillHoverBrush;
  1051. public SolidColorBrush PDFEditRectFillHoverBrush
  1052. {
  1053. get { return pDFEditRectFillHoverBrush.Clone(); }
  1054. set { pDFEditRectFillHoverBrush = value; }
  1055. }
  1056. private Pen pDFEditRectLineHoverPen;
  1057. public Pen PDFEditRectLineHoverPen
  1058. {
  1059. get { return pDFEditRectLineHoverPen.Clone(); }
  1060. set { pDFEditRectLineHoverPen = value; }
  1061. }
  1062. private Pen pDFEditPointHoverPen;
  1063. public Pen PDFEditPointHoverPen
  1064. {
  1065. get { return pDFEditPointHoverPen.Clone(); }
  1066. set { pDFEditPointHoverPen = value; }
  1067. }
  1068. private SolidColorBrush pDFEditPointBorderHoverBrush;
  1069. public SolidColorBrush PDFEditPointBorderHoverBrush
  1070. {
  1071. get { return pDFEditPointBorderHoverBrush.Clone(); }
  1072. set { pDFEditPointBorderHoverBrush = value; }
  1073. }
  1074. #endregion
  1075. #endregion
  1076. #region AnnotEdit
  1077. private SolidColorBrush editControlLineBrush;
  1078. public SolidColorBrush EditControlLineBrush
  1079. {
  1080. get { return editControlLineBrush.Clone(); }
  1081. set { editControlLineBrush = value; }
  1082. }
  1083. private Pen editControlLinePen;
  1084. public Pen EditControlLinePen
  1085. {
  1086. get { return editControlLinePen.Clone(); }
  1087. set { editControlLinePen = value; }
  1088. }
  1089. private Pen editLinePen;
  1090. public Pen EditLinePen
  1091. {
  1092. get { return editLinePen.Clone(); }
  1093. set { editLinePen = value; }
  1094. }
  1095. #endregion
  1096. #region AnnotCreate
  1097. private Pen redactPen;
  1098. public Pen RedactPen
  1099. {
  1100. get { return redactPen.Clone(); }
  1101. set { redactPen = value; }
  1102. }
  1103. private Pen linkPen;
  1104. public Pen LinkPen
  1105. {
  1106. get { return linkPen.Clone(); }
  1107. set { linkPen = value; }
  1108. }
  1109. private SolidColorBrush linkBrush;
  1110. public SolidColorBrush LinkBrush
  1111. {
  1112. get { return linkBrush.Clone(); }
  1113. set { linkBrush = value; }
  1114. }
  1115. #endregion
  1116. #region WidgetCreate
  1117. private Pen createWidgetPen;
  1118. public Pen CreateWidgetPen
  1119. {
  1120. get { return createWidgetPen.Clone(); }
  1121. set { createWidgetPen = value; }
  1122. }
  1123. #endregion
  1124. #region PDFViewer
  1125. private Pen viewerImagePen;
  1126. public Pen ViewerImagePen
  1127. {
  1128. get { return viewerImagePen.Clone(); }
  1129. set { viewerImagePen = value; }
  1130. }
  1131. private Brush viewerImageBackgroundBrush;
  1132. public Brush ViewerImageBackgroundBrush
  1133. {
  1134. get { return viewerImageBackgroundBrush.Clone(); }
  1135. set { viewerImageBackgroundBrush = value; }
  1136. }
  1137. #endregion
  1138. #region PDFEditMultiSelected
  1139. private SolidColorBrush pDFEditMultiMoveBrush;
  1140. public SolidColorBrush PDFEditMultiMoveBrush
  1141. {
  1142. get { return pDFEditMultiMoveBrush.Clone(); }
  1143. set { pDFEditMultiMoveBrush = value; }
  1144. }
  1145. private Pen pDFEditMultiMovePen;
  1146. public Pen PDFEditMultiMovePen
  1147. {
  1148. get { return pDFEditMultiMovePen.Clone(); }
  1149. set { pDFEditMultiMovePen = value; }
  1150. }
  1151. private Pen pDFEditMultiMoveRectPen;
  1152. public Pen PDFEditMultiMoveRectPen
  1153. {
  1154. get { return pDFEditMultiMoveRectPen.Clone(); }
  1155. set { pDFEditMultiMoveRectPen = value; }
  1156. }
  1157. #region Not selected state
  1158. private SolidColorBrush pDFEditMultiRectFillBrush;
  1159. public SolidColorBrush PDFEditMultiRectFillBrush
  1160. {
  1161. get { return pDFEditMultiRectFillBrush.Clone(); }
  1162. set { pDFEditMultiRectFillBrush = value; }
  1163. }
  1164. private Pen pDFEditMultiRectLinePen;
  1165. public Pen PDFEditMultiRectLinePen
  1166. {
  1167. get { return pDFEditMultiRectLinePen.Clone(); }
  1168. set { pDFEditMultiRectLinePen = value; }
  1169. }
  1170. private Pen pDFEditMultiPointPen;
  1171. public Pen PDFEditMultiPointPen
  1172. {
  1173. get { return pDFEditMultiPointPen.Clone(); }
  1174. set { pDFEditMultiPointPen = value; }
  1175. }
  1176. private SolidColorBrush pDFEditMultiPointBorderBrush;
  1177. public SolidColorBrush PDFEditMultiPointBorderBrush
  1178. {
  1179. get { return pDFEditMultiPointBorderBrush.Clone(); }
  1180. set { pDFEditMultiPointBorderBrush = value; }
  1181. }
  1182. #endregion
  1183. #region Selected state
  1184. private SolidColorBrush sPDFEditMultiRectFillBrush;
  1185. public SolidColorBrush SPDFEditMultiRectFillBrush
  1186. {
  1187. get { return sPDFEditMultiRectFillBrush.Clone(); }
  1188. set { sPDFEditMultiRectFillBrush = value; }
  1189. }
  1190. private Pen sPDFEditMultiRectLinePen;
  1191. public Pen SPDFEditMultiRectLinePen
  1192. {
  1193. get { return sPDFEditMultiRectLinePen.Clone(); }
  1194. set { sPDFEditMultiRectLinePen = value; }
  1195. }
  1196. private Pen sPDFEditMultiPointPen;
  1197. public Pen SPDFEditMultiPointPen
  1198. {
  1199. get { return sPDFEditMultiPointPen.Clone(); }
  1200. set { sPDFEditMultiPointPen = value; }
  1201. }
  1202. private SolidColorBrush sPDFEditMultiPointBorderBrush;
  1203. public SolidColorBrush SPDFEditMultiPointBorderBrush
  1204. {
  1205. get { return sPDFEditMultiPointBorderBrush.Clone(); }
  1206. set { sPDFEditMultiPointBorderBrush = value; }
  1207. }
  1208. private SolidColorBrush sPDFEditMultiCropBorderBrush;
  1209. public SolidColorBrush SPDFEditMultiCropBorderBrush
  1210. {
  1211. get { return sPDFEditMultiCropBorderBrush.Clone(); }
  1212. set { sPDFEditMultiCropBorderBrush = value; }
  1213. }
  1214. #endregion
  1215. #region Hover state
  1216. private SolidColorBrush pDFEditMultiRectFillHoverBrush;
  1217. public SolidColorBrush PDFEditMultiRectFillHoverBrush
  1218. {
  1219. get { return pDFEditMultiRectFillHoverBrush.Clone(); }
  1220. set { pDFEditMultiRectFillHoverBrush = value; }
  1221. }
  1222. private Pen pDFEditMultiRectLineHoverPen;
  1223. public Pen PDFEditMultiRectLineHoverPen
  1224. {
  1225. get { return pDFEditMultiRectLineHoverPen.Clone(); }
  1226. set { pDFEditMultiRectLineHoverPen = value; }
  1227. }
  1228. private Pen pDFEditMultiPointHoverPen;
  1229. public Pen PDFEditMultiPointHoverPen
  1230. {
  1231. get { return pDFEditMultiPointHoverPen.Clone(); }
  1232. set { pDFEditMultiPointHoverPen = value; }
  1233. }
  1234. private SolidColorBrush pDFEditMultiPointBorderHoverBrush;
  1235. public SolidColorBrush PDFEditMultiPointBorderHoverBrush
  1236. {
  1237. get { return pDFEditMultiPointBorderHoverBrush.Clone(); }
  1238. set { pDFEditMultiPointBorderHoverBrush = value; }
  1239. }
  1240. #endregion
  1241. #endregion
  1242. #region PageSelected
  1243. private SolidColorBrush pageSelectedBgPen;
  1244. public SolidColorBrush PageSelectedBgPen
  1245. {
  1246. get { return pageSelectedBgPen.Clone(); }
  1247. set { pageSelectedBgPen = value; }
  1248. }
  1249. private SolidColorBrush pageSelectedBgBrush;
  1250. public SolidColorBrush PageSelectedBgBrush
  1251. {
  1252. get { return pageSelectedBgBrush.Clone(); }
  1253. set { pageSelectedBgBrush = value; }
  1254. }
  1255. private SolidColorBrush pageSelectedMoveBrush;
  1256. public SolidColorBrush PageSelectedMoveBrush
  1257. {
  1258. get { return pageSelectedMoveBrush.Clone(); }
  1259. set { pageSelectedMoveBrush = value; }
  1260. }
  1261. private Pen pageSelectedMovePen;
  1262. public Pen PageSelectedMovePen
  1263. {
  1264. get { return pageSelectedMovePen.Clone(); }
  1265. set { pageSelectedMovePen = value; }
  1266. }
  1267. #region Not selected state
  1268. private SolidColorBrush pageSelectedRectFillBrush;
  1269. public SolidColorBrush PageSelectedRectFillBrush
  1270. {
  1271. get { return pageSelectedRectFillBrush.Clone(); }
  1272. set { pageSelectedRectFillBrush = value; }
  1273. }
  1274. private Pen pageSelectedRectLinePen;
  1275. public Pen PageSelectedRectLinePen
  1276. {
  1277. get { return pageSelectedRectLinePen.Clone(); }
  1278. set { pageSelectedRectLinePen = value; }
  1279. }
  1280. private Pen pageSelectedPointPen;
  1281. public Pen PageSelectedPointPen
  1282. {
  1283. get { return pageSelectedPointPen.Clone(); }
  1284. set { pageSelectedPointPen = value; }
  1285. }
  1286. private SolidColorBrush pageSelectedPointBorderBrush;
  1287. public SolidColorBrush PageSelectedPointBorderBrush
  1288. {
  1289. get { return pageSelectedPointBorderBrush.Clone(); }
  1290. set { pageSelectedPointBorderBrush = value; }
  1291. }
  1292. #endregion
  1293. #region Selected state
  1294. private SolidColorBrush sPageSelectedRectFillBrush;
  1295. public SolidColorBrush SPageSelectedRectFillBrush
  1296. {
  1297. get { return sPageSelectedRectFillBrush.Clone(); }
  1298. set { sPageSelectedRectFillBrush = value; }
  1299. }
  1300. private Pen sPageSelectedRectLinePen;
  1301. public Pen SPageSelectedRectLinePen
  1302. {
  1303. get { return sPageSelectedRectLinePen.Clone(); }
  1304. set { sPageSelectedRectLinePen = value; }
  1305. }
  1306. private Pen sPageSelectedPointPen;
  1307. public Pen SPageSelectedPointPen
  1308. {
  1309. get { return sPageSelectedPointPen.Clone(); }
  1310. set { sPageSelectedPointPen = value; }
  1311. }
  1312. private SolidColorBrush sPageSelectedPointBorderBrush;
  1313. public SolidColorBrush SPageSelectedPointBorderBrush
  1314. {
  1315. get { return sPageSelectedPointBorderBrush.Clone(); }
  1316. set { sPageSelectedPointBorderBrush = value; }
  1317. }
  1318. private SolidColorBrush sPageSelectedCropBorderBrush;
  1319. public SolidColorBrush SPageSelectedCropBorderBrush
  1320. {
  1321. get { return sPageSelectedCropBorderBrush.Clone(); }
  1322. set { sPageSelectedCropBorderBrush = value; }
  1323. }
  1324. #endregion
  1325. #region Horver state
  1326. private SolidColorBrush pageSelectedRectFillHoverBrush;
  1327. public SolidColorBrush PageSelectedRectFillHoverBrush
  1328. {
  1329. get { return pageSelectedRectFillHoverBrush.Clone(); }
  1330. set { pageSelectedRectFillHoverBrush = value; }
  1331. }
  1332. private Pen pageSelectedRectLineHoverPen;
  1333. public Pen PageSelectedRectLineHoverPen
  1334. {
  1335. get { return pageSelectedRectLineHoverPen.Clone(); }
  1336. set { pageSelectedRectLineHoverPen = value; }
  1337. }
  1338. private Pen pageSelectedPointHoverPen;
  1339. public Pen PageSelectedPointHoverPen
  1340. {
  1341. get { return pageSelectedPointHoverPen.Clone(); }
  1342. set { pageSelectedPointHoverPen = value; }
  1343. }
  1344. private SolidColorBrush pageSelectedPointBorderHoverBrush;
  1345. public SolidColorBrush PageSelectedPointBorderHoverBrush
  1346. {
  1347. get { return pageSelectedPointBorderHoverBrush.Clone(); }
  1348. set { pageSelectedPointBorderHoverBrush = value; }
  1349. }
  1350. #endregion
  1351. #endregion
  1352. public DefaultDrawParam()
  1353. {
  1354. //ShowAnnot
  1355. ShowLinkBrush = new SolidColorBrush(Color.FromRgb(0x78, 0xB4, 0xDB));
  1356. ShowLinkePen = null;
  1357. // AnnotSelectedRect
  1358. AnnotMoveBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1359. AnnotMovePen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1360. AnnotRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1361. AnnotRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1362. AnnotRectHoverPen = new Pen(Brushes.Orange, 2) { DashStyle = DashStyles.Dash };
  1363. AnnotPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1364. AnnotPointBorderBrush = Brushes.White;
  1365. //PDFEdit
  1366. CaretBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1367. CaretPen = new Pen(Brushes.Black, 1);
  1368. PDFEditMovePen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1369. PDFEditMoveRectPen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1370. PDFEditMoveBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1371. PDFEditRectFillHoverBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1372. PDFEditRectLineHoverPen = new Pen(Brushes.Orange, 2) { DashStyle = DashStyles.Dash };
  1373. PDFEditPointHoverPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1374. PDFEditPointBorderHoverBrush = Brushes.White;
  1375. PDFEditRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1376. PDFEditRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2) { DashStyle = DashStyles.Dash };
  1377. PDFEditPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1378. PDFEditPointBorderBrush = Brushes.White;
  1379. SPDFEditRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1380. SPDFEditRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1381. SPDFEditPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1382. SPDFEditPointBorderBrush = Brushes.White;
  1383. SPDFEditCropBorderBrush = new SolidColorBrush(Color.FromRgb(71, 126, 222));
  1384. //AnnotEdit
  1385. EditControlLineBrush = new SolidColorBrush(Color.FromRgb(0x78, 0xB4, 0xDB));
  1386. EditControlLinePen = new Pen(new SolidColorBrush(Color.FromRgb(0x78, 0xB4, 0xDB)), 1);
  1387. EditLinePen = new Pen(new SolidColorBrush(Color.FromRgb(0x78, 0xB4, 0xDB)), 1);
  1388. //AnnotCreate
  1389. RedactPen = new Pen(Brushes.Red, 1);
  1390. LinkPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 1);
  1391. LinkBrush = new SolidColorBrush(Color.FromRgb(0xCC, 0xDD, 0xEA));
  1392. //WidgetCreate
  1393. CreateWidgetPen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1394. //PDFViewer
  1395. ViewerImagePen = new Pen(new SolidColorBrush(Color.FromRgb(0x46, 0x82, 0xB4)), 1);
  1396. ViewerImageBackgroundBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1397. //PDFEditMultiSelected
  1398. PDFEditMultiMoveRectPen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1399. PDFEditMultiMovePen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1400. PDFEditMultiMoveBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1401. PDFEditMultiRectFillHoverBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1402. PDFEditMultiRectLineHoverPen = new Pen(Brushes.Orange, 2) { DashStyle = DashStyles.Dash };
  1403. PDFEditMultiPointHoverPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1404. PDFEditMultiPointBorderHoverBrush = Brushes.White;
  1405. PDFEditMultiRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1406. PDFEditMultiRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2) { DashStyle = DashStyles.Solid };
  1407. PDFEditMultiPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1408. PDFEditMultiPointBorderBrush = Brushes.White;
  1409. SPDFEditMultiRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1410. SPDFEditMultiRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1411. SPDFEditMultiPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1412. SPDFEditMultiPointBorderBrush = Brushes.White;
  1413. SPDFEditMultiCropBorderBrush = new SolidColorBrush(Color.FromRgb(71, 126, 222));
  1414. //PageSelected
  1415. PageSelectedBgPen = null;
  1416. PageSelectedBgBrush = new SolidColorBrush(Color.FromArgb(0x99, 0x00, 0x00, 0x00));
  1417. PageSelectedMovePen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1418. PageSelectedMoveBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1419. PageSelectedRectFillHoverBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1420. PageSelectedRectLineHoverPen = new Pen(Brushes.Orange, 2) { DashStyle = DashStyles.Dash };
  1421. PageSelectedPointHoverPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1422. PageSelectedPointBorderHoverBrush = Brushes.White;
  1423. PageSelectedRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1424. PageSelectedRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2) { DashStyle = DashStyles.Dash };
  1425. PageSelectedPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1426. PageSelectedPointBorderBrush = Brushes.White;
  1427. SPageSelectedRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1428. SPageSelectedRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1429. SPageSelectedPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1430. SPageSelectedPointBorderBrush = Brushes.White;
  1431. SPageSelectedCropBorderBrush = new SolidColorBrush(Color.FromRgb(71, 126, 222));
  1432. }
  1433. }
  1434. public class MeasureSetting
  1435. {
  1436. public double RulerBase { get; set; } = 1;
  1437. public string RulerBaseUnit { get; set; } = CPDFMeasure.CPDF_CM;
  1438. public double RulerTranslate { get; set; } = 1;
  1439. public string RulerTranslateUnit { get; set; } = CPDFMeasure.CPDF_CM;
  1440. public double Precision { get; set; } = 0.01;
  1441. public double MoveDetectionLength { get; set; } = 10;
  1442. public bool IsShowArea { get; set; } = true;
  1443. public bool IsShowLength { get; set; } = true;
  1444. /// <summary>
  1445. /// Return inch
  1446. /// </summary>
  1447. internal static double GetPointLength(Point startPoint, Point endPoint, double zoom)
  1448. {
  1449. if (zoom > 0)
  1450. {
  1451. return (endPoint - startPoint).Length / zoom / 96D;
  1452. }
  1453. return 0;
  1454. }
  1455. internal double GetMeasureRatio(string baseUnit)
  1456. {
  1457. if (baseUnit == CPDFMeasure.CPDF_PT)
  1458. {
  1459. return 1 / 72;
  1460. }
  1461. if (baseUnit == CPDFMeasure.CPDF_IN)
  1462. {
  1463. return 1;
  1464. }
  1465. if (baseUnit == CPDFMeasure.CPDF_MM)
  1466. {
  1467. return 1 / 25.4;
  1468. }
  1469. if (baseUnit == CPDFMeasure.CPDF_CM)
  1470. {
  1471. return 1 / 2.54;
  1472. }
  1473. if (baseUnit == CPDFMeasure.CPDF_M)
  1474. {
  1475. return 1 / 0.0254;
  1476. }
  1477. if (baseUnit == CPDFMeasure.CPDFO_KM)
  1478. {
  1479. return 1 / 0.0254 / 1000;
  1480. }
  1481. if (baseUnit == CPDFMeasure.CPDF_FT)
  1482. {
  1483. return 12;
  1484. }
  1485. if (baseUnit == CPDFMeasure.CPDF_YD)
  1486. {
  1487. return 36;
  1488. }
  1489. if (baseUnit == CPDFMeasure.CPDF_MI)
  1490. {
  1491. return 63360;
  1492. }
  1493. return 0;
  1494. }
  1495. internal double GetMeasureAreaRatio()
  1496. {
  1497. if (RulerBaseUnit == CPDFMeasure.CPDF_PT)
  1498. {
  1499. return CPDFMeasure.pt;
  1500. }
  1501. if (RulerBaseUnit == CPDFMeasure.CPDF_IN)
  1502. {
  1503. return CPDFMeasure.pt_in;
  1504. }
  1505. if (RulerBaseUnit == CPDFMeasure.CPDF_MM)
  1506. {
  1507. return CPDFMeasure.pt_mm;
  1508. }
  1509. if (RulerBaseUnit == CPDFMeasure.CPDF_CM)
  1510. {
  1511. return CPDFMeasure.pt_cm;
  1512. }
  1513. if (RulerBaseUnit == CPDFMeasure.CPDF_M)
  1514. {
  1515. return CPDFMeasure.pt_m;
  1516. }
  1517. if (RulerBaseUnit == CPDFMeasure.CPDFO_KM)
  1518. {
  1519. return CPDFMeasure.pt_km;
  1520. }
  1521. if (RulerBaseUnit == CPDFMeasure.CPDF_FT)
  1522. {
  1523. return CPDFMeasure.pt_ft;
  1524. }
  1525. if (RulerBaseUnit == CPDFMeasure.CPDF_YD)
  1526. {
  1527. return CPDFMeasure.pt_yd;
  1528. }
  1529. if (RulerBaseUnit == CPDFMeasure.CPDF_MI)
  1530. {
  1531. return CPDFMeasure.pt_mi;
  1532. }
  1533. return 0;
  1534. }
  1535. public int GetMeasureSavePrecision()
  1536. {
  1537. if (Precision == 1)
  1538. {
  1539. return CPDFMeasure.PRECISION_VALUE_ZERO;
  1540. }
  1541. if (Precision == 0.1)
  1542. {
  1543. return CPDFMeasure.PRECISION_VALUE_ONE;
  1544. }
  1545. if (Precision == 0.01)
  1546. {
  1547. return CPDFMeasure.PRECISION_VALUE_TWO;
  1548. }
  1549. if (Precision == 0.001)
  1550. {
  1551. return CPDFMeasure.PRECISION_VALUE_THREE;
  1552. }
  1553. if (Precision == 0.0001)
  1554. {
  1555. return CPDFMeasure.PRECISION_VALUE_FOUR;
  1556. }
  1557. return 0;
  1558. }
  1559. internal double GetMeasureShowPrecision(int precision)
  1560. {
  1561. if (precision == CPDFMeasure.PRECISION_VALUE_ZERO)
  1562. {
  1563. return 1;
  1564. }
  1565. if (CPDFMeasure.PRECISION_VALUE_ONE == precision)
  1566. {
  1567. return 0.1;
  1568. }
  1569. if (CPDFMeasure.PRECISION_VALUE_TWO == precision)
  1570. {
  1571. return 0.01;
  1572. }
  1573. if (CPDFMeasure.PRECISION_VALUE_THREE == precision)
  1574. {
  1575. return 0.001;
  1576. }
  1577. if (CPDFMeasure.PRECISION_VALUE_FOUR == precision)
  1578. {
  1579. return 0.0001;
  1580. }
  1581. return 0;
  1582. }
  1583. internal double GetMeasureLength(Point startPoint, Point endPoint, double zoom)
  1584. {
  1585. try
  1586. {
  1587. double inch = GetPointLength(startPoint, endPoint, zoom);
  1588. double ratio = GetMeasureRatio(RulerBaseUnit);
  1589. double rate = RulerTranslate / RulerBase;
  1590. return inch * rate / ratio;
  1591. }
  1592. catch (Exception ex)
  1593. {
  1594. }
  1595. return 0;
  1596. }
  1597. public double GetMeasurePDFLength(double lenght)
  1598. {
  1599. try
  1600. {
  1601. double inch = lenght / 72D;
  1602. double ratio = GetMeasureRatio(RulerBaseUnit);
  1603. double rate = RulerTranslate / RulerBase;
  1604. return inch * rate / ratio;
  1605. }
  1606. catch (Exception ex)
  1607. {
  1608. }
  1609. return 0;
  1610. }
  1611. public double GetMeasurePDFArea(double area)
  1612. {
  1613. try
  1614. {
  1615. double inch = area;
  1616. double ratio = GetMeasureAreaRatio();
  1617. double rate = RulerTranslate / RulerBase;
  1618. return inch * ratio * ratio * rate * rate;
  1619. }
  1620. catch (Exception ex)
  1621. {
  1622. }
  1623. return 0;
  1624. }
  1625. public string GetPrecisionData(double number)
  1626. {
  1627. NumberFormatInfo formatInfo = new NumberFormatInfo();
  1628. formatInfo.NumberDecimalDigits = 2;
  1629. if (Precision == 1)
  1630. {
  1631. formatInfo.NumberDecimalDigits = 0;
  1632. }
  1633. if (Precision == 0.1)
  1634. {
  1635. formatInfo.NumberDecimalDigits = 1;
  1636. }
  1637. if (Precision == 0.01)
  1638. {
  1639. formatInfo.NumberDecimalDigits = 2;
  1640. }
  1641. if (Precision == 0.001)
  1642. {
  1643. formatInfo.NumberDecimalDigits = 3;
  1644. }
  1645. if (Precision == 0.0001)
  1646. {
  1647. formatInfo.NumberDecimalDigits = 4;
  1648. }
  1649. if (Precision == 0.00001)
  1650. {
  1651. formatInfo.NumberDecimalDigits = 5;
  1652. }
  1653. return number.ToString("N", formatInfo);
  1654. }
  1655. internal double ComputePolygonArea(List<Point> points)
  1656. {
  1657. int point_num = points.Count;
  1658. if (point_num < 3)
  1659. return 0.0;
  1660. double s = points[0].Y * (points[point_num - 1].X - points[1].X);
  1661. for (int i = 1; i < point_num; ++i)
  1662. s += points[i].Y * (points[i - 1].X - points[(i + 1) % point_num].X);
  1663. return Math.Abs(s / 2.0);
  1664. }
  1665. }
  1666. }