/[DXTViewerLoader]/trunk/DXTViewerLoader/main.cs
ViewVC logotype

Contents of /trunk/DXTViewerLoader/main.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 14 - (show annotations) (download)
Thu Dec 12 12:28:07 2013 UTC (6 years, 7 months ago) by william
File size: 3503 byte(s)

1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Linq;
5 using System.Data;
6 using System.Drawing;
7 using System.Text;
8 using System.Windows.Forms;
9 using Enterprise.Logging;
10 using System.IO;
11 using System.Diagnostics;
12
13 namespace DXTViewerLoader
14 {
15 public partial class main : Form
16 {
17 static bool bHideForm = true;
18 static string target_image = string.Empty;
19
20 private void GetCommandLineArgs()
21 {
22 var targs = Environment.GetCommandLineArgs();
23 List<string> args = targs.ToList().GetRange(1, targs.Count() - 1);
24
25 int index = 0;
26 #if DEV_DEBUG
27 args = new List<string>() { @"C:\temp\tamriel.32.0.0.dds" };
28 #endif
29 gLog.Debug.WriteLine("Recieved: {0} commandline arguemnts", args.Count);
30 foreach (var arg in args)
31 {
32 try
33 {
34 FileInfo fi = null;
35 //string path = string.Format(@"{0}{1}", data_path, arg);
36 string path = string.Format(@"{0}",arg);
37 try { fi = new FileInfo(path); }
38 catch (NotSupportedException) { fi = new FileInfo(arg); } // catch unsupported paths, allow all exceptions to be thrown
39 gLog.Debug.WriteLine("arg[{0}]: '{1}' plugin found: '{2}'", index, arg, fi.Exists);
40
41 if (!fi.Exists)
42 {
43 try { throw new DXTViewer.Exceptions.ImageNotFoundException(true, fi.FullName); }
44 catch (Exception) { }
45 }
46 else
47 {
48 target_image = fi.FullName;
49 }
50 index++;
51 }
52 catch (Exception ex)
53 {
54 throw new DXTViewer.Exceptions.ImageNotFoundException(true, arg, ex);
55 }
56 }
57 }
58 private DXTViewer.IInitializationParameters GetInitializationParameters()
59 {
60 GetCommandLineArgs();
61 DXTViewer.InitializationParameters parameters = new DXTViewer.InitializationParameters(target_image);
62 return parameters;
63 }
64
65 public main()
66 {
67 InitializeComponent();
68 string log_path = Application.StartupPath;
69 string log_filename = string.Format("{0}.log", typeof(main).Assembly.GetName().Name);
70 gLog.CreateLog(string.Format(@"{0}\{1}", log_path, log_filename), false, LogLevel.kLogLevel_All);
71 }
72
73 private void main_Load(object sender, EventArgs e)
74 {
75 gLog.Debug.WriteLine("main loaded");
76 this.DoWork();
77 HideForm();
78 }
79 private void HideForm()
80 {
81 gLog.Debug.WriteLine("closing main form :: bHideForm == {0}", bHideForm.ToString());
82 if (!bHideForm)
83 {
84 gLog.Debug.WriteLine("main form not closed");
85 }
86 else
87 {
88 this.Close();
89 gLog.Debug.WriteLine("main form closed");
90 }
91 }
92 private void DoWork()
93 {
94 try
95 {
96 DXTViewer.Initialize(GetInitializationParameters());
97 DXTViewer.DoWork();
98 }
99 catch { }
100 }
101 }
102 }

  ViewVC Help
Powered by ViewVC 1.1.22