using CommunityToolkit.Mvvm.ComponentModel;
using GenericWpfApp.Model;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GenericWpfApp.ViewModel
{
   public partial class MainWindowViewModel : ObservableObject
   {
      public enum Images
      {
         LED_ON,
         LED_OFF
      }

      public Dictionary<Images, string> _imageToResourcePathDict = new Dictionary<Images, string>()
      {
         {Images.LED_ON, @"/Resources/Images/green-led.png" },
         {Images.LED_OFF, @"/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() 
      { 
         _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)
      {
         foreach (var item in rowNumberToPassthroughDataDict)
         {
            _dataGridPassthroughDatatems.Add(item.Value);
         }
      }
   }
}
