Cleanup MainForm interfaces, move ShowDialogAsChild to extension

This commit is contained in:
YoshiRulz 2020-12-01 05:24:58 +10:00 committed by James Groom
parent f0664ce018
commit 8a6c7be6aa
5 changed files with 6 additions and 12 deletions

View File

@ -159,6 +159,9 @@ namespace BizHawk.Client.EmuHawk
dialogController.StartSound();
return ret;
}
public static DialogResult ShowDialogAsChild(this IDialogParent dialogParent, Form dialog)
=> dialog.ShowDialog(dialogParent.SelfAsHandle);
}
public static class ListViewExtensions

View File

@ -1,13 +1,9 @@
#nullable enable
using System.Windows.Forms;
namespace BizHawk.Client.EmuHawk
{
public interface IDialogController
{
DialogResult ShowDialogAsChild(Form dialog);
void StartSound();
void StopSound();

View File

@ -1,11 +1,9 @@
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
public interface IMainFormForConfig : IDialogController
public interface IMainFormForConfig : IDialogController, IDialogParent
{
/// <remarks>only referenced from <see cref="GenericCoreConfig"/></remarks>
IEmulator Emulator { get; }

View File

@ -1,5 +1,4 @@
using System;
using System.Windows.Forms;
using BizHawk.Bizware.BizwareGL;
using BizHawk.Client.Common;
@ -7,7 +6,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
public interface IMainFormForTools : IDialogController
public interface IMainFormForTools : IDialogController, IDialogParent
{
CheatCollection CheatList { get; }

View File

@ -3464,7 +3464,7 @@ namespace BizHawk.Client.EmuHawk
private int? LoadArchiveChooser(HawkFile file)
{
using var ac = new ArchiveChooser(file);
if (ShowDialogAsChild(ac).IsOk())
if (this.ShowDialogAsChild(ac).IsOk())
{
return ac.SelectedMemberIndex;
}
@ -4495,8 +4495,6 @@ namespace BizHawk.Client.EmuHawk
public IWin32Window SelfAsHandle => this;
public DialogResult ShowDialogAsChild(Form dialog) => dialog.ShowDialog(this);
public void StartSound() => Sound.StartSound();
public void StopSound() => Sound.StopSound();
}