From 70840c1b5423655cf583fb1ea3229258441fa500 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 6 Dec 2019 19:22:23 -0600 Subject: [PATCH] remove some unused code, and a few other misc cleanups --- BizHawk.Client.EmuHawk/ArgParser.cs | 12 ++--- .../CustomControls/Win32.cs | 47 ++----------------- .../tools/GBA/MobileDetailView.cs | 20 +------- BizHawk.Client.EmuHawk/tools/TraceLogger.cs | 9 ++-- .../controls/VirtualPadTargetScreen.cs | 5 +- .../tools/VirtualPads/schema/IntvSchema.cs | 1 - 6 files changed, 12 insertions(+), 82 deletions(-) diff --git a/BizHawk.Client.EmuHawk/ArgParser.cs b/BizHawk.Client.EmuHawk/ArgParser.cs index d97ac32c79..9258c0e3d2 100644 --- a/BizHawk.Client.EmuHawk/ArgParser.cs +++ b/BizHawk.Client.EmuHawk/ArgParser.cs @@ -2,11 +2,10 @@ using System.Collections.Generic; using System.Linq; using System.IO; -using System.Windows.Forms; namespace BizHawk.Client.EmuHawk { - class ArgParser + public class ArgParser //parses command line arguments and adds the values to a class attribute //default values are null for strings and false for boolean //the last value will overwrite previously set values @@ -161,7 +160,7 @@ namespace BizHawk.Client.EmuHawk } } - //inititalize socket server + // initialize socket server if (socket_ip != null && socket_port > 0) { GlobalWin.socketServer = new Communication.SocketServer(); @@ -185,13 +184,8 @@ namespace BizHawk.Client.EmuHawk return args.FirstOrDefault(arg => arg.StartsWith("--config=", StringComparison.InvariantCultureIgnoreCase))?.Substring(9); } } - - class ArgParserException : Exception + public class ArgParserException : Exception { - public ArgParserException() - { - } - public ArgParserException(string message) : base(message) { } diff --git a/BizHawk.Client.EmuHawk/CustomControls/Win32.cs b/BizHawk.Client.EmuHawk/CustomControls/Win32.cs index 6c53604b4a..d849bafec7 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/Win32.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/Win32.cs @@ -1,52 +1,14 @@ using System; -using System.Collections.Generic; -using System.Windows.Forms; using System.Drawing; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; namespace BizHawk.Client.EmuHawk { - public unsafe static class Win32 + public static unsafe class Win32 { - public static bool Is64BitProcess { get { return (IntPtr.Size == 8); } } - public static bool Is64BitOperatingSystem { get { return Is64BitProcess || InternalCheckIsWow64(); } } - - [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] - [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool IsWow64Process( - [In] IntPtr hProcess, - [Out] out bool wow64Process - ); - [DllImport("kernel32.dll")] public static extern IntPtr LoadLibrary(string dllToLoad); - [DllImport("kernel32.dll")] - public static extern IntPtr GetProcAddress(IntPtr hModule, string procedureName); - [DllImport("kernel32.dll")] - public static extern bool FreeLibrary(IntPtr hModule); - - - static bool InternalCheckIsWow64() - { - if ((Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1) || - Environment.OSVersion.Version.Major >= 6) - { - using (var p = System.Diagnostics.Process.GetCurrentProcess()) - { - bool retVal; - if (!IsWow64Process(p.Handle, out retVal)) - { - return false; - } - return retVal; - } - } - else - { - return false; - } - } [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct RECT @@ -238,7 +200,6 @@ namespace BizHawk.Client.EmuHawk public const int WAVE_FORMAT_PCM = 1; public const int AVIIF_KEYFRAME = 0x00000010; - [Flags] public enum OpenFileStyle : uint { @@ -434,13 +395,11 @@ namespace BizHawk.Client.EmuHawk // Release an open AVI stream [DllImport("avifil32.dll")] - public static extern int AVIStreamRelease( - IntPtr pavi); + public static extern int AVIStreamRelease(IntPtr pavi); // Release an open AVI stream [DllImport("avifil32.dll")] - public static extern int AVIFileRelease( - IntPtr pfile); + public static extern int AVIFileRelease(IntPtr pfile); // Replacement of mmioFOURCC macros diff --git a/BizHawk.Client.EmuHawk/tools/GBA/MobileDetailView.cs b/BizHawk.Client.EmuHawk/tools/GBA/MobileDetailView.cs index 6fc671fd5d..b0780f6a61 100644 --- a/BizHawk.Client.EmuHawk/tools/GBA/MobileDetailView.cs +++ b/BizHawk.Client.EmuHawk/tools/GBA/MobileDetailView.cs @@ -1,10 +1,4 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; using System.Windows.Forms; namespace BizHawk.Client.EmuHawk @@ -16,25 +10,13 @@ namespace BizHawk.Client.EmuHawk InitializeComponent(); } - public BmpView BmpView { get { return bmpView1; } } - - [Browsable(false)] - public bool ShouldDraw { get { return this.Visible; } } + public BmpView BmpView => bmpView1; public override string ToString() { return Text; } - public void SetDetails(IList> details) - { - listView1.Items.Clear(); - foreach (var t in details) - { - listView1.Items.Add(new ListViewItem(new string[] { t.Item1, t.Item2 })); - } - } - private void MobileDetailView_SizeChanged(object sender, EventArgs e) { // bmp view is always square diff --git a/BizHawk.Client.EmuHawk/tools/TraceLogger.cs b/BizHawk.Client.EmuHawk/tools/TraceLogger.cs index c7bad8fa36..0c004e1bd3 100644 --- a/BizHawk.Client.EmuHawk/tools/TraceLogger.cs +++ b/BizHawk.Client.EmuHawk/tools/TraceLogger.cs @@ -26,7 +26,7 @@ namespace BizHawk.Client.EmuHawk [ConfigPersist] private List Columns { - get { return TraceView.AllColumns; } + get => TraceView.AllColumns; set { TraceView.AllColumns.Clear(); @@ -42,7 +42,7 @@ namespace BizHawk.Client.EmuHawk private FileInfo _logFile; private FileInfo LogFile { - get { return _logFile; } + get => _logFile; set { _logFile = value; @@ -94,10 +94,7 @@ namespace BizHawk.Client.EmuHawk }); } - public bool UpdateBefore - { - get { return false; } - } + public bool UpdateBefore => false; public bool AskSaveChanges() { diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadTargetScreen.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadTargetScreen.cs index 0ec7705863..87f993612b 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadTargetScreen.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/controls/VirtualPadTargetScreen.cs @@ -10,7 +10,6 @@ namespace BizHawk.Client.EmuHawk public partial class VirtualPadTargetScreen : UserControl, IVirtualPadControl { private readonly Pen BlackPen = new Pen(Brushes.Black, 2); - private readonly Pen WhitePen = new Pen(Brushes.White, 2); private readonly Pen GrayPen = new Pen(Brushes.Gray, 2); private readonly Pen RedPen = new Pen(Brushes.Red, 2); @@ -19,8 +18,8 @@ namespace BizHawk.Client.EmuHawk private bool _readonly; private bool _isSet; // The tool has to keep track of this because there is currently no way to know if a float button is being autoheld or just held - private int? _overrideX = null; - private int? _overrideY = null; + private int? _overrideX; + private int? _overrideY; public VirtualPadTargetScreen() { diff --git a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/IntvSchema.cs b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/IntvSchema.cs index 6299da5f5f..178f9bdd75 100644 --- a/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/IntvSchema.cs +++ b/BizHawk.Client.EmuHawk/tools/VirtualPads/schema/IntvSchema.cs @@ -10,7 +10,6 @@ namespace BizHawk.Client.EmuHawk [Schema("INTV")] public class IntvSchema : IVirtualPadSchema { - private string UnpluggedControllerName => typeof(UnpluggedController).DisplayName(); private string StandardControllerName => typeof(StandardController).DisplayName(); private string AnalogControllerName => typeof(FakeAnalogController).DisplayName();