forked from belisleian/uTikDownloadHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
75 lines (65 loc) · 2.18 KB
/
Program.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
using System;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using System.Linq;
namespace uTikDownloadHelper
{
class Program
{
public static ExtractedResources ResourceFiles = new ExtractedResources();
public static MultiFormContext FormContext = new MultiFormContext();
[STAThread]
static void Main(string[] args)
{
Directory.CreateDirectory(Common.TicketsPath);
if (Common.Settings.ticketWebsite == null) Common.Settings.ticketWebsite = "";
if (args.Length == 0)
{
using (frmList frm = new frmList())
{
FormContext.AddForm(frm);
Application.Run(FormContext);
}
return;
}
if (args[0].ToLower().EndsWith(".tmd"))
{
if (File.Exists(args[0]))
{
frmDownload.DownloadMissing(args[0], true);
Application.Run(FormContext);
}
return;
}
string ticketInputPath = args[0];
Byte[] ticket = { };
if (ticketInputPath.ToLower().StartsWith("http"))
{
try
{
ticket = (new System.Net.WebClient()).DownloadData(ticketInputPath);
} catch (Exception e)
{
MessageBox.Show(e.Message.ToString(), "Error Downloading Ticket");
return;
}
} else
{
ticket = File.ReadAllBytes(ticketInputPath);
}
if (ticket.Length < 848)
{
MessageBox.Show("Invalid Ticket");
}
using (var frm = new frmDownload()){
string hexID = HelperFunctions.getTitleIDFromTicket(ticket);
TitleInfo info = new TitleInfo(hexID, "", hexID, "", "", true);
info.ticket = ticket;
frm.TitleQueue.Add(info);
FormContext.AddForm(frm);
Application.Run(FormContext);
}
}
}
}