using DataEntity;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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;
using DataEntity.Page;
using XImagingXhandler.XDAL;
using DataRWDAL;
using XHandler.Class;
using System.Windows.Media.Animation;
namespace XHandler.View.MoveLiquidReport
{
///
/// MoveLiquidDetails.xaml 的交互逻辑
///
public partial class MoveLiquidDetails : UserControl
{
ObservableCollection experimentRunDetailModelList = new ObservableCollection();
public MainWindow mainWindow = null;
public string ExperimentId = string.Empty;
public event EventHandler closeEvent = null;
#region 变量
// 分页数据
private Pagination m_pagination = new Pagination();
#endregion
public MoveLiquidDetails(string ExperimentId)
{
InitializeComponent();
this.ExperimentId=ExperimentId;
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
try
{
Storyboard storyboard = new Storyboard();
DoubleAnimation doubleAnimation = new DoubleAnimation(0, 1900, new Duration(TimeSpan.FromSeconds(0.25)));
Storyboard.SetTarget(doubleAnimation, border);//Target对象
Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("Width"));//Target属性
storyboard.Children.Add(doubleAnimation);
ObjectAnimationUsingKeyFrames showAnimation = new ObjectAnimationUsingKeyFrames();
showAnimation.BeginTime = TimeSpan.FromSeconds(0);
Storyboard.SetTarget(showAnimation, border);
Storyboard.SetTargetProperty(showAnimation, new PropertyPath("(UIElement.Visibility)"));
DiscreteObjectKeyFrame closeKeyFrame = new DiscreteObjectKeyFrame(Visibility.Visible, TimeSpan.FromSeconds(0.01));
showAnimation.KeyFrames.Add(closeKeyFrame);
storyboard.Children.Add(showAnimation);
storyboard.Begin();
BindingExperimentRunDetailCollection();
}
catch (Exception ex)
{
}
}
private void DataGridCell_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
}
///
/// 分页绑定
///
///
private void DataBinding(Pagination pagination)
{
experimentRunDetailModelList=ExperimentRunDetailDB.GetMoveLiquidList(ExperimentId);
var resultRunDetailInformationList = GetPagedData(experimentRunDetailModelList, pagination.Current, pagination.PageSize);
var result = new Tuple, int>(resultRunDetailInformationList, experimentRunDetailModelList.Count());
if (result != null)
{
pagerToolsControl_paging.IsTrigger = false;
pagerToolsControl_paging.DataCount = result.Item2; // 当前查到数量
pagerToolsControl_paging.Current = pagination.Current;
pagerToolsControl_paging.IsTrigger = true;
dgResult.ItemsSource = result.Item1;
}
}
#region 绑定数据日志集合到界面
private void BindingExperimentRunDetailCollection()
{
DataBinding(m_pagination);
}
#endregion
#region 集合数据分页方法
private static IEnumerable GetPagedData(IEnumerable source, int currentPageNumber, int pageSize)
{
if (source == null || !source.Any()) return Enumerable.Empty();
int startIndex = (currentPageNumber - 1) * pageSize;
int endIndex = Math.Min(startIndex + pageSize, source.Count());
return source.Skip(startIndex).Take(endIndex - startIndex);
}
#endregion
private void pagerToolsControl_paging_OnePageRowCntChanged(object sender, Page.C_EventArgsClass e)
{
m_pagination.Current = e.CurrentPageNo;
m_pagination.PageSize = e.PagerNum;
DataBinding(m_pagination);
}
private void pagerToolsControl_paging_PageCntChanged(object sender, Page.C_EventArgsClass e)
{
m_pagination.Current = e.CurrentPageNo;
DataBinding(m_pagination);
}
private void btnClose_Click(object sender, RoutedEventArgs e)
{
if (EventResponseController.Instance.CanExecute() == false)
return;
Storyboard storyboard = new Storyboard();
DoubleAnimation doubleAnimation = new DoubleAnimation(1920, 0, new Duration(TimeSpan.FromSeconds(0.25)));
Storyboard.SetTarget(doubleAnimation, border);//Target对象
Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("Width"));//Target属性
storyboard.Children.Add(doubleAnimation);
ObjectAnimationUsingKeyFrames showAnimation = new ObjectAnimationUsingKeyFrames();
showAnimation.BeginTime = TimeSpan.FromSeconds(0);
Storyboard.SetTarget(showAnimation, border);
Storyboard.SetTargetProperty(showAnimation, new PropertyPath("(UIElement.Visibility)"));
DiscreteObjectKeyFrame closeKeyFrame = new DiscreteObjectKeyFrame(Visibility.Collapsed, TimeSpan.FromSeconds(0.26));
showAnimation.KeyFrames.Add(closeKeyFrame);
storyboard.Children.Add(showAnimation);
storyboard.Completed += delegate { closeEvent?.Invoke(this, EventArgs.Empty); };
storyboard.Begin();
}
}
}