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

Contents of /trunk/DXTViewerLoader/main.cs

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.22