MarkDetailItem.xaml.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. using ivf_tl_Entity.Entity.balance;
  2. using ivf_tl_Entity.Enums;
  3. using ivf_tl_Manage.Converts;
  4. using ivf_tl_Manage.ViewModels;
  5. using System;
  6. using System.Collections;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Diagnostics;
  10. using System.Linq;
  11. using System.Reflection;
  12. using System.Text;
  13. using System.Threading;
  14. using System.Threading.Tasks;
  15. using System.Windows;
  16. using System.Windows.Controls;
  17. using System.Windows.Data;
  18. using System.Windows.Documents;
  19. using System.Windows.Input;
  20. using System.Windows.Media;
  21. using System.Windows.Media.Animation;
  22. using System.Windows.Media.Imaging;
  23. using System.Windows.Navigation;
  24. using System.Windows.Shapes;
  25. using static log4net.Appender.RollingFileAppender;
  26. using static System.Formats.Asn1.AsnWriter;
  27. using static System.Net.Mime.MediaTypeNames;
  28. using Image = System.Windows.Controls.Image;
  29. namespace ivf_tl_Manage.UserControls
  30. {
  31. /// <summary>
  32. /// MarkDetailItem.xaml 的交互逻辑
  33. /// </summary>
  34. public partial class MarkDetailItem : UserControl
  35. {
  36. public event Action<Embryo, long> MarkDetailEvent;
  37. public Action<int> ChangeAction;
  38. public MarkDetailItem()
  39. {
  40. InitializeComponent();
  41. ChangeAction += Change;
  42. }
  43. //public double MinuteWidth = 1120d / 10080d;
  44. public double MinuteWidth = 1225d / 10080d;
  45. public void Change(int i)
  46. {
  47. try
  48. {
  49. Dispatcher.Invoke(() =>
  50. {
  51. SetProgress(0.01f * i, bd_progress);
  52. });
  53. }
  54. catch (Exception)
  55. {
  56. }
  57. }
  58. public new Brush Background
  59. {
  60. get { return (Brush)GetValue(BackgroundProperty); }
  61. set { SetValue(BackgroundProperty, value); }
  62. }
  63. public static new readonly DependencyProperty BackgroundProperty =
  64. DependencyProperty.Register("Background", typeof(Brush), typeof(MarkDetailItem), new PropertyMetadata(null, new PropertyChangedCallback(OnBackgroundPropertyChangedCallback)));
  65. private static void OnBackgroundPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  66. {
  67. if (!(d is MarkDetailItem source)) return;
  68. SolidColorBrush solidColorBrush = (SolidColorBrush)e.NewValue;
  69. if (solidColorBrush == null) return;
  70. source._container.Background = solidColorBrush;
  71. }
  72. /// <summary>
  73. /// 培养进度传(0-100的值)
  74. /// </summary>
  75. public double Progress
  76. {
  77. get { return (double)GetValue(ProgressProperty); }
  78. set { SetValue(ProgressProperty, value); }
  79. }
  80. public static readonly DependencyProperty ProgressProperty = DependencyProperty.Register("Progress", typeof(double),
  81. typeof(MarkDetailItem), new PropertyMetadata(0d, new PropertyChangedCallback(OnProgressPropertyChange)));
  82. static void OnProgressPropertyChange(DependencyObject sender, DependencyPropertyChangedEventArgs args)
  83. {
  84. MarkDetailItem source = (MarkDetailItem)sender;
  85. double data = (double)args.NewValue;
  86. Thread t = new Thread(() =>
  87. {
  88. int m = 0;
  89. while (m < data)
  90. {
  91. Thread.Sleep(10);
  92. //Console.WriteLine(m.ToString());
  93. m++;
  94. source.ChangeAction?.Invoke(m);
  95. }
  96. });
  97. t.Start();
  98. }
  99. public int State
  100. {
  101. get { return (int)GetValue(StateProperty); }
  102. set { SetValue(StateProperty, value); }
  103. }
  104. // Using a DependencyProperty as the backing store for State. This enables animation, styling, binding, etc...
  105. public static readonly DependencyProperty StateProperty =
  106. DependencyProperty.Register("State", typeof(int), typeof(MarkDetailItem), new PropertyMetadata(-1, new PropertyChangedCallback(StatePropertyChangedCallback)));
  107. private static void StatePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  108. {
  109. if (!(d is MarkDetailItem source)) return;
  110. if (!(e.NewValue is int state)) return;
  111. switch (state)
  112. {
  113. case 1: //冷冻
  114. source.st_operate.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/markdetail_bgBlue.png", UriKind.Absolute)));
  115. source.img_icon.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/markdetail_freeze.png", UriKind.Absolute));
  116. break;
  117. case 2://移植
  118. source.st_operate.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/markdetail_bgGreen.png", UriKind.Absolute)));
  119. source.img_icon.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/markdetail_transplant.png", UriKind.Absolute));
  120. break;
  121. case 3://作废
  122. source.st_operate.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/markdetail_bgRed.png", UriKind.Absolute)));
  123. source.img_icon.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/markdetail_x.png", UriKind.Absolute));
  124. break;
  125. case 4:
  126. break;
  127. case 5://删除
  128. source.st_operate.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/markdetail_bgRed.png", UriKind.Absolute)));
  129. source.img_icon.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/markdetail_delete.png", UriKind.Absolute));
  130. break;
  131. default:
  132. break;
  133. }
  134. }
  135. public string Number
  136. {
  137. get { return (string)GetValue(NumberProperty); }
  138. set { SetValue(NumberProperty, value); }
  139. }
  140. public static readonly DependencyProperty NumberProperty =
  141. DependencyProperty.Register("Number", typeof(string), typeof(MarkDetailItem), new PropertyMetadata("", new PropertyChangedCallback(OnNumberPropertyChangedCallback)));
  142. private static void OnNumberPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  143. {
  144. if (!(d is MarkDetailItem source)) return;
  145. if (!(e.NewValue is string number)) return;
  146. source.tb_textNumber.Text = number;
  147. }
  148. public double Score
  149. {
  150. get { return (double)GetValue(ScoreProperty); }
  151. set { SetValue(ScoreProperty, value); }
  152. }
  153. // Using a DependencyProperty as the backing store for Score. This enables animation, styling, binding, etc...
  154. public static readonly DependencyProperty ScoreProperty =
  155. DependencyProperty.Register("Score", typeof(double), typeof(MarkDetailItem), new PropertyMetadata(0d, new PropertyChangedCallback(ScorePropertyChangedCallback)));
  156. private static void ScorePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  157. {
  158. //if (!(d is MarkDetailItem source)) return;
  159. //if (!(e.NewValue is double score)) return;
  160. //source.tb_score.Text = score.ToString();
  161. }
  162. public Embryo EmbryoData
  163. {
  164. get { return (Embryo)GetValue(EmbryoDataProperty); }
  165. set { SetValue(EmbryoDataProperty, value); }
  166. }
  167. // Using a DependencyProperty as the backing store for EmbryoData. This enables animation, styling, binding, etc...
  168. public static readonly DependencyProperty EmbryoDataProperty =
  169. DependencyProperty.Register("EmbryoData", typeof(Embryo), typeof(MarkDetailItem), new PropertyMetadata(null, new PropertyChangedCallback(EmbryoDataPropertyChangedCallback)));
  170. private static void EmbryoDataPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  171. {
  172. Debug.WriteLine($"{e.OldValue}->{e.NewValue}");
  173. if (!(d is MarkDetailItem source)) return;
  174. if (!(e.NewValue is Embryo embryoData)) return;
  175. string imageurl = $"{AppData.Instance.BaseUrl}{embryoData.imageUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}";
  176. source._image.Source = AppData.Instance.StringToBitmapImage(imageurl);
  177. if (embryoData.score == -1)
  178. source.tb_score.Text = "";
  179. else
  180. source.tb_score.Text = $"{embryoData.score}";//-{embryoData.level}
  181. foreach (var item in embryoData.embryoMark)
  182. {
  183. StackPanel stackPanel = new StackPanel();
  184. stackPanel.Background = new SolidColorBrush(Colors.Transparent);
  185. stackPanel.MouseEnter += source.Image_MouseEnter;
  186. stackPanel.MouseLeave += source.Image_MouseLeave;
  187. stackPanel.Tag = item;
  188. Rectangle rectangle = new Rectangle();
  189. stackPanel.Children.Add(rectangle);
  190. rectangle.Width = 5;
  191. rectangle.Height = 15;
  192. rectangle.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffb000"));
  193. //Image image = new Image();
  194. //stackPanel.Children.Add(image);
  195. //image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/markdetail_xiaohuangkuai.png", UriKind.Absolute));
  196. //image.MouseEnter += source.Image_MouseEnter;
  197. //image.MouseLeave += source.Image_MouseLeave;
  198. //image.Width = 22;
  199. //image.Height = 24;
  200. //image.SetValue(Canvas.LeftProperty, left);
  201. //image.SetValue(Canvas.TopProperty, 96d);
  202. //image.Tag = item;
  203. TextBlock textBlock = new TextBlock();
  204. stackPanel.Children.Add(textBlock);
  205. textBlock.Text = item.markName;
  206. textBlock.FontSize = 16;
  207. if (item.markType == "AI_RECTIFY")
  208. {
  209. textBlock.Foreground = new SolidColorBrush(Colors.Red);
  210. }
  211. double Minutes = item.developTime;
  212. if (Minutes > 10080)
  213. {
  214. Minutes = 10080;
  215. }
  216. double left = Minutes * source.MinuteWidth - stackPanel.ActualWidth / 2d;
  217. //stackPanel.SetValue(Canvas.LeftProperty, left);
  218. stackPanel.SetBinding(Canvas.LeftProperty, new Binding("ActualWidth")
  219. {
  220. RelativeSource = new RelativeSource(RelativeSourceMode.Self),
  221. Converter = new LeftConvert(),
  222. ConverterParameter = Minutes * source.MinuteWidth,
  223. Mode = BindingMode.OneWay,
  224. });
  225. stackPanel.SetValue(Canvas.TopProperty, 93d);
  226. source._cellContainer.Children.Add(stackPanel);
  227. }
  228. }
  229. private static void EmbryoDataPropertyChangedCallback1(DependencyObject d, DependencyPropertyChangedEventArgs e)
  230. {
  231. //Debug.WriteLine($"{e.OldValue}->{e.NewValue}");
  232. if (!(d is MarkDetailItem source)) return;
  233. if (!(e.NewValue is Embryo embryoData)) return;
  234. string imageurl = $"{AppData.Instance.BaseUrl}{embryoData.imageUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}";
  235. source._image.Source = AppData.Instance.StringToBitmapImage(imageurl);
  236. if (embryoData.score == -1)
  237. source.tb_score.Text = "";
  238. else
  239. source.tb_score.Text = $"{embryoData.score}-{embryoData.level}";
  240. foreach (var item in embryoData.embryoMark)
  241. {
  242. Image image = new Image();
  243. image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/markdetail_xiaohuangkuai.png", UriKind.Absolute));
  244. image.MouseEnter += source.Image_MouseEnter;
  245. image.MouseLeave += source.Image_MouseLeave;
  246. image.Width = 22;
  247. image.Height = 24;
  248. double Minutes = item.developTime;
  249. double left = Minutes * source.MinuteWidth - image.Width / 2d;
  250. image.SetValue(Canvas.LeftProperty, left);
  251. image.SetValue(Canvas.TopProperty, 96d);
  252. image.Tag = item;
  253. //Rectangle rectangle = new Rectangle();
  254. //rectangle.Width = 24;
  255. //rectangle.Height = 24;
  256. //rectangle.Fill = new SolidColorBrush(Colors.Red);
  257. //rectangle.SetValue(Canvas.LeftProperty, left);
  258. //rectangle.SetValue(Canvas.TopProperty, 96d);
  259. source._cellContainer.Children.Add(image);
  260. //source.tb_title.Text = (item.markName == null ? "" : item.markName) + item.markType;
  261. //source.tb_title.Text = item.markType;
  262. }
  263. }
  264. public string FaYuTime
  265. {
  266. get { return (string)GetValue(FaYuTimeProperty); }
  267. set { SetValue(FaYuTimeProperty, value); }
  268. }
  269. // Using a DependencyProperty as the backing store for FaYuTime. This enables animation, styling, binding, etc...
  270. public static readonly DependencyProperty FaYuTimeProperty =
  271. DependencyProperty.Register("FaYuTime", typeof(string), typeof(MarkDetailItem), new PropertyMetadata("", new PropertyChangedCallback(OnFaYuPropertyChangedCallback)));
  272. private static void OnFaYuPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  273. {
  274. try
  275. {
  276. if (!(d is MarkDetailItem source)) return;
  277. if (!(e.NewValue is string faYuTime)) return;
  278. if (source.EmbryoData == null) return;
  279. if (source.EmbryoData.wellSn == 4)
  280. {
  281. string ss = "";
  282. }
  283. TimeSpan t3 = new TimeSpan();
  284. if (source.State != (int)EmbryoState.None)
  285. {
  286. if (DateTime.TryParse(source.EmbryoData.stateTime, out DateTime newTime))
  287. {
  288. t3 = newTime - DateTime.Parse(source.EmbryoData.startTime);
  289. }
  290. }
  291. else
  292. {
  293. t3 = DateTime.Now - DateTime.Parse(source.EmbryoData.startTime);
  294. }
  295. double Minutes = t3.TotalMinutes;
  296. //double progress = Minutes * source.MinuteWidth / 1120d * 100d;
  297. double progress = Minutes * source.MinuteWidth / 1225d * 100d;
  298. //double progress = double.Parse(faYuTime) / 168d * 100;
  299. source.Progress = progress;
  300. var childs = source.st_container.Children;
  301. //double count24 = double.Parse(faYuTime) / 24d;
  302. double count24 = Minutes / 1440d;
  303. int intCount24 = (int)count24;
  304. for (int i = 0; i < intCount24; i++)
  305. {
  306. if (i == childs.Count)
  307. break;
  308. Border? border = childs[i] as Border;
  309. if (border == null)
  310. continue;
  311. border.BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#95B1DA"));
  312. TextBlock? textBlock = border.Child as TextBlock;
  313. if (textBlock == null)
  314. continue;
  315. textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
  316. }
  317. }
  318. catch (Exception ex)
  319. {
  320. return;
  321. }
  322. }
  323. public string StateTime
  324. {
  325. get { return (string)GetValue(StateTimeProperty); }
  326. set { SetValue(StateTimeProperty, value); }
  327. }
  328. // Using a DependencyProperty as the backing store for StateTime. This enables animation, styling, binding, etc...
  329. public static readonly DependencyProperty StateTimeProperty =
  330. DependencyProperty.Register("StateTime", typeof(string), typeof(MarkDetailItem), new PropertyMetadata("2023-11-11 23:59:59", new PropertyChangedCallback(StateTimePropertyChangedCallback)));
  331. private static void StateTimePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  332. {
  333. if (!(d is MarkDetailItem source)) return;
  334. if (!(e.NewValue is string stateTime)) return;
  335. if (source.EmbryoData == null) return;
  336. if (source.State == (int)EmbryoState.None || source.State == (int)EmbryoState.End) return;
  337. DateTime time = DateTime.Parse(stateTime);
  338. source.tb_icon_time.Text = $"{time.Month}-{time.Day} {time.Hour}:{time.Minute}";
  339. TimeSpan t3 = time - DateTime.Parse(source.EmbryoData.startTime);
  340. double Minutes = t3.TotalMinutes;
  341. if (Minutes > 10080) Minutes = 10080;
  342. double left = Minutes * source.MinuteWidth - source.st_operate.Width / 2;
  343. source.st_operate.SetValue(Canvas.LeftProperty, left);
  344. }
  345. public string Level
  346. {
  347. get { return (string)GetValue(LevelProperty); }
  348. set { SetValue(LevelProperty, value); }
  349. }
  350. // Using a DependencyProperty as the backing store for Level. This enables animation, styling, binding, etc...
  351. public static readonly DependencyProperty LevelProperty =
  352. DependencyProperty.Register("Level", typeof(string), typeof(MarkDetailItem), new PropertyMetadata("", new PropertyChangedCallback(LevelPropertyChangedCallback)));
  353. private static void LevelPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  354. {
  355. if (!(d is MarkDetailItem source)) return;
  356. if (!(e.NewValue is string level)) return;
  357. source.tb_level.Text = level;
  358. }
  359. public string ImageSource
  360. {
  361. get { return (string)GetValue(ImageSourceProperty); }
  362. set { SetValue(ImageSourceProperty, value); }
  363. }
  364. public static readonly DependencyProperty ImageSourceProperty =
  365. DependencyProperty.Register("ImageSource", typeof(string), typeof(MarkDetailItem), new PropertyMetadata(null, new PropertyChangedCallback(OnImageSourcePropertyChangedCallback)));
  366. private static void OnImageSourcePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  367. {
  368. if (!(d is MarkDetailItem source)) return;
  369. if (!(e.NewValue is string uri)) return;
  370. source._image.Source = new BitmapImage(new Uri(uri));
  371. }
  372. private void SetProgress(double value, Border border)
  373. {
  374. LinearGradientBrush brush = new LinearGradientBrush();
  375. brush.StartPoint = new Point(0, 0);//X横向 //1,1是path右下角
  376. brush.EndPoint = new Point(1, 0);//Y纵向 //1,0是path右上角 从下而上
  377. GradientStop stop1 = new GradientStop();
  378. stop1.Color = Color.FromArgb(255, 102, 138, 189);
  379. stop1.Offset = 0;
  380. GradientStop stop2 = new GradientStop();
  381. stop2.Color = Color.FromArgb(255, 102, 138, 189);
  382. stop2.Offset = value;
  383. GradientStop stop3 = new GradientStop();
  384. stop3.Color = Color.FromArgb(255, 207, 207, 207);
  385. stop3.Offset = value + 0.0001;
  386. brush.GradientStops = new GradientStopCollection() { stop1, stop2, stop3 };
  387. border.Background = brush;
  388. }
  389. private void Image_MouseEnter(object sender, MouseEventArgs e)
  390. {
  391. st_markData.Children.Clear();
  392. if (!(sender is StackPanel image)) return;
  393. //Image? image = sender as Image;
  394. //if (image == null)
  395. // return;
  396. //image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/markdetail_enter.png", UriKind.Absolute));
  397. EmbryoMark? embryoMark = image.Tag as EmbryoMark;
  398. if (embryoMark == null) return;
  399. tb_title.Text = embryoMark.markName;
  400. if (embryoMark.score == -1)
  401. {
  402. //embryoMark.markName == "囊胚" && !string.IsNullOrEmpty(EmbryoData.blastocystLevel)
  403. if (embryoMark.markName == KeyToStringConvert.GetLanguageStringByKey("0293") && !string.IsNullOrEmpty(EmbryoData.blastocystLevel))
  404. {
  405. TextBlock_Score.Visibility = Visibility.Visible;
  406. TextBlock_Score.Text = $"({EmbryoData.blastocystLevel})";
  407. }
  408. else
  409. {
  410. TextBlock_Score.Visibility = Visibility.Collapsed;
  411. }
  412. }
  413. else
  414. {
  415. TextBlock_Score.Visibility = Visibility.Visible;
  416. TextBlock_Score.Text = $"({embryoMark.score.ToString("F2")})";
  417. }
  418. if (embryoMark.markType == "MANUAL_MARK")
  419. {
  420. this.Border_ShouDong.Visibility = Visibility.Visible;
  421. }
  422. else
  423. {
  424. this.Border_ShouDong.Visibility = Visibility.Hidden;
  425. }
  426. this.markDevTime.Text = $"{(embryoMark.developTime / 60).ToString("D2")}h:{(embryoMark.developTime % 60).ToString("D2")}m";
  427. //<StackPanel Orientation="Horizontal" Background="Transparent" Margin="50,10,0,0">
  428. // <TextBlock Text="发育时长:" FontSize="16" Foreground="#707070" FontWeight="Medium"></TextBlock>
  429. // <TextBlock Text="52h50m" Margin="15,0,0,0" FontSize="16" Foreground="#4D4D4D" FontWeight="Medium"></TextBlock>
  430. // </StackPanel>
  431. // <StackPanel Orientation="Horizontal" Background="Transparent" Margin="50,10,0,0">
  432. // <TextBlock Text="发育时长:" FontSize="16" Foreground="#707070" FontWeight="Medium"></TextBlock>
  433. // <TextBlock Text="52h50m" Margin="15,0,0,0" FontSize="16" Foreground="#4D4D4D" FontWeight="Medium"></TextBlock>
  434. // </StackPanel>
  435. if (embryoMark.children != null)
  436. {
  437. foreach (var item in embryoMark.children)
  438. {
  439. KeyValuePair<string, string> keyValuePair = FindData(item, item.markName);
  440. StackPanel stackPanel = new StackPanel();
  441. stackPanel.Orientation = Orientation.Horizontal;
  442. stackPanel.Margin = new Thickness(20, 12, 0, 0);
  443. TextBlock textBlock = CreateTextTitle(true);
  444. textBlock.Text = keyValuePair.Key + ":";
  445. TextBlock textBlock1 = CreateTextTitle(false);
  446. textBlock1.Margin = new Thickness(15, 0, 0, 0);
  447. textBlock1.Text = keyValuePair.Value;
  448. stackPanel.Children.Add(textBlock);
  449. stackPanel.Children.Add(textBlock1);
  450. st_markData.Children.Add(stackPanel);
  451. }
  452. }
  453. Grid grid = new Grid(); ;
  454. grid.Height = 20;
  455. grid.Background = new SolidColorBrush(Colors.Transparent);
  456. st_markData.Children.Add(grid);
  457. _popup.PlacementTarget = image;
  458. _popup.IsOpen = true;
  459. }
  460. private KeyValuePair<string, string> FindData(EmbryoMark embryoMark, string markName)
  461. {
  462. if (embryoMark.child == 1)
  463. {
  464. return FindData(embryoMark.children[0], embryoMark.markName);
  465. }
  466. else
  467. {
  468. KeyValuePair<string, string> keyValuePair = new KeyValuePair<string, string>(markName, embryoMark.markName);
  469. return keyValuePair;
  470. }
  471. }
  472. public string DishIdString
  473. {
  474. get { return (string)GetValue(DishIdStringProperty); }
  475. set { SetValue(DishIdStringProperty, value); }
  476. }
  477. // Using a DependencyProperty as the backing store for DishIdString. This enables animation, styling, binding, etc...
  478. public static readonly DependencyProperty DishIdStringProperty =
  479. DependencyProperty.Register("DishIdString", typeof(string), typeof(MarkDetailItem), new PropertyMetadata(null, new PropertyChangedCallback(StringToDishId)));
  480. private static void StringToDishId(DependencyObject d, DependencyPropertyChangedEventArgs e)
  481. {
  482. if (!(d is MarkDetailItem source)) return;
  483. if (!(e.NewValue is string level))
  484. {
  485. source.DishId = 0;
  486. return;
  487. }
  488. if (long.TryParse(level, out long dishId))
  489. {
  490. source.DishId = dishId;
  491. }
  492. else
  493. {
  494. source.DishId = 0;
  495. }
  496. }
  497. public long DishId
  498. {
  499. get { return (long)GetValue(DishIdProperty); }
  500. set { SetValue(DishIdProperty, value); }
  501. }
  502. // Using a DependencyProperty as the backing store for DishId. This enables animation, styling, binding, etc...
  503. public static readonly DependencyProperty DishIdProperty =
  504. DependencyProperty.Register("DishId", typeof(long), typeof(MarkDetailItem), new PropertyMetadata(0L));
  505. private static TextBlock CreateTextTitle(bool isTitle)
  506. {
  507. TextBlock textBlock = new TextBlock();
  508. if (isTitle)
  509. textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#707070"));
  510. else
  511. textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D4D4D"));
  512. textBlock.FontSize = 16;
  513. textBlock.FontWeight = FontWeights.Medium;
  514. return textBlock;
  515. }
  516. private void Image_MouseLeave(object sender, MouseEventArgs e)
  517. {
  518. _popup.IsOpen = false;
  519. return;
  520. Image? image = sender as Image;
  521. if (image == null)
  522. return;
  523. image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/markdetail_xiaohuangkuai.png", UriKind.Absolute));
  524. //_popup.PlacementTarget = huangkuai;
  525. _popup.IsOpen = false;
  526. }
  527. private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  528. {
  529. if (EmbryoData == null) return;
  530. MarkDetailEvent?.Invoke(EmbryoData, DishId);
  531. //AppData.Instance.MainWindowViewModel.CurrentViewModle = new MarkDetailViewModel1(EmbryoData, DishId);
  532. }
  533. }
  534. }