DefaultSettingParam.cs 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954
  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 = 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. break;
  783. case C_ANNOTATION_TYPE.C_ANNOTATION_MOVIE:
  784. break;
  785. case C_ANNOTATION_TYPE.C_ANNOTATION_WIDGET:
  786. if (annotParam is WidgetParm)
  787. {
  788. IsOK = SetWidgetParam(annotParam as WidgetParm);
  789. }
  790. break;
  791. case C_ANNOTATION_TYPE.C_ANNOTATION_SCREEN:
  792. break;
  793. case C_ANNOTATION_TYPE.C_ANNOTATION_PRINTERMARK:
  794. break;
  795. case C_ANNOTATION_TYPE.C_ANNOTATION_TRAPNET:
  796. break;
  797. case C_ANNOTATION_TYPE.C_ANNOTATION_WATERMARK:
  798. break;
  799. case C_ANNOTATION_TYPE.C_ANNOTATION_3D:
  800. break;
  801. case C_ANNOTATION_TYPE.C_ANNOTATION_RICHMEDIA:
  802. break;
  803. case C_ANNOTATION_TYPE.C_ANNOTATION_REDACT:
  804. if (annotParam is RedactParam)
  805. {
  806. RedactParamDef = annotParam as RedactParam;
  807. IsOK = true;
  808. }
  809. break;
  810. case C_ANNOTATION_TYPE.C_ANNOTATION_INTERCHANGE:
  811. break;
  812. default:
  813. break;
  814. }
  815. return IsOK;
  816. }
  817. private bool SetWidgetParam(WidgetParm formParm)
  818. {
  819. bool IsOK = false;
  820. if (formParm == null)
  821. {
  822. return IsOK;
  823. }
  824. switch (formParm.WidgetType)
  825. {
  826. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_NONE:
  827. break;
  828. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_PUSHBUTTON:
  829. if (formParm is PushButtonParam)
  830. {
  831. PushButtonParamDef = formParm as PushButtonParam;
  832. IsOK = true;
  833. }
  834. break;
  835. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_CHECKBOX:
  836. if (formParm is CheckBoxParam)
  837. {
  838. CheckBoxParamDef = formParm as CheckBoxParam;
  839. IsOK = true;
  840. }
  841. break;
  842. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_RADIOBUTTON:
  843. if (formParm is RadioButtonParam)
  844. {
  845. RadioButtonParamDef = formParm as RadioButtonParam;
  846. IsOK = true;
  847. }
  848. break;
  849. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_TEXTFIELD:
  850. if (formParm is TextBoxParam)
  851. {
  852. TextBoxParamDef = formParm as TextBoxParam;
  853. IsOK = true;
  854. }
  855. break;
  856. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_COMBOBOX:
  857. if (formParm is ComboBoxParam)
  858. {
  859. ComboBoxParamDef = formParm as ComboBoxParam;
  860. IsOK = true;
  861. }
  862. break;
  863. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_LISTBOX:
  864. if (formParm is ListBoxParam)
  865. {
  866. ListBoxParamDef = formParm as ListBoxParam;
  867. IsOK = true;
  868. }
  869. break;
  870. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_SIGNATUREFIELDS:
  871. if (formParm is SignatureParam)
  872. {
  873. SignatureParamDef = formParm as SignatureParam;
  874. IsOK = true;
  875. }
  876. break;
  877. case PDFAnnotation.Form.C_WIDGET_TYPE.WIDGET_UNKNOWN:
  878. break;
  879. default:
  880. break;
  881. }
  882. return IsOK;
  883. }
  884. public bool SetPDFEditParamm(PDFEditParam editParam)
  885. {
  886. switch (editParam.EditType)
  887. {
  888. case PDFPage.CPDFEditType.EditText:
  889. if (editParam is TextEditParam)
  890. {
  891. TextEditParamDef = editParam as TextEditParam;
  892. return true;
  893. }
  894. break;
  895. default:
  896. break;
  897. }
  898. return false;
  899. }
  900. }
  901. public class DefaultDrawParam
  902. {
  903. #region ShowAnnot
  904. private SolidColorBrush showLinkBrush;
  905. public SolidColorBrush ShowLinkBrush
  906. {
  907. get { return showLinkBrush.Clone(); }
  908. set { showLinkBrush = value; }
  909. }
  910. private Pen showLinkePen;
  911. public Pen ShowLinkePen
  912. {
  913. get { return showLinkePen.Clone(); }
  914. set { showLinkePen = value; }
  915. }
  916. #endregion
  917. #region AnnotSelectedRect
  918. private SolidColorBrush annotMoveBrush;
  919. public SolidColorBrush AnnotMoveBrush
  920. {
  921. get { return annotMoveBrush.Clone(); }
  922. set { annotMoveBrush = value; }
  923. }
  924. private Pen annotMovePen;
  925. public Pen AnnotMovePen
  926. {
  927. get { return annotMovePen.Clone(); }
  928. set { annotMovePen = value; }
  929. }
  930. private SolidColorBrush annotRectFillBrush;
  931. public SolidColorBrush AnnotRectFillBrush
  932. {
  933. get { return annotRectFillBrush.Clone(); }
  934. set { annotRectFillBrush = value; }
  935. }
  936. private Pen annotRectLinePen;
  937. public Pen AnnotRectLinePen
  938. {
  939. get { return annotRectLinePen.Clone(); }
  940. set { annotRectLinePen = value; }
  941. }
  942. private Pen annotRectHoverPen;
  943. public Pen AnnotRectHoverPen
  944. {
  945. get { return annotRectHoverPen.Clone(); }
  946. set { annotRectHoverPen = value; }
  947. }
  948. private Pen annotPointPen;
  949. public Pen AnnotPointPen
  950. {
  951. get { return annotPointPen.Clone(); }
  952. set { annotPointPen = value; }
  953. }
  954. private SolidColorBrush annotPointBorderBrush;
  955. public SolidColorBrush AnnotPointBorderBrush
  956. {
  957. get { return annotPointBorderBrush.Clone(); }
  958. set { annotPointBorderBrush = value; }
  959. }
  960. #endregion
  961. #region PDFEdit
  962. private SolidColorBrush caretBrush;
  963. public SolidColorBrush CaretBrush
  964. {
  965. get { return caretBrush.Clone(); }
  966. set { caretBrush = value; }
  967. }
  968. private Pen caretPen;
  969. public Pen CaretPen
  970. {
  971. get { return caretPen.Clone(); }
  972. set { caretPen = value; }
  973. }
  974. private SolidColorBrush pDFEditMoveBrush;
  975. public SolidColorBrush PDFEditMoveBrush
  976. {
  977. get { return pDFEditMoveBrush.Clone(); }
  978. set { pDFEditMoveBrush = value; }
  979. }
  980. private Pen pDFEditMovePen;
  981. public Pen PDFEditMovePen
  982. {
  983. get { return pDFEditMovePen.Clone(); }
  984. set { pDFEditMovePen = value; }
  985. }
  986. #region Not selected state
  987. private SolidColorBrush pDFEditRectFillBrush;
  988. public SolidColorBrush PDFEditRectFillBrush
  989. {
  990. get { return pDFEditRectFillBrush.Clone(); }
  991. set { pDFEditRectFillBrush = value; }
  992. }
  993. private Pen pDFEditRectLinePen;
  994. public Pen PDFEditRectLinePen
  995. {
  996. get { return pDFEditRectLinePen.Clone(); }
  997. set { pDFEditRectLinePen = value; }
  998. }
  999. private Pen pDFEditPointPen;
  1000. public Pen PDFEditPointPen
  1001. {
  1002. get { return pDFEditPointPen.Clone(); }
  1003. set { pDFEditPointPen = value; }
  1004. }
  1005. private SolidColorBrush pDFEditPointBorderBrush;
  1006. public SolidColorBrush PDFEditPointBorderBrush
  1007. {
  1008. get { return pDFEditPointBorderBrush.Clone(); }
  1009. set { pDFEditPointBorderBrush = value; }
  1010. }
  1011. #endregion
  1012. #region Selected state
  1013. private SolidColorBrush sPDFEditRectFillBrush;
  1014. public SolidColorBrush SPDFEditRectFillBrush
  1015. {
  1016. get { return sPDFEditRectFillBrush.Clone(); }
  1017. set { sPDFEditRectFillBrush = value; }
  1018. }
  1019. private Pen sPDFEditRectLinePen;
  1020. public Pen SPDFEditRectLinePen
  1021. {
  1022. get { return sPDFEditRectLinePen.Clone(); }
  1023. set { sPDFEditRectLinePen = value; }
  1024. }
  1025. private Pen sPDFEditPointPen;
  1026. public Pen SPDFEditPointPen
  1027. {
  1028. get { return sPDFEditPointPen.Clone(); }
  1029. set { sPDFEditPointPen = value; }
  1030. }
  1031. private SolidColorBrush sPDFEditPointBorderBrush;
  1032. public SolidColorBrush SPDFEditPointBorderBrush
  1033. {
  1034. get { return sPDFEditPointBorderBrush.Clone(); }
  1035. set { sPDFEditPointBorderBrush = value; }
  1036. }
  1037. private SolidColorBrush sPDFEditCropBorderBrush;
  1038. public SolidColorBrush SPDFEditCropBorderBrush
  1039. {
  1040. get { return sPDFEditCropBorderBrush.Clone(); }
  1041. set { sPDFEditCropBorderBrush = value; }
  1042. }
  1043. #endregion
  1044. #region Hover state
  1045. private SolidColorBrush pDFEditRectFillHoverBrush;
  1046. public SolidColorBrush PDFEditRectFillHoverBrush
  1047. {
  1048. get { return pDFEditRectFillHoverBrush.Clone(); }
  1049. set { pDFEditRectFillHoverBrush = value; }
  1050. }
  1051. private Pen pDFEditRectLineHoverPen;
  1052. public Pen PDFEditRectLineHoverPen
  1053. {
  1054. get { return pDFEditRectLineHoverPen.Clone(); }
  1055. set { pDFEditRectLineHoverPen = value; }
  1056. }
  1057. private Pen pDFEditPointHoverPen;
  1058. public Pen PDFEditPointHoverPen
  1059. {
  1060. get { return pDFEditPointHoverPen.Clone(); }
  1061. set { pDFEditPointHoverPen = value; }
  1062. }
  1063. private SolidColorBrush pDFEditPointBorderHoverBrush;
  1064. public SolidColorBrush PDFEditPointBorderHoverBrush
  1065. {
  1066. get { return pDFEditPointBorderHoverBrush.Clone(); }
  1067. set { pDFEditPointBorderHoverBrush = value; }
  1068. }
  1069. #endregion
  1070. #endregion
  1071. #region AnnotEdit
  1072. private SolidColorBrush editControlLineBrush;
  1073. public SolidColorBrush EditControlLineBrush
  1074. {
  1075. get { return editControlLineBrush.Clone(); }
  1076. set { editControlLineBrush = value; }
  1077. }
  1078. private Pen editControlLinePen;
  1079. public Pen EditControlLinePen
  1080. {
  1081. get { return editControlLinePen.Clone(); }
  1082. set { editControlLinePen = value; }
  1083. }
  1084. private Pen editLinePen;
  1085. public Pen EditLinePen
  1086. {
  1087. get { return editLinePen.Clone(); }
  1088. set { editLinePen = value; }
  1089. }
  1090. #endregion
  1091. #region AnnotCreate
  1092. private Pen redactPen;
  1093. public Pen RedactPen
  1094. {
  1095. get { return redactPen.Clone(); }
  1096. set { redactPen = value; }
  1097. }
  1098. private Pen linkPen;
  1099. public Pen LinkPen
  1100. {
  1101. get { return linkPen.Clone(); }
  1102. set { linkPen = value; }
  1103. }
  1104. private SolidColorBrush linkBrush;
  1105. public SolidColorBrush LinkBrush
  1106. {
  1107. get { return linkBrush.Clone(); }
  1108. set { linkBrush = value; }
  1109. }
  1110. #endregion
  1111. #region WidgetCreate
  1112. private Pen createWidgetPen;
  1113. public Pen CreateWidgetPen
  1114. {
  1115. get { return createWidgetPen.Clone(); }
  1116. set { createWidgetPen = value; }
  1117. }
  1118. #endregion
  1119. #region PDFViewer
  1120. private Pen viewerImagePen;
  1121. public Pen ViewerImagePen
  1122. {
  1123. get { return viewerImagePen.Clone(); }
  1124. set { viewerImagePen = value; }
  1125. }
  1126. private Brush viewerImageBackgroundBrush;
  1127. public Brush ViewerImageBackgroundBrush
  1128. {
  1129. get { return viewerImageBackgroundBrush.Clone(); }
  1130. set { viewerImageBackgroundBrush = value; }
  1131. }
  1132. #endregion
  1133. #region PDFEditMultiSelected
  1134. private SolidColorBrush pDFEditMultiMoveBrush;
  1135. public SolidColorBrush PDFEditMultiMoveBrush
  1136. {
  1137. get { return pDFEditMultiMoveBrush.Clone(); }
  1138. set { pDFEditMultiMoveBrush = value; }
  1139. }
  1140. private Pen pDFEditMultiMovePen;
  1141. public Pen PDFEditMultiMovePen
  1142. {
  1143. get { return pDFEditMultiMovePen.Clone(); }
  1144. set { pDFEditMultiMovePen = value; }
  1145. }
  1146. #region Not selected state
  1147. private SolidColorBrush pDFEditMultiRectFillBrush;
  1148. public SolidColorBrush PDFEditMultiRectFillBrush
  1149. {
  1150. get { return pDFEditMultiRectFillBrush.Clone(); }
  1151. set { pDFEditMultiRectFillBrush = value; }
  1152. }
  1153. private Pen pDFEditMultiRectLinePen;
  1154. public Pen PDFEditMultiRectLinePen
  1155. {
  1156. get { return pDFEditMultiRectLinePen.Clone(); }
  1157. set { pDFEditMultiRectLinePen = value; }
  1158. }
  1159. private Pen pDFEditMultiPointPen;
  1160. public Pen PDFEditMultiPointPen
  1161. {
  1162. get { return pDFEditMultiPointPen.Clone(); }
  1163. set { pDFEditMultiPointPen = value; }
  1164. }
  1165. private SolidColorBrush pDFEditMultiPointBorderBrush;
  1166. public SolidColorBrush PDFEditMultiPointBorderBrush
  1167. {
  1168. get { return pDFEditMultiPointBorderBrush.Clone(); }
  1169. set { pDFEditMultiPointBorderBrush = value; }
  1170. }
  1171. #endregion
  1172. #region Selected state
  1173. private SolidColorBrush sPDFEditMultiRectFillBrush;
  1174. public SolidColorBrush SPDFEditMultiRectFillBrush
  1175. {
  1176. get { return sPDFEditMultiRectFillBrush.Clone(); }
  1177. set { sPDFEditMultiRectFillBrush = value; }
  1178. }
  1179. private Pen sPDFEditMultiRectLinePen;
  1180. public Pen SPDFEditMultiRectLinePen
  1181. {
  1182. get { return sPDFEditMultiRectLinePen.Clone(); }
  1183. set { sPDFEditMultiRectLinePen = value; }
  1184. }
  1185. private Pen sPDFEditMultiPointPen;
  1186. public Pen SPDFEditMultiPointPen
  1187. {
  1188. get { return sPDFEditMultiPointPen.Clone(); }
  1189. set { sPDFEditMultiPointPen = value; }
  1190. }
  1191. private SolidColorBrush sPDFEditMultiPointBorderBrush;
  1192. public SolidColorBrush SPDFEditMultiPointBorderBrush
  1193. {
  1194. get { return sPDFEditMultiPointBorderBrush.Clone(); }
  1195. set { sPDFEditMultiPointBorderBrush = value; }
  1196. }
  1197. private SolidColorBrush sPDFEditMultiCropBorderBrush;
  1198. public SolidColorBrush SPDFEditMultiCropBorderBrush
  1199. {
  1200. get { return sPDFEditMultiCropBorderBrush.Clone(); }
  1201. set { sPDFEditMultiCropBorderBrush = value; }
  1202. }
  1203. #endregion
  1204. #region Hover state
  1205. private SolidColorBrush pDFEditMultiRectFillHoverBrush;
  1206. public SolidColorBrush PDFEditMultiRectFillHoverBrush
  1207. {
  1208. get { return pDFEditMultiRectFillHoverBrush.Clone(); }
  1209. set { pDFEditMultiRectFillHoverBrush = value; }
  1210. }
  1211. private Pen pDFEditMultiRectLineHoverPen;
  1212. public Pen PDFEditMultiRectLineHoverPen
  1213. {
  1214. get { return pDFEditMultiRectLineHoverPen.Clone(); }
  1215. set { pDFEditMultiRectLineHoverPen = value; }
  1216. }
  1217. private Pen pDFEditMultiPointHoverPen;
  1218. public Pen PDFEditMultiPointHoverPen
  1219. {
  1220. get { return pDFEditMultiPointHoverPen.Clone(); }
  1221. set { pDFEditMultiPointHoverPen = value; }
  1222. }
  1223. private SolidColorBrush pDFEditMultiPointBorderHoverBrush;
  1224. public SolidColorBrush PDFEditMultiPointBorderHoverBrush
  1225. {
  1226. get { return pDFEditMultiPointBorderHoverBrush.Clone(); }
  1227. set { pDFEditMultiPointBorderHoverBrush = value; }
  1228. }
  1229. #endregion
  1230. #endregion
  1231. #region PageSelected
  1232. private SolidColorBrush pageSelectedBgPen;
  1233. public SolidColorBrush PageSelectedBgPen
  1234. {
  1235. get { return pageSelectedBgPen.Clone(); }
  1236. set { pageSelectedBgPen = value; }
  1237. }
  1238. private SolidColorBrush pageSelectedBgBrush;
  1239. public SolidColorBrush PageSelectedBgBrush
  1240. {
  1241. get { return pageSelectedBgBrush.Clone(); }
  1242. set { pageSelectedBgBrush = value; }
  1243. }
  1244. private SolidColorBrush pageSelectedMoveBrush;
  1245. public SolidColorBrush PageSelectedMoveBrush
  1246. {
  1247. get { return pageSelectedMoveBrush.Clone(); }
  1248. set { pageSelectedMoveBrush = value; }
  1249. }
  1250. private Pen pageSelectedMovePen;
  1251. public Pen PageSelectedMovePen
  1252. {
  1253. get { return pageSelectedMovePen.Clone(); }
  1254. set { pageSelectedMovePen = value; }
  1255. }
  1256. #region Not selected state
  1257. private SolidColorBrush pageSelectedRectFillBrush;
  1258. public SolidColorBrush PageSelectedRectFillBrush
  1259. {
  1260. get { return pageSelectedRectFillBrush.Clone(); }
  1261. set { pageSelectedRectFillBrush = value; }
  1262. }
  1263. private Pen pageSelectedRectLinePen;
  1264. public Pen PageSelectedRectLinePen
  1265. {
  1266. get { return pageSelectedRectLinePen.Clone(); }
  1267. set { pageSelectedRectLinePen = value; }
  1268. }
  1269. private Pen pageSelectedPointPen;
  1270. public Pen PageSelectedPointPen
  1271. {
  1272. get { return pageSelectedPointPen.Clone(); }
  1273. set { pageSelectedPointPen = value; }
  1274. }
  1275. private SolidColorBrush pageSelectedPointBorderBrush;
  1276. public SolidColorBrush PageSelectedPointBorderBrush
  1277. {
  1278. get { return pageSelectedPointBorderBrush.Clone(); }
  1279. set { pageSelectedPointBorderBrush = value; }
  1280. }
  1281. #endregion
  1282. #region Selected state
  1283. private SolidColorBrush sPageSelectedRectFillBrush;
  1284. public SolidColorBrush SPageSelectedRectFillBrush
  1285. {
  1286. get { return sPageSelectedRectFillBrush.Clone(); }
  1287. set { sPageSelectedRectFillBrush = value; }
  1288. }
  1289. private Pen sPageSelectedRectLinePen;
  1290. public Pen SPageSelectedRectLinePen
  1291. {
  1292. get { return sPageSelectedRectLinePen.Clone(); }
  1293. set { sPageSelectedRectLinePen = value; }
  1294. }
  1295. private Pen sPageSelectedPointPen;
  1296. public Pen SPageSelectedPointPen
  1297. {
  1298. get { return sPageSelectedPointPen.Clone(); }
  1299. set { sPageSelectedPointPen = value; }
  1300. }
  1301. private SolidColorBrush sPageSelectedPointBorderBrush;
  1302. public SolidColorBrush SPageSelectedPointBorderBrush
  1303. {
  1304. get { return sPageSelectedPointBorderBrush.Clone(); }
  1305. set { sPageSelectedPointBorderBrush = value; }
  1306. }
  1307. private SolidColorBrush sPageSelectedCropBorderBrush;
  1308. public SolidColorBrush SPageSelectedCropBorderBrush
  1309. {
  1310. get { return sPageSelectedCropBorderBrush.Clone(); }
  1311. set { sPageSelectedCropBorderBrush = value; }
  1312. }
  1313. #endregion
  1314. #region Horver state
  1315. private SolidColorBrush pageSelectedRectFillHoverBrush;
  1316. public SolidColorBrush PageSelectedRectFillHoverBrush
  1317. {
  1318. get { return pageSelectedRectFillHoverBrush.Clone(); }
  1319. set { pageSelectedRectFillHoverBrush = value; }
  1320. }
  1321. private Pen pageSelectedRectLineHoverPen;
  1322. public Pen PageSelectedRectLineHoverPen
  1323. {
  1324. get { return pageSelectedRectLineHoverPen.Clone(); }
  1325. set { pageSelectedRectLineHoverPen = value; }
  1326. }
  1327. private Pen pageSelectedPointHoverPen;
  1328. public Pen PageSelectedPointHoverPen
  1329. {
  1330. get { return pageSelectedPointHoverPen.Clone(); }
  1331. set { pageSelectedPointHoverPen = value; }
  1332. }
  1333. private SolidColorBrush pageSelectedPointBorderHoverBrush;
  1334. public SolidColorBrush PageSelectedPointBorderHoverBrush
  1335. {
  1336. get { return pageSelectedPointBorderHoverBrush.Clone(); }
  1337. set { pageSelectedPointBorderHoverBrush = value; }
  1338. }
  1339. #endregion
  1340. #endregion
  1341. public DefaultDrawParam()
  1342. {
  1343. //ShowAnnot
  1344. ShowLinkBrush = new SolidColorBrush(Color.FromRgb(0x78, 0xB4, 0xDB));
  1345. ShowLinkePen = null;
  1346. // AnnotSelectedRect
  1347. AnnotMoveBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1348. AnnotMovePen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1349. AnnotRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1350. AnnotRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1351. AnnotRectHoverPen = new Pen(Brushes.Orange, 2) { DashStyle = DashStyles.Dash };
  1352. AnnotPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1353. AnnotPointBorderBrush = Brushes.White;
  1354. //PDFEdit
  1355. CaretBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1356. CaretPen = new Pen(Brushes.Black, 1);
  1357. PDFEditMovePen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1358. PDFEditMoveBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1359. PDFEditRectFillHoverBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1360. PDFEditRectLineHoverPen = new Pen(Brushes.Orange, 2) { DashStyle = DashStyles.Dash };
  1361. PDFEditPointHoverPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1362. PDFEditPointBorderHoverBrush = Brushes.White;
  1363. PDFEditRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1364. PDFEditRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2) { DashStyle = DashStyles.Dash };
  1365. PDFEditPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1366. PDFEditPointBorderBrush = Brushes.White;
  1367. SPDFEditRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1368. SPDFEditRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1369. SPDFEditPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1370. SPDFEditPointBorderBrush = Brushes.White;
  1371. SPDFEditCropBorderBrush = new SolidColorBrush(Color.FromRgb(71, 126, 222));
  1372. //AnnotEdit
  1373. EditControlLineBrush = new SolidColorBrush(Color.FromRgb(0x78, 0xB4, 0xDB));
  1374. EditControlLinePen = new Pen(new SolidColorBrush(Color.FromRgb(0x78, 0xB4, 0xDB)), 1);
  1375. EditLinePen = new Pen(new SolidColorBrush(Color.FromRgb(0x78, 0xB4, 0xDB)), 1);
  1376. //AnnotCreate
  1377. RedactPen = new Pen(Brushes.Red, 1);
  1378. LinkPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 1);
  1379. LinkBrush = new SolidColorBrush(Color.FromRgb(0xCC, 0xDD, 0xEA));
  1380. //WidgetCreate
  1381. CreateWidgetPen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1382. //PDFViewer
  1383. ViewerImagePen = new Pen(new SolidColorBrush(Color.FromRgb(0x46, 0x82, 0xB4)), 1);
  1384. ViewerImageBackgroundBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1385. //PDFEditMultiSelected
  1386. PDFEditMultiMovePen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1387. PDFEditMultiMoveBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1388. PDFEditMultiRectFillHoverBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1389. PDFEditMultiRectLineHoverPen = new Pen(Brushes.Orange, 2) { DashStyle = DashStyles.Dash };
  1390. PDFEditMultiPointHoverPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1391. PDFEditMultiPointBorderHoverBrush = Brushes.White;
  1392. PDFEditMultiRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1393. PDFEditMultiRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2) { DashStyle = DashStyles.Solid };
  1394. PDFEditMultiPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1395. PDFEditMultiPointBorderBrush = Brushes.White;
  1396. SPDFEditMultiRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1397. SPDFEditMultiRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1398. SPDFEditMultiPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1399. SPDFEditMultiPointBorderBrush = Brushes.White;
  1400. SPDFEditMultiCropBorderBrush = new SolidColorBrush(Color.FromRgb(71, 126, 222));
  1401. //PageSelected
  1402. PageSelectedBgPen = null;
  1403. PageSelectedBgBrush = new SolidColorBrush(Color.FromArgb(0x99, 0x00, 0x00, 0x00));
  1404. PageSelectedMovePen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1405. PageSelectedMoveBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1406. PageSelectedRectFillHoverBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1407. PageSelectedRectLineHoverPen = new Pen(Brushes.Orange, 2) { DashStyle = DashStyles.Dash };
  1408. PageSelectedPointHoverPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1409. PageSelectedPointBorderHoverBrush = Brushes.White;
  1410. PageSelectedRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1411. PageSelectedRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2) { DashStyle = DashStyles.Dash };
  1412. PageSelectedPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1413. PageSelectedPointBorderBrush = Brushes.White;
  1414. SPageSelectedRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1415. SPageSelectedRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1416. SPageSelectedPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1417. SPageSelectedPointBorderBrush = Brushes.White;
  1418. SPageSelectedCropBorderBrush = new SolidColorBrush(Color.FromRgb(71, 126, 222));
  1419. }
  1420. }
  1421. public class MeasureSetting
  1422. {
  1423. public double RulerBase { get; set; } = 1;
  1424. public string RulerBaseUnit { get; set; } = CPDFMeasure.CPDF_CM;
  1425. public double RulerTranslate { get; set; } = 1;
  1426. public string RulerTranslateUnit { get; set; } = CPDFMeasure.CPDF_CM;
  1427. public double Precision { get; set; } = 0.01;
  1428. public double MoveDetectionLength { get; set; } = 10;
  1429. public bool IsShowArea { get; set; } = true;
  1430. public bool IsShowLength { get; set; } = true;
  1431. /// <summary>
  1432. /// Return inch
  1433. /// </summary>
  1434. internal static double GetPointLength(Point startPoint, Point endPoint, double zoom)
  1435. {
  1436. if (zoom > 0)
  1437. {
  1438. return (endPoint - startPoint).Length / zoom / 96D;
  1439. }
  1440. return 0;
  1441. }
  1442. internal double GetMeasureRatio(string baseUnit)
  1443. {
  1444. if (baseUnit == CPDFMeasure.CPDF_PT)
  1445. {
  1446. return 1 / 72;
  1447. }
  1448. if (baseUnit == CPDFMeasure.CPDF_IN)
  1449. {
  1450. return 1;
  1451. }
  1452. if (baseUnit == CPDFMeasure.CPDF_MM)
  1453. {
  1454. return 1 / 25.4;
  1455. }
  1456. if (baseUnit == CPDFMeasure.CPDF_CM)
  1457. {
  1458. return 1 / 2.54;
  1459. }
  1460. if (baseUnit == CPDFMeasure.CPDF_M)
  1461. {
  1462. return 1 / 0.0254;
  1463. }
  1464. if (baseUnit == CPDFMeasure.CPDFO_KM)
  1465. {
  1466. return 1 / 0.0254 / 1000;
  1467. }
  1468. if (baseUnit == CPDFMeasure.CPDF_FT)
  1469. {
  1470. return 12;
  1471. }
  1472. if (baseUnit == CPDFMeasure.CPDF_YD)
  1473. {
  1474. return 36;
  1475. }
  1476. if (baseUnit == CPDFMeasure.CPDF_MI)
  1477. {
  1478. return 63360;
  1479. }
  1480. return 0;
  1481. }
  1482. internal double GetMeasureAreaRatio()
  1483. {
  1484. if (RulerBaseUnit == CPDFMeasure.CPDF_PT)
  1485. {
  1486. return CPDFMeasure.pt;
  1487. }
  1488. if (RulerBaseUnit == CPDFMeasure.CPDF_IN)
  1489. {
  1490. return CPDFMeasure.pt_in;
  1491. }
  1492. if (RulerBaseUnit == CPDFMeasure.CPDF_MM)
  1493. {
  1494. return CPDFMeasure.pt_mm;
  1495. }
  1496. if (RulerBaseUnit == CPDFMeasure.CPDF_CM)
  1497. {
  1498. return CPDFMeasure.pt_cm;
  1499. }
  1500. if (RulerBaseUnit == CPDFMeasure.CPDF_M)
  1501. {
  1502. return CPDFMeasure.pt_m;
  1503. }
  1504. if (RulerBaseUnit == CPDFMeasure.CPDFO_KM)
  1505. {
  1506. return CPDFMeasure.pt_km;
  1507. }
  1508. if (RulerBaseUnit == CPDFMeasure.CPDF_FT)
  1509. {
  1510. return CPDFMeasure.pt_ft;
  1511. }
  1512. if (RulerBaseUnit == CPDFMeasure.CPDF_YD)
  1513. {
  1514. return CPDFMeasure.pt_yd;
  1515. }
  1516. if (RulerBaseUnit == CPDFMeasure.CPDF_MI)
  1517. {
  1518. return CPDFMeasure.pt_mi;
  1519. }
  1520. return 0;
  1521. }
  1522. public int GetMeasureSavePrecision()
  1523. {
  1524. if (Precision == 1)
  1525. {
  1526. return CPDFMeasure.PRECISION_VALUE_ZERO;
  1527. }
  1528. if (Precision == 0.1)
  1529. {
  1530. return CPDFMeasure.PRECISION_VALUE_ONE;
  1531. }
  1532. if (Precision == 0.01)
  1533. {
  1534. return CPDFMeasure.PRECISION_VALUE_TWO;
  1535. }
  1536. if (Precision == 0.001)
  1537. {
  1538. return CPDFMeasure.PRECISION_VALUE_THREE;
  1539. }
  1540. if (Precision == 0.0001)
  1541. {
  1542. return CPDFMeasure.PRECISION_VALUE_FOUR;
  1543. }
  1544. return 0;
  1545. }
  1546. internal double GetMeasureShowPrecision(int precision)
  1547. {
  1548. if (precision == CPDFMeasure.PRECISION_VALUE_ZERO)
  1549. {
  1550. return 1;
  1551. }
  1552. if (CPDFMeasure.PRECISION_VALUE_ONE == precision)
  1553. {
  1554. return 0.1;
  1555. }
  1556. if (CPDFMeasure.PRECISION_VALUE_TWO == precision)
  1557. {
  1558. return 0.01;
  1559. }
  1560. if (CPDFMeasure.PRECISION_VALUE_THREE == precision)
  1561. {
  1562. return 0.001;
  1563. }
  1564. if (CPDFMeasure.PRECISION_VALUE_FOUR == precision)
  1565. {
  1566. return 0.0001;
  1567. }
  1568. return 0;
  1569. }
  1570. internal double GetMeasureLength(Point startPoint, Point endPoint, double zoom)
  1571. {
  1572. try
  1573. {
  1574. double inch = GetPointLength(startPoint, endPoint, zoom);
  1575. double ratio = GetMeasureRatio(RulerBaseUnit);
  1576. double rate = RulerTranslate / RulerBase;
  1577. return inch * rate / ratio;
  1578. }
  1579. catch (Exception ex)
  1580. {
  1581. }
  1582. return 0;
  1583. }
  1584. public double GetMeasurePDFLength(double lenght)
  1585. {
  1586. try
  1587. {
  1588. double inch = lenght / 72D;
  1589. double ratio = GetMeasureRatio(RulerBaseUnit);
  1590. double rate = RulerTranslate / RulerBase;
  1591. return inch * rate / ratio;
  1592. }
  1593. catch (Exception ex)
  1594. {
  1595. }
  1596. return 0;
  1597. }
  1598. public double GetMeasurePDFArea(double area)
  1599. {
  1600. try
  1601. {
  1602. double inch = area;
  1603. double ratio = GetMeasureAreaRatio();
  1604. double rate = RulerTranslate / RulerBase;
  1605. return inch * ratio * ratio * rate * rate;
  1606. }
  1607. catch (Exception ex)
  1608. {
  1609. }
  1610. return 0;
  1611. }
  1612. public string GetPrecisionData(double number)
  1613. {
  1614. NumberFormatInfo formatInfo = new NumberFormatInfo();
  1615. formatInfo.NumberDecimalDigits = 2;
  1616. if (Precision == 1)
  1617. {
  1618. formatInfo.NumberDecimalDigits = 0;
  1619. }
  1620. if (Precision == 0.1)
  1621. {
  1622. formatInfo.NumberDecimalDigits = 1;
  1623. }
  1624. if (Precision == 0.01)
  1625. {
  1626. formatInfo.NumberDecimalDigits = 2;
  1627. }
  1628. if (Precision == 0.001)
  1629. {
  1630. formatInfo.NumberDecimalDigits = 3;
  1631. }
  1632. if (Precision == 0.0001)
  1633. {
  1634. formatInfo.NumberDecimalDigits = 4;
  1635. }
  1636. if (Precision == 0.00001)
  1637. {
  1638. formatInfo.NumberDecimalDigits = 5;
  1639. }
  1640. return number.ToString("N", formatInfo);
  1641. }
  1642. internal double ComputePolygonArea(List<Point> points)
  1643. {
  1644. int point_num = points.Count;
  1645. if (point_num < 3)
  1646. return 0.0;
  1647. double s = points[0].Y * (points[point_num - 1].X - points[1].X);
  1648. for (int i = 1; i < point_num; ++i)
  1649. s += points[i].Y * (points[i - 1].X - points[(i + 1) % point_num].X);
  1650. return Math.Abs(s / 2.0);
  1651. }
  1652. }
  1653. }