Big changes
This commit is contained in:
63
Source/Program/GUI/Model/PassthroughData.cs
Normal file
63
Source/Program/GUI/Model/PassthroughData.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
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.Model
|
||||
{
|
||||
internal partial class PassthroughData
|
||||
{
|
||||
private int _datagridColumnCount = 0;
|
||||
// this dictionary stores variable and the info needed to locate it in the passthroughdatamodel dictionary which contains a 2-d array
|
||||
private Dictionary<Variables, VariableInfo> _variableEnumToVariableInfoDict = new Dictionary<Variables, VariableInfo>();
|
||||
|
||||
// this dictionary stores variable and its corresponding data model
|
||||
private Dictionary<int, ObservableCollection<string>> _rowNumberToPassthroughDataDict = new Dictionary<int, ObservableCollection<string>>();
|
||||
|
||||
public PassthroughData(int datagridColumnCount)
|
||||
{
|
||||
_datagridColumnCount = datagridColumnCount;
|
||||
VariableInfo variableInfo = new VariableInfo();
|
||||
|
||||
int dictIndex = 0;
|
||||
int colIndex = 0;
|
||||
// contruct a 2-d array of strings based on the list of Variables
|
||||
foreach (Variables enumVar in Enum.GetValues(typeof(Variables)))
|
||||
{
|
||||
if (_rowNumberToPassthroughDataDict.Count == 0 || colIndex == _datagridColumnCount)
|
||||
{
|
||||
dictIndex++;
|
||||
_rowNumberToPassthroughDataDict[dictIndex] = new ObservableCollection<string>(new string[_datagridColumnCount]);
|
||||
colIndex = 0;
|
||||
}
|
||||
|
||||
// name of the variable
|
||||
_rowNumberToPassthroughDataDict[dictIndex][colIndex] = String.Empty;
|
||||
variableInfo.passthroughDataModelItemIndex = colIndex++;
|
||||
|
||||
// value of the variable
|
||||
_rowNumberToPassthroughDataDict[dictIndex][colIndex++] = String.Empty;
|
||||
|
||||
// save the row index so we can refer to this item
|
||||
variableInfo.passthroughDataModelDictIndex = dictIndex;
|
||||
|
||||
// save the column index of this item so we can refer to this item
|
||||
_variableEnumToVariableInfoDict[enumVar] = variableInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<int, ObservableCollection<string>> GetPassthroughDataModelDict()
|
||||
{
|
||||
return _rowNumberToPassthroughDataDict;
|
||||
}
|
||||
|
||||
public void SetValue(Variables variableName, string val)
|
||||
{
|
||||
_rowNumberToPassthroughDataDict[_variableEnumToVariableInfoDict[variableName].passthroughDataModelDictIndex][_variableEnumToVariableInfoDict[variableName].passthroughDataModelItemIndex] = _variableEnumToDescriptionDict[variableName];
|
||||
_rowNumberToPassthroughDataDict[_variableEnumToVariableInfoDict[variableName].passthroughDataModelDictIndex][_variableEnumToVariableInfoDict[variableName].passthroughDataModelItemIndex + 1] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user