-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (45 loc) · 1.34 KB
/
Program.cs
File metadata and controls
53 lines (45 loc) · 1.34 KB
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
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Xml.Linq;
namespace MemeGen
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (args.Length > 0)
RunFromArguments(args);
else
Application.Run(new frmSettings());
}
static void RunFromArguments(string[] args)
{
if (args.Length % 2 != 0)
{
Console.WriteLine("Invalid number of parameters.");
return;
}
List<(Image, string)> steps = new List<(Image, string)>();
for (int i = 0; i < args.Length; i += 2)
{
Image image;
try { image = Image.FromFile(args[i]); }
catch (Exception e)
{
Console.WriteLine($"Could not load image {args[i]}: {e.Message}");
return;
}
steps.Add((image, args[i + 1]));
}
Application.Run(new frmMeme(steps));
}
}
}