rename ToolHelper.cs to ToolFormBase.cs since that is the name of the class

This commit is contained in:
adelikat 2019-12-22 10:26:33 -06:00
parent 77c04412d2
commit c76dbbb977
2 changed files with 121 additions and 121 deletions

View File

@ -1167,7 +1167,7 @@
<Compile Include="tools\TI83\TI83KeyPad.Designer.cs"> <Compile Include="tools\TI83\TI83KeyPad.Designer.cs">
<DependentUpon>TI83KeyPad.cs</DependentUpon> <DependentUpon>TI83KeyPad.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="tools\ToolHelpers.cs"> <Compile Include="tools\ToolFormBase.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="tools\ToolManager.cs" /> <Compile Include="tools\ToolManager.cs" />

View File

@ -1,120 +1,120 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.IEmulatorExtensions; using BizHawk.Emulation.Common.IEmulatorExtensions;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Client.EmuHawk.WinFormExtensions; using BizHawk.Client.EmuHawk.WinFormExtensions;
using System.Drawing; using System.Drawing;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public class ToolFormBase : Form public class ToolFormBase : Form
{ {
public ToolManager Tools { get; set; } public ToolManager Tools { get; set; }
public Config Config { get; set; } public Config Config { get; set; }
public MainForm MainForm { get; set; } public MainForm MainForm { get; set; }
public static FileInfo OpenFileDialog(string currentFile, string path, string fileType, string fileExt) public static FileInfo OpenFileDialog(string currentFile, string path, string fileType, string fileExt)
{ {
if (!Directory.Exists(path)) if (!Directory.Exists(path))
{ {
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
} }
using var ofd = new OpenFileDialog using var ofd = new OpenFileDialog
{ {
FileName = !string.IsNullOrWhiteSpace(currentFile) FileName = !string.IsNullOrWhiteSpace(currentFile)
? Path.GetFileName(currentFile) ? Path.GetFileName(currentFile)
: $"{PathManager.FilesystemSafeName(Global.Game)}.{fileExt}", : $"{PathManager.FilesystemSafeName(Global.Game)}.{fileExt}",
InitialDirectory = path, InitialDirectory = path,
Filter = string.Format("{0} (*.{1})|*.{1}|All Files|*.*", fileType, fileExt), Filter = string.Format("{0} (*.{1})|*.{1}|All Files|*.*", fileType, fileExt),
RestoreDirectory = true RestoreDirectory = true
}; };
var result = ofd.ShowHawkDialog(); var result = ofd.ShowHawkDialog();
if (result != DialogResult.OK) if (result != DialogResult.OK)
{ {
return null; return null;
} }
return new FileInfo(ofd.FileName); return new FileInfo(ofd.FileName);
} }
public static FileInfo SaveFileDialog(string currentFile, string path, string fileType, string fileExt) public static FileInfo SaveFileDialog(string currentFile, string path, string fileType, string fileExt)
{ {
if (!Directory.Exists(path)) if (!Directory.Exists(path))
{ {
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
} }
using var sfd = new SaveFileDialog using var sfd = new SaveFileDialog
{ {
FileName = !string.IsNullOrWhiteSpace(currentFile) FileName = !string.IsNullOrWhiteSpace(currentFile)
? Path.GetFileName(currentFile) ? Path.GetFileName(currentFile)
: $"{PathManager.FilesystemSafeName(Global.Game)}.{fileExt}", : $"{PathManager.FilesystemSafeName(Global.Game)}.{fileExt}",
InitialDirectory = path, InitialDirectory = path,
Filter = string.Format("{0} (*.{1})|*.{1}|All Files|*.*", fileType, fileExt), Filter = string.Format("{0} (*.{1})|*.{1}|All Files|*.*", fileType, fileExt),
RestoreDirectory = true, RestoreDirectory = true,
}; };
var result = sfd.ShowHawkDialog(); var result = sfd.ShowHawkDialog();
if (result != DialogResult.OK) if (result != DialogResult.OK)
{ {
return null; return null;
} }
return new FileInfo(sfd.FileName); return new FileInfo(sfd.FileName);
} }
public static FileInfo GetWatchFileFromUser(string currentFile) public static FileInfo GetWatchFileFromUser(string currentFile)
{ {
return OpenFileDialog(currentFile, PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPathFragment, null), "Watch Files", "wch"); return OpenFileDialog(currentFile, PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPathFragment, null), "Watch Files", "wch");
} }
public static FileInfo GetWatchSaveFileFromUser(string currentFile) public static FileInfo GetWatchSaveFileFromUser(string currentFile)
{ {
return SaveFileDialog(currentFile, PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPathFragment, null), "Watch Files", "wch"); return SaveFileDialog(currentFile, PathManager.MakeAbsolutePath(Global.Config.PathEntries.WatchPathFragment, null), "Watch Files", "wch");
} }
public static void UpdateCheatRelatedTools(object sender, CheatCollection.CheatListEventArgs e) public static void UpdateCheatRelatedTools(object sender, CheatCollection.CheatListEventArgs e)
{ {
if (Global.Emulator.HasMemoryDomains()) if (Global.Emulator.HasMemoryDomains())
{ {
GlobalWin.Tools.UpdateValues<RamWatch>(); GlobalWin.Tools.UpdateValues<RamWatch>();
GlobalWin.Tools.UpdateValues<RamSearch>(); GlobalWin.Tools.UpdateValues<RamSearch>();
GlobalWin.Tools.UpdateValues<HexEditor>(); GlobalWin.Tools.UpdateValues<HexEditor>();
if (GlobalWin.Tools.Has<Cheats>()) if (GlobalWin.Tools.Has<Cheats>())
{ {
GlobalWin.Tools.Cheats.UpdateDialog(); GlobalWin.Tools.Cheats.UpdateDialog();
} }
GlobalWin.MainForm.UpdateCheatStatus(); GlobalWin.MainForm.UpdateCheatStatus();
} }
} }
public void ViewInHexEditor(MemoryDomain domain, IEnumerable<long> addresses, WatchSize size) public void ViewInHexEditor(MemoryDomain domain, IEnumerable<long> addresses, WatchSize size)
{ {
Tools.Load<HexEditor>(); Tools.Load<HexEditor>();
Tools.HexEditor.SetToAddresses(addresses, domain, size); Tools.HexEditor.SetToAddresses(addresses, domain, size);
} }
protected void GenericDragEnter(object sender, DragEventArgs e) protected void GenericDragEnter(object sender, DragEventArgs e)
{ {
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None; e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
} }
protected void RefreshFloatingWindowControl(bool floatingWindow) protected void RefreshFloatingWindowControl(bool floatingWindow)
{ {
Owner = floatingWindow ? null : GlobalWin.MainForm; Owner = floatingWindow ? null : GlobalWin.MainForm;
} }
protected bool IsOnScreen(Point topLeft) protected bool IsOnScreen(Point topLeft)
{ {
return Tools.IsOnScreen(topLeft); return Tools.IsOnScreen(topLeft);
} }
} }
} }