-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
164 lines (144 loc) · 5.28 KB
/
Form1.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
using System.Diagnostics;
using System.Reflection;
using FFmpegMagick.Classes;
using FFmpegMagick.UserControls;
namespace FFmpegMagick
{
public partial class Form1 : Form
{
private readonly UC_Images uc_images = new();
private readonly UC_Settings uc_settings = new();
public Form1()
{
Directory.SetCurrentDirectory(AppContext.BaseDirectory);
InitializeComponent();
ArgsProgram.Args();
}
private void Form1_Load(object sender, EventArgs e)
{
Updater.CheckUpdate();
}
private void UC_Images_ClearListBoxRequested(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
void addUserControl(UserControl userControl)
{
userControl.Dock = DockStyle.Fill;
panelUserControl.Controls.Clear();
panelUserControl.Controls.Add(userControl);
panelUserControl.BringToFront();
}
private void button1_Click(object sender, EventArgs e)
{
Regedit.Reg();
}
private void panel1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
labelDragAndDrop.Text = "Отпустите мышь";
e.Effect = DragDropEffects.Copy;
}
}
private void panel1_DragLeave(object sender, EventArgs e)
{
labelDragAndDrop.Text = "Перетащите файлы сюда";
}
private void panel1_DragDrop(object sender, DragEventArgs e)
{
labelDragAndDrop.Text = "Перетащите файлы сюда";
List<string> paths = [];
foreach (string obj in (string[])e.Data.GetData(DataFormats.FileDrop))
if (Directory.Exists(obj))
{
paths.AddRange(Directory.GetFiles(obj, "*.*", SearchOption.AllDirectories));
}
else
{
// Проверка расширения файла
string extension = Path.GetExtension(obj).ToLower();
if (Utils.IsAllowedExtension(extension))
{
paths.Add(obj);
}
}
foreach (string path in paths)
{
string fileName = Path.GetFileName(path);
if (Utils.IsAllowedExtension(Path.GetExtension(fileName).ToLower()))
{
if (!listBox1.Items.Contains(path))
{
listBox1.Items.Add(path);
}
// if (!listBox1.Items.Contains(fileName))
// {
// listBox1.Items.Add(fileName);
// }
}
}
}
private void panel1_Click(object sender, EventArgs e)
{
if (Regedit.GetUACLevel() == 2)
{
OpenFileDialog openFileDialog = new()
{
Multiselect = true,
Filter = "All images files (*.*)|*.*",
InitialDirectory = SysFolder.Desktop
};
// FolderBrowserDialog folderBrowserDialog = new()
// {
// ShowNewFolderButton = false,
// RootFolder = Environment.SpecialFolder.Desktop
// };
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
foreach (string file in openFileDialog.FileNames)
{
if (!listBox1.Items.Contains(file))
{
if (Utils.IsAllowedExtension(Path.GetExtension(file).ToLower()))
{
listBox1.Items.Add(file);
}
}
}
}
// if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
// {
// foreach (string file in Directory.GetFiles(folderBrowserDialog.SelectedPath))
// {
// if (!listBox1.Items.Contains(file))
// {
// if (Utils.IsAllowedExtension(Path.GetExtension(file).ToLower()))
// {
// listBox1.Items.Add(file);
// }
// }
// }
// }
}
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
Pen pen = new Pen(Color.Black, 2);
pen.DashPattern = new float[] { 2, 2 };
e.Graphics.DrawRectangle(pen, 1, 1, panel1.Width - 2, panel1.Height - 2);
}
private void button2_Click(object sender, EventArgs e)
{
addUserControl(uc_images);
}
private void button3_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
private void buttonSettings_Click(object sender, EventArgs e)
{
addUserControl(uc_settings);
}
}
}