| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709 |
- using ivf_tl_Entity.DTO;
- using ivf_tl_Entity.GlobalEntitys;
- using ivf_tl_Entity.GlobalEnums;
- using ivf_tl_Operate.Converts;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using System.Windows.Markup;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- namespace ivf_tl_Operate.CustomUserControls
- {
- /// <summary>
- /// CustomDishInfo.xaml 的交互逻辑
- /// </summary>
- public partial class CustomDishInfo : UserControl
- {
- public event Action<int> ChangeSelectdIndexEvent;
- public event Action<bool> IsMaxChangedEvent;
- public int selectedIndex = 0;
- private List<TextBlock> TextBlockList = new List<TextBlock>();
- private Dictionary<int, Image> operateImageList = new Dictionary<int, Image>();
- private Dictionary<int, Image> picImageList = new Dictionary<int, Image>();
- private Dictionary<int, Border> BackBorderList = new Dictionary<int, Border>();
- private int ellipseCount = 16;
- private double operateBigRadius = 732;
- private double imageBigRadius = 632;
- private double textBigRadius = 500;
- private double operateRadius = 20;
- private double imageRadius = 107;
- private double centerX = 0;
- private double centerY = 0;
- private double angle = 0;
- /// <summary>
- /// 旋转角度
- /// </summary>
- private double angleOffset = 90;
- /// <summary>
- /// 字体默认颜色
- /// </summary>
- private Color DefaultFontColor { get; set; } = Color.FromArgb(255, 110, 114, 118);
- /// <summary>
- /// 字体选中颜色
- /// </summary>
- private Color SelectFontColor { get; set; } = Colors.White;
- bool isInit = false;
- public CustomDishInfo()
- {
- InitializeComponent();
- centerX = this._canvas.Width / 2;
- centerY = this._canvas.Height / 2;
- angle = 360d / ellipseCount;
- Unloaded += (s, e) =>
- {
- if (ExDishSource == null) return;
- foreach (var item in ExDishSource.embryoList)
- {
- item.AlarmChangedEvent -= EmbryoAlarmEvent;
- }
- ExDishSource = null;
- this._canvas.Children.Clear();
- };
- }
- private void InitCustom()
- {
- for (int i = 0; i < ellipseCount; i++)
- {
- TextBlock borderT = new TextBlock();
- Panel.SetZIndex(borderT, 11);
- this._canvas.Children.Add(borderT);
- borderT.Height = 28;
- borderT.Width = 35;
- borderT.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Width / 2);
- borderT.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Height / 2);
- borderT.Text = $"{i + 1}";
- borderT.TextAlignment = TextAlignment.Center;
- borderT.FontSize = 27;
- if (i == 0)
- {
- borderT.Foreground = new SolidColorBrush(SelectFontColor);
- }
- else
- {
- borderT.Foreground = new SolidColorBrush(DefaultFontColor);
- }
- TextBlockList.Add(borderT);
- Image operateBorder = new Image();
- Panel.SetZIndex(operateBorder, 13);
- this._canvas.Children.Add(operateBorder);
- operateImageList.Add((i + 1), operateBorder);
- operateBorder.Width = operateRadius * 2;
- operateBorder.Height = operateRadius * 2;
- operateBorder.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * operateBigRadius - operateBorder.Width / 2);
- operateBorder.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * operateBigRadius - operateBorder.Height / 2);
- operateBorder.Visibility = Visibility.Collapsed;
- Border imageBorder = new Border();
- Panel.SetZIndex(imageBorder, 12);
- this._canvas.Children.Add(imageBorder);
- Image embryoImage = new Image();
- imageBorder.Child = embryoImage;
- EllipseGeometry ellipseGeometry = new EllipseGeometry(new Point(imageRadius, imageRadius), imageRadius - 3, imageRadius - 3);
- embryoImage.SetValue(Image.ClipProperty, ellipseGeometry);
- imageBorder.Tag = i;
- imageBorder.Width = imageRadius * 2;
- imageBorder.Height = imageRadius * 2;
- embryoImage.Width = imageRadius * 2;
- embryoImage.Height = imageRadius * 2;
- picImageList.Add(i + 1, embryoImage);
- imageBorder.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageBorder.Width / 2);
- imageBorder.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageBorder.Height / 2);
- imageBorder.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/ellipse_backgroud.png", UriKind.Absolute)));
- //border.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/ellipse_backgroud.png", UriKind.RelativeOrAbsolute));
- //if (i > 10)
- //{
- // border.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/ellipse_noembryo.png", UriKind.RelativeOrAbsolute));
- //}
- imageBorder.MouseDown += (s, e) =>
- {
- if (!(s is Border source)) return;
- int index = (int)source.Tag;
- if (selectedIndex == index) return;
- SelectIndex(index);
- ChangeSelectdIndexEvent?.Invoke(index + 1);
- };
- }
- }
- public void InitCustomNew()
- {
- for (int i = 0; i < ellipseCount; i++)
- {
- TextBlock borderT = new TextBlock();
- TextBlockList.Add(borderT);
- Panel.SetZIndex(borderT, 11);
- this._canvas.Children.Add(borderT);
- borderT.Height = 28;
- borderT.Width = 35;
- borderT.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Width / 2);
- borderT.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - borderT.Height / 2);
- borderT.Text = $"{i + 1}";
- borderT.TextAlignment = TextAlignment.Center;
- borderT.FontSize = 27;
- if (i == 0)
- {
- borderT.Foreground = new SolidColorBrush(SelectFontColor);
- }
- else
- {
- borderT.Foreground = new SolidColorBrush(DefaultFontColor);
- }
- Image operateBorder = new Image();
- Panel.SetZIndex(operateBorder, 13);
- this._canvas.Children.Add(operateBorder);
- operateImageList.Add((i + 1), operateBorder);
- operateBorder.Width = operateRadius * 2;
- operateBorder.Height = operateRadius * 2;
- operateBorder.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * operateBigRadius - operateBorder.Width / 2);
- operateBorder.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * operateBigRadius - operateBorder.Height / 2);
- operateBorder.Visibility = Visibility.Collapsed;
- Border imageBorder = new Border();
- BackBorderList.Add(i + 1, imageBorder);
- Panel.SetZIndex(imageBorder, 12);
- this._canvas.Children.Add(imageBorder);
- Image embryoImage = new Image();
- picImageList.Add(i + 1, embryoImage);
- imageBorder.Child = embryoImage;
- int kk = 20;
- embryoImage.Width = imageRadius * 2;
- embryoImage.Height = imageRadius * 2;
- EllipseGeometry ellipseGeometry = new EllipseGeometry(new Point(imageRadius, imageRadius), imageRadius - kk, imageRadius - kk);
- embryoImage.SetValue(Image.ClipProperty, ellipseGeometry);
- imageBorder.Tag = i;
- imageBorder.Width = imageRadius * 2;
- imageBorder.Height = imageRadius * 2;
- imageBorder.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageBorder.Width / 2);
- imageBorder.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageBorder.Height / 2);
- if (ExDishSource != null)
- {
- var itemEmbryo = SetWellImage(i + 1, 1);
- if (itemEmbryo == null)
- {
- embryoImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailNoEmbryo.png", UriKind.Absolute));
- }
- else
- {
- embryoImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailNoEmbryo1.png", UriKind.Absolute));
- }
- }
- else
- {
- imageBorder.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailNoEmbryoBackground.png", UriKind.Absolute)));
- }
- int index = i;
- imageBorder.MouseDown += (s, e) =>
- {
- if (selectedIndex == index) return;
- SelectIndex(index);
- ChangeSelectdIndexEvent?.Invoke(index + 1);
- };
- }
- }
- public void NextEmbryo()
- {
- int index = selectedIndex;
- if (index == 15)
- {
- index = 0;
- }
- else
- {
- index++;
- }
- SelectIndex(index);
- ChangeSelectdIndexEvent?.Invoke(index + 1);
- }
- public void LastEmbryo()
- {
- int index = selectedIndex;
- if (index == 0)
- {
- index = 15;
- }
- else
- {
- index--;
- }
- SelectIndex(index);
- ChangeSelectdIndexEvent?.Invoke(index + 1);
- }
- private object lock1 = new object();
- private ExEmbryo SetWellImage(int index, int oldIndex)
- {
- lock (lock1)
- {
- if (ExDishSource == null) return null;
- Border imageBorder = BackBorderList[index];
- //Image embryoImage = picImageList[index];
- var itemEmbryo = ExDishSource.embryoList.FirstOrDefault(x => x.wellSn == index);
- if (itemEmbryo == null)
- {
- if (index == oldIndex)
- {
- imageBorder.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoSelectedIcon.png", UriKind.Absolute)));
- }
- else
- {
- imageBorder.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailNoEmbryoBackground.png", UriKind.Absolute)));
- }
- return itemEmbryo;
- }
- string borderSource = null;
- switch ((EmbryoState)itemEmbryo.state)
- {
- case EmbryoState.End:
- case EmbryoState.None:
- if (itemEmbryo.alarm == 1)
- {
- borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState3Icon.png";
- }
- else
- {
- if (index == oldIndex)
- {
- borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoSelectedIcon.png";
- }
- else
- {
- borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoBackground.png";
- }
- }
- break;
- case EmbryoState.Freezing: //冷冻
- borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState1Icon.png";
- break;
- case EmbryoState.Transplant://移植
- borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState2Icon.png";
- break;
- case EmbryoState.Cancellation://作废
- borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState3Icon.png";
- break;
- case EmbryoState.Delete://删除
- borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState4Icon.png";
- break;
- }
- imageBorder.Background = new ImageBrush(new BitmapImage(new Uri(borderSource, UriKind.Absolute)));
- return itemEmbryo;
- }
- }
- private void SelectIndex(int index)
- {
- TextBlockList[selectedIndex].Foreground = new SolidColorBrush(DefaultFontColor);
- SetWellImage(selectedIndex + 1, 0);
- selectedIndex = index;
- var itemEmbryo = ExDishSource.embryoList.FirstOrDefault(x => x.wellSn == selectedIndex + 1);
- if (itemEmbryo == null)
- {
- BackBorderList[selectedIndex + 1].Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoSelectedIcon.png", UriKind.Absolute)));
- }
- else
- {
- if ((itemEmbryo.state == (int)EmbryoState.End || itemEmbryo.state == (int)EmbryoState.None) && itemEmbryo.alarm == 0)
- {
- BackBorderList[selectedIndex + 1].Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoSelectedIcon.png", UriKind.Absolute)));
- }
- }
- RotateTransform rotateTransform = this._sx.RenderTransform as RotateTransform;
- if (rotateTransform == null)
- rotateTransform = new RotateTransform();
- rotateTransform.Angle = angle * index;
- //this._sx.RenderTransformOrigin = new Point(0.5, 0);
- this._sx.RenderTransform = rotateTransform;
- //foreach (var item in TextBlockList)
- //{
- // item.Foreground = new SolidColorBrush(DefaultFontColor);
- //}
- TextBlockList[index].Foreground = new SolidColorBrush(SelectFontColor);
- }
- private void mediaElementPlayer_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- string ss = "";
- }
- private void _preview_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- string ss11 = "";
- }
- private void _canvas_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- string ss2 = "";
- }
- public ExDish ExDishSource
- {
- get { return (ExDish)GetValue(ExDishSourceProperty); }
- set { SetValue(ExDishSourceProperty, value); }
- }
- // Using a DependencyProperty as the backing store for ExDishSource. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty ExDishSourceProperty =
- DependencyProperty.Register("ExDishSource", typeof(ExDish), typeof(CustomDishInfo), new PropertyMetadata(null, new PropertyChangedCallback(ExDishSourcePropertyChanged)));
- private static void ExDishSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (!(d is CustomDishInfo source)) return;
- if (source.DataContext == null) return;
- if (e.NewValue == null)
- {
- source.SetDish(source, null);
- return;
- }
- if (!(e.NewValue is ExDish exDish))
- {
- source.SetDish(source, null);
- return;
- }
- if (!source.isInit)
- {
- source.isInit = true;
- source.InitCustomNew();
- }
- source.SetDish(source, exDish);
- foreach (var item in exDish.embryoList)
- {
- item.AlarmChangedEvent -= source.EmbryoAlarmEvent;
- item.AlarmChangedEvent += source.EmbryoAlarmEvent;
- }
- return;
- }
- private void EmbryoAlarmEvent(int wellsn, int stateAlarm)
- {
- Dispatcher.Invoke(() => { SetWellImage(wellsn, selectedIndex + 1); });
- }
- private void SetDish(CustomDishInfo customDishInfo, ExDish exDish)
- {
- if (exDish == null)
- {
- foreach (var item in customDishInfo.operateImageList)
- {
- if (item.Value.Visibility != Visibility.Hidden)
- {
- item.Value.Visibility = Visibility.Hidden;
- }
- }
- foreach (var item in picImageList)
- {
- item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/ellipse_backgroud.png", UriKind.Relative));
- }
- return;
- }
- foreach (var item in customDishInfo.operateImageList)
- {
- var embryo = exDish.embryoList.FirstOrDefault(x => x.wellSn == item.Key);
- if (embryo == null)
- {
- item.Value.Visibility = Visibility.Hidden;
- continue;
- }
- item.Value.Visibility = Visibility.Visible;
- EmbryoState state = (EmbryoState)embryo.state;
- switch (state)
- {
- case EmbryoState.Freezing:
- item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/open_button_freezable.png", UriKind.Relative));//冷冻
- break;
- case EmbryoState.Transplant:
- item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/yz.png", UriKind.Relative));//移植
- break;
- case EmbryoState.Cancellation:
- item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/open_button_no.png", UriKind.Relative));//作废
- break;
- case EmbryoState.Delete:
- item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/menu_delete.png", UriKind.Relative));//作废
- break;
- default:
- item.Value.Visibility = Visibility.Hidden;
- break;
- }
- }
- }
- /// <summary>
- /// 设置胚胎状态
- /// </summary>
- /// <param name="well"></param>
- /// <param name="embryoState"></param>
- public void SetEmbryoState(int well, int embryoState, int alarm)
- {
- var item = operateImageList[well];
- EmbryoState state = (EmbryoState)embryoState;
- item.Visibility = Visibility.Visible;
- switch (state)
- {
- case EmbryoState.Freezing:
- item.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/open_button_freezable.png", UriKind.Relative));//冷冻
- break;
- case EmbryoState.Transplant:
- item.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/yz.png", UriKind.Relative));//移植
- break;
- case EmbryoState.Cancellation:
- item.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/open_button_no.png", UriKind.Relative));//作废
- break;
- case EmbryoState.Delete:
- item.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/menu_delete.png", UriKind.Relative));//作废
- break;
- default:
- item.Visibility = Visibility.Hidden;
- break;
- }
- string borderSource = null;
- switch ((EmbryoState)embryoState)
- {
- case EmbryoState.End:
- case EmbryoState.None:
- if (alarm == 0)
- {
- borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoSelectedIcon.png";
- }
- else
- {
- borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState3Icon.png";
- }
- break;
- case EmbryoState.Freezing: //冷冻
- borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState1Icon.png";
- break;
- case EmbryoState.Transplant://移植
- borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState2Icon.png";
- break;
- case EmbryoState.Cancellation://作废
- borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState3Icon.png";
- break;
- case EmbryoState.Delete://删除
- borderSource = "pack://application:,,,/ivf_tl_Operate;component/Resources/Image/pc_DetailEmbryoState4Icon.png";
- break;
- }
- BackBorderList[well].Background = new ImageBrush(new BitmapImage(new Uri(borderSource, UriKind.Absolute)));
- }
- /// <summary>
- /// 设置缩略图
- /// </summary>
- /// <param name="datas"></param>
- public void SetEmbryoPic(List<DishPicAndVideo> datas)
- {
- foreach (var item in picImageList)
- {
- var embryo = ExDishSource.embryoList.FirstOrDefault(x => x.wellSn == item.Key);
- if (embryo == null)
- {
- item.Value.Tag = 0;
- //item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/ellipse_backgroud.png", UriKind.Relative));
- item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/pc_DetailNoEmbryo.png", UriKind.Relative));
- continue;
- }
- var currentData = datas.FirstOrDefault(x => x.wellSn == embryo.wellSn);
- if (currentData == null || currentData.lastPicture == null)
- {
- item.Value.Tag = 0;
- //item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/ellipse_noembryo.png", UriKind.Relative));
- item.Value.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/DetailEmbryoNoPic.png", UriKind.Relative));
- }
- else
- {
- item.Value.Tag = 1;
- 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()}");
- }
- //if (item.Value.Parent is Border parentBorder)
- // parentBorder.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Operate;component/Resources/Image/ellipse_backgroud.png", UriKind.Absolute)));
- }
- }
- public void SetPreview(DishPicAndVideo dishPicAndVideo)
- {
- this.Cancas_Preview.Visibility = Visibility.Visible;
- this.TextBlock_Preview.Text = "";
- if (dishPicAndVideo == null || string.IsNullOrEmpty(dishPicAndVideo.lastPicture))
- {
- //this._preview.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/video_preview.png", UriKind.Relative));
- AppData.Instance.SetImageSource(this._preview, LogoEnum.BlackCircle);
- return;
- }
- this._preview.Source = AppData.Instance.ConvertHelper.StringToBitmapImage($"{AppData.Instance.BaseUrl}{dishPicAndVideo.lastPicture}?token={AppData.Instance.HttpHelper.GetToken()}");
- }
- public void SetPreviewNoVideo()
- {
- this.Cancas_Preview.Visibility = Visibility.Visible;
- this._preview.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/none_video.png", UriKind.Relative));
- this.TextBlock_Preview.Text = KeyToStringConvert.GetLanguageStringByKey("C0287");
- }
- bool isMax = false;
- double maxWidth = 1583;
- double minWidth = 840;
- double maxLeft = 0;
- double minLeft = 371.5;
- private void PreviewMouseDownEvent(object sender, System.Windows.Input.MouseButtonEventArgs e)
- {
- if (e.ChangedButton == MouseButton.Left && e.ClickCount == 2)
- {
- if (isMax == false)
- {
- isMax = true;
- mask.Width = maxWidth;
- mask.Height = maxWidth;
- //Image_Load.Width= maxWidth;
- //Image_Load.Height= maxWidth;
- mediaElementPlayer.Width = maxWidth;
- mediaElementPlayer.Height = maxWidth;
- //_preview.Width = maxWidth;
- //_preview.Height = maxWidth;
- Canvas.SetLeft(mask, maxLeft);
- Canvas.SetTop(mask, maxLeft);
- //Canvas.SetLeft(Image_Load, maxLeft);
- //Canvas.SetTop(Image_Load, maxLeft);
- //Image_Load.SetValue(Panel.ZIndexProperty, 15);
- Canvas.SetLeft(mediaElementPlayer, maxLeft);
- Canvas.SetTop(mediaElementPlayer, maxLeft);
- mediaElementPlayer.SetValue(Panel.ZIndexProperty, 16);
- //Canvas.SetLeft(_preview, maxLeft);
- //Canvas.SetTop(_preview, maxLeft);
- //_preview.SetValue(Panel.ZIndexProperty, 17);
- }
- else
- {
- isMax = false;
- mask.Width = minWidth;
- mask.Height = minWidth;
- //Image_Load.Width = minWidth;
- //Image_Load.Height = minWidth;
- mediaElementPlayer.Width = minWidth;
- mediaElementPlayer.Height = minWidth;
- //_preview.Width = minWidth;
- //_preview.Height = minWidth;
- Canvas.SetLeft(mask, minLeft);
- Canvas.SetTop(mask, minLeft);
- //Canvas.SetLeft(Image_Load, minLeft);
- //Canvas.SetTop(Image_Load, minLeft);
- //Image_Load.SetValue(Panel.ZIndexProperty, 7);
- Canvas.SetLeft(mediaElementPlayer, minLeft);
- Canvas.SetTop(mediaElementPlayer, minLeft);
- mediaElementPlayer.SetValue(Panel.ZIndexProperty, 8);
- //Canvas.SetLeft(_preview, minLeft);
- //Canvas.SetTop(_preview, minLeft);
- //_preview.SetValue(Panel.ZIndexProperty, 9);
- }
- mask.CornerRadius = new CornerRadius(Width / 2);
- SetLoad(isMax);
- SetPreView(isMax);
- IsMaxChangedEvent?.Invoke(isMax);
- e.Handled = true;
- }
- }
- private void SetPreView(bool ismax)
- {
- if (ismax)
- {
- _preview.Width = maxWidth;
- _preview.Height = maxWidth;
- Cancas_Preview.Width = maxWidth;
- Cancas_Preview.Height = maxWidth;
- TextBlock_Preview.Width = maxWidth;
- TextBlock_Preview.FontSize = 98;
- Canvas.SetTop(TextBlock_Preview, 958);
- Canvas.SetLeft(Cancas_Preview, maxLeft);
- Canvas.SetTop(Cancas_Preview, maxLeft);
- Cancas_Preview.SetValue(Panel.ZIndexProperty, 17);
- }
- else
- {
- _preview.Width = minWidth;
- _preview.Height = minWidth;
- Cancas_Preview.Width = minWidth;
- Cancas_Preview.Height = minWidth;
- TextBlock_Preview.Width = minWidth;
- TextBlock_Preview.FontSize = 50;
- Canvas.SetTop(TextBlock_Preview, 512);
- Canvas.SetLeft(Cancas_Preview, minLeft);
- Canvas.SetTop(Cancas_Preview, minLeft);
- Cancas_Preview.SetValue(Panel.ZIndexProperty, 9);
- }
- }
- private void SetLoad(bool ismax)
- {
- if (ismax)
- {
- Image_Load.Width = maxWidth;
- Image_Load.Height = maxWidth;
- Cancas_Load.Width = maxWidth;
- Cancas_Load.Height = maxWidth;
- TextBlock_Load.Width = maxWidth;
- TextBlock_Load.FontSize = 98;
- Canvas.SetTop(TextBlock_Load, 958);
- Canvas.SetLeft(Cancas_Load, maxLeft);
- Canvas.SetTop(Cancas_Load, maxLeft);
- Cancas_Load.SetValue(Panel.ZIndexProperty, 15);
- }
- else
- {
- Image_Load.Width = minWidth;
- Image_Load.Height = minWidth;
- Cancas_Load.Width = minWidth;
- Cancas_Load.Height = minWidth;
- TextBlock_Load.Width = minWidth;
- TextBlock_Load.FontSize = 50;
- Canvas.SetTop(TextBlock_Load, 512);
- Canvas.SetLeft(Cancas_Load, minLeft);
- Canvas.SetTop(Cancas_Load, minLeft);
- Cancas_Load.SetValue(Panel.ZIndexProperty, 7);
- }
- }
- }
- }
|