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

Contents of /trunk/RomCheater.Core/Docking/MemorySearch/SearchRangePatcher.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: 4483 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 using RomCheater.Logging;
9 using System.Diagnostics;
10 using Sojaner.MemoryScanner.MemoryProviers;
11
12 using RomCheater.Interfaces;
13
14
15 namespace RomCheater.Core.Docking.MemorySearch
16 {
17 public partial class SearchRangePatcher : Form,
18 IAcceptsPlugin<IConfigPlugin>,
19 IAcceptsProcess<Process>,
20 IAcceptsProcessAndConfig
21 {
22 #region IAcceptsProcess<Process> Members
23 public Process AcceptedProcess { get; set; }
24 #endregion
25 #region IAcceptsPlugin<IConfigPlugin> Members
26 public IConfigPlugin AcceptedPlugin { get; set; }
27 #endregion
28 //PCSX2MemoryProvider provider;
29 //SearchDataTypes DataType;
30 //bool Unsigned = false;
31 private List<ResultDataType> PatchList;
32 public SearchRangePatcher(IAcceptsProcessAndConfig pconfig ,List<ResultDataType> patchList)
33 {
34 InitializeComponent();
35 this.AcceptedPlugin = pconfig.AcceptedPlugin;
36 this.AcceptedProcess = pconfig.AcceptedProcess;
37 PatchList = patchList;
38 int CurrentBitSize = 0;
39 // get the larget datatype
40 foreach (ResultDataType patch in PatchList)
41 {
42 if ((int)patch.ValueType > CurrentBitSize)
43 {
44 CurrentBitSize = (int)patch.ValueType;
45 }
46 }
47 switch (CurrentBitSize)
48 {
49 case (int)SearchDataTypes._8bits: txtValue.CreateTypeSize<byte>(); break;
50 case (int)SearchDataTypes._16bits: txtValue.CreateTypeSize<ushort>(); break;
51 case (int)SearchDataTypes._32bits: txtValue.CreateTypeSize<uint>(); break;
52 case (int)SearchDataTypes._64bits: txtValue.CreateTypeSize<ulong>(); break;
53 }
54
55 }
56
57 private void SearchPatcher_Load(object sender, EventArgs e)
58 {
59 txtValue.ReadOnly = false;
60 }
61 private void btnCancel_Click(object sender, EventArgs e)
62 {
63 this.Close();
64 }
65 private void btnOK_Click(object sender, EventArgs e)
66 {
67 using (GenericMemoryProvider provider = new GenericMemoryProvider((IAcceptsProcessAndConfig)this))
68 {
69 provider.OpenProvider();
70 foreach (ResultDataType patch in PatchList)
71 {
72 switch (patch.ValueType)
73 {
74 case SearchDataTypes._8bits:
75 if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (byte)txtValue.Value); }
76 else { provider.PatchMemory(patch.Address, (sbyte)txtValue.Value); }
77 break;
78 case SearchDataTypes._16bits:
79 if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (ushort)txtValue.Value); }
80 else { provider.PatchMemory(patch.Address, (short)txtValue.Value); }
81 break;
82 case SearchDataTypes._32bits:
83 if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (uint)txtValue.Value); }
84 else { provider.PatchMemory(patch.Address, (int)txtValue.Value); }
85 break;
86 case SearchDataTypes._64bits:
87 if (patch.IsUnsigned) { provider.PatchMemory(patch.Address, (ulong)txtValue.Value); }
88 else { provider.PatchMemory(patch.Address, (long)txtValue.Value); }
89 break;
90 }
91 }
92 provider.CloseProvider();
93 }
94 this.Close();
95 }
96
97 private void CopyToClipboard(string data)
98 {
99 Clipboard.SetData(DataFormats.Text, data);
100 }
101
102 private void btnCopyvaluetoClipboard_Click(object sender, EventArgs e)
103 {
104 this.CopyToClipboard(txtValue.Text);
105 }
106
107 private void SearchPatcher_KeyDown(object sender, KeyEventArgs e)
108 {
109 if (e.KeyCode == Keys.Enter) btnOK.PerformClick();
110 }
111 }
112 }

  ViewVC Help
Powered by ViewVC 1.1.22