using ivf_tl_CustomControls;
using ivf_tl_Entity.Entity;
using ivf_tl_Entity.Entity.Mark;
using ivf_tl_Entity.Enums;
using ivf_tl_Manage.UserControls;
using ivf_tl_Service.HttpProvider;
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.Media.TextFormatting;
using System.Windows.Shapes;
namespace ivf_tl_Manage.Win
{
///
/// ImageSourceWindow.xaml 的交互逻辑
///
public partial class ImageSourceWindow : Window
{
PicProvider picProvider = null;
//List picList = new List();
public ImageSourceWindow(long embryoId, int houseSn, int pictureLayer, string tlSn)//List list,
{
try
{
InitializeComponent();
this.Owner = AppData.Instance.MainWindow;
picProvider = AppData.Instance.GetPicProvider();
//picList = list;
Loaded += (s, e) => init(embryoId, houseSn, pictureLayer, tlSn);
this.Closed += (a, b) => AppData.Instance.MainWindow.Activate();
Unloaded += (s, e) =>
{
_root_Canvas.Children.Clear();
};
}
catch (Exception ex)
{
ExLog(ex, "ImageSourceWindow");
}
}
private int CheckBoxImageNum = 1;
private void init(long embryoId, int houseSn, int pictureLayer, string tlSn)
{
var list = picProvider.GetImageSourceApi(embryoId, houseSn, pictureLayer, tlSn);
Task.Run(() =>
{
Dispatcher.Invoke(() =>
{
foreach (var item in list)
{
if (string.IsNullOrEmpty(item.sourceImageUrl)) continue;
PicSourceUserControl checkBoxImage = new PicSourceUserControl()
{
ImageSourceUrl = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{item.sourceImageUrl.Replace(AppData.Instance.PicSuf, $"_180x180{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpServiceCall.GetToken()}"),
ImageInfoString = $"{item.imageTime.ToString("MM-dd HH:mm")}",
};
if (checkBoxImage.ImageSourceUrl == null) continue;
if (CheckBoxImageNum > 7)
{
if ((CheckBoxImageNum - 1) % 7 == 0) checkBoxImage.Margin = new Thickness(0, 10, 0, 0);
else checkBoxImage.Margin = new Thickness(10, 10, 0, 0);
}
else
{
if (CheckBoxImageNum == 1) checkBoxImage.Margin = new Thickness(0);
else checkBoxImage.Margin = new Thickness(10, 0, 0, 0);
}
CheckBoxImageNum++;
_root_Canvas.Children.Add(checkBoxImage);
}
});
});
}
private void ExLog(Exception ex, string name)
{
AppData.Instance.LogService.ExceptionLog(ex, $"MarkQucikWindow.{name}", LogEnum.RunException);
}
private void ErrorLog(string message, LogEnum logType)
{
AppData.Instance.LogService.TLLog($"MarkQucikWindow.{message}", logType);
}
private void Cancel_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
return;
}
private void ScrollViewer_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
{
e.Handled = true;
}
}
}