/[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 838 - (show annotations) (download)
Tue Sep 16 00:57:18 2014 UTC (6 years ago) by william
File size: 2488 byte(s)
+ add an icon resource

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

  ViewVC Help
Powered by ViewVC 1.1.22