From 1f1e904dcb3e6c1194b8dd602555a09b9376531a Mon Sep 17 00:00:00 2001 From: Matt Janda Date: Fri, 23 Dec 2022 16:16:20 +0000 Subject: [PATCH] Resolves #1 trigger capturing --- src/WinGif/Extensions.cs | 8 +++++++- src/WinGif/Program.cs | 2 ++ src/WinGif/Services/CaptureService.cs | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/WinGif/Extensions.cs b/src/WinGif/Extensions.cs index 5a9718b..533d8c8 100644 --- a/src/WinGif/Extensions.cs +++ b/src/WinGif/Extensions.cs @@ -8,11 +8,17 @@ namespace WinGif internal static class Extensions { + internal static IServiceProvider LogVersion(this IServiceProvider provider) { + var version = Assembly.GetExecutingAssembly().GetCustomAttribute()?.InformationalVersion; + + Program.Title = $"WinGif {version} by Matt Janda"; + Console.Title = Program.Title; + provider .GetRequiredService>() - .LogInformation("WinGif {version}", Assembly.GetExecutingAssembly().GetCustomAttribute()?.InformationalVersion); + .LogInformation("WinGif {version}", version); return provider; } diff --git a/src/WinGif/Program.cs b/src/WinGif/Program.cs index a2d7267..667d733 100644 --- a/src/WinGif/Program.cs +++ b/src/WinGif/Program.cs @@ -10,6 +10,8 @@ namespace WinGif { class Program { + internal static string Title { get; set; } + static void Main(string[] args) { try diff --git a/src/WinGif/Services/CaptureService.cs b/src/WinGif/Services/CaptureService.cs index 664a9ef..44d8759 100644 --- a/src/WinGif/Services/CaptureService.cs +++ b/src/WinGif/Services/CaptureService.cs @@ -41,7 +41,7 @@ public void StartCapture(ICaptureParameters parameters) if (text.Contains(parameters.WindowCaption) || (matched && !parameters.SingleWindow)) { // Do not capture itself - if (!parameters.SingleWindow && text.Contains("WinGif.exe") && !parameters.AllowSelfCapture) + if (!parameters.SingleWindow && text.Contains(Program.Title) && !parameters.AllowSelfCapture) { Thread.Sleep(parameters.CaptureDelay); continue;