-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathForm1.cs
238 lines (207 loc) · 7.12 KB
/
Form1.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
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;
using QUI;
using System.Diagnostics;
namespace ListDemo
{
public partial class Form1 : Form,INotifyUI
{
public Form1()
{
InitializeComponent();
{
Form form = this;
mManager = new PaintManagerUI();
mManager.init(ref form);
DialogBuilder builder = new DialogBuilder(true);
mRootNode = builder.createFromFile("skin.xml", null, mManager);
mManager.attachDialog(ref mRootNode);
mManager.addNotifier(this);
this.ClientSize = mManager.getInitSize();
mRectClient = new Rectangle(0, 0, mManager.getInitSize().Width, mManager.getInitSize().Height);
{
/*** 创建显示缓存对象 ***/
mRectClient = new Rectangle(0, 0, mManager.getInitSize().Width, mManager.getInitSize().Height);
mManager.getBufferManager().tryAllocateBuffer(mRectClient);
}
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
mRootNode.setPos(new Rectangle(0, 0, this.Size.Width, this.Size.Height));
this.StartPosition = FormStartPosition.CenterScreen;
init();
}
}
~Form1()
{
if (mManager != null)
{
mManager.release();
mManager = null;
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
{
if (mManager != null)
{
mManager.paintMessageEvent(new Rectangle(0, 0, this.Size.Width, this.Size.Height));
}
}
}
protected override void WndProc(ref Message m)
{
object wParam = m.WParam;
object lParam = m.LParam;
int lRes = 0;
bool handled = true;
switch (m.Msg)
{
case WM_NCHITTEST:
{
lRes = onNcHitTest(m.Msg, m.WParam, m.LParam, ref handled);
break;
}
default:
{
handled = false;
break;
}
}
if (handled == false || m.Msg == (int)WindowMessage.WM_MOUSEMOVE)
{
if (mManager.messageHandler((uint)m.Msg, ref wParam, ref lParam, ref lRes))
{
if (m.Msg == (int)WindowMessage.WM_SETCURSOR)
{
if (this.IsDisposed == false)
{
base.WndProc(ref m);
return;
}
}
m.Result = (IntPtr)lRes;
return;
}
if (this.IsDisposed == false)
{
base.WndProc(ref m);
return;
}
}
else
{
m.Result = (IntPtr)lRes;
}
}
protected Int16 LOWORD(int x)
{
Int16 result = (Int16)(x & 0xffff);
return result;
}
protected Int16 HIWORD(int x)
{
Int16 result = (Int16)((x >> 16) & 0xffff);
return result;
}
protected int onNcHitTest(int msg, object wParam, object lParam, ref bool handled)
{
Point pt = new Point();
IntPtr pos = (IntPtr)lParam;
int nPos = (int)pos;
pt.X = LOWORD(nPos);
pt.Y = HIWORD(nPos);
pt = this.PointToClient(pt);
Rectangle rcClient;
rcClient = this.ClientRectangle;
Rectangle rcCaption = mManager.getCaptionRect();
if (pt.X >= rcClient.Left + rcCaption.Left && pt.X < rcClient.Right - rcCaption.Right && pt.Y >= rcCaption.Top && pt.Y < rcCaption.Bottom)
{
ControlUI pControl = mManager.findControl(ref pt);
if (pControl != null &&
pControl.getClass() != "ButtonUI" &&
pControl.getClass() != "OptionUI" &&
pControl.getClass() != "TextUI"
)
{
return HTCAPTION;
}
}
return HTCLIENT;
}
public int notify(ref TNofityUI msg)
{
if (msg.mType == "click")
{
if (msg.mSender == mButtonClose)
{
this.Dispose();
}
else if (msg.mSender == mButtonLogin)
{
Action action = () =>
{
MessageBox.Show("OK");
};
this.BeginInvoke(action);
}
if (msg.mSender.getName() == "btn")
{
addSomeListItem();
}
}
else if (msg.mType == "itemselect")
{
Action<string, string> action = (controlName, strText) =>
{
if (controlName == "accountcombo")
{
EditUI pAccountEdit = (EditUI)mManager.findControl("accountedit");
if (pAccountEdit != null)
{
pAccountEdit.setText(strText);
}
}
};
this.BeginInvoke(action, msg.mSender.getName(), msg.mSender.getText());
}
return 0;
}
public void init()
{
mButtonClose = mManager.findControl("closebtn");
mButtonLogin = mManager.findControl("loginBtn");
{
ComboUI pAccountCombo = (ComboUI)mManager.findControl("accountcombo");
EditUI pAccountEdit = (EditUI)mManager.findControl("accountedit");
if (pAccountCombo != null && pAccountEdit != null)
{
pAccountEdit.setText(pAccountCombo.getText());
}
}
}
public void addSomeListItem()
{
ListUI pList = (ListUI)mManager.findControl("domainlist");
for (int i = 0; i < 15; i++)
{
ListTextElementUI pListElement = new ListTextElementUI();
pList.add(pListElement);
}
}
public const int HTCLIENT = 0x1;
public const int HTCAPTION = 0x2;
public PaintManagerUI mManager;
public const int WM_NCHITTEST = 0x0084;
protected ControlUI mButtonClose;
protected ControlUI mButtonLogin;
protected Rectangle mRectClient;
protected ControlUI mRootNode;
}
}