| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- using ivf_tl_Entity;
- using ivf_tl_Entity.GlobalEntitys;
- using ivf_tl_Entity.GlobalEnums;
- using ivf_tl_Operate.Converts;
- using ivf_tl_Operate.CustomUserControls;
- using ivf_tl_Operate.ViewModel;
- using ivf_tl_Operate.Windows;
- using System;
- using System.Collections.Generic;
- 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.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace ivf_tl_Operate.View
- {
- /// <summary>
- /// PhotoPageView.xaml 的交互逻辑
- /// </summary>
- public partial class PhotoPageView : UserControl
- {
- private PhotoPageViewModel vm;
- public DetailPageViewModel parentVm;
- public List<PhotoBox> PhotoBoxes { get; set; } = new List<PhotoBox>();
- //private List<PhotoButton> photoButtons = new List<PhotoButton>();
- public int WellSn = 0;
- public PhotoPageView(DetailPageViewModel parentVm1, int wellSn)
- {
- InitializeComponent();
- WellSn = wellSn;
- //this._well_textbolock.Text = $"well{wellSn}原图";
- this._well_textbolock.Text = $"well{wellSn}{Environment.NewLine}{KeyToStringConvert.GetLanguageStringByKey("C0236")}";
- parentVm = parentVm1;
- for (int i = 1; i < 17; i++)
- {
- PhotoBox photoBox = new PhotoBox();
- photoBox.ID = i;
- photoBox.Tag = i;
- photoBox.Visibility = Visibility.Hidden;
- photoBox.MouseUp += PhotoBox_MouseUp;
- this.PhotoBoxes.Add(photoBox);
- _container.Children.Add(photoBox);
- }
- this._photoButton1.PhotoBoxSetting = new PhotoBoxSetting() { MinHour = 0, MaxHour = 24 * 60, MinHour1 = 16 * 60, MaxHour1 = 18 * 60, name = "0-24", name1 = "16-18" };
- this._photoButton2.PhotoBoxSetting = new PhotoBoxSetting() { MinHour = 24 * 60, MaxHour = 48 * 60, MinHour1 = 26 * 60, MaxHour1 = 28 * 60, name = "24-48", name1 = "26-28" };
- this._photoButton3.PhotoBoxSetting = new PhotoBoxSetting() { MinHour = 48 * 60, MaxHour = 72 * 60, MinHour1 = 36 * 60, MaxHour1 = 38 * 60, name = "48-72", name1 = "36-38" };
- this._photoButton4.PhotoBoxSetting = new PhotoBoxSetting() { MinHour = 72 * 60, MaxHour = 96 * 60, MinHour1 = 46 * 60, MaxHour1 = 48 * 60, name = "72-96", name1 = "46-48" };
- this._photoButton5.PhotoBoxSetting = new PhotoBoxSetting() { MinHour = 96 * 60, MaxHour = 120 * 60, MinHour1 = 56 * 60, MaxHour1 = 58 * 60, name = "96-120", name1 = "56-68" };
- this._photoButton6.PhotoBoxSetting = new PhotoBoxSetting() { MinHour = 120 * 60, MaxHour = 144 * 60, MinHour1 = 66 * 60, MaxHour1 = 68 * 60, name = "120-144", name1 = "66-68" };
- this._photoButton7.PhotoBoxSetting = new PhotoBoxSetting() { MinHour = 144 * 60, MaxHour = 0, MinHour1 = 76 * 60, MaxHour1 = 78 * 60, name = "144+", name1 = "76-78" };
- var b11 = AppData.Instance.HttpHelper.GetTimeButtonsApi();
- PhotoBoxSetting pho = null;
- List<ButtonEntity> b = new List<ButtonEntity>();
- foreach (var item in b11)
- {
- if (item.type == "COMMON_BUTTON")
- {
- b = item.button.Take(7).OrderBy(x => x.minHour).ToList();
- for (int i = 0; i < b.Count; i++)
- {
- var item1 = b[i];
- switch (i)
- {
- case 0:
- pho = this._photoButton1.PhotoBoxSetting;
- if (pho == null) pho = new PhotoBoxSetting();
- pho.MinHour = item1.minHour * 60;
- pho.MaxHour = item1.maxHour * 60;
- pho.name = item1.buttonName;
- break;
- case 1:
- pho = this._photoButton2.PhotoBoxSetting;
- if (pho == null) pho = new PhotoBoxSetting();
- pho.MinHour = item1.minHour * 60;
- pho.MaxHour = item1.maxHour * 60;
- pho.name = item1.buttonName;
- break;
- case 2:
- pho = this._photoButton3.PhotoBoxSetting;
- if (pho == null) pho = new PhotoBoxSetting();
- pho.MinHour = item1.minHour * 60;
- pho.MaxHour = item1.maxHour * 60;
- pho.name = item1.buttonName;
- break;
- case 3:
- pho = this._photoButton4.PhotoBoxSetting;
- if (pho == null) pho = new PhotoBoxSetting();
- pho.MinHour = item1.minHour * 60;
- pho.MaxHour = item1.maxHour * 60;
- pho.name = item1.buttonName;
- break;
- case 4:
- pho = this._photoButton5.PhotoBoxSetting;
- if (pho == null) pho = new PhotoBoxSetting();
- pho.MinHour = item1.minHour * 60;
- pho.MaxHour = item1.maxHour * 60;
- pho.name = item1.buttonName;
- break;
- case 5:
- pho = this._photoButton6.PhotoBoxSetting;
- if (pho == null) pho = new PhotoBoxSetting();
- pho.MinHour = item1.minHour * 60;
- pho.MaxHour = item1.maxHour * 60;
- pho.name = item1.buttonName;
- break;
- case 6:
- pho = this._photoButton7.PhotoBoxSetting;
- if (pho == null) pho = new PhotoBoxSetting();
- pho.MinHour = item1.minHour * 60;
- pho.MaxHour = item1.maxHour * 60;
- pho.name = item1.buttonName;
- break;
- }
- }
- }
- else if (item.type == "KEY_BUTTON")
- {
- b = item.button.Take(7).OrderBy(x => x.minHour).ToList();
- for (int i = 0; i < b.Count; i++)
- {
- var item1 = b[i];
- switch (i)
- {
- case 0:
- pho = this._photoButton1.PhotoBoxSetting;
- if (pho == null) pho = new PhotoBoxSetting();
- pho.MinHour1 = item1.minHour * 60;
- pho.MaxHour1 = item1.maxHour * 60;
- pho.name1 = item1.buttonName;
- break;
- case 1:
- pho = this._photoButton2.PhotoBoxSetting;
- if (pho == null) pho = new PhotoBoxSetting();
- pho.MinHour1 = item1.minHour * 60;
- pho.MaxHour1 = item1.maxHour * 60;
- pho.name1 = item1.buttonName;
- break;
- case 2:
- pho = this._photoButton3.PhotoBoxSetting;
- if (pho == null) pho = new PhotoBoxSetting();
- pho.MinHour1 = item1.minHour * 60;
- pho.MaxHour1 = item1.maxHour * 60;
- pho.name1 = item1.buttonName;
- break;
- case 3:
- pho = this._photoButton4.PhotoBoxSetting;
- if (pho == null) pho = new PhotoBoxSetting();
- pho.MinHour1 = item1.minHour * 60;
- pho.MaxHour1 = item1.maxHour * 60;
- pho.name1 = item1.buttonName;
- break;
- case 4:
- pho = this._photoButton5.PhotoBoxSetting;
- if (pho == null) pho = new PhotoBoxSetting();
- pho.MinHour1 = item1.minHour * 60;
- pho.MaxHour1 = item1.maxHour * 60;
- pho.name1 = item1.buttonName;
- break;
- case 5:
- pho = this._photoButton6.PhotoBoxSetting;
- if (pho == null) pho = new PhotoBoxSetting();
- pho.MinHour1 = item1.minHour * 60;
- pho.MaxHour1 = item1.maxHour * 60;
- pho.name1 = item1.buttonName;
- break;
- case 6:
- pho = this._photoButton7.PhotoBoxSetting;
- if (pho == null)
- {
- pho = new PhotoBoxSetting();
- }
- pho.MinHour1 = item1.minHour * 60;
- pho.MaxHour1 = item1.maxHour * 60;
- pho.name1 = item1.buttonName;
- break;
- }
- }
- }
- }
- Loaded += (s, e) =>
- {
- vm = this.DataContext as PhotoPageViewModel;
- if (vm == null) return;
- vm.PhotoButtonList.Add(_photoButton1);
- vm.PhotoButtonList.Add(_photoButton2);
- vm.PhotoButtonList.Add(_photoButton3);
- vm.PhotoButtonList.Add(_photoButton4);
- vm.PhotoButtonList.Add(_photoButton5);
- vm.PhotoButtonList.Add(_photoButton6);
- vm.PhotoButtonList.Add(_photoButton7);
- vm.PhotoToggle = false;
- InitializeToggle(false, false);
- //_box.Children.Clear();
- //for (int i = vm.MinFocal; i <= vm.MaxFocal; i++)
- //{
- // int k = i;
- // Border itembor = new Border();
- // itembor.Width = 178;
- // itembor.Height = 80;
- // itembor.Margin = new Thickness(10);
- // itembor.BorderThickness = new Thickness(0, 0, 0, 1);
- // itembor.BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#DDDEE0"));
- // itembor.Background = new SolidColorBrush(Colors.Transparent);
- // itembor.Tag = i;
- // itembor.VerticalAlignment = VerticalAlignment.Center;
- // itembor.HorizontalAlignment = HorizontalAlignment.Center;
- // TextBlock itemText = new TextBlock();
- // itemText.FontSize = 44;
- // itemText.VerticalAlignment = VerticalAlignment.Center;
- // itemText.HorizontalAlignment = HorizontalAlignment.Center;
- // itemText.Text = i.ToString();
- // itemText.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3A5F91"));
- // itemText.TextAlignment = TextAlignment.Center;
- // //itemText.Background = new SolidColorBrush(Colors.LightBlue);
- // itembor.Child = itemText;
- // itembor.MouseUp += (s, e) =>
- // {
- // _popupLiquid.IsOpen = false;
- // if (k.ToString() == this._picNum_TextBlock.Text)
- // {
- // return;
- // }
- // this._picNum_TextBlock.Text = k.ToString();
- // vm.CurrentPicLayer = k;
- // vm.SetCurrentPicViewList();
- // vm.SetShowPicViewList();
- // //var temp = s as Border;
- // //string newpicnum = temp.Tag.ToString();
- // //string oldpicnum = this._picNum_TextBlock.Text;
- // //if (newpicnum != oldpicnum)
- // //{
- // // this._picNum_TextBlock.Text = temp.Tag.ToString();
- // // // GetAllPhotos((int)temp.Tag);
- // //}
- // };
- // _box.Children.Add(itembor);
- //}
- vm.SetShowPicViewList();
- };
- Unloaded += (s, e) =>
- {
- this.Grid_Root.Children.Clear();
- if (vm != null) vm = null;
- this.DataContext = null;
- };
- }
- private void PhotoBox_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (AppData.Instance.MainWindow == null) return;
- if (!(sender is PhotoBox box)) return;
- if (vm == null) return;
- AppData.Instance.MainWindow.Mark(true);
- //PhotoWindow win = new PhotoWindow(uri);
- //win.ShowDialog();
- new PhotoWindowNew(vm.ShowPicViewList, box.ID, vm.IsSourcePic).ShowDialog();
- AppData.Instance.MainWindow.Mark(false);
- }
- private void InitializeToggle(bool photoToggle, bool isRefresh)
- {
- if (vm == null) return;
- bool b = false;
- if (isRefresh)
- {
- if (vm.PhotoButtonList.FirstOrDefault(x => x.IsSelected) != null)
- {
- b = true;
- }
- }
- foreach (var button in vm.PhotoButtonList)
- {
- button.IsSelected = false;
- if (photoToggle)
- {
- button.Content = button.PhotoBoxSetting.name1;
- }
- else
- {
- button.Content = button.PhotoBoxSetting.name;
- }
- }
- if (b)
- {
- vm.SetShowPicViewList();
- }
- }
- private void Return_Click(object sender, RoutedEventArgs e)
- {
- DetailPageView detailPageView = new DetailPageView()
- {
- DataContext = parentVm,
- };
- AppData.Instance.MainWindow.LoadPage(detailPageView);
- }
- private void Image_MouseUp_PhotoToggle(object sender, MouseButtonEventArgs e)
- {
- if (!(sender is PhotoToggle photoToggle)) return;
- vm.PhotoToggle = photoToggle.IsOpen;
- InitializeToggle(photoToggle.IsOpen, true);
- }
- private void CustomControlPagination_PageChangedEvent(int obj)
- {
- if (vm == null) return;
- foreach (var item in PhotoBoxes)
- {
- item.Visibility = Visibility.Hidden;
- }
- vm.PageIndex = obj;
- var list = vm.ShowPicViewList.Skip(vm.PageSize * (obj - 1)).Take(vm.PageSize).ToList();
- for (int i = 0; i < list.Count; i++)
- {
- this.PhotoBoxes[i].ID = list[i].Num;
- if (vm.IsSourcePic)
- {
- this.PhotoBoxes[i].ImageSource = AppData.Instance.ConvertHelper.StringToBitmapImage($"{AppData.Instance.BaseUrl}{list[i].sourceImageUrl.Replace(AppData.Instance.PicSuf, $"_240x240{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpHelper.GetToken()}");
- }
- else
- {
- this.PhotoBoxes[i].ImageSource = AppData.Instance.ConvertHelper.StringToBitmapImage($"{AppData.Instance.BaseUrl}{list[i].imageUrl.Replace(AppData.Instance.PicSuf, $"_240x240{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpHelper.GetToken()}");
- }
- this.PhotoBoxes[i].peiYangShiChang = list[i].imageTime.ToString("MM-dd HH:mm");
- this.PhotoBoxes[i].Visibility = Visibility.Visible;
- }
- }
- private void _BorderLiquid_MouseUp(object sender, MouseButtonEventArgs e)
- {
- //if (_popupLiquid.IsOpen) _popupLiquid.IsOpen = false;
- //else _popupLiquid.IsOpen = true;
- }
- private void TextBlock_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (vm == null) return;
- if (vm.IsSourcePic)
- {
- vm.IsSourcePic = false;
- //this._well_textbolock.Text = $"well{WellSn}原图";
- this._well_textbolock.Text = $"well{WellSn}{Environment.NewLine}{KeyToStringConvert.GetLanguageStringByKey("C0236")}";
- vm.SetCurrentPicViewList();
- vm.SetShowPicViewList();
- }
- else
- {
- vm.IsSourcePic = true;
- //this._well_textbolock.Text = $"well{WellSn}抠图";
- this._well_textbolock.Text = $"well{WellSn}{Environment.NewLine}{KeyToStringConvert.GetLanguageStringByKey("C0236")}";
- vm.SetCurrentPicViewList();
- vm.SetShowPicViewList();
- }
- }
- private void Image_MouseUp_Output(object sender, MouseButtonEventArgs e)
- {
- }
- private void ChangePicNum_MouseUp(object sender, MouseButtonEventArgs e)
- {
- }
- private void UserControl_Loaded(object sender, RoutedEventArgs e)
- {
- }
- private void PhotoButton_MouseUp(object sender, MouseButtonEventArgs e)
- {
- if (vm == null) return;
- if (!(sender is PhotoButton button)) return;
- button.IsSelected = !button.IsSelected;
- vm.SetShowPicViewList();
- }
- private void BigFocus_Click(object sender, MouseButtonEventArgs e)
- {
- ChangeFocal(true);
- }
- private void SmallFocus_Click(object sender, MouseButtonEventArgs e)
- {
- ChangeFocal(false);
- }
- /// <summary>
- /// 切换图层
- /// </summary>
- /// <param name="isMax"></param>
- private void ChangeFocal(bool isMax)
- {
- try
- {
- if (vm == null) return;
- int newCurrentFocal = vm.CurrentPicLayer;
- if (isMax) newCurrentFocal++;
- else newCurrentFocal--;
- if (newCurrentFocal < vm.MaxFocal)
- {
- this._bigFocal_Button.IsEnabled = true;
- this._bigFocal_Button.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/DetailBigFocusIcon.png", UriKind.Relative));
- }
- else
- {
- this._bigFocal_Button.IsEnabled = false;
- this._bigFocal_Button.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/DetailBigFocusEnableIcon.png", UriKind.Relative));
- }
- if (newCurrentFocal > vm.MinFocal)
- {
- this._smallFocal_Button.IsEnabled = true;
- this._smallFocal_Button.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/DetailSmallFocusIcon.png", UriKind.Relative));
- }
- else
- {
- this._smallFocal_Button.IsEnabled = false;
- this._smallFocal_Button.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/DetailSmallFocusEnableIcon.png", UriKind.Relative));
- }
- if (newCurrentFocal < vm.MinFocal || newCurrentFocal > vm.MaxFocal) return;
- vm.CurrentPicLayer = newCurrentFocal;
- vm.SetCurrentPicViewList();
- vm.SetShowPicViewList();
- }
- catch (Exception ex)
- {
- AppData.Instance.LogHelper.TLLog($"PhotoPageView.{ChangeFocal}", LogEnum.RunException);
- }
- }
- }
- }
|