diff options
7 files changed, 72 insertions, 72 deletions
diff --git a/win/CS/HandBrakeWPF/Controls/SourceSelection.xaml b/win/CS/HandBrakeWPF/Controls/SourceSelection.xaml index 91528e23c..e24c1f245 100644 --- a/win/CS/HandBrakeWPF/Controls/SourceSelection.xaml +++ b/win/CS/HandBrakeWPF/Controls/SourceSelection.xaml @@ -25,9 +25,9 @@ <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
+ <RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
- <RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
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 diff --git a/win/CS/HandBrakeWPF/Utilities/DriveUtilities.cs b/win/CS/HandBrakeWPF/Utilities/DriveUtilities.cs index 40bb2d5c0..ab9ecbace 100644 --- a/win/CS/HandBrakeWPF/Utilities/DriveUtilities.cs +++ b/win/CS/HandBrakeWPF/Utilities/DriveUtilities.cs @@ -40,7 +40,7 @@ namespace HandBrakeWPF.Utilities {
Id = id,
VolumeLabel = curDrive.VolumeLabel,
- RootDirectory = curDrive.RootDirectory.ToString()
+ RootDirectory = curDrive.RootDirectory?.ToString()
});
id++;
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueSelectionViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueSelectionViewModel.cs index 33acdfec8..0ac995fbd 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueSelectionViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/IQueueSelectionViewModel.cs @@ -33,15 +33,12 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// <param name="scannedSource">
/// The scanned source.
/// </param>
- /// <param name="sourceName">
- /// The source Name.
- /// </param>
/// <param name="addAction">
/// The add To Queue action
/// </param>
/// <param name="preset">
/// The preset.
/// </param>
- void Setup(Source scannedSource, string sourceName, Action<IEnumerable<SelectionTitle>> addAction, Preset preset);
+ void Setup(Source scannedSource, Action<IEnumerable<SelectionTitle>> addAction, Preset preset);
}
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 741aa2c38..cd8946fd0 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -390,50 +390,6 @@ namespace HandBrakeWPF.ViewModels }
/// <summary>
- /// Gets SourceName.
- /// </summary>
- public string SourceName
- {
- get
- {
- // Sanity Check
- if (this.ScannedSource == null || this.ScannedSource.ScanPath == null || this.selectedTitle == null)
- {
- return string.Empty;
- }
-
- if (File.Exists(this.ScannedSource.ScanPath)) // Scan Path is a File.
- {
- return Path.GetFileNameWithoutExtension(this.ScannedSource.ScanPath);
- }
-
- if (Directory.Exists(this.ScannedSource.ScanPath)) // Scan Path is a folder.
- {
- // 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.ScannedSource.ScanPath.Replace("\\\\", "\\")))
- {
- return item.VolumeLabel;
- }
- }
-
- // Otherwise, it may be a path of files.
- if (!string.IsNullOrEmpty(this.selectedTitle.SourceName) && File.Exists(this.selectedTitle.SourceName)) // Selected Title is a file
- {
- return Path.GetFileNameWithoutExtension(this.selectedTitle.SourceName);
- }
- else if (Directory.Exists(this.selectedTitle.SourceName)) // Selected Title is a structured source.
- {
- return Path.GetFileName(this.ScannedSource.ScanPath);
- }
- }
-
- return null;
- }
- }
-
- /// <summary>
/// Gets RangeMode.
/// </summary>
public BindingList<PointToPointMode> RangeMode
@@ -606,6 +562,7 @@ namespace HandBrakeWPF.ViewModels {
return this.selectedTitle;
}
+
set
{
if (!Equals(this.selectedTitle, value))
@@ -618,7 +575,7 @@ namespace HandBrakeWPF.ViewModels }
// Use the Path on the Title, or the Source Scan path if one doesn't exist.
- this.SourceLabel = this.SourceName;
+ this.SourceLabel = this.ScannedSource?.SourceName ?? this.SelectedTitle?.DisplaySourceName;
this.CurrentTask.Source = !string.IsNullOrEmpty(this.selectedTitle.SourceName) ? this.selectedTitle.SourceName : this.ScannedSource.ScanPath;
this.CurrentTask.Title = value.TitleNumber;
this.NotifyOfPropertyChange(() => this.StartEndRangeItems);
@@ -640,7 +597,7 @@ namespace HandBrakeWPF.ViewModels {
if (this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat) != null)
{
- this.Destination = AutoNameHelper.AutoName(this.CurrentTask, this.SourceName, this.selectedPreset);
+ this.Destination = AutoNameHelper.AutoName(this.CurrentTask, this.ScannedSource?.SourceName ?? this.SelectedTitle?.DisplaySourceName, this.selectedPreset);
}
}
@@ -697,7 +654,7 @@ namespace HandBrakeWPF.ViewModels if (this.SelectedPointToPoint == PointToPointMode.Chapters && this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat) != null &&
this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat).Contains(Constants.Chapters))
{
- this.Destination = AutoNameHelper.AutoName(this.CurrentTask, this.SourceName, this.selectedPreset);
+ this.Destination = AutoNameHelper.AutoName(this.CurrentTask, this.ScannedSource?.SourceName ?? this.SelectedTitle?.DisplaySourceName, this.selectedPreset);
}
}
@@ -727,7 +684,7 @@ namespace HandBrakeWPF.ViewModels if (this.SelectedPointToPoint == PointToPointMode.Chapters && this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat) != null &&
this.userSettingService.GetUserSetting<string>(UserSettingConstants.AutoNameFormat).Contains(Constants.Chapters))
{
- this.Destination = AutoNameHelper.AutoName(this.CurrentTask, this.SourceName, this.selectedPreset);
+ this.Destination = AutoNameHelper.AutoName(this.CurrentTask, this.ScannedSource?.SourceName ?? this.SelectedTitle?.DisplaySourceName, this.selectedPreset);
}
if (this.SelectedStartPoint > this.SelectedEndPoint && this.SelectedPointToPoint == PointToPointMode.Chapters)
@@ -1468,23 +1425,26 @@ namespace HandBrakeWPF.ViewModels Window window = Application.Current.Windows.Cast<Window>().FirstOrDefault(x => x.GetType() == typeof(QueueSelectionViewModel));
IQueueSelectionViewModel viewModel = IoC.Get<IQueueSelectionViewModel>();
- viewModel.Setup(this.ScannedSource, this.SourceName, (tasks) =>
- {
- foreach (SelectionTitle title in tasks)
+ viewModel.Setup(
+ this.ScannedSource,
+ (tasks) =>
{
- this.SelectedTitle = title.Title;
- var addError = this.AddToQueue(true);
- if (addError != null)
+ foreach (SelectionTitle title in tasks)
{
- MessageBoxResult result = this.errorService.ShowMessageBox(addError.Message + Environment.NewLine + Environment.NewLine + Resources.Main_ContinueAddingToQueue, addError.Header, MessageBoxButton.YesNo, addError.ErrorType);
-
- if (result == MessageBoxResult.No)
+ this.SelectedTitle = title.Title;
+ var addError = this.AddToQueue(true);
+ if (addError != null)
{
- break;
+ MessageBoxResult result = this.errorService.ShowMessageBox(addError.Message + Environment.NewLine + Environment.NewLine + Resources.Main_ContinueAddingToQueue, addError.Header, MessageBoxButton.YesNo, addError.ErrorType);
+
+ if (result == MessageBoxResult.No)
+ {
+ break;
+ }
}
}
- }
- }, this.selectedPreset);
+ },
+ this.selectedPreset);
if (window != null)
{
@@ -2205,7 +2165,7 @@ namespace HandBrakeWPF.ViewModels // Cleanup
this.ShowStatusWindow = false;
- this.SourceLabel = this.SourceName;
+ this.SourceLabel = this.ScannedSource?.SourceName ?? this.SelectedTitle?.DisplaySourceName;
this.StatusLabel = Resources.Main_ScanCompleted;
});
}
@@ -2422,7 +2382,7 @@ namespace HandBrakeWPF.ViewModels if (e.Successful)
{
- this.SourceLabel = this.SourceName;
+ this.SourceLabel = this.ScannedSource?.SourceName ?? this.SelectedTitle?.DisplaySourceName;
this.StatusLabel = Resources.Main_ScanCompleted;
}
else if (e.Cancelled)
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueSelectionViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueSelectionViewModel.cs index 95c276639..82d6458cf 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueSelectionViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueSelectionViewModel.cs @@ -235,16 +235,13 @@ namespace HandBrakeWPF.ViewModels /// <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)
+ public void Setup(Source scannedSource, Action<IEnumerable<SelectionTitle>> addAction, Preset preset)
{
this.TitleList.Clear();
this.addToQueue = addAction;
@@ -257,6 +254,7 @@ namespace HandBrakeWPF.ViewModels foreach (Title item in titles)
{
+ string srcName = scannedSource?.SourceName ?? item.DisplaySourceName;
SelectionTitle title = new SelectionTitle(item, srcName) { IsSelected = true };
TitleList.Add(title);
}
|