AnnotToolContentViewModel.Function.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. using ComPDFKit.PDFAnnotation;
  2. using ComPDFKitViewer;
  3. using ComPDFKitViewer.AnnotEvent;
  4. using Microsoft.Win32;
  5. using PDF_Office.CustomControl;
  6. using PDF_Office.Helper;
  7. using PDF_Office.Properties;
  8. using PDFSettings;
  9. using Prism.Mvvm;
  10. using Prism.Regions;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Windows;
  17. using System.Windows.Media;
  18. namespace PDF_Office.ViewModels.Tools
  19. {
  20. public sealed partial class AnnotToolContentViewModel : BindableBase, INavigationAware
  21. {
  22. #region 初始化
  23. private void BindingEvent()
  24. {
  25. propertyPanel.DataChanged += AnnotPropertyPanel_DataChanged;
  26. propertyPanel.DefaultStored += AnnotProperty_DefaultStored;
  27. }
  28. private void InitDefaultValue()
  29. {
  30. InitAnnotHighlight();
  31. InitAnnotUnderline();
  32. InitAnnotSquiggly();
  33. InitAnnotStrikeout();
  34. }
  35. private void InitAnnotHighlight()
  36. {
  37. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotHighlight);
  38. if (annotProperty == null)
  39. {
  40. annotProperty = new DefaultAnnotProperty();
  41. annotProperty.AnnotToolType = AnnotArgsType.AnnotHighlight;
  42. annotProperty.BackgroundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
  43. annotProperty.ForgoundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
  44. annotProperty.Opacity = 0.5;
  45. SettingHelper.SetAnnotDefaultProperty(annotProperty);
  46. }
  47. else
  48. {
  49. HighLightColor = new SolidColorBrush(annotProperty.BackgroundColor);
  50. HighLightOpacity = annotProperty.Opacity;
  51. }
  52. }
  53. private void InitAnnotUnderline()
  54. {
  55. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotUnderline);
  56. if (annotProperty == null)
  57. {
  58. annotProperty = new DefaultAnnotProperty();
  59. annotProperty.AnnotToolType = AnnotArgsType.AnnotUnderline;
  60. annotProperty.BackgroundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
  61. annotProperty.ForgoundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
  62. annotProperty.Opacity = 0.5;
  63. SettingHelper.SetAnnotDefaultProperty(annotProperty);
  64. }
  65. else
  66. {
  67. UnderLineColor = new SolidColorBrush(annotProperty.BackgroundColor);
  68. UnderLineOpacity = annotProperty.Opacity;
  69. }
  70. }
  71. private void InitAnnotSquiggly()
  72. {
  73. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSquiggly);
  74. if (annotProperty == null)
  75. {
  76. annotProperty = new DefaultAnnotProperty();
  77. annotProperty.AnnotToolType = AnnotArgsType.AnnotSquiggly;
  78. annotProperty.BackgroundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
  79. annotProperty.ForgoundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
  80. annotProperty.Opacity = 0.5;
  81. SettingHelper.SetAnnotDefaultProperty(annotProperty);
  82. }
  83. else
  84. {
  85. SquigglyColor = new SolidColorBrush(annotProperty.BackgroundColor);
  86. SquigglyOpacity = annotProperty.Opacity;
  87. }
  88. }
  89. private void InitAnnotStrikeout()
  90. {
  91. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotStrikeout);
  92. if (annotProperty == null)
  93. {
  94. annotProperty = new DefaultAnnotProperty();
  95. annotProperty.AnnotToolType = AnnotArgsType.AnnotStrikeout;
  96. annotProperty.BackgroundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
  97. annotProperty.ForgoundColor = Color.FromRgb(0xFF, 0xBB, 0x00);
  98. annotProperty.Opacity = 0.5;
  99. SettingHelper.SetAnnotDefaultProperty(annotProperty);
  100. }
  101. else
  102. {
  103. StrikeoutColor = new SolidColorBrush(annotProperty.BackgroundColor);
  104. StrikeoutOpacity = annotProperty.Opacity;
  105. }
  106. }
  107. #endregion
  108. #region 注释工具
  109. /// <summary>
  110. /// 高亮注释
  111. /// </summary>
  112. /// <returns></returns>
  113. private AnnotHandlerEventArgs GetHighLight()
  114. {
  115. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  116. TextHighlightAnnotArgs highlightArgs = new TextHighlightAnnotArgs();
  117. highlightArgs.Color = Color.FromRgb(0xFF, 0xBB, 0x00);
  118. highlightArgs.Transparency = 0.5;
  119. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotHighlight);
  120. if (annotProperty != null)
  121. {
  122. highlightArgs.Color = annotProperty.ForgoundColor;
  123. highlightArgs.Transparency = annotProperty.Opacity;
  124. highlightArgs.Content = annotProperty.NoteText;
  125. }
  126. annotAttribsList[AnnotAttrib.Color] = highlightArgs.Color;
  127. annotAttribsList[AnnotAttrib.Transparency] = highlightArgs.Transparency;
  128. annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
  129. AddToPropertyPanel(highlightArgs, "HighLight", "TextAnnotProperty");
  130. return highlightArgs;
  131. }
  132. private AnnotHandlerEventArgs GetUnderLine()
  133. {
  134. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  135. TextUnderlineAnnotArgs underlineArgs = new TextUnderlineAnnotArgs();
  136. underlineArgs.Color = Color.FromRgb(0x12, 0xFD, 0xFF);
  137. underlineArgs.Transparency = 1;
  138. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotUnderline);
  139. if (annotProperty != null)
  140. {
  141. underlineArgs.Color = annotProperty.ForgoundColor;
  142. underlineArgs.Transparency = annotProperty.Opacity;
  143. underlineArgs.Content = annotProperty.NoteText;
  144. }
  145. annotAttribsList[AnnotAttrib.Color] = underlineArgs.Color;
  146. annotAttribsList[AnnotAttrib.Transparency] = underlineArgs.Transparency;
  147. annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
  148. AddToPropertyPanel(underlineArgs, "UnderLine", "TextAnnotProperty");
  149. return underlineArgs;
  150. }
  151. private AnnotHandlerEventArgs GetSquiggly()
  152. {
  153. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  154. TextSquigglyAnnotArgs squigglyArgs = new TextSquigglyAnnotArgs();
  155. squigglyArgs.Color = Color.FromRgb(0xFF, 0x87, 0x16);
  156. squigglyArgs.Transparency = 1;
  157. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSquiggly);
  158. if (annotProperty != null)
  159. {
  160. squigglyArgs.Color = annotProperty.ForgoundColor;
  161. squigglyArgs.Transparency = annotProperty.Opacity;
  162. squigglyArgs.Content = annotProperty.NoteText;
  163. }
  164. annotAttribsList[AnnotAttrib.Color] = squigglyArgs.Color;
  165. annotAttribsList[AnnotAttrib.Transparency] = squigglyArgs.Transparency;
  166. annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
  167. AddToPropertyPanel(squigglyArgs, "Squiggly", "TextAnnotProperty");
  168. return squigglyArgs;
  169. }
  170. private AnnotHandlerEventArgs GetStrikeout()
  171. {
  172. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  173. TextStrikeoutAnnotArgs strikeoutArgs = new TextStrikeoutAnnotArgs();
  174. strikeoutArgs.Color = Color.FromRgb(0xFF, 0x3B, 0x30);
  175. strikeoutArgs.Transparency = 1;
  176. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotStrikeout);
  177. if (annotProperty != null)
  178. {
  179. strikeoutArgs.Color = annotProperty.ForgoundColor;
  180. strikeoutArgs.Transparency = annotProperty.Opacity;
  181. strikeoutArgs.Content = annotProperty.NoteText;
  182. }
  183. annotAttribsList[AnnotAttrib.Color] = strikeoutArgs.Color;
  184. annotAttribsList[AnnotAttrib.Transparency] = strikeoutArgs.Transparency;
  185. annotAttribsList[AnnotAttrib.NoteText] = string.Empty;
  186. AddToPropertyPanel(strikeoutArgs, "Strikeout", "TextAnnotProperty");
  187. return strikeoutArgs;
  188. }
  189. private AnnotHandlerEventArgs GetFreehand()
  190. {
  191. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  192. FreehandAnnotArgs freehandArgs = new FreehandAnnotArgs();
  193. freehandArgs.InkColor = Color.FromRgb(0x38, 0xE0, 0x2E);
  194. freehandArgs.Transparency = 1;
  195. freehandArgs.LineWidth = 1;
  196. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotFreehand);
  197. if (annotProperty != null)
  198. {
  199. freehandArgs.InkColor = annotProperty.ForgoundColor;
  200. freehandArgs.Transparency = annotProperty.Opacity;
  201. freehandArgs.LineWidth = annotProperty.Thickness;
  202. freehandArgs.Content = annotProperty.NoteText;
  203. }
  204. annotAttribsList[AnnotAttrib.Color] = freehandArgs.InkColor;
  205. annotAttribsList[AnnotAttrib.Transparency] = freehandArgs.Transparency;
  206. annotAttribsList[AnnotAttrib.Thickness] = freehandArgs.LineWidth;
  207. annotAttribsList[AnnotAttrib.NoteText] = freehandArgs.Content;
  208. AddToPropertyPanel(freehandArgs, "Freehand", "FreehandAnnotProperty");
  209. return freehandArgs;
  210. }
  211. private AnnotHandlerEventArgs GetFreetext()
  212. {
  213. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  214. FreeTextAnnotArgs freetextArgs = new FreeTextAnnotArgs();
  215. freetextArgs.Align = TextAlignment.Left;
  216. freetextArgs.BgColor = Colors.Transparent;
  217. freetextArgs.FontFamily = new FontFamily(Settings.Default.AppProperties.Annotate.TextFontFamaily);
  218. freetextArgs.FontColor = Colors.Black;
  219. freetextArgs.FontSize = 14;
  220. freetextArgs.Transparency = 1;
  221. freetextArgs.LineColor = Colors.Black;
  222. freetextArgs.LineWidth = 0;
  223. freetextArgs.TextContent = string.Empty;
  224. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotFreeText);
  225. if (annotProperty != null)
  226. {
  227. freetextArgs.Align = annotProperty.TextAlign;
  228. freetextArgs.BgColor = annotProperty.BackgroundColor;
  229. freetextArgs.FontFamily = new FontFamily(annotProperty.FontFamily);
  230. freetextArgs.FontColor = annotProperty.ForgoundColor;
  231. freetextArgs.FontSize = annotProperty.FontSize;
  232. freetextArgs.Transparency = annotProperty.Opacity;
  233. freetextArgs.LineColor = annotProperty.BorderColor;
  234. freetextArgs.LineWidth = annotProperty.Thickness;
  235. freetextArgs.TextContent = annotProperty.NoteText;
  236. freetextArgs.FontWeight = annotProperty.FontWeight;
  237. freetextArgs.FontStyle = annotProperty.FontStyle;
  238. }
  239. int align = Settings.Default.AppProperties.Annotate.TextAlign;
  240. TextAlignment textAlignment;
  241. if (align == 0)
  242. textAlignment = TextAlignment.Left;
  243. else if (align == 1)
  244. textAlignment = TextAlignment.Center;
  245. else
  246. textAlignment = TextAlignment.Right;
  247. annotAttribsList[AnnotAttrib.Color] = freetextArgs.LineColor;
  248. annotAttribsList[AnnotAttrib.FillColor] = freetextArgs.BgColor;
  249. annotAttribsList[AnnotAttrib.Thickness] = freetextArgs.LineWidth;
  250. annotAttribsList[AnnotAttrib.Transparency] = freetextArgs.Transparency;
  251. annotAttribsList[AnnotAttrib.FontColor] = freetextArgs.FontColor;
  252. annotAttribsList[AnnotAttrib.FontSize] = freetextArgs.FontSize;
  253. annotAttribsList[AnnotAttrib.FontFamily] = freetextArgs.FontFamily;
  254. annotAttribsList[AnnotAttrib.FontStyle] = freetextArgs.FontStyle;
  255. annotAttribsList[AnnotAttrib.FontWeight] = freetextArgs.FontWeight;
  256. annotAttribsList[AnnotAttrib.TextAlign] = textAlignment;
  257. annotAttribsList[AnnotAttrib.NoteText] = freetextArgs.TextContent;
  258. AddToPropertyPanel(freetextArgs, "Freetext", "FreetextAnnotProperty");
  259. return freetextArgs;
  260. }
  261. private AnnotHandlerEventArgs GetStickyNote()
  262. {
  263. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  264. StickyAnnotArgs stickyAnnotArgs = new StickyAnnotArgs();
  265. stickyAnnotArgs.Color = Color.FromRgb(0xFF, 0x81, 0x33);
  266. stickyAnnotArgs.StickyNote = string.Empty;
  267. stickyAnnotArgs.Transparency = 1;
  268. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSticky);
  269. if (annotProperty != null)
  270. {
  271. stickyAnnotArgs.Color = annotProperty.ForgoundColor;
  272. stickyAnnotArgs.StickyNote = annotProperty.NoteText;
  273. stickyAnnotArgs.Transparency = annotProperty.Opacity;
  274. }
  275. annotAttribsList[AnnotAttrib.Color] = stickyAnnotArgs.Color;
  276. annotAttribsList[AnnotAttrib.Transparency] = stickyAnnotArgs.Transparency;
  277. annotAttribsList[AnnotAttrib.NoteText] = stickyAnnotArgs.StickyNote;
  278. AddToPropertyPanel(stickyAnnotArgs, "StickyNote", "FreetextAnnotProperty");
  279. return stickyAnnotArgs;
  280. }
  281. private AnnotHandlerEventArgs GetRect()
  282. {
  283. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  284. SquareAnnotArgs squareArgs = new SquareAnnotArgs();
  285. squareArgs.LineColor = Colors.Red;
  286. squareArgs.BgColor = Colors.Transparent;
  287. squareArgs.LineWidth = 1;
  288. squareArgs.Transparency = 1;
  289. squareArgs.LineDash = DashStyles.Solid;
  290. squareArgs.Content = string.Empty;
  291. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotSquare);
  292. if (annotProperty != null)
  293. {
  294. squareArgs.LineColor = annotProperty.BorderColor;
  295. squareArgs.BgColor = annotProperty.BackgroundColor;
  296. if (annotProperty.DashArray == null || annotProperty.DashArray.Count == 0)
  297. {
  298. squareArgs.LineDash = DashStyles.Solid;
  299. }
  300. else
  301. {
  302. DashStyle dash = new DashStyle();
  303. foreach (var offset in annotProperty.DashArray)
  304. {
  305. dash.Dashes.Add(offset);
  306. }
  307. squareArgs.LineDash = dash;
  308. }
  309. squareArgs.LineWidth = annotProperty.Thickness;
  310. squareArgs.Transparency = annotProperty.Opacity;
  311. squareArgs.Content = annotProperty.NoteText;
  312. }
  313. annotAttribsList[AnnotAttrib.Color] = squareArgs.LineColor;
  314. annotAttribsList[AnnotAttrib.FillColor] = squareArgs.BgColor;
  315. annotAttribsList[AnnotAttrib.LineStyle] = squareArgs.LineDash;
  316. annotAttribsList[AnnotAttrib.Thickness] = squareArgs.LineWidth;
  317. annotAttribsList[AnnotAttrib.Transparency] = squareArgs.Transparency;
  318. annotAttribsList[AnnotAttrib.NoteText] = squareArgs.Content;
  319. AddToPropertyPanel(squareArgs, "Rect", "SharpsAnnotProperty");
  320. return squareArgs;
  321. }
  322. private AnnotHandlerEventArgs GetCircle()
  323. {
  324. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  325. CircleAnnotArgs circleAnnotArgs = new CircleAnnotArgs();
  326. circleAnnotArgs.LineColor = Colors.Red;
  327. circleAnnotArgs.BgColor = Colors.Transparent;
  328. circleAnnotArgs.LineWidth = 1;
  329. circleAnnotArgs.Transparency = 1;
  330. circleAnnotArgs.LineDash = DashStyles.Solid;
  331. circleAnnotArgs.Content = string.Empty;
  332. DefaultAnnotProperty annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotCircle);
  333. if (annotProperty != null)
  334. {
  335. circleAnnotArgs.LineColor = annotProperty.BorderColor;
  336. circleAnnotArgs.BgColor = annotProperty.BackgroundColor;
  337. if (annotProperty.DashArray == null || annotProperty.DashArray.Count == 0)
  338. {
  339. circleAnnotArgs.LineDash = DashStyles.Solid;
  340. }
  341. else
  342. {
  343. DashStyle dash = new DashStyle();
  344. foreach (var offset in annotProperty.DashArray)
  345. {
  346. dash.Dashes.Add(offset);
  347. }
  348. circleAnnotArgs.LineDash = dash;
  349. }
  350. circleAnnotArgs.LineWidth = annotProperty.Thickness;
  351. circleAnnotArgs.Transparency = annotProperty.Opacity;
  352. circleAnnotArgs.Content = annotProperty.NoteText;
  353. }
  354. annotAttribsList[AnnotAttrib.Color] = circleAnnotArgs.LineColor;
  355. annotAttribsList[AnnotAttrib.FillColor] = circleAnnotArgs.BgColor;
  356. annotAttribsList[AnnotAttrib.LineStyle] = circleAnnotArgs.LineDash;
  357. annotAttribsList[AnnotAttrib.Thickness] = circleAnnotArgs.LineWidth;
  358. annotAttribsList[AnnotAttrib.Transparency] = circleAnnotArgs.Transparency;
  359. annotAttribsList[AnnotAttrib.NoteText] = circleAnnotArgs.Content;
  360. AddToPropertyPanel(circleAnnotArgs, "Circle", "SharpsAnnotProperty");
  361. return circleAnnotArgs;
  362. }
  363. private AnnotHandlerEventArgs GetArrowLine(string TagStr)
  364. {
  365. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  366. LineAnnotArgs lineArgs = new LineAnnotArgs();
  367. lineArgs.LineColor = Colors.Red;
  368. lineArgs.HeadLineType = C_LINE_TYPE.LINETYPE_NONE;
  369. if (TagStr == "Line")
  370. {
  371. lineArgs.TailLineType = C_LINE_TYPE.LINETYPE_NONE;
  372. }
  373. else
  374. {
  375. lineArgs.TailLineType = C_LINE_TYPE.LINETYPE_ARROW;
  376. }
  377. lineArgs.LineDash = DashStyles.Solid;
  378. lineArgs.LineWidth = 1;
  379. lineArgs.Transparency = 1;
  380. lineArgs.Content = string.Empty;
  381. DefaultAnnotProperty annotProperty = null;
  382. if (TagStr == "Line")
  383. {
  384. annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotLine, "Line");
  385. if (annotProperty != null)
  386. {
  387. annotProperty.HeadLineType = C_LINE_TYPE.LINETYPE_NONE;
  388. annotProperty.TailLineType = C_LINE_TYPE.LINETYPE_NONE;
  389. }
  390. }
  391. else
  392. {
  393. annotProperty = SettingHelper.GetAnnotDefaultProperty(AnnotArgsType.AnnotLine, "Arrow");
  394. }
  395. if (annotProperty != null)
  396. {
  397. lineArgs.LineColor = annotProperty.BorderColor;
  398. lineArgs.HeadLineType = annotProperty.HeadLineType;
  399. lineArgs.TailLineType = annotProperty.TailLineType;
  400. DashStyle dash = new DashStyle();
  401. foreach (var offset in annotProperty.DashArray)
  402. {
  403. dash.Dashes.Add(offset);
  404. }
  405. lineArgs.LineDash = dash;
  406. lineArgs.LineWidth = annotProperty.Thickness;
  407. lineArgs.Transparency = annotProperty.Opacity;
  408. lineArgs.Content = annotProperty.NoteText;
  409. }
  410. annotAttribsList[AnnotAttrib.Color] = lineArgs.LineColor;
  411. annotAttribsList[AnnotAttrib.LineStart] = lineArgs.HeadLineType;
  412. annotAttribsList[AnnotAttrib.LineEnd] = lineArgs.TailLineType;
  413. annotAttribsList[AnnotAttrib.LineStyle] = lineArgs.LineDash;
  414. annotAttribsList[AnnotAttrib.Thickness] = lineArgs.LineWidth;
  415. annotAttribsList[AnnotAttrib.Transparency] = lineArgs.Transparency;
  416. annotAttribsList[AnnotAttrib.NoteText] = lineArgs.Content;
  417. AddToPropertyPanel(lineArgs, TagStr, "SharpsAnnotProperty");
  418. return lineArgs;
  419. }
  420. private AnnotHandlerEventArgs GetStamp()
  421. {
  422. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  423. StampAnnotArgs stampAnnotArgs = new StampAnnotArgs();
  424. stampAnnotArgs.Opacity = 1;
  425. stampAnnotArgs.StampText = "APPROVED";
  426. stampAnnotArgs.Type = StampType.STANDARD_STAMP;
  427. annotAttribsList[AnnotAttrib.Transparency] = stampAnnotArgs.Opacity;
  428. AddToPropertyPanel(stampAnnotArgs, null, "StampAnnotProperty");
  429. return stampAnnotArgs;
  430. }
  431. private AnnotHandlerEventArgs GetImage(CustomIconToggleBtn annotBtn)
  432. {
  433. Dictionary<AnnotAttrib, object> annotAttribsList = new Dictionary<AnnotAttrib, object>();
  434. annotBtn.IsChecked = false;
  435. StampAnnotArgs stampArgs = new StampAnnotArgs();
  436. stampArgs.Opacity = 1;
  437. stampArgs.Type = StampType.IMAGE_STAMP;
  438. OpenFileDialog openFileDialog = new OpenFileDialog();
  439. openFileDialog.Filter = "Image Files(*.jpg;*.jpeg;*.png;*.bmp)|*.jpg;*.jpeg;*.png;*.bmp;";
  440. if (openFileDialog.ShowDialog() == true)
  441. {
  442. stampArgs.ImagePath = openFileDialog.FileName;
  443. }
  444. AddToPropertyPanel(stampArgs, null, "ImageAnnotProperty");
  445. return stampArgs;
  446. }
  447. private void AddToPropertyPanel(AnnotHandlerEventArgs annot, string toolTag, string viewContent)
  448. {
  449. if (string.IsNullOrEmpty(toolTag) == false)
  450. {
  451. if (!ToolExpandDict.ContainsKey(toolTag))
  452. {
  453. ToolExpandDict[toolTag] = true;
  454. }
  455. }
  456. if (annot != null)
  457. propertyPanel.annot = annot;
  458. if (string.IsNullOrEmpty(viewContent) == false)
  459. {
  460. viewContentViewModel.SelectedPrpoertyPanel(viewContent, propertyPanel);
  461. }
  462. }
  463. #endregion
  464. }
  465. }