diff options
author | sr55 <[email protected]> | 2020-05-10 11:25:39 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2020-05-10 11:25:39 +0100 |
commit | f3a438dcbd3003215fbf6555b99c85f28c6aab3a (patch) | |
tree | 94637728fd7546e0dda3796e08f5799ce0b090b7 /win/CS/HandBrakeWPF/Services | |
parent | 41a900a3fff4c02a3d39ddcb5bf6639fe6461a5c (diff) |
WinGui: Fix a potential crash when working with DVD discs during AutoNaming Fixes #2837
Fix scrollbar not dispaying on source selection. Fixes #2843
Diffstat (limited to 'win/CS/HandBrakeWPF/Services')
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Scan/Model/Source.cs | 32 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Scan/Model/Title.cs | 13 |
2 files changed, 45 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Scan/Model/Source.cs b/win/CS/HandBrakeWPF/Services/Scan/Model/Source.cs index dcdb329df..7d332f1b9 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/Model/Source.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/Model/Source.cs @@ -10,8 +10,13 @@ namespace HandBrakeWPF.Services.Scan.Model { using System.Collections.Generic; + using System.IO; + using System.Xaml; using System.Xml.Serialization; + using HandBrakeWPF.Model; + using HandBrakeWPF.Utilities; + /// <summary> /// An object representing a scanned DVD /// </summary> @@ -38,6 +43,8 @@ namespace HandBrakeWPF.Services.Scan.Model [XmlIgnore] public List<Title> Titles { get; set; } + public string SourceName { get; private set; } + /// <summary> /// Copy this Source to another Source Model /// </summary> @@ -48,6 +55,31 @@ namespace HandBrakeWPF.Services.Scan.Model { source.Titles = this.Titles; source.ScanPath = this.ScanPath; + + // Scan Path is a File. + if (File.Exists(this.ScanPath)) + { + this.SourceName = Path.GetFileNameWithoutExtension(this.ScanPath); + } + + // Scan Path is a folder. + if (Directory.Exists(this.ScanPath)) + { + // Check to see if it's a Drive. If yes, use the volume label. + foreach (DriveInformation item in DriveUtilities.GetDrives()) + { + if (item.RootDirectory.Contains(this.ScanPath.Replace("\\\\", "\\"))) + { + this.SourceName = item.VolumeLabel; + } + } + + // Otherwise, it may be a path of files. + if (string.IsNullOrEmpty(this.SourceName)) + { + this.SourceName = Path.GetFileName(this.ScanPath); + } + } } } }
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Scan/Model/Title.cs b/win/CS/HandBrakeWPF/Services/Scan/Model/Title.cs index ac611cfb7..cf79c6726 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/Model/Title.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/Model/Title.cs @@ -127,6 +127,19 @@ namespace HandBrakeWPF.Services.Scan.Model /// </summary> public string SourceName { get; set; } + public string DisplaySourceName + { + get + { + if (!string.IsNullOrEmpty(this.SourceName)) + { + return Path.GetFileNameWithoutExtension(this.SourceName); + } + + return null; + } + } + public string SourceDisplayName { get |