public void ByteViewer_SetDisplayMode_InvokeWithBytesWithHandle_GetReturnsExpected(DisplayMode value, int expectedInvalidatedCallCount1, int expectedInvalidatedCallCount2) { using var control = new ByteViewer(); control.SetBytes(new byte[] { 1, 2, 3 }); Assert.NotEqual(IntPtr.Zero, control.Handle); int invalidatedCallCount = 0; control.Invalidated += (sender, e) => invalidatedCallCount++; int styleChangedCallCount = 0; control.StyleChanged += (sender, e) => styleChangedCallCount++; int createdCallCount = 0; control.HandleCreated += (sender, e) => createdCallCount++; control.SetDisplayMode(value); Assert.Equal(value, control.GetDisplayMode()); Assert.True(control.IsHandleCreated); Assert.Equal(expectedInvalidatedCallCount1, invalidatedCallCount); Assert.Equal(0, styleChangedCallCount); Assert.Equal(0, createdCallCount); // Set same. control.SetDisplayMode(value); Assert.Equal(value, control.GetDisplayMode()); Assert.True(control.IsHandleCreated); Assert.Equal(expectedInvalidatedCallCount2, invalidatedCallCount); Assert.Equal(0, styleChangedCallCount); Assert.Equal(0, createdCallCount); }
public void ByteViewer_SetDisplayMode_InvokeNoBytes_ThrowsNullReferenceException(DisplayMode value) { using var control = new ByteViewer(); Assert.Throws <NullReferenceException>(() => control.SetDisplayMode(value)); Assert.Equal(value, control.GetDisplayMode()); Assert.False(control.IsHandleCreated); // Set same. Assert.Throws <NullReferenceException>(() => control.SetDisplayMode(value)); Assert.Equal(value, control.GetDisplayMode()); Assert.False(control.IsHandleCreated); }
public void ByteViewer_SetDisplayMode_InvokeNoBytes_GetReturnsExpected(DisplayMode value) { using var control = new ByteViewer(); control.SetDisplayMode(value); Assert.Equal(value, control.GetDisplayMode()); Assert.False(control.IsHandleCreated); // Set same. control.SetDisplayMode(value); Assert.Equal(value, control.GetDisplayMode()); Assert.False(control.IsHandleCreated); }
// Changes the display mode of the byte viewer according to the // Text property of the RadioButton sender control. private void changeByteMode(object sender, EventArgs e) { System.Windows.Forms.RadioButton rbutton = (System.Windows.Forms.RadioButton)sender; DisplayMode mode; switch (rbutton.Text) { case "ANSI": mode = DisplayMode.Ansi; break; case "Hex": mode = DisplayMode.Hexdump; break; case "Unicode": mode = DisplayMode.Unicode; break; default: mode = DisplayMode.Auto; break; } // Sets the display mode. byteviewer.SetDisplayMode(mode); }
public HexViewer(string filename) { InitializeComponent(); ByteViewer bv = new ByteViewer(); bv.SetFile(filename); bv.Dock = DockStyle.Fill; bv.SetDisplayMode(DisplayMode.Hexdump); Controls.Add(bv); }
//TODO fix this. public override void Load(FileInfo file) { ByteViewer viewer = new ByteViewer(); viewer.Dock = DockStyle.Fill; viewer.SetFile(file.FullName); viewer.BackColor = Color.White; viewer.ForeColor = Color.Black; viewer.SetDisplayMode(DisplayMode.Hexdump); Controls.Add(viewer); }
private void btn_openfile_Click(object sender, EventArgs e) { byte[] buffer = new byte[40]; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { label_openfilepath.Text = openFileDialog.FileName; openfile(openFileDialog.FileName); bv.SetFile(openFileDialog.FileName); bv.SetDisplayMode(DisplayMode.Auto); //bv.SetRow(10); } }
public HexEditorControl(byte[] data) { InitializeComponent(); var byteviewer = new ByteViewer(); byteviewer.Dock = DockStyle.Fill; byteviewer.SetBytes(data); byteviewer.SetDisplayMode(DisplayMode.Hexdump); Controls.Add(byteviewer); }
public void ByteViewer_SetDisplayMode_UnicodeWithBytes_EditReturnsExpected(byte[] bytes, string expected) { using var control = new ByteViewer(); control.SetBytes(bytes); control.SetDisplayMode(DisplayMode.Unicode); TextBox textBox = control.Controls.OfType <TextBox>().Single(); ScrollBar scrollBar = control.Controls.OfType <ScrollBar>().Single(); Assert.Equal(expected, textBox.Text); Assert.True(textBox.Visible); Assert.False(scrollBar.Visible); Assert.False(control.IsHandleCreated); // Set different. control.SetBytes(new byte[] { (byte)'1', 0, (byte)'2', 0, (byte)'3', 0 }); Assert.Equal("123", textBox.Text); Assert.True(textBox.Visible); Assert.False(scrollBar.Visible); Assert.False(control.IsHandleCreated); }
public HexEditorControl(DefaultRepresentation data) { _data = data; InitializeComponent(); var byteviewer = new ByteViewer(); byteviewer.Dock = DockStyle.Fill; if (data.Blob == null) { byteviewer.SetBytes(new byte[] {}); } else { byteviewer.SetBytes(data.Blob); } byteviewer.SetDisplayMode(DisplayMode.Hexdump); Controls.Add(byteviewer); }
public void ByteViewer_SetDisplayMode_InvokeInvalidMode_ThrowsInvalidEnumArgumentException(DisplayMode value) { using var control = new ByteViewer(); Assert.Throws <InvalidEnumArgumentException>("mode", () => control.SetDisplayMode(value)); }