-
Notifications
You must be signed in to change notification settings - Fork 27
/
FormOptions.cs
112 lines (93 loc) · 3.37 KB
/
FormOptions.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
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
namespace WebMCam
{
public partial class FormOptions : Form
{
private const string defaultArgs = "-framerate {fps:avg} -i {format} {audio} -c:v {codec} -c:a libvorbis -auto-alt-ref 0 -b:v 2M -r {fps:avg} {output}";
private Properties.Settings settings = Properties.Settings.Default;
public FormOptions()
{
InitializeComponent();
}
private void FormOptions_Load(object sender, EventArgs e)
{
// Set Defaults if not set
if (settings.FFmpegPath.Length < 1)
settings.FFmpegPath = "ffmpeg.exe";
if (settings.FFmpegArguments.Length < 1)
settings.FFmpegArguments = defaultArgs;
if (settings.ImageFormat.Length < 1)
settings.ImageFormat = "PNG";
textBoxFFmpegPath.Text = settings.FFmpegPath;
textBoxFFmpegArguments.Text = settings.FFmpegArguments;
comboBoxImageFormat.Text = settings.ImageFormat;
checkBoxAltWindowTracking.Checked = settings.AltWindowTracking;
checkBoxRememberSize.Checked = settings.RememberSize;
}
public string getFFmpegArguments()
{
return textBoxFFmpegArguments.Text;
}
public string getFFmpegPath()
{
return textBoxFFmpegPath.Text.Replace(Environment.NewLine, " ");
}
public ImageFormat getImageFormat()
{
switch(comboBoxImageFormat.SelectedText)
{
case "JPG":
return ImageFormat.Jpeg;
case "BMP":
return ImageFormat.Bmp;
case "GIF":
return ImageFormat.Gif;
case "PNG":
default:
return ImageFormat.Png;
}
}
public Size getWindowSize()
{
if (!settings.RememberSize)
{
return new Size(0, 0);
}
return new Size(settings.SizeWidth, settings.SizeHeight);
}
public void saveWindowSize(Size size)
{
settings.SizeWidth = size.Width;
settings.SizeHeight = size.Height;
settings.Save();
}
private void buttonBrowse_Click(object sender, EventArgs e)
{
var openFileDialog = new OpenFileDialog()
{
Filter = "FFmpeg (*.exe)|*.exe",
FileName = "ffmpeg.exe",
DefaultExt = "exe"
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
textBoxFFmpegPath.Text = openFileDialog.FileName;
}
private void buttonResetArguments_Click(object sender, EventArgs e)
{
textBoxFFmpegArguments.Text = defaultArgs;
}
private void buttonSave_Click(object sender, EventArgs e)
{
settings.FFmpegPath = textBoxFFmpegPath.Text;
settings.FFmpegArguments = textBoxFFmpegArguments.Text;
settings.ImageFormat = comboBoxImageFormat.Text;
settings.AltWindowTracking = checkBoxAltWindowTracking.Checked;
settings.RememberSize = checkBoxRememberSize.Checked;
settings.Save();
Close();
}
}
}