// --------------------------------------------------------------------------------------------------------------------
//
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
//
//
// Interaction logic for VideoView.xaml
//
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Views
{
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using HandBrake.ApplicationServices.Model;
using HandBrakeWPF.ViewModels;
///
/// Interaction logic for VideoView.xaml
///
public partial class VideoView : UserControl
{
///
/// Initializes a new instance of the class.
///
public VideoView()
{
InitializeComponent();
}
///
/// The qsv_preset_radiobutton.
///
///
/// The sender.
///
///
/// The e.
///
private void qsv_preset_radiobutton(object sender, System.Windows.RoutedEventArgs e)
{
qsv_preset_ValueChanged(sender, null);
}
///
/// The qsv_preset_ value changed.
///
///
/// The sender.
///
///
/// The e.
///
private void qsv_preset_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
{
VideoViewModel mvm = ((VideoViewModel)this.DataContext);
EncodeTask task = mvm.Task;
string full_string = string.Empty;
IDictionary newOptions = new Dictionary();
string[] existingSegments = full_string.Split(':');
foreach (string existingSegment in existingSegments)
{
string optionName = existingSegment;
string optionValue = string.Empty;
int equalsIndex = existingSegment.IndexOf('=');
if (equalsIndex >= 0)
{
optionName = existingSegment.Substring(
0, existingSegment.IndexOf("=", System.StringComparison.Ordinal));
optionValue = existingSegment.Substring(equalsIndex);
}
if (optionName != string.Empty)
{
if (newOptions.ContainsKey(optionName))
newOptions.Remove(optionName);
newOptions.Add(optionName, optionValue);
}
}
full_string = string.Empty;
foreach (KeyValuePair entry in newOptions)
{
full_string += entry.Key;
if (entry.Value != string.Empty)
full_string += entry.Value;
full_string += ":";
}
full_string = full_string.TrimEnd(':');
task.AdvancedEncoderOptions = full_string;
task.NotifyOfPropertyChange(() => task.AdvancedEncoderOptions);
}
}
}