public static void AddHighLights(this HexViewer hexView, List <Tuple <uint, uint> > ranges, Color colorA, Color colorB) { var currentColor = Color.Empty; foreach (var range in ranges) { currentColor = (currentColor == colorA ? colorB : colorA); hexView.AddHighLight(new HexViewer.HighLight(currentColor, range.Item1, range.Item2)); } }
protected override void OnModelUpdated() { gridView.Clear(); if (Model != null) { hexView.ClearHighLight(); var tbls = Model.Stream; var ranges = new List <Tuple <uint, uint> >(); uint relBase = (uint)tbls.StartOffset; uint offset = 0; gridView.AddRow("Reserved1", ranges.IncrementOffset(relBase, ref offset, 4), tbls.Reserved1); gridView.AddRow("MajorVersion", ranges.IncrementOffset(relBase, ref offset, 1), (byte)(tbls.Version >> 8)); gridView.AddRow("MinorVersion", ranges.IncrementOffset(relBase, ref offset, 1), (byte)tbls.Version); gridView.AddRow("Flags", ranges.IncrementOffset(relBase, ref offset, 1), tbls.Flags); gridView.AddRow("Log2Rid", ranges.IncrementOffset(relBase, ref offset, 1), tbls.Log2Rid); gridView.AddRow("MaskValid", ranges.IncrementOffset(relBase, ref offset, 8), tbls.ValidMask); gridView.AddRow("MaskSorted", ranges.IncrementOffset(relBase, ref offset, 8), tbls.SortedMask); var rowSizeBegin = offset; var numTbls = Math.Min(Utils.GetNumOfSetBits(tbls.ValidMask), 0x3f); var rowSizeEnd = rowSizeBegin + numTbls * 4; hexView.AddHighLight(new HexViewer.HighLight(Color.Green, rowSizeBegin, rowSizeEnd)); if (tbls.HasExtraData) { gridView.AddRow("ExtraData (!)", ranges.IncrementOffset(relBase, ref rowSizeEnd, 4), tbls.ExtraData); } hexView.AddHighLights(ranges, Color.Red, Color.Blue); hexView.Stream = tbls.GetClonedImageStream(); } else { hexView.Stream = null; } }