// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // The Advanced View Model // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrakeWPF.ViewModels { using System.Collections.Generic; using System.ComponentModel.Composition; using Caliburn.Micro; using HandBrake.ApplicationServices.Functions; using HandBrake.ApplicationServices.Model; using HandBrake.ApplicationServices.Parsing; using HandBrake.ApplicationServices.Services.Interfaces; using HandBrake.Interop.Model.Encoding; using HandBrake.Interop.Model.Encoding.x264; using HandBrakeWPF.ViewModels.Interfaces; /// /// The Advanced View Model /// [Export(typeof(IAdvancedViewModel))] public class AdvancedViewModel : ViewModelBase, IAdvancedViewModel { #region Constants and Fields /// /// Backing field used to display / hide the x264 options /// private bool displayX264Options; #endregion #region Constructors and Destructors /// /// Initializes a new instance of the class. /// /// /// The window manager. /// /// /// The user Setting Service. /// public AdvancedViewModel(IWindowManager windowManager, IUserSettingService userSettingService) { this.Task = new EncodeTask(); X264Presets = EnumHelper.GetEnumList(); X264Profiles = EnumHelper.GetEnumList(); X264Tunes = EnumHelper.GetEnumList(); } #endregion #region Public Properties /// /// Gets or sets Task. /// public EncodeTask Task { get; set; } /// /// Gets or sets State. /// public string Query { get { return this.Task.AdvancedEncoderOptions; } set { this.Task.AdvancedEncoderOptions = value; this.NotifyOfPropertyChange(() => this.Query); } } /// /// Gets or sets X264Preset. /// public x264Preset X264Preset { get { return this.Task.x264Preset; } set { this.Task.x264Preset = value; this.NotifyOfPropertyChange(() => this.X264Preset); } } /// /// Gets or sets X264Profile. /// public x264Profile X264Profile { get { return this.Task.x264Profile; } set { this.Task.x264Profile = value; this.NotifyOfPropertyChange(() => this.X264Profile); } } /// /// Gets or sets X264Tune. /// public x264Tune X264Tune { get { return this.Task.X264Tune; } set { this.Task.X264Tune = value; this.NotifyOfPropertyChange(() => this.X264Tune); } } /// /// Gets or sets X264Presets. /// public IEnumerable X264Presets { get; set; } /// /// Gets or sets X264Profiles. /// public IEnumerable X264Profiles { get; set; } /// /// Gets or sets X264Tunes. /// public IEnumerable X264Tunes { get; set; } /// /// Gets or sets a value indicating whether DisplayX264Options. /// public bool DisplayX264Options { get { return this.displayX264Options; } set { this.displayX264Options = value; this.NotifyOfPropertyChange(() => this.DisplayX264Options); } } #endregion #region Public Methods /// /// Setup this window for a new source /// /// /// The title. /// /// /// The preset. /// /// /// The task. /// public void SetSource(Title title, Preset preset, EncodeTask task) { this.Task = task; this.NotifyOfPropertyChange(() => this.Task); } /// /// Setup this tab for the specified preset. /// /// /// The preset. /// /// /// The task. /// public void SetPreset(Preset preset, EncodeTask task) { this.Task = task; this.NotifyOfPropertyChange(() => this.Task); if (preset != null && preset.Task != null) { this.Query = preset.Task.AdvancedEncoderOptions; this.SetEncoder(preset.Task.VideoEncoder); this.X264Preset = preset.Task.x264Preset; this.X264Profile = preset.Task.x264Profile; this.X264Tune = preset.Task.X264Tune; } } /// /// Set the currently selected encoder. /// /// /// The Video Encoder. /// public void SetEncoder(VideoEncoder encoder) { this.DisplayX264Options = encoder == VideoEncoder.X264; } #endregion } }