-
Notifications
You must be signed in to change notification settings - Fork 11
/
WindowControl.vb
515 lines (427 loc) · 18.5 KB
/
WindowControl.vb
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
Imports Dragablz
Module WindowControl
Private MainWindowW As MainWindowD
Public Function GetMainWindow() As MainWindowD
If MainWindowW IsNot Nothing Then
Return MainWindowW
End If
For Each win As Window In Application.Current.Windows
If win.GetType Is GetType(MainWindowD) Then
MainWindowW = win
Return win
End If
Next
Return Nothing
End Function
Public Sub CloseToolWindow()
'다른 윈도우들이 하나라도 남아 있는지 판단
Dim flag As Boolean = False
Dim MainWindow As Window = Nothing
For Each win As Window In Application.Current.Windows
If win.GetType Is GetType(DataEditor) Or win.GetType Is GetType(TriggerEditor) Or win.GetType Is GetType(PluginWindow) Then
flag = True '다른 윈도우가 남아있음
ElseIf win.GetType Is GetType(MainWindowD) Then
MainWindow = win
End If
Next
If Not flag Then '다른 윈도우가 없음
MainWindow.Visibility = Visibility.Visible
End If
End Sub
Public Sub OpenToolWindow()
'메인 윈도우 숨기기
For Each win As Window In Application.Current.Windows
If win.GetType Is GetType(MainWindowD) Then
win.Visibility = Visibility.Hidden
End If
Next
End Sub
Public Enum CloseType
All
Other
This
End Enum
Public Sub TERefreshSetting()
For Each win As Window In Application.Current.Windows
If win.GetType Is GetType(TriggerEditor) Then
Dim MainContent As Object = CType(win, TriggerEditor).MainTab
If GetTESettingWindow(MainContent) Then
Exit Sub
End If
'If CheckTabablzControl(tTEFile, MainContent) Then
' win.Activate()
' Return True
'End If
End If
Next
End Sub
Public Function GetTESettingWindow(ParentBranch As Object) As Boolean
While TypeOf ParentBranch IsNot TabablzControl
Select Case ParentBranch.GetType
Case GetType(TabablzControl)
Exit While
Case GetType(Dockablz.Branch)
Dim tBranch As Dockablz.Branch = ParentBranch
If GetTESettingWindow(ParentBranch.FirstItem) Then
Return True
End If
If GetTESettingWindow(ParentBranch.SecondItem) Then
Return True
End If
Return False
Exit While
Case GetType(Dockablz.Layout)
Dim tLayout As Dockablz.Layout = ParentBranch
ParentBranch = tLayout.Content
End Select
End While
Return GetTESettinTabablzControl(ParentBranch)
Return False
End Function
Private Function GetTESettinTabablzControl(Control As TabablzControl) As Boolean
Dim tefile As TEFile = Nothing
Dim index As Integer
For i = 0 To Control.Items.Count - 1
Dim TabContent As Object = CType(Control.Items(index), TabItem).Content
If TypeOf TabContent Is TriggerEditorSetting Then
Dim tPage As TriggerEditorSetting = TabContent
tPage.Refresh()
Return True
End If
index += 1
Next
Return False
End Function
Public Sub TECloseAllTabITem(tTEFile As TEFile)
'우선 모든 윈도우 돌면서 조사하자
For Each win As Window In Application.Current.Windows
If win.GetType Is GetType(TriggerEditor) Then
Dim MainContent As Object = CType(win, TriggerEditor).MainTab
If CloseCheckBranch(tTEFile, MainContent, CloseType.All) Then
Exit Sub
End If
'If CheckTabablzControl(tTEFile, MainContent) Then
' win.Activate()
' Return True
'End If
End If
Next
End Sub
Public Sub TECloseOtherTabITem(tTEFile As TEFile)
'우선 모든 윈도우 돌면서 조사하자
For Each win As Window In Application.Current.Windows
If win.GetType Is GetType(TriggerEditor) Then
Dim MainContent As Object = CType(win, TriggerEditor).MainTab
If CloseCheckBranch(tTEFile, MainContent, CloseType.Other) Then
Exit Sub
End If
'If CheckTabablzControl(tTEFile, MainContent) Then
' win.Activate()
' Return True
'End If
End If
Next
End Sub
Public Sub TECloseTabITem(tTEFile As TEFile)
'우선 모든 윈도우 돌면서 조사하자
For Each win As Window In Application.Current.Windows
If win.GetType Is GetType(TriggerEditor) Then
Dim MainContent As Object = CType(win, TriggerEditor).MainTab
If CloseCheckBranch(tTEFile, MainContent, CloseType.This) Then
Exit Sub
End If
'If CheckTabablzControl(tTEFile, MainContent) Then
' win.Activate()
' Return True
'End If
End If
Next
End Sub
Private Function CloseCheckBranch(tTEFile As TEFile, ParentBranch As Object, CloseType As CloseType) As Boolean
'우선 모든 윈도우 돌면서 조사하자
While TypeOf ParentBranch IsNot TabablzControl
Select Case ParentBranch.GetType
Case GetType(TabablzControl)
Exit While
Case GetType(Dockablz.Branch)
Dim tBranch As Dockablz.Branch = ParentBranch
If CloseCheckBranch(tTEFile, ParentBranch.FirstItem, CloseType) Then
Return True
End If
If CloseCheckBranch(tTEFile, ParentBranch.SecondItem, CloseType) Then
Return True
End If
Return False
Exit While
Case GetType(Dockablz.Layout)
Dim tLayout As Dockablz.Layout = ParentBranch
ParentBranch = tLayout.Content
End Select
End While
Return CloseCheckTabablzControl(tTEFile, ParentBranch, CloseType)
Return False
End Function
Private Function CloseCheckTabablzControl(tTEFile As TEFile, Control As TabablzControl, CloseType As CloseType) As Boolean
Dim tefile As TEFile = Nothing
Dim index As Integer
For i = 0 To Control.Items.Count - 1
Dim TabContent As Object = CType(Control.Items(index), TabItem).Content
If TypeOf TabContent Is TECUIPage Then
Dim tPage As TECUIPage = TabContent
tefile = tPage.TEFile
ElseIf TypeOf TabContent Is TEGUIPage Then
Dim tPage As TEGUIPage = TabContent
tefile = tPage.TEFile
ElseIf TypeOf TabContent Is TECTPage Then
Dim tPage As TECTPage = TabContent
tefile = tPage.TEFile
ElseIf TypeOf TabContent Is TESCAScriptPage Then
Dim tPage As TESCAScriptPage = TabContent
tefile = tPage.TEFile
End If
If tefile Is tTEFile Then
Select Case CloseType
Case CloseType.This
Control.Items.RemoveAt(index)
Return True
Case CloseType.All
Control.Items.RemoveAt(index)
Case CloseType.Other
index += 1
End Select
Else
Select Case CloseType
Case CloseType.This
index += 1
Case CloseType.All
Control.Items.RemoveAt(index)
Case CloseType.Other
Control.Items.RemoveAt(index)
End Select
End If
Next
Return False
End Function
End Module
Namespace WindowMenu
Public Module WindowMenus
Public Sub MenuItemSave()
If Not pgData.IsCompilng And Tool.IsProjectLoad Then
pjData.Save()
ProjectControlBinding.PropertyChangedPack()
End If
End Sub
Public Sub MenuItemSaveAs()
If Not pgData.IsCompilng And Tool.IsProjectLoad Then
pjData.Save(True)
ProjectControlBinding.PropertyChangedPack()
End If
End Sub
Public Sub NewFile()
If Not pgData.IsCompilng Then
Tool.CloseOtherWindow()
ProjectData.Load(True, pjData)
ProjectControlBinding.PropertyChangedPack()
End If
End Sub
Public Sub Setting()
If Not pgData.IsCompilng Then
If SettiingForm Is Nothing Then '첫 실행일 경우
SettiingForm = New SettingWindows
SettiingForm.ShowDialog()
Else
If SettiingForm.IsLoaded Then '열려있을경우
SettiingForm.Activate()
Else '닫혀있을 경우
SettiingForm = New SettingWindows
SettiingForm.ShowDialog()
End If
End If
ProjectControlBinding.PropertyChangedPack()
End If
End Sub
Public Sub Close()
If Not pgData.IsCompilng And Tool.IsProjectLoad Then
If pjData.CloseFile() Then
pjData = Nothing
End If
ProjectControlBinding.PropertyChangedPack()
End If
End Sub
Public Sub Save()
If Not pgData.IsCompilng And Tool.IsProjectLoad Then
pjData.Save()
ProjectControlBinding.PropertyChangedPack()
End If
End Sub
Public Sub LoadWithFile(filename As String)
If Not pgData.IsCompilng Then
ProjectData.LoadWithCheckOepn(filename, pjData)
ProjectControlBinding.PropertyChangedPack()
End If
End Sub
Public Sub Load()
If Not pgData.IsCompilng Then
ProjectData.Load(False, pjData)
ProjectControlBinding.PropertyChangedPack()
End If
End Sub
Public Sub ScmdOpen()
If Tool.IsProjectLoad Then
ProjectControlBinding.PropertyChangedPack()
If My.Computer.FileSystem.FileExists(pjData.OpenMapName) Then
Try
Process.Start(pjData.OpenMapName)
Catch ex As ComponentModel.Win32Exception
Tool.CustomMsgBox(Tool.GetText("ConnectProgramNoExist"), MessageBoxButton.OK, MessageBoxImage.Error)
End Try
Exit Sub
Else
If Tool.CustomMsgBox(Tool.GetText("Error OpenMap is not exist reset"), MessageBoxButton.OKCancel) = MsgBoxResult.Ok Then
If Tool.OpenMapSet Then
ProjectControlBinding.PropertyChangedPack()
Try
Process.Start(pjData.OpenMapName)
Catch ex As ComponentModel.Win32Exception
Tool.CustomMsgBox(Tool.GetText("ConnectProgramNoExist"), MessageBoxButton.OK, MessageBoxImage.Error)
End Try
Exit Sub
End If
End If
End If
Tool.ErrorMsgBox(Tool.GetText("Error OpenMap is not exist!"))
End If
End Sub
Public Sub insert(Optional IsEdd As Boolean = False)
If Tool.IsProjectLoad Then
ProjectControlBinding.PropertyChangedPack()
pjData.EudplibData.Build(IsEdd)
End If
End Sub
Public Sub OpenDataEditor()
If Tool.IsProjectLoad Then
ProjectControlBinding.PropertyChangedPack()
If Not scData.LoadStarCraftData Then '로드가 되어있지 않을 경우 판단
If Tool.CustomMsgBox(Tool.GetText("Error NotExistMPQ reset"), MessageBoxButton.OKCancel) = MsgBoxResult.Ok Then
Dim opendialog As New System.Windows.Forms.OpenFileDialog With {
.Filter = "StarCraft.exe|StarCraft.exe",
.FileName = "StarCraft.exe",
.Title = Tool.GetText("StarExeFile Select")
}
If opendialog.ShowDialog() = Forms.DialogResult.OK Then
pgData.Setting(ProgramData.TSetting.starcraft) = opendialog.FileName
scData.LoadGRPData()
ProjectControlBinding.PropertyChangedPack()
Else
Tool.ErrorMsgBox(Tool.GetText("Error FailLoad DataEditor"))
Exit Sub
End If
Else
Tool.ErrorMsgBox(Tool.GetText("Error FailLoad DataEditor"))
Exit Sub
End If
End If
If scData.LoadStarCraftData Then
'pjData.SetDirty(True)
Dim DataEditorForm As New DataEditor(DataEditor.OpenType.MainWindow)
DataEditorForm.Show()
OpenToolWindow()
End If
End If
End Sub
Public Sub OpenTriggerEdit()
If Tool.IsProjectLoad Then
ProjectControlBinding.PropertyChangedPack()
'Dim TriggerEditorForm As New FastTreeview
'TriggerEditorForm.Show()
If Not scData.LoadStarCraftData Then '로드가 되어있지 않을 경우 판단
If Tool.CustomMsgBox(Tool.GetText("Error NotExistMPQ reset"), MessageBoxButton.OKCancel) = MsgBoxResult.Ok Then
Dim opendialog As New System.Windows.Forms.OpenFileDialog With {
.Filter = "StarCraft.exe|StarCraft.exe",
.FileName = "StarCraft.exe",
.Title = Tool.GetText("StarExeFile Select")
}
If opendialog.ShowDialog() = Forms.DialogResult.OK Then
pgData.Setting(ProgramData.TSetting.starcraft) = opendialog.FileName
scData.LoadGRPData()
ProjectControlBinding.PropertyChangedPack()
Else
Tool.ErrorMsgBox(Tool.GetText("Error FailLoad TriggerEditor"))
Exit Sub
End If
Else
Tool.ErrorMsgBox(Tool.GetText("Error FailLoad TriggerEditor"))
Exit Sub
End If
End If
If scData.LoadStarCraftData Then
Dim flag As Boolean = False
For Each win As Window In Application.Current.Windows
If win.GetType Is GetType(TriggerEditor) Then
win.Activate()
flag = True
Exit For
End If
Next
'flag가 True이면 윈도우 첫 실행이므로 TabItem을 불러와야됨.
If Not flag Then
Dim TriggerEditorForm As New TriggerEditor
TriggerEditorForm.Show()
TriggerEditorForm.LoadLastTabItems()
OpenToolWindow()
End If
End If
End If
End Sub
Public Sub OpenPlugin()
If Tool.IsProjectLoad Then
ProjectControlBinding.PropertyChangedPack()
If Not scData.LoadStarCraftData Then '로드가 되어있지 않을 경우 판단
If Tool.CustomMsgBox(Tool.GetText("Error NotExistMPQ reset"), MessageBoxButton.OKCancel) = MsgBoxResult.Ok Then
Dim opendialog As New System.Windows.Forms.OpenFileDialog With {
.Filter = "StarCraft.exe|StarCraft.exe",
.FileName = "StarCraft.exe",
.Title = Tool.GetText("StarExeFile Select")
}
If opendialog.ShowDialog() = Forms.DialogResult.OK Then
pgData.Setting(ProgramData.TSetting.starcraft) = opendialog.FileName
scData.LoadGRPData()
ProjectControlBinding.PropertyChangedPack()
Else
Tool.ErrorMsgBox(Tool.GetText("Error FailLoad PluginSet"))
Exit Sub
End If
Else
Tool.ErrorMsgBox(Tool.GetText("Error FailLoad PluginSet"))
Exit Sub
End If
End If
If scData.LoadStarCraftData Then
Dim flag As Boolean = False
For Each win As Window In Application.Current.Windows
If win.GetType Is GetType(PluginWindow) Then
win.Activate()
flag = True
Exit For
End If
Next
If Not flag Then
'pjData.SetDirty(True)
Dim PluginForm As New PluginWindow
PluginForm.Show()
OpenToolWindow()
End If
End If
End If
End Sub
Public Sub CodeFold()
For Each win As Window In Application.Current.Windows
If win.GetType Is GetType(DataEditor) Then
If win.IsActive Then
CType(win, DataEditor).CodeViewFold()
End If
End If
Next
End Sub
End Module
End Namespace