microsoft/TypeAgent
Publicmirrored fromhttps://github.com/microsoft/TypeAgentAvailable
dotnet/autoShell/Handlers/SystemActionHandler.cs
36lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using autoShell.Handlers.Generated; |
| 5 | using autoShell.Services; |
| 6 | |
| 7 | namespace autoShell.Handlers; |
| 8 | |
| 9 | /// <summary> |
| 10 | /// Handles system/utility commands: Debug and ToggleNotifications. |
| 11 | /// </summary> |
| 12 | internal class SystemActionHandler : ActionHandlerBase |
| 13 | { |
| 14 | private readonly IProcessService _process; |
| 15 | private readonly IDebuggerService _debugger; |
| 16 | |
| 17 | public SystemActionHandler(IProcessService process, IDebuggerService debugger) |
| 18 | { |
| 19 | _process = process; |
| 20 | _debugger = debugger; |
| 21 | AddAction<DebugParams>("Debug", HandleDebug); |
| 22 | AddAction<ToggleNotificationsParams>("ToggleNotifications", HandleToggleNotifications); |
| 23 | } |
| 24 | |
| 25 | private ActionResult HandleDebug(DebugParams p) |
| 26 | { |
| 27 | _debugger.Launch(); |
| 28 | return ActionResult.Ok("Debugger launched"); |
| 29 | } |
| 30 | |
| 31 | private ActionResult HandleToggleNotifications(ToggleNotificationsParams p) |
| 32 | { |
| 33 | _process.StartShellExecute("ms-actioncenter:"); |
| 34 | return ActionResult.Ok("Toggled Action Center"); |
| 35 | } |
| 36 | } |
| 37 | |