| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423 |
- using ivf_tl_Entity.DebugEntitys;
- using ivf_tl_Operate.Converts;
- using ivf_tl_Operate.ViewModel;
- using ivf_tl_Operate.Windows;
- using ivf_tl_Services;
- 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.Animation;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace ivf_tl_Operate.View
- {
- /// <summary>
- /// SettingPageView.xaml 的交互逻辑
- /// </summary>
- public partial class SettingPageView : UserControl
- {
- string guanbi;
- public TLSettingCommon tLSettingCommon = null;
- public SettingPageView()
- {
- InitializeComponent();
- List<int> autoTimeList = new List<int>();
- for (int i = 0; i < 24; i++) autoTimeList.Add(i);
- List<int> zhenList = new List<int>();
- for (int i = 1; i <= 30; i++) zhenList.Add(i);
- guanbi = KeyToStringConvert.GetLanguageStringByKey("C0305");
- List<string> cropList = new List<string>() { guanbi, "1", "3", "5", "7", "9", "11", "13", "15", "17", "19", "21", "23", "25" };
- //for (int i = 1; i <= 11; i++) cropList.Add(i);
- this._timingAutoFocus_ComboBox.ItemsSource = autoTimeList;
- this._videoFps_ComboBox.ItemsSource = zhenList;
- this._cropNum_ComboBox.ItemsSource = cropList;
- Loaded += SettingPageView_Loaded;
- }
- private void SettingPageView_Loaded(object sender, RoutedEventArgs e)
- {
- if (AppData.Instance.TLSettingCommon != null && AppData.Instance.TLSettingCommon.id == 0)
- {
- AppData.Instance.TLSettingCommon = AppData.Instance.HttpHelper.SettingCommonApi(AppData.Instance.TLSettingCommon.tlSn);
- if (AppData.Instance.TLSettingCommon != null && AppData.Instance.TLSettingCommon.id == 0)
- {
- new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, "获取设置失败");
- }
- }
- tLSettingCommon = AppData.Instance.TLSettingCommon;
- SetPageInfo();
- }
- private string GetDataTime()
- {
- try
- {
- AppData.Instance.MainWindow.Mark(true);
- GetDateWindow getDate = new GetDateWindow(AppData.Instance.MainWindow);
- //getDate._dateControl.SetNYR(false);
- getDate.SetSelectWeiLai();
- getDate.isClos = true;
- var result = getDate.ShowDialog();
- if (result.Value == true)
- {
- return $"{getDate.Date} 00:00:00";
- }
- return null;
- }
- catch (Exception ex)
- {
- return null;
- }
- finally
- {
- AppData.Instance.MainWindow.Mark(false);
- }
- }
- private void SetPageInfo()
- {
- //this._timingAutoFocus_TextBlock.Text = $"{tLSettingCommon.autoFocusTime} >";
- //this._videoFps_TextBlock.Text = $"{tLSettingCommon.videoFps} >";
- //this._hepaTime_TextBlock.Text = $"{tLSettingCommon.heapDate} >";
- //this._keepTime_TextBlock.Text = $"{tLSettingCommon.keepDate} >";
- this._timingAutoFocus_ComboBox.SelectedItem = tLSettingCommon.autoFocusTime;
- this._videoFps_ComboBox.SelectedItem = tLSettingCommon.videoFps;
- if (tLSettingCommon.cropNum == -1)
- {
- this._cropNum_ComboBox.SelectedItem = guanbi;
- }
- else
- {
- this._cropNum_ComboBox.SelectedItem = tLSettingCommon.cropNum.ToString();
- }
- }
- private bool MiMa(PasswordBox textBox)
- {
- bool rs = false;
- // M5-02-3:工程师口令改读加密存储的 engineerPwd(首次无值回退默认 tl13579,迁移已在 App_Startup 加密回写)。
- // 方法签名与 7 处调用点不变(00-需求总览.md §8),仅换口令来源。[D8] 权限分级(普通运维 vs 工程师)待确认。
- string engineerPwd = ivf_tl_Operate.Helpers.AppConfigHelper.GetEngineerPwd();
- if (textBox.Password.Trim() == engineerPwd) rs = true;
- textBox.Password = "";
- return rs;
- }
- private bool UpdataTlSetting()
- {
- if (AppData.Instance.HttpHelper.CommonUpdateApi(tLSettingCommon))
- {
- new MessagePrompt().ShowCenterOwnerSuccess(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0232"));
- return true;
- }
- else
- {
- //new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, "更新失败");
- new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0233"));
- return false;
- }
- }
- private void Return_Click(object sender, RoutedEventArgs e)
- {
- AppData.Instance.BackMainPage();
- }
- private void TimingAutoFocus_ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (this._timingAutoFocus_ComboBox.SelectedItem is int newValue)
- {
- if (newValue != tLSettingCommon.autoFocusTime)
- {
- int oldValue = tLSettingCommon.autoFocusTime;
- tLSettingCommon.autoFocusTime = newValue;
- if (!UpdataTlSetting()) tLSettingCommon.autoFocusTime = oldValue;
- }
- }
- }
- private void VideoFps_ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (this._videoFps_ComboBox.SelectedItem is int newValue)
- {
- if (newValue != tLSettingCommon.videoFps)
- {
- int oldValue = tLSettingCommon.videoFps;
- tLSettingCommon.videoFps = newValue;
- if (!UpdataTlSetting()) tLSettingCommon.videoFps = oldValue;
- }
- }
- }
- /// <summary>
- /// HEPA下次更换时间
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void HepaTime_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (!MiMa(this._hepaTime_PasswordBox))
- {
- //new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, "密码输入错误");
- new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0234"));
- return;
- }
- string newTime = GetDataTime();
- if (string.IsNullOrEmpty(newTime))
- {
- return;
- }
- string oldValue = tLSettingCommon.heapDate;
- tLSettingCommon.heapDate = newTime;
- if (!UpdataTlSetting()) tLSettingCommon.heapDate = oldValue;
- }
- /// <summary>
- /// 设备下次保养时间
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void KeepTime_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (!MiMa(this.KeepTime_PasswordBox))
- {
- //new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, "密码输入错误");
- new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0234"));
- return;
- }
- string newTime = GetDataTime();
- if (string.IsNullOrEmpty(newTime))
- {
- return;
- }
- string oldValue = tLSettingCommon.keepDate;
- tLSettingCommon.keepDate = newTime;
- if (!UpdataTlSetting()) tLSettingCommon.keepDate = oldValue;
- }
- /// <summary>
- /// 系统参数设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void HouseSetting_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (!MiMa(this.HouseSetting_PasswordBox))
- {
- //new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, "密码输入错误");
- new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0234"));
- return;
- }
- HouseSettingPageViewModel houseSettingPageViewModel = new HouseSettingPageViewModel();
- HouseSettingPageView houseSettingPageView = new HouseSettingPageView()
- {
- DataContext = houseSettingPageViewModel,
- };
- //houseSettingPageView.TestData();
- AppData.Instance.MainWindow.LoadPage(houseSettingPageView);
- }
- /// <summary>
- /// 对焦参数设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void AutoFocusSetting_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (!MiMa(this.AutoFocusSetting_PasswordBox))
- {
- //new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, "密码输入错误");
- new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0234"));
- return;
- }
- AutoFocusSettingViewModel autoFocusSettingViewModel = new AutoFocusSettingViewModel();
- AutoFocusSettingView autoFocusSettingView = new AutoFocusSettingView(autoFocusSettingViewModel);
- AppData.Instance.MainWindow.LoadPage(autoFocusSettingView);
- }
- /// <summary>
- /// 舱室调试
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void HouseDebug_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (!MiMa(this.HouseDebug_PasswordBox))
- {
- //new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, "密码输入错误");
- new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0234"));
- return;
- }
- if (!IsClose())
- {
- //new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, "请先关闭下位机控制软件");
- new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0235"));
- return;
- }
- HouseDebugPageViewModel houseDebugPageViewModel = new HouseDebugPageViewModel();
- string err = null;
- houseDebugPageViewModel.Start(ref err);
- if (!string.IsNullOrEmpty(err))
- {
- if (err == "结束") return;
- MessageBox.Show(err);
- return;
- }
- HouseDebugPageView houseDebugPageView = new HouseDebugPageView(houseDebugPageViewModel);
- AppData.Instance.MainWindow.LoadPage(houseDebugPageView);
- }
- /// <summary>
- /// 缓冲瓶调试
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BufferDebug_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (!MiMa(this.BufferDebug_PasswordBox))
- {
- //new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, "密码输入错误");
- new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0234"));
- return;
- }
- if (!IsClose())
- {
- //new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, "请先关闭下位机控制软件");
- new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0235"));
- return;
- }
- BufferDebugViewModel bufferDebugViewModel = new BufferDebugViewModel();
- string err = null;
- bufferDebugViewModel.Start(ref err);
- if (!string.IsNullOrEmpty(err))
- {
- if (err == "结束") return;
- MessageBox.Show(err);
- return;
- }
- BufferDebugView houseDebugPageView = new BufferDebugView(bufferDebugViewModel);
- AppData.Instance.MainWindow.LoadPage(houseDebugPageView);
- }
- /// <summary>
- /// 退出系统
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Exit_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (!MiMa(this.Exit_PasswordBox))
- {
- //new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, "密码输入错误");
- new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0234"));
- return;
- }
- App.Current.Shutdown();
- }
- /// <summary>
- /// 关于我们
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void About_MouseUp(object sender, MouseButtonEventArgs e)
- {
- AboutView houseDebugPageView = new AboutView();
- AppData.Instance.MainWindow.LoadPage(houseDebugPageView);
- }
- /// <summary>
- /// M5-02-4:统一配置(本地层配置界面化)。工程师口令保护,仿 HouseSetting_MouseUp。既有入口不变。
- /// </summary>
- private void UnifiedConfig_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (!MiMa(this.UnifiedConfig_PasswordBox))
- {
- new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0234"));
- return;
- }
- UnifiedConfigView unifiedConfigView = new UnifiedConfigView();
- AppData.Instance.MainWindow.LoadPage(unifiedConfigView);
- }
- /// <summary>
- /// M5-03-5:服务监控(只读)。仿 About_MouseUp(无口令、直接进入)。
- /// 监控页纯只读、无任何控制/写控件。[D8] 是否需口令/权限分级待确认。既有入口不变。
- /// </summary>
- private void ServiceMonitor_MouseUp(object sender, MouseButtonEventArgs e)
- {
- ServiceMonitorView serviceMonitorView = new ServiceMonitorView();
- AppData.Instance.MainWindow.LoadPage(serviceMonitorView);
- }
- private void _exitPass_PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
- {
- PasswordBox passwordBox = sender as PasswordBox;
- if (passwordBox == null) return;
- string ss = passwordBox.Password.Trim();
- if (string.IsNullOrEmpty(ss))
- {
- passwordBox.Background = (VisualBrush)this.FindResource("HelpBrush");
- }
- else
- {
- passwordBox.Background = new SolidColorBrush(Colors.White);
- }
- }
- private void Min_MouseUp(object sender, MouseButtonEventArgs e)
- {
- AppData.Instance.MainWindow.WindowState = WindowState.Minimized;
- }
- private bool IsClose()
- {
- Process[] processes = Process.GetProcessesByName("ivf_tl_ControlMain");
- if (processes.Length == 0) return true;
- return false;
- }
- private void CropNum_ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (this._cropNum_ComboBox.SelectedItem is string newValue)
- {
- int newValueInt;
- if (!int.TryParse(newValue, out newValueInt) && newValue == guanbi) newValueInt = -1;
- if (newValueInt != tLSettingCommon.cropNum)
- {
- int oldValue = tLSettingCommon.cropNum;
- tLSettingCommon.cropNum = newValueInt;
- if (!UpdataTlSetting())
- {
- tLSettingCommon.cropNum = oldValue;
- if (tLSettingCommon.cropNum == -1)
- {
- this._cropNum_ComboBox.SelectedItem = guanbi;
- }
- else
- {
- this._cropNum_ComboBox.SelectedItem = tLSettingCommon.cropNum.ToString();
- }
- }
- }
- }
- }
- }
- }
|