blob: 9da0b7361f5b8976c5f078f9e7ece0d86a4e6ca6 (
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
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="EncoderOptionsViewModel.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 Simple Encoder options screen
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.ViewModels
{
using System.Collections.Generic;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.Interop.Model.Encoding;
using HandBrakeWPF.Model.Preset;
using HandBrakeWPF.ViewModels.Interfaces;
/// <summary>
/// The Simple Encoder options screen
/// </summary>
public class EncoderOptionsViewModel : ViewModelBase, IEncoderOptionsViewModel
{
/// <summary>
/// The cached options.
/// </summary>
private readonly Dictionary<VideoEncoder, string> cachedOptions = new Dictionary<VideoEncoder, string>();
/// <summary>
/// Initializes a new instance of the <see cref="EncoderOptionsViewModel"/> class.
/// </summary>
public EncoderOptionsViewModel()
{
this.Task = new EncodeTask();
}
/// <summary>
/// Gets or sets the task.
/// </summary>
public EncodeTask Task { get; set; }
/// <summary>
/// Gets or sets the preset.
/// </summary>
public Preset Preset { get; set; }
/// <summary>
/// Gets or sets the current video encoder.
/// </summary>
public VideoEncoder CurrentVideoEncoder { get; set; }
/// <summary>
/// Gets or sets the options string.
/// </summary>
public string AdvancedOptionsString
{
get
{
return this.Task.AdvancedEncoderOptions;
}
set
{
this.Task.AdvancedEncoderOptions = value;
this.NotifyOfPropertyChange(() => this.AdvancedOptionsString);
}
}
/// <summary>
/// The set source.
/// </summary>
/// <param name="selectedTitle">
/// The selected title.
/// </param>
/// <param name="currentPreset">
/// The current preset.
/// </param>
/// <param name="task">
/// The task.
/// </param>
public void SetSource(Title selectedTitle, Preset currentPreset, EncodeTask task)
{
this.Task = task;
this.Preset = currentPreset;
this.NotifyOfPropertyChange(() => this.AdvancedOptionsString);
}
/// <summary>
/// The set preset.
/// </summary>
/// <param name="preset">
/// The preset.
/// </param>
/// <param name="task">
/// The task.
/// </param>
public void SetPreset(Preset preset, EncodeTask task)
{
this.Task = task;
this.Preset = preset;
this.AdvancedOptionsString = preset.Task.AdvancedEncoderOptions;
}
/// <summary>
/// The update task.
/// </summary>
/// <param name="task">
/// The task.
/// </param>
public void UpdateTask(EncodeTask task)
{
this.Task = task;
this.NotifyOfPropertyChange(() => this.AdvancedOptionsString);
}
/// <summary>
/// The set encoder.
/// </summary>
/// <param name="encoder">
/// The encoder.
/// </param>
public void SetEncoder(VideoEncoder encoder)
{
// Cache the existing string so it can be reused if the user changes the encoder back.
if (!string.IsNullOrEmpty(this.AdvancedOptionsString))
{
this.cachedOptions[CurrentVideoEncoder] = this.AdvancedOptionsString;
}
this.CurrentVideoEncoder = encoder;
// Set the option from the cached version if we have one.
string advacnedOptionsString;
if (cachedOptions.TryGetValue(encoder, out advacnedOptionsString)
&& !string.IsNullOrEmpty(advacnedOptionsString))
{
this.AdvancedOptionsString = advacnedOptionsString;
}
else
{
this.AdvancedOptionsString = this.Preset != null && this.Preset.Task != null
&& !string.IsNullOrEmpty(this.Preset.Task.AdvancedEncoderOptions)
? this.Preset.Task.AdvancedEncoderOptions
: string.Empty;
}
}
/// <summary>
/// The clear.
/// </summary>
public void Clear()
{
}
}
}
|