mirror of
https://github.com/LorenzCK/OnTopReplica.git
synced 2024-06-03 11:04:32 +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)
|
if (titleSeekString == null)
|
||||||
throw new ArgumentNullException();
|
throw new ArgumentNullException();
|
||||||
|
|
||||||
TitleMatch = titleSeekString.Trim();
|
TitleMatch = titleSeekString.Trim().ToLowerInvariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string TitleMatch { get; private set; }
|
public string TitleMatch { get; private set; }
|
||||||
|
@ -30,15 +30,19 @@ namespace OnTopReplica.WindowSeekers {
|
||||||
if (!WindowManagerMethods.IsTopLevel(handle.Handle))
|
if (!WindowManagerMethods.IsTopLevel(handle.Handle))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
string handleTitle = handle.Title.ToLowerInvariant();
|
||||||
int points = 0;
|
int points = 0;
|
||||||
|
|
||||||
//Give points for partial match
|
//Give points for partial match
|
||||||
if (handle.Title.StartsWith(TitleMatch, StringComparison.InvariantCultureIgnoreCase))
|
if (handleTitle.Equals(TitleMatch)) {
|
||||||
points += 10;
|
points += 20;
|
||||||
|
}
|
||||||
//Give points for exact match
|
else if (handleTitle.StartsWith(TitleMatch)) {
|
||||||
if (handle.Title.Equals(TitleMatch, StringComparison.InvariantCultureIgnoreCase))
|
points += 15;
|
||||||
|
}
|
||||||
|
else if (handleTitle.Contains(TitleMatch)) {
|
||||||
points += 10;
|
points += 10;
|
||||||
|
}
|
||||||
|
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue