-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathByteDetails.cs
62 lines (50 loc) · 1.64 KB
/
ByteDetails.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace EntropyGlance
{
public partial class ByteDetails : Form
{
private DataEntropyUTF8 currentEntropy;
public ByteDetails(DataEntropyUTF8 entropy)
{
InitializeComponent();
currentEntropy = entropy;
}
private void ByteDetails_Shown(object sender, EventArgs e)
{
int counter = 1;
List<Tuple<int, byte>> entryList = new List<Tuple<int, byte>>();
foreach (KeyValuePair<byte, int> entry in currentEntropy.DistributionDict)
{
entryList.Add(new Tuple<int, byte>(entry.Value, entry.Key));
}
entryList.Sort();
entryList.Reverse();
foreach (Tuple<int, byte> tup in entryList)
{
/*
Rank
DecimalValue
HexValue
Symbol
Count
Probability
*/
int decVal = (int)tup.Item2;
string hexVal = tup.Item2.ToString("X");
string symb = Encoding.UTF8.GetString(new byte[] { tup.Item2 });
int count = tup.Item1;
string prob = currentEntropy.ProbabilityDict[tup.Item2].ToString("##0.######");
dataGridView1.Rows.Add(counter, decVal, hexVal, symb, count, prob);
counter++;
}
}
}
}