DetailPicView.xaml.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. using ivf_tl_CustomControls;
  2. using ivf_tl_Entity.Entity;
  3. using ivf_tl_Entity.Entity.balance;
  4. using ivf_tl_Entity.Enums;
  5. using ivf_tl_Entity.Pic;
  6. using ivf_tl_Manage.UserControls;
  7. using ivf_tl_Manage.ViewModels;
  8. using ivf_tl_Manage.Win;
  9. using ivf_tl_Service;
  10. using ivf_tl_Service.HttpProvider;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Diagnostics;
  14. using System.Linq;
  15. using System.Reflection;
  16. using System.Text;
  17. using System.Threading.Tasks;
  18. using System.Windows;
  19. using System.Windows.Controls;
  20. using System.Windows.Data;
  21. using System.Windows.Documents;
  22. using System.Windows.Input;
  23. using System.Windows.Media;
  24. using System.Windows.Media.Imaging;
  25. using System.Windows.Navigation;
  26. using System.Windows.Shapes;
  27. namespace ivf_tl_Manage.Views
  28. {
  29. /// <summary>
  30. /// DetailPicView.xaml 的交互逻辑
  31. /// </summary>
  32. public partial class DetailPicView : UserControl
  33. {
  34. private DetailPicViewModel vm = null;
  35. private int CheckBoxImageNum = 1;
  36. private int CheckBoxNum = 1;
  37. private List<PicUserControl> CheckBoxImageList = new List<PicUserControl>();
  38. private DetailProvider DetailProvider = null;
  39. public DetailPicView()
  40. {
  41. InitializeComponent();
  42. this._photoBox0.Tag = new PhotoBoxSetting() { MinHour = 0, MaxHour = 24 * 60 };
  43. this._photoBox1.Tag = new PhotoBoxSetting() { MinHour = 24 * 60, MaxHour = 48 * 60 };
  44. this._photoBox2.Tag = new PhotoBoxSetting() { MinHour = 48 * 60, MaxHour = 72 * 60 };
  45. this._photoBox3.Tag = new PhotoBoxSetting() { MinHour = 72 * 60, MaxHour = 96 * 60 };
  46. this._photoBox4.Tag = new PhotoBoxSetting() { MinHour = 96 * 60, MaxHour = 120 * 60 };
  47. this._photoBox5.Tag = new PhotoBoxSetting() { MinHour = 120 * 60, MaxHour = 144 * 60 };
  48. this._photoBox6.Tag = new PhotoBoxSetting() { MinHour = 18 * 60, MaxHour = 20 * 60 };
  49. this._photoBox7.Tag = new PhotoBoxSetting() { MinHour = 25 * 60, MaxHour = 26 * 60 };
  50. this._photoBox8.Tag = new PhotoBoxSetting() { MinHour = 42 * 60, MaxHour = 44 * 60 };
  51. this._photoBox9.Tag = new PhotoBoxSetting() { MinHour = 62 * 60, MaxHour = 68 * 60 };
  52. DetailProvider = AppData.Instance.GetDetailProvider();
  53. var a = DetailProvider.GetPicTimeButtonsApi();
  54. foreach (var item in a)
  55. {
  56. if (item.type == "COMMON_BUTTON")
  57. {
  58. var b = item.button.Take(7).ToList();
  59. for (int i = 0; i < b.Count; i++)
  60. {
  61. var item1 = b[i];
  62. switch (i)
  63. {
  64. case 0:
  65. this._photoBox0.Content = item1.buttonName;
  66. this._photoBox0.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  67. break;
  68. case 1:
  69. this._photoBox1.Content = item1.buttonName;
  70. this._photoBox1.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  71. break;
  72. case 2:
  73. this._photoBox2.Content = item1.buttonName;
  74. this._photoBox2.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  75. break;
  76. case 3:
  77. this._photoBox3.Content = item1.buttonName;
  78. this._photoBox3.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  79. break;
  80. case 4:
  81. this._photoBox4.Content = item1.buttonName;
  82. this._photoBox4.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  83. break;
  84. case 5:
  85. this._photoBox5.Content = item1.buttonName;
  86. this._photoBox5.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  87. break;
  88. case 6:
  89. this._photoBox5_1.Content = item1.buttonName;
  90. this._photoBox5_1.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  91. break;
  92. }
  93. }
  94. }
  95. else if (item.type == "KEY_BUTTON")
  96. {
  97. var b = item.button.Take(7).ToList();
  98. for (int i = 0; i < b.Count; i++)
  99. {
  100. var item1 = b[i];
  101. switch (i)
  102. {
  103. case 0:
  104. this._photoBox6.Content = item1.buttonName;
  105. this._photoBox6.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  106. break;
  107. case 1:
  108. this._photoBox7.Content = item1.buttonName;
  109. this._photoBox7.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  110. break;
  111. case 2:
  112. this._photoBox8.Content = item1.buttonName;
  113. this._photoBox8.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  114. break;
  115. case 3:
  116. this._photoBox9.Content = item1.buttonName;
  117. this._photoBox9.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  118. break;
  119. case 4:
  120. this._photoBox9_1.Content = item1.buttonName;
  121. this._photoBox9_1.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  122. break;
  123. case 5:
  124. this._photoBox9_2.Content = item1.buttonName;
  125. this._photoBox9_2.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  126. break;
  127. case 6:
  128. this._photoBox9_3.Content = item1.buttonName;
  129. this._photoBox9_3.Tag = new PhotoBoxSetting() { MinHour = item1.minHour * 60, MaxHour = item1.maxHour * 60 };
  130. break;
  131. }
  132. }
  133. }
  134. }
  135. Loaded += DetailPicView_Loaded;
  136. Unloaded += (s, e) =>
  137. {
  138. Canvas_Root.Children.Clear();
  139. vm = null;
  140. DataContext = null;
  141. };
  142. }
  143. private void DetailPicView_Loaded(object sender, RoutedEventArgs e)
  144. {
  145. vm = (DetailPicViewModel)this.DataContext;
  146. if (vm == null) return;
  147. InitNav();
  148. if (vm.ShowPictureList == null || vm.ViewCheckBoxImageList.Any()) return;
  149. Task.Run(() =>
  150. {
  151. this.Dispatcher.Invoke(() =>
  152. {
  153. _root_Canvas.Children.Clear();
  154. CheckBoxImageList.Clear();
  155. this._allCheck.IsChecked = false;
  156. vm.ViewCheckBoxImageList.Clear();
  157. var list = vm.ShowPictureList.Take(vm.PicPageSize);
  158. CheckBoxImageNum = 1;
  159. foreach (var item in list)
  160. {
  161. if (string.IsNullOrEmpty(item.imageUrl)) continue;
  162. PicUserControl checkBoxImage = new PicUserControl()
  163. {
  164. //ImageSourceUrl = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{item.imageUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}"),
  165. ImageSourceUrl = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{item.imageUrl.Replace(AppData.Instance.PicSuf, $"_240x240{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpServiceCall.GetToken()}"),
  166. ImageInfoString = $"{item.imageTime.ToString("MM-dd HH:mm")}",
  167. Tag = item.id,
  168. };
  169. if (checkBoxImage.ImageSourceUrl == null) continue;
  170. if (CheckBoxImageNum > 6)
  171. {
  172. if ((CheckBoxImageNum - 1) % 6 == 0) checkBoxImage.Margin = new Thickness(40, 18, 0, 0);
  173. else checkBoxImage.Margin = new Thickness(18, 18, 0, 0);
  174. }
  175. else
  176. {
  177. if (CheckBoxImageNum == 1) checkBoxImage.Margin = new Thickness(40, 0, 0, 0);
  178. else checkBoxImage.Margin = new Thickness(18, 0, 0, 0);
  179. }
  180. CheckBoxImageNum++;
  181. checkBoxImage.MouseDown += CheckBoxImage_MouseDown;
  182. checkBoxImage.SelectedPropertyChangedEevent += CheckBoxImage_SelectedPropertyChangedEevent;
  183. //checkBoxImage.Checked += CheckBoxImage_Checked;
  184. //checkBoxImage.Unchecked += CheckBoxImage_Unchecked;
  185. vm.ViewCheckBoxImageList.Add(checkBoxImage);
  186. _root_Canvas.Children.Add(checkBoxImage);
  187. }
  188. });
  189. });
  190. }
  191. private void InitNav()
  192. {
  193. _nav_StackPanel.Children.Clear();
  194. for (int i = 0; i < vm.NavList.Count; i++)
  195. {
  196. var item = vm.NavList[i];
  197. if (i == vm.NavList.Count - 1)
  198. {
  199. TextBlock textBlock1 = new TextBlock();
  200. textBlock1.Margin = new Thickness(8, 0, 0, 0);
  201. textBlock1.FontWeight = FontWeights.Bold;
  202. textBlock1.Foreground = new SolidColorBrush(Colors.Black);
  203. textBlock1.FontSize = 32d;
  204. textBlock1.VerticalAlignment = VerticalAlignment.Center;
  205. textBlock1.Text = item.NavName;
  206. _nav_StackPanel.Children.Add(textBlock1);
  207. return;
  208. }
  209. Button button = new Button();
  210. button.Content = item.NavName;
  211. button.FontWeight = FontWeights.Bold;
  212. button.FontSize = 28d;
  213. button.BorderThickness = new Thickness(0);
  214. button.Background = new SolidColorBrush(Colors.Transparent);
  215. button.Style = App.Current.FindResource("ButtonStyle1") as Style;
  216. if (i == 0)
  217. {
  218. button.Margin = new Thickness(0, 0, 0, 0);
  219. }
  220. else
  221. {
  222. button.Margin = new Thickness(8, 0, 0, 0);
  223. }
  224. button.Click += (s, e) =>
  225. {
  226. if (vm != null) vm.NavList.Clear();
  227. if (item is PatientManageViewModel patient)
  228. {
  229. patient.SetTLInfo(AppData.Instance.CurrentTlInfo);
  230. AppData.Instance.MainWindowViewModel.CurrentViewModle = patient;
  231. return;
  232. }
  233. AppData.Instance.MainWindowViewModel.CurrentViewModle = item;
  234. };
  235. TextBlock textBlock = new TextBlock();
  236. textBlock.Margin = new Thickness(8, 0, 0, 0);
  237. textBlock.VerticalAlignment = VerticalAlignment.Center;
  238. textBlock.FontWeight = FontWeights.Bold;
  239. textBlock.FontSize = 28d;
  240. textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9B9B9B"));
  241. textBlock.Text = ">";
  242. _nav_StackPanel.Children.Add(button);
  243. _nav_StackPanel.Children.Add(textBlock);
  244. }
  245. }
  246. private void ExLog(Exception ex, string name)
  247. {
  248. AppData.Instance.LogService.ExceptionLog(ex, $"DetailPicView.{name}", LogEnum.RunException);
  249. }
  250. private void ErrorLog(string message, LogEnum logType)
  251. {
  252. AppData.Instance.LogService.TLLog($"DetailPicView.{message}", logType);
  253. }
  254. private void Toast(bool success)
  255. {
  256. new ToastWindow(AppData.Instance.MainWindow, 1920, 65, success).Show();
  257. }
  258. /// <summary>
  259. /// 设备管理
  260. /// </summary>
  261. /// <param name="sender"></param>
  262. /// <param name="e"></param>
  263. private void Button_Click(object sender, RoutedEventArgs e)
  264. {
  265. AppData.Instance.MainWindowViewModel.CurrentViewModle = AppData.Instance.MainWindowViewModel.devManageViewModel;
  266. }
  267. /// <summary>
  268. /// 患者管理
  269. /// </summary>
  270. /// <param name="sender"></param>
  271. /// <param name="e"></param>
  272. private void Parien_Click(object sender, RoutedEventArgs e)
  273. {
  274. AppData.Instance.MainWindowViewModel.patientManageViewModel.SetTLInfo(vm.tLInfo);
  275. AppData.Instance.MainWindowViewModel.CurrentViewModle = AppData.Instance.MainWindowViewModel.patientManageViewModel;
  276. }
  277. /// <summary>
  278. /// 详情界面
  279. /// </summary>
  280. /// <param name="sender"></param>
  281. /// <param name="e"></param>
  282. private void Detail_Click(object sender, RoutedEventArgs e)
  283. {
  284. //AppData.Instance.MainWindowViewModel.detailViewModel.Init(null, vm.tLInfo, vm.CurrentDish);
  285. //AppData.Instance.MainWindowViewModel.CurrentViewModle = vm.DetailViewModel;
  286. }
  287. private void RecordDetail_Click(object sender, RoutedEventArgs e)
  288. {
  289. //AppData.Instance.MainWindowViewModel.CurrentViewModle = vm.DetailViewModel;
  290. }
  291. private void RecordParien_Click(object sender, RoutedEventArgs e)
  292. {
  293. //AppData.Instance.MainWindowViewModel.CurrentViewModle = vm.RecordViewModel;
  294. }
  295. private void SmallFocus_Click(object sender, RoutedEventArgs e)
  296. {
  297. ChangeFocal(false);
  298. }
  299. private void BigFocus_Click(object sender, RoutedEventArgs e)
  300. {
  301. ChangeFocal(true);
  302. }
  303. /// <summary>
  304. /// 切换图层
  305. /// </summary>
  306. /// <param name="isMax"></param>
  307. private void ChangeFocal(bool isMax)
  308. {
  309. try
  310. {
  311. int newCurrentFocal = vm.CurrentFocal;
  312. if (isMax)
  313. {
  314. newCurrentFocal++;
  315. }
  316. else
  317. {
  318. newCurrentFocal--;
  319. }
  320. if (newCurrentFocal < vm.MaxFocal) this._bigFocal_Button.IsEnabled = true;
  321. else this._bigFocal_Button.IsEnabled = false;
  322. if (newCurrentFocal > vm.MinFocal) this._smallFocal_Button.IsEnabled = true;
  323. else this._smallFocal_Button.IsEnabled = false;
  324. if (newCurrentFocal < vm.MinFocal || newCurrentFocal > vm.MaxFocal)
  325. {
  326. return;
  327. }
  328. vm.CurrentFocal = newCurrentFocal;
  329. vm.RefPic(vm.CurrentFocal);
  330. }
  331. catch (Exception ex)
  332. {
  333. ExLog(ex, "ChangeFocal");
  334. }
  335. }
  336. private void ImageSource_Click(object sender, RoutedEventArgs e)
  337. {
  338. //List<PictureEntity> allList = new List<PictureEntity>();
  339. //if (vm.CurrentEmbryoAllPicDic.ContainsKey(vm.CurrentFocal)) allList = vm.CurrentEmbryoAllPicDic[vm.CurrentFocal];
  340. AppData.Instance.MainWindowViewModel.MaskVisibility = true;
  341. if (new SafeWindow(AppData.Instance.MainWindow).ShowDialog() != true)
  342. {
  343. AppData.Instance.MainWindowViewModel.MaskVisibility = false;
  344. return;
  345. }
  346. List<PhotoBoxSetting1> settings = new List<PhotoBoxSetting1>();
  347. foreach (var item in vm.CheckBoxNoFrameCustomList) if (item.Tag is PhotoBoxSetting itemsetting) settings.Add(new PhotoBoxSetting1 { minHour = itemsetting.MinHour / 60, maxHour = itemsetting.MaxHour / 60 });
  348. new ImageSourceNewWindow(vm.CurrentEmbryo, vm.CurrentEmbryo.houseSn, vm.CurrentFocal, vm.CurrentEmbryo.tlSn, vm.CurrentDish, vm.MaxFocal, vm.MinFocal, settings).ShowDialog();
  349. AppData.Instance.MainWindowViewModel.MaskVisibility = false;
  350. }
  351. private void ImageExport_Click(object sender, RoutedEventArgs e)
  352. {
  353. if (vm == null || !vm.ShowPictureList.Any())
  354. {
  355. Toast(false);
  356. return;
  357. }
  358. AppData.Instance.MainWindowViewModel.MaskVisibility = true;
  359. if (new PicExportWindow(AppData.Instance.MainWindow, CheckBoxImageList.Count).ShowDialog() != true)
  360. {
  361. AppData.Instance.MainWindowViewModel.MaskVisibility = false;
  362. return;
  363. }
  364. string dateString = DateTime.Now.ToString("yy-MM-dd-HH-mm");
  365. string fileName = SaveFileName(dateString);
  366. AppData.Instance.MainWindowViewModel.MaskVisibility = false;
  367. if (string.IsNullOrEmpty(fileName)) return;
  368. if (CheckBoxImageList.Any())
  369. {
  370. vm.DowLoadPic(CheckBoxImageList.Select(x => (long)x.Tag).ToList(), fileName);
  371. }
  372. else
  373. {
  374. vm.DowLoadPic(vm.ShowPictureList.Select(x => x.id).ToList(), fileName);
  375. }
  376. }
  377. private void ScrollViewer_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
  378. {
  379. e.Handled = true;
  380. }
  381. private void PaginationUserControl_PageChangedEvent(PaginationUserControl source, int obj)
  382. {
  383. if (source == null) return;
  384. if (!source.IsLoaded) return;
  385. Task.Run(() =>
  386. {
  387. this.Dispatcher.Invoke(() =>
  388. {
  389. _root_Canvas.Children.Clear();
  390. CheckBoxImageList.Clear();
  391. this._allCheck.IsChecked = false;
  392. if (vm == null || vm.ShowPictureList == null) return;
  393. vm.CurrentPage = obj;
  394. vm.ViewCheckBoxImageList.Clear();
  395. var list = vm.ShowPictureList.Skip(vm.PicPageSize * (obj - 1)).Take(vm.PicPageSize);
  396. CheckBoxNum = 1;
  397. CheckBoxImageNum = 1;
  398. foreach (var item in list)
  399. {
  400. if (string.IsNullOrEmpty(item.imageUrl)) continue;
  401. PicUserControl checkBoxImage = new PicUserControl()
  402. {
  403. ImageSourceUrl = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{item.imageUrl.Replace(AppData.Instance.PicSuf, $"_240x240{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpServiceCall.GetToken()}"),
  404. ImageInfoString = $"{item.imageTime.ToString("MM-dd HH:mm")}",
  405. Tag = item.id,
  406. };
  407. if (checkBoxImage.ImageSourceUrl == null) continue;
  408. if (CheckBoxImageNum > 6)
  409. {
  410. if ((CheckBoxImageNum - 1) % 6 == 0) checkBoxImage.Margin = new Thickness(40, 18, 0, 0);
  411. else checkBoxImage.Margin = new Thickness(18, 18, 0, 0);
  412. }
  413. else
  414. {
  415. if (CheckBoxImageNum == 1) checkBoxImage.Margin = new Thickness(40, 0, 0, 0);
  416. else checkBoxImage.Margin = new Thickness(18, 0, 0, 0);
  417. }
  418. CheckBoxImageNum++;
  419. checkBoxImage.MouseDown += CheckBoxImage_MouseDown;
  420. checkBoxImage.SelectedPropertyChangedEevent += CheckBoxImage_SelectedPropertyChangedEevent;
  421. //checkBoxImage.Checked += CheckBoxImage_Checked;
  422. //checkBoxImage.Unchecked += CheckBoxImage_Unchecked;
  423. vm.ViewCheckBoxImageList.Add(checkBoxImage);
  424. _root_Canvas.Children.Add(checkBoxImage);
  425. }
  426. this._ScrollViewer.ScrollToVerticalOffset(0);
  427. //this._ScrollViewer.ScrollToTop();
  428. //this._ScrollViewer.ScrollToHome();
  429. });
  430. });
  431. }
  432. private void CheckBoxImage_PreviewMouseDown(object sender, MouseButtonEventArgs e)
  433. {
  434. if (e.ClickCount >= 2)
  435. {
  436. e.Handled = true;
  437. }
  438. }
  439. private bool isImage = false;
  440. private void CheckBoxImage_Unchecked(object sender, RoutedEventArgs e)
  441. {
  442. //if (!(sender is CheckBoxImage source)) return;
  443. //isImage = true;
  444. //this._allCheck.IsChecked = false;
  445. //isImage = false;
  446. //CheckBoxNum--;
  447. //if (!CheckBoxImageList.Any()) return;
  448. //if (CheckBoxImageList.Last() == source)
  449. //{
  450. // CheckBoxImageList.Remove(source);
  451. // return;
  452. //}
  453. //CheckBoxImageList.Remove(source);
  454. //int k = 1;
  455. //foreach (var item in CheckBoxImageList)
  456. //{
  457. // source.SelectedNum = k++;
  458. //}
  459. }
  460. private void CheckBoxImage_Checked(object sender, RoutedEventArgs e)
  461. {
  462. // if (!(sender is CheckBoxImage source)) return;
  463. // source.SelectedNum = CheckBoxNum++;
  464. // CheckBoxImageList.Add(source);
  465. //if(vm != null)
  466. // {
  467. // var a = vm.ViewCheckBoxImageList.FirstOrDefault(x => x.IsChecked == false);
  468. // if (a == null) this._allCheck.IsChecked = true;
  469. // }
  470. }
  471. private void CheckBoxImage_SelectedPropertyChangedEevent(PicUserControl arg1, bool arg2)
  472. {
  473. if (arg1 == null) return;
  474. if (!arg1.IsLoaded) return;
  475. if (arg2)
  476. {
  477. arg1.SelectedNum = CheckBoxNum++;
  478. CheckBoxImageList.Add(arg1);
  479. if (vm != null)
  480. {
  481. var a = vm.ViewCheckBoxImageList.FirstOrDefault(x => x.IsSelected == false);
  482. if (a == null) this._allCheck.IsChecked = true;
  483. }
  484. return;
  485. }
  486. isImage = true;
  487. this._allCheck.IsChecked = false;
  488. isImage = false;
  489. CheckBoxNum--;
  490. if (!CheckBoxImageList.Any()) return;
  491. if (CheckBoxImageList.Last() == arg1)
  492. {
  493. CheckBoxImageList.Remove(arg1);
  494. return;
  495. }
  496. CheckBoxImageList.Remove(arg1);
  497. int k = 1;
  498. foreach (var item in CheckBoxImageList)
  499. {
  500. item.SelectedNum = k++;
  501. }
  502. }
  503. private void CheckBoxImage_MouseDown(object sender, MouseButtonEventArgs e)
  504. {
  505. if (!(sender is PicUserControl source)) return;
  506. if (!source.IsLoaded) return;
  507. if (source.IsSelected) return;
  508. if (vm == null || vm.CurrentDish == null || vm.CurrentEmbryo == null) return;
  509. AppData.Instance.MainWindowViewModel.MaskVisibility = true;
  510. PhotoWindowNew photoWindowNew = new PhotoWindowNew(AppData.Instance.MainWindow, vm.ShowPictureList, (long)source.Tag, vm.CurrentDish.tlSn, vm.CurrentDish.houseSn, vm.CurrentDish.wife, vm.CurrentEmbryo.wellSn);
  511. photoWindowNew.ShowDialog();
  512. AppData.Instance.MainWindowViewModel.MaskVisibility = false;
  513. }
  514. private ButtonRightImage GetButtonImage(CheckBoxNoFrameCustom checkBoxNoFrameCustom)
  515. {
  516. var a = new ButtonRightImage()
  517. {
  518. Margin = new Thickness(7, 0, 0, 0),
  519. Padding = new Thickness(15, 0, 0, 0),
  520. MinWidth = 127,
  521. Height = 42,
  522. Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E8E8E8")),
  523. IconMargin = new Thickness(20, 0, 15, 0),
  524. FontWeight = FontWeights.Medium,
  525. Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D75AC")),
  526. FontSize = 18,
  527. CornerRadiusButton = new CornerRadius(10),
  528. Tag = checkBoxNoFrameCustom,
  529. Content = checkBoxNoFrameCustom.Content,
  530. IconWidth = 18,
  531. IconHeight = 18,
  532. IconSource = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/CloseGrayIcon.png", UriKind.Absolute)),
  533. MouseOverIconSource = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/CloseBlueIcon.png", UriKind.Absolute)),
  534. };
  535. a.Click += (s, e) =>
  536. {
  537. if (checkBoxNoFrameCustom.IsChecked == true)
  538. {
  539. checkBoxNoFrameCustom.IsChecked = false;
  540. }
  541. };
  542. vm.ButtonRightImageList.Add(a);
  543. return a;
  544. }
  545. private void CheckBoxNoFrameCustom_Checked(object sender, RoutedEventArgs e)
  546. {
  547. if (vm == null) return;
  548. if (!(sender is CheckBoxNoFrameCustom source)) return;
  549. this._stack.Children.Add(GetButtonImage(source));
  550. if (!vm.CheckBoxNoFrameCustomList.Contains(source))
  551. {
  552. vm.CheckBoxNoFrameCustomList.Add(source);
  553. }
  554. vm.RefPic(vm.CurrentFocal);
  555. }
  556. private void CheckBoxNoFrameCustom_Unchecked(object sender, RoutedEventArgs e)
  557. {
  558. if (vm == null) return;
  559. if (!(sender is CheckBoxNoFrameCustom source)) return;
  560. ButtonRightImage k = null;
  561. foreach (var item in vm.ButtonRightImageList)
  562. {
  563. if (!(item.Tag is CheckBoxNoFrameCustom c)) continue;
  564. if (c == source)
  565. {
  566. k = item;
  567. break;
  568. }
  569. }
  570. if (k != null)
  571. {
  572. vm.ButtonRightImageList.Remove(k);
  573. this._stack.Children.Remove(k);
  574. }
  575. if (vm.CheckBoxNoFrameCustomList.Contains(source))
  576. {
  577. var a = vm.CheckBoxNoFrameCustomList.Remove(source);
  578. }
  579. vm.RefPic(vm.CurrentFocal);
  580. }
  581. public string SaveFileName(string dateString)
  582. {
  583. var dialog = new Microsoft.Win32.SaveFileDialog();
  584. dialog.FileName = $"{vm.CurrentDish.wife}_{dateString}.zip";
  585. dialog.DefaultExt = ".zip";
  586. dialog.Filter = "zip|*.zip";
  587. if (dialog.ShowDialog() != true)
  588. {
  589. return null;
  590. }
  591. return dialog.FileName;
  592. }
  593. private void CheckBoxContent_Checked(object sender, RoutedEventArgs e)
  594. {
  595. if (sender is CheckBoxContent source && source.IsLoaded && vm != null)
  596. {
  597. foreach (var item in vm.ViewCheckBoxImageList)
  598. {
  599. item.IsSelected = true;
  600. }
  601. }
  602. }
  603. private void CheckBoxContent_Unchecked(object sender, RoutedEventArgs e)
  604. {
  605. if (isImage) return;
  606. if (sender is CheckBoxContent source && source.IsLoaded && vm != null)
  607. {
  608. foreach (var item in vm.ViewCheckBoxImageList)
  609. {
  610. item.IsSelected = false;
  611. }
  612. }
  613. }
  614. private void ListBox_Selected(object sender, RoutedEventArgs e)
  615. {
  616. this._bigFocal_Button.IsEnabled = true;
  617. this._smallFocal_Button.IsEnabled = true;
  618. }
  619. private void ListBox_Selected(object sender, SelectionChangedEventArgs e)
  620. {
  621. this._bigFocal_Button.IsEnabled = true;
  622. this._smallFocal_Button.IsEnabled = true;
  623. }
  624. }
  625. }