diff --git a/src/GenshinFishingToy.sln b/src/GenshinFishingToy.sln
index db6546e..1b60c56 100644
--- a/src/GenshinFishingToy.sln
+++ b/src/GenshinFishingToy.sln
@@ -7,6 +7,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenshinFishingToy", "Genshi
EndProject
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "GenshinFishingToySetup", "GenshinFishingToySetup\GenshinFishingToySetup.wapproj", "{A80A34DD-ACBC-4D67-A22D-156A0FFC32A8}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WindowsGraphicsCapture", "WindowsGraphicsCapture", "{61B278E1-2049-475B-B200-3F0C3DDA87C2}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScreenCapture", "WindowsGraphicsCapture\ScreenCapture\ScreenCapture.csproj", "{AB145A23-0897-4517-8EA6-BEB87CB9D26A}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CaptureSampleCore", "WindowsGraphicsCapture\CaptureSampleCore\CaptureSampleCore.csproj", "{D8154C31-38C2-49E2-96A0-69EB76567461}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Composition.WindowsRuntimeHelpers", "WindowsGraphicsCapture\Composition.WindowsRuntimeHelpers\Composition.WindowsRuntimeHelpers.csproj", "{AE6F99F5-AFD5-467E-A082-D4003E3EEECF}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -23,10 +31,27 @@ Global
{A80A34DD-ACBC-4D67-A22D-156A0FFC32A8}.Release|x64.ActiveCfg = Release|x64
{A80A34DD-ACBC-4D67-A22D-156A0FFC32A8}.Release|x64.Build.0 = Release|x64
{A80A34DD-ACBC-4D67-A22D-156A0FFC32A8}.Release|x64.Deploy.0 = Release|x64
+ {AB145A23-0897-4517-8EA6-BEB87CB9D26A}.Debug|x64.ActiveCfg = Debug|x64
+ {AB145A23-0897-4517-8EA6-BEB87CB9D26A}.Debug|x64.Build.0 = Debug|x64
+ {AB145A23-0897-4517-8EA6-BEB87CB9D26A}.Release|x64.ActiveCfg = Release|x64
+ {AB145A23-0897-4517-8EA6-BEB87CB9D26A}.Release|x64.Build.0 = Release|x64
+ {D8154C31-38C2-49E2-96A0-69EB76567461}.Debug|x64.ActiveCfg = Debug|x64
+ {D8154C31-38C2-49E2-96A0-69EB76567461}.Debug|x64.Build.0 = Debug|x64
+ {D8154C31-38C2-49E2-96A0-69EB76567461}.Release|x64.ActiveCfg = Release|x64
+ {D8154C31-38C2-49E2-96A0-69EB76567461}.Release|x64.Build.0 = Release|x64
+ {AE6F99F5-AFD5-467E-A082-D4003E3EEECF}.Debug|x64.ActiveCfg = Debug|x64
+ {AE6F99F5-AFD5-467E-A082-D4003E3EEECF}.Debug|x64.Build.0 = Debug|x64
+ {AE6F99F5-AFD5-467E-A082-D4003E3EEECF}.Release|x64.ActiveCfg = Release|x64
+ {AE6F99F5-AFD5-467E-A082-D4003E3EEECF}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {AB145A23-0897-4517-8EA6-BEB87CB9D26A} = {61B278E1-2049-475B-B200-3F0C3DDA87C2}
+ {D8154C31-38C2-49E2-96A0-69EB76567461} = {61B278E1-2049-475B-B200-3F0C3DDA87C2}
+ {AE6F99F5-AFD5-467E-A082-D4003E3EEECF} = {61B278E1-2049-475B-B200-3F0C3DDA87C2}
+ EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DFA8F1CD-513D-45D7-856D-378146C4D367}
EndGlobalSection
diff --git a/src/GenshinFishingToy/App.xaml.cs b/src/GenshinFishingToy/App.xaml.cs
index d19c399..68cf57c 100644
--- a/src/GenshinFishingToy/App.xaml.cs
+++ b/src/GenshinFishingToy/App.xaml.cs
@@ -1,4 +1,5 @@
-using GenshinFishingToy.Core;
+using Composition.WindowsRuntimeHelpers;
+using GenshinFishingToy.Core;
using GenshinFishingToy.ViewModels;
using Hardcodet.Wpf.TaskbarNotification;
using Microsoft.Toolkit.Uwp.Notifications;
@@ -9,11 +10,13 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
+using Windows.System;
namespace GenshinFishingToy;
public partial class App : Application
{
+ private DispatcherQueueController _controller;
public static new App? Current { get; protected set; } = null!;
public TaskbarIcon Taskbar { get; protected set; } = null!;
public static bool IsElevated { get; } = GetElevated();
@@ -23,6 +26,7 @@ public App()
Logger.Info("Startup");
Current = this;
Current.DispatcherUnhandledException += (_, e) => e.Handled = true;
+ _controller = CoreMessagingHelper.CreateDispatcherQueueControllerForCurrentThread();
AppDomain.CurrentDomain.UnhandledException += (s, e) => Logger.Error(e);
ToastNotificationManagerCompat.OnActivated += NotifyIconViewModel.OnNotificationActivated;
NoticeService.ClearNotice();
diff --git a/src/GenshinFishingToy/Core/ImageCapture.cs b/src/GenshinFishingToy/Core/ImageCapture.cs
index 0f8f9a8..ea9d610 100644
--- a/src/GenshinFishingToy/Core/ImageCapture.cs
+++ b/src/GenshinFishingToy/Core/ImageCapture.cs
@@ -1,6 +1,8 @@
using System;
using System.Drawing;
+using System.Text.RegularExpressions;
using System.Windows;
+using WPFCaptureSample;
namespace GenshinFishingToy.Core;
@@ -11,6 +13,8 @@ internal static class ImageCapture
public static int W { get; set; }
public static int H { get; set; }
+ public static ImageCaptureType CaptureType = ImageCaptureType.WindowsGraphicsCapture;
+
public static void Setup(int x, int y, int w, int h)
{
X = x;
@@ -24,6 +28,11 @@ public static void Setup((int x, int y, int w, int h) rect)
Setup(rect.x, rect.y, rect.w, rect.h);
}
+ public static void Teardown()
+ {
+ GraphicsCapture.Uncapture();
+ }
+
public static bool IsFullScreen { get; private set; } = false;
public static bool IsFullScreenMode(IntPtr hwnd)
{
@@ -52,11 +61,40 @@ private static int GetCaptionHeight(IntPtr? hwnd = null)
public static Bitmap Capture(IntPtr? hwnd = null)
{
- return ImageExtension.Capture(X, Y - GetCaptionHeight(hwnd), W, H, hwnd);
+ if (CaptureType == ImageCaptureType.BitBlt)
+ {
+ return ImageExtension.Capture(X, Y - GetCaptionHeight(hwnd), W, H, hwnd);
+ }
+ else if (CaptureType == ImageCaptureType.WindowsGraphicsCapture)
+ {
+ return GraphicsCapture.Capture(X, Y, W, H, hwnd);
+ }
+ return null!;
}
public static Bitmap CaptureLiftingWords(IntPtr? hwnd = null)
{
- return ImageExtension.Capture(X, Y - GetCaptionHeight(hwnd) + H, W, (int)(H * 2.5d), hwnd);
+ if (CaptureType == ImageCaptureType.BitBlt)
+ {
+ return ImageExtension.Capture(X, Y - GetCaptionHeight(hwnd) + H, W, (int)(H * 2.5d), hwnd);
+ }
+ else if (CaptureType == ImageCaptureType.WindowsGraphicsCapture)
+ {
+ return GraphicsCapture.Capture(X, Y + H, W, (int)(H * 2.5d), hwnd);
+ }
+ return null!;
}
}
+
+public enum ImageCaptureType
+{
+ ///
+ /// BitBlt (Windows 7 and up)
+ ///
+ BitBlt,
+
+ ///
+ /// Windows 10 (1903 and up)
+ ///
+ WindowsGraphicsCapture,
+}
diff --git a/src/GenshinFishingToy/Core/ImageJigging.cs b/src/GenshinFishingToy/Core/ImageJigging.cs
index a8a2588..10f3f40 100644
--- a/src/GenshinFishingToy/Core/ImageJigging.cs
+++ b/src/GenshinFishingToy/Core/ImageJigging.cs
@@ -29,11 +29,19 @@ internal class ImageJigging
public bool IsRunning { get; protected set; } = false;
+ private Preview previewForm = null!;
+
public ImageJigging()
{
timerCapture.Tick += Tick;
timerCapture.Interval = Convert.ToInt32(1000d / frameRate);
timerCapture.Start();
+ previewForm = new();
+
+ if (Settings.ShowRecognitionCapture.Get())
+ {
+ previewForm.Show();
+ }
}
public async Task StartFishing()
@@ -47,6 +55,7 @@ public async Task StopFishing()
IsRunning = false;
findFishBoxTips = false;
isFishingProcess = false;
+ ImageCapture.Teardown();
}
public async void Tick(object? sender, EventArgs e)
@@ -102,6 +111,7 @@ public async void Tick(object? sender, EventArgs e)
ImageCapture.Setup(rect);
using Bitmap captured = ImageCapture.Capture(window.Hwnd);
+ previewForm.SetImage(captured);
rects = ImageRecognition.GetRect(captured, Settings.ShowRecognitionJigging);
window.MotionArea.Rects = rects?.ToArray() ?? Array.Empty();
diff --git a/src/GenshinFishingToy/FodyWeavers.xml b/src/GenshinFishingToy/FodyWeavers.xml
new file mode 100644
index 0000000..5029e70
--- /dev/null
+++ b/src/GenshinFishingToy/FodyWeavers.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/src/GenshinFishingToy/FodyWeavers.xsd b/src/GenshinFishingToy/FodyWeavers.xsd
new file mode 100644
index 0000000..05e92c1
--- /dev/null
+++ b/src/GenshinFishingToy/FodyWeavers.xsd
@@ -0,0 +1,141 @@
+
+
+
+
+
+
+
+
+
+
+
+ A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks
+
+
+
+
+ A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.
+
+
+
+
+ A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks
+
+
+
+
+ A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.
+
+
+
+
+ A list of unmanaged 32 bit assembly names to include, delimited with line breaks.
+
+
+
+
+ A list of unmanaged 64 bit assembly names to include, delimited with line breaks.
+
+
+
+
+ The order of preloaded assemblies, delimited with line breaks.
+
+
+
+
+
+ This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.
+
+
+
+
+ Controls if .pdbs for reference assemblies are also embedded.
+
+
+
+
+ Controls if runtime assemblies are also embedded.
+
+
+
+
+ Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.
+
+
+
+
+ Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.
+
+
+
+
+ As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.
+
+
+
+
+ Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.
+
+
+
+
+ Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.
+
+
+
+
+ A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |
+
+
+
+
+ A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.
+
+
+
+
+ A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |
+
+
+
+
+ A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.
+
+
+
+
+ A list of unmanaged 32 bit assembly names to include, delimited with |.
+
+
+
+
+ A list of unmanaged 64 bit assembly names to include, delimited with |.
+
+
+
+
+ The order of preloaded assemblies, delimited with |.
+
+
+
+
+
+
+
+ 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.
+
+
+
+
+ A comma-separated list of error codes that can be safely ignored in assembly verification.
+
+
+
+
+ 'false' to turn off automatic generation of the XML Schema file.
+
+
+
+
+
\ No newline at end of file
diff --git a/src/GenshinFishingToy/GenshinFishingToy.csproj b/src/GenshinFishingToy/GenshinFishingToy.csproj
index 49088c4..87a716c 100644
--- a/src/GenshinFishingToy/GenshinFishingToy.csproj
+++ b/src/GenshinFishingToy/GenshinFishingToy.csproj
@@ -1,74 +1,85 @@
-
- WinExe
- net6.0-windows10.0.18362.0
- enable
- true
- true
- Resources\favicon.ico
- app.manifest
- x64
- 1.4.1
- 1.4.1
- $(VersionPrefix)1.4.1
- GenshinMatrix
- GenshinMatrix
- True
-
-
+
+ WinExe
+ net48
+ enable
+ 11.0
+ True
+ true
+ Resources\favicon.ico
+ app.manifest
+ x64
+ 1.5.0
+ 1.5.0
+ $(VersionPrefix)1.5.0
+ GenshinMatrix
+ GenshinMatrix
+ True
+
+
-
- 1701;1702;1998;
- $(DefineConstants)TRACE;
-
+
+ 1701;1702;1998;
+ $(DefineConstants)TRACE;
+
-
- 1701;1702;1998;
- $(DefineConstants)TRACE;
-
+
+ 1701;1702;1998;
+ $(DefineConstants)TRACE;
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ all
+ compile; runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/GenshinFishingToy/Models/Settings.cs b/src/GenshinFishingToy/Models/Settings.cs
index cce15d2..4c99004 100644
--- a/src/GenshinFishingToy/Models/Settings.cs
+++ b/src/GenshinFishingToy/Models/Settings.cs
@@ -11,7 +11,9 @@ public class Settings
public static SettingsDefinition<(int, int, int, int)> JigRect { get; } = new(nameof(JigRect), (100, 100, 450, 100));
public static SettingsDefinition FullScreenWhenSaved { get; } = new(nameof(FullScreenWhenSaved), false);
public static SettingsDefinition Lock { get; } = new(nameof(Lock), false);
+ public static SettingsDefinition CaptureType { get; } = new(nameof(CaptureType), "WindowsGraphicsCapture");
public static SettingsDefinition AutoLifting { get; } = new(nameof(AutoLifting), true);
+ public static SettingsDefinition ShowRecognitionCapture { get; } = new(nameof(ShowRecognitionCapture), false);
public static SettingsDefinition ShowRecognitionJigging { get; } = new(nameof(ShowRecognitionJigging), false);
public static SettingsDefinition ShowRecognitionLifting { get; } = new(nameof(ShowRecognitionLifting), false);
}
diff --git a/src/GenshinFishingToy/Resources/Languages/en-us.xaml b/src/GenshinFishingToy/Resources/Languages/en-us.xaml
index 64ca6c0..9b61daf 100644
--- a/src/GenshinFishingToy/Resources/Languages/en-us.xaml
+++ b/src/GenshinFishingToy/Resources/Languages/en-us.xaml
@@ -19,12 +19,16 @@
Language
We only support running on an OS version higher than {0}. Your OS version is {1}.
Auto Lifting
+ Show captupe recognition (Debug)
Show jigging recognition (Debug)
Show lifting recognition (Debug)
Jigging recognition debug
Lifting recognition debug
Lock fishing region
Reset fishing region
+ Image Capture Type
+ BitBlt (Windows 7 and up)
+ Windows 10 (1903 and up)
Not started
Started
Open Config File
diff --git a/src/GenshinFishingToy/Resources/Languages/jp.xaml b/src/GenshinFishingToy/Resources/Languages/jp.xaml
index dcfca44..f53a0dc 100644
--- a/src/GenshinFishingToy/Resources/Languages/jp.xaml
+++ b/src/GenshinFishingToy/Resources/Languages/jp.xaml
@@ -19,12 +19,16 @@
言語
本プログラムはOSバージョンが{0}もしくはそれより高いOSバージョンのみサポートしています。あなたのOSバージョンは{1}です。
自動リフティング
+ キャプチャ画像を表示(デバッグ)
釣りの識別を表示(デバッグ)
リフティングの識別を表示(デバッグ)
釣り識別デバッグ
リフティング識別デバッグ
釣り枠をロック
釣り枠をリセット
+ 画像キャプチャモード
+ BitBlt (Windows 7 以降)
+ Windows 10 (1903以降)
スタート待ち
スタート済み
配置ファイルを開く
diff --git a/src/GenshinFishingToy/Resources/Languages/zh-cn.xaml b/src/GenshinFishingToy/Resources/Languages/zh-cn.xaml
index 6e40f59..2fd2507 100644
--- a/src/GenshinFishingToy/Resources/Languages/zh-cn.xaml
+++ b/src/GenshinFishingToy/Resources/Languages/zh-cn.xaml
@@ -19,12 +19,16 @@
语言
我们仅支持系统版本高于{0}。您的系统版本为{1}。
自动提竿
+ 显示采集识别(调试)
显示饵钓识别(调试)
显示提竿识别(调试)
饵钓识别调试
提竿识别调试
锁定钓鱼框
重置钓鱼框
+ 图像采集模式
+ BitBlt (Windows 7 或更新版本)
+ Windows 10 (1903或更新版本)
未启动
已启动
打开配置文件
diff --git a/src/GenshinFishingToy/ViewModels/MainViewModel.cs b/src/GenshinFishingToy/ViewModels/MainViewModel.cs
index 6194e45..b9d8354 100644
--- a/src/GenshinFishingToy/ViewModels/MainViewModel.cs
+++ b/src/GenshinFishingToy/ViewModels/MainViewModel.cs
@@ -15,7 +15,7 @@
namespace GenshinFishingToy.ViewModels;
-public class MainViewModel : ObservableRecipient
+public partial class MainViewModel : ObservableRecipient
{
public MainWindow Source { get; set; } = null!;
internal ImageJigging jigging = new();
@@ -55,6 +55,16 @@ public bool OptionShowRecognitionJigging
}
}
+ public bool OptionShowRecognitionCapture
+ {
+ get => Settings.ShowRecognitionCapture;
+ set
+ {
+ Settings.ShowRecognitionCapture.Set(value);
+ SettingsManager.Save();
+ }
+ }
+
public bool OptionShowRecognitionLifting
{
get => Settings.ShowRecognitionLifting;
@@ -213,4 +223,24 @@ public async Task StopFishing()
{
await jigging.StopFishing();
}
+
+ [ObservableProperty]
+ private bool isImageCaptureTypeIsBitBlt = Settings.CaptureType.Get().Equals(nameof(ImageCaptureType.BitBlt));
+
+ [ObservableProperty]
+ private bool isImageCaptureTypeIsWindowsGraphicsCapture = Settings.CaptureType.Get().Equals(nameof(ImageCaptureType.WindowsGraphicsCapture));
+
+ [RelayCommand]
+ public void SetImageCaptureType(string captureType)
+ {
+ if (jigging.IsRunning)
+ {
+ IsImageCaptureTypeIsBitBlt = Settings.CaptureType.Get().Equals(nameof(ImageCaptureType.BitBlt));
+ IsImageCaptureTypeIsWindowsGraphicsCapture = Settings.CaptureType.Get().Equals(nameof(ImageCaptureType.WindowsGraphicsCapture));
+ return;
+ }
+ ImageCapture.CaptureType = (ImageCaptureType)Enum.Parse(typeof(ImageCaptureType), captureType);
+ Settings.CaptureType.Set(ImageCapture.CaptureType.ToString());
+ SettingsManager.Save();
+ }
}
diff --git a/src/GenshinFishingToy/ViewModels/NotifyIconViewModel.cs b/src/GenshinFishingToy/ViewModels/NotifyIconViewModel.cs
index 1f7e4c0..d5988b6 100644
--- a/src/GenshinFishingToy/ViewModels/NotifyIconViewModel.cs
+++ b/src/GenshinFishingToy/ViewModels/NotifyIconViewModel.cs
@@ -72,7 +72,7 @@ public static void OnNotificationActivated(ToastNotificationActivatedEventArgsCo
foreach (KeyValuePair arg in args)
{
- (string k, string v) = arg;
+ (string k, string v) = (arg.Key, arg.Value);
if (k == "" && v == "")
{
diff --git a/src/GenshinFishingToy/Views/MainWindow.xaml b/src/GenshinFishingToy/Views/MainWindow.xaml
index 207fcee..c297498 100644
--- a/src/GenshinFishingToy/Views/MainWindow.xaml
+++ b/src/GenshinFishingToy/Views/MainWindow.xaml
@@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GenshinFishingToy.Views"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
+ xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
xmlns:main="clr-namespace:GenshinFishingToy"
mc:Ignorable="d" Closed="MainWindowClosed"
@@ -119,6 +120,11 @@
+
+
+