| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- using ivf_tl_Entity.Entity.balance;
- using ivf_tl_Manage.Converts;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using static System.Net.Mime.MediaTypeNames;
- namespace ivf_tl_Manage.UserControls
- {
- /// <summary>
- /// MarkDetailItem1.xaml 的交互逻辑
- /// </summary>
- public partial class MarkDetailItem1 : UserControl
- {
- public MarkDetailItem1()
- {
- InitializeComponent();
- }
- public new Brush Background
- {
- get { return (Brush)GetValue(BackgroundProperty); }
- set { SetValue(BackgroundProperty, value); }
- }
- public static new readonly DependencyProperty BackgroundProperty =
- DependencyProperty.Register("Background", typeof(Brush), typeof(MarkDetailItem1), new PropertyMetadata(null, new PropertyChangedCallback(OnBackgroundPropertyChangedCallback)));
- private static void OnBackgroundPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is MarkDetailItem1 source)) return;
- SolidColorBrush colorBrush = (SolidColorBrush)e.NewValue;
- if (colorBrush == null) return;
- source.st_container.Background = colorBrush;
- }
- public string BlastocystLevel
- {
- get { return (string)GetValue(BlastocystLevelProperty); }
- set { SetValue(BlastocystLevelProperty, value); }
- }
- // Using a DependencyProperty as the backing store for BlastocystLevel. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty BlastocystLevelProperty =
- DependencyProperty.Register("BlastocystLevel", typeof(string), typeof(MarkDetailItem1), new PropertyMetadata(null));
- public bool? IsSelect
- {
- get { return (bool?)GetValue(IsSelectProperty); }
- set { SetValue(IsSelectProperty, value); }
- }
- // Using a DependencyProperty as the backing store for State. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty IsSelectProperty =
- DependencyProperty.Register("IsSelect", typeof(bool?), typeof(MarkDetailItem1), new PropertyMetadata(null, new PropertyChangedCallback(IsSelectPropertyChangedCallback)));
- private static void IsSelectPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is MarkDetailItem1 source)) return;
- bool? state = e.NewValue as bool?;
- if (state == null) return;
- if (state.Value)
- {
- source.rect_big.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ECEEF2"));
- source.rect_samll.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D75AC"));
- source.ellipse_samll.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D75AC"));
- source.ellipse_big.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#AFC3DE"));
- source.tb_time.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D4D4D"));
- }
- else
- {
- source.rect_big.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F6F6F6"));
- source.rect_samll.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BBC9DC"));
- source.ellipse_samll.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#CFCFCF"));
- source.ellipse_big.Fill = new SolidColorBrush(Colors.Transparent);
- source.tb_time.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#707070"));
- }
- }
- public EmbryoMark EmbryoData
- {
- get { return (EmbryoMark)GetValue(EmbryoDataProperty); }
- set { SetValue(EmbryoDataProperty, value); }
- }
- // Using a DependencyProperty as the backing store for EmbryoData. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty EmbryoDataProperty =
- DependencyProperty.Register("EmbryoData", typeof(EmbryoMark), typeof(MarkDetailItem1), new PropertyMetadata(null, new PropertyChangedCallback(EmbryoDataPropertyChangedCallback)));
- private static void EmbryoDataPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is MarkDetailItem1 source)) return;
- if (!(e.NewValue is EmbryoMark embryoData)) return;
- string imageurl = $"{AppData.Instance.BaseUrl}{embryoData.pictureUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}";
- source.img.Source = AppData.Instance.StringToBitmapImage(imageurl);
- source.tb_time.Text = embryoData.createTime.ToString();
- source.st_markData.Children.Clear();
- //< TextBlock x: Name = "tb_title" Grid.Row = "0" Text = "囊胚期" Margin = "30,15,0,0" FontSize = "20" Foreground = "#4D75AC" FontWeight = "Medium" ></ TextBlock >
- StackPanel titleStackPanel = new StackPanel();
- titleStackPanel.Orientation=Orientation.Horizontal;
- TextBlock tb_title = new TextBlock();
- titleStackPanel.Children.Add(tb_title);
- tb_title.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D75AC"));
- tb_title.FontSize = 25;
- tb_title.FontWeight = FontWeights.Medium;
- if (embryoData.score == -1)
- {
- //embryoData.markName == "囊胚" && !string.IsNullOrEmpty(source.BlastocystLevel)
- if (embryoData.markName == KeyToStringConvert.GetLanguageStringByKey("0293") && !string.IsNullOrEmpty(source.BlastocystLevel))
- {
- tb_title.Text = $"{embryoData.markName} ({source.BlastocystLevel})";
- }
- else
- {
- tb_title.Text = embryoData.markName;
- }
- }
- else
- {
- tb_title.Text = $"{embryoData.markName} ({embryoData.score.ToString("F2")})";
- }
- tb_title.Margin = new Thickness(30, -5, 0, 0);
- if (embryoData.markType == "MANUAL_MARK")
- {
- Border titBorder = new Border();
- TextBlock titTextBlock = new TextBlock();
- titleStackPanel.Children.Add(titBorder);
- titBorder.Child = titTextBlock;
- titBorder.Margin=new Thickness (10, -5, 0, 0);
- //titBorder.Width = 82;
- titBorder.Height = 30;
- titBorder.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F9E8CB"));
- titBorder.CornerRadius = new CornerRadius(4);
- titTextBlock.VerticalAlignment=VerticalAlignment.Center;
- titTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
- //titTextBlock.Text = "人工标记";
- titTextBlock.Text = KeyToStringConvert.GetLanguageStringByKey("0277");
- titTextBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ED6306"));
- titTextBlock.FontSize = 18;
- titTextBlock.FontWeight = FontWeights.Medium;
- titTextBlock.Margin = new Thickness(5, -1.5, 5, 0);
- }
- source.st_markData.Children.Add(titleStackPanel);
- // < Border x: Name = "Border_ShouDong" Margin = "10 0 0 0" Width = "82" Height = "30" Background = "#F9E8CB" CornerRadius = "4" >
- // < TextBlock VerticalAlignment = "Center" HorizontalAlignment = "Center" Text = "人工标记" Foreground = "#ED6306" FontSize = "18" FontWeight = "Medium" />
- //</ Border >
- int offsetHeight = 30;
- int count = embryoData.children.Count;
- if (count > 4)
- {
- int offsetCount = count - 4;
- source._container.Height = source._container.Height + offsetCount * offsetHeight;
- source.rect_big.Height = source.rect_big.Height + offsetCount * offsetHeight;
- source.rect_samll.Height = source.rect_samll.Height + offsetCount * offsetHeight;
- source.st_container.Height = source.st_container.Height + offsetCount * offsetHeight;
- source._rect.Height = source._rect.Height + offsetCount * offsetHeight;
- }
- int i = 0;
- #region 发育时长
- StackPanel sp = new StackPanel();
- sp.Orientation = Orientation.Horizontal;
- sp.Margin = new Thickness(30, 20, 0, 0);
- TextBlock tb = CreateTextTitle(true);
- //tb.Text = "发育时长:";
- tb.Text = $"{KeyToStringConvert.GetLanguageStringByKey("0289")}:";
- TextBlock tb1 = CreateTextTitle(false);
- tb1.Margin = new Thickness(15, 0, 0, 0);
- tb1.Text = $"{(embryoData.developTime / 60).ToString("D2")}h:{(embryoData.developTime % 60).ToString("D2")}m";
- sp.Children.Add(tb);
- sp.Children.Add(tb1);
- source.st_markData.Children.Add(sp);
- #endregion
- foreach (var item in embryoData.children)
- {
- KeyValuePair<string, string> keyValuePair = source.FindData(item, item.markName);
- StackPanel stackPanel = new StackPanel();
- stackPanel.Orientation = Orientation.Horizontal;
- //if (i == 0)
- //{
- // stackPanel.Margin = new Thickness(30, 20, 0, 0);
- //}
- //else
- //{
- stackPanel.Margin = new Thickness(30, 6, 0, 0);
- //}
- TextBlock textBlock = CreateTextTitle(true);
- textBlock.Text = keyValuePair.Key + ":";
- TextBlock textBlock1 = CreateTextTitle(false);
- textBlock1.Margin = new Thickness(15, 0, 0, 0);
- textBlock1.Text = keyValuePair.Value;
- stackPanel.Children.Add(textBlock);
- stackPanel.Children.Add(textBlock1);
- source.st_markData.Children.Add(stackPanel);
- i++;
- }
- }
- private static TextBlock CreateTextTitle(bool isTitle)
- {
- TextBlock textBlock = new TextBlock();
- if (isTitle)
- textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#707070"));
- else
- textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D4D4D"));
- textBlock.FontSize = 21;
- textBlock.FontWeight = FontWeights.Medium;
- textBlock.VerticalAlignment = VerticalAlignment.Center;
- return textBlock;
- }
- private KeyValuePair<string, string> FindData(EmbryoMark embryoMark, string markName)
- {
- if (embryoMark.child == 1)
- {
- return FindData(embryoMark.children[0], embryoMark.markName);
- }
- else
- {
- KeyValuePair<string, string> keyValuePair = new KeyValuePair<string, string>(markName, embryoMark.markName);
- return keyValuePair;
- }
- }
- public string ImageSource
- {
- get { return (string)GetValue(ImageSourceProperty); }
- set { SetValue(ImageSourceProperty, value); }
- }
- public static readonly DependencyProperty ImageSourceProperty =
- DependencyProperty.Register("ImageSource", typeof(string), typeof(MarkDetailItem1), new PropertyMetadata(null, new PropertyChangedCallback(OnImageSourcePropertyChangedCallback)));
- private static void OnImageSourcePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is MarkDetailItem source)) return;
- if (!(e.NewValue is string uri)) return;
- source._image.Source = new BitmapImage(new Uri(uri));
- }
- public event Action<bool, ImageSource> ImageMouseEnterEvent;
- private void img_MouseEnter(object sender, MouseEventArgs e)
- {
- ImageMouseEnterEvent?.Invoke(true, this.img.Source);
- }
- private void img_MouseLeave(object sender, MouseEventArgs e)
- {
- ImageMouseEnterEvent?.Invoke(false, this.img.Source);
- }
- }
- }
|