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
|
/* frmAddPreset.cs $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.fr>.
It may be used under the terms of the GNU General Public License. */
namespace Handbrake
{
using System;
using System.Windows.Forms;
using Handbrake.Functions;
using Handbrake.Model;
using Presets;
/// <summary>
/// The Add Preset Window
/// </summary>
public partial class frmAddPreset : Form
{
private readonly frmMain mainWindow;
/// <summary>
/// The Preset Handler
/// </summary>
private readonly PresetsHandler presetCode;
/// <summary>
/// Initializes a new instance of the <see cref="frmAddPreset"/> class.
/// </summary>
/// <param name="mainWindow"></param>
/// <param name="presetHandler">
/// The preset handler.
/// </param>
public frmAddPreset(frmMain mainWindow, PresetsHandler presetHandler)
{
InitializeComponent();
this.mainWindow = mainWindow;
presetCode = presetHandler;
cb_usePictureSettings.SelectedIndex = 0;
}
/// <summary>
/// Handle the Add button event.
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
private void BtnAddClick(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txt_preset_name.Text.Trim()))
{
MessageBox.Show("You must enter a preset name!", "Warning",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
QueryPictureSettingsMode pictureSettingsMode;
switch (cb_usePictureSettings.SelectedIndex)
{
case 0:
pictureSettingsMode = QueryPictureSettingsMode.None;
break;
case 1:
pictureSettingsMode = QueryPictureSettingsMode.SourceMaximum;
break;
default:
pictureSettingsMode = QueryPictureSettingsMode.None;
break;
}
string query = QueryGenerator.GenerateQueryForPreset(mainWindow, pictureSettingsMode, check_useFilters.Checked, 0, 0);
if (presetCode.Add(txt_preset_name.Text.Trim(), query, pictureSettingsMode != QueryPictureSettingsMode.None))
{
this.DialogResult = DialogResult.OK;
this.Close();
}
else
MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
/// <summary>
/// Handle the Cancel button event
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
private void BtnCancelClick(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
}
}
|