summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Commands/PresetMenuSelectCommand.cs
blob: 84dc135a3ea9585d2fb24ece1b14276aba0dada7 (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
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PresetMenuSelectCommand.cs" company="HandBrake Project (http://handbrake.fr)">
//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
//   A Command to handle the Preset Menu Clicks.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace HandBrakeWPF.Commands
{
    using System;
    using System.Windows.Input;

    using Caliburn.Micro;

    using HandBrakeWPF.Services.Presets.Model;
    using HandBrakeWPF.ViewModels.Interfaces;

    /// <summary>
    /// The preset menu select command.
    /// </summary>
    public class PresetMenuSelectCommand : ICommand
    {
        private readonly Preset preset;

        /// <summary>
        /// Initializes a new instance of the <see cref="PresetMenuSelectCommand"/> class. 
        /// </summary>
        /// <param name="preset">
        /// The preset.
        /// </param>
        public PresetMenuSelectCommand(Preset preset)
        {
            this.preset = preset;
        }

        /// <summary>Defines the method that determines whether the command can execute in its current state.</summary>
        /// <returns>true if this command can be executed; otherwise, false.</returns>
        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to null.</param>
        public bool CanExecute(object parameter)
        {
            return true;
        }

        /// <summary>Defines the method to be called when the command is invoked.</summary>
        /// <param name="parameter">Data used by the command.  If the command does not require data to be passed, this object can be set to null.</param>
        public void Execute(object parameter)
        {
            IMainViewModel mvm = IoC.Get<IMainViewModel>();
            mvm.PresetSelect(this.preset);
        }

        /// <summary>
        /// The can execute changed.
        /// </summary>
        public event EventHandler CanExecuteChanged { add { } remove { } }
    }
}