using System.Threading;\r
using System.Windows;\r
\r
- using Caliburn.Micro;\r
-\r
using HandBrake.ApplicationServices;\r
using HandBrake.ApplicationServices.Model;\r
using HandBrake.ApplicationServices.Model.Encoding;\r
/// <summary>\r
/// Initializes a new instance of the <see cref="PreviewViewModel"/> class.\r
/// </summary>\r
- /// <param name="windowManager">\r
- /// The window manager.\r
- /// </param>\r
/// <param name="encodeService">\r
/// The encode Service.\r
/// </param>\r
/// <param name="userSettingService">\r
/// The user Setting Service.\r
/// </param>\r
- public PreviewViewModel(IWindowManager windowManager, IEncodeServiceWrapper encodeService, IErrorService errorService, IUserSettingService userSettingService) \r
+ public PreviewViewModel(IEncodeServiceWrapper encodeService, IErrorService errorService, IUserSettingService userSettingService) \r
{\r
this.encodeService = encodeService;\r
this.errorService = errorService;\r
PointToPointMode = PointToPointMode.Preview\r
};\r
\r
- this.CurrentlyPlaying = encodeTask.Destination.Replace(".m", "_sample.m");\r
-\r
+ // Filename handling.\r
+ if (string.IsNullOrEmpty(encodeTask.Destination))\r
+ {\r
+ string filename = Path.ChangeExtension(Path.GetTempFileName(), encodeTask.OutputFormat == OutputFormat.Mkv ? "m4v" : "mkv");\r
+ encodeTask.Destination = filename;\r
+ this.CurrentlyPlaying = filename;\r
+ }\r
+ else\r
+ {\r
+ string directory = Path.GetDirectoryName(encodeTask.Destination) ?? string.Empty;\r
+ string filename = Path.GetFileNameWithoutExtension(encodeTask.Destination);\r
+ string extension = Path.GetExtension(encodeTask.Destination);\r
+ string previewFilename = string.Format("{0}_preview{1}", filename, extension);\r
+ string previewFullPath = Path.Combine(directory, previewFilename);\r
+ encodeTask.Destination = previewFullPath;\r
+ this.CurrentlyPlaying = previewFullPath;\r
+ }\r
+ \r
// Setup the encode task as a preview encode\r
encodeTask.IsPreviewEncode = true;\r
encodeTask.PreviewEncodeStartAt = this.StartAt.ToString(CultureInfo.InvariantCulture);\r
<TextBox Name="StartPointText"\r
MinWidth="60"\r
Margin="8,0,0,0"\r
- Text="{Binding SelectedStartPoint}"\r
+ Text="{Binding SelectedStartPoint, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"\r
Visibility="{Binding ShowTextEntryForPointToPointMode,\r
Converter={StaticResource boolToVisConverter},\r
ConverterParameter=false}"\r
<TextBox Name="EndPointText"\r
MinWidth="60"\r
Margin="8,0,0,0"\r
- Text="{Binding SelectedEndPoint}"\r
+ Text="{Binding SelectedEndPoint, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"\r
Visibility="{Binding ShowTextEntryForPointToPointMode,\r
Converter={StaticResource boolToVisConverter},\r
ConverterParameter=false}"\r