85 lines
2.5 KiB
C#
85 lines
2.5 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using ProgramLib.GUI.Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
namespace ProgramLib.GUI.ViewModel
|
|
{
|
|
internal partial class LiveDataWindowViewModel : ObservableObject
|
|
{
|
|
public enum Images
|
|
{
|
|
LED_ON,
|
|
LED_OFF
|
|
}
|
|
|
|
private Window _window;
|
|
|
|
public Dictionary<Images, string> ImageToResourcePathDict
|
|
{
|
|
get
|
|
{
|
|
return _imageToResourcePathDict;
|
|
}
|
|
|
|
private set { }
|
|
}
|
|
|
|
private Dictionary<Images, string> _imageToResourcePathDict = new Dictionary<Images, string>()
|
|
{
|
|
{Images.LED_ON, @"pack://application:,,,/ProgramGui;component/Resources/Images/green-led.png" },
|
|
{Images.LED_OFF, @"pack://application:,,,/ProgramGui;component/Resources/Images/black-led.png" }
|
|
};
|
|
|
|
#region Data Bindings
|
|
public ObservableCollection<PowerModuleDataModel> _dataGridPowerDatatems { get; set; }
|
|
|
|
// 2-dimensional data array
|
|
// inner ObservableCollection<> is the columns
|
|
// outer ObservableCollection is the row
|
|
public ObservableCollection<ObservableCollection<string>> _dataGridPassthroughDatatems { get; set; }
|
|
|
|
[ObservableProperty]
|
|
private string uutPowerLedImagePath;
|
|
|
|
[ObservableProperty]
|
|
private string tePowerLedImagePath;
|
|
|
|
#endregion Data Bindings
|
|
|
|
public LiveDataWindowViewModel(Window window)
|
|
{
|
|
_window = window;
|
|
_dataGridPowerDatatems = new ObservableCollection<PowerModuleDataModel>();
|
|
_dataGridPassthroughDatatems = new ObservableCollection<ObservableCollection<string>>();
|
|
|
|
UutPowerLedImagePath = _imageToResourcePathDict[Images.LED_OFF];
|
|
TePowerLedImagePath = _imageToResourcePathDict[Images.LED_ON];
|
|
}
|
|
|
|
public void AddPowerData(Dictionary<string, PowerModuleDataModel> powerModuleToPowerDataModelDict)
|
|
{
|
|
foreach (var item in powerModuleToPowerDataModelDict)
|
|
{
|
|
_dataGridPowerDatatems.Add(item.Value);
|
|
}
|
|
}
|
|
|
|
public void AddPassthroughData(Dictionary<int, ObservableCollection<string>> rowNumberToPassthroughDataDict)
|
|
{
|
|
_window.Dispatcher.Invoke((Action)delegate
|
|
{
|
|
foreach (var item in rowNumberToPassthroughDataDict)
|
|
{
|
|
_dataGridPassthroughDatatems.Add(item.Value);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|