CustomDishInfo.xaml.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. using ivf_tl_Entity.DTO;
  2. using ivf_tl_Entity.GlobalEntitys;
  3. using ivf_tl_Entity.GlobalEnums;
  4. using ivf_tl_Operate.Converts;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Reflection;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Input;
  13. using System.Windows.Markup;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. namespace ivf_tl_Operate.CustomUserControls
  17. {
  18. /// <summary>
  19. /// CustomDishInfo.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class CustomDishInfo : UserControl
  22. {
  23. public event Action<int> ChangeSelectdIndexEvent;
  24. public event Action<bool> IsMaxChangedEvent;
  25. public int selectedIndex = 0;
  26. private List<TextBlock> TextBlockList = new List<TextBlock>();
  27. private Dictionary<int, Image> operateImageList = new Dictionary<int, Image>();
  28. private Dictionary<int, Image> picImageList = new Dictionary<int, Image>();
  29. private Dictionary<int, Border> BackBorderList = new Dictionary<int, Border>();
  30. private int ellipseCount = 16;
  31. private double operateBigRadius = 732;
  32. private double imageBigRadius = 632;
  33. private double textBigRadius = 500;
  34. private double operateRadius = 20;
  35. private double imageRadius = 107;
  36. private double centerX = 0;
  37. private double centerY = 0;
  38. private double angle = 0;
  39. /// <summary>
  40. /// 旋转角度
  41. /// </summary>
  42. private double angleOffset = 90;
  43. /// <summary>
  44. /// 字体默认颜色
  45. /// </summary>
  46. private Color DefaultFontColor { get; set; } = Color.FromArgb(255, 110, 114, 118);
  47. /// <summary>
  48. /// 字体选中颜色
  49. /// </summary>
  50. private Color SelectFontColor { get; set; } = Colors.White;
  51. bool isInit = false;
  52. public CustomDishInfo()
  53. {
  54. InitializeComponent();
  55. centerX = this._canvas.Width / 2;
  56. centerY = this._canvas.Height / 2;
  57. angle = 360d / ellipseCount;
  58. Unloaded += (s, e) =>
  59. {
  60. if (ExDishSource == null) return;
  61. foreach (var item in ExDishSource.embryoList)
  62. {
  63. item.AlarmChangedEvent -= EmbryoAlarmEvent;
  64. }
  65. ExDishSource = null;
  66. this._canvas.Children.Clear();
  67. };
  68. }
  69. private void InitCustom()
  70. {
  71. for (int i = 0; i < ellipseCount; i++)
  72. {
  73. TextBlock borderT = new TextBlock();
  74. Panel.SetZIndex(borderT, 11);
  75. this._canvas.Children.Add(borderT);
  76. borderT.Height = 28;
  77. borderT.Width = 35;
  78. borderT.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Width / 2);
  79. borderT.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Height / 2);
  80. borderT.Text = $"{i + 1}";
  81. borderT.TextAlignment = TextAlignment.Center;
  82. borderT.FontSize = 27;
  83. if (i == 0)
  84. {
  85. borderT.Foreground = new SolidColorBrush(SelectFontColor);
  86. }
  87. else
  88. {
  89. borderT.Foreground = new SolidColorBrush(DefaultFontColor);
  90. }
  91. TextBlockList.Add(borderT);
  92. Image operateBorder = new Image();
  93. Panel.SetZIndex(operateBorder, 13);
  94. this._canvas.Children.Add(operateBorder);
  95. operateImageList.Add((i + 1), operateBorder);
  96. operateBorder.Width = operateRadius * 2;
  97. operateBorder.Height = operateRadius * 2;
  98. operateBorder.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * operateBigRadius - operateBorder.Width / 2);
  99. operateBorder.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * operateBigRadius - operateBorder.Height / 2);
  100. operateBorder.Visibility = Visibility.Collapsed;
  101. Border imageBorder = new Border();
  102. Panel.SetZIndex(imageBorder, 12);
  103. this._canvas.Children.Add(imageBorder);
  104. Image embryoImage = new Image();
  105. imageBorder.Child = embryoImage;
  106. EllipseGeometry ellipseGeometry = new EllipseGeometry(new Point(imageRadius, imageRadius), imageRadius - 3, imageRadius - 3);
  107. embryoImage.SetValue(Image.ClipProperty, ellipseGeometry);
  108. imageBorder.Tag = i;
  109. imageBorder.Width = imageRadius * 2;
  110. imageBorder.Height = imageRadius * 2;
  111. embryoImage.Width = imageRadius * 2;
  112. embryoImage.Height = imageRadius * 2;
  113. picImageList.Add(i + 1, embryoImage);
  114. imageBorder.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageBorder.Width / 2);
  115. imageBorder.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageBorder.Height / 2);
  116. imageBorder.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/ellipse_backgroud.png", UriKind.Absolute)));
  117. //border.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/ellipse_backgroud.png", UriKind.RelativeOrAbsolute));
  118. //if (i > 10)
  119. //{
  120. // border.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/ellipse_noembryo.png", UriKind.RelativeOrAbsolute));
  121. //}
  122. imageBorder.MouseDown += (s, e) =>
  123. {
  124. if (!(s is Border source)) return;
  125. int index = (int)source.Tag;
  126. if (selectedIndex == index) return;
  127. SelectIndex(index);
  128. ChangeSelectdIndexEvent?.Invoke(index + 1);
  129. };
  130. }
  131. }
  132. public void InitCustomNew()
  133. {
  134. for (int i = 0; i < ellipseCount; i++)
  135. {
  136. TextBlock borderT = new TextBlock();
  137. TextBlockList.Add(borderT);
  138. Panel.SetZIndex(borderT, 11);
  139. this._canvas.Children.Add(borderT);
  140. borderT.Height = 28;
  141. borderT.Width = 35;
  142. borderT.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Width / 2);
  143. borderT.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Height / 2);
  144. borderT.Text = $"{i + 1}";
  145. borderT.TextAlignment = TextAlignment.Center;
  146. borderT.FontSize = 27;
  147. if (i == 0)
  148. {
  149. borderT.Foreground = new SolidColorBrush(SelectFontColor);
  150. }
  151. else
  152. {
  153. borderT.Foreground = new SolidColorBrush(DefaultFontColor);
  154. }
  155. Image operateBorder = new Image();
  156. Panel.SetZIndex(operateBorder, 13);
  157. this._canvas.Children.Add(operateBorder);
  158. operateImageList.Add((i + 1), operateBorder);
  159. operateBorder.Width = operateRadius * 2;
  160. operateBorder.Height = operateRadius * 2;
  161. operateBorder.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * operateBigRadius - operateBorder.Width / 2);
  162. operateBorder.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * operateBigRadius - operateBorder.Height / 2);
  163. operateBorder.Visibility = Visibility.Collapsed;
  164. Border imageBorder = new Border();
  165. BackBorderList.Add(i + 1, imageBorder);
  166. Panel.SetZIndex(imageBorder, 12);
  167. this._canvas.Children.Add(imageBorder);
  168. Image embryoImage = new Image();
  169. picImageList.Add(i + 1, embryoImage);
  170. imageBorder.Child = embryoImage;
  171. int kk = 20;
  172. embryoImage.Width = imageRadius * 2;
  173. embryoImage.Height = imageRadius * 2;
  174. EllipseGeometry ellipseGeometry = new EllipseGeometry(new Point(imageRadius, imageRadius), imageRadius - kk, imageRadius - kk);
  175. embryoImage.SetValue(Image.ClipProperty, ellipseGeometry);
  176. imageBorder.Tag = i;
  177. imageBorder.Width = imageRadius * 2;
  178. imageBorder.Height = imageRadius * 2;
  179. imageBorder.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageBorder.Width / 2);
  180. imageBorder.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageBorder.Height / 2);
  181. if (ExDishSource != null)
  182. {
  183. var itemEmbryo = SetWellImage(i + 1, 1);
  184. if (itemEmbryo == null)
  185. {
  186. embryoImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailNoEmbryo.png", UriKind.Absolute));
  187. }
  188. else
  189. {
  190. embryoImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailNoEmbryo1.png", UriKind.Absolute));
  191. }
  192. }
  193. else
  194. {
  195. imageBorder.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailNoEmbryoBackground.png", UriKind.Absolute)));
  196. }
  197. int index = i;
  198. imageBorder.MouseDown += (s, e) =>
  199. {
  200. if (selectedIndex == index) return;
  201. SelectIndex(index);
  202. ChangeSelectdIndexEvent?.Invoke(index + 1);
  203. };
  204. }
  205. }
  206. public void NextEmbryo()
  207. {
  208. int index = selectedIndex;
  209. if (index == 15)
  210. {
  211. index = 0;
  212. }
  213. else
  214. {
  215. index++;
  216. }
  217. SelectIndex(index);
  218. ChangeSelectdIndexEvent?.Invoke(index + 1);
  219. }
  220. public void LastEmbryo()
  221. {
  222. int index = selectedIndex;
  223. if (index == 0)
  224. {
  225. index = 15;
  226. }
  227. else
  228. {
  229. index--;
  230. }
  231. SelectIndex(index);
  232. ChangeSelectdIndexEvent?.Invoke(index + 1);
  233. }
  234. private object lock1 = new object();
  235. private ExEmbryo SetWellImage(int index, int oldIndex)
  236. {
  237. lock (lock1)
  238. {
  239. if (ExDishSource == null) return null;
  240. Border imageBorder = BackBorderList[index];
  241. //Image embryoImage = picImageList[index];
  242. var itemEmbryo = ExDishSource.embryoList.FirstOrDefault(x => x.wellSn == index);
  243. if (itemEmbryo == null)
  244. {
  245. if (index == oldIndex)
  246. {
  247. imageBorder.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoSelectedIcon.png", UriKind.Absolute)));
  248. }
  249. else
  250. {
  251. imageBorder.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailNoEmbryoBackground.png", UriKind.Absolute)));
  252. }
  253. return itemEmbryo;
  254. }
  255. string borderSource = null;
  256. switch ((EmbryoState)itemEmbryo.state)
  257. {
  258. case EmbryoState.End:
  259. case EmbryoState.None:
  260. if (itemEmbryo.alarm == 1)
  261. {
  262. borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState3Icon.png";
  263. }
  264. else
  265. {
  266. if (index == oldIndex)
  267. {
  268. borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoSelectedIcon.png";
  269. }
  270. else
  271. {
  272. borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoBackground.png";
  273. }
  274. }
  275. break;
  276. case EmbryoState.Freezing: //冷冻
  277. borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState1Icon.png";
  278. break;
  279. case EmbryoState.Transplant://移植
  280. borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState2Icon.png";
  281. break;
  282. case EmbryoState.Cancellation://作废
  283. borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState3Icon.png";
  284. break;
  285. case EmbryoState.Delete://删除
  286. borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState4Icon.png";
  287. break;
  288. }
  289. imageBorder.Background = new ImageBrush(new BitmapImage(new Uri(borderSource, UriKind.Absolute)));
  290. return itemEmbryo;
  291. }
  292. }
  293. private void SelectIndex(int index)
  294. {
  295. TextBlockList[selectedIndex].Foreground = new SolidColorBrush(DefaultFontColor);
  296. SetWellImage(selectedIndex + 1, 0);
  297. selectedIndex = index;
  298. var itemEmbryo = ExDishSource.embryoList.FirstOrDefault(x => x.wellSn == selectedIndex + 1);
  299. if (itemEmbryo == null)
  300. {
  301. BackBorderList[selectedIndex + 1].Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoSelectedIcon.png", UriKind.Absolute)));
  302. }
  303. else
  304. {
  305. if ((itemEmbryo.state == (int)EmbryoState.End || itemEmbryo.state == (int)EmbryoState.None) && itemEmbryo.alarm == 0)
  306. {
  307. BackBorderList[selectedIndex + 1].Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoSelectedIcon.png", UriKind.Absolute)));
  308. }
  309. }
  310. RotateTransform rotateTransform = this._sx.RenderTransform as RotateTransform;
  311. if (rotateTransform == null)
  312. rotateTransform = new RotateTransform();
  313. rotateTransform.Angle = angle * index;
  314. //this._sx.RenderTransformOrigin = new Point(0.5, 0);
  315. this._sx.RenderTransform = rotateTransform;
  316. //foreach (var item in TextBlockList)
  317. //{
  318. // item.Foreground = new SolidColorBrush(DefaultFontColor);
  319. //}
  320. TextBlockList[index].Foreground = new SolidColorBrush(SelectFontColor);
  321. }
  322. private void mediaElementPlayer_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
  323. {
  324. string ss = "";
  325. }
  326. private void _preview_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
  327. {
  328. string ss11 = "";
  329. }
  330. private void _canvas_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
  331. {
  332. string ss2 = "";
  333. }
  334. public ExDish ExDishSource
  335. {
  336. get { return (ExDish)GetValue(ExDishSourceProperty); }
  337. set { SetValue(ExDishSourceProperty, value); }
  338. }
  339. // Using a DependencyProperty as the backing store for ExDishSource. This enables animation, styling, binding, etc...
  340. public static readonly DependencyProperty ExDishSourceProperty =
  341. DependencyProperty.Register("ExDishSource", typeof(ExDish), typeof(CustomDishInfo), new PropertyMetadata(null, new PropertyChangedCallback(ExDishSourcePropertyChanged)));
  342. private static void ExDishSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
  343. {
  344. if (!(d is CustomDishInfo source)) return;
  345. if (source.DataContext == null) return;
  346. if (e.NewValue == null)
  347. {
  348. source.SetDish(source, null);
  349. return;
  350. }
  351. if (!(e.NewValue is ExDish exDish))
  352. {
  353. source.SetDish(source, null);
  354. return;
  355. }
  356. if (!source.isInit)
  357. {
  358. source.isInit = true;
  359. source.InitCustomNew();
  360. }
  361. source.SetDish(source, exDish);
  362. foreach (var item in exDish.embryoList)
  363. {
  364. item.AlarmChangedEvent -= source.EmbryoAlarmEvent;
  365. item.AlarmChangedEvent += source.EmbryoAlarmEvent;
  366. }
  367. return;
  368. }
  369. private void EmbryoAlarmEvent(int wellsn, int stateAlarm)
  370. {
  371. Dispatcher.Invoke(() => { SetWellImage(wellsn, selectedIndex + 1); });
  372. }
  373. private void SetDish(CustomDishInfo customDishInfo, ExDish exDish)
  374. {
  375. if (exDish == null)
  376. {
  377. foreach (var item in customDishInfo.operateImageList)
  378. {
  379. if (item.Value.Visibility != Visibility.Hidden)
  380. {
  381. item.Value.Visibility = Visibility.Hidden;
  382. }
  383. }
  384. foreach (var item in picImageList)
  385. {
  386. item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/ellipse_backgroud.png", UriKind.Relative));
  387. }
  388. return;
  389. }
  390. foreach (var item in customDishInfo.operateImageList)
  391. {
  392. var embryo = exDish.embryoList.FirstOrDefault(x => x.wellSn == item.Key);
  393. if (embryo == null)
  394. {
  395. item.Value.Visibility = Visibility.Hidden;
  396. continue;
  397. }
  398. item.Value.Visibility = Visibility.Visible;
  399. EmbryoState state = (EmbryoState)embryo.state;
  400. switch (state)
  401. {
  402. case EmbryoState.Freezing:
  403. item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/open_button_freezable.png", UriKind.Relative));//冷冻
  404. break;
  405. case EmbryoState.Transplant:
  406. item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/yz.png", UriKind.Relative));//移植
  407. break;
  408. case EmbryoState.Cancellation:
  409. item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/open_button_no.png", UriKind.Relative));//作废
  410. break;
  411. case EmbryoState.Delete:
  412. item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/menu_delete.png", UriKind.Relative));//作废
  413. break;
  414. default:
  415. item.Value.Visibility = Visibility.Hidden;
  416. break;
  417. }
  418. }
  419. }
  420. /// <summary>
  421. /// 设置胚胎状态
  422. /// </summary>
  423. /// <param name="well"></param>
  424. /// <param name="embryoState"></param>
  425. public void SetEmbryoState(int well, int embryoState, int alarm)
  426. {
  427. var item = operateImageList[well];
  428. EmbryoState state = (EmbryoState)embryoState;
  429. item.Visibility = Visibility.Visible;
  430. switch (state)
  431. {
  432. case EmbryoState.Freezing:
  433. item.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/open_button_freezable.png", UriKind.Relative));//冷冻
  434. break;
  435. case EmbryoState.Transplant:
  436. item.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/yz.png", UriKind.Relative));//移植
  437. break;
  438. case EmbryoState.Cancellation:
  439. item.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/open_button_no.png", UriKind.Relative));//作废
  440. break;
  441. case EmbryoState.Delete:
  442. item.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/menu_delete.png", UriKind.Relative));//作废
  443. break;
  444. default:
  445. item.Visibility = Visibility.Hidden;
  446. break;
  447. }
  448. string borderSource = null;
  449. switch ((EmbryoState)embryoState)
  450. {
  451. case EmbryoState.End:
  452. case EmbryoState.None:
  453. if (alarm == 0)
  454. {
  455. borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoSelectedIcon.png";
  456. }
  457. else
  458. {
  459. borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState3Icon.png";
  460. }
  461. break;
  462. case EmbryoState.Freezing: //冷冻
  463. borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState1Icon.png";
  464. break;
  465. case EmbryoState.Transplant://移植
  466. borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState2Icon.png";
  467. break;
  468. case EmbryoState.Cancellation://作废
  469. borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState3Icon.png";
  470. break;
  471. case EmbryoState.Delete://删除
  472. borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState4Icon.png";
  473. break;
  474. }
  475. BackBorderList[well].Background = new ImageBrush(new BitmapImage(new Uri(borderSource, UriKind.Absolute)));
  476. }
  477. /// <summary>
  478. /// 设置缩略图
  479. /// </summary>
  480. /// <param name="datas"></param>
  481. public void SetEmbryoPic(List<DishPicAndVideo> datas)
  482. {
  483. foreach (var item in picImageList)
  484. {
  485. var embryo = ExDishSource.embryoList.FirstOrDefault(x => x.wellSn == item.Key);
  486. if (embryo == null)
  487. {
  488. item.Value.Tag = 0;
  489. //item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/ellipse_backgroud.png", UriKind.Relative));
  490. item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/pc_DetailNoEmbryo.png", UriKind.Relative));
  491. continue;
  492. }
  493. var currentData = datas.FirstOrDefault(x => x.wellSn == embryo.wellSn);
  494. if (currentData == null || currentData.lastPicture == null)
  495. {
  496. item.Value.Tag = 0;
  497. //item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/ellipse_noembryo.png", UriKind.Relative));
  498. item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/DetailEmbryoNoPic.png", UriKind.Relative));
  499. }
  500. else
  501. {
  502. item.Value.Tag = 1;
  503. item.Value.Source = AppData.Instance.ConvertHelper.StringToBitmapImage($"{AppData.Instance.BaseUrl}{currentData.lastPicture.Replace(AppData.Instance.PicSuf, $"_214x214{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpHelper.GetToken()}");
  504. }
  505. //if (item.Value.Parent is Border parentBorder)
  506. // parentBorder.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/ellipse_backgroud.png", UriKind.Absolute)));
  507. }
  508. }
  509. public void SetPreview(DishPicAndVideo dishPicAndVideo)
  510. {
  511. this.Cancas_Preview.Visibility = Visibility.Visible;
  512. this.TextBlock_Preview.Text = "";
  513. if (dishPicAndVideo == null || string.IsNullOrEmpty(dishPicAndVideo.lastPicture))
  514. {
  515. //this._preview.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/video_preview.png", UriKind.Relative));
  516. AppData.Instance.SetImageSource(this._preview, LogoEnum.BlackCircle);
  517. return;
  518. }
  519. this._preview.Source = AppData.Instance.ConvertHelper.StringToBitmapImage($"{AppData.Instance.BaseUrl}{dishPicAndVideo.lastPicture}?token={AppData.Instance.HttpHelper.GetToken()}");
  520. }
  521. public void SetPreviewNoVideo()
  522. {
  523. this.Cancas_Preview.Visibility = Visibility.Visible;
  524. this._preview.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/none_video.png", UriKind.Relative));
  525. this.TextBlock_Preview.Text = KeyToStringConvert.GetLanguageStringByKey("C0287");
  526. }
  527. bool isMax = false;
  528. double maxWidth = 1583;
  529. double minWidth = 840;
  530. double maxLeft = 0;
  531. double minLeft = 371.5;
  532. private void PreviewMouseDownEvent(object sender, System.Windows.Input.MouseButtonEventArgs e)
  533. {
  534. if (e.ChangedButton == MouseButton.Left && e.ClickCount == 2)
  535. {
  536. if (isMax == false)
  537. {
  538. isMax = true;
  539. mask.Width = maxWidth;
  540. mask.Height = maxWidth;
  541. //Image_Load.Width= maxWidth;
  542. //Image_Load.Height= maxWidth;
  543. mediaElementPlayer.Width = maxWidth;
  544. mediaElementPlayer.Height = maxWidth;
  545. //_preview.Width = maxWidth;
  546. //_preview.Height = maxWidth;
  547. Canvas.SetLeft(mask, maxLeft);
  548. Canvas.SetTop(mask, maxLeft);
  549. //Canvas.SetLeft(Image_Load, maxLeft);
  550. //Canvas.SetTop(Image_Load, maxLeft);
  551. //Image_Load.SetValue(Panel.ZIndexProperty, 15);
  552. Canvas.SetLeft(mediaElementPlayer, maxLeft);
  553. Canvas.SetTop(mediaElementPlayer, maxLeft);
  554. mediaElementPlayer.SetValue(Panel.ZIndexProperty, 16);
  555. //Canvas.SetLeft(_preview, maxLeft);
  556. //Canvas.SetTop(_preview, maxLeft);
  557. //_preview.SetValue(Panel.ZIndexProperty, 17);
  558. }
  559. else
  560. {
  561. isMax = false;
  562. mask.Width = minWidth;
  563. mask.Height = minWidth;
  564. //Image_Load.Width = minWidth;
  565. //Image_Load.Height = minWidth;
  566. mediaElementPlayer.Width = minWidth;
  567. mediaElementPlayer.Height = minWidth;
  568. //_preview.Width = minWidth;
  569. //_preview.Height = minWidth;
  570. Canvas.SetLeft(mask, minLeft);
  571. Canvas.SetTop(mask, minLeft);
  572. //Canvas.SetLeft(Image_Load, minLeft);
  573. //Canvas.SetTop(Image_Load, minLeft);
  574. //Image_Load.SetValue(Panel.ZIndexProperty, 7);
  575. Canvas.SetLeft(mediaElementPlayer, minLeft);
  576. Canvas.SetTop(mediaElementPlayer, minLeft);
  577. mediaElementPlayer.SetValue(Panel.ZIndexProperty, 8);
  578. //Canvas.SetLeft(_preview, minLeft);
  579. //Canvas.SetTop(_preview, minLeft);
  580. //_preview.SetValue(Panel.ZIndexProperty, 9);
  581. }
  582. mask.CornerRadius = new CornerRadius(Width / 2);
  583. SetLoad(isMax);
  584. SetPreView(isMax);
  585. IsMaxChangedEvent?.Invoke(isMax);
  586. e.Handled = true;
  587. }
  588. }
  589. private void SetPreView(bool ismax)
  590. {
  591. if (ismax)
  592. {
  593. _preview.Width = maxWidth;
  594. _preview.Height = maxWidth;
  595. Cancas_Preview.Width = maxWidth;
  596. Cancas_Preview.Height = maxWidth;
  597. TextBlock_Preview.Width = maxWidth;
  598. TextBlock_Preview.FontSize = 98;
  599. Canvas.SetTop(TextBlock_Preview, 958);
  600. Canvas.SetLeft(Cancas_Preview, maxLeft);
  601. Canvas.SetTop(Cancas_Preview, maxLeft);
  602. Cancas_Preview.SetValue(Panel.ZIndexProperty, 17);
  603. }
  604. else
  605. {
  606. _preview.Width = minWidth;
  607. _preview.Height = minWidth;
  608. Cancas_Preview.Width = minWidth;
  609. Cancas_Preview.Height = minWidth;
  610. TextBlock_Preview.Width = minWidth;
  611. TextBlock_Preview.FontSize = 50;
  612. Canvas.SetTop(TextBlock_Preview, 512);
  613. Canvas.SetLeft(Cancas_Preview, minLeft);
  614. Canvas.SetTop(Cancas_Preview, minLeft);
  615. Cancas_Preview.SetValue(Panel.ZIndexProperty, 9);
  616. }
  617. }
  618. private void SetLoad(bool ismax)
  619. {
  620. if (ismax)
  621. {
  622. Image_Load.Width = maxWidth;
  623. Image_Load.Height = maxWidth;
  624. Cancas_Load.Width = maxWidth;
  625. Cancas_Load.Height = maxWidth;
  626. TextBlock_Load.Width = maxWidth;
  627. TextBlock_Load.FontSize = 98;
  628. Canvas.SetTop(TextBlock_Load, 958);
  629. Canvas.SetLeft(Cancas_Load, maxLeft);
  630. Canvas.SetTop(Cancas_Load, maxLeft);
  631. Cancas_Load.SetValue(Panel.ZIndexProperty, 15);
  632. }
  633. else
  634. {
  635. Image_Load.Width = minWidth;
  636. Image_Load.Height = minWidth;
  637. Cancas_Load.Width = minWidth;
  638. Cancas_Load.Height = minWidth;
  639. TextBlock_Load.Width = minWidth;
  640. TextBlock_Load.FontSize = 50;
  641. Canvas.SetTop(TextBlock_Load, 512);
  642. Canvas.SetLeft(Cancas_Load, minLeft);
  643. Canvas.SetTop(Cancas_Load, minLeft);
  644. Cancas_Load.SetValue(Panel.ZIndexProperty, 7);
  645. }
  646. }
  647. }
  648. }