From 1e9e2d00e0ebf87f2fbf736ef3b34b90232f1f3a Mon Sep 17 00:00:00 2001 From: Myuuiii Date: Tue, 27 Dec 2022 16:57:12 +0100 Subject: [PATCH] Ableton regex to trim [ProjectName] from title --- DAWPresence/DAWs/AbletonLive10Intro.cs | 8 ++++++-- DAWPresence/DAWs/AbletonLive10Standard.cs | 8 ++++++-- DAWPresence/DAWs/AbletonLive10Suite.cs | 8 ++++++-- DAWPresence/DAWs/AbletonLive11Intro.cs | 8 ++++++-- DAWPresence/DAWs/AbletonLive11Standard.cs | 8 ++++++-- DAWPresence/DAWs/AbletonLive11Suite.cs | 10 +++++++--- DAWPresence/DAWs/AbletonLive9Intro.cs | 8 ++++++-- DAWPresence/DAWs/AbletonLive9Standard.cs | 8 ++++++-- DAWPresence/DAWs/AbletonLive9Suite.cs | 8 ++++++-- 9 files changed, 55 insertions(+), 19 deletions(-) diff --git a/DAWPresence/DAWs/AbletonLive10Intro.cs b/DAWPresence/DAWs/AbletonLive10Intro.cs index b4617b4..6e07d4e 100644 --- a/DAWPresence/DAWs/AbletonLive10Intro.cs +++ b/DAWPresence/DAWs/AbletonLive10Intro.cs @@ -1,8 +1,9 @@ using System.Diagnostics; +using System.Text.RegularExpressions; namespace DAWPresence.DAWs; -public class AbletonLive10Intro : Daw +public partial class AbletonLive10Intro : Daw { public AbletonLive10Intro() { @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow() if (process is null) return ""; string title = process.MainWindowTitle; return title.Contains(WindowTrim) - ? title[..^TitleOffset] + ? TitleRegex().Match(title[..^TitleOffset]).Value : ""; } + + [GeneratedRegex("[^\\[]*")] + private static partial Regex TitleRegex(); } \ No newline at end of file diff --git a/DAWPresence/DAWs/AbletonLive10Standard.cs b/DAWPresence/DAWs/AbletonLive10Standard.cs index 536e88f..d994748 100644 --- a/DAWPresence/DAWs/AbletonLive10Standard.cs +++ b/DAWPresence/DAWs/AbletonLive10Standard.cs @@ -1,8 +1,9 @@ using System.Diagnostics; +using System.Text.RegularExpressions; namespace DAWPresence.DAWs; -public class AbletonLive10Standard : Daw +public partial class AbletonLive10Standard : Daw { public AbletonLive10Standard() { @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow() if (process is null) return ""; string title = process.MainWindowTitle; return title.Contains(WindowTrim) - ? title[..^TitleOffset] + ? TitleRegex().Match(title[..^TitleOffset]).Value : ""; } + + [GeneratedRegex("[^\\[]*")] + private static partial Regex TitleRegex(); } \ No newline at end of file diff --git a/DAWPresence/DAWs/AbletonLive10Suite.cs b/DAWPresence/DAWs/AbletonLive10Suite.cs index 6278cbd..eef8c08 100644 --- a/DAWPresence/DAWs/AbletonLive10Suite.cs +++ b/DAWPresence/DAWs/AbletonLive10Suite.cs @@ -1,8 +1,9 @@ using System.Diagnostics; +using System.Text.RegularExpressions; namespace DAWPresence.DAWs; -public class AbletonLive10Suite : Daw +public partial class AbletonLive10Suite : Daw { public AbletonLive10Suite() { @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow() if (process is null) return ""; string title = process.MainWindowTitle; return title.Contains(WindowTrim) - ? title[..^TitleOffset] + ? TitleRegex().Match(title[..^TitleOffset]).Value : ""; } + + [GeneratedRegex("[^\\[]*")] + private static partial Regex TitleRegex(); } \ No newline at end of file diff --git a/DAWPresence/DAWs/AbletonLive11Intro.cs b/DAWPresence/DAWs/AbletonLive11Intro.cs index a837c26..ecb166d 100644 --- a/DAWPresence/DAWs/AbletonLive11Intro.cs +++ b/DAWPresence/DAWs/AbletonLive11Intro.cs @@ -1,8 +1,9 @@ using System.Diagnostics; +using System.Text.RegularExpressions; namespace DAWPresence.DAWs; -public class AbletonLive11Intro : Daw +public partial class AbletonLive11Intro : Daw { public AbletonLive11Intro() { @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow() if (process is null) return ""; string title = process.MainWindowTitle; return title.Contains(WindowTrim) - ? title[..^TitleOffset] + ? TitleRegex().Match(title[..^TitleOffset]).Value : ""; } + + [GeneratedRegex("[^\\[]*")] + private static partial Regex TitleRegex(); } \ No newline at end of file diff --git a/DAWPresence/DAWs/AbletonLive11Standard.cs b/DAWPresence/DAWs/AbletonLive11Standard.cs index 2d18bd8..fa28d9e 100644 --- a/DAWPresence/DAWs/AbletonLive11Standard.cs +++ b/DAWPresence/DAWs/AbletonLive11Standard.cs @@ -1,8 +1,9 @@ using System.Diagnostics; +using System.Text.RegularExpressions; namespace DAWPresence.DAWs; -public class AbletonLive11Standard : Daw +public partial class AbletonLive11Standard : Daw { public AbletonLive11Standard() { @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow() if (process is null) return ""; string title = process.MainWindowTitle; return title.Contains(WindowTrim) - ? title[..^TitleOffset] + ? TitleRegex().Match(title[..^TitleOffset]).Value : ""; } + + [GeneratedRegex("[^\\[]*")] + private static partial Regex TitleRegex(); } \ No newline at end of file diff --git a/DAWPresence/DAWs/AbletonLive11Suite.cs b/DAWPresence/DAWs/AbletonLive11Suite.cs index ec0723c..5dcfcc8 100644 --- a/DAWPresence/DAWs/AbletonLive11Suite.cs +++ b/DAWPresence/DAWs/AbletonLive11Suite.cs @@ -1,14 +1,15 @@ using System.Diagnostics; +using System.Text.RegularExpressions; namespace DAWPresence.DAWs; -public class AbletonLive11Suite : Daw +public partial class AbletonLive11Suite : Daw { public AbletonLive11Suite() { ProcessName = "Ableton Live 11 Suite"; DisplayName = ProcessName; - ImageKey = "ableton-white"; + ImageKey = "ableton"; ApplicationId = "1053952444859686983"; WindowTrim = " - " + DisplayName; TitleOffset = 24; @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow() if (process is null) return ""; string title = process.MainWindowTitle; return title.Contains(WindowTrim) - ? title[..^TitleOffset] + ? TitleRegex().Match(title[..^TitleOffset]).Value : ""; } + + [GeneratedRegex("[^\\[]*")] + private static partial Regex TitleRegex(); } \ No newline at end of file diff --git a/DAWPresence/DAWs/AbletonLive9Intro.cs b/DAWPresence/DAWs/AbletonLive9Intro.cs index b6ba8d7..6a27ea7 100644 --- a/DAWPresence/DAWs/AbletonLive9Intro.cs +++ b/DAWPresence/DAWs/AbletonLive9Intro.cs @@ -1,8 +1,9 @@ using System.Diagnostics; +using System.Text.RegularExpressions; namespace DAWPresence.DAWs; -public class AbletonLive9Intro : Daw +public partial class AbletonLive9Intro : Daw { public AbletonLive9Intro() { @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow() if (process is null) return ""; string title = process.MainWindowTitle; return title.Contains(WindowTrim) - ? title[..^TitleOffset] + ? TitleRegex().Match(title[..^TitleOffset]).Value : ""; } + + [GeneratedRegex("[^\\[]*")] + private static partial Regex TitleRegex(); } \ No newline at end of file diff --git a/DAWPresence/DAWs/AbletonLive9Standard.cs b/DAWPresence/DAWs/AbletonLive9Standard.cs index 7a56eb0..8dbe080 100644 --- a/DAWPresence/DAWs/AbletonLive9Standard.cs +++ b/DAWPresence/DAWs/AbletonLive9Standard.cs @@ -1,8 +1,9 @@ using System.Diagnostics; +using System.Text.RegularExpressions; namespace DAWPresence.DAWs; -public class AbletonLive9Standard : Daw +public partial class AbletonLive9Standard : Daw { public AbletonLive9Standard() { @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow() if (process is null) return ""; string title = process.MainWindowTitle; return title.Contains(WindowTrim) - ? title[..^TitleOffset] + ? TitleRegex().Match(title[..^TitleOffset]).Value : ""; } + + [GeneratedRegex("[^\\[]*")] + private static partial Regex TitleRegex(); } \ No newline at end of file diff --git a/DAWPresence/DAWs/AbletonLive9Suite.cs b/DAWPresence/DAWs/AbletonLive9Suite.cs index 4a179cd..97db064 100644 --- a/DAWPresence/DAWs/AbletonLive9Suite.cs +++ b/DAWPresence/DAWs/AbletonLive9Suite.cs @@ -1,8 +1,9 @@ using System.Diagnostics; +using System.Text.RegularExpressions; namespace DAWPresence.DAWs; -public class AbletonLive9Suite : Daw +public partial class AbletonLive9Suite : Daw { public AbletonLive9Suite() { @@ -20,7 +21,10 @@ public override string GetProjectNameFromProcessWindow() if (process is null) return ""; string title = process.MainWindowTitle; return title.Contains(WindowTrim) - ? title[..^TitleOffset] + ? TitleRegex().Match(title[..^TitleOffset]).Value : ""; } + + [GeneratedRegex("[^\\[]*")] + private static partial Regex TitleRegex(); } \ No newline at end of file