diff --git a/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs b/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs index 002c1af7aa..9d22d023f6 100644 --- a/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs +++ b/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; @@ -52,6 +53,11 @@ namespace BizHawk.Client.EmuHawk.WinFormExtensions } } } + + public static Point ChildPointToScreen(this Control control, Control child) + { + return control.PointToScreen(new Point(child.Location.X, child.Location.Y)); + } } public static class FormExtensions diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs index 425c041d8e..af486cccda 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs @@ -679,12 +679,6 @@ namespace BizHawk.Client.EmuHawk _domainMenuItems.Add(rom_item); } - private Point GetPromptPoint() - { - return PointToScreen( - new Point(MemoryViewerBox.Location.X + 30, MemoryViewerBox.Location.Y + 30)); - } - private void ClearNibbles() { for (var i = 0; i < 8; i++) @@ -1483,7 +1477,11 @@ namespace BizHawk.Client.EmuHawk private void GoToAddressMenuItem_Click(object sender, EventArgs e) { - var inputPrompt = new InputPrompt { Text = "Go to Address", StartLocation = GetPromptPoint() }; + var inputPrompt = new InputPrompt + { + Text = "Go to Address", + StartLocation = this.ChildPointToScreen(MemoryViewerBox) + }; inputPrompt.SetMessage("Enter a hexadecimal value"); var result = inputPrompt.ShowHawkDialog(); diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index b1f131cb02..2d33041097 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -558,12 +558,6 @@ namespace BizHawk.Client.EmuHawk return true; } - private Point GetPromptPoint() - { - return PointToScreen( - new Point(LuaListView.Location.X + 30, LuaListView.Location.Y + 30)); - } - private static void UpdateRegisteredFunctionsDialog() { foreach (var form in Application.OpenForms.OfType()) @@ -880,8 +874,10 @@ namespace BizHawk.Client.EmuHawk if (!alreadyOpen) { - var form = new LuaRegisteredFunctionsList { StartLocation = GetPromptPoint() }; - form.Show(); + new LuaRegisteredFunctionsList + { + StartLocation = this.ChildPointToScreen(LuaListView) + }.Show(); } } } diff --git a/BizHawk.Client.EmuHawk/tools/TraceLogger.cs b/BizHawk.Client.EmuHawk/tools/TraceLogger.cs index 4340f8a5ba..5f74e94ab8 100644 --- a/BizHawk.Client.EmuHawk/tools/TraceLogger.cs +++ b/BizHawk.Client.EmuHawk/tools/TraceLogger.cs @@ -152,13 +152,6 @@ namespace BizHawk.Client.EmuHawk TraceView.ItemCount = _instructions.Count; } - private Point GetPromptPoint() - { - return PointToScreen( - new Point(TraceView.Location.X + 30, TraceView.Location.Y + 30) - ); - } - private void SetTracerBoxTitle() { if (Global.CoreComm.Tracer.Enabled) @@ -292,11 +285,15 @@ namespace BizHawk.Client.EmuHawk private void MaxLinesMenuItem_Click(object sender, EventArgs e) { - var prompt = new InputPrompt(); + var prompt = new InputPrompt + { + StartLocation = this.ChildPointToScreen(TraceView), + TextInputType = InputPrompt.InputType.Unsigned + }; + prompt.SetMessage("Max lines to display in the window"); prompt.SetInitialValue(Global.Config.TraceLoggerMaxLines.ToString()); - prompt.TextInputType = InputPrompt.InputType.Unsigned; - prompt.StartLocation = GetPromptPoint(); + var result = prompt.ShowHawkDialog(); if (result == DialogResult.OK) { diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs index 228de9f167..7f604acfdf 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs @@ -868,20 +868,18 @@ namespace BizHawk.Client.EmuHawk } } - private Point GetPromptPoint() - { - return PointToScreen(new Point(WatchListView.Location.X, WatchListView.Location.Y)); - } - private void PokeAddress() { if (SelectedIndices.Any()) { - var poke = new RamPoke(); - var watches = SelectedIndices.Select(t => _searches[t]).ToList(); - poke.SetWatch(watches); - poke.InitialLocation = GetPromptPoint(); + var poke = new RamPoke + { + InitialLocation = this.ChildPointToScreen(WatchListView) + }; + + poke.SetWatch(SelectedIndices.Select(t => _searches[t]).ToList()); poke.ShowHawkDialog(); + UpdateValues(); } } @@ -933,7 +931,12 @@ namespace BizHawk.Client.EmuHawk private void GoToSpecifiedAddress() { WatchListView.SelectedIndices.Clear(); - var prompt = new InputPrompt { Text = "Go to Address", StartLocation = GetPromptPoint() }; + var prompt = new InputPrompt + { + Text = "Go to Address", + StartLocation = this.ChildPointToScreen(WatchListView) + }; + prompt.SetMessage("Enter a hexadecimal value"); var result = prompt.ShowHawkDialog(); diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index dd5ce02475..cbf06df024 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -335,7 +335,7 @@ namespace BizHawk.Client.EmuHawk { var we = new WatchEditor { - InitialLocation = GetPromptPoint(), + InitialLocation = this.ChildPointToScreen(WatchListView) }; we.SetWatch(_watches.Domain, SelectedWatches, duplicate ? WatchEditor.Mode.Duplicate : WatchEditor.Mode.Edit); @@ -396,11 +396,6 @@ namespace BizHawk.Client.EmuHawk return width; } - private Point GetPromptPoint() - { - return PointToScreen(new Point(WatchListView.Location.X, WatchListView.Location.Y)); - } - private void LoadColumnInfo() { WatchListView.Columns.Clear(); @@ -723,7 +718,7 @@ namespace BizHawk.Client.EmuHawk { var we = new WatchEditor { - InitialLocation = GetPromptPoint() + InitialLocation = this.ChildPointToScreen(WatchListView) }; we.SetWatch(_watches.Domain); we.ShowHawkDialog(); @@ -769,7 +764,7 @@ namespace BizHawk.Client.EmuHawk { var poke = new RamPoke { - InitialLocation = GetPromptPoint() + InitialLocation = this.ChildPointToScreen(WatchListView) }; poke.SetWatch(SelectedWatches);