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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 892 - (show annotations) (download)
Wed Sep 17 05:56:41 2014 UTC (6 years, 10 months ago) by william
File size: 5288 byte(s)
+ alot of dang work to force an icon to be shown on the docked panels
  ** when it was as simple as setting: DockPanel.ShowDocumentIcon to true

1 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.Interfaces;
11
12 namespace RomCheater.Core.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.AcceptedPlugin = pconfig.AcceptedPlugin;
31 this.AcceptedProcess = pconfig.AcceptedProcess;
32 Unsigned = true;
33 DataType = SearchDataTypes._8bits;
34 txtStartAddress.Text = string.Format("0x{0:x8}", 0);
35 txtEndAddress.Text = string.Format("0x{0:x8}", 0);
36 this.AddedPatchValue = new List<ResultDataType>();
37 txtStartAddress.MaxLength = sizeof(uint) * 2 + 2;
38 txtEndAddress.MaxLength = sizeof(uint) * 2 + 2;
39 }
40
41 private void PatchRangeAdder_Load(object sender, EventArgs e)
42 {
43 foreach (int val in Enum.GetValues(typeof(SearchDataTypes)))
44 {
45 comboDataBitSize.Items.Add(val);
46 }
47 comboDataBitSize.SelectedIndex = 0;
48 comboDataBitSize.Text = comboDataBitSize.Items[comboDataBitSize.SelectedIndex].ToString();
49 txtStartAddress.ReadOnly = false;
50 txtEndAddress.ReadOnly = false;
51 txtStartAddress.Text = "";
52 txtEndAddress.Text = "";
53 }
54
55 private void btnOK_Click(object sender, EventArgs e)
56 {
57 uint StartAddress = txtStartAddress.ToUInt32();
58 uint EndAddress = txtEndAddress.ToUInt32();
59 uint BIT_SIZE = ((uint)DataType) / 8;
60
61 //if (!(ramdumper.VTLB_VADDR_MIN <= StartAddress && StartAddress < ramdumper.VTLB_VADDR_MAX || ramdumper.VTLB_VADDR_MIN <= EndAddress && EndAddress < ramdumper.VTLB_VADDR_MAX))
62 //{
63 // 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);
64 // txtStartAddress.Text = "";
65 // txtEndAddress.Text = "";
66 // return;
67 //}
68
69
70 //if (!(ramdumper.VTLB_VADDR_MIN <= StartAddress && StartAddress < ramdumper.VTLB_VADDR_MAX))
71 //{
72 // 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);
73 // txtStartAddress.Text = "";
74 // return;
75 //}
76
77
78 //if (!(ramdumper.VTLB_VADDR_MIN <= EndAddress && EndAddress < ramdumper.VTLB_VADDR_MAX))
79 //{
80 // 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);
81 // txtEndAddress.Text = "";
82 // return;
83 //}
84
85 for (uint i = StartAddress; i <= EndAddress; i += BIT_SIZE)
86 {
87
88 ResultItemState _result_state = new ResultItemState(string.Format("0x{0:x8}", i), DataType, Unsigned, (IAcceptsProcessAndConfig)this);
89 ResultDataType _result = _result_state;
90 this.AddedPatchValue.Add(_result);
91 }
92 this.Close();
93 }
94
95 private void btnCancel_Click(object sender, EventArgs e)
96 {
97 this.Close();
98 }
99
100 public bool WasAPatchAdded
101 {
102 get { return (this.AddedPatchValue.Count > 0); }
103 }
104 private List<ResultDataType> _AddedPatchValue;
105 public List<ResultDataType> AddedPatchValue
106 {
107 get { return _AddedPatchValue; }
108 private set { _AddedPatchValue = value; }
109 }
110
111 private void comboDataBitSize_SelectedIndexChanged(object sender, EventArgs e)
112 {
113 int selected_index = comboDataBitSize.SelectedIndex;
114 int bit_size = -1;
115
116 bit_size = Convert.ToInt32(comboDataBitSize.Items[comboDataBitSize.SelectedIndex]);
117 txtStartAddress.CreateTypeSize<ulong>();
118 txtEndAddress.CreateTypeSize<ulong>();
119 this.DataType = (SearchDataTypes)bit_size;
120 }
121
122 private void PatchRangeAdder_KeyDown(object sender, KeyEventArgs e)
123 {
124 if (e.KeyCode == Keys.Enter) btnOK.PerformClick();
125 }
126 }
127 }
128

  ViewVC Help
Powered by ViewVC 1.1.22