MarkSettingDialogViewModel.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. using ComPDFKitViewer;
  2. using ComPDFKitViewer.AnnotEvent;
  3. using PDF_Office.Model;
  4. using Prism.Commands;
  5. using Prism.Mvvm;
  6. using Prism.Services.Dialogs;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows;
  13. using System.Windows.Media;
  14. namespace PDF_Office.ViewModels.Dialog.Redaction
  15. {
  16. public class MarkSettingDialogViewModel : BindableBase, IDialogAware
  17. {
  18. public string Title => "";
  19. public event Action<IDialogResult> RequestClose;
  20. private RedactionAnnotArgs annotArgs;
  21. public DelegateCommand OkCommand { get; set; }
  22. public DelegateCommand CancelCommand { get; set; }
  23. public DelegateCommand<string> AlignCommand { get; set; }
  24. private Color lineColor;
  25. public Color LineColor
  26. {
  27. get { return lineColor; }
  28. set
  29. {
  30. SetProperty(ref lineColor, value);
  31. }
  32. }
  33. private Color bgColor;
  34. public Color BgColor
  35. {
  36. get { return bgColor; }
  37. set
  38. {
  39. SetProperty(ref bgColor, value);
  40. }
  41. }
  42. private Color fontColor;
  43. public Color FontColor
  44. {
  45. get { return fontColor; }
  46. set
  47. {
  48. SetProperty(ref fontColor, value);
  49. }
  50. }
  51. private bool isUserText;
  52. public bool IsUseText
  53. {
  54. get { return isUserText; }
  55. set
  56. {
  57. SetProperty(ref isUserText, value);
  58. }
  59. }
  60. private bool leftChecked = true;
  61. public bool LeftChecked
  62. {
  63. get { return leftChecked; }
  64. set
  65. {
  66. SetProperty(ref leftChecked, value);
  67. }
  68. }
  69. private bool centerChecked;
  70. public bool CenterChecked
  71. {
  72. get { return centerChecked; }
  73. set
  74. {
  75. SetProperty(ref centerChecked, value);
  76. }
  77. }
  78. private bool rightChecked;
  79. public bool RightChecked
  80. {
  81. get { return rightChecked; }
  82. set
  83. {
  84. SetProperty(ref rightChecked, value);
  85. }
  86. }
  87. private bool strechChecked;
  88. public bool StrechChecked
  89. {
  90. get { return strechChecked; }
  91. set
  92. {
  93. SetProperty(ref strechChecked, value);
  94. }
  95. }
  96. private string overText;
  97. public string OvertText
  98. {
  99. get { return overText; }
  100. set
  101. {
  102. SetProperty(ref overText, value);
  103. }
  104. }
  105. private int fontFamilySelectedIndex;
  106. public int FontFamilySelectedIndex
  107. {
  108. get { return fontFamilySelectedIndex; }
  109. set
  110. {
  111. SetProperty(ref fontFamilySelectedIndex, value);
  112. }
  113. }
  114. private string fontFamily = "";
  115. private int fontWeightSelectedIndex;
  116. public int FontWeightSelectedIndex
  117. {
  118. get { return fontWeightSelectedIndex; }
  119. set
  120. {
  121. SetProperty(ref fontWeightSelectedIndex, value);
  122. }
  123. }
  124. private FontWeight fontWeight = FontWeights.Regular;
  125. private int fontSizeSelectedIndex;
  126. public int FontSizeSelectedIndex
  127. {
  128. get { return fontSizeSelectedIndex; }
  129. set
  130. {
  131. SetProperty(ref fontSizeSelectedIndex, value);
  132. }
  133. }
  134. public List<string> FontFamilys { get; set; }
  135. public List<string> FontWeight { get; set; }
  136. public List<string> FontSizes { get; set; }
  137. public MarkSettingDialogViewModel()
  138. {
  139. OkCommand = new DelegateCommand(ok);
  140. CancelCommand = new DelegateCommand(cancel);
  141. AlignCommand = new DelegateCommand<string>(align);
  142. InitFontFamily();
  143. InitFontWeight();
  144. InitFontSize();
  145. }
  146. private void InitFontFamily()
  147. {
  148. FontFamilys.Add("Courier New");
  149. FontFamilys.Add("Arial");
  150. FontFamilys.Add("Times New Roman");
  151. }
  152. private void InitFontWeight()
  153. {
  154. FontWeight.Add("Regular");
  155. FontWeight.Add("Bold");
  156. FontWeight.Add("Italic");
  157. FontWeight.Add("Bold Italic");
  158. }
  159. private void InitFontSize()
  160. {
  161. FontSizes.Add("Auto");
  162. }
  163. private void cancel()
  164. {
  165. RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
  166. }
  167. private void ok()
  168. {
  169. //annotArgs.UpdateAttrib(AnnotAttrib.FillColor, frm.SaveredactionArgs.BgColor);
  170. //annotArgs.UpdateAttrib(AnnotAttrib.NoteText, frm.SaveredactionArgs.Content);
  171. //annotArgs.UpdateAttrib(AnnotAttrib.FontColor, frm.SaveredactionArgs.FontColor);
  172. //annotArgs.UpdateAttrib(AnnotAttrib.Color, frm.SaveredactionArgs.LineColor);
  173. //annotArgs.UpdateAttrib(AnnotAttrib.FontSize, frm.SaveredactionArgs.FontSize);
  174. //annotArgs.UpdateAttrib(AnnotAttrib.TextAlign, frm.SaveredactionArgs.Align);
  175. //if (IsUseText)
  176. //{
  177. // annotArgs.UpdateAttrib(AnnotAttrib.NoteText, string.Empty);
  178. //}
  179. //annotArgs.UpdateAnnot();
  180. RequestClose.Invoke(new DialogResult(ButtonResult.OK));
  181. }
  182. private void align(string tag)
  183. {
  184. }
  185. public bool CanCloseDialog()
  186. {
  187. return true;
  188. }
  189. public void OnDialogClosed()
  190. {
  191. }
  192. public void OnDialogOpened(IDialogParameters parameters)
  193. {
  194. annotArgs = parameters.GetValue<RedactionAnnotArgs>(ParameterNames.DataModel);
  195. BgColor = annotArgs.BgColor;
  196. LineColor = annotArgs.LineColor;
  197. FontColor = annotArgs.FontColor;
  198. OvertText = annotArgs.Content;
  199. switch (annotArgs.FontFamily.ToString())
  200. {
  201. case "":
  202. FontFamilySelectedIndex = 0;
  203. break;
  204. case "1":
  205. FontFamilySelectedIndex = 1;
  206. break;
  207. case "2":
  208. FontFamilySelectedIndex = 2;
  209. break;
  210. default:
  211. break;
  212. }
  213. }
  214. }
  215. }