102 lines
2.8 KiB
C#
102 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Windows;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using ProgramLib.GUI.Model;
|
|
|
|
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;
|
|
|
|
#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;
|
|
|
|
[ObservableProperty]
|
|
private string w1CableImagePath;
|
|
|
|
[ObservableProperty]
|
|
private string w2CableImagePath;
|
|
|
|
[ObservableProperty]
|
|
private string w3CableImagePath;
|
|
|
|
[ObservableProperty]
|
|
private string w4CableImagePath;
|
|
|
|
[ObservableProperty]
|
|
private string w5CableImagePath;
|
|
|
|
[ObservableProperty]
|
|
private string labelGradientAppControlledOrUnControlled;
|
|
|
|
[ObservableProperty]
|
|
private string testTimeStr;
|
|
|
|
[ObservableProperty]
|
|
private string powerOnTimeStr;
|
|
|
|
#endregion Data Bindings
|
|
|
|
public LiveDataWindowViewModel(Window window)
|
|
{
|
|
_window = window;
|
|
_dataGridPowerDatatems = new ObservableCollection<PowerModuleDataModel>();
|
|
_dataGridPassthroughDatatems = new ObservableCollection<ObservableCollection<string>>();
|
|
|
|
_imageToResourcePathDict = new Dictionary<Images, string>()
|
|
{
|
|
{Images.LED_ON, @$"pack://application:,,,/{GetType().Assembly.GetName().Name};component/Resources/Images/green-led.png" },
|
|
{Images.LED_OFF, @$"pack://application:,,,/{GetType().Assembly.GetName().Name};component/Resources/Images/black-led.png" }
|
|
};
|
|
}
|
|
|
|
public void AddPowerData(PowerModuleDataModel powerData)
|
|
{
|
|
_dataGridPowerDatatems.Add(powerData);
|
|
}
|
|
|
|
public void AddPassthroughData(Dictionary<int, ObservableCollection<string>> rowNumberToPassthroughDataDict)
|
|
{
|
|
_window.Dispatcher.Invoke((Action)delegate
|
|
{
|
|
foreach (var item in rowNumberToPassthroughDataDict)
|
|
{
|
|
_dataGridPassthroughDatatems.Add(item.Value);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|