-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainLoader.cs
113 lines (82 loc) · 2.69 KB
/
MainLoader.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace DmScrCap
{
public class MainLoader
{
public bool En_AutoSave = false;
public string Def_FName;
public FormEditor Editor;
public FormCapturer Cap;
public FormBucket Bucket;
public NotificationControl SystemIcon;
public MainLoader(string CommandLine)
{
Cap = new FormCapturer();
Editor = new FormEditor();
Bucket = new FormBucket();
Parse_Parameter(CommandLine);
SystemIcon = new NotificationControl(Editor, Editor.Icon);
ToolStripMenuItem item;
item = new ToolStripMenuItem();
item.Click += SystemIconMenuBucket_Click;
item.Text = "Bucket";
SystemIcon.AddMenuItem(item);
item = new ToolStripMenuItem();
item.Click += SystemIconMenuEditor_Click;
item.Text = "Editor";
SystemIcon.AddMenuItem(item);
Editor.Hide();
}
void SystemIconMenuBucket_Click(object sender, EventArgs e)
{
Bucket.Show();
}
void SystemIconMenuEditor_Click(object sender, EventArgs e)
{
Editor.Show();
}
public void Parse_Parameter(string StrParam)
{
En_AutoSave = (StrParam.IndexOf("/save") >= 0);
Def_FName = GetStrInStr(StrParam, "(", ")");
}
public static string GetStrInStr(string Inp, string StrSt, string StrEn)
{
if (Inp.Length == 0)
return "";
int St = Inp.IndexOf(StrSt);
int En = Inp.IndexOf(StrEn);
if (((St < 0) || (En < 0)) && (En <= St))
return "";
return Inp.Substring(St + 1, En - St - 1);
}
public int RunWait()
{
Cap.SetRectFullScreen();
Editor.DisplayImage.Image = Cap.LoadBitmapFromScreen();
while (Editor.ShowDialog() == DialogResult.Retry)
{
if (Cap.ShowDialog() == DialogResult.Cancel)
break;
Editor.DisplayImage.Image = Cap.LoadBitmapFromScreen();
}
if (Editor.DialogResult == DialogResult.Yes)
{
if (En_AutoSave)
{
Editor.SaveImageFile(Def_FName);
return 1;
}
else
{
if (Editor.SaveImageFile())
return 1;
}
}
return 0;
}
}
}