DefaultSettingParam.cs 58 KB

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