/[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 249 - (show annotations) (download)
Sun Jun 3 16:09:05 2012 UTC (8 years, 6 months ago) by william
File size: 2280 byte(s)
change address from uint to int

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 int 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, int BaseAddress) : this() { byte_data = data; base_address = BaseAddress; }
32
33 private void ByteEditor_Load(object sender, EventArgs e)
34 {
35 uint max_ram_view = (uint)byte_data.Length;
36 //for (uint i = 0; i < byte_data.Length; i += max_address_width) { max_ram_view += max_address_width; }
37 for (int i = base_address; i < (base_address + max_ram_view); i += max_address_width)
38 {
39 txtAddresses.Text = txtAddresses.Text + string.Format("{0:X8}:\n", i);
40 }
41
42 DynamicByteProvider _DynamicByteProvider = new DynamicByteProvider(byte_data);
43 txtData.ByteProvider = _DynamicByteProvider;
44 }
45 public byte[] AsBytes { get { return (txtData.ByteProvider as DynamicByteProvider).Bytes.ToArray(); } }
46
47 private bool _BytesEdited;
48 public bool BytesEdited { get { return _BytesEdited; } set { _BytesEdited = value; } }
49
50 private void btnSave_Click(object sender, EventArgs e)
51 {
52 this.BytesEdited = true;
53 this.Close();
54 }
55
56 private void btnCancel_Click(object sender, EventArgs e)
57 {
58 this.BytesEdited = false;
59 this.Close();
60 }
61 }
62 }

  ViewVC Help
Powered by ViewVC 1.1.22