SharpsAnnotPropertyViewModel.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  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. BasicVm.IsSharpAnnotSelected = !BasicVm.IsMultiSelected;
  465. IsAttributeEquals();
  466. }
  467. else
  468. {
  469. BasicVm.IsSharpAnnotSelected = PropertyPanel.IsSharpAnnotSelected;
  470. GetAnnotProperty();
  471. }
  472. LoadPropertyHandler?.Invoke(null, Annot);
  473. }
  474. }
  475. private List<AnnotHandlerEventArgs> ConvertLists()
  476. {
  477. List<AnnotHandlerEventArgs> FreeTextLists = new List<AnnotHandlerEventArgs>();
  478. foreach (var item in PropertyPanel.annotlists)
  479. {
  480. var itemFreeText = item as AnnotHandlerEventArgs;
  481. if (itemFreeText != null)
  482. {
  483. FreeTextLists.Add(itemFreeText);
  484. }
  485. }
  486. if (FreeTextLists.Count != PropertyPanel.annotlists.Count)
  487. return null;
  488. else
  489. return FreeTextLists;
  490. }
  491. private void IsAttributeEquals()
  492. {
  493. int isAnnotArgs = 0;
  494. CircleAnnotArgs args = new CircleAnnotArgs();
  495. SquareAnnotArgs argsSquare = new SquareAnnotArgs();
  496. LineAnnotArgs argsLine = new LineAnnotArgs();
  497. var list = ConvertLists();
  498. Color LineColor = Color.FromArgb(0x01, 0xff, 0xff, 0xff);
  499. Color BgColor = Color.FromArgb(0x01, 0xff, 0xff, 0xff);
  500. double LineWidth = 2;
  501. DashStyle LineDash = new DashStyle();
  502. Color LineColoritem = Color.FromArgb(0x01, 0xff, 0xff, 0xff);
  503. Color BgColoritem = Color.FromArgb(0x01, 0xff, 0xff, 0xff);
  504. double LineWidthitem = 2;
  505. DashStyle LineDashitem = new DashStyle();
  506. if (list != null)
  507. {
  508. var temp = list[0];
  509. switch (temp.EventType)
  510. {
  511. case AnnotArgsType.AnnotCircle:
  512. args = temp as CircleAnnotArgs;
  513. LineColor = args.LineColor;
  514. BgColor = args.BgColor;
  515. LineWidth = args.LineWidth;
  516. LineDash = args.LineDash;
  517. break;
  518. case AnnotArgsType.AnnotSquare:
  519. argsSquare = temp as SquareAnnotArgs;
  520. LineColor = argsSquare.LineColor;
  521. BgColor = argsSquare.BgColor;
  522. LineWidth = argsSquare.LineWidth;
  523. LineDash = argsSquare.LineDash;
  524. break;
  525. case AnnotArgsType.AnnotLine:
  526. argsLine = temp as LineAnnotArgs;
  527. IsLineAnnot = true;
  528. LineColor = argsLine.LineColor;
  529. LineWidth = argsLine.LineWidth;
  530. LineDash = argsLine.LineDash;
  531. break;
  532. }
  533. Dictionary<string, bool> isNoEqualsDir = new Dictionary<string, bool>();
  534. isNoEqualsDir.Add("FillColor", false);
  535. isNoEqualsDir.Add("LineColor", false);
  536. isNoEqualsDir.Add("Thickness", false);
  537. isNoEqualsDir.Add("ThickSolidDashStyle", false);
  538. isNoEqualsDir.Add("AnnotTypeTitle", false);
  539. foreach (var item in list)
  540. {
  541. if (item is SquareAnnotArgs)
  542. {
  543. argsSquare = item as SquareAnnotArgs;
  544. LineColoritem = argsSquare.LineColor;
  545. BgColoritem = argsSquare.BgColor;
  546. LineWidthitem = argsSquare.LineWidth;
  547. LineDashitem = argsSquare.LineDash;
  548. }
  549. if (item is CircleAnnotArgs)
  550. {
  551. args = item as CircleAnnotArgs;
  552. LineColoritem = args.LineColor;
  553. BgColoritem = args.BgColor;
  554. LineWidthitem = args.LineWidth;
  555. LineDashitem = args.LineDash;
  556. }
  557. if (item is LineAnnotArgs)
  558. {
  559. argsLine = item as LineAnnotArgs;
  560. IsLineAnnot = true;
  561. LineColoritem = argsLine.LineColor;
  562. LineWidthitem = argsLine.LineWidth;
  563. LineDashitem = argsLine.LineDash;
  564. }
  565. if (item == list[0])
  566. continue;
  567. if (isNoEqualsDir["AnnotTypeTitle"] == false)
  568. {
  569. if (temp.EventType != item.EventType)
  570. {
  571. BasicVm.AnnotTypeTitle = "其他";
  572. isNoEqualsDir["AnnotTypeTitle"] = true;
  573. }
  574. else
  575. {
  576. var annotLinetemp = temp as LineAnnotArgs;
  577. var annotLineitem = item as LineAnnotArgs;
  578. if (annotLineitem != null && annotLinetemp != null)
  579. {
  580. if (annotLinetemp.TailLineType != annotLineitem.TailLineType)
  581. {
  582. BasicVm.AnnotTypeTitle = "其他";
  583. isNoEqualsDir["AnnotTypeTitle"] = true;
  584. }
  585. }
  586. }
  587. }
  588. if (isNoEqualsDir["FillColor"] == false)
  589. {
  590. if (BgColor.A != BgColoritem.A || BgColor.R != BgColoritem.R || BgColor.G != BgColoritem.G || BgColor.B != BgColoritem.B)
  591. {
  592. BasicVm.FillColor = new SolidColorBrush(Color.FromArgb(0x01, 0xff, 0xff, 0xff));
  593. isNoEqualsDir["FillColor"] = true;
  594. }
  595. }
  596. if (isNoEqualsDir["LineColor"] == false)
  597. {
  598. if (LineColor.A != LineColoritem.A || LineColor.R != LineColoritem.R || LineColor.G != LineColoritem.G || LineColor.B != LineColoritem.B)
  599. {
  600. BasicVm.BorderColor = new SolidColorBrush(Color.FromArgb(0x01, 0xff, 0xff, 0xff));
  601. isNoEqualsDir["LineColor"] = true;
  602. }
  603. }
  604. if (isNoEqualsDir["Thickness"] == false)
  605. {
  606. isNoEqualsDir["Thickness"] = true;
  607. if (LineWidth > LineWidthitem)
  608. {
  609. BasicVm.AnnotThickness = LineWidth;
  610. }
  611. else
  612. {
  613. BasicVm.AnnotThickness = LineWidthitem;
  614. }
  615. }
  616. if (isNoEqualsDir["ThickSolidDashStyle"] == false)
  617. {
  618. if (AnnotTransfer.IsSolidStyle(LineDash) != AnnotTransfer.IsSolidStyle(LineDashitem))
  619. {
  620. isNoEqualsDir["ThickSolidDashStyle"] = true;
  621. }
  622. }
  623. }
  624. ////以下是多选注释的属性相等时
  625. if (isNoEqualsDir["FillColor"] == false)
  626. {
  627. BasicVm.FillColor = new SolidColorBrush(BgColor);
  628. }
  629. if (isNoEqualsDir["LineColor"] == false)
  630. {
  631. BasicVm.BorderColor = new SolidColorBrush(LineColor);
  632. }
  633. if (isNoEqualsDir["Thickness"] == false)
  634. {
  635. BasicVm.AnnotThickness = LineWidth;
  636. }
  637. if (isNoEqualsDir["ThickSolidDashStyle"] == true)
  638. {
  639. BasicVm.IsSolidLine = BasicVm.IsDashLine = false;
  640. }
  641. else
  642. {
  643. var isSolid = AnnotTransfer.IsSolidStyle(LineDash);
  644. BasicVm.IsSolidLine = isSolid;
  645. BasicVm.IsDashLine = !isSolid;
  646. }
  647. }
  648. }
  649. private bool IsSolidStyle(AnnotHandlerEventArgs annot)
  650. {
  651. bool isSolid = true;
  652. if (annot is SquareAnnotArgs)
  653. {
  654. var Square = Annot as SquareAnnotArgs;
  655. isSolid = AnnotTransfer.IsSolidStyle(Square.LineDash);
  656. }
  657. else if (annot is CircleAnnotArgs)
  658. {
  659. var Circle = Annot as CircleAnnotArgs;
  660. isSolid = AnnotTransfer.IsSolidStyle(Circle.LineDash);
  661. }
  662. else if (annot is LineAnnotArgs)
  663. {
  664. var line = Annot as LineAnnotArgs;
  665. isSolid = AnnotTransfer.IsSolidStyle(line.LineDash);
  666. }
  667. return isSolid;
  668. }
  669. private void GetAnnotProperty()
  670. {
  671. if (Annot != null)
  672. {
  673. bool isSolid = true;
  674. switch (Annot.EventType)
  675. {
  676. case AnnotArgsType.AnnotSquare:
  677. if (Annot is SquareAnnotArgs)
  678. {
  679. var Square = Annot as SquareAnnotArgs;
  680. BasicVm.BorderColor = new SolidColorBrush(Square.LineColor);
  681. BasicVm.FillColor = new SolidColorBrush(Square.BgColor);
  682. BasicVm.BorderOpacity = Square.Transparency;
  683. BasicVm.FillOpacity = Square.Transparency;
  684. BasicVm.AnnotThickness = Square.LineWidth;
  685. Dash = Square.LineDash;
  686. SharpsType("Rect", false);
  687. BasicVm.AnnotTypeTitle = "矩形";
  688. IsLineAnnot = false;
  689. IsRect = true;
  690. }
  691. break;
  692. case AnnotArgsType.AnnotCircle:
  693. if (Annot is CircleAnnotArgs)
  694. {
  695. var Circle = Annot as CircleAnnotArgs;
  696. BasicVm.BorderColor = new SolidColorBrush(Circle.LineColor);
  697. BasicVm.FillColor = new SolidColorBrush(Circle.BgColor);
  698. BasicVm.BorderOpacity = Circle.Transparency;
  699. BasicVm.FillOpacity = Circle.Transparency;
  700. BasicVm.AnnotThickness = Circle.LineWidth;
  701. Dash = Circle.LineDash;
  702. SharpsType("Circle", false);
  703. BasicVm.AnnotTypeTitle = "圆";
  704. IsLineAnnot = false;
  705. IsCircle = true;
  706. }
  707. break;
  708. case AnnotArgsType.AnnotLine:
  709. if (Annot is LineAnnotArgs)
  710. {
  711. var line = Annot as LineAnnotArgs;
  712. BasicVm.BorderColor = new SolidColorBrush(line.LineColor);
  713. BasicVm.FillColor = new SolidColorBrush(line.LineColor);
  714. BasicVm.BorderOpacity = line.Transparency;
  715. BasicVm.FillOpacity = line.Transparency;
  716. BasicVm.AnnotThickness = line.LineWidth;
  717. Dash = line.LineDash;
  718. if (line.TailLineType == C_LINE_TYPE.LINETYPE_ARROW && line.HeadLineType == C_LINE_TYPE.LINETYPE_NONE)
  719. {
  720. SharpsType("Arrow", false);
  721. BasicVm.AnnotTypeTitle = "箭头";
  722. IsArrow = true;
  723. }
  724. else
  725. {
  726. SharpsType("Line", false);
  727. BasicVm.AnnotTypeTitle = "线条";
  728. IsLine = true;
  729. }
  730. IsLineAnnot = true;
  731. }
  732. break;
  733. }
  734. isSolid = IsSolidStyle(Annot);
  735. BasicVm.IsSolidLine = isSolid;
  736. BasicVm.IsDashLine = !isSolid;
  737. }
  738. }
  739. }
  740. }