microsoft/TypeAgent

Public

mirrored fromhttps://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/remove-deprecated-dependencies

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

dotnet/autoShell/Handlers/WindowCommandHandler.cs

65lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4using System.Collections.Generic;
5using autoShell.Services;
6using Newtonsoft.Json.Linq;
7
8namespace autoShell.Handlers;
9
10/// <summary>
11/// Handles window management commands: Maximize, Minimize, SwitchTo, and Tile.
12/// </summary>
13internal class WindowCommandHandler : ICommandHandler
14{
15 private readonly IAppRegistry _appRegistry;
16 private readonly IWindowService _window;
17
18 public WindowCommandHandler(IAppRegistry appRegistry, IWindowService window)
19 {
20 _appRegistry = appRegistry;
21 _window = window;
22 }
23
24 /// <inheritdoc/>
25 public IEnumerable<string> SupportedCommands { get; } =
26 [
27 "Maximize",
28 "Minimize",
29 "SwitchTo",
30 "Tile",
31 ];
32
33 /// <inheritdoc/>
34 public void Handle(string key, string value, JToken rawValue)
35 {
36 switch (key)
37 {
38 case "Maximize":
39 string maxProcess = _appRegistry.ResolveProcessName(value);
40 _window.MaximizeWindow(maxProcess);
41 break;
42
43 case "Minimize":
44 string minProcess = _appRegistry.ResolveProcessName(value);
45 _window.MinimizeWindow(minProcess);
46 break;
47
48 case "SwitchTo":
49 string switchProcess = _appRegistry.ResolveProcessName(value);
50 string path = _appRegistry.GetExecutablePath(value);
51 _window.RaiseWindow(switchProcess, path);
52 break;
53
54 case "Tile":
55 string[] apps = value.Split(',');
56 if (apps.Length == 2)
57 {
58 string processName1 = _appRegistry.ResolveProcessName(apps[0]);
59 string processName2 = _appRegistry.ResolveProcessName(apps[1]);
60 _window.TileWindows(processName1, processName2);
61 }
62 break;
63 }
64 }
65}
66