using LiveCharts;
using LiveCharts.Wpf;
using MathNet.Numerics.LinearAlgebra;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace FLY.HeatingHelper.UI.UiModule
{
public class UC_FrameDiffViewModel : INotifyPropertyChanged
{
IThickHeatData mdata;
public UC_FrameDiffViewModel()
{
}
///
/// 两个ID
///
public int FrameIdx1 { get; set; } = -1;
public int FrameIdx2 { get; set; } = -1;
public void Init(IThickHeatData dat)
{
mdata = dat;
PropertyChanged += DataSelecter_PropertyChanged;
}
Vector thick1;
Vector thick2;
Vector heat1;
Vector heat2;
Vector thickDiff;
Vector heatDiff;
void Update()
{
if (FrameIdx1 < 0 || FrameIdx2 < 0 || (mdata is null))
{
return;
}
thick1 = Vector.Build.DenseOfArray(mdata.GetThicksByIndex(FrameIdx1, -1, -1));
thick2 = Vector.Build.DenseOfArray(mdata.GetThicksByIndex(FrameIdx2, -1, -1));
heat1 = Vector.Build.DenseOfArray(mdata.GetHeatsByIndex(FrameIdx1, -1, -1));
heat2 = Vector.Build.DenseOfArray(mdata.GetHeatsByIndex(FrameIdx2, -1, -1));
thickDiff = thick2 - thick1;
heatDiff = heat1 - heat2;
UpdateSeries();
}
public double[] DS_vthick { get; set; }
public double[] DS_vheat { get; set; }
private void UpdateSeries()
{
DS_vthick = thickDiff.ToArray();
DS_vheat = heatDiff.ToArray();
}
private void DataSelecter_PropertyChanged(object s, PropertyChangedEventArgs e)
{
if (e.PropertyName == "FrameIdx1" || e.PropertyName == "FrameIdx2")
{
Update();
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}