/*------------------------------------------------------------------------- // 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 { /// /// Passthrough Data model used for data binding /// 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 _variableEnumToVariableInfoDict = new Dictionary(); // this dictionary stores variable and its corresponding data model private Dictionary> _rowNumberToPassthroughDataDict = new Dictionary>(); 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(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; } } /// /// Get data model dictionary /// public Dictionary> GetPassthroughDataModelDict() { return _rowNumberToPassthroughDataDict; } /// /// Set value for a variable /// 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; } /// /// Blank all data for every variable /// public void BlankAllData() { foreach (KeyValuePair> item in _rowNumberToPassthroughDataDict) { for (int i = 0; i < item.Value.Count; i++) { item.Value[i] = ""; } } } } }