mirror of
https://github.com/LorenzCK/OnTopReplica.git
synced 2024-05-21 04:43:55 +12:00
Improved title seeking (used from CLI when seeking for window by title).
This commit is contained in:
parent
6cd21971cf
commit
dc031dcdb1
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue