| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- using ivf_tl_Entity.Entity.balance;
- using ivf_tl_Entity.Enums;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection.Metadata;
- 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;
- namespace ivf_tl_Manage.UserControls
- {
- /// <summary>
- /// DishInfoUserControl.xaml 的交互逻辑
- /// </summary>
- public partial class DishInfoUserControl : UserControl
- {
- public event Action<DishInfoUserControl,House, string> EditAndAddClickEvent;
- public event Action<DishInfoUserControl,House, string> DetailAndAddClickEvent;
- public DishInfoUserControl()
- {
- InitializeComponent();
- centerX = 280 / 2.0;
- centerY = 280 / 2.0;
- angle = 360.00 / 16;
- InitCustom();
- this.IsEnabledChanged -= DishInfoUserControl_IsEnabledChanged;
- this.IsEnabledChanged += DishInfoUserControl_IsEnabledChanged;
- }
- private void DishInfoUserControl_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
- {
- if (this.IsEnabled)
- {
- this.maskHouse.Opacity = 0;
- }
- else
- {
- this.maskHouse.Opacity = 0.2;
- }
- }
- private Dictionary<int, Image> EmbryoStateImageList = new Dictionary<int, Image>();
- private double centerX, centerY;
- private double angle;
- private double angleOffset = 90;
- private int ellipseCount = 16;
- //19
- private int imageRadius = 18;
- //95
- private int imageBigRadius = 100;
- private int textRadius = 77;
- private void InitCustom()
- {
- try
- {
- for (int i = 0; i < ellipseCount; i++)
- {
- Image border = new Image();
- TextBlock textBlock = new TextBlock();
- this._canvas.Children.Add(border);
- this._canvas.Children.Add(textBlock);
- textBlock.Text = $"{i+1}";
- textBlock.TextAlignment = TextAlignment.Center;
- textBlock.FontWeight = FontWeights.Medium;
- textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9B9B9B"));
- //textBlock.Foreground = new SolidColorBrush(Colors.Red);
- //textBlock.Background = new SolidColorBrush(Colors.LightBlue);
- textBlock.FontSize = 9.5;
- textBlock.Width = 12;
- textBlock.Height = 14;
- textBlock.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * textRadius - 6);
- textBlock.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * textRadius - 7);
- EmbryoStateImageList.Add((i + 1), border);
- border.Name = $"B{i + 1}";
- border.Width = imageRadius * 2;
- border.Height = imageRadius * 2;
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/NoEmbryoYuanIcon.png", UriKind.Absolute));
- border.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
- border.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
- }
- }
- catch (Exception)
- {
- throw;
- }
- }
- public House HouseSource
- {
- get { return (House)GetValue(HouseSourceProperty); }
- set { SetValue(HouseSourceProperty, value); }
- }
- // Using a DependencyProperty as the backing store for HouseSource. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty HouseSourceProperty =
- DependencyProperty.Register("HouseSource", typeof(House), typeof(DishInfoUserControl), new PropertyMetadata(new House(), new PropertyChangedCallback(HouseSourcePropertyChangedCallback)));
- private static void HouseSourcePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is DishInfoUserControl source)) return;
- if (e.NewValue == null)
- {
- source.SetDish(source, null);
- return;
- }
- if (!(e.NewValue is House house))
- {
- source.SetDish(source, null);
- return;
- }
- if(house.houseSn == 3)
- {
- string ss = "";
- }
- source.SetDish(source, house.embryoRecordVO);
- return;
- }
- public int HouseSn
- {
- get { return (int)GetValue(HouseSnProperty); }
- set { SetValue(HouseSnProperty, value); }
- }
- // Using a DependencyProperty as the backing store for HouseSn. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty HouseSnProperty =
- DependencyProperty.Register("HouseSn", typeof(int), typeof(DishInfoUserControl), new PropertyMetadata(0));
- public string TLSN
- {
- get { return (string)GetValue(TLSNProperty); }
- set { SetValue(TLSNProperty, value); }
- }
- // Using a DependencyProperty as the backing store for TLSN. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty TLSNProperty =
- DependencyProperty.Register("TLSN", typeof(string), typeof(DishInfoUserControl), new PropertyMetadata(null));
- public int OnLine
- {
- get { return (int)GetValue(OnLineProperty); }
- set { SetValue(OnLineProperty, value); }
- }
- // Using a DependencyProperty as the backing store for OnLine. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty OnLineProperty =
- DependencyProperty.Register("OnLine", typeof(int), typeof(DishInfoUserControl), new PropertyMetadata(1));
- private void Edit_Click(object sender, RoutedEventArgs e)
- {
- if (!this.IsLoaded) return;
- EditAndAddClickEvent?.Invoke(this,HouseSource, TLSN);
- e.Handled = true;
- }
- private void Add_Click(object sender, RoutedEventArgs e)
- {
- if (!this.IsLoaded) return;
- EditAndAddClickEvent?.Invoke(this,HouseSource, TLSN);
- e.Handled = true;
- }
- private void _canvas_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (!this.IsLoaded) return;
- DetailAndAddClickEvent?.Invoke(this,HouseSource, TLSN);
- e.Handled = true;
- }
- public void SetDish(DishInfoUserControl source, Dish dish)
- {
- if (dish == null || dish.embryoList == null || !dish.embryoList.Any())
- {
- foreach (var item in source.EmbryoStateImageList) item.Value.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/NoEmbryoYuanIcon.png", UriKind.Absolute));
- return;
- }
- foreach (var item in source.EmbryoStateImageList)
- {
- var currentEmbryo = dish.embryoList.FirstOrDefault(x => x.wellSn == item.Key);
- if (currentEmbryo == null)
- {
- item.Value.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/NoEmbryoYuanIcon.png", UriKind.Absolute));
- continue;
- }
- EmbryoState state = (EmbryoState)currentEmbryo.state;
- switch (state)
- {
- case EmbryoState.None:
- item.Value.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoYuanIcon.png", UriKind.Absolute));
- break;
- case EmbryoState.Freezing:
- item.Value.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoFreezingIcon.png", UriKind.Absolute));//冷冻
- break;
- case EmbryoState.Transplant:
- item.Value.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoTransplantIcon.png", UriKind.Absolute));//移植
- break;
- case EmbryoState.Cancellation:
- item.Value.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoCancellationIcon.png", UriKind.Absolute));//作废
- break;
- case EmbryoState.Delete:
- item.Value.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoDeleteIcon.png", UriKind.Absolute));//删除
- break;
- default:
- item.Value.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoYuanIcon.png", UriKind.Absolute));
- break;
- }
- }
- }
- }
- }
|