MarkDetailItem1.xaml.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. using ivf_tl_Entity.Entity.balance;
  2. using ivf_tl_Manage.Converts;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Runtime.CompilerServices;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Navigation;
  17. using System.Windows.Shapes;
  18. using static System.Net.Mime.MediaTypeNames;
  19. namespace ivf_tl_Manage.UserControls
  20. {
  21. /// <summary>
  22. /// MarkDetailItem1.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class MarkDetailItem1 : UserControl
  25. {
  26. public MarkDetailItem1()
  27. {
  28. InitializeComponent();
  29. }
  30. public new Brush Background
  31. {
  32. get { return (Brush)GetValue(BackgroundProperty); }
  33. set { SetValue(BackgroundProperty, value); }
  34. }
  35. public static new readonly DependencyProperty BackgroundProperty =
  36. DependencyProperty.Register("Background", typeof(Brush), typeof(MarkDetailItem1), new PropertyMetadata(null, new PropertyChangedCallback(OnBackgroundPropertyChangedCallback)));
  37. private static void OnBackgroundPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  38. {
  39. if (!(d is MarkDetailItem1 source)) return;
  40. SolidColorBrush colorBrush = (SolidColorBrush)e.NewValue;
  41. if (colorBrush == null) return;
  42. source.st_container.Background = colorBrush;
  43. }
  44. public string BlastocystLevel
  45. {
  46. get { return (string)GetValue(BlastocystLevelProperty); }
  47. set { SetValue(BlastocystLevelProperty, value); }
  48. }
  49. // Using a DependencyProperty as the backing store for BlastocystLevel. This enables animation, styling, binding, etc...
  50. public static readonly DependencyProperty BlastocystLevelProperty =
  51. DependencyProperty.Register("BlastocystLevel", typeof(string), typeof(MarkDetailItem1), new PropertyMetadata(null));
  52. public bool? IsSelect
  53. {
  54. get { return (bool?)GetValue(IsSelectProperty); }
  55. set { SetValue(IsSelectProperty, value); }
  56. }
  57. // Using a DependencyProperty as the backing store for State. This enables animation, styling, binding, etc...
  58. public static readonly DependencyProperty IsSelectProperty =
  59. DependencyProperty.Register("IsSelect", typeof(bool?), typeof(MarkDetailItem1), new PropertyMetadata(null, new PropertyChangedCallback(IsSelectPropertyChangedCallback)));
  60. private static void IsSelectPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  61. {
  62. if (!(d is MarkDetailItem1 source)) return;
  63. bool? state = e.NewValue as bool?;
  64. if (state == null) return;
  65. if (state.Value)
  66. {
  67. source.rect_big.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ECEEF2"));
  68. source.rect_samll.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D75AC"));
  69. source.ellipse_samll.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D75AC"));
  70. source.ellipse_big.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#AFC3DE"));
  71. source.tb_time.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D4D4D"));
  72. }
  73. else
  74. {
  75. source.rect_big.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F6F6F6"));
  76. source.rect_samll.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BBC9DC"));
  77. source.ellipse_samll.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#CFCFCF"));
  78. source.ellipse_big.Fill = new SolidColorBrush(Colors.Transparent);
  79. source.tb_time.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#707070"));
  80. }
  81. }
  82. public EmbryoMark EmbryoData
  83. {
  84. get { return (EmbryoMark)GetValue(EmbryoDataProperty); }
  85. set { SetValue(EmbryoDataProperty, value); }
  86. }
  87. // Using a DependencyProperty as the backing store for EmbryoData. This enables animation, styling, binding, etc...
  88. public static readonly DependencyProperty EmbryoDataProperty =
  89. DependencyProperty.Register("EmbryoData", typeof(EmbryoMark), typeof(MarkDetailItem1), new PropertyMetadata(null, new PropertyChangedCallback(EmbryoDataPropertyChangedCallback)));
  90. private static void EmbryoDataPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  91. {
  92. if (!(d is MarkDetailItem1 source)) return;
  93. if (!(e.NewValue is EmbryoMark embryoData)) return;
  94. string imageurl = $"{AppData.Instance.BaseUrl}{embryoData.pictureUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}";
  95. source.img.Source = AppData.Instance.StringToBitmapImage(imageurl);
  96. source.tb_time.Text = embryoData.createTime.ToString();
  97. source.st_markData.Children.Clear();
  98. //< TextBlock x: Name = "tb_title" Grid.Row = "0" Text = "囊胚期" Margin = "30,15,0,0" FontSize = "20" Foreground = "#4D75AC" FontWeight = "Medium" ></ TextBlock >
  99. StackPanel titleStackPanel = new StackPanel();
  100. titleStackPanel.Orientation=Orientation.Horizontal;
  101. TextBlock tb_title = new TextBlock();
  102. titleStackPanel.Children.Add(tb_title);
  103. tb_title.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D75AC"));
  104. tb_title.FontSize = 25;
  105. tb_title.FontWeight = FontWeights.Medium;
  106. if (embryoData.score == -1)
  107. {
  108. //embryoData.markName == "囊胚" && !string.IsNullOrEmpty(source.BlastocystLevel)
  109. if (embryoData.markName == KeyToStringConvert.GetLanguageStringByKey("0293") && !string.IsNullOrEmpty(source.BlastocystLevel))
  110. {
  111. tb_title.Text = $"{embryoData.markName} ({source.BlastocystLevel})";
  112. }
  113. else
  114. {
  115. tb_title.Text = embryoData.markName;
  116. }
  117. }
  118. else
  119. {
  120. tb_title.Text = $"{embryoData.markName} ({embryoData.score.ToString("F2")})";
  121. }
  122. tb_title.Margin = new Thickness(30, -5, 0, 0);
  123. if (embryoData.markType == "MANUAL_MARK")
  124. {
  125. Border titBorder = new Border();
  126. TextBlock titTextBlock = new TextBlock();
  127. titleStackPanel.Children.Add(titBorder);
  128. titBorder.Child = titTextBlock;
  129. titBorder.Margin=new Thickness (10, -5, 0, 0);
  130. //titBorder.Width = 82;
  131. titBorder.Height = 30;
  132. titBorder.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F9E8CB"));
  133. titBorder.CornerRadius = new CornerRadius(4);
  134. titTextBlock.VerticalAlignment=VerticalAlignment.Center;
  135. titTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
  136. //titTextBlock.Text = "人工标记";
  137. titTextBlock.Text = KeyToStringConvert.GetLanguageStringByKey("0277");
  138. titTextBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ED6306"));
  139. titTextBlock.FontSize = 18;
  140. titTextBlock.FontWeight = FontWeights.Medium;
  141. titTextBlock.Margin = new Thickness(5, -1.5, 5, 0);
  142. }
  143. source.st_markData.Children.Add(titleStackPanel);
  144. // < Border x: Name = "Border_ShouDong" Margin = "10 0 0 0" Width = "82" Height = "30" Background = "#F9E8CB" CornerRadius = "4" >
  145. // < TextBlock VerticalAlignment = "Center" HorizontalAlignment = "Center" Text = "人工标记" Foreground = "#ED6306" FontSize = "18" FontWeight = "Medium" />
  146. //</ Border >
  147. int offsetHeight = 30;
  148. int count = embryoData.children.Count;
  149. if (count > 4)
  150. {
  151. int offsetCount = count - 4;
  152. source._container.Height = source._container.Height + offsetCount * offsetHeight;
  153. source.rect_big.Height = source.rect_big.Height + offsetCount * offsetHeight;
  154. source.rect_samll.Height = source.rect_samll.Height + offsetCount * offsetHeight;
  155. source.st_container.Height = source.st_container.Height + offsetCount * offsetHeight;
  156. source._rect.Height = source._rect.Height + offsetCount * offsetHeight;
  157. }
  158. int i = 0;
  159. #region 发育时长
  160. StackPanel sp = new StackPanel();
  161. sp.Orientation = Orientation.Horizontal;
  162. sp.Margin = new Thickness(30, 20, 0, 0);
  163. TextBlock tb = CreateTextTitle(true);
  164. //tb.Text = "发育时长:";
  165. tb.Text = $"{KeyToStringConvert.GetLanguageStringByKey("0289")}:";
  166. TextBlock tb1 = CreateTextTitle(false);
  167. tb1.Margin = new Thickness(15, 0, 0, 0);
  168. tb1.Text = $"{(embryoData.developTime / 60).ToString("D2")}h:{(embryoData.developTime % 60).ToString("D2")}m";
  169. sp.Children.Add(tb);
  170. sp.Children.Add(tb1);
  171. source.st_markData.Children.Add(sp);
  172. #endregion
  173. foreach (var item in embryoData.children)
  174. {
  175. KeyValuePair<string, string> keyValuePair = source.FindData(item, item.markName);
  176. StackPanel stackPanel = new StackPanel();
  177. stackPanel.Orientation = Orientation.Horizontal;
  178. //if (i == 0)
  179. //{
  180. // stackPanel.Margin = new Thickness(30, 20, 0, 0);
  181. //}
  182. //else
  183. //{
  184. stackPanel.Margin = new Thickness(30, 6, 0, 0);
  185. //}
  186. TextBlock textBlock = CreateTextTitle(true);
  187. textBlock.Text = keyValuePair.Key + ":";
  188. TextBlock textBlock1 = CreateTextTitle(false);
  189. textBlock1.Margin = new Thickness(15, 0, 0, 0);
  190. textBlock1.Text = keyValuePair.Value;
  191. stackPanel.Children.Add(textBlock);
  192. stackPanel.Children.Add(textBlock1);
  193. source.st_markData.Children.Add(stackPanel);
  194. i++;
  195. }
  196. }
  197. private static TextBlock CreateTextTitle(bool isTitle)
  198. {
  199. TextBlock textBlock = new TextBlock();
  200. if (isTitle)
  201. textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#707070"));
  202. else
  203. textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D4D4D"));
  204. textBlock.FontSize = 21;
  205. textBlock.FontWeight = FontWeights.Medium;
  206. textBlock.VerticalAlignment = VerticalAlignment.Center;
  207. return textBlock;
  208. }
  209. private KeyValuePair<string, string> FindData(EmbryoMark embryoMark, string markName)
  210. {
  211. if (embryoMark.child == 1)
  212. {
  213. return FindData(embryoMark.children[0], embryoMark.markName);
  214. }
  215. else
  216. {
  217. KeyValuePair<string, string> keyValuePair = new KeyValuePair<string, string>(markName, embryoMark.markName);
  218. return keyValuePair;
  219. }
  220. }
  221. public string ImageSource
  222. {
  223. get { return (string)GetValue(ImageSourceProperty); }
  224. set { SetValue(ImageSourceProperty, value); }
  225. }
  226. public static readonly DependencyProperty ImageSourceProperty =
  227. DependencyProperty.Register("ImageSource", typeof(string), typeof(MarkDetailItem1), new PropertyMetadata(null, new PropertyChangedCallback(OnImageSourcePropertyChangedCallback)));
  228. private static void OnImageSourcePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
  229. {
  230. if (!(d is MarkDetailItem source)) return;
  231. if (!(e.NewValue is string uri)) return;
  232. source._image.Source = new BitmapImage(new Uri(uri));
  233. }
  234. public event Action<bool, ImageSource> ImageMouseEnterEvent;
  235. private void img_MouseEnter(object sender, MouseEventArgs e)
  236. {
  237. ImageMouseEnterEvent?.Invoke(true, this.img.Source);
  238. }
  239. private void img_MouseLeave(object sender, MouseEventArgs e)
  240. {
  241. ImageMouseEnterEvent?.Invoke(false, this.img.Source);
  242. }
  243. }
  244. }