summaryrefslogtreecommitdiffstats
path: root/win/C#/frmAddPreset.cs
blob: 30537f9e1c110eb0d2e585b6d3c27894b73177ef (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
/*  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.Drawing;
    using System.Windows.Forms;
    using Presets;

    public partial class frmAddPreset : Form
    {
        private readonly frmMain _frmMainWindow;
        private readonly PresetsHandler _presetCode;
        private readonly string _query = string.Empty;

        public frmAddPreset(frmMain fmw, string queryString, PresetsHandler presetHandler)
        {
            InitializeComponent();
            _frmMainWindow = fmw;
            _presetCode = presetHandler;
            this._query = queryString;
        }

        private void btn_add_Click(object sender, EventArgs e)
        {
            if (_presetCode.Add(txt_preset_name.Text.Trim(), _query, check_pictureSettings.Checked))
            {
                TreeNode presetTreeview = new TreeNode(txt_preset_name.Text.Trim()) {ForeColor = Color.Black};
                _frmMainWindow.treeView_presets.Nodes.Add(presetTreeview);
                this.Close();
            }
            else
                MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", 
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}