using System.Collections.Generic; using System.Linq; using ivf_tl_Entity.Entity.balance; using CommunityToolkit.Mvvm.ComponentModel; using ivf_tl_Entity.Entity.Result; using ivf_tl_Service.HttpProvider; using ivf_tl_Entity.Entity; using ivf_tl_Manage.Converts; using System.Diagnostics; using System; using ivf_tl_Entity.Enums; using System.Collections.ObjectModel; namespace ivf_tl_Manage.ViewModels { public partial class DetailViewModel : BaseViewModel { public DetailProvider detailProvider = null; public BaseViewModel ParentViewModel = null; [ObservableProperty] private House currentHouse = null; [ObservableProperty] private Dish currentDish; [ObservableProperty] private Embryo currentEmbryo = null; [ObservableProperty] private double videoAllTime = 1; [ObservableProperty] private double videoCurrentTime = 0; [ObservableProperty] private int currentFocal = 0; [ObservableProperty] private Dictionary fpsItemList = new Dictionary(); [ObservableProperty] private KeyValuePair selectedFps = new KeyValuePair(1, "1.0x"); [ObservableProperty] private bool isDishRecord = false; [ObservableProperty] private bool isHistory = false; [ObservableProperty] private bool isCurrentDish = true; [ObservableProperty] private bool isUpdata = false; [ObservableProperty] private ObservableCollection measurementList = new ObservableCollection(); public List DishPicAndVideoList { get; set; } = new List(); public DishPicAndVideo CurrentWellDishPicAndVideo { get; set; } = null; public LayerPicAndVideo CurrentWellLayerPicAndVideo { get; set; } = null; public DetailPic CurrentPic { get; set; } = null; public List QuickButtons { get; set; } = new List(); private bool _IsInit = false; public int MaxTotalLayer = -1; public DetailViewModel(BaseViewModel baseViewModel, TLInfo tLInfo, Dish dish, House house, bool dishrecord) { AppData.Instance.CurrentTlInfo = tLInfo; MeasurementList.Clear(); MeasurementList.Add(new MeasurementEntity { Num = 1 }); MeasurementList.Add(new MeasurementEntity { Num = 2 }); MeasurementList.Add(new MeasurementEntity { Num = 3 }); FpsItemList.Clear(); FpsItemList.Add(2, "2.0x"); FpsItemList.Add(1.5, "1.5x"); FpsItemList.Add(1.25, "1.25x"); FpsItemList.Add(1, "1.0x"); FpsItemList.Add(0.5, "0.5x"); FpsItemList.Add(0.25, "0.25x"); if (detailProvider == null) detailProvider = AppData.Instance.GetDetailProvider(); base.ViewModelName = nameof(DetailViewModel); this.ParentViewModel = baseViewModel; IsDishRecord = dishrecord; this.CurrentHouse = house; this.CurrentDish = dish; if (CurrentDish.embryoList == null) CurrentDish.embryoList = new List(); IsUpdata = true; base.NavName = $"{KeyToStringConvert.GetLanguageStringByKey("0163")}{CurrentHouse.houseSn}"; NavList.Clear(); if (IsDishRecord == true) { NavList.Add(baseViewModel); NavList.Add(this); return; } NavList.Add(AppData.Instance.MainWindowViewModel.devManageViewModel); NavList.Add(AppData.Instance.MainWindowViewModel.patientManageViewModel); NavList.Add(this); } public void Init() { Stopwatch stopwatch = Stopwatch.StartNew(); TimeLog($"{CurrentHouse.houseSn}号舱室详情界面数据初始化开始,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}", LogEnum.TakeTime); var time1 = stopwatch.Elapsed; VideoAllTime = 1; VideoCurrentTime = 0; CurrentFocal = 0; if (_IsInit) return; _IsInit = true; SelectedFps = new KeyValuePair(1, "1.0x"); CurrentEmbryo = null; DishPicAndVideoList.Clear(); CurrentWellDishPicAndVideo = null; CurrentWellLayerPicAndVideo = null; CurrentPic = null; QuickButtons.Clear(); if (CurrentDish.embryoList != null && CurrentDish.embryoList.Any()) DishPicAndVideoList = detailProvider.GetRecordDetailApi(CurrentDish.tlSn, CurrentDish.houseSn, CurrentDish.id, CurrentDish.embryoList.Select(x => x.wellSn).ToList()); var time2 = stopwatch.Elapsed; TimeLog($"获取图片视频:{DateTime.Now},耗时:{(time2 - time1).TotalMilliseconds}毫秒", LogEnum.TakeTime); QuickButtons = detailProvider.GetQuickButtonsApi(); time1 = stopwatch.Elapsed; DebugLog($"{CurrentHouse.houseSn}号舱室详情界面数据初始化完成,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")},[读取快捷按钮耗时:{(time1 - time2).TotalMilliseconds}毫秒]总耗时:{stopwatch.Elapsed.TotalMilliseconds}毫秒", LogEnum.TakeTime); stopwatch.Stop(); } public void Back() { if (ParentViewModel != null) AppData.Instance.MainWindowViewModel.CurrentViewModle = ParentViewModel; else AppData.Instance.MainWindowViewModel.CurrentViewModle = AppData.Instance.MainWindowViewModel.devManageViewModel; } public void MarkEmbryo() { //MarkUseViewModel markUseViewModel = null; //if (!IsDishRecord) markUseViewModel = new MarkUseViewModel(this, $"{KeyToStringConvert.GetLanguageStringByKey("0163")}{CurrentHouse.houseSn}"); //else markUseViewModel = new MarkUseViewModel(this, ParentViewModel, $"{KeyToStringConvert.GetLanguageStringByKey("0163")}{CurrentHouse.houseSn}"); //markUseViewModel.Init(); //AppData.Instance.MainWindowViewModel.CurrentViewModle = markUseViewModel; MarkUseViewModel markUseViewModel = new MarkUseViewModel(this, IsDishRecord, IsCurrentDish); markUseViewModel.Init(); AppData.Instance.MainWindowViewModel.CurrentViewModle = markUseViewModel; } public bool MarkEmbryo(int embryoState) { return detailProvider.MarkEmbryoDestinationApi(CurrentEmbryo.id, embryoState); } public bool EndDish() { if (detailProvider.EndCultureRecordApi(CurrentDish.id)) { AppData.Instance.MainWindowViewModel.patientManageViewModel.EndDish(CurrentDish.houseSn); return true; } return false; } public void GetPicDetail() { } } }