using ivf_tl_Entity.Entity.AppSetting; using ivf_tl_Entity.Enums; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; 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 { /// /// UserBusWindow.xaml 的交互逻辑 /// public partial class UserBusWindow : Window { List BusinesseList = new List(); public UserBusWindow(List businesses) { InitializeComponent(); this.Owner = AppData.Instance.MainWindow; foreach (var item in businesses) { item.isOpen = 0; } BusinesseList = businesses; this._listBox.ItemsSource = BusinesseList; this.Closed += (a, b) => { AppData.Instance.MainWindow.Activate(); }; } private void MessageBoxShow(string mess) { } private void ExLog(Exception ex, string name) { AppData.Instance.LogService.ExceptionLog(ex, $"UserBusWindow.{name}", LogEnum.RunException); } private void ErrorLog(string message, LogEnum logType) { AppData.Instance.LogService.TLLog($"UserBusWindow.{message}", logType); } private void Cancel_Click(object sender, RoutedEventArgs e) { this.DialogResult = false; return; } private void _listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!(this._listBox.SelectedItem is Business business)) return; foreach (var item in BusinesseList) { if (item.id == business.id) { item.isOpen = 1; } else { item.isOpen = 0; } } this._children.ItemsSource = business.children; } private void Ok_Click(object sender, RoutedEventArgs e) { this.DialogResult = true; return; } private void Image_MouseDown(object sender, MouseButtonEventArgs e) { if (!(sender is Image source)) return; if (!(source.Tag is Business business)) return; if (this._listBox.SelectedItem == business) { if (business.isOpen == 1) { business.isOpen = 0; this._children.ItemsSource = null; } else { business.isOpen = 1; this._children.ItemsSource = business.children; } } else { this._listBox.SelectedItem = business; } e.Handled = true; } } }