| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- using CommunityToolkit.Mvvm.ComponentModel;
- using ivf_tl_Entity.GlobalEntitys;
- using ivf_tl_Operate.CustomUserControls;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ivf_tl_Operate.ViewModel
- {
- public partial class PhotoPageViewModel : ObservableObject
- {
- [ObservableProperty]
- private int pageIndex = 1;
- [ObservableProperty]
- private int pageSize = 16;
- [ObservableProperty]
- private int dataCount = -1;
- [ObservableProperty]
- private List<int> picLayerList = new List<int>();
- [ObservableProperty]
- private int currentPicLayer = 0;
- public long EmbryoId { get; set; } = 0;
- public int HouseSn { get; set; } = 1;
- private Dictionary<int, List<PictureView>> AllPicViewList = new Dictionary<int, List<PictureView>>();
- [ObservableProperty]
- private List<PictureView> currentPicViewList = new List<PictureView>();
- [ObservableProperty]
- private ObservableCollection<PictureView> showPicViewList = new ObservableCollection<PictureView>();
- public bool IsSourcePic { get; set; } = false;
- public bool PhotoToggle { get; set; } = false;
- public List<PhotoButton> PhotoButtonList { get; set; } = new List<PhotoButton>();
- public int MaxFocal = 0;
- public int MinFocal = 0;
- public PhotoPageViewModel(int _HouseSn,long _EmbryoId,int MaxTotalLayer)
- {
- HouseSn = _HouseSn;
- EmbryoId = _EmbryoId;
- GetMaxAndMinFocal(MaxTotalLayer);
- SetCurrentPicViewList();
- }
- private void GetMaxAndMinFocal(int MaxTotalLayer)
- {
- PicLayerList.Clear();
- if (MaxTotalLayer <= 0)
- {
- MaxFocal = 0;
- MinFocal = 0;
- PicLayerList.Add(0);
- return;
- }
- MaxFocal = (MaxTotalLayer - 1) / 2;
- MinFocal = -MaxFocal;
- for (int i = MinFocal; i <= MaxFocal; i++)
- {
- PicLayerList.Add(i);
- }
- }
- public void SetCurrentPicViewList()
- {
- if (IsSourcePic)
- {
- CurrentPicViewList = AppData.Instance.HttpHelper.GetSourcePictureViewApi(AppData.Instance.TlSn, HouseSn, EmbryoId, CurrentPicLayer);
- return;
- }
- if(AllPicViewList.ContainsKey(CurrentPicLayer))
- {
- CurrentPicViewList = AllPicViewList[CurrentPicLayer];
- return;
- }
- CurrentPicViewList = AppData.Instance.HttpHelper.GetPictureViewApi(AppData.Instance.TlSn, HouseSn, EmbryoId, CurrentPicLayer);
- AllPicViewList.Add(CurrentPicLayer, CurrentPicViewList);
- }
- public void SetShowPicViewList()
- {
- ShowPicViewList.Clear();
- Dictionary<int, int> buttonTime = new Dictionary<int, int>();
- var selButton = PhotoButtonList.Where(x => x.IsSelected).ToList();
- int k = 1;
- if (selButton.Any())
- {
- foreach (var item in selButton)
- {
- if (PhotoToggle)
- {
- buttonTime.Add(item.PhotoBoxSetting.MinHour1, item.PhotoBoxSetting.MaxHour1);
- }
- else
- {
- buttonTime.Add(item.PhotoBoxSetting.MinHour, item.PhotoBoxSetting.MaxHour);
- }
- }
- foreach (var item in CurrentPicViewList)
- {
- foreach (var buttonTimeItem in buttonTime)
- {
- if(buttonTimeItem.Value == 0)
- {
- if (item.developTime >= buttonTimeItem.Key)
- {
- item.Num = k++;
- ShowPicViewList.Add(item);
- }
- }
- else
- {
- if (item.developTime >= buttonTimeItem.Key && item.developTime <= buttonTimeItem.Value)
- {
- item.Num = k++;
- ShowPicViewList.Add(item);
- }
- }
- }
- }
- }
- else
- {
- foreach (var item in CurrentPicViewList)
- {
- item.Num = k++;
- ShowPicViewList.Add(item);
- }
- }
- DataCount = -1;
- DataCount = ShowPicViewList.Count;
- }
- }
- }
|