diff --git a/src/SwitchifyPc.App/App.xaml.cs b/src/SwitchifyPc.App/App.xaml.cs index 80c292a..5dd7331 100644 --- a/src/SwitchifyPc.App/App.xaml.cs +++ b/src/SwitchifyPc.App/App.xaml.cs @@ -9,6 +9,7 @@ using SwitchifyPc.Core.Input; using SwitchifyPc.Core.Pairing; using SwitchifyPc.Core.Settings; +using SwitchifyPc.Core.SwitchControl; using SwitchifyPc.Core.AppLifecycle; using SwitchifyPc.Core.Diagnostics; using SwitchifyPc.Core.Startup; @@ -36,6 +37,7 @@ public partial class App : System.Windows.Application private WindowsExistingInstanceSignal? existingInstanceSignal; private NativeTrayIcon? trayIcon; private SettingsWindow? settingsWindow; + private SwitchControlProfileWindow? switchControlProfileWindow; private SetupGuideWindow? setupGuideWindow; private MainWindowViewModel mainWindowViewModel = new(); private SetupGuideViewModel setupGuideViewModel = new(); @@ -45,6 +47,7 @@ public partial class App : System.Windows.Application private WindowsBluetoothGattServer? bluetoothServer; private BluetoothRemoteFrameProcessor? bluetoothFrameProcessor; private DesktopCommandExecutor? commandExecutor; + private JsonSwitchControlProfileStore? switchControlProfileStore; private MouseRepeatController? mouseRepeatController; private WindowsCursorOverlayNotifier? cursorOverlay; private WindowsModifierKeyOverlayNotifier? modifierOverlay; @@ -154,6 +157,7 @@ protected override void OnExit(ExitEventArgs e) themeManager?.Dispose(); themeManager = null; commandExecutor = null; + switchControlProfileStore = null; bluetoothFrameProcessor = null; bluetoothStatusTracker = null; pairingApprovalManager = null; @@ -164,6 +168,7 @@ protected override void OnExit(ExitEventArgs e) trayIcon?.Dispose(); trayIcon = null; settingsWindow = null; + switchControlProfileWindow = null; setupGuideWindow = null; telemetryReporter?.Dispose(); telemetryReporter = null; @@ -273,7 +278,7 @@ private SetupGuideWindow CreateSetupGuideWindow() private SettingsWindow CreateSettingsWindow() { - SettingsWindow window = new(CreateSettingsController()); + SettingsWindow window = new(CreateSettingsController(), ShowSwitchControlProfiles); window.Closing += (_, eventArgs) => { if (isQuitting) return; @@ -284,6 +289,22 @@ private SettingsWindow CreateSettingsWindow() return window; } + private void ShowSwitchControlProfiles() + { + switchControlProfileStore ??= new JsonSwitchControlProfileStore( + Path.Combine(UserDataDirectory(), "switch-control-profiles.json")); + if (switchControlProfileWindow is null) + { + switchControlProfileWindow = new SwitchControlProfileWindow( + switchControlProfileStore, + () => null); + switchControlProfileWindow.Closed += (_, _) => switchControlProfileWindow = null; + } + switchControlProfileWindow.Owner = settingsWindow; + switchControlProfileWindow.Show(); + switchControlProfileWindow.Activate(); + } + private static void CenterWindow(Window window) { window.Left = SystemParameters.WorkArea.Left + (SystemParameters.WorkArea.Width - window.Width) / 2; diff --git a/src/SwitchifyPc.App/SettingsWindow.xaml b/src/SwitchifyPc.App/SettingsWindow.xaml index 7b99159..78751cc 100644 --- a/src/SwitchifyPc.App/SettingsWindow.xaml +++ b/src/SwitchifyPc.App/SettingsWindow.xaml @@ -368,6 +368,20 @@ + + + + +