diff --git a/KeyboardMouseWin/KeyboardMouseWin.csproj b/KeyboardMouseWin/KeyboardMouseWin.csproj
index 8647f25..bf6936e 100644
--- a/KeyboardMouseWin/KeyboardMouseWin.csproj
+++ b/KeyboardMouseWin/KeyboardMouseWin.csproj
@@ -11,9 +11,20 @@
app.manifest
+
+
+
+
+
+
+ Always
+
+
+
+
diff --git a/KeyboardMouseWin/MainWindow.xaml.cs b/KeyboardMouseWin/MainWindow.xaml.cs
index caab084..b9ea656 100644
--- a/KeyboardMouseWin/MainWindow.xaml.cs
+++ b/KeyboardMouseWin/MainWindow.xaml.cs
@@ -20,6 +20,7 @@ namespace KeyboardMouseWin
///
public partial class MainWindow : Window
{
+
public MainWindow()
{
InitializeComponent();
diff --git a/KeyboardMouseWin/Program.cs b/KeyboardMouseWin/Program.cs
index dd093af..3a2ccec 100644
--- a/KeyboardMouseWin/Program.cs
+++ b/KeyboardMouseWin/Program.cs
@@ -1,25 +1,58 @@
using KeyboardMouseWin.Utils;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
using SharpHook;
using System.Windows;
-namespace KeyboardMouseWin
+namespace KeyboardMouseWin;
+
+public static class Program
{
- public static class Program
+ [STAThread]
+ public static void Main(string[] args)
{
- [STAThread]
- public static void Main(string[] args)
+ var hostbuilder = new HostBuilder()
+ .ConfigureAppConfiguration((context, configurationBuilder) =>
+ {
+ configurationBuilder.SetBasePath(context.HostingEnvironment.ContentRootPath);
+ configurationBuilder.AddJsonFile("appsettings.json", optional: false);
+ })
+ .ConfigureServices((context, services) =>
+ {
+ services.Configure(context.Configuration);
+
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton(sp =>
+ new CaptionViewModel(sp.GetRequiredService(), new FlauiProvider(), sp.GetRequiredService().Dispatcher));
+ })
+ .ConfigureLogging(logging =>
{
- var hook = new TaskPoolGlobalHook();
- hook.RunAsync();
- var service = new CaptionService();
- var window = new MainWindow();
- var viewModel = new CaptionViewModel(service, new FlauiProvider(), window.Dispatcher);
- hook.KeyPressed += async (_, e) => await viewModel.HandleKeyDown(SharpHookConverter.ToKey(e.Data.KeyCode), e);
- hook.KeyReleased += (_, e) => viewModel.HandleKeyUp(SharpHookConverter.ToKey(e.Data.KeyCode));
- window.DataContext = viewModel;
- var application = new Application();
- Task.Run(() => window.Dispatcher.Invoke(() => window.Hide()));
- application.Run(window);
- }
+ logging.AddConsole();
+ });
+
+ var host = hostbuilder.Build();
+
+ host.Start();
+
+
+
+ var hook = host.Services.GetRequiredService();
+ hook.RunAsync();
+
+ var viewModel = host.Services.GetRequiredService< CaptionViewModel>();
+ hook.KeyPressed += async (_, e) => await viewModel.HandleKeyDown(SharpHookConverter.ToKey(e.Data.KeyCode), e);
+ hook.KeyReleased += (_, e) => viewModel.HandleKeyUp(SharpHookConverter.ToKey(e.Data.KeyCode));
+
+ var window = host.Services.GetRequiredService();
+ window.DataContext = viewModel;
+
+
+ var application = new Application();
+ Task.Run(() => window.Dispatcher.Invoke(() => window.Hide()));
+ application.Run(window);
}
}
diff --git a/KeyboardMouseWin/WelcomeWindow.xaml b/KeyboardMouseWin/WelcomeWindow.xaml
index b4b8876..3e6d294 100644
--- a/KeyboardMouseWin/WelcomeWindow.xaml
+++ b/KeyboardMouseWin/WelcomeWindow.xaml
@@ -7,9 +7,12 @@
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:WelcomeWindowViewModel}"
Title="Welcome" Height="450" Width="800">
+
+
+
-
+
+
+
+
+
-
-
+
+
-
-
+
+
+ HorizontalAlignment="Right" VerticalAlignment="Bottom"
+ Orientation="Horizontal"
+ Margin="10">
+
diff --git a/KeyboardMouseWin/appsettings.json b/KeyboardMouseWin/appsettings.json
new file mode 100644
index 0000000..cae1649
--- /dev/null
+++ b/KeyboardMouseWin/appsettings.json
@@ -0,0 +1,14 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Trace"
+ },
+ "Console": {
+ "LogLevel": {
+ "Default": "Trace"
+ },
+ "IncludeScopes": true,
+ "TimestampFormat": "HH:mm:ss"
+ }
+ }
+}
\ No newline at end of file