-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathGlobals.cs
365 lines (311 loc) · 8.03 KB
/
Globals.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
using System;
using System.Windows.Forms;
using System.Reflection;
using System.IO;
namespace SpiffCode
{
/// <summary>
/// Summary description for Globals.
/// </summary>
public class Globals
{
private static AnimDoc s_doc;
private static Strip s_stpActive = null;
private static int s_ifrActive = 0;
private static int s_cfrActive = 1;
private static int s_msFrameRate = 80;
private static int s_nPreviewScale = 4;
private static int s_nStripScale = 1;
private static bool s_fSideColorMappingOn = true;
private static bool s_fGridOn = true;
private static bool s_fShowOriginPoint = false;
private static bool s_fShowSpecialPoint = false;
private static AnimDoc s_docNull;
private static Control s_ctlStrip;
private static Control s_ctlPreview;
private static Form s_frmStrips;
private static Form s_frmStrip;
private static Form s_frmMain;
private static Cursor s_crsrHand;
private static Cursor s_crsrGrab;
private static int s_nTileSize = 32;
private static int s_cxGrid = 32;
private static int s_cyGrid = 32;
public static event EventHandler ActiveDocumentChanged;
public static AnimDoc ActiveDocument {
get {
return s_doc;
}
set {
// Keep track of the ActiveDoc's ActiveStrip
if (s_doc != null)
s_doc.ActiveStripChanged -= new EventHandler(OnActiveStripChanged);
s_doc = value;
if (ActiveDocumentChanged != null)
ActiveDocumentChanged(null, EventArgs.Empty);
ActiveStrip = s_doc == null ? null : s_doc.ActiveStrip;
if (s_doc != null)
s_doc.ActiveStripChanged += new EventHandler(OnActiveStripChanged);
}
}
private static void OnActiveStripChanged(object obSender, EventArgs e) {
ActiveStrip = s_doc.ActiveStrip;
}
public static event EventHandler ActiveStripChanged;
public static Strip ActiveStrip {
get {
return s_stpActive;
}
set {
// Keep track of the ActiveStrip's ActiveFrame
if (s_stpActive != null) {
s_stpActive.ActiveFrameChanged -= new EventHandler(OnActiveFrameChanged);
s_stpActive.ActiveFrameCountChanged -= new EventHandler(OnActiveFrameCountChanged);
}
s_stpActive = value;
if (ActiveStripChanged != null)
ActiveStripChanged(null, EventArgs.Empty);
ActiveFrame = s_stpActive == null ? 0 : s_stpActive.ActiveFrame;
if (s_stpActive != null) {
s_stpActive.ActiveFrameChanged += new EventHandler(OnActiveFrameChanged);
s_stpActive.ActiveFrameCountChanged += new EventHandler(OnActiveFrameCountChanged);
}
}
}
private static void OnActiveFrameChanged(object obSender, EventArgs e) {
ActiveFrame = s_stpActive.ActiveFrame;
}
private static void OnActiveFrameCountChanged(object obSender, EventArgs e) {
ActiveFrameCount = s_stpActive.ActiveFrameCount;
}
public static event EventHandler ActiveFrameChanged;
public static int ActiveFrame {
get {
return s_ifrActive;
}
set {
s_ifrActive = value;
if (ActiveFrameChanged != null)
ActiveFrameChanged(null, EventArgs.Empty);
}
}
public static event EventHandler ActiveFrameCountChanged;
public static int ActiveFrameCount {
get {
return s_cfrActive;
}
set {
s_cfrActive = value;
if (ActiveFrameCountChanged != null)
ActiveFrameCountChanged(null, EventArgs.Empty);
}
}
public static int FrameRate {
get {
return s_msFrameRate;
}
set {
s_msFrameRate = value;
}
}
public static event EventHandler GridChanged;
public static bool GridOn {
get {
return s_fGridOn;
}
set {
s_fGridOn = value;
if (GridChanged != null)
GridChanged(null, EventArgs.Empty);
}
}
public static int GridWidth {
get {
return s_cxGrid;
}
set {
s_cxGrid = value;
if (GridChanged != null)
GridChanged(null, EventArgs.Empty);
}
}
public static int GridHeight {
get {
return s_cyGrid;
}
set {
s_cyGrid = value;
if (GridChanged != null)
GridChanged(null, EventArgs.Empty);
}
}
public static event EventHandler TileSizeChanged;
public static int TileSize {
set {
s_nTileSize = value;
GridWidth = s_nTileSize;
GridHeight = s_nTileSize;
if (s_nTileSize < 24) {
StripScale = 2;
} else {
StripScale = 1;
}
if (TileSizeChanged != null)
TileSizeChanged(null, EventArgs.Empty);
}
get {
return s_nTileSize;
}
}
public static Cursor HandCursor {
get {
if (s_crsrHand == null) {
Assembly ass = Assembly.GetAssembly(typeof(Globals));
// string[] astr = ass.GetManifestResourceNames();
Stream stm = ass.GetManifestResourceStream("SpiffCode.Resources.hand.cur");
s_crsrHand = new Cursor(stm);
stm.Close();
}
return s_crsrHand;
}
}
public static Cursor GrabCursor {
get {
if (s_crsrGrab == null) {
Assembly ass = Assembly.GetAssembly(typeof(Globals));
Stream stm = ass.GetManifestResourceStream("SpiffCode.Resources.grab.cur");
s_crsrGrab = new Cursor(stm);
stm.Close();
}
return s_crsrGrab;
}
}
public static event EventHandler SideColorMappingOnChanged;
public static bool SideColorMappingOn {
get {
return s_fSideColorMappingOn;
}
set {
s_fSideColorMappingOn = value;
if (SideColorMappingOnChanged != null)
SideColorMappingOnChanged(null, EventArgs.Empty);
}
}
public static event EventHandler ShowOriginPointChanged;
public static bool ShowOriginPoint {
get {
return s_fShowOriginPoint;
}
set {
s_fShowOriginPoint = value;
if (ShowOriginPointChanged != null)
ShowOriginPointChanged(null, EventArgs.Empty);
}
}
public static event EventHandler ShowSpecialPointChanged;
public static bool ShowSpecialPoint {
get {
return s_fShowSpecialPoint;
}
set {
s_fShowSpecialPoint = value;
if (ShowSpecialPointChanged != null)
ShowSpecialPointChanged(null, EventArgs.Empty);
}
}
public static event EventHandler PreviewScaleChanged;
public static int PreviewScale {
get {
return s_nPreviewScale;
}
set {
s_nPreviewScale = value;
if (PreviewScaleChanged != null)
PreviewScaleChanged(null, EventArgs.Empty);
}
}
public static event EventHandler StripScaleChanged;
public static int StripScale {
get {
return s_nStripScale;
}
set {
s_nStripScale = value;
if (StripScaleChanged != null)
StripScaleChanged(null, EventArgs.Empty);
}
}
public static AnimDoc NullDocument {
get {
return s_docNull;
}
set {
s_docNull = value;
}
}
public static Control StripControl {
get {
return s_ctlStrip;
}
set {
s_ctlStrip = value;
}
}
public static Control PreviewControl {
get {
return s_ctlPreview;
}
set {
s_ctlPreview = value;
}
}
public static Form StripsForm {
get {
return s_frmStrips;
}
set {
s_frmStrips = value;
}
}
public static Form StripForm {
get {
return s_frmStrip;
}
set {
s_frmStrip = value;
}
}
public static Form MainForm {
get {
return s_frmMain;
}
set {
s_frmMain = value;
}
}
public static event KeyPressEventHandler KeyPress;
// UNDONE: this will send to every handler even after one has handled
// the event.
public static void OnKeyPress(Object sender, KeyPressEventArgs e) {
if (KeyPress != null)
KeyPress(sender, e);
}
public static event KeyEventHandler KeyDown;
public static void OnKeyDown(Object sender, KeyEventArgs e) {
if (KeyDown != null)
KeyDown(sender, e);
}
public static event KeyEventHandler KeyUp;
public static void OnKeyUp(Object sender, KeyEventArgs e) {
if (KeyUp != null)
KeyUp(sender, e);
}
public static event EventHandler FrameContentChanged;
// UNDONE: this will send to every handler even after one has handled
// the event.
public static void OnFrameContentChanged(Object sender, EventArgs e) {
if (FrameContentChanged != null)
FrameContentChanged(sender, e);
}
}
}