-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
61 lines (54 loc) · 1.92 KB
/
Program.cs
File metadata and controls
61 lines (54 loc) · 1.92 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
54
55
56
57
58
59
60
61
using System;
using System.Linq;
using System.Windows.Forms;
using GIF_Viewer.Utils;
using Microsoft.VisualBasic.ApplicationServices;
namespace GIF_Viewer
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// Setup and run the application
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
FormMain form = new FormMain(args);
// Load the program settings
Settings.Instance.LoadSettings();
// Create the application base.
WindowsApplicationBase applicationBase = new WindowsApplicationBase(form, Settings.Instance.SingleInstance);
applicationBase.StartupNextInstance += (sender, eventArgs) =>
{
if (!Settings.Instance.SingleInstance)
return;
eventArgs.BringToForeground = true;
form.TopMost = true;
form.ProcessCommandLine(eventArgs.CommandLine.ToArray());
form.BringToFront();
form.TopMost = false;
form.Focus();
};
applicationBase.Run(args);
}
}
/// <summary>
/// Class used to manage singleton instances of the application
/// </summary>
public class WindowsApplicationBase : WindowsFormsApplicationBase
{
/// <summary>
/// Initializes a new instance of the WindowsApplicationBase class
/// </summary>
/// <param name="form">The target form to open</param>
/// <param name="singleInstance">Whether the application should be single-instance</param>
public WindowsApplicationBase(Form form, bool singleInstance)
{
IsSingleInstance = singleInstance;
MainForm = form;
}
}
}