-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.cs
97 lines (84 loc) · 2.44 KB
/
Config.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using AlwaysOnTop.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AlwaysOnTop
{
public partial class Config : Form
{
private static readonly string SettingStr = "설정 중";
private static readonly string SettingIdleStr = "설정";
private bool nowTopMost_ON_Setting = false;
private bool nowTopMost_OFF_Setting = false;
public Config()
{
InitializeComponent();
topMost_ON_button.Click += TopMost_ON;
topMost_OFF_button.Click += TopMost_OFF;
Program.hookCallback += KeyHook;
ReloadAll();
}
protected override void OnFormClosing(FormClosingEventArgs e)
{
Program.hookCallback -= KeyHook;
base.OnFormClosing(e);
}
private void ReloadAll()
{
topMost_ON_textBox.Text = Settings.Default.TopMost_ON;
topMost_OFF_textBox.Text = Settings.Default.TopMost_OFF;
}
private void TopMost_ON(object sender, EventArgs e)
{
if (nowTopMost_OFF_Setting) return;
if (nowTopMost_ON_Setting)
{
Settings.Default.TopMost_ON = string.IsNullOrEmpty(topMost_ON_textBox.Text) ? Settings.Default.TopMost_ON : topMost_ON_textBox.Text;
nowTopMost_ON_Setting = false;
MainContext.Get.IsBlockingKeyInput = false;
topMost_ON_button.Text = SettingIdleStr;
Settings.Default.Save();
} else
{
Settings.Default.TopMost_ON = string.Empty;
nowTopMost_ON_Setting = true;
MainContext.Get.IsBlockingKeyInput = true;
topMost_ON_button.Text = SettingStr;
}
}
private void TopMost_OFF(object sender, EventArgs e)
{
if (nowTopMost_ON_Setting) return;
if (nowTopMost_OFF_Setting)
{
Settings.Default.TopMost_OFF = string.IsNullOrEmpty(topMost_OFF_textBox.Text) ? Settings.Default.TopMost_OFF : topMost_OFF_textBox.Text;
nowTopMost_OFF_Setting = false;
MainContext.Get.IsBlockingKeyInput = false;
topMost_OFF_button.Text = SettingIdleStr;
Settings.Default.Save();
} else
{
Settings.Default.TopMost_OFF = string.Empty;
nowTopMost_OFF_Setting = true;
MainContext.Get.IsBlockingKeyInput = true;
topMost_OFF_button.Text = SettingStr;
}
}
private void KeyHook(KeyHookData data)
{
if (nowTopMost_ON_Setting)
{
topMost_ON_textBox.Text = data.ToString();
} else if (nowTopMost_OFF_Setting)
{
topMost_OFF_textBox.Text = data.ToString();
}
}
}
}