Initial check-in
This commit is contained in:
53
Source/ProgramGUI/ViewModel/ImpedanceCheckWindowViewModel.cs
Normal file
53
Source/ProgramGUI/ViewModel/ImpedanceCheckWindowViewModel.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using ProgramGui.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace ProgramGui.ViewModel
|
||||
{
|
||||
public class ImpedanceCheckWindowViewModel : ObservableObject
|
||||
{
|
||||
private Window _window;
|
||||
public enum Images
|
||||
{
|
||||
PASS_CHECK,
|
||||
FAIL_CHECK
|
||||
}
|
||||
|
||||
public Dictionary<Images, string> _imageToResourcePathDict = new Dictionary<Images, string>()
|
||||
{
|
||||
{Images.PASS_CHECK, @"pack://application:,,,/ProgramGui;component/Resources/Images/green-check-mark.png" },
|
||||
{Images.FAIL_CHECK, @"pack://application:,,,/ProgramGui;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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
74
Source/ProgramGUI/ViewModel/MainWindowViewModel.cs
Normal file
74
Source/ProgramGUI/ViewModel/MainWindowViewModel.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using ProgramGui.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 ProgramGui.ViewModel
|
||||
{
|
||||
public partial class MainWindowViewModel : ObservableObject
|
||||
{
|
||||
public enum Images
|
||||
{
|
||||
LED_ON,
|
||||
LED_OFF
|
||||
}
|
||||
|
||||
private Window _window;
|
||||
|
||||
public 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 MainWindowViewModel(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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user