UserBusWindow.xaml.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using ivf_tl_Entity.Entity.AppSetting;
  2. using ivf_tl_Entity.Enums;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Shapes;
  17. namespace ivf_tl_Manage.Win
  18. {
  19. /// <summary>
  20. /// UserBusWindow.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class UserBusWindow : Window
  23. {
  24. List<Business> BusinesseList = new List<Business>();
  25. public UserBusWindow(List<Business> businesses)
  26. {
  27. InitializeComponent();
  28. this.Owner = AppData.Instance.MainWindow;
  29. foreach (var item in businesses)
  30. {
  31. item.isOpen = 0;
  32. }
  33. BusinesseList = businesses;
  34. this._listBox.ItemsSource = BusinesseList;
  35. this.Closed += (a, b) =>
  36. {
  37. AppData.Instance.MainWindow.Activate();
  38. };
  39. }
  40. private void MessageBoxShow(string mess)
  41. {
  42. }
  43. private void ExLog(Exception ex, string name)
  44. {
  45. AppData.Instance.LogService.ExceptionLog(ex, $"UserBusWindow.{name}", LogEnum.RunException);
  46. }
  47. private void ErrorLog(string message, LogEnum logType)
  48. {
  49. AppData.Instance.LogService.TLLog($"UserBusWindow.{message}", logType);
  50. }
  51. private void Cancel_Click(object sender, RoutedEventArgs e)
  52. {
  53. this.DialogResult = false;
  54. return;
  55. }
  56. private void _listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  57. {
  58. if (!(this._listBox.SelectedItem is Business business)) return;
  59. foreach (var item in BusinesseList)
  60. {
  61. if (item.id == business.id)
  62. {
  63. item.isOpen = 1;
  64. }
  65. else
  66. {
  67. item.isOpen = 0;
  68. }
  69. }
  70. this._children.ItemsSource = business.children;
  71. }
  72. private void Ok_Click(object sender, RoutedEventArgs e)
  73. {
  74. this.DialogResult = true;
  75. return;
  76. }
  77. private void Image_MouseDown(object sender, MouseButtonEventArgs e)
  78. {
  79. if (!(sender is Image source)) return;
  80. if (!(source.Tag is Business business)) return;
  81. if (this._listBox.SelectedItem == business)
  82. {
  83. if (business.isOpen == 1)
  84. {
  85. business.isOpen = 0;
  86. this._children.ItemsSource = null;
  87. }
  88. else
  89. {
  90. business.isOpen = 1;
  91. this._children.ItemsSource = business.children;
  92. }
  93. }
  94. else
  95. {
  96. this._listBox.SelectedItem = business;
  97. }
  98. e.Handled = true;
  99. }
  100. }
  101. }