/[RomCheater]/trunk/RomCheater.RVACalculator/RVACalculatorDockControl.cs
ViewVC logotype

Diff of /trunk/RomCheater.RVACalculator/RVACalculatorDockControl.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.RVACalculator/RVACalculatorDockControl.cs	2013/06/17 12:40:47	699
+++ trunk/RomCheater.RVACalculator/RVACalculatorDockControl.cs	2013/06/17 13:09:29	700
@@ -69,24 +69,27 @@
         {
             //logger.Warn.WriteLine("plugin_OnSelectedProcessChanged::has not been implemented!");
         }
-        /*
-         *  foreach (var col in Enumerable.Range(0, lstCheats.Columns.Count))
+
+
+        private void ResizeColumns()
+        {
+            foreach (var col in Enumerable.Range(0, lstCheats.Columns.Count))
             {
                 lstCheats.AutoResizeColumn(col, ColumnHeaderAutoResizeStyle.ColumnContent);
             }
-         */
+        }
+
         private void btnAdd_Click(object sender, EventArgs e)
         {
-            string name = string.Empty;
-            string address = string.Empty;
-
-            name = Microsoft.VisualBasic.Interaction.InputBox("Input Dialog", "Enter the cheat name", string.Empty);
-            address = Microsoft.VisualBasic.Interaction.InputBox("Input Dialog", "Enter the cheat address (in hex : 0xXXXXXXXX)", string.Empty);
-            uint physical = Convert.ToUInt32(address, 16) + txtRVA.ToUInt32();
-            ListViewItem li = new ListViewItem(name);
-            li.SubItems.Add(new ListViewItem.ListViewSubItem(li, string.Format("0x{0:x8}", Convert.ToUInt32(address, 16))));
+            CheatInputDialog dlg = new CheatInputDialog();
+            DialogResult result = dlg.ShowDialog();
+            if (result == DialogResult.Cancel) { return; }
+            uint physical = dlg.CheatAddress + txtRVA.ToUInt32();
+            ListViewItem li = new ListViewItem(dlg.CheatName);
+            li.SubItems.Add(new ListViewItem.ListViewSubItem(li, string.Format("0x{0:x8}", dlg.CheatAddress)));
             li.SubItems.Add(new ListViewItem.ListViewSubItem(li, string.Format("0x{0:x8}", physical)));
             lstCheats.Items.Add(li);
+            ResizeColumns();
         }
 
         private void btnRemove_Click(object sender, EventArgs e)
@@ -94,6 +97,7 @@
             if (lstCheats.SelectedItems.Count == 0 || lstCheats.SelectedItems.Count > 1) { return; }
             int index = lstCheats.SelectedIndices[0];
             lstCheats.Items.RemoveAt(index);
+            ResizeColumns();
         }
 
         private void btnUpdate_Click(object sender, EventArgs e)
@@ -104,13 +108,15 @@
             string name = li.Text;
             string address = li.SubItems[1].Text;
 
-            name = Microsoft.VisualBasic.Interaction.InputBox("Input Dialog", "Enter the cheat name", name);
-            address = Microsoft.VisualBasic.Interaction.InputBox("Input Dialog", "Enter the cheat address (in hex : 0xXXXXXXXX)", address);
-            uint physical = Convert.ToUInt32(address, 16) + txtRVA.ToUInt32();
-            li.Text = name;
-            li.SubItems[1].Text = string.Format("0x{0:x8}", Convert.ToUInt32(address, 16));
+            CheatInputDialog dlg = new CheatInputDialog(name, Convert.ToUInt32(address, 16));
+            DialogResult result = dlg.ShowDialog();
+            if (result == DialogResult.Cancel) { return; }
+            uint physical = dlg.CheatAddress + txtRVA.ToUInt32();
+            li.Text = dlg.CheatName;
+            li.SubItems[1].Text = string.Format("0x{0:x8}", dlg.CheatAddress);
             li.SubItems[2].Text = string.Format("0x{0:x8}", physical);
-            lstCheats.Items[index] = li;            
+            lstCheats.Items[index] = li;
+            ResizeColumns();
         }
 
         private void btnCopy_Click(object sender, EventArgs e)
@@ -232,6 +238,7 @@
                 logger.VerboseError.WriteLine(ex.ToString());
                 MessageBox.Show(string.Format("Failed to open: '{0}'", new FileInfo(CheatLoader.FileName).Name), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
+            ResizeColumns();
         }
 
         private void btnRefresh_Click(object sender, EventArgs e)
@@ -246,6 +253,7 @@
                 lstCheats.Items[index] = li;
                 index++;
             }
+            ResizeColumns();
         }
         private void btnCopyAll_Click(object sender, EventArgs e)
         {

 

  ViewVC Help
Powered by ViewVC 1.1.22