| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- using ivf_tl_Entity.Entity;
- using ivf_tl_Manage.ViewModels;
- using System;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using ivf_tl_CustomControls;
- using ivf_tl_Manage.Win;
- using System.Windows.Threading;
- using System.Configuration;
- using Newtonsoft.Json;
- using System.Windows.Controls;
- using ivf_tl_Service;
- using log4net.Appender;
- using log4net.Repository.Hierarchy;
- using log4net;
- using System.Linq;
- using ivf_tl_Entity.Entity.DownLoad;
- namespace ivf_tl_Manage
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- MainWindowViewModel vm = new MainWindowViewModel();
- DispatcherTimer ShowTimer;
- public MainWindow()
- {
- InitializeComponent();
- this.DataContext = vm;
- QuestPDF.Settings.License = QuestPDF.Infrastructure.LicenseType.Community;
- ShowTime();
- AppData.Instance.SetImageSource(this.MainLogoImg, ivf_tl_Entity.Enums.LogoEnum.Rectangle);
- Loaded += MainWindow_Loaded;
- #if DEBUG
- this.chLan.Visibility = Visibility.Visible;
- this.enLan.Visibility = Visibility.Visible;
- this.upLan.Visibility = Visibility.Visible;
- Canvas originalCanvas = MainCanvas;
- this.Content = null;
- Viewbox viewbox = new Viewbox
- {
- Child = originalCanvas,
- Stretch = Stretch.Uniform
- };
- this.Content = viewbox;
- #endif
- }
- private UserInfo currentUserInfo = new UserInfo();
- private void MainWindow_Loaded(object sender, RoutedEventArgs e)
- {
- if (new LoginWindow(this, currentUserInfo).ShowDialog() != true)
- {
- Application.Current.Shutdown();
- return;
- }
- AppData.Instance.MainWindow = this;
- if (int.TryParse(ConfigurationManager.AppSettings["DownLoadMaxNum"].ToString(), out int downNum))
- {
- vm = new MainWindowViewModel(currentUserInfo, downNum);
- }
- else
- {
- vm = new MainWindowViewModel(currentUserInfo, 3);
- }
-
-
- if (int.TryParse(ConfigurationManager.AppSettings["ClearLogDay"].ToString(), out int newLogDay)) vm.ClearLogDay = newLogDay;
- //AppData.Instance.GetHouseProvider().GetSettingCommonApi();;
- this.DataContext = vm;
- AppData.Instance.MainWindowViewModel = vm;
- vm.CurrentViewModle = vm.devManageViewModel;
- ShowTimer = new DispatcherTimer();
- ShowTimer.Tick += new EventHandler(ShowCurTimer);//起个Timer一直获取当前时间
- ShowTimer.Interval = new TimeSpan(0, 0, 5);
- ShowTimer.Start();
- //Debug.WriteLine(DateTime.Now);
- }
- private void ShowCurTimer(object? sender, EventArgs e)
- {
- ShowTime();
- }
- private void ShowTime()
- {
- this.TextBlock_CurrentTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
- }
- private void Exit_Click(object sender, RoutedEventArgs e)
- {
- Application.Current.Shutdown();
- //Environment.Exit(0);
- return;
- }
- private void DevManage_PreviewMouseDown(object sender, MouseButtonEventArgs e)
- {
- if (!this.IsLoaded) return;
- if (vm == null) return;
- if (!(sender is RadioButtonNoFrame source)) return;
- if (!source.IsLoaded) return;
- if (source.IsChecked == true && vm.CurrentViewModle != vm.devManageViewModel) vm.CurrentViewModle = vm.devManageViewModel;
- }
- /// <summary>
- /// 设备管理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DevManage_Checked(object sender, RoutedEventArgs e)
- {
- if (!this.IsLoaded) return;
- if (vm == null) return;
- vm.CurrentViewModle = vm.devManageViewModel;
- foreach (var item in vm.devManageViewModel.TlInfoList)
- {
- foreach (var houseItem in item.houses)
- {
- houseItem.IsUpdate = true;
- }
- }
- }
- /// <summary>
- /// 培养记录
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DishRecord_Checked(object sender, RoutedEventArgs e)
- {
- if (!this.IsLoaded) return;
- if (AppData.Instance.MainWindowViewModel.IsClick) vm.CurrentTlSN = null;
- vm.CurrentViewModle = new DishRecordViewModel(vm.CurrentTlSN);
- }
- /// <summary>
- /// 系统异常
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void AlarmHistory_Checked(object sender, RoutedEventArgs e)
- {
- if (!this.IsLoaded) return;
- if (AppData.Instance.MainWindowViewModel.IsClick) vm.CurrentTlSN = null;
- vm.CurrentViewModle = new AlarmHistoryViewModel(vm.CurrentTlSN);
- }
- /// <summary>
- /// 远程报警
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void AlarmSetting_Checked(object sender, RoutedEventArgs e)
- {
- if (!this.IsLoaded) return;
- vm.CurrentViewModle = new AlarmSettingViewModel();
- }
- /// <summary>
- /// 模型配置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MarkSetting_Checked(object sender, RoutedEventArgs e)
- {
- if (!this.IsLoaded) return;
- vm.CurrentViewModle = new MarkSettingViewModel();
- }
- /// <summary>
- /// 舱室环境
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BinSetting_Checked(object sender, RoutedEventArgs e)
- {
- if (!this.IsLoaded) return;
- if (AppData.Instance.MainWindowViewModel.IsClick) vm.CurrentTlSN = null;
- vm.CurrentViewModle = new BinSettingViewModel(vm.CurrentTlSN);
- }
- /// <summary>
- /// 系统管理
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void RadioButtonNoFrame_Checked(object sender, RoutedEventArgs e)
- {
- if (!this.IsLoaded) return;
- vm.CurrentViewModle = new AppSettingViewModel();
- }
- private void Canvas_User_MouseEnter(object sender, MouseEventArgs e)
- {
- if (!this.IsLoaded) return;
- this.Popup_EditPassWord.IsOpen = true;
- this.TextBlock_User.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#0053C4"));
- this.Canvas_User.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/UserNameBoxMouseOver.png", UriKind.Absolute)));
- this.Image_User.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/UserHeadshotMouseOver.png", UriKind.Absolute));
- }
- private async void Canvas_User_MouseLeave(object sender, MouseEventArgs e)
- {
- if (!this.IsLoaded) return;
- await Task.Delay(200);
- if (!this.Popup_EditPassWord.IsMouseOver)
- {
- this.Popup_EditPassWord.IsOpen = false;
- this.TextBlock_User.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#003177"));
- this.Canvas_User.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/UserNameBox.png", UriKind.Absolute)));
- this.Image_User.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/UserHeadshot.png", UriKind.Absolute));
- }
- }
- private async void Popup_EditPassWord_MouseLeave(object sender, MouseEventArgs e)
- {
- if (!this.IsLoaded) return;
- await Task.Delay(200);
- if (!this.Canvas_User.IsMouseOver)
- {
- this.Popup_EditPassWord.IsOpen = false;
- this.TextBlock_User.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#003177"));
- this.Canvas_User.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/UserNameBox.png", UriKind.Absolute)));
- this.Image_User.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/UserHeadshot.png", UriKind.Absolute));
- }
- }
- private void Password_Click(object sender, RoutedEventArgs e)
- {
- //vm.devManageViewModel.View._root_Canvas.Children.Clear();
- //return;
- if (!this.IsLoaded) return;
- this.Popup_EditPassWord.IsOpen = false;
- this.TextBlock_User.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#003177"));
- this.Canvas_User.Background = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/UserNameBox.png", UriKind.Absolute)));
- this.Image_User.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/UserHeadshot.png", UriKind.Absolute));
- vm.MaskVisibility = true;
- new PasswordWindow().ShowDialog();
- vm.MaskVisibility = false;
- }
- private void Min_Click(object sender, RoutedEventArgs e)
- {
- this.WindowState = WindowState.Minimized;
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- AppData.Instance.ChangeLanguage("Chinese.xaml");
- }
- private void Button_Click1(object sender, RoutedEventArgs e)
- {
- AppData.Instance.ChangeLanguage("English.xaml");
- }
- private void Button_Click2(object sender, RoutedEventArgs e)
- {
- //for (int i = 0; i < 30; i++)
- //{
- // AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
- // {
- // NewFileFullName = @"C:\PersonalSpace\work\1 VisualWorkSpace\Personal\Git\ivf_tl_Manage_2.0\ivf_tl_Manage\Resources\1.ico",
- // FileName = i.ToString()
- // });
- //}
- //vm.DownLoadFileCount = 5;
- //return;
- //clientType 1PC、2App、3Surafce
- #if DEBUG
- string fileDir = @"C:\PersonalSpace\work\1 VisualWorkSpace\PCLan\";
- #else
- string fileDir = $"{System.AppDomain.CurrentDomain.BaseDirectory}Language\\";
- #endif
- if (true)
- {
- AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
- {
- DownLoadUrl = $"/api/tl/control/data/downloadLanguageConf",
- NewFileFullName = $"{fileDir}Chinese.xaml",
- FileName = "Chinese.xaml",
- Body = JsonConvert.SerializeObject(new { clientType = 1, region = 1 }),
- });
- AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
- {
- DownLoadUrl = $"/api/tl/control/data/downloadLanguageConf",
- NewFileFullName = $"{fileDir}English.xaml",
- FileName = "English.xaml",
- Body = JsonConvert.SerializeObject(new { clientType = 1, region = 2 }),
- });
- AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
- {
- DownLoadUrl = $"/api/tl/control/data/downloadLanguageConf",
- NewFileFullName = @"C:\PersonalSpace\work\1 VisualWorkSpace\SurfaceLan\Chinese.xaml",
- FileName = "Chinese.xaml",
- Body = JsonConvert.SerializeObject(new { clientType = 3, region = 1 }),
- });
- AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
- {
- DownLoadUrl = $"/api/tl/control/data/downloadLanguageConf",
- NewFileFullName = @"C:\PersonalSpace\work\1 VisualWorkSpace\SurfaceLan\English.xaml",
- FileName = "English.xaml",
- Body = JsonConvert.SerializeObject(new { clientType = 3, region = 2 }),
- });
- }
- else
- {
- }
- }
- private void Carousel_LogEvent(string obj)
- {
- //Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss.fff")}:{obj}----------------------------------------------");
- }
- private void AlarmSetting_CheckedNew(object sender, RoutedEventArgs e)
- {
- if (!this.IsLoaded) return;
- vm.CurrentViewModle = new AlarmSettingNewViewModel();
- }
- private void StackPanel_MouseDown(object sender, MouseButtonEventArgs e)
- {
- try
- {
- if (!this.IsLoaded || vm == null) return;
- vm.MaskVisibility = true;
- //vm.DownLoadFileList.Clear();
- //for (int i = 0; i < 100; i++)
- //{
- // vm.DownLoadFileList.Add(new DownLoadEntity
- // {
- // DownLoadUrl = "123",
- // FileName = $"filename{i}",
- // NewFileFullName = "newfileName"
- // });
- //}
- DownLoadDetailWindow downLoadDetailWindow = new DownLoadDetailWindow(vm);
- downLoadDetailWindow.ShowDialog();
- }
- finally
- {
- vm.MaskVisibility = false;
- }
- }
- }
- }
|