ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater/Docking/UI/ByteEditor.cs
Revision: 198
Committed: Thu May 31 07:13:43 2012 UTC (11 years ago) by william
File size: 2284 byte(s)
Log Message:
+ initial support for memoryview and getting ram from process for display

File Contents

# Content
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 uint max_address_width = 16;
16 private byte[] byte_data = new byte[] { };
17 private uint 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
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 (uint 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 }