public void CheckSpectralTableisValidWithValidExampleDataTest() { //Arrange SpectralTableBlock spectralTableBlock = new SpectralTableBlock(); using (BinaryReader reader = new BinaryReader(Helpers.GetExampleSpectralTableMemoryStream())) { Helpers.ReadSpectralTableBlock(reader, 3, ref spectralTableBlock); } var expected = true; //Act var result = spectralTableBlock.CheckSpectralTableisValid(); //Assert Assert.AreEqual(expected, result); }
private void SetSpectralTablesTab(SpectralTableBlock spectralTables) { for (int i = 0; i < spectralTables.SpectralTables.Count; i++) { flowLayoutSpectralTable.Controls.Clear(); DataGridView dg = new DataGridView(); dg.Size = new Size(220, 350); dg.Name = "SpectralTable" + (_DataGridViewisAddedCount + 1).ToString(); dg.Columns.Add("Wavelength", "Wavelength"); dg.Columns.Add("Weight", "Relative Weight"); for (int j = 0; j < spectralTables.SpectralTables[i].Numberofpairs; j++) { int rowId = dg.Rows.Add(); DataGridViewRow row = dg.Rows[rowId]; SpectralDataPair spectralData = new SpectralDataPair(); row.Cells[0].Value = spectralTables.SpectralTables[i].Data[j].Wavelength; row.Cells[1].Value = spectralTables.SpectralTables[i].Data[j].RelativeWeight; } dg.Dock = DockStyle.Top; dg.BackgroundColor = Color.LightGray; dg.BorderStyle = BorderStyle.Fixed3D; dg.AllowUserToAddRows = false; dg.AllowUserToDeleteRows = false; dg.AllowUserToOrderColumns = true; dg.ReadOnly = true; dg.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dg.MultiSelect = false; dg.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None; dg.AllowUserToResizeColumns = false; dg.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; dg.AllowUserToResizeRows = false; dg.RowHeadersVisible = false; dg.BorderStyle = BorderStyle.None; dg.Columns[0].Width = 100; dg.Columns[1].Width = 100; flowLayoutSpectralTable.Controls.Add(dg); _CurrentDataGridViewName = dg.Name; _DataGridViewisAddedCount += 1; } }
public static void ReadSpectralTableBlock(BinaryReader reader, int numberOfTables, ref SpectralTableBlock spectralTableBlock) { int tableBlockSize = 0; spectralTableBlock.SpectralTables = new List <SpectralTable>(); for (int i = 0; i < numberOfTables; i++) { SpectralTable table = new SpectralTable(); table.Data = new List <SpectralData>(); table.Numberofpairs = reader.ReadInt32(); tableBlockSize += 4 * ((2 * table.Numberofpairs) + 1); for (int j = 0; j < table.Numberofpairs; j++) { SpectralDataPair dataPair = new SpectralDataPair(); dataPair.Wavelength = reader.ReadSingle(); dataPair.RelativeWeight = reader.ReadSingle(); table.Data.Add(dataPair); } spectralTableBlock.SpectralTables.Add(table); } if (tableBlockSize % 32 != 0) { int numberToPad = (((tableBlockSize / 32) + 1) * 32 - tableBlockSize) / 4; for (int i = 0; i < numberToPad; i++) { reader.ReadSingle(); spectralTableBlock.SpectralTables[numberOfTables - 1].Data.Add(new SpectralPadding()); } } }