summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels/AdvancedViewModel.cs
blob: 6f2dee1a0c04971b6abffa23da998eac3a95e023 (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
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AdvancedViewModel.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>
//   The Advanced View Model
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace HandBrakeWPF.ViewModels
{
    using HandBrake.ApplicationServices.Model;
    using HandBrake.ApplicationServices.Services.Encode.Model;
    using HandBrake.ApplicationServices.Services.Scan.Model;
    using HandBrake.Interop.Model.Encoding;

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

    /// <summary>
    /// The Advanced View Model
    /// </summary>
    public class AdvancedViewModel : ViewModelBase, IAdvancedViewModel
    {
        #region Constants and Fields

        /// <summary>
        /// Backing field for displaying x264 options
        /// </summary>
        private bool? displayX264Options;

        /// <summary>
        /// The show x 264 panel.
        /// </summary>
        private bool showX264Panel;

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the x 264 view model.
        /// </summary>
        public IX264ViewModel X264ViewModel { get; set; }

        /// <summary>
        /// Gets or sets the encoder options view model.
        /// </summary>
        public IEncoderOptionsViewModel EncoderOptionsViewModel { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether show x 264 panel.
        /// </summary>
        public bool ShowX264Panel
        {
            get
            {
                return this.showX264Panel;
            }
            set
            {
                this.showX264Panel = value;
                this.NotifyOfPropertyChange(() => this.ShowX264Panel);
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether DisplayX264Options.
        /// </summary>
        public bool? ShowSimplePanel
        {
            get
            {
                return this.displayX264Options;
            }
            set
            {
                this.displayX264Options = value;
                this.NotifyOfPropertyChange(() => this.ShowSimplePanel);
            }
        }

        #endregion

        #region Implemented Interfaces

        /// <summary>
        /// The set encoder.
        /// </summary>
        /// <param name="encoder">
        /// The encoder.
        /// </param>
        public void SetEncoder(VideoEncoder encoder)
        {
            this.EncoderOptionsViewModel.SetEncoder(encoder);
            this.X264ViewModel.SetEncoder(encoder);

            if (encoder == VideoEncoder.X264)
            {
                this.ShowX264Panel = true;
                this.ShowSimplePanel = false;
            }
            else
            {
                this.ShowX264Panel = false;
                this.ShowSimplePanel = true;
            }  
        }

        /// <summary>
        /// The clear.
        /// </summary>
        public void Clear()
        {
            this.EncoderOptionsViewModel.Clear();
            this.X264ViewModel.Clear();
        }

        /// <summary>
        /// Setup this tab for the specified preset.
        /// </summary>
        /// <param name="preset">
        /// The preset.
        /// </param>
        /// <param name="task">
        /// The task.
        /// </param>
        public void SetPreset(Preset preset, EncodeTask task)
        {
            this.EncoderOptionsViewModel.SetPreset(preset, task);
            this.X264ViewModel.SetPreset(preset, task);
        }

        /// <summary>
        /// Update all the UI controls based on the encode task passed in.
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        public void UpdateTask(EncodeTask task)
        {
            this.EncoderOptionsViewModel.UpdateTask(task);
            this.X264ViewModel.UpdateTask(task);

            this.SetEncoder(task.VideoEncoder);
        }

        /// <summary>
        /// Setup this window for a new source
        /// </summary>
        /// <param name="title">
        /// The title.
        /// </param>
        /// <param name="preset">
        /// The preset.
        /// </param>
        /// <param name="task">
        /// The task.
        /// </param>
        public void SetSource(Title title, Preset preset, EncodeTask task)
        {
            this.EncoderOptionsViewModel.SetSource(title, preset, task);
            this.X264ViewModel.SetSource(title, preset, task);
        }

        #endregion
    }
}