FreetextAnnotPropertyViewModel.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. using ComPDFKitViewer;
  2. using ComPDFKitViewer.AnnotEvent;
  3. using PDF_Master.CustomControl.CompositeControl;
  4. using PDF_Master.Model;
  5. using PDF_Master.Model.AnnotPanel;
  6. using PDF_Master.Model.PropertyPanel.AnnotPanel;
  7. using PDF_Master.ViewModels.Tools;
  8. using PDF_Master.ViewModels.Tools.AnnotManager;
  9. using PDFSettings;
  10. using Prism.Commands;
  11. using Prism.Mvvm;
  12. using Prism.Regions;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Threading.Tasks;
  18. using System.Windows;
  19. using System.Windows.Controls;
  20. using System.Windows.Documents;
  21. using System.Windows.Media;
  22. using static Dropbox.Api.UsersCommon.AccountType;
  23. namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
  24. {
  25. public class FreetextAnnotPropertyViewModel : BindableBase, INavigationAware
  26. {
  27. #region 文案
  28. private string T_title;
  29. public string T_Title
  30. {
  31. get { return T_title; }
  32. set
  33. {
  34. SetProperty(ref T_title, value);
  35. }
  36. }
  37. private string T_font;
  38. public string T_Font
  39. {
  40. get { return T_font; }
  41. set
  42. {
  43. SetProperty(ref T_font, value);
  44. }
  45. }
  46. private string T_fill;
  47. public string T_Fill
  48. {
  49. get { return T_fill; }
  50. set
  51. {
  52. SetProperty(ref T_fill, value);
  53. }
  54. }
  55. private void InitString()
  56. {
  57. T_Title = App.MainPageLoader.GetString("FreeText_Title");
  58. T_Font = App.MainPageLoader.GetString("FreeText_Font");
  59. T_Fill = App.MainPageLoader.GetString("FreeText_Fill");
  60. }
  61. #endregion 文案
  62. private FontBoardVm _fontVm = new FontBoardVm(true);
  63. public FontBoardVm FontVm
  64. {
  65. get { return _fontVm; }
  66. set { SetProperty(ref _fontVm, value); }
  67. }
  68. private AnnotCommon _basicVm = new AnnotCommon();
  69. public AnnotCommon BasicVm
  70. {
  71. get { return _basicVm; }
  72. set => SetProperty(ref _basicVm, value);
  73. }
  74. private bool _isFillFreeText = false;
  75. public bool IsFillFreeTextAnnot
  76. {
  77. get { return _isFillFreeText; }
  78. set => SetProperty(ref _isFillFreeText, value);
  79. }
  80. private bool _isCheckedTime = false;
  81. public bool IsCheckedTime
  82. {
  83. get { return _isCheckedTime; }
  84. set => SetProperty(ref _isCheckedTime, value);
  85. }
  86. private ComboDataItem _currrentDateFormat = new ComboDataItem("M/d", "format");
  87. public ComboDataItem CurrrentDateFormat
  88. {
  89. get { return _currrentDateFormat; }
  90. set => SetProperty(ref _currrentDateFormat, value);
  91. }
  92. public List<ComboDataItem> DateFormatItems { get; private set; }
  93. public AnnotAttribEvent AnnotEvent { get; set; }
  94. private FreeTextAnnotArgs Annot;
  95. private AnnotTransfer PropertyPanel;
  96. public DelegateCommand SelectedPresetFontCommand { get; set; }
  97. public DelegateCommand FontFamilyChangedCommand { get; set; }
  98. public DelegateCommand FontStyleWeightChangedCommand { get; set; }
  99. public DelegateCommand<object> SelectedFillOpacityCommand { get; set; }
  100. public DelegateCommand<object> SelectedColorCommand { get; set; }
  101. public DelegateCommand<object> SelectedFillColorCommand { get; set; }
  102. public DelegateCommand FontSizeChangedCommand { get; set; }
  103. public DelegateCommand<object> TextAlignCheckedCommand { get; set; }
  104. public DelegateCommand<object> LineModeCheckedCommand { get; set; }
  105. public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
  106. public DelegateCommand CustomFontStyleCommand { get; set; }
  107. public DelegateCommand ReDefineFontStyleCommand { get; set; }
  108. public DelegateCommand RestoreDefaultStyleCommand { get; set; }
  109. public DelegateCommand DateFormatChangedCommand { get; set; }
  110. public DelegateCommand ShowTimeCheckedChnagedCommand { get; set; }
  111. public event EventHandler<object> LoadPropertyHandler;
  112. public FreetextAnnotPropertyViewModel()
  113. {
  114. InitString();
  115. //文本设置
  116. //预设文本样式
  117. SelectedPresetFontCommand = new DelegateCommand(SelectedPresetFont);
  118. //文本字重、字体
  119. FontStyleWeightChangedCommand = new DelegateCommand(FontStyleWeightChanged);
  120. //字体
  121. FontFamilyChangedCommand = new DelegateCommand(FontFamilyChanged);
  122. //自定义
  123. CustomFontStyleCommand = new DelegateCommand(CustomFontStyle);
  124. //重新定义
  125. ReDefineFontStyleCommand = new DelegateCommand(ReDefineFontStyle);
  126. //恢复默认
  127. RestoreDefaultStyleCommand = new DelegateCommand(RestoreDefaultStyle);
  128. //颜色
  129. SelectedColorCommand = new DelegateCommand<object>(SelectedColor_Command);
  130. //填充颜色
  131. SelectedFillColorCommand = new DelegateCommand<object>(SelectedFillColorChange);
  132. //填充颜色不透明度
  133. SelectedFillOpacityCommand = new DelegateCommand<object>(SelectedFillOpacity);
  134. //大小
  135. FontSizeChangedCommand = new DelegateCommand(FontSizeChanged);
  136. //内容对齐
  137. TextAlignCheckedCommand = new DelegateCommand<object>(TextAlignChecked);
  138. //填写与签名:日期
  139. DateFormatChangedCommand = new DelegateCommand(DateFormatChanged);
  140. ShowTimeCheckedChnagedCommand = new DelegateCommand(ShowTimeCheckedChnaged);
  141. //MVP不上
  142. LineModeCheckedCommand = new DelegateCommand<object>(LineMode_Checked);
  143. SelectedOpacityValueCommand = new DelegateCommand<object>(SelectedOpacityValue);
  144. InitVariable();
  145. }
  146. private void InitVariable()
  147. {
  148. DateFormatItems = new List<ComboDataItem>();
  149. DateFormatItems = TextFont.GetDateFormats();
  150. UpdateDateFormatLists();
  151. InitFillColorItems();
  152. }
  153. private void InitFillColorItems()
  154. {
  155. BasicVm.FillColorItems = AnnotColorList.GetColorList(ColorSelectorType.Fill);
  156. }
  157. private void UpdateDateFormatLists()
  158. {
  159. string strTime = " HH:mm:ss";
  160. foreach (var item in DateFormatItems)
  161. {
  162. if (IsCheckedTime)
  163. strTime = item.ValueStr + " HH:mm:ss";
  164. else
  165. strTime = item.ValueStr;
  166. string stadate = System.DateTime.Now.ToString(strTime);
  167. item.SetContent(stadate);
  168. if (CurrrentDateFormat != null && item.ValueStr == CurrrentDateFormat.ValueStr)
  169. CurrrentDateFormat.SetContent(stadate);
  170. }
  171. CurrrentDateFormat = new ComboDataItem(CurrrentDateFormat.ValueStr, CurrrentDateFormat.Content);
  172. }
  173. private void TextAlignChecked(object obj)
  174. {
  175. if ((string)obj != null)
  176. {
  177. switch ((string)obj)
  178. {
  179. case "AlignLeft":
  180. GetAnnotAlign(TextAlignment.Left);
  181. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.TextAlign, TextAlignment.Left);
  182. break;
  183. case "AlignCenter":
  184. GetAnnotAlign(TextAlignment.Center);
  185. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.TextAlign, TextAlignment.Center);
  186. break;
  187. case "AlignRight":
  188. GetAnnotAlign(TextAlignment.Right);
  189. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.TextAlign, TextAlignment.Right);
  190. break;
  191. case "Justify":
  192. GetAnnotAlign(TextAlignment.Justify);
  193. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.TextAlign, TextAlignment.Justify);
  194. break;
  195. }
  196. }
  197. }
  198. private void LineMode_Checked(object obj)
  199. {
  200. if (obj != null)
  201. {
  202. var tag = ((string)obj);
  203. switch (tag)
  204. {
  205. case "Dashed":
  206. AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Dash);
  207. break;
  208. case "Solid":
  209. AnnotEvent?.UpdateAttrib(AnnotAttrib.LineStyle, DashStyles.Solid);
  210. break;
  211. }
  212. AnnotEvent?.UpdateAnnot();
  213. }
  214. }
  215. //从预设样式设置文本
  216. private void SelectedPresetFont()
  217. {
  218. if (FontVm.CurrentPresetFont != null)
  219. {
  220. var itemComboxItem = FontVm.CurrentPresetFont;
  221. var item = FontVm.PresetFontList.FirstOrDefault(temp => temp.mTag == itemComboxItem.ValueStr);
  222. if (item != null)
  223. {
  224. FontVm.GetCurrentFontSize(item.mFontSize);
  225. if (item.mFontFamily != null)
  226. {
  227. FontVm.GetCurrentFontFamily(item.mFontFamily.ToString(), item.mFontFamily.ToString());
  228. }
  229. FontVm.GetFontWeights_Style(item.mFontStyle, item.mFontWeight);
  230. Dictionary<AnnotAttrib, object> AnnotAttribDir = new Dictionary<AnnotAttrib, object>();
  231. AnnotAttribDir.Add(AnnotAttrib.FontSize, item.mFontSize);
  232. AnnotAttribDir.Add(AnnotAttrib.FontFamily, item.mFontFamily);
  233. AnnotAttribDir.Add(AnnotAttrib.FontStyle, item.mFontStyle);
  234. AnnotAttribDir.Add(AnnotAttrib.FontWeight, item.mFontWeight);
  235. PropertyPanel.UpdateAnnotAllAttribs(AnnotAttribDir);
  236. }
  237. }
  238. }
  239. //设置文本字重、样式
  240. private void FontStyleWeightChanged()
  241. {
  242. if (FontVm.CurrrentFontWeightStyle != null)
  243. {
  244. FontVm.UpdateFontWeight_Style();
  245. Dictionary<AnnotAttrib, object> AnnotAttribDir = new Dictionary<AnnotAttrib, object>();
  246. AnnotAttribDir.Add(AnnotAttrib.FontStyle, FontVm.FontStyleItem);
  247. AnnotAttribDir.Add(AnnotAttrib.FontWeight, FontVm.FontWeightItem);
  248. PropertyPanel.UpdateAnnotAllAttribs(AnnotAttribDir);
  249. }
  250. }
  251. private void SelectedFillOpacity(object obj)
  252. {
  253. if (obj != null)
  254. {
  255. BasicVm.FillOpacity = (double)obj;
  256. BasicVm.FillColor.Opacity = BasicVm.FillOpacity;
  257. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
  258. }
  259. }
  260. /// <summary>
  261. /// 设置颜色透明度
  262. /// </summary>
  263. /// <param name="obj"></param>
  264. private void SelectedOpacityValue(object obj)
  265. {
  266. if (obj != null && obj is double)
  267. {
  268. BasicVm.FillOpacity = (double)obj;
  269. BasicVm.FillColor.Opacity = BasicVm.FillOpacity;
  270. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
  271. }
  272. }
  273. //设置字体大小
  274. private void FontSizeChanged()
  275. {
  276. if (FontVm.CurrentFontSize != null)
  277. {
  278. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.FontSize, FontVm.CurrentFontSize.Value);
  279. //if (BasicVm.IsMultiSelected == false)
  280. // PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, Annot);
  281. }
  282. }
  283. //设置字体样式
  284. private void FontFamilyChanged()
  285. {
  286. if (string.IsNullOrEmpty(FontVm.CurrentFontFamily.ValueStr) == false)
  287. {
  288. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.FontFamily, new FontFamily(FontVm.CurrentFontFamily.ValueStr));
  289. }
  290. }
  291. private void SelectedFillColorChange(object obj)
  292. {
  293. if (obj != null)
  294. {
  295. var colorValue = (Color)obj;
  296. if (colorValue != null)
  297. {
  298. BasicVm.FillColor = new SolidColorBrush(colorValue);
  299. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.FillColor, colorValue);
  300. // BasicVm.FillColor.Opacity = BasicVmFillOpacity;
  301. }
  302. }
  303. }
  304. private void SelectedColor_Command(object obj)
  305. {
  306. if (obj != null)
  307. {
  308. var colorValue = (Color)obj;
  309. if (colorValue != null)
  310. {
  311. FontVm.FontColor = new SolidColorBrush(colorValue);
  312. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.FontColor, colorValue);
  313. }
  314. }
  315. }
  316. private void CustomFontStyle()
  317. {
  318. if (FontVm.CurrentPresetFont != null)
  319. {
  320. ContextMenu menu;
  321. if (FontVm.CurrentPresetFont.ValueStr == "Custom")
  322. {
  323. menu = SelectAnnotContextMenu(false);
  324. }
  325. else
  326. {
  327. menu = SelectAnnotContextMenu(true);
  328. }
  329. if (menu != null)
  330. {
  331. menu.IsOpen = true;
  332. }
  333. }
  334. }
  335. private ContextMenu SelectAnnotContextMenu(bool isEnable)
  336. {
  337. var popMenu = App.Current.FindResource("CustomFontStyleFlyoutMenu") as ContextMenu;
  338. if (popMenu != null && popMenu.Items.Count == 2)
  339. {
  340. //用所选部分重新定义
  341. MenuItem menuItem = popMenu.Items[0] as MenuItem;
  342. menuItem.IsEnabled = isEnable;
  343. menuItem.Command = ReDefineFontStyleCommand;
  344. //恢复默认预设样式
  345. menuItem = popMenu.Items[1] as MenuItem;
  346. menuItem.IsEnabled = isEnable;
  347. menuItem.Command = RestoreDefaultStyleCommand;
  348. }
  349. return popMenu;
  350. }
  351. public List<PresetFontItem> FontStyleList = new List<PresetFontItem>();
  352. /// <summary>
  353. /// 重新定义
  354. /// </summary>
  355. private void ReDefineFontStyle()
  356. {
  357. var item = FontVm.PresetFontList.FirstOrDefault(temp => temp.mTag == FontVm.CurrentPresetFont.ValueStr);
  358. if (item == null) return;
  359. item.mFontFamily = new FontFamily(FontVm.CurrentFontFamily.ValueStr);
  360. if (FontVm.CurrrentFontWeightStyle.ValueStr == "Bold")
  361. {
  362. item.mFontStyle = FontStyles.Normal;
  363. item.mFontWeight = FontWeights.Bold;
  364. }
  365. else if (FontVm.CurrrentFontWeightStyle.ValueStr == "Regular")
  366. {
  367. item.mFontStyle = FontStyles.Normal;
  368. item.mFontWeight = FontWeights.Normal;
  369. }
  370. else if (FontVm.CurrrentFontWeightStyle.ValueStr == "Italic")
  371. {
  372. item.mFontStyle = FontStyles.Italic;
  373. item.mFontWeight = FontWeights.Normal;
  374. }
  375. else
  376. {
  377. item.mFontStyle = FontStyles.Italic;
  378. item.mFontWeight = FontWeights.Bold;
  379. }
  380. item.mFontSize = (int)FontVm.CurrentFontSize.Value;
  381. FontVm.CurrentPresetFont = new ComboDataItem(item.mTag, item.mTagContent);
  382. SelectedPresetFont();
  383. //if (BasicVm.IsMultiSelected == false)
  384. // PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, Annot);
  385. }
  386. private void RestoreDefaultStyle()
  387. {
  388. var defaultlists = TextFont.GetPresetFontStyle();
  389. if (FontVm.CurrentPresetFont.ValueStr != "Custom")
  390. {
  391. var defaulItem = defaultlists.FirstOrDefault(temp => temp.mTag == FontVm.CurrentPresetFont.ValueStr);
  392. if (defaulItem != null)
  393. {
  394. var currentItem = FontVm.PresetFontList.FirstOrDefault(temp => temp.mTag == FontVm.CurrentPresetFont.ValueStr);
  395. if (currentItem != null)
  396. {
  397. currentItem.mTagContent = defaulItem.mTagContent;
  398. currentItem.mFontStyle = defaulItem.mFontStyle;
  399. currentItem.mFontWeight = defaulItem.mFontWeight;
  400. currentItem.mFontFamily = defaulItem.mFontFamily;
  401. currentItem.mFontSize = defaulItem.mFontSize;
  402. FontVm.GetCurrentFontFamily(currentItem.mFontFamily.ToString(), currentItem.mFontFamily.ToString());
  403. FontVm.GetCurrentFontSize(currentItem.mFontSize);
  404. FontVm.GetFontWeights_Style(currentItem.mFontStyle, currentItem.mFontWeight);
  405. FontVm.CurrentPresetFont = new ComboDataItem(defaulItem.mTag, defaulItem.mTagContent);
  406. SelectedPresetFont();
  407. }
  408. }
  409. }
  410. }
  411. private void DateFormatChanged()
  412. {
  413. if (CurrrentDateFormat != null)
  414. {
  415. if (IsCheckedTime)
  416. UpdateDateFormatLists();
  417. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.NoteText, CurrrentDateFormat.Content);
  418. }
  419. }
  420. private void ShowTimeCheckedChnaged()
  421. {
  422. if (CurrrentDateFormat != null)
  423. {
  424. UpdateDateFormatLists();
  425. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.NoteText, CurrrentDateFormat.Content);
  426. }
  427. }
  428. public bool IsNavigationTarget(NavigationContext navigationContext)
  429. {
  430. return true;
  431. }
  432. public void OnNavigatedFrom(NavigationContext navigationContext)
  433. {
  434. BasicVm.IsMultiSelected = false;
  435. // IsCheckedTime = false;
  436. }
  437. public void OnNavigatedTo(NavigationContext navigationContext)
  438. {
  439. navigationContext.Parameters.TryGetValue<AnnotTransfer>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
  440. if (PropertyPanel != null)
  441. {
  442. AnnotEvent = PropertyPanel.AnnotEvent;
  443. Annot = PropertyPanel.annot as FreeTextAnnotArgs;
  444. LoadPropertyHandler?.Invoke(this, Annot);
  445. BasicVm.AnnotType = PropertyPanel.annot.EventType;
  446. BasicVm.AnnotTypeTitle = "文字";
  447. BasicVm.IsMultiSelected = PropertyPanel.IsMultiSelected;
  448. IsFillFreeTextAnnot = PropertyPanel.IsTextFill;
  449. if (BasicVm.IsMultiSelected)
  450. {
  451. IsAttributeEquals();
  452. BasicVm.IsSolidLine = BasicVm.IsDashLine = false;
  453. }
  454. else
  455. {
  456. GetAnnotProperty();
  457. }
  458. IsFillFreeTextAnnot = PropertyPanel.IsTextFill;
  459. }
  460. }
  461. /// <summary>
  462. /// 多选的注释
  463. /// </summary>
  464. private List<FreeTextAnnotArgs> ConvertLists()
  465. {
  466. List<FreeTextAnnotArgs> FreeTextLists = new List<FreeTextAnnotArgs>();
  467. foreach (var item in PropertyPanel.annotlists)
  468. {
  469. var itemFreeText = item as FreeTextAnnotArgs;
  470. if (itemFreeText != null)
  471. {
  472. FreeTextLists.Add(itemFreeText);
  473. }
  474. }
  475. if (FreeTextLists.Count != PropertyPanel.annotlists.Count)
  476. return null;
  477. else
  478. return FreeTextLists;
  479. }
  480. private void IsAttributeEquals()
  481. {
  482. var list = ConvertLists();
  483. if (list != null)
  484. {
  485. var temp = list[0];
  486. Dictionary<string, bool> isNoEqualsDir = new Dictionary<string, bool>();
  487. isNoEqualsDir.Add("FontFamily", false);
  488. isNoEqualsDir.Add("FontSize", false);
  489. isNoEqualsDir.Add("FontStyleFontWeight", false);
  490. isNoEqualsDir.Add("FontColor", false);
  491. isNoEqualsDir.Add("FillColor", false);
  492. isNoEqualsDir.Add("TextAglin", false);
  493. foreach (var item in list)
  494. {
  495. if (item == list[0])
  496. continue;
  497. if (temp.Align != item.Align)
  498. {
  499. isNoEqualsDir["TextAglin"] = true;
  500. FontVm.StrTextAlign = "None";
  501. }
  502. if (temp.FontFamily != item.FontFamily)
  503. {
  504. isNoEqualsDir["FontFamily"] = true;
  505. FontVm.CurrentFontFamily = null;
  506. }
  507. if (temp.FontSize != item.FontSize)
  508. {
  509. isNoEqualsDir["FontSize"] = true;
  510. FontVm.CurrentFontSize = null;
  511. }
  512. if (temp.FontStyle != item.FontStyle || temp.FontWeight != item.FontWeight)
  513. {
  514. isNoEqualsDir["FontStyleFontWeight"] = true;
  515. FontVm.CurrrentFontWeightStyle = null;
  516. }
  517. if (isNoEqualsDir["FontFamily"] == true || isNoEqualsDir["FontSize"] == true || isNoEqualsDir["FontStyleFontWeight"] == true)
  518. {
  519. FontVm.CurrentPresetFont = null;
  520. }
  521. if (isNoEqualsDir["FontColor"] == false)
  522. {
  523. if (temp.FontColor.A != item.FontColor.A || temp.FontColor.R != item.FontColor.R || temp.FontColor.G != item.FontColor.G || temp.FontColor.B != item.FontColor.B)
  524. {
  525. FontVm.FontColor = new SolidColorBrush(Color.FromArgb(0x01, 0xff, 0xff, 0xff));
  526. isNoEqualsDir["FontColor"] = true;
  527. }
  528. }
  529. if (isNoEqualsDir["FillColor"] == false)
  530. {
  531. if (temp.BgColor.A != item.BgColor.A || temp.BgColor.R != item.BgColor.R || temp.BgColor.G != item.BgColor.G || temp.BgColor.B != item.BgColor.B)
  532. {
  533. BasicVm.FillColor = new SolidColorBrush(Color.FromArgb(0x01, 0xff, 0xff, 0xff));
  534. isNoEqualsDir["FillColor"] = true;
  535. }
  536. }
  537. }
  538. ////以下是多选注释的属性相等时
  539. if (isNoEqualsDir["TextAglin"] == false)
  540. {
  541. GetAnnotAlign(temp.Align);
  542. }
  543. if (isNoEqualsDir["FontFamily"] == false)
  544. {
  545. FontVm.GetCurrentFontFamily(temp.FontFamily.ToString(), temp.FontFamily.ToString());
  546. }
  547. if (isNoEqualsDir["FontSize"] == false)
  548. {
  549. FontVm.GetCurrentFontSize((int)temp.FontSize);
  550. }
  551. if (isNoEqualsDir["FontStyleFontWeight"] == false)
  552. {
  553. FontVm.GetFontWeights_Style(temp.FontStyle, temp.FontWeight);
  554. }
  555. if (isNoEqualsDir["FontColor"] == false)
  556. {
  557. FontVm.FontColor = new SolidColorBrush(temp.FontColor);
  558. }
  559. if (isNoEqualsDir["FillColor"] == false)
  560. {
  561. FontVm.FontColor = new SolidColorBrush(temp.BgColor);
  562. }
  563. }
  564. }
  565. private void GetAnnotProperty()
  566. {
  567. BasicVm.FillColor = new SolidColorBrush(Annot.BgColor);
  568. BasicVm.FillOpacity = Annot.Transparency;
  569. FontVm.FontColor = new SolidColorBrush(Annot.FontColor);
  570. FontVm.GetCurrentFontSize((int)Annot.FontSize);
  571. FontVm.GetCurrentPresetFont(Annot);
  572. FontVm.GetCurrentFontFamily(Annot.FontFamily.ToString(), Annot.FontFamily.ToString());
  573. FontVm.GetFontWeights_Style(Annot.FontStyle, Annot.FontWeight);
  574. GetTimeFormat();
  575. GetAnnotAlign(Annot.Align);
  576. }
  577. //填写与签名
  578. private void GetTimeFormat()
  579. {
  580. if (IsFillFreeTextAnnot == false)
  581. return;
  582. if (string.IsNullOrEmpty(Annot.TextContent))
  583. {
  584. if (CurrrentDateFormat != null)
  585. {
  586. if (IsCheckedTime)
  587. UpdateDateFormatLists();
  588. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.NoteText, CurrrentDateFormat.Content);
  589. }
  590. return;
  591. }
  592. DateTime dtDate;
  593. bool isTime = false;
  594. foreach (var item in DateFormatItems)
  595. {
  596. var strFormat = "";
  597. var strArr = Annot.TextContent.Split(' ');
  598. if (strArr != null && strArr.Count() == 2)
  599. {
  600. strFormat = item.ValueStr + " HH:mm:ss";
  601. }
  602. else
  603. {
  604. strFormat = item.ValueStr;
  605. }
  606. if (DateTime.TryParseExact(Annot.TextContent, strFormat, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AdjustToUniversal, out dtDate))
  607. {
  608. if (strArr != null && strArr.Count() == 2)
  609. {
  610. isTime = true;
  611. }
  612. foreach (var item2 in DateFormatItems)
  613. {
  614. string stadate = System.DateTime.Now.ToString(strFormat);
  615. item.SetContent(stadate);
  616. }
  617. CurrrentDateFormat = new ComboDataItem(item.ValueStr, item.Content);
  618. break;
  619. }
  620. }
  621. IsCheckedTime = isTime;
  622. }
  623. //文本内容对齐
  624. private void GetAnnotAlign(TextAlignment align)
  625. {
  626. switch (align)
  627. {
  628. case TextAlignment.Left:
  629. FontVm.StrTextAlign = "Left";
  630. break;
  631. case TextAlignment.Center:
  632. FontVm.StrTextAlign = "Center";
  633. break;
  634. case TextAlignment.Right:
  635. FontVm.StrTextAlign = "Right";
  636. break;
  637. case TextAlignment.Justify:
  638. FontVm.StrTextAlign = "Justify";
  639. break;
  640. default:
  641. FontVm.StrTextAlign = "None";
  642. break;
  643. }
  644. }
  645. }
  646. }