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 = 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. private Pen pDFEditMoveRectPen;
  987. public Pen PDFEditMoveRectPen
  988. {
  989. get { return pDFEditMoveRectPen.Clone(); }
  990. set { pDFEditMoveRectPen = value; }
  991. }
  992. #region Not selected state
  993. private SolidColorBrush pDFEditRectFillBrush;
  994. public SolidColorBrush PDFEditRectFillBrush
  995. {
  996. get { return pDFEditRectFillBrush.Clone(); }
  997. set { pDFEditRectFillBrush = value; }
  998. }
  999. private Pen pDFEditRectLinePen;
  1000. public Pen PDFEditRectLinePen
  1001. {
  1002. get { return pDFEditRectLinePen.Clone(); }
  1003. set { pDFEditRectLinePen = value; }
  1004. }
  1005. private Pen pDFEditPointPen;
  1006. public Pen PDFEditPointPen
  1007. {
  1008. get { return pDFEditPointPen.Clone(); }
  1009. set { pDFEditPointPen = value; }
  1010. }
  1011. private SolidColorBrush pDFEditPointBorderBrush;
  1012. public SolidColorBrush PDFEditPointBorderBrush
  1013. {
  1014. get { return pDFEditPointBorderBrush.Clone(); }
  1015. set { pDFEditPointBorderBrush = value; }
  1016. }
  1017. #endregion
  1018. #region Selected state
  1019. private SolidColorBrush sPDFEditRectFillBrush;
  1020. public SolidColorBrush SPDFEditRectFillBrush
  1021. {
  1022. get { return sPDFEditRectFillBrush.Clone(); }
  1023. set { sPDFEditRectFillBrush = value; }
  1024. }
  1025. private Pen sPDFEditRectLinePen;
  1026. public Pen SPDFEditRectLinePen
  1027. {
  1028. get { return sPDFEditRectLinePen.Clone(); }
  1029. set { sPDFEditRectLinePen = value; }
  1030. }
  1031. private Pen sPDFEditPointPen;
  1032. public Pen SPDFEditPointPen
  1033. {
  1034. get { return sPDFEditPointPen.Clone(); }
  1035. set { sPDFEditPointPen = value; }
  1036. }
  1037. private SolidColorBrush sPDFEditPointBorderBrush;
  1038. public SolidColorBrush SPDFEditPointBorderBrush
  1039. {
  1040. get { return sPDFEditPointBorderBrush.Clone(); }
  1041. set { sPDFEditPointBorderBrush = value; }
  1042. }
  1043. private SolidColorBrush sPDFEditCropBorderBrush;
  1044. public SolidColorBrush SPDFEditCropBorderBrush
  1045. {
  1046. get { return sPDFEditCropBorderBrush.Clone(); }
  1047. set { sPDFEditCropBorderBrush = value; }
  1048. }
  1049. #endregion
  1050. #region Hover state
  1051. private SolidColorBrush pDFEditRectFillHoverBrush;
  1052. public SolidColorBrush PDFEditRectFillHoverBrush
  1053. {
  1054. get { return pDFEditRectFillHoverBrush.Clone(); }
  1055. set { pDFEditRectFillHoverBrush = value; }
  1056. }
  1057. private Pen pDFEditRectLineHoverPen;
  1058. public Pen PDFEditRectLineHoverPen
  1059. {
  1060. get { return pDFEditRectLineHoverPen.Clone(); }
  1061. set { pDFEditRectLineHoverPen = value; }
  1062. }
  1063. private Pen pDFEditPointHoverPen;
  1064. public Pen PDFEditPointHoverPen
  1065. {
  1066. get { return pDFEditPointHoverPen.Clone(); }
  1067. set { pDFEditPointHoverPen = value; }
  1068. }
  1069. private SolidColorBrush pDFEditPointBorderHoverBrush;
  1070. public SolidColorBrush PDFEditPointBorderHoverBrush
  1071. {
  1072. get { return pDFEditPointBorderHoverBrush.Clone(); }
  1073. set { pDFEditPointBorderHoverBrush = value; }
  1074. }
  1075. #endregion
  1076. #endregion
  1077. #region AnnotEdit
  1078. private SolidColorBrush editControlLineBrush;
  1079. public SolidColorBrush EditControlLineBrush
  1080. {
  1081. get { return editControlLineBrush.Clone(); }
  1082. set { editControlLineBrush = value; }
  1083. }
  1084. private Pen editControlLinePen;
  1085. public Pen EditControlLinePen
  1086. {
  1087. get { return editControlLinePen.Clone(); }
  1088. set { editControlLinePen = value; }
  1089. }
  1090. private Pen editLinePen;
  1091. public Pen EditLinePen
  1092. {
  1093. get { return editLinePen.Clone(); }
  1094. set { editLinePen = value; }
  1095. }
  1096. #endregion
  1097. #region AnnotCreate
  1098. private Pen redactPen;
  1099. public Pen RedactPen
  1100. {
  1101. get { return redactPen.Clone(); }
  1102. set { redactPen = value; }
  1103. }
  1104. private Pen linkPen;
  1105. public Pen LinkPen
  1106. {
  1107. get { return linkPen.Clone(); }
  1108. set { linkPen = value; }
  1109. }
  1110. private SolidColorBrush linkBrush;
  1111. public SolidColorBrush LinkBrush
  1112. {
  1113. get { return linkBrush.Clone(); }
  1114. set { linkBrush = value; }
  1115. }
  1116. #endregion
  1117. #region WidgetCreate
  1118. private Pen createWidgetPen;
  1119. public Pen CreateWidgetPen
  1120. {
  1121. get { return createWidgetPen.Clone(); }
  1122. set { createWidgetPen = value; }
  1123. }
  1124. #endregion
  1125. #region PDFViewer
  1126. private Pen viewerImagePen;
  1127. public Pen ViewerImagePen
  1128. {
  1129. get { return viewerImagePen.Clone(); }
  1130. set { viewerImagePen = value; }
  1131. }
  1132. private Brush viewerImageBackgroundBrush;
  1133. public Brush ViewerImageBackgroundBrush
  1134. {
  1135. get { return viewerImageBackgroundBrush.Clone(); }
  1136. set { viewerImageBackgroundBrush = value; }
  1137. }
  1138. #endregion
  1139. #region PDFEditMultiSelected
  1140. private SolidColorBrush pDFEditMultiMoveBrush;
  1141. public SolidColorBrush PDFEditMultiMoveBrush
  1142. {
  1143. get { return pDFEditMultiMoveBrush.Clone(); }
  1144. set { pDFEditMultiMoveBrush = value; }
  1145. }
  1146. private Pen pDFEditMultiMovePen;
  1147. public Pen PDFEditMultiMovePen
  1148. {
  1149. get { return pDFEditMultiMovePen.Clone(); }
  1150. set { pDFEditMultiMovePen = value; }
  1151. }
  1152. private Pen pDFEditMultiMoveRectPen;
  1153. public Pen PDFEditMultiMoveRectPen
  1154. {
  1155. get { return pDFEditMultiMoveRectPen.Clone(); }
  1156. set { pDFEditMultiMoveRectPen = value; }
  1157. }
  1158. #region Not selected state
  1159. private SolidColorBrush pDFEditMultiRectFillBrush;
  1160. public SolidColorBrush PDFEditMultiRectFillBrush
  1161. {
  1162. get { return pDFEditMultiRectFillBrush.Clone(); }
  1163. set { pDFEditMultiRectFillBrush = value; }
  1164. }
  1165. private Pen pDFEditMultiRectLinePen;
  1166. public Pen PDFEditMultiRectLinePen
  1167. {
  1168. get { return pDFEditMultiRectLinePen.Clone(); }
  1169. set { pDFEditMultiRectLinePen = value; }
  1170. }
  1171. private Pen pDFEditMultiPointPen;
  1172. public Pen PDFEditMultiPointPen
  1173. {
  1174. get { return pDFEditMultiPointPen.Clone(); }
  1175. set { pDFEditMultiPointPen = value; }
  1176. }
  1177. private SolidColorBrush pDFEditMultiPointBorderBrush;
  1178. public SolidColorBrush PDFEditMultiPointBorderBrush
  1179. {
  1180. get { return pDFEditMultiPointBorderBrush.Clone(); }
  1181. set { pDFEditMultiPointBorderBrush = value; }
  1182. }
  1183. #endregion
  1184. #region Selected state
  1185. private SolidColorBrush sPDFEditMultiRectFillBrush;
  1186. public SolidColorBrush SPDFEditMultiRectFillBrush
  1187. {
  1188. get { return sPDFEditMultiRectFillBrush.Clone(); }
  1189. set { sPDFEditMultiRectFillBrush = value; }
  1190. }
  1191. private Pen sPDFEditMultiRectLinePen;
  1192. public Pen SPDFEditMultiRectLinePen
  1193. {
  1194. get { return sPDFEditMultiRectLinePen.Clone(); }
  1195. set { sPDFEditMultiRectLinePen = value; }
  1196. }
  1197. private Pen sPDFEditMultiPointPen;
  1198. public Pen SPDFEditMultiPointPen
  1199. {
  1200. get { return sPDFEditMultiPointPen.Clone(); }
  1201. set { sPDFEditMultiPointPen = value; }
  1202. }
  1203. private SolidColorBrush sPDFEditMultiPointBorderBrush;
  1204. public SolidColorBrush SPDFEditMultiPointBorderBrush
  1205. {
  1206. get { return sPDFEditMultiPointBorderBrush.Clone(); }
  1207. set { sPDFEditMultiPointBorderBrush = value; }
  1208. }
  1209. private SolidColorBrush sPDFEditMultiCropBorderBrush;
  1210. public SolidColorBrush SPDFEditMultiCropBorderBrush
  1211. {
  1212. get { return sPDFEditMultiCropBorderBrush.Clone(); }
  1213. set { sPDFEditMultiCropBorderBrush = value; }
  1214. }
  1215. #endregion
  1216. #region Hover state
  1217. private SolidColorBrush pDFEditMultiRectFillHoverBrush;
  1218. public SolidColorBrush PDFEditMultiRectFillHoverBrush
  1219. {
  1220. get { return pDFEditMultiRectFillHoverBrush.Clone(); }
  1221. set { pDFEditMultiRectFillHoverBrush = value; }
  1222. }
  1223. private Pen pDFEditMultiRectLineHoverPen;
  1224. public Pen PDFEditMultiRectLineHoverPen
  1225. {
  1226. get { return pDFEditMultiRectLineHoverPen.Clone(); }
  1227. set { pDFEditMultiRectLineHoverPen = value; }
  1228. }
  1229. private Pen pDFEditMultiPointHoverPen;
  1230. public Pen PDFEditMultiPointHoverPen
  1231. {
  1232. get { return pDFEditMultiPointHoverPen.Clone(); }
  1233. set { pDFEditMultiPointHoverPen = value; }
  1234. }
  1235. private SolidColorBrush pDFEditMultiPointBorderHoverBrush;
  1236. public SolidColorBrush PDFEditMultiPointBorderHoverBrush
  1237. {
  1238. get { return pDFEditMultiPointBorderHoverBrush.Clone(); }
  1239. set { pDFEditMultiPointBorderHoverBrush = value; }
  1240. }
  1241. #endregion
  1242. #endregion
  1243. #region PageSelected
  1244. private SolidColorBrush pageSelectedBgPen;
  1245. public SolidColorBrush PageSelectedBgPen
  1246. {
  1247. get { return pageSelectedBgPen.Clone(); }
  1248. set { pageSelectedBgPen = value; }
  1249. }
  1250. private SolidColorBrush pageSelectedBgBrush;
  1251. public SolidColorBrush PageSelectedBgBrush
  1252. {
  1253. get { return pageSelectedBgBrush.Clone(); }
  1254. set { pageSelectedBgBrush = value; }
  1255. }
  1256. private SolidColorBrush pageSelectedMoveBrush;
  1257. public SolidColorBrush PageSelectedMoveBrush
  1258. {
  1259. get { return pageSelectedMoveBrush.Clone(); }
  1260. set { pageSelectedMoveBrush = value; }
  1261. }
  1262. private Pen pageSelectedMovePen;
  1263. public Pen PageSelectedMovePen
  1264. {
  1265. get { return pageSelectedMovePen.Clone(); }
  1266. set { pageSelectedMovePen = value; }
  1267. }
  1268. #region Not selected state
  1269. private SolidColorBrush pageSelectedRectFillBrush;
  1270. public SolidColorBrush PageSelectedRectFillBrush
  1271. {
  1272. get { return pageSelectedRectFillBrush.Clone(); }
  1273. set { pageSelectedRectFillBrush = value; }
  1274. }
  1275. private Pen pageSelectedRectLinePen;
  1276. public Pen PageSelectedRectLinePen
  1277. {
  1278. get { return pageSelectedRectLinePen.Clone(); }
  1279. set { pageSelectedRectLinePen = value; }
  1280. }
  1281. private Pen pageSelectedPointPen;
  1282. public Pen PageSelectedPointPen
  1283. {
  1284. get { return pageSelectedPointPen.Clone(); }
  1285. set { pageSelectedPointPen = value; }
  1286. }
  1287. private SolidColorBrush pageSelectedPointBorderBrush;
  1288. public SolidColorBrush PageSelectedPointBorderBrush
  1289. {
  1290. get { return pageSelectedPointBorderBrush.Clone(); }
  1291. set { pageSelectedPointBorderBrush = value; }
  1292. }
  1293. #endregion
  1294. #region Selected state
  1295. private SolidColorBrush sPageSelectedRectFillBrush;
  1296. public SolidColorBrush SPageSelectedRectFillBrush
  1297. {
  1298. get { return sPageSelectedRectFillBrush.Clone(); }
  1299. set { sPageSelectedRectFillBrush = value; }
  1300. }
  1301. private Pen sPageSelectedRectLinePen;
  1302. public Pen SPageSelectedRectLinePen
  1303. {
  1304. get { return sPageSelectedRectLinePen.Clone(); }
  1305. set { sPageSelectedRectLinePen = value; }
  1306. }
  1307. private Pen sPageSelectedPointPen;
  1308. public Pen SPageSelectedPointPen
  1309. {
  1310. get { return sPageSelectedPointPen.Clone(); }
  1311. set { sPageSelectedPointPen = value; }
  1312. }
  1313. private SolidColorBrush sPageSelectedPointBorderBrush;
  1314. public SolidColorBrush SPageSelectedPointBorderBrush
  1315. {
  1316. get { return sPageSelectedPointBorderBrush.Clone(); }
  1317. set { sPageSelectedPointBorderBrush = value; }
  1318. }
  1319. private SolidColorBrush sPageSelectedCropBorderBrush;
  1320. public SolidColorBrush SPageSelectedCropBorderBrush
  1321. {
  1322. get { return sPageSelectedCropBorderBrush.Clone(); }
  1323. set { sPageSelectedCropBorderBrush = value; }
  1324. }
  1325. #endregion
  1326. #region Horver state
  1327. private SolidColorBrush pageSelectedRectFillHoverBrush;
  1328. public SolidColorBrush PageSelectedRectFillHoverBrush
  1329. {
  1330. get { return pageSelectedRectFillHoverBrush.Clone(); }
  1331. set { pageSelectedRectFillHoverBrush = value; }
  1332. }
  1333. private Pen pageSelectedRectLineHoverPen;
  1334. public Pen PageSelectedRectLineHoverPen
  1335. {
  1336. get { return pageSelectedRectLineHoverPen.Clone(); }
  1337. set { pageSelectedRectLineHoverPen = value; }
  1338. }
  1339. private Pen pageSelectedPointHoverPen;
  1340. public Pen PageSelectedPointHoverPen
  1341. {
  1342. get { return pageSelectedPointHoverPen.Clone(); }
  1343. set { pageSelectedPointHoverPen = value; }
  1344. }
  1345. private SolidColorBrush pageSelectedPointBorderHoverBrush;
  1346. public SolidColorBrush PageSelectedPointBorderHoverBrush
  1347. {
  1348. get { return pageSelectedPointBorderHoverBrush.Clone(); }
  1349. set { pageSelectedPointBorderHoverBrush = value; }
  1350. }
  1351. #endregion
  1352. #endregion
  1353. public DefaultDrawParam()
  1354. {
  1355. //ShowAnnot
  1356. ShowLinkBrush = new SolidColorBrush(Color.FromRgb(0x78, 0xB4, 0xDB));
  1357. ShowLinkePen = null;
  1358. // AnnotSelectedRect
  1359. AnnotMoveBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1360. AnnotMovePen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1361. AnnotRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1362. AnnotRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1363. AnnotRectHoverPen = new Pen(Brushes.Orange, 2) { DashStyle = DashStyles.Dash };
  1364. AnnotPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1365. AnnotPointBorderBrush = Brushes.White;
  1366. //PDFEdit
  1367. CaretBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1368. CaretPen = new Pen(Brushes.Black, 1);
  1369. PDFEditMovePen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1370. PDFEditMoveRectPen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1371. PDFEditMoveBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1372. PDFEditRectFillHoverBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1373. PDFEditRectLineHoverPen = new Pen(Brushes.Orange, 2) { DashStyle = DashStyles.Dash };
  1374. PDFEditPointHoverPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1375. PDFEditPointBorderHoverBrush = Brushes.White;
  1376. PDFEditRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1377. PDFEditRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2) { DashStyle = DashStyles.Dash };
  1378. PDFEditPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1379. PDFEditPointBorderBrush = Brushes.White;
  1380. SPDFEditRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1381. SPDFEditRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1382. SPDFEditPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1383. SPDFEditPointBorderBrush = Brushes.White;
  1384. SPDFEditCropBorderBrush = new SolidColorBrush(Color.FromRgb(71, 126, 222));
  1385. //AnnotEdit
  1386. EditControlLineBrush = new SolidColorBrush(Color.FromRgb(0x78, 0xB4, 0xDB));
  1387. EditControlLinePen = new Pen(new SolidColorBrush(Color.FromRgb(0x78, 0xB4, 0xDB)), 1);
  1388. EditLinePen = new Pen(new SolidColorBrush(Color.FromRgb(0x78, 0xB4, 0xDB)), 1);
  1389. //AnnotCreate
  1390. RedactPen = new Pen(Brushes.Red, 1);
  1391. LinkPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 1);
  1392. LinkBrush = new SolidColorBrush(Color.FromRgb(0xCC, 0xDD, 0xEA));
  1393. //WidgetCreate
  1394. CreateWidgetPen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1395. //PDFViewer
  1396. ViewerImagePen = new Pen(new SolidColorBrush(Color.FromRgb(0x46, 0x82, 0xB4)), 1);
  1397. ViewerImageBackgroundBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1398. //PDFEditMultiSelected
  1399. PDFEditMultiMoveRectPen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1400. PDFEditMultiMovePen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1401. PDFEditMultiMoveBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1402. PDFEditMultiRectFillHoverBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1403. PDFEditMultiRectLineHoverPen = new Pen(Brushes.Orange, 2) { DashStyle = DashStyles.Dash };
  1404. PDFEditMultiPointHoverPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1405. PDFEditMultiPointBorderHoverBrush = Brushes.White;
  1406. PDFEditMultiRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1407. PDFEditMultiRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2) { DashStyle = DashStyles.Solid };
  1408. PDFEditMultiPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1409. PDFEditMultiPointBorderBrush = Brushes.White;
  1410. SPDFEditMultiRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1411. SPDFEditMultiRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1412. SPDFEditMultiPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1413. SPDFEditMultiPointBorderBrush = Brushes.White;
  1414. SPDFEditMultiCropBorderBrush = new SolidColorBrush(Color.FromRgb(71, 126, 222));
  1415. //PageSelected
  1416. PageSelectedBgPen = null;
  1417. PageSelectedBgBrush = new SolidColorBrush(Color.FromArgb(0x99, 0x00, 0x00, 0x00));
  1418. PageSelectedMovePen = new Pen(new SolidColorBrush(Color.FromRgb(0x00, 0xFF, 0x00)), 2);
  1419. PageSelectedMoveBrush = new SolidColorBrush(Color.FromArgb(0x46, 0x46, 0x82, 0xB4));
  1420. PageSelectedRectFillHoverBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1421. PageSelectedRectLineHoverPen = new Pen(Brushes.Orange, 2) { DashStyle = DashStyles.Dash };
  1422. PageSelectedPointHoverPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1423. PageSelectedPointBorderHoverBrush = Brushes.White;
  1424. PageSelectedRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1425. PageSelectedRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2) { DashStyle = DashStyles.Dash };
  1426. PageSelectedPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1427. PageSelectedPointBorderBrush = Brushes.White;
  1428. SPageSelectedRectFillBrush = new SolidColorBrush(Color.FromArgb(0x01, 0x00, 0x00, 0x00));
  1429. SPageSelectedRectLinePen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1430. SPageSelectedPointPen = new Pen(new SolidColorBrush(Color.FromRgb(71, 126, 222)), 2);
  1431. SPageSelectedPointBorderBrush = Brushes.White;
  1432. SPageSelectedCropBorderBrush = new SolidColorBrush(Color.FromRgb(71, 126, 222));
  1433. }
  1434. }
  1435. public class MeasureSetting
  1436. {
  1437. public double RulerBase { get; set; } = 1;
  1438. public string RulerBaseUnit { get; set; } = CPDFMeasure.CPDF_CM;
  1439. public double RulerTranslate { get; set; } = 1;
  1440. public string RulerTranslateUnit { get; set; } = CPDFMeasure.CPDF_CM;
  1441. public double Precision { get; set; } = 0.01;
  1442. public double MoveDetectionLength { get; set; } = 10;
  1443. public bool IsShowArea { get; set; } = true;
  1444. public bool IsShowLength { get; set; } = true;
  1445. /// <summary>
  1446. /// Return inch
  1447. /// </summary>
  1448. internal static double GetPointLength(Point startPoint, Point endPoint, double zoom)
  1449. {
  1450. if (zoom > 0)
  1451. {
  1452. return (endPoint - startPoint).Length / zoom / 96D;
  1453. }
  1454. return 0;
  1455. }
  1456. internal double GetMeasureRatio(string baseUnit)
  1457. {
  1458. if (baseUnit == CPDFMeasure.CPDF_PT)
  1459. {
  1460. return 1 / 72;
  1461. }
  1462. if (baseUnit == CPDFMeasure.CPDF_IN)
  1463. {
  1464. return 1;
  1465. }
  1466. if (baseUnit == CPDFMeasure.CPDF_MM)
  1467. {
  1468. return 1 / 25.4;
  1469. }
  1470. if (baseUnit == CPDFMeasure.CPDF_CM)
  1471. {
  1472. return 1 / 2.54;
  1473. }
  1474. if (baseUnit == CPDFMeasure.CPDF_M)
  1475. {
  1476. return 1 / 0.0254;
  1477. }
  1478. if (baseUnit == CPDFMeasure.CPDFO_KM)
  1479. {
  1480. return 1 / 0.0254 / 1000;
  1481. }
  1482. if (baseUnit == CPDFMeasure.CPDF_FT)
  1483. {
  1484. return 12;
  1485. }
  1486. if (baseUnit == CPDFMeasure.CPDF_YD)
  1487. {
  1488. return 36;
  1489. }
  1490. if (baseUnit == CPDFMeasure.CPDF_MI)
  1491. {
  1492. return 63360;
  1493. }
  1494. return 0;
  1495. }
  1496. internal double GetMeasureAreaRatio()
  1497. {
  1498. if (RulerBaseUnit == CPDFMeasure.CPDF_PT)
  1499. {
  1500. return CPDFMeasure.pt;
  1501. }
  1502. if (RulerBaseUnit == CPDFMeasure.CPDF_IN)
  1503. {
  1504. return CPDFMeasure.pt_in;
  1505. }
  1506. if (RulerBaseUnit == CPDFMeasure.CPDF_MM)
  1507. {
  1508. return CPDFMeasure.pt_mm;
  1509. }
  1510. if (RulerBaseUnit == CPDFMeasure.CPDF_CM)
  1511. {
  1512. return CPDFMeasure.pt_cm;
  1513. }
  1514. if (RulerBaseUnit == CPDFMeasure.CPDF_M)
  1515. {
  1516. return CPDFMeasure.pt_m;
  1517. }
  1518. if (RulerBaseUnit == CPDFMeasure.CPDFO_KM)
  1519. {
  1520. return CPDFMeasure.pt_km;
  1521. }
  1522. if (RulerBaseUnit == CPDFMeasure.CPDF_FT)
  1523. {
  1524. return CPDFMeasure.pt_ft;
  1525. }
  1526. if (RulerBaseUnit == CPDFMeasure.CPDF_YD)
  1527. {
  1528. return CPDFMeasure.pt_yd;
  1529. }
  1530. if (RulerBaseUnit == CPDFMeasure.CPDF_MI)
  1531. {
  1532. return CPDFMeasure.pt_mi;
  1533. }
  1534. return 0;
  1535. }
  1536. public int GetMeasureSavePrecision()
  1537. {
  1538. if (Precision == 1)
  1539. {
  1540. return CPDFMeasure.PRECISION_VALUE_ZERO;
  1541. }
  1542. if (Precision == 0.1)
  1543. {
  1544. return CPDFMeasure.PRECISION_VALUE_ONE;
  1545. }
  1546. if (Precision == 0.01)
  1547. {
  1548. return CPDFMeasure.PRECISION_VALUE_TWO;
  1549. }
  1550. if (Precision == 0.001)
  1551. {
  1552. return CPDFMeasure.PRECISION_VALUE_THREE;
  1553. }
  1554. if (Precision == 0.0001)
  1555. {
  1556. return CPDFMeasure.PRECISION_VALUE_FOUR;
  1557. }
  1558. return 0;
  1559. }
  1560. internal double GetMeasureShowPrecision(int precision)
  1561. {
  1562. if (precision == CPDFMeasure.PRECISION_VALUE_ZERO)
  1563. {
  1564. return 1;
  1565. }
  1566. if (CPDFMeasure.PRECISION_VALUE_ONE == precision)
  1567. {
  1568. return 0.1;
  1569. }
  1570. if (CPDFMeasure.PRECISION_VALUE_TWO == precision)
  1571. {
  1572. return 0.01;
  1573. }
  1574. if (CPDFMeasure.PRECISION_VALUE_THREE == precision)
  1575. {
  1576. return 0.001;
  1577. }
  1578. if (CPDFMeasure.PRECISION_VALUE_FOUR == precision)
  1579. {
  1580. return 0.0001;
  1581. }
  1582. return 0;
  1583. }
  1584. internal double GetMeasureLength(Point startPoint, Point endPoint, double zoom)
  1585. {
  1586. try
  1587. {
  1588. double inch = GetPointLength(startPoint, endPoint, zoom);
  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 GetMeasurePDFLength(double lenght)
  1599. {
  1600. try
  1601. {
  1602. double inch = lenght / 72D;
  1603. double ratio = GetMeasureRatio(RulerBaseUnit);
  1604. double rate = RulerTranslate / RulerBase;
  1605. return inch * rate / ratio;
  1606. }
  1607. catch (Exception ex)
  1608. {
  1609. }
  1610. return 0;
  1611. }
  1612. public double GetMeasurePDFArea(double area)
  1613. {
  1614. try
  1615. {
  1616. double inch = area;
  1617. double ratio = GetMeasureAreaRatio();
  1618. double rate = RulerTranslate / RulerBase;
  1619. return inch * ratio * ratio * rate * rate;
  1620. }
  1621. catch (Exception ex)
  1622. {
  1623. }
  1624. return 0;
  1625. }
  1626. public string GetPrecisionData(double number)
  1627. {
  1628. NumberFormatInfo formatInfo = new NumberFormatInfo();
  1629. formatInfo.NumberDecimalDigits = 2;
  1630. if (Precision == 1)
  1631. {
  1632. formatInfo.NumberDecimalDigits = 0;
  1633. }
  1634. if (Precision == 0.1)
  1635. {
  1636. formatInfo.NumberDecimalDigits = 1;
  1637. }
  1638. if (Precision == 0.01)
  1639. {
  1640. formatInfo.NumberDecimalDigits = 2;
  1641. }
  1642. if (Precision == 0.001)
  1643. {
  1644. formatInfo.NumberDecimalDigits = 3;
  1645. }
  1646. if (Precision == 0.0001)
  1647. {
  1648. formatInfo.NumberDecimalDigits = 4;
  1649. }
  1650. if (Precision == 0.00001)
  1651. {
  1652. formatInfo.NumberDecimalDigits = 5;
  1653. }
  1654. return number.ToString("N", formatInfo);
  1655. }
  1656. internal double ComputePolygonArea(List<Point> points)
  1657. {
  1658. int point_num = points.Count;
  1659. if (point_num < 3)
  1660. return 0.0;
  1661. double s = points[0].Y * (points[point_num - 1].X - points[1].X);
  1662. for (int i = 1; i < point_num; ++i)
  1663. s += points[i].Y * (points[i - 1].X - points[(i + 1) % point_num].X);
  1664. return Math.Abs(s / 2.0);
  1665. }
  1666. }
  1667. }