/[RomCheater]/trunk/RomCheater/Docking/UI/ByteEditor.cs
ViewVC logotype

Contents of /trunk/RomCheater/Docking/UI/ByteEditor.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 576 - (show annotations) (download)
Thu Jun 6 07:49:01 2013 UTC (8 years, 3 months ago) by william
File size: 2420 byte(s)

1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Drawing;
6 using System.Linq;
7 using System.Text;
8 using System.Windows.Forms;
9 using Be.Windows.Forms;
10
11 namespace RomCheater.Docking.UI
12 {
13 public partial class ByteEditor : Form
14 {
15 private const int max_address_width = 16;
16 private byte[] byte_data = new byte[] { };
17 private ulong base_address = 0;
18 public ByteEditor()
19 {
20 InitializeComponent();
21 txtData.BytesPerLine = (int)max_address_width;
22 txtData.UseFixedBytesPerLine = true;
23 txtData.StringViewVisible = true;
24 //txtData.LineInfoVisible = true;
25 lblAddressMarker.Text = "";
26 for (uint i = 0; i < max_address_width; i++)
27 {
28 lblAddressMarker.Text = lblAddressMarker.Text + string.Format("{0:X2} ", i);
29 }
30 }
31 public ByteEditor(byte[] data, uint BaseAddress) : this() { byte_data = data; base_address = BaseAddress; }
32 public ByteEditor(byte[] data, ulong BaseAddress) : this() { byte_data = data; base_address = BaseAddress; }
33
34 private void ByteEditor_Load(object sender, EventArgs e)
35 {
36 uint max_ram_view = (uint)byte_data.Length;
37 //for (uint i = 0; i < byte_data.Length; i += max_address_width) { max_ram_view += max_address_width; }
38 for (ulong i = base_address; i < (base_address + max_ram_view); i += max_address_width)
39 {
40 txtAddresses.Text = txtAddresses.Text + string.Format("{0:X8}:\n", i);
41 }
42
43 DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(byte_data,true,false,false);
44 txtData.ByteProvider = _DynamicByteProvider;
45 }
46 public byte[] AsBytes { get { return (txtData.ByteProvider as DynamicByteProvider).Bytes.ToArray(); } }
47
48 private bool _BytesEdited;
49 public bool BytesEdited { get { return _BytesEdited; } set { _BytesEdited = value; } }
50
51 private void btnSave_Click(object sender, EventArgs e)
52 {
53 this.BytesEdited = true;
54 this.Close();
55 }
56
57 private void btnCancel_Click(object sender, EventArgs e)
58 {
59 this.BytesEdited = false;
60 this.Close();
61 }
62 }
63 }

  ViewVC Help
Powered by ViewVC 1.1.22