|
|
@@ -1,458 +0,0 @@
|
|
|
-using ivf_tl_Entity.Entity.balance;
|
|
|
-using ivf_tl_Entity.Entity.Result;
|
|
|
-using ivf_tl_Entity.Enums;
|
|
|
-using ivf_tl_Entity.Response;
|
|
|
-using ivf_tl_Manage.Converts;
|
|
|
-using ivf_tl_Manage.UserControls;
|
|
|
-using ivf_tl_Service.HttpProvider;
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
-using System.Text;
|
|
|
-using System.Text.RegularExpressions;
|
|
|
-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.Shapes;
|
|
|
-
|
|
|
-namespace ivf_tl_Manage.Win
|
|
|
-{
|
|
|
- /// <summary>
|
|
|
- /// AutoFocusWindow.xaml 的交互逻辑
|
|
|
- /// </summary>
|
|
|
- public partial class AutoFocusWindow : Window
|
|
|
- {
|
|
|
- PicProvider picProvider;
|
|
|
- string tlSn;
|
|
|
- int houseSn;
|
|
|
- public AutoFocusWindow(string tlSn, int houseSn, List<Embryo> EmbryoList, Embryo currentEmbryo)
|
|
|
- {
|
|
|
- InitializeComponent();
|
|
|
- this.Owner = AppData.Instance.MainWindow;
|
|
|
- picProvider = AppData.Instance.GetPicProvider();
|
|
|
- this.tlSn = tlSn;
|
|
|
- this.houseSn = houseSn;
|
|
|
- int currentWellSn = EmbryoList.First().wellSn;
|
|
|
- if (currentEmbryo != null && currentEmbryo.state == (int)EmbryoState.None) currentWellSn = currentEmbryo.wellSn;
|
|
|
- Loaded += (s, e) =>
|
|
|
- {
|
|
|
- List<PositionEntity> ItemSourceData = new List<PositionEntity>();
|
|
|
- var dataList = picProvider.GetPositionApi(tlSn, houseSn, EmbryoList.Select(x => x.wellSn).ToList());
|
|
|
- foreach (var item in dataList)
|
|
|
- {
|
|
|
- item.focusStartingPoint = item.verticalMotorPosition;
|
|
|
- var item11 = EmbryoList.FirstOrDefault(x => x.wellSn == item.wellSn);
|
|
|
- if (item11 != null)
|
|
|
- {
|
|
|
- item.EmbryoId = item11.id;
|
|
|
- ItemSourceData.Add(item);
|
|
|
- }
|
|
|
- }
|
|
|
- var currentPost = ItemSourceData.FirstOrDefault(x => x.wellSn == currentWellSn);
|
|
|
- this.ListBox_Well.ItemsSource = ItemSourceData;
|
|
|
- if (currentPost == null) this.ListBox_Well.SelectedIndex = 0;
|
|
|
- else this.ListBox_Well.SelectedItem = currentPost;
|
|
|
- };
|
|
|
- Unloaded += (s, e) =>
|
|
|
- {
|
|
|
- this.Canvas_BigRoot.Children.Clear();
|
|
|
- AppData.Instance.MainWindow.Activate();
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- private void Button_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- if (this.ListBox_Well.SelectedItem == null) return;
|
|
|
- if (!(this.ListBox_Well.SelectedItem is PositionEntity positionEntity)) return;
|
|
|
- string ss = this.TextBlock_focusStartingPoint.Text.Trim();
|
|
|
- if (string.IsNullOrEmpty(ss))
|
|
|
- {
|
|
|
- //new ToastMessageWindow(AppData.Instance.MainWindow, $"请输入新位置").Show();
|
|
|
- new ToastMessageWindow(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("0310")).Show();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!int.TryParse(ss, out int newValue))
|
|
|
- {
|
|
|
- new ToastMessageWindow(AppData.Instance.MainWindow, $"新位置只能是数字").Show();
|
|
|
- return;
|
|
|
- }
|
|
|
- positionEntity.IsUpdate = true;
|
|
|
- positionEntity.focusStartingPoint = newValue;
|
|
|
- //new ToastMessageWindow(AppData.Instance.MainWindow, $"缓存成功!").Show();
|
|
|
- new ToastMessageWindow(AppData.Instance.MainWindow, $"{KeyToStringConvert.GetLanguageStringByKey("0311")}!").Show();
|
|
|
- }
|
|
|
-
|
|
|
- Dictionary<int, PicSourceUserControl> ListPic = new Dictionary<int, PicSourceUserControl>();
|
|
|
-
|
|
|
- private void ListBox_Selected(object sender, SelectionChangedEventArgs e)
|
|
|
- {
|
|
|
- if (!(sender is ListBox source)) return;
|
|
|
- if (source.SelectedItem == null) return;
|
|
|
- if (!(source.SelectedItem is PositionEntity positionEntity)) return;
|
|
|
- this.TextBlock_verticalMotorPosition.Text = positionEntity.verticalMotorPosition.ToString();
|
|
|
- this.TextBlock_focusStartingPoint.Text = positionEntity.focusStartingPoint.ToString();
|
|
|
- int CheckBoxImageNum = 1;
|
|
|
- int ImageIndex = 1;
|
|
|
- this.Canvas_Big.Visibility = Visibility.Collapsed;
|
|
|
- Task.Run(() =>
|
|
|
- {
|
|
|
- var a = picProvider.GetAutofocusPicturesApi(tlSn, houseSn, positionEntity.EmbryoId);
|
|
|
- Dispatcher.Invoke(() =>
|
|
|
- {
|
|
|
- if (string.IsNullOrEmpty(a.autofocusTime))
|
|
|
- {
|
|
|
- this.TextBlock_Title.Visibility = Visibility.Hidden;
|
|
|
- this.TextBlock_AutoTime.Visibility = Visibility.Hidden;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this.TextBlock_Title.Visibility = Visibility.Visible;
|
|
|
- this.TextBlock_AutoTime.Visibility = Visibility.Visible;
|
|
|
- }
|
|
|
- this.TextBlock_AutoTime.Text = a.autofocusTime;
|
|
|
- _root_Canvas.Children.Clear();
|
|
|
- ListPic.Clear();
|
|
|
- if (!a.focusPreviewPictureVOList.Any()) return;
|
|
|
- string imageurlString = null;
|
|
|
- BitmapImage BitmapImageSource = null;
|
|
|
-
|
|
|
- //for (int i = (a.focusPreviewPictureVOList.Count - 1); i >= 12; i--)
|
|
|
- //{
|
|
|
- // var item = a.focusPreviewPictureVOList[i];
|
|
|
- // item.imageUrl = item.sourceImageUrl;
|
|
|
- //}
|
|
|
-
|
|
|
- for (int i = 0; i < a.focusPreviewPictureVOList.Count; i++)
|
|
|
- {
|
|
|
- var item = a.focusPreviewPictureVOList[i];
|
|
|
- imageurlString = item.imageUrl;
|
|
|
- if (this._yuantu.IsChecked == true)
|
|
|
- {
|
|
|
- imageurlString = item.sourceImageUrl;
|
|
|
- }
|
|
|
- if (string.IsNullOrEmpty(imageurlString))
|
|
|
- {
|
|
|
- BitmapImageSource = null;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- BitmapImageSource = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{imageurlString.Replace(AppData.Instance.PicSuf, $"_180x180{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpServiceCall.GetToken()}");
|
|
|
- }
|
|
|
- PicSourceUserControl checkBoxImage = new PicSourceUserControl()
|
|
|
- {
|
|
|
- ImageSourceUrl = BitmapImageSource,
|
|
|
- ImageInfoString = $"{item.houseSn}-{item.wellSn}-{item.shootingPosition}.jpg",
|
|
|
- ImageUrl = imageurlString,
|
|
|
- };
|
|
|
- if (item.highestScore)
|
|
|
- {
|
|
|
- checkBoxImage.templateRoot.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#666DA5FF"));
|
|
|
- }
|
|
|
-
|
|
|
- if (CheckBoxImageNum > 7)
|
|
|
- {
|
|
|
- if ((CheckBoxImageNum - 1) % 7 == 0) checkBoxImage.Margin = new Thickness(0, 10, 0, 0);
|
|
|
- else checkBoxImage.Margin = new Thickness(10, 10, 0, 0);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (CheckBoxImageNum == 1) checkBoxImage.Margin = new Thickness(0);
|
|
|
- else checkBoxImage.Margin = new Thickness(10, 0, 0, 0);
|
|
|
- }
|
|
|
-
|
|
|
- var k = ImageIndex;
|
|
|
- checkBoxImage.Tag = item;
|
|
|
- checkBoxImage.MouseDown += (s, e) =>
|
|
|
- {
|
|
|
- this.Text_Big.Text = checkBoxImage.ImageInfoString;
|
|
|
- this.Image_Big.Source = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{checkBoxImage.ImageUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}");
|
|
|
- this.Canvas_Big.Visibility = Visibility.Visible;
|
|
|
- this.Image_Big.Tag = k;
|
|
|
-
|
|
|
- if (k < ListPic.Last().Key)
|
|
|
- {
|
|
|
- this._nextPic_Button.Visibility = Visibility.Visible;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this._nextPic_Button.Visibility = Visibility.Hidden;
|
|
|
- }
|
|
|
- if (k > 1)
|
|
|
- {
|
|
|
- this._prePic_Button.Visibility = Visibility.Visible;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this._prePic_Button.Visibility = Visibility.Hidden;
|
|
|
- }
|
|
|
- };
|
|
|
- CheckBoxImageNum++;
|
|
|
- ListPic.Add(k, checkBoxImage);
|
|
|
- ImageIndex++;
|
|
|
- _root_Canvas.Children.Add(checkBoxImage);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void Button1_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- if (!this.ListBox_Well.HasItems) return;
|
|
|
- if (this.ListBox_Well.SelectedItem == null) return;
|
|
|
- if (!(this.ListBox_Well.SelectedItem is PositionEntity CurrentPositionEntity)) return;
|
|
|
- string ss = this.TextBlock_focusStartingPoint.Text.Trim();
|
|
|
- if (string.IsNullOrEmpty(ss))
|
|
|
- {
|
|
|
- //new ToastMessageWindow(AppData.Instance.MainWindow, $"请输入新位置").Show();
|
|
|
- new ToastMessageWindow(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("0310")).Show();
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!int.TryParse(ss, out int newValue))
|
|
|
- {
|
|
|
- new ToastMessageWindow(AppData.Instance.MainWindow, $"新位置只能是数字").Show();
|
|
|
- return;
|
|
|
- }
|
|
|
- CurrentPositionEntity.IsUpdate = true;
|
|
|
- CurrentPositionEntity.focusStartingPoint = newValue;
|
|
|
- List<FocusStartingPointResponse> listData = new List<FocusStartingPointResponse>();
|
|
|
- foreach (var item in this.ListBox_Well.Items)
|
|
|
- {
|
|
|
- if (!(item is PositionEntity positionEntity)) continue;
|
|
|
- if (!positionEntity.IsUpdate) continue;
|
|
|
- listData.Add(new FocusStartingPointResponse
|
|
|
- {
|
|
|
- wellSn = positionEntity.wellSn,
|
|
|
- focusStartingPoint = positionEntity.focusStartingPoint
|
|
|
- });
|
|
|
- }
|
|
|
- if (picProvider.UpdateImmediatelyApi(tlSn, houseSn, listData))
|
|
|
- {
|
|
|
- new ToastWindow(this, 1920, 65, true).Show();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- new ToastWindow(this, 1920, 65, false).Show();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void Cancel_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- this.DialogResult = false;
|
|
|
- this.Close();
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- private void Aad_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- if (this.ListBox_Well.SelectedItem == null) return;
|
|
|
- if (!(this.ListBox_Well.SelectedItem is PositionEntity positionEntity)) return;
|
|
|
- if (!int.TryParse(this.TextBlock_focusStartingPoint.Text, out int newValue))
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- newValue += positionEntity.verticalMotorSpacePulse * 5;
|
|
|
- this.TextBlock_focusStartingPoint.Text = newValue.ToString();
|
|
|
- if (newValue < 125000)
|
|
|
- {
|
|
|
- this.Button_Add.IsEnabled = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this.Button_Add.IsEnabled = false;
|
|
|
- }
|
|
|
- if (newValue > 0)
|
|
|
- {
|
|
|
- this.Button_Sub.IsEnabled = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this.Button_Sub.IsEnabled = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void Sub_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- if (this.ListBox_Well.SelectedItem == null) return;
|
|
|
- if (!(this.ListBox_Well.SelectedItem is PositionEntity positionEntity)) return;
|
|
|
- if (!int.TryParse(this.TextBlock_focusStartingPoint.Text, out int newValue))
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- newValue -= positionEntity.verticalMotorSpacePulse * 5;
|
|
|
- this.TextBlock_focusStartingPoint.Text = newValue.ToString();
|
|
|
- if (newValue > 0)
|
|
|
- {
|
|
|
- this.Button_Sub.IsEnabled = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this.Button_Sub.IsEnabled = false;
|
|
|
- }
|
|
|
- if (newValue < 125000)
|
|
|
- {
|
|
|
- this.Button_Add.IsEnabled = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this.Button_Add.IsEnabled = false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void ScrollViewer_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
|
|
|
- {
|
|
|
- e.Handled = true;
|
|
|
- }
|
|
|
-
|
|
|
- private void NextButton_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- if (!int.TryParse(this.Image_Big.Tag.ToString(), out int newValue))
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- newValue++;
|
|
|
- if (!ListPic.ContainsKey(newValue)) return;
|
|
|
- var checkBoxImage = ListPic[newValue];
|
|
|
- this.Text_Big.Text = checkBoxImage.ImageInfoString;
|
|
|
- this.Image_Big.Source = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{checkBoxImage.ImageUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}");
|
|
|
- this.Canvas_Big.Visibility = Visibility.Visible;
|
|
|
- this.Image_Big.Tag = newValue;
|
|
|
- if (newValue < ListPic.Last().Key)
|
|
|
- {
|
|
|
- this._nextPic_Button.Visibility = Visibility.Visible;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this._nextPic_Button.Visibility = Visibility.Hidden;
|
|
|
- }
|
|
|
- if (newValue > 1)
|
|
|
- {
|
|
|
- this._prePic_Button.Visibility = Visibility.Visible;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this._prePic_Button.Visibility = Visibility.Hidden;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void PreButton_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- if (!int.TryParse(this.Image_Big.Tag.ToString(), out int newValue))
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- newValue--;
|
|
|
- if (!ListPic.ContainsKey(newValue)) return;
|
|
|
- var checkBoxImage = ListPic[newValue];
|
|
|
- this.Text_Big.Text = checkBoxImage.ImageInfoString;
|
|
|
- this.Image_Big.Source = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{checkBoxImage.ImageUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}");
|
|
|
- this.Canvas_Big.Visibility = Visibility.Visible;
|
|
|
- this.Image_Big.Tag = newValue;
|
|
|
- if (newValue > 1)
|
|
|
- {
|
|
|
- this._prePic_Button.Visibility = Visibility.Visible;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this._prePic_Button.Visibility = Visibility.Hidden;
|
|
|
- }
|
|
|
- if (newValue < ListPic.Last().Key)
|
|
|
- {
|
|
|
- this._nextPic_Button.Visibility = Visibility.Visible;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- this._nextPic_Button.Visibility = Visibility.Hidden;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void Close_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- this.Canvas_Big.Visibility = Visibility.Collapsed;
|
|
|
- }
|
|
|
-
|
|
|
- private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
|
|
- {
|
|
|
- e.Handled = !Regex.IsMatch(e.Text, @"[0-9]");
|
|
|
- }
|
|
|
-
|
|
|
- private void KouTu_Checked(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- if (!this.IsLoaded) return;
|
|
|
- this.Canvas_Big.Visibility = Visibility.Collapsed;
|
|
|
- BitmapImage ImageSourceUrl = null;
|
|
|
- foreach (var item in ListPic)
|
|
|
- {
|
|
|
- if (!(item.Value.Tag is AutoFocusPictureEntity tagEntity)) continue;
|
|
|
- if (string.IsNullOrEmpty(tagEntity.imageUrl))
|
|
|
- {
|
|
|
- ImageSourceUrl = null;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ImageSourceUrl = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{tagEntity.imageUrl.Replace(AppData.Instance.PicSuf, $"_180x180{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpServiceCall.GetToken()}");
|
|
|
- }
|
|
|
- item.Value.ImageUrl = tagEntity.imageUrl;
|
|
|
- item.Value.ImageSourceUrl = ImageSourceUrl;
|
|
|
- }
|
|
|
- var aa = ListPic.Where(x => x.Value.Visibility == Visibility.Visible);
|
|
|
- int CheckBoxImageNum = 1;
|
|
|
- foreach (var checkBoxImage in aa)
|
|
|
- {
|
|
|
- if (CheckBoxImageNum > 7)
|
|
|
- {
|
|
|
- if ((CheckBoxImageNum - 1) % 7 == 0) checkBoxImage.Value.Margin = new Thickness(0, 10, 0, 0);
|
|
|
- else checkBoxImage.Value.Margin = new Thickness(10, 10, 0, 0);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (CheckBoxImageNum == 1) checkBoxImage.Value.Margin = new Thickness(0);
|
|
|
- else checkBoxImage.Value.Margin = new Thickness(10, 0, 0, 0);
|
|
|
- }
|
|
|
- CheckBoxImageNum++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void YuanTu_Checked(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- if (!this.IsLoaded) return;
|
|
|
- this.Canvas_Big.Visibility = Visibility.Collapsed;
|
|
|
- BitmapImage ImageSourceUrl = null;
|
|
|
- foreach (var item in ListPic)
|
|
|
- {
|
|
|
- if (!(item.Value.Tag is AutoFocusPictureEntity tagEntity)) continue;
|
|
|
- if (string.IsNullOrEmpty(tagEntity.sourceImageUrl))
|
|
|
- {
|
|
|
- ImageSourceUrl = null;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ImageSourceUrl = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{tagEntity.sourceImageUrl.Replace(AppData.Instance.PicSuf, $"_180x180{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpServiceCall.GetToken()}");
|
|
|
- }
|
|
|
- item.Value.ImageUrl = tagEntity.sourceImageUrl;
|
|
|
- item.Value.ImageSourceUrl = ImageSourceUrl;
|
|
|
- }
|
|
|
-
|
|
|
- var aa = ListPic.Where(x => x.Value.Visibility == Visibility.Visible);
|
|
|
- int CheckBoxImageNum = 1;
|
|
|
- foreach (var checkBoxImage in aa)
|
|
|
- {
|
|
|
- if (CheckBoxImageNum > 7)
|
|
|
- {
|
|
|
- if ((CheckBoxImageNum - 1) % 7 == 0) checkBoxImage.Value.Margin = new Thickness(0, 10, 0, 0);
|
|
|
- else checkBoxImage.Value.Margin = new Thickness(10, 10, 0, 0);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (CheckBoxImageNum == 1) checkBoxImage.Value.Margin = new Thickness(0);
|
|
|
- else checkBoxImage.Value.Margin = new Thickness(10, 0, 0, 0);
|
|
|
- }
|
|
|
- CheckBoxImageNum++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|