Update ScreenMatch.cs

This commit is contained in:
Namhyeon Go 2024-09-18 15:01:05 +09:00
parent 27e9a328d4
commit c36d7fb71f

View File

@ -369,8 +369,6 @@ public class ScreenMatch
}
Bitmap image = templateImages[templateCurrentIndex];
parent.Log($"Trying match the template {image.Tag as string} on the screen {i}...");
string templateName = image.Tag as string;
Size templateSize = new Size
{
@ -378,6 +376,8 @@ public class ScreenMatch
Height = image.Height
};
parent.Log($"Trying match the template {templateName} on the screen {i}...");
Bitmap _mainImage;
if (templateName.StartsWith("binary_"))
{
@ -398,7 +398,7 @@ public class ScreenMatch
results.Add(new ScreenMatchResult
{
FileName = image.Tag.ToString(),
FileName = templateName,
ScreenNumber = i,
Position = matchPosition,
Text = text
@ -559,19 +559,36 @@ public class ScreenMatch
if (windowImage != null)
{
Bitmap image = templateImages[templateCurrentIndex];
string templateName = image.Tag as string;
Size templateSize = new Size
{
Width = image.Width,
Height = image.Height
};
List<Point> matchPositions = FindTemplate(windowImage, image);
matchPositions.ForEach((matchPosition) =>
{
string templateName = image.Tag as string;
results.Add(new ScreenMatchResult
try
{
FileName = templateName,
WindowHandle = hWnd,
WindowTitle = windowTitle,
ProcessName = processName,
WindowPosition = windowPosition,
Position = matchPosition
});
string text = sampleAny.Contains(templateName) ?
InspectSample((Bitmap)windowImage.Clone(), matchPosition, templateSize, templateName, sampleSize) : string.Empty;
results.Add(new ScreenMatchResult
{
FileName = templateName,
WindowHandle = hWnd,
WindowTitle = windowTitle,
ProcessName = processName,
WindowPosition = windowPosition,
Position = matchPosition,
Text = text
});
}
catch (Exception ex)
{
parent.Log($"Ignore the match. {ex.Message}");
}
});
}
}