forked from w8tcha/ripper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSingleInstanceController.cs
87 lines (74 loc) · 3.4 KB
/
SingleInstanceController.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
76
77
78
79
80
81
82
83
84
85
86
87
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SingleInstanceController.cs" company="The Watcher">
// Copyright (c) The Watcher Partial Rights Reserved.
// // // This software is licensed under the MIT license. See license.txt for details.
// </copyright>
// <summary>
// Code Named: VG-Ripper
// Function : Extracts Images posted on RiP forums and attempts to fetch them to disk.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Ripper
{
using System.Windows.Forms;
using Microsoft.VisualBasic.ApplicationServices;
using Ripper.Core.Components;
/// <summary>
/// Single Instance Controller
/// </summary>
public class SingleInstanceController : WindowsFormsApplicationBase
{
/// <summary>
/// Initializes a new instance of the <see cref="SingleInstanceController"/> class.
/// </summary>
public SingleInstanceController()
{
// Set whether the application is single instance
this.IsSingleInstance = true;
this.StartupNextInstance += SingleInstanceController_StartupNextInstance;
this.Startup += SingleInstanceController_Startup;
}
/// <summary>
/// When overridden in a derived class, allows a designer to emit code that configures the splash screen and main form.
/// </summary>
protected override void OnCreateMainForm()
{
// Instantiate your main application form
this.MainForm = new MainForm();
}
/// <summary>
/// Handles the Startup event of the SingleInstanceController control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="Microsoft.VisualBasic.ApplicationServices.StartupEventArgs"/> instance containing the event data.</param>
private static void SingleInstanceController_Startup(object sender, StartupEventArgs e)
{
if (e.CommandLine.Count <= 0 || string.IsNullOrEmpty(e.CommandLine[0]))
{
return;
}
var extractedUrl = ProtocolHelper.ProccesArguments(e.CommandLine[0]);
if (!string.IsNullOrEmpty(extractedUrl))
{
Clipboard.SetText(extractedUrl);
}
}
/// <summary>
/// Handles the StartupNextInstance event of the this control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs"/> instance containing the event data.</param>
private static void SingleInstanceController_StartupNextInstance(object sender, StartupNextInstanceEventArgs e)
{
if (e.CommandLine.Count <= 0 || string.IsNullOrEmpty(e.CommandLine[0]))
{
return;
}
var extractedUrl = ProtocolHelper.ProccesArguments(e.CommandLine[0]);
if (!string.IsNullOrEmpty(extractedUrl))
{
Clipboard.SetText(extractedUrl);
}
}
}
}