From 067a1ea6ebcab26baf6fd0205b5e54a462017f98 Mon Sep 17 00:00:00 2001 From: Lesueur Benjamin Date: Sun, 16 Apr 2023 19:28:13 +0200 Subject: [PATCH] code cleanup --- ControllerCommon/Controllers/ControllerState.cs | 1 - ControllerCommon/Devices/GPD/GPDWin4.cs | 5 ++--- ControllerCommon/IniFile.cs | 6 +----- ControllerCommon/Managers/PowerManager.cs | 4 ++-- ControllerCommon/Utils/CommonUtils.cs | 6 +----- ControllerCommon/Utils/ProcessUtils.cs | 2 +- HandheldCompanion/Actions/MouseActions.cs | 1 - HandheldCompanion/Controllers/NeptuneController.cs | 1 - HandheldCompanion/Controllers/XInputController.cs | 1 - HandheldCompanion/Managers/HotkeysManager.cs | 6 +++--- HandheldCompanion/Managers/LayoutManager.cs | 3 +-- HandheldCompanion/Managers/ProfileManager.cs | 6 ++---- HandheldCompanion/Managers/SettingsManager.cs | 1 - HandheldCompanion/Models/ModelDS4.cs | 2 +- HandheldCompanion/Platforms/GOGGalaxy.cs | 7 +------ HandheldCompanion/Platforms/SteamPlatform.cs | 1 - HandheldCompanion/Platforms/UbisoftConnect.cs | 4 ---- HandheldCompanion/Views/Pages/LayoutPage.xaml.cs | 3 +-- HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs | 1 - .../Views/QuickPages/QuickProfilesPage.xaml.cs | 1 - HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs | 2 +- HandheldCompanion/XInputPlus.cs | 7 +------ HandheldCompanion/models/ModelToyController.cs | 2 +- 23 files changed, 19 insertions(+), 54 deletions(-) diff --git a/ControllerCommon/Controllers/ControllerState.cs b/ControllerCommon/Controllers/ControllerState.cs index e39471f5f..0fb89e12c 100644 --- a/ControllerCommon/Controllers/ControllerState.cs +++ b/ControllerCommon/Controllers/ControllerState.cs @@ -1,5 +1,4 @@ using ControllerCommon.Inputs; -using SharpDX.XInput; using System; using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/ControllerCommon/Devices/GPD/GPDWin4.cs b/ControllerCommon/Devices/GPD/GPDWin4.cs index cda4b6c8e..9b42ca3fd 100644 --- a/ControllerCommon/Devices/GPD/GPDWin4.cs +++ b/ControllerCommon/Devices/GPD/GPDWin4.cs @@ -1,6 +1,5 @@ using ControllerCommon.Inputs; using System.Collections.Generic; -using System.Net; using System.Numerics; using WindowsInput.Events; @@ -66,8 +65,8 @@ public GPDWin4() : base() )); OEMChords.Add(new DeviceChord("Bottom button right", - new List() { KeyCode.F12, KeyCode.R}, - new List() { KeyCode.F12, KeyCode.R}, + new List() { KeyCode.F12, KeyCode.R }, + new List() { KeyCode.F12, KeyCode.R }, false, ButtonFlags.OEM3 )); } diff --git a/ControllerCommon/IniFile.cs b/ControllerCommon/IniFile.cs index 812557343..e8ddef260 100644 --- a/ControllerCommon/IniFile.cs +++ b/ControllerCommon/IniFile.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; +using System.IO; using System.Reflection; using System.Runtime.InteropServices; using System.Text; -using System.Threading.Tasks; namespace ControllerCommon { diff --git a/ControllerCommon/Managers/PowerManager.cs b/ControllerCommon/Managers/PowerManager.cs index d200fca79..8a8926093 100644 --- a/ControllerCommon/Managers/PowerManager.cs +++ b/ControllerCommon/Managers/PowerManager.cs @@ -2,10 +2,10 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; +using System.Timers; using System.Windows.Forms; -using Timer = System.Timers.Timer; using SystemPowerManager = Windows.System.Power.PowerManager; -using System.Timers; +using Timer = System.Timers.Timer; namespace ControllerCommon.Managers { diff --git a/ControllerCommon/Utils/CommonUtils.cs b/ControllerCommon/Utils/CommonUtils.cs index df4d2fc4c..8900c8665 100644 --- a/ControllerCommon/Utils/CommonUtils.cs +++ b/ControllerCommon/Utils/CommonUtils.cs @@ -1,6 +1,4 @@ -using SharpDX.Multimedia; -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Net; @@ -9,8 +7,6 @@ using System.Security.Principal; using System.Text.RegularExpressions; using System.Threading; -using System.Windows.Documents; -using static System.Net.Mime.MediaTypeNames; namespace ControllerCommon.Utils { diff --git a/ControllerCommon/Utils/ProcessUtils.cs b/ControllerCommon/Utils/ProcessUtils.cs index edb0689fd..1f5ad6b3a 100644 --- a/ControllerCommon/Utils/ProcessUtils.cs +++ b/ControllerCommon/Utils/ProcessUtils.cs @@ -166,7 +166,7 @@ public static string GetWindowTitle(IntPtr handle) public static Dictionary GetAppProperties(string filePath1) { - Dictionary AppProperties = new (); + Dictionary AppProperties = new(); ShellObject shellFile = ShellObject.FromParsingName(filePath1); foreach (var property in typeof(ShellProperties.PropertySystem).GetProperties(BindingFlags.Public | BindingFlags.Instance)) diff --git a/HandheldCompanion/Actions/MouseActions.cs b/HandheldCompanion/Actions/MouseActions.cs index 9212f1609..6c1cc82c3 100644 --- a/HandheldCompanion/Actions/MouseActions.cs +++ b/HandheldCompanion/Actions/MouseActions.cs @@ -1,5 +1,4 @@ using ControllerCommon.Actions; -using ControllerCommon.Controllers; using ControllerCommon.Inputs; using HandheldCompanion.Simulators; using System; diff --git a/HandheldCompanion/Controllers/NeptuneController.cs b/HandheldCompanion/Controllers/NeptuneController.cs index 83c534696..c8b4db7dd 100644 --- a/HandheldCompanion/Controllers/NeptuneController.cs +++ b/HandheldCompanion/Controllers/NeptuneController.cs @@ -8,7 +8,6 @@ using SharpDX.XInput; using System; using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; namespace HandheldCompanion.Controllers diff --git a/HandheldCompanion/Controllers/XInputController.cs b/HandheldCompanion/Controllers/XInputController.cs index 3f1d77a32..8392c86d0 100644 --- a/HandheldCompanion/Controllers/XInputController.cs +++ b/HandheldCompanion/Controllers/XInputController.cs @@ -6,7 +6,6 @@ using System; using System.Linq; using System.Runtime.InteropServices; -using System.Threading; using System.Threading.Tasks; using System.Windows.Media; diff --git a/HandheldCompanion/Managers/HotkeysManager.cs b/HandheldCompanion/Managers/HotkeysManager.cs index 57321d799..4c4fb03c7 100644 --- a/HandheldCompanion/Managers/HotkeysManager.cs +++ b/HandheldCompanion/Managers/HotkeysManager.cs @@ -110,7 +110,7 @@ public static void Start() if (!string.IsNullOrEmpty(hotkey.inputsHotkey.Settings)) hotkey.IsEnabled = SettingsManager.GetBoolean(hotkey.inputsHotkey.Settings); - + HotkeyCreated?.Invoke(hotkey); } @@ -136,7 +136,7 @@ private static void SettingsManager_SettingValueChanged(string name, object valu Application.Current.Dispatcher.BeginInvoke(() => { // manage toggle type hotkeys - foreach(Hotkey hotkey in Hotkeys.Values.Where(item => item.inputsHotkey.Listener.Equals(name))) + foreach (Hotkey hotkey in Hotkeys.Values.Where(item => item.inputsHotkey.Listener.Equals(name))) { if (!hotkey.inputsHotkey.IsToggle) continue; @@ -146,7 +146,7 @@ private static void SettingsManager_SettingValueChanged(string name, object valu } // manage settings type hotkeys - foreach(Hotkey hotkey in Hotkeys.Values.Where(item => item.inputsHotkey.Settings.Contains(name))) + foreach (Hotkey hotkey in Hotkeys.Values.Where(item => item.inputsHotkey.Settings.Contains(name))) { bool enabled = SettingsManager.GetBoolean(hotkey.inputsHotkey.Settings); hotkey.IsEnabled = enabled; diff --git a/HandheldCompanion/Managers/LayoutManager.cs b/HandheldCompanion/Managers/LayoutManager.cs index 1a16caecb..33eabcae4 100644 --- a/HandheldCompanion/Managers/LayoutManager.cs +++ b/HandheldCompanion/Managers/LayoutManager.cs @@ -11,7 +11,6 @@ using System.Collections.Generic; using System.IO; using System.Windows; -using static PInvoke.Kernel32; using Layout = ControllerCommon.Layout; namespace HandheldCompanion.Managers @@ -226,7 +225,7 @@ public static void SerializeLayoutTemplate(LayoutTemplate layoutTemplate) }); string fileName = string.Empty; - + if (layoutTemplate.IsTemplate) fileName = Path.Combine(TemplatesPath, $"{layoutTemplate.Name}.json"); else diff --git a/HandheldCompanion/Managers/ProfileManager.cs b/HandheldCompanion/Managers/ProfileManager.cs index 6d09fa88d..5b0a28619 100644 --- a/HandheldCompanion/Managers/ProfileManager.cs +++ b/HandheldCompanion/Managers/ProfileManager.cs @@ -3,7 +3,6 @@ using ControllerCommon.Managers; using ControllerCommon.Pipes; using ControllerCommon.Utils; -using Force.Crc32; using HandheldCompanion.Controllers; using HandheldCompanion.Controls; using HandheldCompanion.Views; @@ -13,7 +12,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using static ControllerCommon.Utils.ProcessUtils; namespace HandheldCompanion.Managers { @@ -275,7 +273,7 @@ private static void ProcessProfile(string fileName) if (jObject.ContainsKey("Version")) version = new(jObject["Version"].ToString()); - switch(version.ToString()) + switch (version.ToString()) { case "0.15.0.4": outputraw = CommonUtils.RegexReplace(outputraw, "Generic.Dictionary(.*)System.Private.CoreLib\"", "Generic.SortedDictionary$1System.Collections\""); @@ -479,7 +477,7 @@ private static void ControllerManager_ControllerSelected(IController Controller) if (Controller.GetType() != typeof(XInputController)) return; - foreach(Profile profile in profiles.Values) + foreach (Profile profile in profiles.Values) UpdateProfileWrapper(profile); } } diff --git a/HandheldCompanion/Managers/SettingsManager.cs b/HandheldCompanion/Managers/SettingsManager.cs index dbe791163..2cf0b261c 100644 --- a/HandheldCompanion/Managers/SettingsManager.cs +++ b/HandheldCompanion/Managers/SettingsManager.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Configuration; -using System.IO; using System.Linq; namespace HandheldCompanion.Managers diff --git a/HandheldCompanion/Models/ModelDS4.cs b/HandheldCompanion/Models/ModelDS4.cs index 6b17f0c77..5f125318b 100644 --- a/HandheldCompanion/Models/ModelDS4.cs +++ b/HandheldCompanion/Models/ModelDS4.cs @@ -1,7 +1,7 @@ using ControllerCommon.Inputs; using System; -using System.IO; using System.Collections.Generic; +using System.IO; using System.Windows; using System.Windows.Media; using System.Windows.Media.Media3D; diff --git a/HandheldCompanion/Platforms/GOGGalaxy.cs b/HandheldCompanion/Platforms/GOGGalaxy.cs index d59abed1e..87156fbf6 100644 --- a/HandheldCompanion/Platforms/GOGGalaxy.cs +++ b/HandheldCompanion/Platforms/GOGGalaxy.cs @@ -1,14 +1,9 @@ -using ControllerCommon.Managers; -using ControllerCommon.Platforms; +using ControllerCommon.Platforms; using ControllerCommon.Utils; -using HandheldCompanion.Properties; using System; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics; using System.IO; -using System.Linq; -using System.Text.RegularExpressions; namespace HandheldCompanion.Platforms { diff --git a/HandheldCompanion/Platforms/SteamPlatform.cs b/HandheldCompanion/Platforms/SteamPlatform.cs index 77f4a3c06..f8158723f 100644 --- a/HandheldCompanion/Platforms/SteamPlatform.cs +++ b/HandheldCompanion/Platforms/SteamPlatform.cs @@ -4,7 +4,6 @@ using HandheldCompanion.Properties; using System; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; diff --git a/HandheldCompanion/Platforms/UbisoftConnect.cs b/HandheldCompanion/Platforms/UbisoftConnect.cs index 89b21988b..f34dc3603 100644 --- a/HandheldCompanion/Platforms/UbisoftConnect.cs +++ b/HandheldCompanion/Platforms/UbisoftConnect.cs @@ -1,13 +1,9 @@ using ControllerCommon.Platforms; using ControllerCommon.Utils; -using HandheldCompanion.Properties; using System; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics; using System.IO; -using System.Linq; -using System.Text.RegularExpressions; namespace HandheldCompanion.Platforms { diff --git a/HandheldCompanion/Views/Pages/LayoutPage.xaml.cs b/HandheldCompanion/Views/Pages/LayoutPage.xaml.cs index b045d179c..c3db3ee58 100644 --- a/HandheldCompanion/Views/Pages/LayoutPage.xaml.cs +++ b/HandheldCompanion/Views/Pages/LayoutPage.xaml.cs @@ -1,4 +1,3 @@ -using ControllerCommon; using ControllerCommon.Actions; using ControllerCommon.Controllers; using ControllerCommon.Devices; @@ -441,7 +440,7 @@ private void LayoutExportButton_Click(object sender, RoutedEventArgs e) if (ExportForCurrent.IsChecked == true) newLayout.ControllerType = ControllerManager.GetTargetController().GetType(); - + LayoutManager.SerializeLayoutTemplate(newLayout); // close flyout diff --git a/HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs b/HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs index 08dd234db..95dda9610 100644 --- a/HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs +++ b/HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs @@ -15,7 +15,6 @@ using System.Windows; using System.Windows.Controls; using System.Xml; -using System.Xml.Linq; using Layout = ControllerCommon.Layout; using Page = System.Windows.Controls.Page; diff --git a/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs b/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs index 6bed1dcdd..8deeedfd5 100644 --- a/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs +++ b/HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs @@ -9,7 +9,6 @@ using System.Threading; using System.Windows; using System.Windows.Controls; -using static System.Runtime.InteropServices.JavaScript.JSType; using Layout = ControllerCommon.Layout; using Page = System.Windows.Controls.Page; using Timer = System.Timers.Timer; diff --git a/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs b/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs index f17fc0c7e..80f1593c4 100644 --- a/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs +++ b/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs @@ -6,11 +6,11 @@ using System.Linq; using System.Windows; using System.Windows.Forms; -using Input = System.Windows.Input; using System.Windows.Interop; using System.Windows.Navigation; using Windows.System.Power; using Application = System.Windows.Application; +using Input = System.Windows.Input; using Page = System.Windows.Controls.Page; using PowerManager = ControllerCommon.Managers.PowerManager; using SystemPowerManager = Windows.System.Power.PowerManager; diff --git a/HandheldCompanion/XInputPlus.cs b/HandheldCompanion/XInputPlus.cs index a8e1e50e0..9a8479e49 100644 --- a/HandheldCompanion/XInputPlus.cs +++ b/HandheldCompanion/XInputPlus.cs @@ -4,15 +4,10 @@ using Force.Crc32; using HandheldCompanion.Controllers; using HandheldCompanion.Managers; -using HelixToolkit.Wpf; using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static ControllerCommon.Utils.ProcessUtils; -using static PInvoke.Kernel32; namespace HandheldCompanion { @@ -44,7 +39,7 @@ public static void RegisterApplication(Profile profile) { XInputController XController = (XInputController)controller; int idx = XController.GetUserIndex() + 1; - + IniFile IniFile = new IniFile(IniPath); IniFile.Write("Controller1", Convert.ToString(idx), "ControllerNumber"); diff --git a/HandheldCompanion/models/ModelToyController.cs b/HandheldCompanion/models/ModelToyController.cs index e2de7b84e..a03420a0f 100644 --- a/HandheldCompanion/models/ModelToyController.cs +++ b/HandheldCompanion/models/ModelToyController.cs @@ -1,7 +1,7 @@ using ControllerCommon.Inputs; using System; -using System.IO; using System.Collections.Generic; +using System.IO; using System.Windows; using System.Windows.Media; using System.Windows.Media.Media3D;