本文整理汇总了C#中HandBrakeWPF.Services.Presets.Model.Preset类的典型用法代码示例。如果您正苦于以下问题:C# Preset类的具体用法?C# Preset怎么用?C# Preset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Preset类属于HandBrakeWPF.Services.Presets.Model命名空间,在下文中一共展示了Preset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Export
/// <summary>
/// Export a MacGui style plist preset.
/// </summary>
/// <param name="path">
/// The path.
/// </param>
/// <param name="preset">
/// The preset.
/// </param>
/// <param name="build">
/// The build.PictureModulusPictureModulus
/// </param>
public static void Export(string path, Preset preset, string build)
{
if (string.IsNullOrEmpty(path))
{
return;
}
EncodeTask parsed = new EncodeTask(preset.Task);
using (XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.UTF8) { Formatting = Formatting.Indented })
{
// Header
xmlWriter.WriteStartDocument();
xmlWriter.WriteDocType(
"plist", "-//Apple//DTD PLIST 1.0//EN", @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
xmlWriter.WriteStartElement("plist");
xmlWriter.WriteStartElement("array");
// Add New Preset Here. Can write multiple presets here if required in future.
WritePreset(xmlWriter, parsed, preset, build);
// Footer
xmlWriter.WriteEndElement();
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
// Closeout
xmlWriter.Close();
}
}
示例2: Preset
/// <summary>
/// Initializes a new instance of the <see cref="PropertyChangedBase"/> class.
/// Creates an instance of <see cref="T:HandBrakeWPF.Utilities.PropertyChangedBase"/>.
/// </summary>
public Preset(Preset preset)
{
this.Category = preset.Category;
this.Description = preset.Description;
this.IsBuildIn = preset.IsBuildIn;
this.Name = preset.Name;
this.PictureSettingsMode = preset.PictureSettingsMode;
this.Task = new EncodeTask(preset.Task);
this.AudioTrackBehaviours = new AudioBehaviours(preset.AudioTrackBehaviours);
this.SubtitleTrackBehaviours = new SubtitleBehaviours(preset.SubtitleTrackBehaviours);
}
示例3: CreatePreset
/// <summary>
/// The create preset.
/// </summary>
/// <param name="plist">
/// The plist.
/// </param>
/// <returns>
/// The <see cref="Preset"/>.
/// </returns>
public static Preset CreatePreset(PList plist)
{
Preset preset = new Preset
{
Task = new EncodeTask(),
Category = PresetService.UserPresetCatgoryName,
AudioTrackBehaviours = new AudioBehaviours(),
SubtitleTrackBehaviours = new SubtitleBehaviours()
};
// Parse the settings out.
foreach (var item in plist)
{
if (item.Key == "AudioList")
{
List<AudioTrack> tracks = ParseAudioTracks(item.Value);
preset.Task.AudioTracks = new ObservableCollection<AudioTrack>(tracks);
}
else
{
ParseSetting(item, preset);
}
}
// Handle the PictureDecombDeinterlace key
if (preset.UseDeinterlace)
{
preset.Task.Decomb = Decomb.Off;
preset.Task.CustomDecomb = string.Empty;
}
// Depending on the selected preset options, we may need to change some settings around.
// If the user chose not to use fitlers, remove them.
if (!preset.UsePictureFilters)
{
preset.Task.Detelecine = Detelecine.Off;
preset.Task.Denoise = Denoise.Off;
preset.Task.Deinterlace = Deinterlace.Off;
preset.Task.Decomb = Decomb.Off;
preset.Task.Deblock = 0;
preset.Task.Grayscale = false;
}
// IF we are using Source Max, Set the Max Width / Height values.
if (preset.PictureSettingsMode == PresetPictureSettingsMode.SourceMaximum)
{
preset.Task.MaxWidth = preset.Task.Height;
preset.Task.MaxHeight = preset.Task.Width;
}
return preset;
}
示例4: Setup
/// <summary>
/// The setup.
/// </summary>
/// <param name="scannedSource">
/// The scanned source.
/// </param>
/// <param name="srcName">
/// The src Name.
/// </param>
/// <param name="addAction">
/// The add Action.
/// </param>
/// <param name="preset">
/// The preset.
/// </param>
public void Setup(Source scannedSource, string srcName, Action<IEnumerable<SelectionTitle>> addAction, Preset preset)
{
this.TitleList.Clear();
this.addToQueue = addAction;
if (scannedSource != null)
{
IEnumerable<Title> titles = orderedByTitle
? scannedSource.Titles
: scannedSource.Titles.OrderByDescending(o => o.Duration).ToList();
foreach (Title item in titles)
{
SelectionTitle title = new SelectionTitle(item, srcName) { IsSelected = true };
TitleList.Add(title);
}
}
if (preset != null)
{
this.CurrentPreset = string.Format(ResourcesUI.QueueSelection_UsingPreset, preset.Name);
}
this.NotifyOfPropertyChange(() => this.IsAutoNamingEnabled);
}
示例5: SetPreset
/// <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.Task = task;
this.Task.IncludeChapterMarkers = preset.Task.IncludeChapterMarkers;
this.NotifyOfPropertyChange(() => this.Task);
}
示例6: SetSource
/// <summary>
/// Setup this window for a new source
/// </summary>
/// <param name="source">
/// The source.
/// </param>
/// <param name="title">
/// The title.
/// </param>
/// <param name="preset">
/// The preset.
/// </param>
/// <param name="task">
/// The task.
/// </param>
public void SetSource(Source source, Title title, Preset preset, EncodeTask task)
{
this.SourceTracks.Clear();
this.SourceTracks.Add(ForeignAudioSearchTrack);
foreach (Subtitle subtitle in title.Subtitles)
{
this.SourceTracks.Add(subtitle);
}
this.Task = task;
this.NotifyOfPropertyChange(() => this.Task);
this.AutomaticSubtitleSelection();
}
示例7: SetSource
/// <summary>
/// Setup this window for a new source
/// </summary>
/// <param name="source">
/// The source.
/// </param>
/// <param name="title">
/// The title.
/// </param>
/// <param name="preset">
/// The preset.
/// </param>
/// <param name="task">
/// The task.
/// </param>
public void SetSource(Source source, Title title, Preset preset, EncodeTask task)
{
this.Task = task;
this.NotifyOfPropertyChange(() => this.AdvancedOptionsString);
}
示例8: Add
/// <summary>
/// Add a new preset to the system.
/// Performs an Update if it already exists
/// </summary>
/// <param name="preset">
/// A Preset to add
/// </param>
/// <returns>
/// True if added,
/// False if name already exists
/// </returns>
public bool Add(Preset preset)
{
if (this.CheckIfPresetExists(preset.Name) == false)
{
this.presets.Add(preset);
this.LastPresetAdded = preset;
// Update the presets file
this.UpdatePresetFiles();
return true;
}
this.Update(preset);
return true;
}
示例9: SetSource
/// <summary>
/// Setup the window after a scan.
/// </summary>
/// <param name="source">
/// The source.
/// </param>
/// <param name="selectedTitle">
/// The selected title.
/// </param>
/// <param name="currentPreset">
/// The Current preset
/// </param>
/// <param name="encodeTask">
/// The task.
/// </param>
public void SetSource(Source source, Title selectedTitle, Preset currentPreset, EncodeTask encodeTask)
{
this.Task = encodeTask;
}
示例10: SetSource
/// <summary>
/// Setup this window for a new source
/// </summary>
/// <param name="source">
/// The source.
/// </param>
/// <param name="title">
/// The title.
/// </param>
/// <param name="preset">
/// The preset.
/// </param>
/// <param name="task">
/// The task.
/// </param>
public void SetSource(Source source, Title title, Preset preset, EncodeTask task)
{
this.currentTitle = title;
this.Task = task;
this.scannedSource = source;
if (title != null)
{
// Set cached info
this.sourceParValues = title.ParVal;
this.sourceResolution = title.Resolution;
// Update the cropping values, preffering those in the presets.
if (!preset.Task.HasCropping)
{
this.Task.Cropping.Top = title.AutoCropDimensions.Top;
this.Task.Cropping.Bottom = title.AutoCropDimensions.Bottom;
this.Task.Cropping.Left = title.AutoCropDimensions.Left;
this.Task.Cropping.Right = title.AutoCropDimensions.Right;
this.IsCustomCrop = false;
}
else
{
this.Task.Cropping.Left = preset.Task.Cropping.Left;
this.Task.Cropping.Right = preset.Task.Cropping.Right;
this.Task.Cropping.Top = preset.Task.Cropping.Top;
this.Task.Cropping.Bottom = preset.Task.Cropping.Bottom;
this.IsCustomCrop = true;
}
if (preset.PictureSettingsMode == PresetPictureSettingsMode.None)
{
// We have no instructions, so simply set it to the source.
this.Task.Width = this.GetModulusValue(this.sourceResolution.Width - this.CropLeft - this.CropRight);
this.MaintainAspectRatio = true;
}
else
{
// Set the Max Width / Height available to the user controls
if (this.sourceResolution.Width < this.MaxWidth)
{
this.MaxWidth = this.sourceResolution.Width;
}
else if (this.sourceResolution.Width > this.MaxWidth)
{
this.MaxWidth = preset.Task.MaxWidth ?? this.sourceResolution.Width;
}
if (this.sourceResolution.Height < this.MaxHeight)
{
this.MaxHeight = this.sourceResolution.Height;
}
else if (this.sourceResolution.Height > this.MaxHeight)
{
this.MaxHeight = preset.Task.MaxHeight ?? this.sourceResolution.Height;
}
// Set the Width, and Maintain Aspect ratio. That should calc the Height for us.
if (this.SelectedAnamorphicMode == Anamorphic.None)
{
this.Task.Width = preset.Task.Width ?? (this.MaxWidth - this.CropLeft - this.CropRight);
// Note: This will be auto-corrected in the property if it's too large.
}
else
{
this.Task.Width = preset.Task.Width ?? this.MaxWidth;
int cropHeight = this.Task.Cropping.Top + this.Task.Cropping.Bottom;
this.Task.Height = (preset.Task.Height ?? this.MaxHeight) - cropHeight;
}
// If our height is too large, let it downscale the width for us by setting the height to the lower value.
if (!this.MaintainAspectRatio && this.Height > this.MaxHeight)
{
this.Task.Height = this.MaxHeight;
}
}
// Set Screen Controls
this.SourceInfo = string.Format(
"{0}x{1}, PAR: {2}/{3}",
title.Resolution.Width,
title.Resolution.Height,
title.ParVal.Width,
//.........这里部分代码省略.........
示例11: SetPreset
/// <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.Task = task;
if (preset == null || preset.Task == null)
{
return;
}
this.SelectedVideoEncoder = preset.Task.VideoEncoder;
this.SelectedFramerate = preset.Task.Framerate.HasValue ? preset.Task.Framerate.Value.ToString(CultureInfo.InvariantCulture) : SameAsSource;
this.IsConstantQuantity = preset.Task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality;
switch (preset.Task.FramerateMode)
{
case FramerateMode.CFR:
this.IsConstantFramerate = true;
break;
case FramerateMode.VFR:
this.IsVariableFramerate = true;
this.ShowPeakFramerate = false;
break;
case FramerateMode.PFR:
this.IsPeakFramerate = true;
this.ShowPeakFramerate = true;
break;
}
this.SetRF(preset.Task.Quality);
this.TwoPass = preset.Task.TwoPass;
this.TurboFirstPass = preset.Task.TurboFirstPass;
this.Task.VideoBitrate = preset.Task.VideoBitrate;
this.NotifyOfPropertyChange(() => this.Task);
if (preset.Task != null)
{
this.HandleEncoderChange(preset.Task.VideoEncoder);
HBVideoEncoder encoder = HandBrakeEncoderHelpers.VideoEncoders.FirstOrDefault(s => s.ShortName == EnumHelper<VideoEncoder>.GetShortName(preset.Task.VideoEncoder));
if (encoder != null)
{
if (preset.Task.VideoEncoder == VideoEncoder.X264 || preset.Task.VideoEncoder == VideoEncoder.X265 || preset.Task.VideoEncoder == VideoEncoder.QuickSync)
{
this.VideoLevel = preset.Task.VideoLevel != null ? preset.Task.VideoLevel.Clone() : this.VideoLevels.FirstOrDefault();
this.VideoProfile = preset.Task.VideoProfile != null ? preset.Task.VideoProfile.Clone() : this.VideoProfiles.FirstOrDefault();
this.VideoPresetValue = preset.Task.VideoPreset != null ? this.VideoPresets.IndexOf(preset.Task.VideoPreset) : 0;
this.FastDecode = preset.Task.VideoTunes != null && preset.Task.VideoTunes.Contains(VideoTune.FastDecode);
this.VideoTune = (preset.Task.VideoTunes != null && preset.Task.VideoTunes.Any() ? preset.Task.VideoTunes.FirstOrDefault(t => !Equals(t, VideoTune.FastDecode)) : this.VideoTunes.FirstOrDefault())
?? VideoTune.None;
}
}
this.ExtraArguments = preset.Task.ExtraAdvancedArguments;
this.UseAdvancedTab = !string.IsNullOrEmpty(preset.Task.AdvancedEncoderOptions) && this.ShowAdvancedTab;
}
}
示例12: AutoName
/// <summary>
/// Function which generates the filename and path automatically based on
/// the Source Name, DVD title and DVD Chapters
/// </summary>
/// <param name="task">
/// The task.
/// </param>
/// <param name="sourceOrLabelName">
/// The Source or Label Name
/// </param>
/// <returns>
/// The Generated FileName
/// </returns>
public static string AutoName(EncodeTask task, string sourceOrLabelName, Preset presetName)
{
IUserSettingService userSettingService = IoC.Get<IUserSettingService>();
if (task.Destination == null)
{
task.Destination = string.Empty;
}
string autoNamePath = string.Empty;
if (task.Title != 0)
{
// Get the Source Name and remove any invalid characters
string sourceName = Path.GetInvalidFileNameChars().Aggregate(sourceOrLabelName, (current, character) => current.Replace(character.ToString(), string.Empty));
string sanitisedPresetName = presetName != null ? Path.GetInvalidFileNameChars().Aggregate(presetName.Name, (current, character) => current.Replace(character.ToString(), string.Empty)) : string.Empty;
// Remove Underscores
if (userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameRemoveUnderscore))
sourceName = sourceName.Replace("_", " ");
if (userSettingService.GetUserSetting<bool>(UserSettingConstants.RemovePunctuation))
{
sourceName = sourceName.Replace("-", string.Empty);
sourceName = sourceName.Replace(",", string.Empty);
sourceName = sourceName.Replace(".", string.Empty);
}
// Switch to "Title Case"
if (userSettingService.GetUserSetting<bool>(UserSettingConstants.AutoNameTitleCase))
sourceName = sourceName.ToTitleCase();
// Get the Selected Title Number
string dvdTitle = task.Title.ToString();
// Get the Chapter Start and Chapter End Numbers
string chapterStart = task.StartPoint.ToString();
string chapterFinish = task.EndPoint.ToString();
string combinedChapterTag = chapterStart;
if (chapterFinish != chapterStart && chapterFinish != string.Empty)
combinedChapterTag = chapterStart + "-" + chapterFinish;
/*
* File Name
*/
string destinationFilename;
if (userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat) != string.Empty)
{
destinationFilename = userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat);
destinationFilename =
destinationFilename
.Replace("{source}", sourceName)
.Replace(Constants.Title, dvdTitle)
.Replace(Constants.Chapters, combinedChapterTag)
.Replace(Constants.Date, DateTime.Now.Date.ToShortDateString().Replace('/', '-'))
.Replace(Constants.Time,DateTime.Now.ToString("HH:mm"))
.Replace(Constants.Preset, sanitisedPresetName);
if (task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality)
{
destinationFilename = destinationFilename.Replace(Constants.Quality, task.Quality.ToString());
destinationFilename = destinationFilename.Replace(Constants.Bitrate, string.Empty);
}
else
{
destinationFilename = destinationFilename.Replace(Constants.Bitrate, task.VideoBitrate.ToString());
destinationFilename = destinationFilename.Replace(Constants.Quality, string.Empty);
}
}
else
destinationFilename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag;
/*
* File Extension
*/
if (task.OutputFormat == OutputFormat.Mp4)
{
switch (userSettingService.GetUserSetting<int>(UserSettingConstants.UseM4v))
{
case 0: // Automatic
destinationFilename += task.IncludeChapterMarkers || MP4Helper.RequiresM4v(task) ? ".m4v" : ".mp4";
break;
case 1: // Always MP4
destinationFilename += ".mp4";
break;
case 2: // Always M4V
destinationFilename += ".m4v";
break;
//.........这里部分代码省略.........
示例13: SetPreset
/// <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.Task = task;
// Handle built-in presets.
if (preset.IsBuildIn)
{
preset.PictureSettingsMode = PresetPictureSettingsMode.Custom;
}
// Setup the Picture Sizes
switch (preset.PictureSettingsMode)
{
default:
case PresetPictureSettingsMode.Custom:
case PresetPictureSettingsMode.SourceMaximum:
// Anamorphic Mode
this.SelectedAnamorphicMode = preset.Task.Anamorphic;
// Modulus
if (preset.Task.Modulus.HasValue)
{
this.SelectedModulus = preset.Task.Modulus;
}
// Set the Maintain Aspect ratio.
this.MaintainAspectRatio = preset.Task.KeepDisplayAspect;
// Set the Maximum so libhb can correctly manage the size.
if (preset.PictureSettingsMode == PresetPictureSettingsMode.SourceMaximum)
{
this.MaxWidth = this.sourceResolution.Width;
this.MaxHeight = this.sourceResolution.Height;
}
else
{
this.MaxWidth = preset.Task.MaxWidth ?? this.sourceResolution.Width;
this.MaxHeight = preset.Task.MaxHeight ?? this.sourceResolution.Height;
}
// Set the width, then check the height doesn't breach the max height and correct if necessary.
int width = this.GetModulusValue(this.GetRes((this.sourceResolution.Width - this.CropLeft - this.CropRight), preset.Task.MaxWidth));
this.Width = width;
// If we have a max height, make sure we havn't breached it.
int height = this.GetModulusValue(this.GetRes((this.sourceResolution.Height - this.CropTop - this.CropBottom), preset.Task.MaxHeight));
if (preset.Task.MaxHeight.HasValue && this.Height > preset.Task.MaxHeight.Value)
{
this.Height = height;
}
break;
case PresetPictureSettingsMode.None:
// Do Nothing except reset the Max Width/Height
this.MaxWidth = this.sourceResolution.Width;
this.MaxHeight = this.sourceResolution.Height;
this.SelectedAnamorphicMode = preset.Task.Anamorphic;
break;
}
// Custom Anamorphic
if (preset.Task.Anamorphic == Anamorphic.Custom)
{
this.DisplayWidth = preset.Task.DisplayWidth != null ? int.Parse(preset.Task.DisplayWidth.ToString()) : 0;
this.ParWidth = preset.Task.PixelAspectX;
this.ParHeight = preset.Task.PixelAspectY;
}
// Cropping
if (preset.Task.HasCropping)
{
this.IsCustomCrop = true;
this.CropLeft = preset.Task.Cropping.Left;
this.CropRight = preset.Task.Cropping.Right;
this.CropTop = preset.Task.Cropping.Top;
this.CropBottom = preset.Task.Cropping.Bottom;
}
else
{
this.IsCustomCrop = false;
}
this.NotifyOfPropertyChange(() => this.Task);
this.UpdateVisibileControls();
}
示例14: SetupLanguages
/// <summary>
/// The setup languages.
/// </summary>
/// <param name="preset">
/// The preset.
/// </param>
public void SetupLanguages(Preset preset)
{
if (preset != null)
{
this.SetupLanguages(preset.SubtitleTrackBehaviours);
}
}
示例15: Equals
/// <summary>
/// The equals.
/// </summary>
/// <param name="other">
/// The other.
/// </param>
/// <returns>
/// The <see cref="bool"/>.
/// </returns>
protected bool Equals(Preset other)
{
return string.Equals(this.Name, other.Name);
}