using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Be.Windows.Forms; namespace RomCheater.Docking.UI { public partial class ByteEditor : Form { private const uint max_address_width = 16; private byte[] byte_data = new byte[] { }; private uint base_address = 0; public ByteEditor() { InitializeComponent(); txtData.BytesPerLine = (int)max_address_width; txtData.UseFixedBytesPerLine = true; txtData.StringViewVisible = true; //txtData.LineInfoVisible = true; lblAddressMarker.Text = ""; for (uint i = 0; i < max_address_width; i++) { lblAddressMarker.Text = lblAddressMarker.Text + string.Format("{0:X2} ", i); } } public ByteEditor(byte[] data, uint BaseAddress) : this() { byte_data = data; base_address = BaseAddress; } private void ByteEditor_Load(object sender, EventArgs e) { uint max_ram_view = (uint)byte_data.Length; //for (uint i = 0; i < byte_data.Length; i += max_address_width) { max_ram_view += max_address_width; } for (uint i = base_address; i < (base_address + max_ram_view); i += max_address_width) { txtAddresses.Text = txtAddresses.Text + string.Format("{0:X8}:\n", i); } DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(byte_data); txtData.ByteProvider = _DynamicByteProvider; } public byte[] AsBytes { get { return (txtData.ByteProvider as DynamicByteProvider).Bytes.ToArray(); } } private bool _BytesEdited; public bool BytesEdited { get { return _BytesEdited; } set { _BytesEdited = value; } } private void btnSave_Click(object sender, EventArgs e) { this.BytesEdited = true; this.Close(); } private void btnCancel_Click(object sender, EventArgs e) { this.BytesEdited = false; this.Close(); } } }