private void UpdateDisplay(bool force) { if (!tsbViewUpdate.Checked && !force) { return; } if (_cdl == null) { lvCDL.BeginUpdate(); if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) { lvCDL.Items.Clear(); } else { // this is a winforms implementation problem for mono // see https://github.com/mono/mono/issues/11070 // until this is resolved in mono we should just skip this call } lvCDL.EndUpdate(); return; } lvCDL.BeginUpdate(); listContents = new string[_cdl.Count][]; int idx = 0; foreach (var kvp in _cdl) { int[] totals = new int[8]; int total = 0; unsafe { int *map = stackalloc int[256]; for (int i = 0; i < 256; i++) map[i] = 0; fixed(byte *data = kvp.Value) { byte *src = data; byte *end = data + kvp.Value.Length; while (src < end) { byte s = *src++; map[s]++; } } for (int i = 0; i < 256; i++) { if (i != 0) { total += map[i]; } if ((i & 0x01) != 0) { totals[0] += map[i]; } if ((i & 0x02) != 0) { totals[1] += map[i]; } if ((i & 0x04) != 0) { totals[2] += map[i]; } if ((i & 0x08) != 0) { totals[3] += map[i]; } if ((i & 0x10) != 0) { totals[4] += map[i]; } if ((i & 0x20) != 0) { totals[5] += map[i]; } if ((i & 0x40) != 0) { totals[6] += map[i]; } if ((i & 0x80) != 0) { totals[7] += map[i]; } } } var bm = _cdl.GetBlockMap(); long addr = bm[kvp.Key]; var lvi = listContents[idx++] = new string[13]; lvi[0] = $"{addr:X8}"; lvi[1] = kvp.Key; lvi[2] = $"{total / (float)kvp.Value.Length * 100f:0.00}%"; if (tsbViewStyle.SelectedIndex == 2) { lvi[3] = $"{total / 1024.0f:0.00}"; } else { lvi[3] = $"{total}"; } if (tsbViewStyle.SelectedIndex == 2) { int n = (int)(kvp.Value.Length / 1024.0f); float ncheck = kvp.Value.Length / 1024.0f; lvi[4] = $"of {(n == ncheck ? "" : "~")}{n} KBytes"; } else { lvi[4] = $"of {kvp.Value.Length} Bytes"; } for (int i = 0; i < 8; i++) { if (tsbViewStyle.SelectedIndex == 0) { lvi[5 + i] = $"{totals[i] / (float)kvp.Value.Length * 100f:0.00}%"; } if (tsbViewStyle.SelectedIndex == 1) { lvi[5 + i] = $"{totals[i]}"; } if (tsbViewStyle.SelectedIndex == 2) { lvi[5 + i] = $"{totals[i] / 1024.0f:0.00}"; } } } lvCDL.VirtualListSize = _cdl.Count; lvCDL.EndUpdate(); }
private void UpdateDisplay(bool force) { if (!tsbViewUpdate.Checked && !force) { return; } if (_cdl == null) { lvCDL.BeginUpdate(); lvCDL.Items.Clear(); lvCDL.EndUpdate(); return; } lvCDL.BeginUpdate(); listContents = new string[_cdl.Count][]; int idx = 0; foreach (var kvp in _cdl) { int[] totals = new int[8]; int total = 0; unsafe { int *map = stackalloc int[256]; for (int i = 0; i < 256; i++) map[i] = 0; fixed(byte *data = kvp.Value) { byte *src = data; byte *end = data + kvp.Value.Length; while (src < end) { byte s = *src++; map[s]++; } } for (int i = 0; i < 256; i++) { if (i != 0) { total += map[i]; } if ((i & 0x01) != 0) { totals[0] += map[i]; } if ((i & 0x02) != 0) { totals[1] += map[i]; } if ((i & 0x04) != 0) { totals[2] += map[i]; } if ((i & 0x08) != 0) { totals[3] += map[i]; } if ((i & 0x10) != 0) { totals[4] += map[i]; } if ((i & 0x20) != 0) { totals[5] += map[i]; } if ((i & 0x40) != 0) { totals[6] += map[i]; } if ((i & 0x80) != 0) { totals[7] += map[i]; } } } var bm = _cdl.GetBlockMap(); long addr = bm[kvp.Key]; var lvi = listContents[idx++] = new string[13]; lvi[0] = string.Format("{0:X8}", addr); lvi[1] = kvp.Key; lvi[2] = string.Format("{0:0.00}%", total / (float)kvp.Value.Length * 100f); if (tsbViewStyle.SelectedIndex == 2) { lvi[3] = string.Format("{0:0.00}", total / 1024.0f); } else { lvi[3] = string.Format("{0}", total); } if (tsbViewStyle.SelectedIndex == 2) { int n = (int)(kvp.Value.Length / 1024.0f); float ncheck = kvp.Value.Length / 1024.0f; lvi[4] = string.Format("of {0}{1} KBytes", n == ncheck ? "" : "~", n); } else { lvi[4] = string.Format("of {0} Bytes", kvp.Value.Length); } for (int i = 0; i < 8; i++) { if (tsbViewStyle.SelectedIndex == 0) { lvi[5 + i] = string.Format("{0:0.00}%", totals[i] / (float)kvp.Value.Length * 100f); } if (tsbViewStyle.SelectedIndex == 1) { lvi[5 + i] = string.Format("{0}", totals[i]); } if (tsbViewStyle.SelectedIndex == 2) { lvi[5 + i] = string.Format("{0:0.00}", totals[i] / 1024.0f); } } } lvCDL.VirtualListSize = _cdl.Count; lvCDL.EndUpdate(); }
private void UpdateDisplay(bool force) { if (!tsbViewUpdate.Checked && !force) { return; } if (_cdl == null) { lvCDL.DeselectAll(); return; } listContents = new string[_cdl.Count][]; int idx = 0; foreach (var kvp in _cdl) { int[] totals = new int[8]; int total = 0; unsafe { int *map = stackalloc int[256]; for (int i = 0; i < 256; i++) map[i] = 0; fixed(byte *data = kvp.Value) { byte *src = data; byte *end = data + kvp.Value.Length; while (src < end) { byte s = *src++; map[s]++; } } for (int i = 0; i < 256; i++) { if (i != 0) { total += map[i]; } if ((i & 0x01) != 0) { totals[0] += map[i]; } if ((i & 0x02) != 0) { totals[1] += map[i]; } if ((i & 0x04) != 0) { totals[2] += map[i]; } if ((i & 0x08) != 0) { totals[3] += map[i]; } if ((i & 0x10) != 0) { totals[4] += map[i]; } if ((i & 0x20) != 0) { totals[5] += map[i]; } if ((i & 0x40) != 0) { totals[6] += map[i]; } if ((i & 0x80) != 0) { totals[7] += map[i]; } } } var bm = _cdl.GetBlockMap(); long addr = bm[kvp.Key]; var lvi = listContents[idx++] = new string[13]; lvi[0] = $"{addr:X8}"; lvi[1] = kvp.Key; lvi[2] = $"{total / (float)kvp.Value.Length * 100f:0.00}%"; if (tsbViewStyle.SelectedIndex == 2) { lvi[3] = $"{total / 1024.0f:0.00}"; } else { lvi[3] = $"{total}"; } if (tsbViewStyle.SelectedIndex == 2) { int n = (int)(kvp.Value.Length / 1024.0f); float ncheck = kvp.Value.Length / 1024.0f; lvi[4] = $"of {(n == ncheck ? "" : "~")}{n} KBytes"; } else { lvi[4] = $"of {kvp.Value.Length} Bytes"; } for (int i = 0; i < 8; i++) { if (tsbViewStyle.SelectedIndex == 0) { lvi[5 + i] = $"{totals[i] / (float)kvp.Value.Length * 100f:0.00}%"; } if (tsbViewStyle.SelectedIndex == 1) { lvi[5 + i] = $"{totals[i]}"; } if (tsbViewStyle.SelectedIndex == 2) { lvi[5 + i] = $"{totals[i] / 1024.0f:0.00}"; } } } lvCDL.RowCount = _cdl.Count; }