blob: f634909b3debddc51f1904751740aa7f9978d664 (
plain)
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace Handbrake
{
class PresetLoader
{
/// <summary>
/// This function takes in a Query which has been parsed by QueryParser and
/// set's all the GUI widgets correctly.
/// </summary>
/// <param name="mainWindow"></param>
/// <param name="presetQuery">The Parsed CLI Query</param>
/// <param name="name">Name of the preset</param>
public void presetLoader(frmMain mainWindow, Functions.QueryParser presetQuery, string name)
{
// ---------------------------
// Setup the GUI
// ---------------------------
// Source tab
#region source
// Reset some vaules to stock first to prevent errors.
mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;
// Now load all the new settings onto the main window
if (presetQuery.Format != null)
{
string destination = mainWindow.text_destination.Text;
destination = destination.Replace(".mp4", "." + presetQuery.Format);
destination = destination.Replace(".m4v", "." + presetQuery.Format);
destination = destination.Replace(".avi", "." + presetQuery.Format);
destination = destination.Replace(".mkv", "." + presetQuery.Format);
destination = destination.Replace(".ogm", "." + presetQuery.Format);
mainWindow.text_destination.Text = destination;
}
#endregion
// Destination tab
#region destination
mainWindow.drp_videoEncoder.Text = presetQuery.VideoEncoder;
if (presetQuery.Format != null)
{
if (presetQuery.Format == "mp4")
mainWindow.drop_format.SelectedIndex = 0;
else if (presetQuery.Format == "m4v")
mainWindow.drop_format.SelectedIndex = 1;
else if (presetQuery.Format == "mkv")
mainWindow.drop_format.SelectedIndex = 2;
else if (presetQuery.Format == "avi")
mainWindow.drop_format.SelectedIndex = 3;
else if (presetQuery.Format == "ogm")
mainWindow.drop_format.SelectedIndex = 4;
if (presetQuery.ChapterMarkers == true && presetQuery.Format == "mp4")
mainWindow.drop_format.SelectedIndex = 1;
}
if (presetQuery.IpodAtom == true)
mainWindow.check_iPodAtom.CheckState = CheckState.Checked;
else
mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;
if (presetQuery.OptimizeMP4 == true)
mainWindow.check_optimiseMP4.CheckState = CheckState.Checked;
else
mainWindow.check_optimiseMP4.CheckState = CheckState.Unchecked;
#endregion
// Picture Settings Tab
#region Picture
mainWindow.check_autoCrop.Checked = true;
if (presetQuery.CropBottom == "0" && presetQuery.CropTop == "0")
if (presetQuery.CropLeft == "0" && presetQuery.CropRight == "0")
mainWindow.check_customCrop.Checked = true;
mainWindow.drp_deInterlace_option.Text = presetQuery.DeInterlace;
mainWindow.drp_deNoise.Text = presetQuery.DeNoise;
if (presetQuery.Decomb == true)
mainWindow.check_decomb.CheckState = CheckState.Checked;
else
mainWindow.check_decomb.CheckState = CheckState.Unchecked;
if (presetQuery.DeTelecine == true)
mainWindow.check_detelecine.CheckState = CheckState.Checked;
else
mainWindow.check_detelecine.CheckState = CheckState.Unchecked;
if (presetQuery.DeBlock != 0)
{
mainWindow.slider_deblock.Value = presetQuery.DeBlock;
mainWindow.lbl_deblockVal.Text = presetQuery.DeBlock.ToString();
}
else
{
mainWindow.slider_deblock.Value = 4;
mainWindow.lbl_deblockVal.Text = "Off";
}
if (presetQuery.Anamorphic == true)
mainWindow.drp_anamorphic.SelectedIndex = 1;
else
mainWindow.drp_anamorphic.SelectedIndex = 0;
if (presetQuery.LooseAnamorphic == true)
mainWindow.drp_anamorphic.SelectedIndex = 2;
else
{
if (presetQuery.Anamorphic != true)
mainWindow.drp_anamorphic.SelectedIndex = 0;
}
if (presetQuery.Width != 0)
mainWindow.text_width.Text = presetQuery.Width.ToString();
else
{
mainWindow.text_width.Text = "";
}
if (presetQuery.Height != 0)
mainWindow.text_height.Text = presetQuery.Height.ToString();
else
{
mainWindow.text_height.Text = "";
}
// Set the public max width and max height varibles in frmMain
// These are used by the query generator to determine if it should use -X or -w / -Y or -h
if (presetQuery.MaxWidth != 0)
{
mainWindow.text_width.Text = presetQuery.MaxWidth.ToString();
mainWindow.maxWidth = presetQuery.MaxWidth;
}
if (presetQuery.MaxHeight != 0)
{
mainWindow.text_height.Text = presetQuery.MaxHeight.ToString();
mainWindow.maxHeight = presetQuery.MaxHeight;
}
#endregion
// Video Settings Tab
#region video
mainWindow.text_bitrate.Text = presetQuery.AverageVideoBitrate;
mainWindow.text_filesize.Text = presetQuery.VideoTargetSize;
mainWindow.slider_videoQuality.Value = presetQuery.VideoQuality;
if (mainWindow.slider_videoQuality.Value != 0)
{
int ql = presetQuery.VideoQuality;
mainWindow.SliderValue.Text = ql.ToString() + "%";
}
if (presetQuery.TwoPass == true)
mainWindow.check_2PassEncode.CheckState = CheckState.Checked;
else
mainWindow.check_2PassEncode.CheckState = CheckState.Unchecked;
if (presetQuery.Grayscale == true)
mainWindow.check_grayscale.CheckState = CheckState.Checked;
else
mainWindow.check_grayscale.CheckState = CheckState.Unchecked;
mainWindow.drp_videoFramerate.Text = presetQuery.VideoFramerate;
if (presetQuery.TurboFirstPass == true)
mainWindow.check_turbo.CheckState = CheckState.Checked;
else
mainWindow.check_turbo.CheckState = CheckState.Unchecked;
if (presetQuery.LargeMP4 == true)
mainWindow.check_largeFile.CheckState = CheckState.Checked;
else
{
mainWindow.check_largeFile.CheckState = CheckState.Unchecked;
mainWindow.check_largeFile.BackColor = Color.Transparent;
}
#endregion
// Chapter Markers Tab
#region Chapter Markers
if (presetQuery.ChapterMarkers == true)
{
mainWindow.Check_ChapterMarkers.CheckState = CheckState.Checked;
mainWindow.Check_ChapterMarkers.Enabled = true;
}
else
mainWindow.Check_ChapterMarkers.CheckState = CheckState.Unchecked;
#endregion
// Audio Settings Tab
#region Audio
// Clear the audio listing
mainWindow.lv_audioList.Items.Clear();
// Create a new row for the Audio list based on the currently selected items in the dropdown.
ListViewItem newTrack = new ListViewItem("Automatic");
newTrack.SubItems.Add(presetQuery.AudioEncoder1);
newTrack.SubItems.Add(presetQuery.AudioTrackMix1);
newTrack.SubItems.Add(presetQuery.AudioSamplerate1);
newTrack.SubItems.Add(presetQuery.AudioBitrate1);
newTrack.SubItems.Add(presetQuery.DRC1.ToString());
mainWindow.lv_audioList.Items.Add(newTrack);
if (presetQuery.AudioTrack2 != "None")
{
newTrack = new ListViewItem("Automatic");
newTrack.SubItems.Add(presetQuery.AudioEncoder2);
newTrack.SubItems.Add(presetQuery.AudioTrackMix2);
newTrack.SubItems.Add(presetQuery.AudioSamplerate2);
newTrack.SubItems.Add(presetQuery.AudioBitrate2);
newTrack.SubItems.Add(presetQuery.DRC2.ToString());
mainWindow.lv_audioList.Items.Add(newTrack);
}
if (presetQuery.AudioTrack3 != "None")
{
newTrack = new ListViewItem("Automatic");
newTrack.SubItems.Add(presetQuery.AudioEncoder3);
newTrack.SubItems.Add(presetQuery.AudioTrackMix3);
newTrack.SubItems.Add(presetQuery.AudioSamplerate3);
newTrack.SubItems.Add(presetQuery.AudioBitrate3);
newTrack.SubItems.Add(presetQuery.DRC3.ToString());
mainWindow.lv_audioList.Items.Add(newTrack);
}
if (presetQuery.AudioTrack4 != "None")
{
newTrack = new ListViewItem("Automatic");
newTrack.SubItems.Add(presetQuery.AudioEncoder4);
newTrack.SubItems.Add(presetQuery.AudioTrackMix4);
newTrack.SubItems.Add(presetQuery.AudioSamplerate4);
newTrack.SubItems.Add(presetQuery.AudioBitrate4);
newTrack.SubItems.Add(presetQuery.DRC4.ToString());
mainWindow.lv_audioList.Items.Add(newTrack);
}
// Subtitle Stuff
mainWindow.drp_subtitle.Text = presetQuery.Subtitles;
if (presetQuery.ForcedSubtitles == true)
{
mainWindow.check_forced.CheckState = CheckState.Checked;
mainWindow.check_forced.Enabled = true;
}
else
mainWindow.check_forced.CheckState = CheckState.Unchecked;
#endregion
// H264 Tab & Preset Name
#region other
mainWindow.rtf_x264Query.Text = presetQuery.H264Query;
// Set the preset name
mainWindow.groupBox_output.Text = "Output Settings (Preset: " + name + ")";
#endregion
}
}
}
|