ImageSourceWindow.xaml.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using ivf_tl_CustomControls;
  2. using ivf_tl_Entity.Entity;
  3. using ivf_tl_Entity.Entity.Mark;
  4. using ivf_tl_Entity.Enums;
  5. using ivf_tl_Manage.UserControls;
  6. using ivf_tl_Service.HttpProvider;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows;
  13. using System.Windows.Controls;
  14. using System.Windows.Data;
  15. using System.Windows.Documents;
  16. using System.Windows.Input;
  17. using System.Windows.Media;
  18. using System.Windows.Media.Imaging;
  19. using System.Windows.Media.TextFormatting;
  20. using System.Windows.Shapes;
  21. namespace ivf_tl_Manage.Win
  22. {
  23. /// <summary>
  24. /// ImageSourceWindow.xaml 的交互逻辑
  25. /// </summary>
  26. public partial class ImageSourceWindow : Window
  27. {
  28. PicProvider picProvider = null;
  29. //List<PictureEntity> picList = new List<PictureEntity>();
  30. public ImageSourceWindow(long embryoId, int houseSn, int pictureLayer, string tlSn)//List<PictureEntity> list,
  31. {
  32. try
  33. {
  34. InitializeComponent();
  35. this.Owner = AppData.Instance.MainWindow;
  36. picProvider = AppData.Instance.GetPicProvider();
  37. //picList = list;
  38. Loaded += (s, e) => init(embryoId, houseSn, pictureLayer, tlSn);
  39. this.Closed += (a, b) => AppData.Instance.MainWindow.Activate();
  40. Unloaded += (s, e) =>
  41. {
  42. _root_Canvas.Children.Clear();
  43. };
  44. }
  45. catch (Exception ex)
  46. {
  47. ExLog(ex, "ImageSourceWindow");
  48. }
  49. }
  50. private int CheckBoxImageNum = 1;
  51. private void init(long embryoId, int houseSn, int pictureLayer, string tlSn)
  52. {
  53. var list = picProvider.GetImageSourceApi(embryoId, houseSn, pictureLayer, tlSn);
  54. Task.Run(() =>
  55. {
  56. Dispatcher.Invoke(() =>
  57. {
  58. foreach (var item in list)
  59. {
  60. if (string.IsNullOrEmpty(item.sourceImageUrl)) continue;
  61. PicSourceUserControl checkBoxImage = new PicSourceUserControl()
  62. {
  63. ImageSourceUrl = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{item.sourceImageUrl.Replace(AppData.Instance.PicSuf, $"_180x180{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpServiceCall.GetToken()}"),
  64. ImageInfoString = $"{item.imageTime.ToString("MM-dd HH:mm")}",
  65. };
  66. if (checkBoxImage.ImageSourceUrl == null) continue;
  67. if (CheckBoxImageNum > 7)
  68. {
  69. if ((CheckBoxImageNum - 1) % 7 == 0) checkBoxImage.Margin = new Thickness(0, 10, 0, 0);
  70. else checkBoxImage.Margin = new Thickness(10, 10, 0, 0);
  71. }
  72. else
  73. {
  74. if (CheckBoxImageNum == 1) checkBoxImage.Margin = new Thickness(0);
  75. else checkBoxImage.Margin = new Thickness(10, 0, 0, 0);
  76. }
  77. CheckBoxImageNum++;
  78. _root_Canvas.Children.Add(checkBoxImage);
  79. }
  80. });
  81. });
  82. }
  83. private void ExLog(Exception ex, string name)
  84. {
  85. AppData.Instance.LogService.ExceptionLog(ex, $"MarkQucikWindow.{name}", LogEnum.RunException);
  86. }
  87. private void ErrorLog(string message, LogEnum logType)
  88. {
  89. AppData.Instance.LogService.TLLog($"MarkQucikWindow.{message}", logType);
  90. }
  91. private void Cancel_Click(object sender, RoutedEventArgs e)
  92. {
  93. this.DialogResult = false;
  94. return;
  95. }
  96. private void ScrollViewer_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
  97. {
  98. e.Handled = true;
  99. }
  100. }
  101. }