From dc031dcdb11e6b6de9c3d3cf48834f5bf6797d24 Mon Sep 17 00:00:00 2001 From: Lorenz Cuno Klopfenstein Date: Wed, 16 Oct 2013 16:09:28 +0200 Subject: [PATCH] Improved title seeking (used from CLI when seeking for window by title). --- .../WindowSeekers/ByTitleWindowSeeker.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/OnTopReplica/WindowSeekers/ByTitleWindowSeeker.cs b/OnTopReplica/WindowSeekers/ByTitleWindowSeeker.cs index c551392..5850335 100644 --- a/OnTopReplica/WindowSeekers/ByTitleWindowSeeker.cs +++ b/OnTopReplica/WindowSeekers/ByTitleWindowSeeker.cs @@ -16,7 +16,7 @@ namespace OnTopReplica.WindowSeekers { if (titleSeekString == null) throw new ArgumentNullException(); - TitleMatch = titleSeekString.Trim(); + TitleMatch = titleSeekString.Trim().ToLowerInvariant(); } public string TitleMatch { get; private set; } @@ -30,15 +30,19 @@ namespace OnTopReplica.WindowSeekers { if (!WindowManagerMethods.IsTopLevel(handle.Handle)) return -1; + string handleTitle = handle.Title.ToLowerInvariant(); int points = 0; //Give points for partial match - if (handle.Title.StartsWith(TitleMatch, StringComparison.InvariantCultureIgnoreCase)) - points += 10; - - //Give points for exact match - if (handle.Title.Equals(TitleMatch, StringComparison.InvariantCultureIgnoreCase)) + if (handleTitle.Equals(TitleMatch)) { + points += 20; + } + else if (handleTitle.StartsWith(TitleMatch)) { + points += 15; + } + else if (handleTitle.Contains(TitleMatch)) { points += 10; + } return points; }