/[RomCheater]/trunk/RomCheater.Core/Docking/MemorySearch/PatchRangeAdder.cs
ViewVC logotype

Annotation of /trunk/RomCheater.Core/Docking/MemorySearch/PatchRangeAdder.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 885 - (hide annotations) (download)
Wed Sep 17 03:50:34 2014 UTC (7 years ago) by william
File size: 5345 byte(s)


1 william 885 using System;
2     using System.Collections.Generic;
3     using System.ComponentModel;
4     using System.Data;
5     using System.Drawing;
6     using System.Text;
7     using System.Windows.Forms;
8    
9     using System.Diagnostics;
10     using RomCheater.Core;
11    
12     namespace RomCheater.Docking.MemorySearch
13     {
14     public partial class PatchRangeAdder : Form,
15     IAcceptsPlugin<IConfigPlugin>,
16     IAcceptsProcess<Process>,
17     IAcceptsProcessAndConfig
18     {
19     #region IAcceptsProcess<Process> Members
20     public Process AcceptedProcess { get; set; }
21     #endregion
22     #region IAcceptsPlugin<IConfigPlugin> Members
23     public IConfigPlugin AcceptedPlugin { get; set; }
24     #endregion
25     SearchDataTypes DataType;
26     bool Unsigned = false;
27     public PatchRangeAdder(IAcceptsProcessAndConfig pconfig)
28     {
29     InitializeComponent();
30     this.Icon = Core.Properties.Resources.romcheater_icon;
31     this.AcceptedPlugin = pconfig.AcceptedPlugin;
32     this.AcceptedProcess = pconfig.AcceptedProcess;
33     Unsigned = true;
34     DataType = SearchDataTypes._8bits;
35     txtStartAddress.Text = string.Format("0x{0:x8}", 0);
36     txtEndAddress.Text = string.Format("0x{0:x8}", 0);
37     this.AddedPatchValue = new List<ResultDataType>();
38     txtStartAddress.MaxLength = sizeof(uint) * 2 + 2;
39     txtEndAddress.MaxLength = sizeof(uint) * 2 + 2;
40     }
41    
42     private void PatchRangeAdder_Load(object sender, EventArgs e)
43     {
44     foreach (int val in Enum.GetValues(typeof(SearchDataTypes)))
45     {
46     comboDataBitSize.Items.Add(val);
47     }
48     comboDataBitSize.SelectedIndex = 0;
49     comboDataBitSize.Text = comboDataBitSize.Items[comboDataBitSize.SelectedIndex].ToString();
50     txtStartAddress.ReadOnly = false;
51     txtEndAddress.ReadOnly = false;
52     txtStartAddress.Text = "";
53     txtEndAddress.Text = "";
54     }
55    
56     private void btnOK_Click(object sender, EventArgs e)
57     {
58     uint StartAddress = txtStartAddress.ToUInt32();
59     uint EndAddress = txtEndAddress.ToUInt32();
60     uint BIT_SIZE = ((uint)DataType) / 8;
61    
62     //if (!(ramdumper.VTLB_VADDR_MIN <= StartAddress && StartAddress < ramdumper.VTLB_VADDR_MAX || ramdumper.VTLB_VADDR_MIN <= EndAddress && EndAddress < ramdumper.VTLB_VADDR_MAX))
63     //{
64     // MessageBox.Show(string.Format("EE Ram requires the Starting and End Address to be between: 0x{0:x8} and 0x{1:x8}", ramdumper.VTLB_VADDR_MIN, ramdumper.VTLB_VADDR_MAX), "Address Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
65     // txtStartAddress.Text = "";
66     // txtEndAddress.Text = "";
67     // return;
68     //}
69    
70    
71     //if (!(ramdumper.VTLB_VADDR_MIN <= StartAddress && StartAddress < ramdumper.VTLB_VADDR_MAX))
72     //{
73     // MessageBox.Show(string.Format("EE Ram requires the Starting Address to be between: 0x{0:x8} and 0x{1:x8}", ramdumper.VTLB_VADDR_MIN, ramdumper.VTLB_VADDR_MAX), "Address Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
74     // txtStartAddress.Text = "";
75     // return;
76     //}
77    
78    
79     //if (!(ramdumper.VTLB_VADDR_MIN <= EndAddress && EndAddress < ramdumper.VTLB_VADDR_MAX))
80     //{
81     // MessageBox.Show(string.Format("EE Ram requires the Ending Address to be between: 0x{0:x8} and 0x{1:x8}", ramdumper.VTLB_VADDR_MIN, ramdumper.VTLB_VADDR_MAX), "Address Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
82     // txtEndAddress.Text = "";
83     // return;
84     //}
85    
86     for (uint i = StartAddress; i <= EndAddress; i += BIT_SIZE)
87     {
88    
89     ResultItemState _result_state = new ResultItemState(string.Format("0x{0:x8}", i), DataType, Unsigned, (IAcceptsProcessAndConfig)this);
90     ResultDataType _result = _result_state;
91     this.AddedPatchValue.Add(_result);
92     }
93     this.Close();
94     }
95    
96     private void btnCancel_Click(object sender, EventArgs e)
97     {
98     this.Close();
99     }
100    
101     public bool WasAPatchAdded
102     {
103     get { return (this.AddedPatchValue.Count > 0); }
104     }
105     private List<ResultDataType> _AddedPatchValue;
106     public List<ResultDataType> AddedPatchValue
107     {
108     get { return _AddedPatchValue; }
109     private set { _AddedPatchValue = value; }
110     }
111    
112     private void comboDataBitSize_SelectedIndexChanged(object sender, EventArgs e)
113     {
114     int selected_index = comboDataBitSize.SelectedIndex;
115     int bit_size = -1;
116    
117     bit_size = Convert.ToInt32(comboDataBitSize.Items[comboDataBitSize.SelectedIndex]);
118     txtStartAddress.CreateTypeSize<ulong>();
119     txtEndAddress.CreateTypeSize<ulong>();
120     this.DataType = (SearchDataTypes)bit_size;
121     }
122    
123     private void PatchRangeAdder_KeyDown(object sender, KeyEventArgs e)
124     {
125     if (e.KeyCode == Keys.Enter) btnOK.PerformClick();
126     }
127     }
128     }
129    

  ViewVC Help
Powered by ViewVC 1.1.22