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 class ImpedanceCheckWindowViewModel : ObservableObject { private Window _window; public enum Images { PASS_CHECK, FAIL_CHECK } public Dictionary ImageToResourcePathDict { get { return _imageToResourcePathDict; } private set { } } private Dictionary _imageToResourcePathDict; #region Data Bindings public ObservableCollection _listviewImpedanceDataItems { get; set; } #endregion Data Bindings public ImpedanceCheckWindowViewModel(Window window) { _window = window; _listviewImpedanceDataItems = new ObservableCollection(); _imageToResourcePathDict = new Dictionary() { {Images.PASS_CHECK, @$"pack://application:,,,/{GetType().Assembly.GetName().Name};component/Resources/Images/green-check-mark.png" }, {Images.FAIL_CHECK, @$"pack://application:,,,/{GetType().Assembly.GetName().Name};component/Resources/Images/red-cross-mark.png" } }; } public void AddData(ImpedanceDataModel item) { _window.Dispatcher.Invoke((Action)delegate { _listviewImpedanceDataItems.Add(item); }); } public void ClearData() { _window.Dispatcher.Invoke((Action)delegate { _listviewImpedanceDataItems.Clear(); }); } } }