SharpsAnnotPropertyViewModel.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. using ComPDFKit.PDFAnnotation;
  2. using ComPDFKitViewer;
  3. using ComPDFKitViewer.AnnotEvent;
  4. using ComPDFKitViewer.PdfViewer;
  5. using ImTools;
  6. using PDF_Master.CustomControl.CompositeControl;
  7. using PDF_Master.Helper;
  8. using PDF_Master.Model;
  9. using PDF_Master.Model.AnnotPanel;
  10. using PDF_Master.Properties;
  11. using PDF_Master.ViewModels.Tools;
  12. using PDF_Master.ViewModels.Tools.AnnotManager;
  13. using PDF_Master.Views.Tools;
  14. using PDFSettings;
  15. using Prism.Commands;
  16. using Prism.Mvvm;
  17. using Prism.Regions;
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Drawing;
  21. using System.Globalization;
  22. using System.Linq;
  23. using System.Text;
  24. using System.Threading.Tasks;
  25. using System.Windows;
  26. using System.Windows.Controls;
  27. using System.Windows.Data;
  28. using System.Windows.Media;
  29. using static Dropbox.Api.UsersCommon.AccountType;
  30. using Color = System.Windows.Media.Color;
  31. using Point = System.Windows.Point;
  32. namespace PDF_Master.ViewModels.PropertyPanel.AnnotPanel
  33. {
  34. public class DashStyleConverter : IValueConverter
  35. {
  36. public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
  37. {
  38. if (value is DashStyle)
  39. {
  40. var dash = value as DashStyle;
  41. if (dash.Dashes == null || dash.Dashes.Count == 0 || dash.Dashes[0] == 0)
  42. {
  43. return DashStyles.Solid.Dashes;
  44. }
  45. else
  46. {
  47. DashStyle dashx = new DashStyle();
  48. dashx.Dashes.Add(1);
  49. dashx.Dashes.Add(1);
  50. return dashx.Dashes;
  51. }
  52. }
  53. return value;
  54. }
  55. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
  56. {
  57. throw new NotImplementedException();
  58. }
  59. }
  60. public class SharpsAnnotPropertyViewModel : BindableBase, INavigationAware
  61. {
  62. #region 属性
  63. private bool isRect = false;
  64. public bool IsRect
  65. {
  66. get { return isRect; }
  67. set => SetProperty(ref isRect, value);
  68. }
  69. private bool isCircle = false;
  70. public bool IsCircle
  71. {
  72. get { return isCircle; }
  73. set => SetProperty(ref isCircle, value);
  74. }
  75. private bool isArrow = false;
  76. public bool IsArrow
  77. {
  78. get { return isArrow; }
  79. set => SetProperty(ref isArrow, value);
  80. }
  81. private bool isLine = false;
  82. public bool IsLine
  83. {
  84. get { return isLine; }
  85. set => SetProperty(ref isLine, value);
  86. }
  87. private string _strShapeChecked = "";
  88. public string StrShapeChecked
  89. {
  90. get { return _strShapeChecked; }
  91. set
  92. {
  93. SetProperty(ref _strShapeChecked, value);
  94. }
  95. }
  96. public List<ComboDataItem> ThicknessItems { get; protected set; }
  97. private AnnotCommon _basicVm = new AnnotCommon();
  98. public AnnotCommon BasicVm
  99. {
  100. get { return _basicVm; }
  101. set => SetProperty(ref _basicVm, value);
  102. }
  103. private Geometry dataPath = null;
  104. public Geometry DataPath
  105. {
  106. get { return dataPath; }
  107. set
  108. {
  109. SetProperty(ref dataPath, value);
  110. }
  111. }
  112. private DashStyle dash = new DashStyle();
  113. public DashStyle Dash
  114. {
  115. get { return dash; }
  116. set
  117. {
  118. SetProperty(ref dash, value);
  119. }
  120. }
  121. private bool _isLineAnnot = false;
  122. public bool IsLineAnnot
  123. {
  124. get { return _isLineAnnot; }
  125. set
  126. {
  127. SetProperty(ref _isLineAnnot, value);
  128. }
  129. }
  130. #endregion 属性
  131. public DelegateCommand<object> SelectedThickCommand { get; set; }
  132. public DelegateCommand<object> SelectedBorderColorCommand { get; set; }
  133. public DelegateCommand<object> SelectedFillOpacityCommand { get; set; }
  134. public DelegateCommand<object> SelectedFillColorCommand { get; set; }
  135. public DelegateCommand<object> LineStyleCommand { get; set; }
  136. public DelegateCommand<object> SharpsTypeCommand { get; set; }
  137. public DelegateCommand<object> ThicknessChangedCommand { get; set; }
  138. public DelegateCommand<object> SelectedOpacityValueCommand { get; set; }
  139. public event EventHandler<object> LoadPropertyHandler;
  140. public IRegionManager region;
  141. public SharpsAnnotPropertyViewModel(IRegionManager regionManager)
  142. {
  143. region = regionManager;
  144. InitColorItems();
  145. InitFillColorItems();
  146. InitThicknessItems();
  147. SharpsTypeCommand = new DelegateCommand<object>(SharpsType_Command);
  148. SelectedFillOpacityCommand = new DelegateCommand<object>(SelectedFillOpacity_Command);
  149. SelectedFillColorCommand = new DelegateCommand<object>(SelectedFillColor_Command);
  150. SelectedThickCommand = new DelegateCommand<object>(SelectedThick_Command);
  151. SelectedBorderColorCommand = new DelegateCommand<object>(SelectedBorderColor);
  152. SelectedOpacityValueCommand = new DelegateCommand<object>(SelectedOpacityValue);
  153. ThicknessChangedCommand = new DelegateCommand<object>(ThicknessChanged_Command);
  154. LineStyleCommand = new DelegateCommand<object>(LineStyle_Command);
  155. }
  156. private void InitThicknessItems()
  157. {
  158. ThicknessItems = new List<ComboDataItem>();
  159. ComboDataItem item = new ComboDataItem(1, "pt");
  160. ThicknessItems.Add(item);
  161. item = new ComboDataItem(2, "pt");
  162. ThicknessItems.Add(item);
  163. item = new ComboDataItem(4, "pt");
  164. ThicknessItems.Add(item);
  165. item = new ComboDataItem(6, "pt");
  166. ThicknessItems.Add(item);
  167. item = new ComboDataItem(8, "pt");
  168. ThicknessItems.Add(item);
  169. }
  170. private void InitColorItems()
  171. {
  172. BasicVm.ColorItems = AnnotColorList.GetColorList(ColorSelectorType.Border);
  173. }
  174. private void InitFillColorItems()
  175. {
  176. BasicVm.FillColorItems = AnnotColorList.GetColorList(ColorSelectorType.Fill);
  177. }
  178. private void ThicknessChanged_Command(object obj)
  179. {
  180. if (obj != null)
  181. {
  182. var item = (ComboBoxItem)obj;
  183. var content = (string)item.Content;
  184. if (content != null)
  185. {
  186. var intData = int.Parse(content);
  187. BasicVm.AnnotThickness = intData;
  188. }
  189. }
  190. }
  191. private void SharpsType_Command(object obj)
  192. {
  193. if (obj != null)
  194. {
  195. var tag = (string)obj;
  196. SharpsType(tag, true);
  197. }
  198. }
  199. private void SharpsType(string tag, bool isFromToolsBtn = false)
  200. {
  201. Dictionary<AnnotArgsType, object> changeData = new Dictionary<AnnotArgsType, object>();
  202. switch (tag)
  203. {
  204. case "Rect":
  205. RectangleGeometry rectPath = new RectangleGeometry();
  206. rectPath.Rect = new Rect(0, 5, 28, 22);
  207. DataPath = rectPath;
  208. changeData[AnnotArgsType.AnnotSquare] = tag;
  209. IsLineAnnot = false;
  210. break;
  211. case "Circle":
  212. EllipseGeometry circlePath = new EllipseGeometry();
  213. circlePath.RadiusX = 14;
  214. circlePath.RadiusY = 14;
  215. circlePath.Center = new Point(14, 14);
  216. DataPath = circlePath;
  217. changeData[AnnotArgsType.AnnotCircle] = tag;
  218. IsLineAnnot = false;
  219. break;
  220. case "Arrow":
  221. {
  222. ArrowHelper arrowLine = new ArrowHelper();
  223. arrowLine.ArrowLength = 8;
  224. arrowLine.LineStart = new Point(8, 24);
  225. arrowLine.LineEnd = new Point(24, 8);
  226. arrowLine.StartSharp = C_LINE_TYPE.LINETYPE_NONE;
  227. arrowLine.EndSharp = C_LINE_TYPE.LINETYPE_ARROW;
  228. DataPath = arrowLine.BuildArrowBody();
  229. changeData[AnnotArgsType.AnnotLine] = tag;
  230. if (IsLineAnnot == false)
  231. IsLineAnnot = true;
  232. }
  233. break;
  234. case "Line":
  235. {
  236. ArrowHelper arrowLine = new ArrowHelper();
  237. arrowLine.LineStart = new Point(0, 32);
  238. arrowLine.LineEnd = new Point(32, 0);
  239. DataPath = arrowLine.BuildArrowBody();
  240. changeData[AnnotArgsType.AnnotLine] = tag;
  241. if (IsLineAnnot == false)
  242. IsLineAnnot = true;
  243. }
  244. break;
  245. }
  246. if (isFromToolsBtn)
  247. PropertyPanel.AnnotTypeChangedInvoke(this, changeData);
  248. StrShapeChecked = tag;
  249. PropertyPanel.SharpsAnnot = tag;
  250. BasicVm.SetOtherTag(tag);
  251. }
  252. private void LineStyle_Command(object obj)
  253. {
  254. if (obj != null)
  255. {
  256. var tag = obj as string;
  257. if (tag == "Solid")
  258. {
  259. DashStyle dashAnnot = new DashStyle();
  260. dashAnnot.Dashes.Add(0);
  261. dashAnnot.Dashes.Add(0);
  262. Dash = dashAnnot;
  263. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.LineStyle, DashStyles.Solid);
  264. }
  265. else
  266. {
  267. DashStyle dashAnnot = new DashStyle();
  268. dashAnnot.Dashes.Add(1);
  269. dashAnnot.Dashes.Add(1);
  270. Dash = dashAnnot;
  271. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.LineStyle, dash);
  272. }
  273. if (BasicVm.IsMultiSelected == false)
  274. PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, Annot);
  275. }
  276. }
  277. private void SelectedFillColor_Command(object obj)
  278. {
  279. if (obj != null && PropertyPanel != null)
  280. {
  281. //点击空白处 后 会 清空当前的注释对象 ,此操作为了修改属性后,添加
  282. GetLastAnnot();
  283. var colorValue = (Color)obj;
  284. if (colorValue != null)
  285. {
  286. BasicVm.FillColor = new SolidColorBrush(colorValue);
  287. BasicVm.FillColor.Opacity = BasicVm.FillOpacity;
  288. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.FillColor, colorValue);
  289. if (BasicVm.IsMultiSelected == false)
  290. PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, Annot);
  291. }
  292. }
  293. }
  294. private void GetLastAnnot()
  295. {
  296. if (PropertyPanel.annot == null)
  297. {
  298. AnnotHandlerEventArgs annotArgs = null;
  299. bool isLastAnnot = (PropertyPanel.LastArrowAnnot != null ? true : false);
  300. switch (PropertyPanel.SharpsAnnot)
  301. {
  302. case "Rect":
  303. annotArgs = PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotSquare];
  304. break;
  305. case "Circle":
  306. annotArgs = PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotCircle];
  307. break;
  308. case "Arrow":
  309. if (isLastAnnot)
  310. {
  311. annotArgs = PropertyPanel.LastArrowAnnot;
  312. }
  313. break;
  314. case "Line":
  315. annotArgs = PropertyPanel.LastAnnotDict[AnnotArgsType.AnnotLine];
  316. break;
  317. }
  318. annotArgs.PageIndex = -1;
  319. annotArgs.AnnotIndex = -1;
  320. annotArgs.ClientRect = Rect.Empty;
  321. PropertyPanel.annot = annotArgs;
  322. Annot = annotArgs;
  323. PropertyPanel.annotlists = new List<AnnotHandlerEventArgs>();
  324. PropertyPanel.annotlists.Add(PropertyPanel.annot);
  325. PropertyPanel.AnnotEvent = AnnotAttribEvent.GetAnnotAttribEvent(Annot, Annot.GetAnnotAttrib());
  326. }
  327. }
  328. private void SelectedFillOpacity_Command(object obj)
  329. {
  330. if (obj != null)
  331. {
  332. //点击空白处 后 会 清空当前的注释对象 ,此操作为了修改属性后,添加
  333. GetLastAnnot();
  334. BasicVm.FillOpacity = (double)obj;
  335. BasicVm.FillColor.Opacity = BasicVm.FillOpacity;
  336. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
  337. PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, BasicVm.FillOpacity);
  338. }
  339. }
  340. private void SelectedOpacityValue(object obj)
  341. {
  342. if (obj != null)
  343. {
  344. //点击空白处 后 会 清空当前的注释对象 ,此操作为了修改属性后,添加
  345. GetLastAnnot();
  346. BasicVm.FillOpacity = (double)obj;
  347. BasicVm.FillColor.Opacity = BasicVm.FillOpacity;
  348. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Transparency, BasicVm.FillOpacity);
  349. PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, BasicVm.FillOpacity);
  350. }
  351. }
  352. private void SelectedBorderColor(object obj)
  353. {
  354. if (obj != null && PropertyPanel != null)
  355. {
  356. //点击空白处 后 会 清空当前的注释对象 ,此操作为了修改属性后,添加
  357. GetLastAnnot();
  358. var colorValue = (Color)obj;
  359. if (colorValue != null)
  360. {
  361. BasicVm.BorderColor = new SolidColorBrush(colorValue);
  362. BasicVm.BorderColor.Opacity = BasicVm.BorderOpacity;
  363. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Color, colorValue);
  364. if (BasicVm.IsMultiSelected == false)
  365. PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, Annot);
  366. }
  367. }
  368. }
  369. private void SelectedThick_Command(object obj)
  370. {
  371. if (obj is double)
  372. {
  373. //点击空白处 后 会 清空当前的注释对象 ,此操作为了修改属性后,添加
  374. //GetLastAnnot();
  375. var tran = (double)obj;
  376. AnnotArgsType argsType = AnnotArgsType.AnnotSquare;
  377. bool isLine = false;
  378. switch (BasicVm.strOtherTag)
  379. {
  380. case "Rect":
  381. argsType = AnnotArgsType.AnnotSquare;
  382. break;
  383. case "Circle":
  384. argsType = AnnotArgsType.AnnotCircle;
  385. break;
  386. case "Line":
  387. argsType = AnnotArgsType.AnnotLine;
  388. isLine = true;
  389. break;
  390. case "Arrow":
  391. argsType = AnnotArgsType.AnnotLine;
  392. isLine = false;
  393. break;
  394. }
  395. if (BasicVm.IsMultiSelected == false)
  396. {
  397. if (argsType == BasicVm.AnnotType)
  398. {
  399. //if(argsType== AnnotArgsType.AnnotLine && isLine)
  400. BasicVm.AnnotThickness = tran;
  401. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, tran);
  402. }
  403. PropertyPanel.InvokeToMyTools(BasicVm.AnnotType, Annot);
  404. }
  405. else
  406. {
  407. BasicVm.AnnotThickness = tran;
  408. PropertyPanel.UpdateAnnotAAttrib(AnnotAttrib.Thickness, tran);
  409. }
  410. }
  411. }
  412. public bool IsNavigationTarget(NavigationContext navigationContext)
  413. {
  414. return true;
  415. }
  416. public void OnNavigatedFrom(NavigationContext navigationContext)
  417. {
  418. BasicVm.IsMultiSelected = false;
  419. //PropertyPanel.annot = null;
  420. //PropertyPanel.AnnotEvents = null;
  421. //PropertyPanel.AnnotEvent = null;
  422. //PropertyPanel.annotlists = null;
  423. //AnnotEvent = null;
  424. //Annot = null;
  425. }
  426. private void SetAnnotType()
  427. {
  428. switch (BasicVm.AnnotType)
  429. {
  430. case AnnotArgsType.AnnotCircle:
  431. BasicVm.AnnotTypeTitle = "圆";
  432. break;
  433. case AnnotArgsType.AnnotSquare:
  434. BasicVm.AnnotTypeTitle = "矩形";
  435. break;
  436. case AnnotArgsType.AnnotLine:
  437. var annotLine = Annot as LineAnnotArgs;
  438. if (annotLine != null)
  439. {
  440. if (annotLine.TailLineType == C_LINE_TYPE.LINETYPE_ARROW && annotLine.HeadLineType == C_LINE_TYPE.LINETYPE_NONE)
  441. BasicVm.AnnotTypeTitle = "箭头";
  442. else
  443. BasicVm.AnnotTypeTitle = "线";
  444. }
  445. break;
  446. }
  447. }
  448. public AnnotAttribEvent AnnotEvent { get; set; }
  449. public AnnotHandlerEventArgs Annot;
  450. public AnnotTransfer PropertyPanel;
  451. public ViewContentViewModel ViewContentViewModel;
  452. public void OnNavigatedTo(NavigationContext navigationContext)
  453. {
  454. navigationContext.Parameters.TryGetValue<AnnotTransfer>(ParameterNames.PropertyPanelContentViewModel, out PropertyPanel);
  455. navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out ViewContentViewModel);
  456. if (PropertyPanel != null)
  457. {
  458. AnnotEvent = PropertyPanel.AnnotEvent;
  459. BasicVm.AnnotType = PropertyPanel.annot.EventType;
  460. Annot = PropertyPanel.annot;
  461. BasicVm.IsMultiSelected = PropertyPanel.IsMultiSelected;
  462. if (BasicVm.IsMultiSelected)
  463. {
  464. IsAttributeEquals();
  465. }
  466. else
  467. {
  468. GetAnnotProperty();
  469. }
  470. LoadPropertyHandler?.Invoke(null, Annot);
  471. }
  472. }
  473. private List<AnnotHandlerEventArgs> ConvertLists()
  474. {
  475. List<AnnotHandlerEventArgs> FreeTextLists = new List<AnnotHandlerEventArgs>();
  476. foreach (var item in PropertyPanel.annotlists)
  477. {
  478. var itemFreeText = item as AnnotHandlerEventArgs;
  479. if (itemFreeText != null)
  480. {
  481. FreeTextLists.Add(itemFreeText);
  482. }
  483. }
  484. if (FreeTextLists.Count != PropertyPanel.annotlists.Count)
  485. return null;
  486. else
  487. return FreeTextLists;
  488. }
  489. private void IsAttributeEquals()
  490. {
  491. int isAnnotArgs = 0;
  492. CircleAnnotArgs args = new CircleAnnotArgs();
  493. SquareAnnotArgs argsSquare = new SquareAnnotArgs();
  494. LineAnnotArgs argsLine = new LineAnnotArgs();
  495. var list = ConvertLists();
  496. Color LineColor = Color.FromArgb(0x01, 0xff, 0xff, 0xff);
  497. Color BgColor = Color.FromArgb(0x01, 0xff, 0xff, 0xff);
  498. double LineWidth=2;
  499. DashStyle LineDash=new DashStyle();
  500. Color LineColoritem = Color.FromArgb(0x01, 0xff, 0xff, 0xff);
  501. Color BgColoritem= Color.FromArgb(0x01, 0xff, 0xff, 0xff);
  502. double LineWidthitem =2;
  503. DashStyle LineDashitem= new DashStyle();
  504. if (list != null)
  505. {
  506. var temp = list[0];
  507. switch (temp.EventType)
  508. {
  509. case AnnotArgsType.AnnotCircle:
  510. args = temp as CircleAnnotArgs;
  511. LineColor = args.LineColor;
  512. BgColor = args.BgColor;
  513. LineWidth = args.LineWidth;
  514. LineDash = args.LineDash;
  515. break;
  516. case AnnotArgsType.AnnotSquare:
  517. argsSquare = temp as SquareAnnotArgs;
  518. LineColor = argsSquare.LineColor;
  519. BgColor = argsSquare.BgColor;
  520. LineWidth = argsSquare.LineWidth;
  521. LineDash = argsSquare.LineDash;
  522. break;
  523. case AnnotArgsType.AnnotLine:
  524. argsLine = temp as LineAnnotArgs;
  525. IsLineAnnot = true;
  526. LineColor = argsLine.LineColor;
  527. LineWidth = argsLine.LineWidth;
  528. LineDash = argsLine.LineDash;
  529. break;
  530. }
  531. Dictionary<string, bool> isNoEqualsDir = new Dictionary<string, bool>();
  532. isNoEqualsDir.Add("FillColor", false);
  533. isNoEqualsDir.Add("LineColor", false);
  534. isNoEqualsDir.Add("Thickness", false);
  535. isNoEqualsDir.Add("ThickSolidDashStyle", false);
  536. isNoEqualsDir.Add("AnnotTypeTitle", false);
  537. foreach (var item in list)
  538. {
  539. if (item is SquareAnnotArgs)
  540. {
  541. argsSquare = item as SquareAnnotArgs;
  542. LineColoritem = argsSquare.LineColor;
  543. BgColoritem = argsSquare.BgColor;
  544. LineWidthitem = argsSquare.LineWidth;
  545. LineDashitem = argsSquare.LineDash;
  546. }
  547. if (item is CircleAnnotArgs)
  548. {
  549. args = item as CircleAnnotArgs;
  550. LineColoritem = args.LineColor;
  551. BgColoritem = args.BgColor;
  552. LineWidthitem = args.LineWidth;
  553. LineDashitem = args.LineDash;
  554. }
  555. if (item is LineAnnotArgs)
  556. {
  557. argsLine = item as LineAnnotArgs;
  558. IsLineAnnot = true;
  559. LineColoritem = argsLine.LineColor;
  560. LineWidthitem = argsLine.LineWidth;
  561. LineDashitem = argsLine.LineDash;
  562. }
  563. if (item == list[0])
  564. continue;
  565. if (isNoEqualsDir["AnnotTypeTitle"] == false)
  566. {
  567. if (temp.EventType != item.EventType)
  568. {
  569. BasicVm.AnnotTypeTitle = "其他";
  570. isNoEqualsDir["AnnotTypeTitle"] = true;
  571. }
  572. else
  573. {
  574. var annotLinetemp = temp as LineAnnotArgs;
  575. var annotLineitem = item as LineAnnotArgs;
  576. if (annotLineitem != null && annotLinetemp != null)
  577. {
  578. if (annotLinetemp.TailLineType != annotLineitem.TailLineType)
  579. {
  580. BasicVm.AnnotTypeTitle = "其他";
  581. isNoEqualsDir["AnnotTypeTitle"] = true;
  582. }
  583. }
  584. }
  585. }
  586. if (isNoEqualsDir["FillColor"] == false)
  587. {
  588. if (BgColor.A != BgColoritem.A || BgColor.R != BgColoritem.R || BgColor.G != BgColoritem.G || BgColor.B != BgColoritem.B)
  589. {
  590. BasicVm.FillColor = new SolidColorBrush(Color.FromArgb(0x01, 0xff, 0xff, 0xff));
  591. isNoEqualsDir["FillColor"] = true;
  592. }
  593. }
  594. if (isNoEqualsDir["LineColor"] == false)
  595. {
  596. if (LineColor.A != LineColoritem.A || LineColor.R != LineColoritem.R || LineColor.G != LineColoritem.G ||LineColor.B != LineColoritem.B)
  597. {
  598. BasicVm.BorderColor = new SolidColorBrush(Color.FromArgb(0x01, 0xff, 0xff, 0xff));
  599. isNoEqualsDir["LineColor"] = true;
  600. }
  601. }
  602. if (isNoEqualsDir["Thickness"] == false)
  603. {
  604. isNoEqualsDir["Thickness"] = true;
  605. if (LineWidth > LineWidthitem)
  606. {
  607. BasicVm.AnnotThickness = LineWidth;
  608. }
  609. else
  610. {
  611. BasicVm.AnnotThickness = LineWidthitem;
  612. }
  613. }
  614. if (isNoEqualsDir["ThickSolidDashStyle"] == false)
  615. {
  616. if (AnnotTransfer.IsSolidStyle(LineDash) != AnnotTransfer.IsSolidStyle(LineDashitem))
  617. {
  618. isNoEqualsDir["ThickSolidDashStyle"] = true;
  619. }
  620. }
  621. }
  622. ////以下是多选注释的属性相等时
  623. if (isNoEqualsDir["FillColor"] == false)
  624. {
  625. BasicVm.FillColor = new SolidColorBrush(BgColor);
  626. }
  627. if (isNoEqualsDir["LineColor"] == false)
  628. {
  629. BasicVm.BorderColor = new SolidColorBrush(LineColor);
  630. }
  631. if (isNoEqualsDir["Thickness"] == false)
  632. {
  633. BasicVm.AnnotThickness = LineWidth;
  634. }
  635. if (isNoEqualsDir["ThickSolidDashStyle"] == true)
  636. {
  637. BasicVm.IsSolidLine = BasicVm.IsDashLine = false;
  638. }
  639. else
  640. {
  641. var isSolid = AnnotTransfer.IsSolidStyle(LineDash);
  642. BasicVm.IsSolidLine = isSolid;
  643. BasicVm.IsDashLine = !isSolid;
  644. }
  645. }
  646. }
  647. private bool IsSolidStyle(AnnotHandlerEventArgs annot)
  648. {
  649. bool isSolid = true;
  650. if (annot is SquareAnnotArgs)
  651. {
  652. var Square = Annot as SquareAnnotArgs;
  653. isSolid = AnnotTransfer.IsSolidStyle(Square.LineDash);
  654. }
  655. else if (annot is CircleAnnotArgs)
  656. {
  657. var Circle = Annot as CircleAnnotArgs;
  658. isSolid = AnnotTransfer.IsSolidStyle(Circle.LineDash);
  659. }
  660. else if (annot is LineAnnotArgs)
  661. {
  662. var line = Annot as LineAnnotArgs;
  663. isSolid = AnnotTransfer.IsSolidStyle(line.LineDash);
  664. }
  665. return isSolid;
  666. }
  667. private void GetAnnotProperty()
  668. {
  669. if (Annot != null)
  670. {
  671. bool isSolid = true;
  672. switch (Annot.EventType)
  673. {
  674. case AnnotArgsType.AnnotSquare:
  675. if (Annot is SquareAnnotArgs)
  676. {
  677. var Square = Annot as SquareAnnotArgs;
  678. BasicVm.BorderColor = new SolidColorBrush(Square.LineColor);
  679. BasicVm.FillColor = new SolidColorBrush(Square.BgColor);
  680. BasicVm.BorderOpacity = Square.Transparency;
  681. BasicVm.FillOpacity = Square.Transparency;
  682. BasicVm.AnnotThickness = Square.LineWidth;
  683. Dash = Square.LineDash;
  684. SharpsType("Rect", false);
  685. BasicVm.AnnotTypeTitle = "矩形";
  686. IsLineAnnot = false;
  687. IsRect = true;
  688. }
  689. break;
  690. case AnnotArgsType.AnnotCircle:
  691. if (Annot is CircleAnnotArgs)
  692. {
  693. var Circle = Annot as CircleAnnotArgs;
  694. BasicVm.BorderColor = new SolidColorBrush(Circle.LineColor);
  695. BasicVm.FillColor = new SolidColorBrush(Circle.BgColor);
  696. BasicVm.BorderOpacity = Circle.Transparency;
  697. BasicVm.FillOpacity = Circle.Transparency;
  698. BasicVm.AnnotThickness = Circle.LineWidth;
  699. Dash = Circle.LineDash;
  700. SharpsType("Circle", false);
  701. BasicVm.AnnotTypeTitle = "圆";
  702. IsLineAnnot = false;
  703. IsCircle = true;
  704. }
  705. break;
  706. case AnnotArgsType.AnnotLine:
  707. if (Annot is LineAnnotArgs)
  708. {
  709. var line = Annot as LineAnnotArgs;
  710. BasicVm.BorderColor = new SolidColorBrush(line.LineColor);
  711. BasicVm.FillColor = new SolidColorBrush(line.LineColor);
  712. BasicVm.BorderOpacity = line.Transparency;
  713. BasicVm.FillOpacity = line.Transparency;
  714. BasicVm.AnnotThickness = line.LineWidth;
  715. Dash = line.LineDash;
  716. if (line.TailLineType == C_LINE_TYPE.LINETYPE_ARROW && line.HeadLineType == C_LINE_TYPE.LINETYPE_NONE)
  717. {
  718. SharpsType("Arrow", false);
  719. BasicVm.AnnotTypeTitle = "箭头";
  720. IsArrow = true;
  721. }
  722. else
  723. {
  724. SharpsType("Line", false);
  725. BasicVm.AnnotTypeTitle = "线条";
  726. IsLine = true;
  727. }
  728. IsLineAnnot = true;
  729. }
  730. break;
  731. }
  732. isSolid = IsSolidStyle(Annot);
  733. BasicVm.IsSolidLine = isSolid;
  734. BasicVm.IsDashLine = !isSolid;
  735. }
  736. }
  737. }
  738. }