0
|
1 // This file is a part of the SGA Explorer app and is copyright 2006-2018 IBBoard.
|
|
2 //
|
|
3 // The file and the library/program it is in are licensed under the GNU GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
|
|
4 using System;
|
|
5 using System.Drawing;
|
|
6 using System.Collections;
|
|
7 using System.ComponentModel;
|
|
8 using System.Windows.Forms;
|
|
9 using System.Data;
|
|
10 using System.IO;
|
|
11 using System.Text.RegularExpressions;
|
|
12 using IBBoard;
|
|
13 using IBBoard.Graphics;
|
|
14 using IBBoard.Relic.RelicTools;
|
|
15 using IBBoard.Windows.Forms;
|
|
16
|
|
17 namespace IBBoard.Relic.SGAExplorer
|
|
18 {
|
|
19 /// <summary>
|
|
20 /// Summary description for Form1.
|
|
21 /// </summary>
|
|
22 public class Form1 : System.Windows.Forms.Form
|
|
23 {
|
|
24 #region Form and app variables
|
|
25 private Preferences pref;
|
|
26 private SgaArchive archive;
|
|
27 private TreeNode root;
|
|
28 private System.Windows.Forms.MainMenu mainMenu1;
|
|
29 private System.Windows.Forms.MenuItem menuItem1;
|
|
30 private System.Windows.Forms.MenuItem menuItem2;
|
|
31 private System.Windows.Forms.MenuItem menuItem3;
|
|
32 private System.Windows.Forms.MenuItem menuItem4;
|
|
33 private System.Windows.Forms.OpenFileDialog openFileDialog;
|
|
34 private System.Windows.Forms.TreeView treeView;
|
|
35 private System.Windows.Forms.ListView listView;
|
|
36 private System.Windows.Forms.ImageList folderList;
|
|
37 private System.Windows.Forms.StatusBar statusBar;
|
|
38 private System.Windows.Forms.Timer timer;
|
|
39 private System.Windows.Forms.MenuItem menuItem5;
|
|
40 private System.Windows.Forms.MenuItem menuItem6;
|
|
41 private System.Windows.Forms.MenuItem menuItem7;
|
|
42 private System.Windows.Forms.ImageList tinyImageList;
|
|
43 private System.Windows.Forms.ImageList iconImageList;
|
|
44 private System.Windows.Forms.MenuItem menuItem8;
|
|
45 private System.Windows.Forms.ColumnHeader colName;
|
|
46 private System.Windows.Forms.ColumnHeader colSize;
|
|
47 private System.Windows.Forms.ColumnHeader colSizeUncompressed;
|
|
48 private System.Windows.Forms.ColumnHeader colExtension;
|
|
49 private System.Windows.Forms.ColumnHeader colExtensionLong;
|
|
50 private System.Windows.Forms.ContextMenu contextMenuFiles;
|
|
51 private System.Windows.Forms.MenuItem menuItem9;
|
|
52 private System.Windows.Forms.MenuItem menuItem10;
|
|
53 private System.ComponentModel.IContainer components;
|
|
54 private System.Windows.Forms.MenuItem menuItem13;
|
|
55 private System.Windows.Forms.MenuItem menuItem14;
|
|
56 private System.Windows.Forms.MenuItem menuItem15;
|
|
57 private System.Windows.Forms.MenuItem menuItem16;
|
|
58 private System.Windows.Forms.Button bttnGo;
|
|
59 private System.Windows.Forms.TextBox txtPath;
|
|
60 private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog;
|
|
61 private IBBoard.Windows.Forms.ListViewColumnSorter listViewSorter;
|
|
62 private SgaArchive.ExtractionNotification notificationFailure;
|
|
63 private SgaArchive.ExtractionNotification notificationSuccess;
|
|
64 private SgaArchive.ExtractionNotification notificationEvent;
|
|
65 private string output;
|
|
66 private int extractSuccess;
|
|
67 private int extractFailure;
|
|
68 private System.Windows.Forms.MenuItem menuItem17;
|
|
69 private System.Windows.Forms.MenuItem menuItem18;
|
|
70 private DebugWindow debugWindow;
|
|
71 private System.Windows.Forms.ColumnHeader colCompressionType;
|
|
72 private System.Windows.Forms.MenuItem miTypeToDefault;
|
|
73 private System.Windows.Forms.MenuItem miTypeToLocation;
|
|
74 private System.Windows.Forms.MenuItem miTypeToDefaultHexedit;
|
|
75 private System.Windows.Forms.MenuItem miTypeToLocationHexedit;
|
|
76 private System.Windows.Forms.MenuItem miToDefaultHexedit;
|
|
77 private System.Windows.Forms.MenuItem miToLocationHexedit;
|
|
78 private Options opt;
|
|
79 #endregion
|
|
80
|
|
81 public Form1(string[] args)
|
|
82 {
|
|
83 pref = new Preferences("SGAExplorer");
|
|
84 debugWindow = new DebugWindow();
|
|
85 debugWindow.Closing+= new CancelEventHandler(debugWindow_Closing);
|
|
86 opt = new Options(pref);
|
|
87 //
|
|
88 // Required for Windows Form Designer support
|
|
89 //
|
|
90 InitializeComponent();
|
|
91
|
|
92 listViewSorter = new ListViewColumnSorter();
|
|
93 listView.ListViewItemSorter = listViewSorter;
|
|
94
|
|
95 switch((View)pref["ViewType"])
|
|
96 {
|
|
97 case View.List: menuItem6_Click(this, EventArgs.Empty);
|
|
98 break;
|
|
99 case View.LargeIcon: menuItem7_Click(this, EventArgs.Empty);
|
|
100 break;
|
|
101 case View.Details: menuItem8_Click(this, EventArgs.Empty);
|
|
102 break;
|
|
103 default: menuItem6_Click(this, EventArgs.Empty);
|
|
104 break;
|
|
105 }
|
|
106
|
|
107 if ((bool)pref["ShowDebug"])
|
|
108 {
|
|
109 debugWindow.Show();
|
|
110 menuItem18.Checked = true;
|
|
111 this.Focus();
|
|
112 }
|
|
113
|
|
114 notificationFailure = new SgaArchive.ExtractionNotification(ExtractionFailure);
|
|
115 notificationSuccess = new SgaArchive.ExtractionNotification(ExtractionSuccess);
|
|
116 notificationEvent = new SgaArchive.ExtractionNotification(ExtractionEvent);
|
|
117
|
|
118 if (args.Length==1 && args[0].EndsWith(".sga") && File.Exists(args[0]))
|
|
119 {
|
|
120 loadSGA(args[0]);
|
|
121 }
|
|
122 }
|
|
123
|
|
124 /// <summary>
|
|
125 /// Clean up any resources being used.
|
|
126 /// </summary>
|
|
127 protected override void Dispose( bool disposing )
|
|
128 {
|
|
129 if( disposing )
|
|
130 {
|
|
131 if (components != null)
|
|
132 {
|
|
133 components.Dispose();
|
|
134 }
|
|
135 }
|
|
136 base.Dispose( disposing );
|
|
137 }
|
|
138
|
|
139 #region Windows Form Designer generated code
|
|
140 /// <summary>
|
|
141 /// Required method for Designer support - do not modify
|
|
142 /// the contents of this method with the code editor.
|
|
143 /// </summary>
|
|
144 private void InitializeComponent()
|
|
145 {
|
|
146 this.components = new System.ComponentModel.Container();
|
|
147 System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
|
|
148 this.treeView = new System.Windows.Forms.TreeView();
|
|
149 this.contextMenuFiles = new System.Windows.Forms.ContextMenu();
|
|
150 this.menuItem9 = new System.Windows.Forms.MenuItem();
|
|
151 this.menuItem10 = new System.Windows.Forms.MenuItem();
|
|
152 this.miToDefaultHexedit = new System.Windows.Forms.MenuItem();
|
|
153 this.miToLocationHexedit = new System.Windows.Forms.MenuItem();
|
|
154 this.miTypeToDefault = new System.Windows.Forms.MenuItem();
|
|
155 this.miTypeToLocation = new System.Windows.Forms.MenuItem();
|
|
156 this.miTypeToDefaultHexedit = new System.Windows.Forms.MenuItem();
|
|
157 this.miTypeToLocationHexedit = new System.Windows.Forms.MenuItem();
|
|
158 this.folderList = new System.Windows.Forms.ImageList(this.components);
|
|
159 this.listView = new System.Windows.Forms.ListView();
|
|
160 this.colName = new System.Windows.Forms.ColumnHeader();
|
|
161 this.colSize = new System.Windows.Forms.ColumnHeader();
|
|
162 this.colSizeUncompressed = new System.Windows.Forms.ColumnHeader();
|
|
163 this.colExtension = new System.Windows.Forms.ColumnHeader();
|
|
164 this.colExtensionLong = new System.Windows.Forms.ColumnHeader();
|
|
165 this.colCompressionType = new System.Windows.Forms.ColumnHeader();
|
|
166 this.iconImageList = new System.Windows.Forms.ImageList(this.components);
|
|
167 this.tinyImageList = new System.Windows.Forms.ImageList(this.components);
|
|
168 this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
|
|
169 this.mainMenu1 = new System.Windows.Forms.MainMenu();
|
|
170 this.menuItem1 = new System.Windows.Forms.MenuItem();
|
|
171 this.menuItem2 = new System.Windows.Forms.MenuItem();
|
|
172 this.menuItem3 = new System.Windows.Forms.MenuItem();
|
|
173 this.menuItem4 = new System.Windows.Forms.MenuItem();
|
|
174 this.menuItem13 = new System.Windows.Forms.MenuItem();
|
|
175 this.menuItem14 = new System.Windows.Forms.MenuItem();
|
|
176 this.menuItem5 = new System.Windows.Forms.MenuItem();
|
|
177 this.menuItem6 = new System.Windows.Forms.MenuItem();
|
|
178 this.menuItem7 = new System.Windows.Forms.MenuItem();
|
|
179 this.menuItem8 = new System.Windows.Forms.MenuItem();
|
|
180 this.menuItem17 = new System.Windows.Forms.MenuItem();
|
|
181 this.menuItem18 = new System.Windows.Forms.MenuItem();
|
|
182 this.menuItem15 = new System.Windows.Forms.MenuItem();
|
|
183 this.menuItem16 = new System.Windows.Forms.MenuItem();
|
|
184 this.statusBar = new System.Windows.Forms.StatusBar();
|
|
185 this.timer = new System.Windows.Forms.Timer(this.components);
|
|
186 this.txtPath = new System.Windows.Forms.TextBox();
|
|
187 this.bttnGo = new System.Windows.Forms.Button();
|
|
188 this.folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
|
|
189 this.SuspendLayout();
|
|
190 //
|
|
191 // treeView
|
|
192 //
|
|
193 this.treeView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
|
194 | System.Windows.Forms.AnchorStyles.Left)));
|
|
195 this.treeView.ContextMenu = this.contextMenuFiles;
|
|
196 this.treeView.ImageList = this.folderList;
|
|
197 this.treeView.Location = new System.Drawing.Point(0, 20);
|
|
198 this.treeView.Name = "treeView";
|
|
199 this.treeView.Size = new System.Drawing.Size(310, 470);
|
|
200 this.treeView.TabIndex = 0;
|
|
201 this.treeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseDown);
|
|
202 this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect);
|
|
203 //
|
|
204 // contextMenuFiles
|
|
205 //
|
|
206 this.contextMenuFiles.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
|
207 this.menuItem9,
|
|
208 this.menuItem10,
|
|
209 this.miToDefaultHexedit,
|
|
210 this.miToLocationHexedit,
|
|
211 this.miTypeToDefault,
|
|
212 this.miTypeToLocation,
|
|
213 this.miTypeToDefaultHexedit,
|
|
214 this.miTypeToLocationHexedit});
|
|
215 this.contextMenuFiles.Popup += new System.EventHandler(this.contextMenuFiles_Popup);
|
|
216 //
|
|
217 // menuItem9
|
|
218 //
|
|
219 this.menuItem9.Enabled = false;
|
|
220 this.menuItem9.Index = 0;
|
|
221 this.menuItem9.Text = "Extract to &default";
|
|
222 this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
|
|
223 //
|
|
224 // menuItem10
|
|
225 //
|
|
226 this.menuItem10.Enabled = false;
|
|
227 this.menuItem10.Index = 1;
|
|
228 this.menuItem10.Text = "Extract to &location";
|
|
229 this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);
|
|
230 //
|
|
231 // miToDefaultHexedit
|
|
232 //
|
|
233 this.miToDefaultHexedit.Enabled = false;
|
|
234 this.miToDefaultHexedit.Index = 2;
|
|
235 this.miToDefaultHexedit.RadioCheck = true;
|
|
236 this.miToDefaultHexedit.Text = "Extract and &hex-edit";
|
|
237 //
|
|
238 // miToLocationHexedit
|
|
239 //
|
|
240 this.miToLocationHexedit.Enabled = false;
|
|
241 this.miToLocationHexedit.Index = 3;
|
|
242 this.miToLocationHexedit.RadioCheck = true;
|
|
243 this.miToLocationHexedit.Text = "Extract to location and he&x-edit";
|
|
244 //
|
|
245 // miTypeToDefault
|
|
246 //
|
|
247 this.miTypeToDefault.Enabled = false;
|
|
248 this.miTypeToDefault.Index = 4;
|
|
249 this.miTypeToDefault.Text = "Extract type to default";
|
|
250 this.miTypeToDefault.Click += new System.EventHandler(this.miTypeToDefault_Click);
|
|
251 //
|
|
252 // miTypeToLocation
|
|
253 //
|
|
254 this.miTypeToLocation.Enabled = false;
|
|
255 this.miTypeToLocation.Index = 5;
|
|
256 this.miTypeToLocation.Text = "Extract type to location";
|
|
257 this.miTypeToLocation.Click += new System.EventHandler(this.miTypeToLocation_Click);
|
|
258 //
|
|
259 // miTypeToDefaultHexedit
|
|
260 //
|
|
261 this.miTypeToDefaultHexedit.Enabled = false;
|
|
262 this.miTypeToDefaultHexedit.Index = 6;
|
|
263 this.miTypeToDefaultHexedit.RadioCheck = true;
|
|
264 this.miTypeToDefaultHexedit.Text = "Extract type and hex-edit";
|
|
265 this.miTypeToDefaultHexedit.Click += new System.EventHandler(this.miTypeToDefaultHexedit_Click);
|
|
266 //
|
|
267 // miTypeToLocationHexedit
|
|
268 //
|
|
269 this.miTypeToLocationHexedit.Enabled = false;
|
|
270 this.miTypeToLocationHexedit.Index = 7;
|
|
271 this.miTypeToLocationHexedit.RadioCheck = true;
|
|
272 this.miTypeToLocationHexedit.Text = "Extract type to location and hex-edit";
|
|
273 this.miTypeToLocationHexedit.Click += new System.EventHandler(this.miTypeToLocationHexedit_Click);
|
|
274 //
|
|
275 // folderList
|
|
276 //
|
|
277 this.folderList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
|
|
278 this.folderList.ImageSize = new System.Drawing.Size(16, 16);
|
|
279 this.folderList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("folderList.ImageStream")));
|
|
280 this.folderList.TransparentColor = System.Drawing.Color.Transparent;
|
|
281 //
|
|
282 // listView
|
|
283 //
|
|
284 this.listView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
|
285 | System.Windows.Forms.AnchorStyles.Left)
|
|
286 | System.Windows.Forms.AnchorStyles.Right)));
|
|
287 this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
|
288 this.colName,
|
|
289 this.colSize,
|
|
290 this.colSizeUncompressed,
|
|
291 this.colExtension,
|
|
292 this.colExtensionLong,
|
|
293 this.colCompressionType});
|
|
294 this.listView.ContextMenu = this.contextMenuFiles;
|
|
295 this.listView.LargeImageList = this.iconImageList;
|
|
296 this.listView.Location = new System.Drawing.Point(312, 20);
|
|
297 this.listView.Name = "listView";
|
|
298 this.listView.Size = new System.Drawing.Size(310, 470);
|
|
299 this.listView.SmallImageList = this.tinyImageList;
|
|
300 this.listView.TabIndex = 1;
|
|
301 this.listView.View = System.Windows.Forms.View.List;
|
|
302 this.listView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listView_ColumnClick);
|
|
303 this.listView.SelectedIndexChanged += new System.EventHandler(this.listView_SelectedIndexChanged);
|
|
304 //
|
|
305 // colName
|
|
306 //
|
|
307 this.colName.Text = "File Name";
|
|
308 this.colName.Width = 200;
|
|
309 //
|
|
310 // colSize
|
|
311 //
|
|
312 this.colSize.Text = "Size";
|
|
313 //
|
|
314 // colSizeUncompressed
|
|
315 //
|
|
316 this.colSizeUncompressed.Text = "Unzipped Size";
|
|
317 this.colSizeUncompressed.Width = 90;
|
|
318 //
|
|
319 // colExtension
|
|
320 //
|
|
321 this.colExtension.Text = "Extension";
|
|
322 this.colExtension.Width = 70;
|
|
323 //
|
|
324 // colExtensionLong
|
|
325 //
|
|
326 this.colExtensionLong.Text = "File Type Desc.";
|
|
327 this.colExtensionLong.Width = 120;
|
|
328 //
|
|
329 // colCompressionType
|
|
330 //
|
|
331 this.colCompressionType.Text = "Compression Type";
|
|
332 //
|
|
333 // iconImageList
|
|
334 //
|
|
335 this.iconImageList.ImageSize = new System.Drawing.Size(32, 32);
|
|
336 this.iconImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("iconImageList.ImageStream")));
|
|
337 this.iconImageList.TransparentColor = System.Drawing.Color.Transparent;
|
|
338 //
|
|
339 // tinyImageList
|
|
340 //
|
|
341 this.tinyImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
|
|
342 this.tinyImageList.ImageSize = new System.Drawing.Size(16, 16);
|
|
343 this.tinyImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("tinyImageList.ImageStream")));
|
|
344 this.tinyImageList.TransparentColor = System.Drawing.Color.Transparent;
|
|
345 //
|
|
346 // mainMenu1
|
|
347 //
|
|
348 this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
|
349 this.menuItem1,
|
|
350 this.menuItem13,
|
|
351 this.menuItem5,
|
|
352 this.menuItem15});
|
|
353 //
|
|
354 // menuItem1
|
|
355 //
|
|
356 this.menuItem1.Index = 0;
|
|
357 this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
|
358 this.menuItem2,
|
|
359 this.menuItem3,
|
|
360 this.menuItem4});
|
|
361 this.menuItem1.Text = "&File";
|
|
362 //
|
|
363 // menuItem2
|
|
364 //
|
|
365 this.menuItem2.Index = 0;
|
|
366 this.menuItem2.Text = "&Open";
|
|
367 this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
|
|
368 //
|
|
369 // menuItem3
|
|
370 //
|
|
371 this.menuItem3.Index = 1;
|
|
372 this.menuItem3.Text = "-";
|
|
373 //
|
|
374 // menuItem4
|
|
375 //
|
|
376 this.menuItem4.Index = 2;
|
|
377 this.menuItem4.Text = "E&xit";
|
|
378 this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
|
|
379 //
|
|
380 // menuItem13
|
|
381 //
|
|
382 this.menuItem13.Index = 1;
|
|
383 this.menuItem13.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
|
384 this.menuItem14});
|
|
385 this.menuItem13.Text = "&Edit";
|
|
386 //
|
|
387 // menuItem14
|
|
388 //
|
|
389 this.menuItem14.Index = 0;
|
|
390 this.menuItem14.Text = "&Options";
|
|
391 this.menuItem14.Click += new System.EventHandler(this.menuItem14_Click);
|
|
392 //
|
|
393 // menuItem5
|
|
394 //
|
|
395 this.menuItem5.Index = 2;
|
|
396 this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
|
397 this.menuItem6,
|
|
398 this.menuItem7,
|
|
399 this.menuItem8,
|
|
400 this.menuItem17,
|
|
401 this.menuItem18});
|
|
402 this.menuItem5.Text = "&View";
|
|
403 //
|
|
404 // menuItem6
|
|
405 //
|
|
406 this.menuItem6.Checked = true;
|
|
407 this.menuItem6.Index = 0;
|
|
408 this.menuItem6.RadioCheck = true;
|
|
409 this.menuItem6.Text = "&List";
|
|
410 this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
|
|
411 //
|
|
412 // menuItem7
|
|
413 //
|
|
414 this.menuItem7.Index = 1;
|
|
415 this.menuItem7.RadioCheck = true;
|
|
416 this.menuItem7.Text = "&Icons";
|
|
417 this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
|
|
418 //
|
|
419 // menuItem8
|
|
420 //
|
|
421 this.menuItem8.Index = 2;
|
|
422 this.menuItem8.RadioCheck = true;
|
|
423 this.menuItem8.Text = "&Detail";
|
|
424 this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
|
|
425 //
|
|
426 // menuItem17
|
|
427 //
|
|
428 this.menuItem17.Index = 3;
|
|
429 this.menuItem17.Text = "-";
|
|
430 //
|
|
431 // menuItem18
|
|
432 //
|
|
433 this.menuItem18.Index = 4;
|
|
434 this.menuItem18.Text = "Debug &Information";
|
|
435 this.menuItem18.Click += new System.EventHandler(this.menuItem18_Click);
|
|
436 //
|
|
437 // menuItem15
|
|
438 //
|
|
439 this.menuItem15.Index = 3;
|
|
440 this.menuItem15.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
|
441 this.menuItem16});
|
|
442 this.menuItem15.Text = "&Help";
|
|
443 //
|
|
444 // menuItem16
|
|
445 //
|
|
446 this.menuItem16.Index = 0;
|
|
447 this.menuItem16.Text = "&About";
|
|
448 this.menuItem16.Click += new System.EventHandler(this.menuItem16_Click);
|
|
449 //
|
|
450 // statusBar
|
|
451 //
|
|
452 this.statusBar.Location = new System.Drawing.Point(0, 490);
|
|
453 this.statusBar.Name = "statusBar";
|
|
454 this.statusBar.Size = new System.Drawing.Size(622, 22);
|
|
455 this.statusBar.TabIndex = 2;
|
|
456 //
|
|
457 // timer
|
|
458 //
|
|
459 this.timer.Interval = 1000;
|
|
460 this.timer.Tick += new System.EventHandler(this.timer_Tick);
|
|
461 //
|
|
462 // txtPath
|
|
463 //
|
|
464 this.txtPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
|
465 | System.Windows.Forms.AnchorStyles.Right)));
|
|
466 this.txtPath.Location = new System.Drawing.Point(0, 0);
|
|
467 this.txtPath.Name = "txtPath";
|
|
468 this.txtPath.Size = new System.Drawing.Size(556, 20);
|
|
469 this.txtPath.TabIndex = 3;
|
|
470 this.txtPath.Text = "";
|
|
471 this.txtPath.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtPath_KeyDown);
|
|
472 //
|
|
473 // bttnGo
|
|
474 //
|
|
475 this.bttnGo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
|
476 this.bttnGo.Enabled = false;
|
|
477 this.bttnGo.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
|
478 this.bttnGo.Location = new System.Drawing.Point(556, 0);
|
|
479 this.bttnGo.Name = "bttnGo";
|
|
480 this.bttnGo.Size = new System.Drawing.Size(66, 20);
|
|
481 this.bttnGo.TabIndex = 4;
|
|
482 this.bttnGo.Text = "Go";
|
|
483 this.bttnGo.Click += new System.EventHandler(this.bttnGo_Click);
|
|
484 //
|
|
485 // Form1
|
|
486 //
|
|
487 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
|
488 this.ClientSize = new System.Drawing.Size(622, 512);
|
|
489 this.Controls.Add(this.bttnGo);
|
|
490 this.Controls.Add(this.txtPath);
|
|
491 this.Controls.Add(this.statusBar);
|
|
492 this.Controls.Add(this.listView);
|
|
493 this.Controls.Add(this.treeView);
|
|
494 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
|
495 this.Menu = this.mainMenu1;
|
|
496 this.Name = "Form1";
|
|
497 this.Text = "SGA Explorer";
|
|
498 this.Load += new System.EventHandler(this.Form1_Load);
|
|
499 this.ResumeLayout(false);
|
|
500
|
|
501 }
|
|
502 #endregion
|
|
503
|
|
504 /// <summary>
|
|
505 /// The main entry point for the application.
|
|
506 /// </summary>
|
|
507 [STAThread]
|
|
508 static void Main(string[] args)
|
|
509 {
|
|
510 Application.EnableVisualStyles();
|
|
511 Application.DoEvents();
|
|
512 Application.Run(new Form1(args));
|
|
513 }
|
|
514
|
|
515 private void menuItem4_Click(object sender, System.EventArgs e)
|
|
516 {
|
|
517 this.Close();
|
|
518 }
|
|
519
|
|
520 private void Form1_Load(object sender, System.EventArgs e)
|
|
521 {
|
|
522 openFileDialog.FileName = "";
|
|
523 openFileDialog.Filter = "SGA Archive (*.sga)|*.sga";
|
|
524 openFileDialog.InitialDirectory = pref["DoWPath"].ToString();
|
|
525 openFileDialog.Multiselect = false;
|
|
526 openFileDialog.CheckFileExists = true;
|
|
527
|
|
528 foreach (ColumnHeader ch in listView.Columns)
|
|
529 {
|
|
530 ch.Width = -2;
|
|
531 }
|
|
532
|
|
533 }
|
|
534
|
|
535 private void menuItem2_Click(object sender, System.EventArgs e)
|
|
536 {
|
|
537 DialogResult dr = openFileDialog.ShowDialog(this);
|
|
538
|
|
539 if (dr==DialogResult.OK)
|
|
540 {
|
|
541 loadSGA(openFileDialog.FileName);
|
|
542 }
|
|
543 }
|
|
544
|
|
545 private void loadSGA(string archivePath)
|
|
546 {
|
|
547 if (archive!=null)
|
|
548 {
|
|
549 archive.OnExtractFileFail-= notificationFailure;
|
|
550 archive.OnExtractFolderFail-= notificationFailure;
|
|
551 archive.OnExtractFileSuccess-= notificationSuccess;
|
|
552 archive.OnExtractFolderSuccess-= notificationSuccess;
|
|
553 }
|
|
554
|
|
555 statusBar.Text = "Loading SGA File...";
|
|
556 Output("Loading SGA: "+archivePath, false);
|
|
557 try
|
|
558 {
|
|
559 archive = new SgaArchive(archivePath);
|
|
560
|
|
561 statusBar.Text = "Loading folders...";
|
|
562 root = new TreeNode(archive.Root.Name, 0, 1);
|
|
563 root.Tag = archive.Root;
|
|
564
|
|
565 foreach(SgaFolder child in archive.Root.SubFolders.Values)
|
|
566 {
|
|
567 loadFolderTree(child, root);
|
|
568 }
|
|
569
|
|
570 treeView.Nodes.Clear();
|
|
571 treeView.Nodes.Add(root);
|
|
572 listView.Items.Clear();
|
|
573 bttnGo.Enabled = true;
|
|
574
|
|
575 folderBrowserDialog.SelectedPath = archive.DefaultPath;
|
|
576
|
|
577 statusBar.Text = "Loaded";
|
|
578
|
|
579 archive.OnExtractFileFail+= notificationFailure;
|
|
580 archive.OnExtractFolderFail+= notificationFailure;
|
|
581 archive.OnExtractFileSuccess+= notificationSuccess;
|
|
582 archive.OnExtractFolderSuccess+= notificationSuccess;
|
|
583 }
|
|
584 catch (Exception ex)
|
|
585 {
|
|
586 debugWindow.AddText(ex.Message+Environment.NewLine+ex.StackTrace);
|
|
587 ShowOutput(false);
|
|
588 ClearOutput(false);
|
|
589 MessageBox.Show(this, "Error: "+ ex.Message);
|
|
590 }
|
|
591 finally
|
|
592 {
|
|
593 timer.Enabled = true;
|
|
594 }
|
|
595 }
|
|
596
|
|
597 private void loadFolderTree(SgaFolder folder, TreeNode parent)
|
|
598 {
|
|
599 TreeNode node = new TreeNode(folder.Name, 0, 1);
|
|
600 node.Tag = folder;
|
|
601 parent.Nodes.Add(node);
|
|
602
|
|
603 foreach(SgaFolder child in folder.SubFolders.Values)
|
|
604 {
|
|
605 loadFolderTree(child, node);
|
|
606 }
|
|
607 }
|
|
608
|
|
609 private void treeView_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
|
|
610 {
|
|
611 SgaFolder folder = (SgaFolder)e.Node.Tag;
|
|
612
|
|
613 listView.Items.Clear();
|
|
614
|
|
615 if (folder!=null)
|
|
616 {
|
|
617 txtPath.Text = folder.Path.TrimEnd('\\');
|
|
618 }
|
|
619 else
|
|
620 {
|
|
621 txtPath.Text = "";
|
|
622 }
|
|
623
|
|
624 if (folder!=null && folder.Files.Count>0)
|
|
625 {
|
|
626 statusBar.Text = "Loading files...";
|
|
627 ListViewItem item;
|
|
628 ListViewItem[] items = new ListViewItem[folder.Files.Count];
|
|
629 int i = 0;
|
|
630
|
|
631 foreach (SgaFile file in folder.Files.Values)
|
|
632 {
|
|
633 //FIXME: In Linux the items are in a seemingly random order, even though they're added in alphabetical order
|
|
634 item = new ListViewItem(file.Name, 0);//(int)file.Format);
|
|
635 item.SubItems.AddRange(new string[]{file.Size.ToString(), file.SizeUncompressed.ToString(), file.Type, file.TypeDesc, file.Compression.ToString()});
|
|
636 item.Tag = file;
|
|
637 items[i] = item;
|
|
638 i++;
|
|
639 }
|
|
640
|
|
641 listView.Items.AddRange(items);
|
|
642
|
|
643 statusBar.Text = "Loaded";
|
|
644 timer.Enabled = true;
|
|
645 }
|
|
646 else
|
|
647 {
|
|
648 statusBar.Text = "";
|
|
649 }
|
|
650
|
|
651 if (treeView.SelectedNode!=null)
|
|
652 {
|
|
653 foreach(MenuItem item in contextMenuFiles.MenuItems)
|
|
654 {
|
|
655 item.Enabled = true;
|
|
656 }
|
|
657 }
|
|
658 else
|
|
659 {
|
|
660 foreach(MenuItem item in contextMenuFiles.MenuItems)
|
|
661 {
|
|
662 item.Enabled = false;
|
|
663 }
|
|
664 }
|
|
665
|
|
666 }
|
|
667
|
|
668 private void timer_Tick(object sender, System.EventArgs e)
|
|
669 {
|
|
670 timer.Enabled = false;
|
|
671 statusBar.Text = ((listView.Items.Count>1)?listView.Items.Count+" items":((listView.Items.Count>0)?"1 item":""));
|
|
672 }
|
|
673
|
|
674 private void menuItem6_Click(object sender, System.EventArgs e)
|
|
675 {
|
|
676 listView.View = View.List;
|
|
677 menuItem6.Checked = true;
|
|
678 menuItem7.Checked = false;
|
|
679 menuItem8.Checked = false;
|
|
680 }
|
|
681
|
|
682 private void menuItem7_Click(object sender, System.EventArgs e)
|
|
683 {
|
|
684 listView.View = View.LargeIcon;
|
|
685 menuItem6.Checked = false;
|
|
686 menuItem7.Checked = true;
|
|
687 menuItem8.Checked = false;
|
|
688 }
|
|
689
|
|
690 private void menuItem8_Click(object sender, System.EventArgs e)
|
|
691 {
|
|
692 listView.View = View.Details;
|
|
693 menuItem6.Checked = false;
|
|
694 menuItem7.Checked = false;
|
|
695 menuItem8.Checked = true;
|
|
696 }
|
|
697
|
|
698 private void listView_SelectedIndexChanged(object sender, System.EventArgs e)
|
|
699 {
|
|
700 }
|
|
701
|
|
702 private void menuItem9_Click(object sender, System.EventArgs e)
|
|
703 {
|
|
704 ClearOutput();
|
|
705
|
|
706 if (listView.Focused)
|
|
707 {
|
|
708 foreach(ListViewItem item in listView.SelectedItems)
|
|
709 {
|
|
710 if (item.Tag is SgaFile)
|
|
711 {
|
|
712 archive.Extract(((SgaFile)item.Tag).Path, (bool)pref["Overwrite"]);
|
|
713 }
|
|
714 }
|
|
715 }
|
|
716 else if (treeView.Focused)
|
|
717 {
|
|
718 if (treeView.SelectedNode!=null)
|
|
719 {
|
|
720 archive.ExtractFolder(((SgaFolder)treeView.SelectedNode.Tag).Path, true, (bool)pref["Overwrite"]);
|
|
721 }
|
|
722 }
|
|
723
|
|
724 ShowOutput(true);
|
|
725 }
|
|
726
|
|
727 private void listView_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e)
|
|
728 {
|
|
729 // Determine if clicked column is already the column that is being sorted.
|
|
730 if ( e.Column == listViewSorter.SortColumn )
|
|
731 {
|
|
732 // Reverse the current sort direction for this column.
|
|
733 if (listViewSorter.Order == SortOrder.Ascending)
|
|
734 {
|
|
735 listViewSorter.Order = SortOrder.Descending;
|
|
736 }
|
|
737 else
|
|
738 {
|
|
739 listViewSorter.Order = SortOrder.Ascending;
|
|
740 }
|
|
741 }
|
|
742 else
|
|
743 {
|
|
744 // Set the column number that is to be sorted; default to ascending.
|
|
745 listViewSorter.SortColumn = e.Column;
|
|
746 listViewSorter.Order = SortOrder.Ascending;
|
|
747 }
|
|
748
|
|
749 // Perform the sort with these new sort options.
|
|
750 this.listView.Sort();
|
|
751 }
|
|
752
|
|
753 private void menuItem16_Click(object sender, System.EventArgs e)
|
|
754 {
|
|
755 AboutSGAExplorer frm = new AboutSGAExplorer();
|
|
756 frm.ShowDialog(this);
|
|
757 frm.Dispose();
|
|
758 }
|
|
759
|
|
760 private void menuItem14_Click(object sender, System.EventArgs e)
|
|
761 {
|
|
762 DialogResult dr = opt.ShowDialog(this);
|
|
763
|
|
764 if (dr==DialogResult.OK)
|
|
765 {
|
|
766 if ((View)pref["ViewType"]!=listView.View)
|
|
767 {
|
|
768 switch((View)pref["ViewType"])
|
|
769 {
|
|
770 case View.List: menuItem6_Click(this, EventArgs.Empty);
|
|
771 break;
|
|
772 case View.LargeIcon: menuItem7_Click(this, EventArgs.Empty);
|
|
773 break;
|
|
774 case View.Details: menuItem8_Click(this, EventArgs.Empty);
|
|
775 break;
|
|
776 default: menuItem6_Click(this, EventArgs.Empty);
|
|
777 break;
|
|
778 }
|
|
779 }
|
|
780
|
|
781 if ((bool)pref["ShowDebug"])
|
|
782 {
|
|
783 debugWindow.Show();
|
|
784 menuItem18.Checked = true;
|
|
785 }
|
|
786 else
|
|
787 {
|
|
788 debugWindow.Hide();
|
|
789 menuItem18.Checked = false;
|
|
790 }
|
|
791 }
|
|
792 }
|
|
793
|
|
794 private void bttnGo_Click(object sender, System.EventArgs e)
|
|
795 {
|
|
796 string file = "";
|
|
797
|
|
798 if (txtPath.Text == "")
|
|
799 {
|
|
800 txtPath.Text = this.archive.Root.Path;
|
|
801 }
|
|
802
|
|
803 txtPath.Text.Replace("/", "\\");
|
|
804
|
|
805 if (txtPath.Text.LastIndexOf('.')>txtPath.Text.LastIndexOf('\\'))
|
|
806 {
|
|
807 int pos = txtPath.Text.LastIndexOf('\\');
|
|
808 file = txtPath.Text.Substring(pos+1);
|
|
809 txtPath.Text = txtPath.Text.Substring(0, pos);
|
|
810 }
|
|
811
|
|
812 //remove the leading slash before we split because of the new path format
|
|
813 string[] pathParts = txtPath.Text.TrimStart('\\').Split('\\');
|
|
814 bool found = false;
|
|
815 TreeNode folder = treeView.Nodes[0];
|
|
816
|
|
817 if (folder.Text!=pathParts[0])
|
|
818 {
|
|
819 MessageBox.Show(this, "The path '"+txtPath.Text+"' could not be found in this SGA archive.\r\nPlease check the path and try again", "Path not found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
|
820 txtPath.Focus();
|
|
821 txtPath.SelectAll();
|
|
822 return;
|
|
823 }
|
|
824 else if (pathParts.Length > 1)
|
|
825 {
|
|
826 for (int i = 1; i<pathParts.Length; i++)
|
|
827 {
|
|
828 found = false;
|
|
829
|
|
830 foreach (TreeNode fold in folder.Nodes)
|
|
831 {
|
|
832 if (fold.Text==pathParts[i])
|
|
833 {
|
|
834 folder = fold;
|
|
835 found = true;
|
|
836 break;
|
|
837 }
|
|
838 }
|
|
839
|
|
840 if (found==false)
|
|
841 {
|
|
842 MessageBox.Show(this, "The path '"+txtPath.Text+"' could not be found in this SGA archive.\r\nPlease check the path and try again", "Path not found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
|
843 txtPath.Focus();
|
|
844 txtPath.SelectAll();
|
|
845 return;
|
|
846 }
|
|
847 }
|
|
848 }
|
|
849
|
|
850 treeView.SelectedNode = folder;
|
|
851
|
|
852 if (file!="")
|
|
853 {
|
|
854 Application.DoEvents();
|
|
855
|
|
856 foreach(ListViewItem lvi in listView.Items)
|
|
857 {
|
|
858 if (lvi.Text == file)
|
|
859 {
|
|
860 lvi.Selected = true;
|
|
861 break;
|
|
862 }
|
|
863 }
|
|
864
|
|
865 listView.Select();
|
|
866 }
|
|
867 }
|
|
868
|
|
869 private void txtPath_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
|
|
870 {
|
|
871 if(e.KeyData == (Keys.Control|Keys.A) && e.Control)
|
|
872 {
|
|
873 txtPath.SelectAll();
|
|
874 }
|
|
875 else if (e.KeyData == Keys.Enter && bttnGo.Enabled)
|
|
876 {
|
|
877 bttnGo_Click(txtPath, EventArgs.Empty);
|
|
878 }
|
|
879 }
|
|
880
|
|
881 private void menuItem10_Click(object sender, System.EventArgs e)
|
|
882 {
|
|
883 bool defaultPath = false;
|
|
884
|
|
885 string path = folderBrowserDialog.SelectedPath+"\\"+((SgaFolder)treeView.SelectedNode.Tag).InternalPath.TrimEnd('\\');
|
|
886
|
|
887 if (folderBrowserDialog.SelectedPath == archive.DefaultPath)
|
|
888 {
|
|
889 defaultPath = true;
|
|
890
|
|
891 if (!Directory.Exists(path))
|
|
892 {
|
|
893 Directory.CreateDirectory(path);
|
|
894 }
|
|
895
|
|
896 folderBrowserDialog.SelectedPath = path;
|
|
897 }
|
|
898
|
|
899 DialogResult dr = folderBrowserDialog.ShowDialog();
|
|
900
|
|
901 if (dr==DialogResult.OK)
|
|
902 {
|
|
903 if (path != folderBrowserDialog.SelectedPath)
|
|
904 {
|
|
905 defaultPath = false;
|
|
906 }
|
|
907
|
|
908 ClearOutput();
|
|
909 if (listView.Focused)
|
|
910 {
|
|
911 foreach(ListViewItem item in listView.SelectedItems)
|
|
912 {
|
|
913 if (item.Tag is SgaFile)
|
|
914 {
|
|
915 archive.Extract(((SgaFile)item.Tag).Path, folderBrowserDialog.SelectedPath, (bool)pref["Overwrite"]);
|
|
916 }
|
|
917 }
|
|
918 }
|
|
919 else if (treeView.Focused)
|
|
920 {
|
|
921 if (treeView.SelectedNode!=null)
|
|
922 {
|
|
923 archive.ExtractFolder(((SgaFolder)treeView.SelectedNode.Tag).Path, folderBrowserDialog.SelectedPath, true, (bool)pref["Overwrite"]);
|
|
924 }
|
|
925 }
|
|
926
|
|
927 ShowOutput(true);
|
|
928 }
|
|
929
|
|
930 if (defaultPath)
|
|
931 {
|
|
932 folderBrowserDialog.SelectedPath = archive.DefaultPath;
|
|
933 }
|
|
934 }
|
|
935
|
|
936 private void treeView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
|
|
937 {
|
|
938 if (e.Button == MouseButtons.Right)
|
|
939 {
|
|
940 TreeNode tn = treeView.GetNodeAt(e.X, e.Y);
|
|
941
|
|
942 if (tn!=null)
|
|
943 {
|
|
944 treeView.SelectedNode = tn;
|
|
945 }
|
|
946 else
|
|
947 {
|
|
948 treeView.SelectedNode = null;
|
|
949 }
|
|
950 }
|
|
951 }
|
|
952
|
|
953 private void contextMenuFiles_Popup(object sender, System.EventArgs e)
|
|
954 {
|
|
955 if (listView.Focused)
|
|
956 {
|
|
957 if (listView.SelectedItems.Count>0)
|
|
958 {
|
|
959 foreach(MenuItem item in contextMenuFiles.MenuItems)
|
|
960 {
|
|
961 item.Enabled = !item.RadioCheck;
|
|
962 item.Visible = !(item==miTypeToDefaultHexedit || item==miTypeToLocationHexedit || item==miTypeToDefault || item==miTypeToLocation);
|
|
963 }
|
|
964 }
|
|
965 else
|
|
966 {
|
|
967 foreach(MenuItem item in contextMenuFiles.MenuItems)
|
|
968 {
|
|
969 item.Enabled = false;
|
|
970 item.Visible = !(item==miTypeToDefaultHexedit || item==miTypeToLocationHexedit || item==miTypeToDefault || item==miTypeToLocation);
|
|
971 }
|
|
972 }
|
|
973 }
|
|
974 else if (treeView.Focused)
|
|
975 {
|
|
976 if (treeView.SelectedNode!=null)
|
|
977 {
|
|
978 foreach(MenuItem item in contextMenuFiles.MenuItems)
|
|
979 {
|
|
980 item.Enabled = !item.RadioCheck;
|
|
981 item.Visible = true;
|
|
982 }
|
|
983 }
|
|
984 else
|
|
985 {
|
|
986 foreach(MenuItem item in contextMenuFiles.MenuItems)
|
|
987 {
|
|
988 item.Visible = false;
|
|
989 }
|
|
990 }
|
|
991 }
|
|
992 }
|
|
993
|
|
994 private void ExtractionSuccess(string type, string name, string message)
|
|
995 {
|
|
996 extractSuccess++;
|
|
997 Output(String.Format("Extraction of {0} \"{1}\" succeeded", type, name), true);
|
|
998 }
|
|
999
|
|
1000 private void ExtractionFailure(string type, string name, string message)
|
|
1001 {
|
|
1002 extractFailure++;
|
|
1003 Output(String.Format("Extraction of {0} \"{1}\" failed: {2}", type, name, message), true);
|
|
1004 }
|
|
1005
|
|
1006 private void ExtractionEvent(string type, string name, string message)
|
|
1007 {
|
|
1008 Output(message, false);
|
|
1009 }
|
|
1010
|
|
1011 private void Output(string str, bool dialog)
|
|
1012 {
|
|
1013 str+= Environment.NewLine;
|
|
1014
|
|
1015 if (dialog)
|
|
1016 {
|
|
1017 output+= str;
|
|
1018 }
|
|
1019
|
|
1020 debugWindow.AddText(str);
|
|
1021 }
|
|
1022
|
|
1023 private void ShowOutput(bool dialog)
|
|
1024 {
|
|
1025 if (dialog)
|
|
1026 {
|
|
1027 if (output!="")
|
|
1028 {
|
|
1029 string msg = output;
|
|
1030
|
|
1031 if (extractFailure+extractSuccess>10)
|
|
1032 {
|
|
1033 msg = Regex.Replace(output, "(([^\r]+\r\n){10}).*", "$1", RegexOptions.Singleline)+"..."+Environment.NewLine+Environment.NewLine+"Too many messages to display. Check debug for full output.";
|
|
1034 }
|
|
1035
|
|
1036 MessageBox.Show(this, String.Format("{0} successes and {1} failures", extractSuccess, extractFailure) +Environment.NewLine+Environment.NewLine+
|
|
1037 msg, "Extraction Messages", MessageBoxButtons.OK,
|
|
1038 MessageBoxIcon.Information);
|
|
1039 }
|
|
1040 }
|
|
1041 else
|
|
1042 {
|
|
1043 debugWindow.Show();
|
|
1044 }
|
|
1045 }
|
|
1046
|
|
1047 private void ClearOutput()
|
|
1048 {
|
|
1049 ClearOutput(false);
|
|
1050 }
|
|
1051
|
|
1052 private void menuItem18_Click(object sender, System.EventArgs e)
|
|
1053 {
|
|
1054 if (!menuItem18.Checked)
|
|
1055 {
|
|
1056 debugWindow.Show();
|
|
1057 }
|
|
1058 else
|
|
1059 {
|
|
1060 debugWindow.Hide();
|
|
1061 }
|
|
1062
|
|
1063 menuItem18.Checked = !menuItem18.Checked;
|
|
1064 }
|
|
1065
|
|
1066 private void ClearOutput(bool clearDebug)
|
|
1067 {
|
|
1068 output = "";
|
|
1069 extractFailure = 0;
|
|
1070 extractSuccess = 0;
|
|
1071
|
|
1072 if (clearDebug)
|
|
1073 {
|
|
1074 debugWindow.ClearText();
|
|
1075 }
|
|
1076 else
|
|
1077 {
|
|
1078 //else if we don't want to clear the debug window, just add a new line to space the
|
|
1079 //next lot of output away from the last lot
|
|
1080 debugWindow.AddText(Environment.NewLine);
|
|
1081 }
|
|
1082 }
|
|
1083
|
|
1084 private void debugWindow_Closing(object sender, CancelEventArgs e)
|
|
1085 {
|
|
1086 menuItem18.Checked = false;
|
|
1087 }
|
|
1088
|
|
1089 private void miTypeToDefault_Click(object sender, System.EventArgs e)
|
|
1090 {
|
|
1091 if (treeView.Focused)
|
|
1092 {
|
|
1093 FrmFileType type = new FrmFileType();
|
|
1094 DialogResult dr = type.ShowDialog(this);
|
|
1095
|
|
1096 if (dr==DialogResult.OK)
|
|
1097 {
|
|
1098 ClearOutput();
|
|
1099
|
|
1100 if (treeView.SelectedNode!=null)
|
|
1101 {
|
|
1102 archive.ExtractType(type.SelectedExtension, ((SgaFolder)treeView.SelectedNode.Tag).Path, true, (bool)pref["Overwrite"]);
|
|
1103 }
|
|
1104
|
|
1105 ShowOutput(true);
|
|
1106 }
|
|
1107 }
|
|
1108 }
|
|
1109
|
|
1110 private void miTypeToLocation_Click(object sender, System.EventArgs e)
|
|
1111 {
|
|
1112 if (treeView.Focused)
|
|
1113 {
|
|
1114 FrmFileType type = new FrmFileType();
|
|
1115 DialogResult dr = type.ShowDialog(this);
|
|
1116
|
|
1117 if (dr!=DialogResult.OK)
|
|
1118 {
|
|
1119 return;
|
|
1120 }
|
|
1121
|
|
1122 bool defaultPath = false;
|
|
1123
|
|
1124 string path = folderBrowserDialog.SelectedPath+"\\"+((SgaFolder)treeView.SelectedNode.Tag).InternalPath.TrimEnd('\\');
|
|
1125
|
|
1126 if (folderBrowserDialog.SelectedPath == archive.DefaultPath)
|
|
1127 {
|
|
1128 defaultPath = true;
|
|
1129
|
|
1130 if (!Directory.Exists(path))
|
|
1131 {
|
|
1132 Directory.CreateDirectory(path);
|
|
1133 }
|
|
1134
|
|
1135 folderBrowserDialog.SelectedPath = path;
|
|
1136 }
|
|
1137
|
|
1138 dr = folderBrowserDialog.ShowDialog();
|
|
1139
|
|
1140 if (dr==DialogResult.OK)
|
|
1141 {
|
|
1142 if (path != folderBrowserDialog.SelectedPath)
|
|
1143 {
|
|
1144 defaultPath = false;
|
|
1145 }
|
|
1146
|
|
1147 ClearOutput();
|
|
1148 if (treeView.SelectedNode!=null)
|
|
1149 {
|
|
1150 archive.ExtractType(type.SelectedExtension, ((SgaFolder)treeView.SelectedNode.Tag).Path, folderBrowserDialog.SelectedPath, true, (bool)pref["Overwrite"]);
|
|
1151 }
|
|
1152
|
|
1153 ShowOutput(true);
|
|
1154 }
|
|
1155
|
|
1156 if (defaultPath)
|
|
1157 {
|
|
1158 folderBrowserDialog.SelectedPath = archive.DefaultPath;
|
|
1159 }
|
|
1160 }
|
|
1161 }
|
|
1162
|
|
1163 private void miTypeToDefaultHexedit_Click(object sender, System.EventArgs e)
|
|
1164 {
|
|
1165
|
|
1166 }
|
|
1167
|
|
1168 private void miTypeToLocationHexedit_Click(object sender, System.EventArgs e)
|
|
1169 {
|
|
1170
|
|
1171 }
|
|
1172 }
|
|
1173 }
|