using ivf_tl_Manage.Converts; using ivf_tl_Manage.ViewModels; using ivf_tl_Manage.Win; using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; using System.Threading; 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.Navigation; using System.Windows.Shapes; namespace ivf_tl_Manage.Views { /// /// HouseSettingView.xaml 的交互逻辑 /// public partial class HouseSettingView : UserControl { private HouseSettingViewModel vm; public HouseSettingView() { InitializeComponent(); List sdf = new List(); for (int i = 0; i < 10; i++) { sdf.Add(i); } //this.te.ItemsSource= sdf; Loaded += HouseSettingView_Loaded; } private void HouseSettingView_Loaded(object sender, RoutedEventArgs e) { vm = (HouseSettingViewModel)this.DataContext; if (vm == null) return; Task.Run(() => { vm.Init(); Dispatcher.InvokeAsync(() => { if (vm == null || vm.CurrentTlSettingCommon == null) return; if (!string.IsNullOrEmpty(vm.CurrentTlSettingCommon.reportHospitalLogoUrl)) { this.logoImage.Source = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{vm.CurrentTlSettingCommon.reportHospitalLogoUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}"); } if (vm == null || vm.CurrentTlSettingCommon == null) return; this._autoTime_ComBox.SelectedItem = vm.CurrentTlSettingCommon.autoFocusTime; this._videoZhen_ComBox.SelectedItem = vm.CurrentTlSettingCommon.videoFps; }); }); } public void MessageShow(string message) { new ToastMessageWindow(AppData.Instance.MainWindow, 1920, 65, message).Show(); } private void Toast(bool success) { new ToastWindow(AppData.Instance.MainWindow, 1920, 65, success).Show(); } private void Button_Click(object sender, RoutedEventArgs e) { if (vm == null) return; AppData.Instance.MainWindowViewModel.CurrentViewModle = vm.ParentViewModel; } private void Button_Click_1(object sender, RoutedEventArgs e) { } private void checkKey_Checked(object sender, RoutedEventArgs e) { } private void ScrollViewer_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e) { e.Handled = true; } private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e) { if ((e.OriginalSource is Border s && (s.Name == "customControlBorder" || s.Name == "dropDownBorder")) || (e.OriginalSource is TextBlock t && t.TemplatedParent is ContentPresenter tc && tc.Name == "customControlTextBlock") || (e.OriginalSource is Grid gr && gr.TemplatedParent is ScrollViewer grc && grc.Name == "DropDownScrollViewer")) return; if (!(sender is ScrollViewer scrollViewer)) return; if (e.Delta > 0) { scrollViewer.LineLeft(); scrollViewer.LineLeft(); } else { scrollViewer.LineRight(); scrollViewer.LineRight(); } e.Handled = true; } const long FileLengthMax = 1048576; private void UpLoadLogo_Click(object sender, RoutedEventArgs e) { var dialog = new Microsoft.Win32.OpenFileDialog { Filter = $"{KeyToStringConvert.GetLanguageStringByKey("0608")}|*.jpg;*.png" }; if (dialog.ShowDialog() != true) return; string filePath = dialog.FileName; FileInfo fileInfo = new FileInfo(filePath); if (fileInfo.Length > FileLengthMax) { //MessageShow("LOGO文件不能超过1M"); MessageShow(KeyToStringConvert.GetLanguageStringByKey("0609")); return; } var fileByte = File.ReadAllBytes(filePath); if (!vm.UploadLogo(fileByte, System.IO.Path.GetFileName(filePath))) { //MessageShow("LOGO上传失败"); MessageShow(KeyToStringConvert.GetLanguageStringByKey("0592")); return; } logoImage.Source = AppData.Instance.ByteToBitmapImage(fileByte); } private void ClearLogo_Click(object sender, RoutedEventArgs e) { if (vm == null) return; if (vm.ClearLogo()) { this.logoImage.Source = null; Toast(true); return; } Toast(false); } private void UpdateSettingCommon_Click(object sender, RoutedEventArgs e) { if (vm == null) return; if (vm.CurrentTlSettingCommon.reportHospitalName.Length > 50) { //MessageShow("医院名称最大支持50个字符"); MessageShow(KeyToStringConvert.GetLanguageStringByKey("0593")); return; } Toast(vm.UpdateSettingCommon()); } private void SaveSetting_Click(object sender, RoutedEventArgs e) { if (vm == null) return; Toast(vm.UpdateSettingSystem()); } } }