-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCommon.cs
More file actions
127 lines (109 loc) · 3.69 KB
/
Common.cs
File metadata and controls
127 lines (109 loc) · 3.69 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using System;
using System.Windows.Forms;
public class AutoClosingMessageBox
{
System.Threading.Timer _timeoutTimer;
string _caption;
AutoClosingMessageBox(string text, string caption, int timeout, MessageBoxIcon icon = 0)
{
_caption = caption;
_timeoutTimer = new System.Threading.Timer(OnTimerElapsed,
null, timeout, System.Threading.Timeout.Infinite);
using (_timeoutTimer)
MessageBox.Show(text, caption,0, icon);
}
public static void Show(string text, string caption, int timeout, MessageBoxIcon icon = 0)
{
new AutoClosingMessageBox(text, caption, timeout, icon);
}
void OnTimerElapsed(object state)
{
IntPtr mbWnd = FindWindow("#32770", _caption); // lpClassName is #32770 for MessageBox
if (mbWnd != IntPtr.Zero)
SendMessage(mbWnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
_timeoutTimer.Dispose();
}
const int WM_CLOSE = 0x0010;
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
}
namespace OMF_Editor
{
partial class Form1
{
private int BitSet(int flags, int mask, bool bvalue)
{
if (bvalue)
return flags |= mask;
else
return flags &= ~mask;
}
private void ChangeMotionMarksPanelState(bool state)
{
bMotMarkPanel = state;
foreach (Control control in groupMotomMarks.Controls)
control.Enabled = state;
}
bool bMotionMarksGroupSelected()
{
return listMotionMarksGroup.SelectedIndices.Count > 0 && listMotionMarksGroup.Items.Count > 0;
}
bool bMotionMarkSelected()
{
return listMotionMarksParams.SelectedIndices.Count > 0 && listMotionMarksParams.Items.Count > 0;
}
private void MotionMarkPanelReset()
{
ChangeMarksParamsPanelState(false);
listMotionMarksParams.Items.Clear();
listMotionMarksGroup.Items.Clear();
ChangeMarksParamsEditState(false);
}
private void ChangeMarksParamsPanelState(bool state)
{
listMotionMarksParams.Enabled = state;
btnAddMark.Enabled = state;
btnDelMark.Enabled = state;
}
private void ChangeMarksParamsEditState(bool state)
{
boxStartMotionMark.Text = "";
boxStartMotionMark.Enabled = state;
boxEndMotionMark.Text = "";
boxEndMotionMark.Enabled = state;
}
private void DisableInput()
{
bTextBoxEnabled = false;
foreach (TextBox box in textBoxes)
{
box.Text = "";
box.Enabled = false;
}
foreach (CheckBox box in Boxes)
{
box.Enabled = false;
box.Checked = false;
}
groupBox2.Enabled = false;
ChangeMotionMarksPanelState(false);
MotionMarkPanelReset();
}
private void EnableInput()
{
bTextBoxEnabled = true;
foreach (TextBox box in textBoxes)
{
box.Text = "";
box.Enabled = true;
}
foreach (CheckBox box in Boxes)
{
box.Enabled = true;
}
groupBox2.Enabled = true;
}
}
}