-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.xaml.cs
44 lines (38 loc) · 1.25 KB
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.IO;
using System.Windows.Forms;
using Hardcodet.Wpf.TaskbarNotification;
namespace Keyboard_Usurper
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : System.Windows.Application
{
private KeyboardHook _hook;
private TaskbarIcon notifyIcon;
[STAThread]
private void Usurp(object sender, StartupEventArgs e)
{
string jsonString = File.ReadAllText(Path.Combine(Environment.ExpandEnvironmentVariables("%HOMEDRIVE%%HOMEPATH%"), "usurper.json"));
Configuration config = JsonSerializer.Deserialize<Configuration>(jsonString);
_hook = new KeyboardHook(ConfigurationToMapping.Convert(config));
notifyIcon = (TaskbarIcon)FindResource("NotifyIcon");
// MainWindow main = new MainWindow();
// main.Show();
}
private void Unsurp(object sender, ExitEventArgs e)
{
notifyIcon.Dispose();
_hook.Uninstall();
}
}
}