100 lines
4.1 KiB
C#
100 lines
4.1 KiB
C#
/*-------------------------------------------------------------------------
|
|
// UNCLASSIFIED
|
|
/*-------------------------------------------------------------------------
|
|
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
|
|
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
|
|
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
|
|
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
|
|
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
|
|
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
|
|
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
|
|
COMPANY.
|
|
|
|
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
|
|
GOVERNMENT.
|
|
|
|
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
|
|
-------------------------------------------------------------------------*/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
|
|
namespace ProgramLib.GUI.Model
|
|
{
|
|
/// <summary>
|
|
/// Passthrough Data model used for data binding
|
|
/// </summary>
|
|
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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get data model dictionary
|
|
/// </summary>
|
|
public Dictionary<int, ObservableCollection<string>> GetPassthroughDataModelDict()
|
|
{
|
|
return _rowNumberToPassthroughDataDict;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Set value for a variable
|
|
/// </summary>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Blank all data for every variable
|
|
/// </summary>
|
|
public void BlankAllData()
|
|
{
|
|
foreach (KeyValuePair<int, ObservableCollection<string>> item in _rowNumberToPassthroughDataDict)
|
|
{
|
|
for (int i = 0; i < item.Value.Count; i++)
|
|
{
|
|
item.Value[i] = "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|