Big changes

This commit is contained in:
Duc
2025-03-13 12:04:22 -07:00
parent c689fcb7f9
commit ffa9905494
748 changed files with 199255 additions and 3743 deletions

View File

@@ -0,0 +1,63 @@
using CommunityToolkit.Mvvm.ComponentModel;
using ProgramLib.GUI.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Threading;
namespace ProgramLib.GUI.ViewModel
{
internal class ImpedanceCheckWindowViewModel : ObservableObject
{
private Window _window;
public enum Images
{
PASS_CHECK,
FAIL_CHECK
}
public Dictionary<Images, string> ImageToResourcePathDict
{
get
{
return _imageToResourcePathDict;
}
private set { }
}
private Dictionary<Images, string> _imageToResourcePathDict = new Dictionary<Images, string>()
{
{Images.PASS_CHECK, @"pack://application:,,,/Program;component/Resources/Images/green-check-mark.png" },
{Images.FAIL_CHECK, @"pack://application:,,,/Program;component/Resources/Images/red-cross-mark.png" }
};
#region Data Bindings
public ObservableCollection<ImpedanceDataModel> _listviewImpedanceDatatems { get; set; }
#endregion Data Bindings
public ImpedanceCheckWindowViewModel(Window window)
{
_window = window;
_listviewImpedanceDatatems = new ObservableCollection<ImpedanceDataModel>();
}
public void AddData(ImpedanceDataModel item)
{
_window.Dispatcher.Invoke((Action)delegate
{
_listviewImpedanceDatatems.Add(item);
});
}
public void ClearData()
{
_window.Dispatcher.Invoke((Action)delegate
{
_listviewImpedanceDatatems.Clear();
});
}
}
}

View File

@@ -0,0 +1,84 @@
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);
}
});
}
}
}