// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // A model for the multiple selection window for adding to the queue. // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrakeWPF.Model { using System; using System.IO; using HandBrakeWPF.Helpers; using HandBrakeWPF.Services.Scan.Model; using HandBrakeWPF.ViewModels; /// /// A model for the multiple selection window for adding to the queue. /// public class SelectionTitle : PropertyChangedBase { /// /// The source name. /// private readonly string sourceName; /// /// The is selected. /// private bool isSelected; /// /// Initializes a new instance of the class. /// /// /// The title. /// /// /// The source Name. /// public SelectionTitle(Title title, string sourceName) { this.sourceName = sourceName; this.Title = title; } /// /// Gets the source name. /// public string SourceName { get { return !string.IsNullOrEmpty(Title.SourcePath) ? Title.SourcePath : sourceName; } } /// /// Gets or sets the end point. /// public int EndPoint { get; set; } /// /// Gets or sets a value indicating whether is selected. /// public bool IsSelected { get { return this.isSelected; } set { this.isSelected = value; this.NotifyOfPropertyChange(() => this.IsSelected); } } /// /// Gets or sets the start point. /// public int StartPoint { get; set; } /// /// Gets or sets the title. /// public Title Title { get; set; } public string SourceInfo => string.Format("{0}{1}", FilesizeStr, SourceInfoHelper.GenerateSourceInfo(this.Title)); public decimal? FilesizeMB => CalcFilesize(); public string FilesizeStr { get { if (FilesizeMB.HasValue) { return string.Format("{0} MB, ", FilesizeMB); } return null; } } private decimal? CalcFilesize() { if (this.Title != null && !string.IsNullOrEmpty(this.Title.SourcePath) && File.Exists(this.Title.SourcePath)) { if (Path.GetExtension(this.Title.SourcePath)?.Contains("iso", StringComparison.InvariantCultureIgnoreCase) ?? false) { return null; } FileInfo info = new FileInfo(this.Title.SourcePath); return Math.Round((decimal)info.Length / 1024 / 1024, 1); } return null; } } }