FreetextAnnotPropertyViewModel.cs 24 KB

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