/[RomCheater]/trunk/RomCheater/Docking/FloatingRamDumperDialog.cs
ViewVC logotype

Contents of /trunk/RomCheater/Docking/FloatingRamDumperDialog.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 154 - (show annotations) (download)
Mon May 28 03:04:05 2012 UTC (8 years, 7 months ago) by william
File size: 5497 byte(s)

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 WeifenLuo.WinFormsUI.Docking;
10 using RomCheater.PluginFramework.Interfaces;
11 using System.Diagnostics;
12
13 namespace RomCheater.Docking
14 {
15 public partial class FloatingRamDumperDialog : DockContent, IProcessConfig
16 {
17 #region sub-classes
18 private const int BYTE_CORRECTION_VALUE = 23;
19 public enum DumpSize
20 {
21 Bytes,
22 KiloBytes,
23 MegaBytes,
24 GigaBytes,
25 }
26 #endregion
27 private DumpSize dumpSize = DumpSize.Bytes;
28
29 public FloatingRamDumperDialog() { InitializeComponent(); this.AcceptedPlugin = null; this.AcceptedProcess = null; }
30 public FloatingRamDumperDialog(IConfigPlugin config) : this() { this.AcceptedPlugin = config; }
31 public FloatingRamDumperDialog(IConfigPlugin config, Process process) : this() { this.AcceptedPlugin = config; this.AcceptedProcess = process; }
32
33 private void FloatingRamDumperDialog_Load(object sender, EventArgs e)
34 {
35 txtStart.Value = 0;
36 txtEnd.Value = int.MaxValue;
37 }
38
39
40 #region IProcessConfig Members'
41 public Process AcceptedProcess { get; set; }
42 #endregion
43 #region IAcceptsPlugin<IConfigPlugin> Members
44 public IConfigPlugin AcceptedPlugin { get; set; }
45 #endregion
46
47 private void radioBTNBytes_CheckedChanged(object sender, EventArgs e)
48 {
49 dumpSize = DumpSize.Bytes;
50 }
51
52 private void radioBTNKiloBytes_CheckedChanged(object sender, EventArgs e)
53 {
54 dumpSize = DumpSize.KiloBytes;
55 }
56
57 private void radioBTNMegaBytes_CheckedChanged(object sender, EventArgs e)
58 {
59 dumpSize = DumpSize.MegaBytes;
60 }
61
62 private void radioBTNGigaBytes_CheckedChanged(object sender, EventArgs e)
63 {
64 dumpSize = DumpSize.GigaBytes;
65 }
66
67 private void btnCalcEndAddr_Click(object sender, EventArgs e)
68 {
69 ulong start = 0;
70 ulong end = 0;
71 start = txtStart.Value;
72 switch (dumpSize)
73 {
74 case DumpSize.Bytes:
75 end = (ulong)(Convert.ToDouble(txtDumpSize.Text) * 1.0 + start) - BYTE_CORRECTION_VALUE;
76 txtEnd.Value = end;
77 break;
78 case DumpSize.KiloBytes:
79 end = (ulong)(Convert.ToDouble(txtDumpSize.Text) * 1000.0 + start) - BYTE_CORRECTION_VALUE;
80 txtEnd.Value = end;
81 break;
82 case DumpSize.MegaBytes:
83 end = (ulong)(Convert.ToDouble(txtDumpSize.Text) * 1000000.0 + start) - BYTE_CORRECTION_VALUE;
84 txtEnd.Value = end;
85 break;
86 case DumpSize.GigaBytes:
87 end = (ulong)(Convert.ToDouble(txtDumpSize.Text) * 1000000000.0 + start) - BYTE_CORRECTION_VALUE;
88 txtEnd.Value = end;
89 break;
90 }
91 }
92
93 private void btnCalcStartAddr_Click(object sender, EventArgs e)
94 {
95 long start = 0;
96 long end = 0;
97 end = txtEnd.ToInt64();
98 switch (dumpSize)
99 {
100 case DumpSize.Bytes:
101 start = (long)((double)end - (Convert.ToDouble(txtDumpSize.Text) * 1.0)) + BYTE_CORRECTION_VALUE;
102 txtStart.Value = (ulong)start;;
103 break;
104 case DumpSize.KiloBytes:
105 start = (long)((double)end - (Convert.ToDouble(txtDumpSize.Text) * 1000.0)) + BYTE_CORRECTION_VALUE;
106 txtStart.Value = (ulong)start;;
107 break;
108 case DumpSize.MegaBytes:
109 start = (long)((double)end - (Convert.ToDouble(txtDumpSize.Text) * 1000000.0)) + BYTE_CORRECTION_VALUE;
110 txtStart.Value = (ulong)start;;
111 break;
112 case DumpSize.GigaBytes:
113 start = (long)((double)end - (Convert.ToDouble(txtDumpSize.Text) * 1000000000.0)) + BYTE_CORRECTION_VALUE;
114 txtStart.Value = (ulong)start;
115 break;
116 }
117 }
118
119 private void btnCalcDumpSize_Click(object sender, EventArgs e)
120 {
121 ulong start = txtStart.Value;
122 ulong end = txtEnd.Value;
123 ulong byte_diff = (end - start) + BYTE_CORRECTION_VALUE;
124 switch (dumpSize)
125 {
126 case DumpSize.Bytes:
127 txtDumpSize.Text = string.Format("{0:n2}", (double)byte_diff);
128 break;
129 case DumpSize.KiloBytes:
130 txtDumpSize.Text = string.Format("{0:n3}", (double)byte_diff / 1000.0);
131 break;
132 case DumpSize.MegaBytes:
133 txtDumpSize.Text = string.Format("{0:n6}", (double)byte_diff / 1000000.0);
134 break;
135 case DumpSize.GigaBytes:
136 txtDumpSize.Text = string.Format("{0:n9}", (double)byte_diff / 1000000000.0);
137 break;
138 }
139 }
140 }
141 }

  ViewVC Help
Powered by ViewVC 1.1.22