MeasureSettingPanel.xaml.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. using ComPDFKit.Measure;
  2. using ComPDFKit.PDFAnnotation;
  3. using Compdfkit_Tools.PDFControl;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Input;
  9. using ComPDFKit.Tool.SettingParam;
  10. namespace Compdfkit_Tools.Measure
  11. {
  12. /// <summary>
  13. /// MeasureSettingPanel.xaml 的交互逻辑
  14. /// </summary>
  15. public partial class MeasureSettingPanel : UserControl
  16. {
  17. public event EventHandler CancelEvent;
  18. public event EventHandler DoneEvent;
  19. public PDFViewControl PdfViewControl { get; set; }
  20. public bool ReturnToInfoPanel { get; set; }
  21. //public List<AnnotHandlerEventArgs> UpdateArgsList { get; set; } = new List<AnnotHandlerEventArgs>();
  22. public MeasureSettingPanel()
  23. {
  24. InitializeComponent();
  25. }
  26. private void ButtonCancel_Click(object sender, RoutedEventArgs e)
  27. {
  28. //if (UpdateArgsList != null && UpdateArgsList.Count > 0)
  29. //{
  30. // ReturnToInfoPanel = false;
  31. //}
  32. //UpdateArgsList?.Clear();
  33. CancelEvent?.Invoke(this, e);
  34. ReturnToInfoPanel = false;
  35. }
  36. public void ShowAreaAndLength(Visibility visibility)
  37. {
  38. if (visibility == Visibility.Visible)
  39. {
  40. SettingPanel.Height = 350;
  41. }
  42. else
  43. {
  44. SettingPanel.Height = 290;
  45. }
  46. AreaAndLength.Visibility = visibility;
  47. }
  48. private void ButtonDone_Click(object sender, RoutedEventArgs e)
  49. {
  50. if (string.IsNullOrEmpty(RulerBaseText.Text) || string.IsNullOrEmpty(RulerTranslateText.Text))
  51. {
  52. MessageBox.Show("Scale is not greater than zero");
  53. return;
  54. }
  55. if (double.TryParse(RulerBaseText.Text, out double ruleBase))
  56. {
  57. if (ruleBase <= 0)
  58. {
  59. MessageBox.Show("Scale is not greater than zero");
  60. return;
  61. }
  62. }
  63. if (double.TryParse(RulerTranslateText.Text, out double ruletranBase))
  64. {
  65. if (ruletranBase <= 0)
  66. {
  67. MessageBox.Show("Scale is not greater than zero");
  68. return;
  69. }
  70. }
  71. //if (UpdateArgsList != null && UpdateArgsList.Count == 0)
  72. //{
  73. // SaveMeasureSetting();
  74. //}
  75. //if (UpdateArgsList != null && UpdateArgsList.Count > 0)
  76. //{
  77. // List<AnnotArgsType> allowTypeList = new List<AnnotArgsType>()
  78. // {
  79. // AnnotArgsType.LineMeasure,
  80. // AnnotArgsType.PolyLineMeasure,
  81. // AnnotArgsType.PolygonMeasure
  82. // };
  83. // foreach (AnnotHandlerEventArgs args in UpdateArgsList)
  84. // {
  85. // if (allowTypeList.Contains(args.EventType))
  86. // {
  87. // CPDFAnnotation pdfAnnot = args.GetPDFAnnot();
  88. // switch (pdfAnnot.Type)
  89. // {
  90. // case C_ANNOTATION_TYPE.C_ANNOTATION_LINE:
  91. // {
  92. // CPDFLineAnnotation lineAnnot = (CPDFLineAnnotation)pdfAnnot;
  93. // if (lineAnnot.IsMersured())
  94. // {
  95. // CPDFDistanceMeasure lineMeasure = lineAnnot.GetDistanceMeasure();
  96. // CPDFMeasureInfo measureInfo = lineMeasure.MeasureInfo;
  97. // if (PrecisionBox.SelectedValue != null)
  98. // {
  99. // ComboBoxItem checkItem = PrecisionBox.SelectedValue as ComboBoxItem;
  100. // if (double.TryParse(checkItem.Content.ToString(), out double precision))
  101. // {
  102. // measureInfo.Precision = GetMeasureSavePrecision(precision);
  103. // }
  104. // }
  105. // if (double.TryParse(RulerBaseText.Text, out double ruleBasedata))
  106. // {
  107. // measureInfo.RulerBase = (float)ruleBasedata;
  108. // }
  109. // if (RulerBaseUnitCombo.SelectedItem != null)
  110. // {
  111. // ComboBoxItem RulerBaseUnitcheckItem = RulerBaseUnitCombo.SelectedItem as ComboBoxItem;
  112. // measureInfo.RulerBaseUnit = RulerBaseUnitcheckItem.Content.ToString();
  113. // }
  114. // if (double.TryParse(RulerTranslateText.Text, out double ruletranBasedata))
  115. // {
  116. // measureInfo.RulerTranslate = (float)ruletranBasedata;
  117. // }
  118. // if (RulerTranslateCombo.SelectedItem != null)
  119. // {
  120. // ComboBoxItem RulerTranslatecheckItem = RulerTranslateCombo.SelectedItem as ComboBoxItem;
  121. // measureInfo.RulerTranslateUnit = RulerTranslatecheckItem.Content.ToString();
  122. // }
  123. // lineMeasure.SetMeasureInfo(measureInfo);
  124. // lineMeasure.SetMeasureScale(
  125. // measureInfo.RulerBase,
  126. // measureInfo.RulerBaseUnit,
  127. // measureInfo.RulerTranslate,
  128. // measureInfo.RulerTranslateUnit);
  129. // lineMeasure.UpdateAnnotMeasure();
  130. // lineAnnot.UpdateAp();
  131. // args.Draw();
  132. // if (PdfViewControl != null && PdfViewControl.PDFView != null)
  133. // {
  134. // CPDFViewer viewer = PdfViewControl.PDFView;
  135. // if (viewer != null && viewer.UndoManager != null)
  136. // {
  137. // viewer.UndoManager.CanSave = true;
  138. // }
  139. // }
  140. // }
  141. // }
  142. // break;
  143. // case C_ANNOTATION_TYPE.C_ANNOTATION_POLYLINE:
  144. // {
  145. // CPDFPolylineAnnotation polylineAnnot = (CPDFPolylineAnnotation)pdfAnnot;
  146. // if (polylineAnnot.IsMersured())
  147. // {
  148. // CPDFPerimeterMeasure polylineMeasure = polylineAnnot.GetPerimeterMeasure();
  149. // CPDFMeasureInfo measureInfo = polylineMeasure.MeasureInfo;
  150. // if (PrecisionBox.SelectedValue != null)
  151. // {
  152. // ComboBoxItem checkItem = PrecisionBox.SelectedValue as ComboBoxItem;
  153. // if (double.TryParse(checkItem.Content.ToString(), out double precision))
  154. // {
  155. // measureInfo.Precision = GetMeasureSavePrecision(precision);
  156. // }
  157. // }
  158. // if (double.TryParse(RulerBaseText.Text, out double ruleBasedata))
  159. // {
  160. // measureInfo.RulerBase = (float)ruleBasedata;
  161. // }
  162. // if (RulerBaseUnitCombo.SelectedItem != null)
  163. // {
  164. // ComboBoxItem RulerBaseUnitcheckItem = RulerBaseUnitCombo.SelectedItem as ComboBoxItem;
  165. // measureInfo.RulerBaseUnit = RulerBaseUnitcheckItem.Content.ToString();
  166. // }
  167. // if (double.TryParse(RulerTranslateText.Text, out double ruletranBasedata))
  168. // {
  169. // measureInfo.RulerTranslate = (float)ruletranBasedata;
  170. // }
  171. // if (RulerTranslateCombo.SelectedItem != null)
  172. // {
  173. // ComboBoxItem RulerTranslatecheckItem = RulerTranslateCombo.SelectedItem as ComboBoxItem;
  174. // measureInfo.RulerTranslateUnit = RulerTranslatecheckItem.Content.ToString();
  175. // }
  176. // polylineMeasure.SetMeasureInfo(measureInfo);
  177. // polylineMeasure.SetMeasureScale(
  178. // measureInfo.RulerBase,
  179. // measureInfo.RulerBaseUnit,
  180. // measureInfo.RulerTranslate,
  181. // measureInfo.RulerTranslateUnit);
  182. // polylineMeasure.UpdateAnnotMeasure();
  183. // polylineAnnot.UpdateAp();
  184. // args.Draw();
  185. // if (PdfViewControl != null && PdfViewControl.PDFView != null)
  186. // {
  187. // CPDFViewer viewer = PdfViewControl.PDFView;
  188. // if (viewer != null && viewer.UndoManager != null)
  189. // {
  190. // viewer.UndoManager.CanSave = true;
  191. // }
  192. // }
  193. // }
  194. // }
  195. // break;
  196. // case C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON:
  197. // {
  198. // CPDFPolygonAnnotation areaAnnot = (CPDFPolygonAnnotation)pdfAnnot;
  199. // if (areaAnnot.IsMersured())
  200. // {
  201. // CPDFAreaMeasure areaMeasure = areaAnnot.GetAreaMeasure();
  202. // CPDFMeasureInfo measureInfo = areaMeasure.MeasureInfo;
  203. // if (PrecisionBox.SelectedValue != null)
  204. // {
  205. // ComboBoxItem checkItem = PrecisionBox.SelectedValue as ComboBoxItem;
  206. // if (double.TryParse(checkItem.Content.ToString(), out double precision))
  207. // {
  208. // measureInfo.Precision = GetMeasureSavePrecision(precision);
  209. // }
  210. // }
  211. // if (double.TryParse(RulerBaseText.Text, out double ruleBasedata))
  212. // {
  213. // measureInfo.RulerBase = (float)ruleBasedata;
  214. // }
  215. // if (RulerBaseUnitCombo.SelectedItem != null)
  216. // {
  217. // ComboBoxItem RulerBaseUnitcheckItem = RulerBaseUnitCombo.SelectedItem as ComboBoxItem;
  218. // measureInfo.RulerBaseUnit = RulerBaseUnitcheckItem.Content.ToString();
  219. // }
  220. // if (double.TryParse(RulerTranslateText.Text, out double ruletranBasedata))
  221. // {
  222. // measureInfo.RulerTranslate = (float)ruletranBasedata;
  223. // }
  224. // if (RulerTranslateCombo.SelectedItem != null)
  225. // {
  226. // ComboBoxItem RulerTranslatecheckItem = RulerTranslateCombo.SelectedItem as ComboBoxItem;
  227. // measureInfo.RulerTranslateUnit = RulerTranslatecheckItem.Content.ToString();
  228. // }
  229. // measureInfo.CaptionType = CPDFCaptionType.CPDF_CAPTION_NONE;
  230. // if ((bool)AreaCheckBox.IsChecked)
  231. // {
  232. // measureInfo.CaptionType |= CPDFCaptionType.CPDF_CAPTION_AREA;
  233. // }
  234. // if ((bool)LengthCheckBox.IsChecked)
  235. // {
  236. // measureInfo.CaptionType |= CPDFCaptionType.CPDF_CAPTION_LENGTH;
  237. // }
  238. // areaMeasure.SetMeasureInfo(measureInfo);
  239. // areaMeasure.SetMeasureScale(
  240. // measureInfo.RulerBase,
  241. // measureInfo.RulerBaseUnit,
  242. // measureInfo.RulerTranslate,
  243. // measureInfo.RulerTranslateUnit);
  244. // areaMeasure.UpdateAnnotMeasure();
  245. // areaAnnot.UpdateAp();
  246. // args.Draw();
  247. // if(PdfViewControl!=null && PdfViewControl.PDFView!=null)
  248. // {
  249. // CPDFViewer viewer = PdfViewControl.PDFView;
  250. // if(viewer!=null && viewer.UndoManager!=null)
  251. // {
  252. // viewer.UndoManager.CanSave = true;
  253. // }
  254. // }
  255. // }
  256. // }
  257. // break;
  258. // default:
  259. // break;
  260. // }
  261. // }
  262. // }
  263. // ReturnToInfoPanel = false;
  264. //}
  265. //UpdateArgsList?.Clear();
  266. DoneEvent?.Invoke(this, e);
  267. ReturnToInfoPanel = false;
  268. }
  269. private int GetMeasureSavePrecision(double Precision)
  270. {
  271. if (Precision == 1)
  272. {
  273. return CPDFMeasure.PRECISION_VALUE_ZERO;
  274. }
  275. if (Precision == 0.1)
  276. {
  277. return CPDFMeasure.PRECISION_VALUE_ONE;
  278. }
  279. if (Precision == 0.01)
  280. {
  281. return CPDFMeasure.PRECISION_VALUE_TWO;
  282. }
  283. if (Precision == 0.001)
  284. {
  285. return CPDFMeasure.PRECISION_VALUE_THREE;
  286. }
  287. if (Precision == 0.0001)
  288. {
  289. return CPDFMeasure.PRECISION_VALUE_FOUR;
  290. }
  291. return 0;
  292. }
  293. private void TextBox_PreviewKeyDown(object sender, KeyEventArgs e)
  294. {
  295. List<Key> allowKeys = new List<Key>()
  296. {
  297. Key.Delete, Key.Back, Key.Enter, Key.NumPad0, Key.NumPad1, Key.NumPad2, Key.NumPad3,
  298. Key.NumPad4, Key.NumPad5, Key.NumPad6, Key.NumPad7, Key.NumPad8, Key.NumPad9, Key.D0,
  299. Key.D1, Key.D2, Key.D3, Key.D4, Key.D5, Key.D6, Key.D7, Key.D8, Key.D9, Key.Left, Key.Right,
  300. Key.OemPeriod,Key.Decimal
  301. };
  302. if (allowKeys.Contains(e.Key) == false)
  303. {
  304. e.Handled = true;
  305. }
  306. }
  307. private void TextBox_CanExecute(object sender, CanExecuteRoutedEventArgs e)
  308. {
  309. try
  310. {
  311. if (e.Command == ApplicationCommands.Paste && Clipboard.ContainsText())
  312. {
  313. string checkText = Clipboard.GetText();
  314. if (int.TryParse(checkText, out int value))
  315. {
  316. e.CanExecute = true;
  317. }
  318. e.Handled = true;
  319. }
  320. }
  321. catch (Exception ex)
  322. {
  323. }
  324. }
  325. public void BindMeasureSetting(CPDFMeasureInfo measureInfo)
  326. {
  327. if(measureInfo == null)
  328. {
  329. return;
  330. }
  331. RulerBaseText.Text = measureInfo.RulerBase.ToString();
  332. RulerTranslateText.Text = measureInfo.RulerTranslate.ToString();
  333. RulerTranslateCombo.SelectedIndex = -1;
  334. RulerBaseUnitCombo.SelectedIndex = -1;
  335. PrecisionBox.SelectedIndex = -1;
  336. if (measureInfo.RulerBaseUnit == "in")
  337. {
  338. RulerBaseUnitCombo.SelectedIndex = 0;
  339. }
  340. if (measureInfo.RulerBaseUnit == "cm")
  341. {
  342. RulerBaseUnitCombo.SelectedIndex = 1;
  343. }
  344. if (measureInfo.RulerBaseUnit == "mm")
  345. {
  346. RulerBaseUnitCombo.SelectedIndex = 2;
  347. }
  348. for (int i = 0; i < RulerTranslateCombo.Items.Count; i++)
  349. {
  350. ComboBoxItem checkItem = RulerTranslateCombo.Items[i] as ComboBoxItem;
  351. if (checkItem != null && checkItem.Tag.ToString() == measureInfo.RulerTranslateUnit.ToString())
  352. {
  353. RulerTranslateCombo.SelectedIndex = i;
  354. }
  355. }
  356. string precision = GetMeasureShowPrecision(measureInfo.Precision).ToString();
  357. for (int i = 0; i < PrecisionBox.Items.Count; i++)
  358. {
  359. ComboBoxItem checkItem = PrecisionBox.Items[i] as ComboBoxItem;
  360. if (checkItem != null && checkItem.Content.ToString() == precision)
  361. {
  362. PrecisionBox.SelectedIndex = i;
  363. }
  364. }
  365. }
  366. //public void BindMeasureSetting(MeasureEventArgs measureEventArgs)
  367. //{
  368. // if (measureEventArgs != null)
  369. // {
  370. // RulerBaseText.Text = measureEventArgs.RulerBase.ToString();
  371. // RulerTranslateText.Text = measureEventArgs.RulerTranslate.ToString();
  372. // RulerTranslateCombo.SelectedIndex = -1;
  373. // RulerBaseUnitCombo.SelectedIndex = -1;
  374. // PrecisionBox.SelectedIndex = -1;
  375. // if (measureEventArgs.RulerBaseUnit == "in")
  376. // {
  377. // RulerBaseUnitCombo.SelectedIndex = 0;
  378. // }
  379. // if (measureEventArgs.RulerBaseUnit == "cm")
  380. // {
  381. // RulerBaseUnitCombo.SelectedIndex = 1;
  382. // }
  383. // if (measureEventArgs.RulerBaseUnit == "mm")
  384. // {
  385. // RulerBaseUnitCombo.SelectedIndex = 2;
  386. // }
  387. // for (int i = 0; i < RulerTranslateCombo.Items.Count; i++)
  388. // {
  389. // ComboBoxItem checkItem = RulerTranslateCombo.Items[i] as ComboBoxItem;
  390. // if (checkItem != null && checkItem.Content.ToString() == measureEventArgs.RulerTranslateUnit.ToString())
  391. // {
  392. // RulerTranslateCombo.SelectedIndex = i;
  393. // }
  394. // }
  395. // for (int i = 0; i < PrecisionBox.Items.Count; i++)
  396. // {
  397. // ComboBoxItem checkItem = PrecisionBox.Items[i] as ComboBoxItem;
  398. // if (checkItem != null && checkItem.Content.ToString() == ((decimal)measureEventArgs.Precision).ToString())
  399. // {
  400. // PrecisionBox.SelectedIndex = i;
  401. // }
  402. // }
  403. // }
  404. //}
  405. public void SaveMeasureSetting(CPDFAnnotation annot)
  406. {
  407. MeasureSetting measureSetting = new MeasureSetting();
  408. if (double.TryParse(RulerBaseText.Text, out double ruleBase))
  409. {
  410. measureSetting.RulerBase = ruleBase;
  411. }
  412. if (RulerBaseUnitCombo.SelectedItem != null)
  413. {
  414. ComboBoxItem checkItem = RulerBaseUnitCombo.SelectedItem as ComboBoxItem;
  415. measureSetting.RulerBaseUnit = checkItem.Tag.ToString();
  416. }
  417. if (double.TryParse(RulerTranslateText.Text, out double ruletranBase))
  418. {
  419. measureSetting.RulerTranslate = ruletranBase;
  420. }
  421. if (RulerTranslateCombo.SelectedItem != null)
  422. {
  423. ComboBoxItem checkItem = RulerTranslateCombo.SelectedItem as ComboBoxItem;
  424. measureSetting.RulerTranslateUnit = checkItem.Tag.ToString();
  425. }
  426. if (PrecisionBox.SelectedValue != null)
  427. {
  428. ComboBoxItem checkItem = PrecisionBox.SelectedValue as ComboBoxItem;
  429. if (double.TryParse(checkItem.Content.ToString(), out double precision))
  430. {
  431. measureSetting.Precision = precision;
  432. }
  433. }
  434. measureSetting.IsShowArea = (bool)AreaCheckBox?.IsChecked;
  435. measureSetting.IsShowLength = (bool)LengthCheckBox?.IsChecked;
  436. UpdateAnnotWithSetting(annot, measureSetting);
  437. }
  438. private void UpdateAnnotWithSetting(CPDFAnnotation annot, MeasureSetting measureSetting)
  439. {
  440. if(annot is CPDFLineAnnotation lineAnnot)
  441. {
  442. if (lineAnnot.IsMersured())
  443. {
  444. CPDFDistanceMeasure lineMeasure = lineAnnot.GetDistanceMeasure();
  445. CPDFMeasureInfo info = lineMeasure.MeasureInfo;
  446. info.RulerBaseUnit = measureSetting.RulerBaseUnit;
  447. info.RulerBase = (float)measureSetting.RulerBase;
  448. info.RulerTranslateUnit = measureSetting.RulerTranslateUnit;
  449. info.RulerTranslate = (float)measureSetting.RulerTranslate;
  450. info.Precision = GetMeasureSavePrecision(measureSetting.Precision);
  451. lineAnnot.GetDistanceMeasure().SetMeasureInfo(info);
  452. lineAnnot.GetDistanceMeasure().SetMeasureScale(info.RulerBase, info.RulerBaseUnit, info.RulerTranslate, info.RulerTranslateUnit);
  453. lineAnnot.GetDistanceMeasure().UpdateAnnotMeasure();
  454. lineAnnot.UpdateAp();
  455. PdfViewControl.UpdateAnnotFrame();
  456. }
  457. }
  458. else if(annot is CPDFPolylineAnnotation polylineAnnot)
  459. {
  460. if (polylineAnnot.IsMersured())
  461. {
  462. CPDFPerimeterMeasure polylineMeasure = polylineAnnot.GetPerimeterMeasure();
  463. CPDFMeasureInfo info = polylineMeasure.MeasureInfo;
  464. info.RulerBaseUnit = measureSetting.RulerBaseUnit;
  465. info.RulerBase = (float)measureSetting.RulerBase;
  466. info.RulerTranslateUnit = measureSetting.RulerTranslateUnit;
  467. info.RulerTranslate = (float)measureSetting.RulerTranslate;
  468. info.Precision = GetMeasureSavePrecision(measureSetting.Precision);
  469. polylineAnnot.GetPerimeterMeasure().SetMeasureInfo(info);
  470. polylineAnnot.GetPerimeterMeasure().SetMeasureScale(info.RulerBase, info.RulerBaseUnit, info.RulerTranslate, info.RulerTranslateUnit);
  471. polylineAnnot.GetPerimeterMeasure().UpdateAnnotMeasure();
  472. polylineAnnot.UpdateAp();
  473. PdfViewControl.UpdateAnnotFrame();
  474. }
  475. }
  476. else if(annot is CPDFPolygonAnnotation areaAnnot)
  477. {
  478. if (areaAnnot.IsMersured())
  479. {
  480. CPDFAreaMeasure areaMeasure = areaAnnot.GetAreaMeasure();
  481. CPDFMeasureInfo info = areaMeasure.MeasureInfo;
  482. info.RulerBaseUnit = measureSetting.RulerBaseUnit;
  483. info.RulerBase = (float)measureSetting.RulerBase;
  484. info.RulerTranslateUnit = measureSetting.RulerTranslateUnit;
  485. info.RulerTranslate = (float)measureSetting.RulerTranslate;
  486. info.Precision = GetMeasureSavePrecision(measureSetting.Precision);
  487. info.CaptionType = CPDFCaptionType.CPDF_CAPTION_NONE;
  488. if (measureSetting.IsShowArea)
  489. {
  490. info.CaptionType |= CPDFCaptionType.CPDF_CAPTION_AREA;
  491. }
  492. if (measureSetting.IsShowLength)
  493. {
  494. info.CaptionType |= CPDFCaptionType.CPDF_CAPTION_LENGTH;
  495. }
  496. areaAnnot.GetAreaMeasure().SetMeasureInfo(info);
  497. areaAnnot.GetAreaMeasure().SetMeasureScale(info.RulerBase, info.RulerBaseUnit, info.RulerTranslate, info.RulerTranslateUnit);
  498. areaAnnot.GetAreaMeasure().UpdateAnnotMeasure();
  499. areaAnnot.UpdateAp();
  500. PdfViewControl.UpdateAnnotFrame();
  501. }
  502. }
  503. }
  504. private double GetMeasureShowPrecision(int precision)
  505. {
  506. if (precision == CPDFMeasure.PRECISION_VALUE_ZERO)
  507. {
  508. return 1;
  509. }
  510. if (CPDFMeasure.PRECISION_VALUE_ONE == precision)
  511. {
  512. return 0.1;
  513. }
  514. if (CPDFMeasure.PRECISION_VALUE_TWO == precision)
  515. {
  516. return 0.01;
  517. }
  518. if (CPDFMeasure.PRECISION_VALUE_THREE == precision)
  519. {
  520. return 0.001;
  521. }
  522. if (CPDFMeasure.PRECISION_VALUE_FOUR == precision)
  523. {
  524. return 0.0001;
  525. }
  526. return 0;
  527. }
  528. public void ChangedCheckBoxIsChecked(bool Area, bool Lenght)
  529. {
  530. AreaCheckBox.IsChecked = Area;
  531. LengthCheckBox.IsChecked = Lenght;
  532. }
  533. }
  534. }