-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
111 lines (91 loc) · 3.34 KB
/
Form1.cs
File metadata and controls
111 lines (91 loc) · 3.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
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace PackVideo
{
public partial class Form1 : Form
{
private VideoConverter converter;
private string Version = "1.1 2021";
public Form1()
{
InitializeComponent();
converter = new VideoConverter();
converter.UpdateStatus = UpdateStatus;
this.Text += " ver " + Version;
tbLog.Text = @"Программа для пересжатия mp4
Версия " + Version + @"
Автор Aant
Программа пересжимает все mp4 файлы в avi с тем же именем, если таких файлов уже не существует.
Рядом с программой должен быть ffmpeg.exe.
"
+ Environment.NewLine + $"Параметры для сжатия: {converter.FfmpegArguments}"
+ Environment.NewLine + $"Параметры для сжатия с уменьшением размера: {converter.FfmpegArgumentsResize}"
+ @"
Copyright 2021 Ivanov Vasilii Sergeevich aka Aant
Licensed under the LGPLv2.1
https://github.com/AantCoder/PackVideo
Components used:
* FFmpeg (LGPLv2.1 license) https://ffmpeg.org/
";
}
private void UpdateStatus(bool showError)
{
if (showError) MessageBox.Show(converter.Status, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (this.InvokeRequired)
this.Invoke((Action)UpdateStatusDo);
else
UpdateStatusDo();
}
private void UpdateStatusDo()
{
tbLog.Text = converter.Log;
lStatus.Text = converter.Status;
if (converter.ProgressText != null) this.Text = converter.ProgressText;
progressBar.Value = converter.ProgressValue;
}
private void button2_Click(object sender, EventArgs e)
{
if (tbFolder.Text == string.Empty)
{
if (folderBrowserDialog.ShowDialog() != DialogResult.OK) return;
tbFolder.Text = folderBrowserDialog.SelectedPath;
}
button1.Enabled = true;
button2.Enabled = false;
tbFolder.ReadOnly = true;
if (!converter.GetFiles(tbFolder.Text))
{
lStatus.Text = "Файлы для сжатия не найдены";
tbLog.Text = "";
button1.Enabled = false;
button2.Enabled = true;
tbFolder.Text = "";
tbFolder.ReadOnly = false;
return;
}
lStatus.Text = converter.Status;
tbLog.Text = converter.Log;
}
private void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
cbDel.Enabled = false;
cbAutoResize.Enabled = false;
lStatus.Text = "Подготовка...";
converter.Start(cbDel.Checked, cbAutoResize.Checked);
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
converter.Stop();
}
}
}