Skip to content

Commit

Permalink
WTQ v2
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingpie committed Jan 21, 2024
1 parent 83db694 commit 54f0d5c
Show file tree
Hide file tree
Showing 58 changed files with 1,005 additions and 1,795 deletions.
29 changes: 8 additions & 21 deletions windows-terminal-quake.sln
Original file line number Diff line number Diff line change
@@ -1,40 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34221.43
VisualStudioVersion = 17.8.34511.84
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "windows-terminal-quake", "windows-terminal-quake\windows-terminal-quake.csproj", "{96A07892-69EC-49FB-84C4-3AE678EE3EDE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "windows-terminal-quake", "windows-terminal-quake\windows-terminal-quake.csproj", "{7174B5DC-25D7-413D-B215-14FDC0278D0C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{1C9CDE72-0E19-42DC-BF4A-D1399AB6AEED}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
azure-pipelines.yml = azure-pipelines.yml
build.cake = build.cake
build.ps1 = build.ps1
.config\dotnet-tools.json = .config\dotnet-tools.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Schema", "Schema", "{2A5D241E-3682-411C-8463-3F67346ACFA7}"
ProjectSection(SolutionItems) = preProject
schema\windows-terminal-quake.schema.1.json = schema\windows-terminal-quake.schema.1.json
EndProjectSection
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{629FF3AD-5292-42A3-AE5E-1488D06C8E9F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{96A07892-69EC-49FB-84C4-3AE678EE3EDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96A07892-69EC-49FB-84C4-3AE678EE3EDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96A07892-69EC-49FB-84C4-3AE678EE3EDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96A07892-69EC-49FB-84C4-3AE678EE3EDE}.Release|Any CPU.Build.0 = Release|Any CPU
{7174B5DC-25D7-413D-B215-14FDC0278D0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7174B5DC-25D7-413D-B215-14FDC0278D0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7174B5DC-25D7-413D-B215-14FDC0278D0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7174B5DC-25D7-413D-B215-14FDC0278D0C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {872F04B6-D29D-4893-A0B9-73253354D678}
SolutionGuid = {65349C7B-F6B3-49A8-9935-4ABF9B6D3D70}
EndGlobalSection
EndGlobal
63 changes: 0 additions & 63 deletions windows-terminal-quake/AnimationTypeProvider.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace WindowsTerminalQuake.Settings;
namespace Wtq.Configuration;

public enum AnimationType
{
Expand Down
10 changes: 10 additions & 0 deletions windows-terminal-quake/Configuration/CreateProcessOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Wtq.Configuration;

public class CreateProcessOptions
{
[NotNull]
[Required]
public string? FileName { get; set; }

public IEnumerable<string> Arguments { get; set; } = Array.Empty<string>();
}
23 changes: 23 additions & 0 deletions windows-terminal-quake/Configuration/FindProcessOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Diagnostics;

namespace Wtq.Configuration;

public class FindProcessOptions
{
public string? ProcessName { get; set; }

public bool Filter(Process process)
{
if (process.MainWindowHandle == IntPtr.Zero)
{
return false;
}

if (!string.IsNullOrWhiteSpace(ProcessName))
{
return process.ProcessName.Equals(ProcessName, StringComparison.OrdinalIgnoreCase);
}

return false;
}
}
11 changes: 11 additions & 0 deletions windows-terminal-quake/Configuration/HotkeyOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Windows.Forms;
using Wtq.Native;

namespace Wtq.Configuration;

public class HotkeyOptions
{
public Keys Key { get; set; }

public KeyModifiers Modifiers { get; set; }
}
27 changes: 27 additions & 0 deletions windows-terminal-quake/Configuration/WtqAppOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Windows.Forms;
using Wtq.Native;

namespace Wtq.Configuration;

public class WtqAppOptions
{
public IEnumerable<HotkeyOptions> Hotkeys { get; set; } = Array.Empty<HotkeyOptions>();

[NotNull]
[Required]
public FindProcessOptions? FindExisting { get; set; }

[NotNull]
[Required]
public CreateProcessOptions? StartNew { get; set; }

public bool HasHotkey(Keys key, KeyModifiers modifiers)
{
return Hotkeys.Any(hk => hk.Key == key && hk.Modifiers == modifiers);
}

public override string ToString()
{
return FindExisting?.ProcessName ?? StartNew?.FileName ?? "<unknown>";
}
}
10 changes: 10 additions & 0 deletions windows-terminal-quake/Configuration/WtqOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Wtq.Configuration;

public sealed class WtqOptions
{
[Required]
public IEnumerable<WtqAppOptions> Apps { get; set; } = Enumerable.Empty<WtqAppOptions>();

[Required]
public IEnumerable<HotkeyOptions> Hotkeys { get; set; } = Enumerable.Empty<HotkeyOptions>();
}
18 changes: 18 additions & 0 deletions windows-terminal-quake/Exceptions/CancelRetryException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Wtq.Exceptions;

public sealed class CancelRetryException : Exception
{
public CancelRetryException()
{
}

public CancelRetryException(string message)
: base(message)
{
}

public CancelRetryException(string message, Exception innerException)
: base(message, innerException)
{
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace WindowsTerminalQuake.Exceptions;
namespace Wtq.Exceptions;

public sealed class WindowsTerminalQuakeException : Exception
{
Expand Down
18 changes: 7 additions & 11 deletions windows-terminal-quake/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
global using Polly;
global using Polly.Retry;
global using Serilog;
global using Microsoft.Extensions.Logging;
global using System.Drawing;
global using Wtq.Utils;
global using System;
global using System.Collections.Generic;
global using System.ComponentModel;
global using System.Diagnostics;
global using System.Drawing;
global using System.IO;
global using System.Linq;
global using System.Threading;
global using System.Text;
global using System.Threading.Tasks;
global using System.Windows.Forms;
global using WindowsTerminalQuake.Exceptions;
global using WindowsTerminalQuake.Settings;
global using System.ComponentModel.DataAnnotations;
global using System.Diagnostics.CodeAnalysis;

22 changes: 0 additions & 22 deletions windows-terminal-quake/Logging.cs

This file was deleted.

87 changes: 0 additions & 87 deletions windows-terminal-quake/Native/FocusTracker.cs

This file was deleted.

10 changes: 7 additions & 3 deletions windows-terminal-quake/Native/HotKeyManager.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
namespace WindowsTerminalQuake.Native;
using System.Threading;
using System.Windows.Forms;
using Wtq.Native.Win32;

namespace Wtq.Native;

/// <summary>
/// Wrapper around Windows Forms global hot key functionality. Surfaces an delegate to handle the hot key being pressed.
/// </summary>
public static class HotKeyManager
public static class HotkeyManager
{
/// <summary>
/// Fired when the registered hot key is pressed. Note that <see cref="RegisterHotKey"/> needs to be called first.
Expand Down Expand Up @@ -35,7 +39,7 @@ public static void UnregisterHotKey(int id)

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

static HotKeyManager()
static HotkeyManager()
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
{
Thread messageLoop = new(delegate ()
Expand Down
Loading

0 comments on commit 54f0d5c

Please sign in to comment.