diff options
author | sr55 <[email protected]> | 2013-03-09 22:32:07 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2013-03-09 22:32:07 +0000 |
commit | e6bbf3b9ecfd237eec98bd2711800f267ee9ddb1 (patch) | |
tree | ca11f6a3df993dd40d8c247d7c8ee5640ca2bc91 /win/CS/HandBrakeWPF/ViewModels | |
parent | e318631790e818539c917f567cc39babe5def745 (diff) |
Merging Trunk to OpenCL branch
git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/opencl@5319 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
7 files changed, 154 insertions, 79 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs index e578d9688..f1da43828 100644 --- a/win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/EncoderOptionsViewModel.cs @@ -9,6 +9,8 @@ namespace HandBrakeWPF.ViewModels
{
+ using System.Collections.Generic;
+
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Parsing;
using HandBrake.Interop.Model.Encoding;
@@ -21,6 +23,11 @@ namespace HandBrakeWPF.ViewModels public class EncoderOptionsViewModel : ViewModelBase, IEncoderOptionsViewModel, ITabInterface
{
/// <summary>
+ /// The cached options.
+ /// </summary>
+ private readonly Dictionary<VideoEncoder, string> cachedOptions = new Dictionary<VideoEncoder, string>();
+
+ /// <summary>
/// Initializes a new instance of the <see cref="EncoderOptionsViewModel"/> class.
/// </summary>
public EncoderOptionsViewModel()
@@ -34,6 +41,16 @@ namespace HandBrakeWPF.ViewModels public EncodeTask Task { get; set; }
/// <summary>
+ /// Gets or sets the preset.
+ /// </summary>
+ public Preset Preset { get; set; }
+
+ /// <summary>
+ /// Gets or sets the current video encoder.
+ /// </summary>
+ public VideoEncoder CurrentVideoEncoder { get; set; }
+
+ /// <summary>
/// Gets or sets the options string.
/// </summary>
public string AdvancedOptionsString
@@ -64,6 +81,7 @@ namespace HandBrakeWPF.ViewModels public void SetSource(Title selectedTitle, Preset currentPreset, EncodeTask task)
{
this.Task = task;
+ this.Preset = currentPreset;
this.NotifyOfPropertyChange(() => this.AdvancedOptionsString);
}
@@ -79,6 +97,7 @@ namespace HandBrakeWPF.ViewModels public void SetPreset(Preset preset, EncodeTask task)
{
this.Task = task;
+ this.Preset = preset;
this.AdvancedOptionsString = preset.Task.AdvancedEncoderOptions;
}
@@ -102,6 +121,28 @@ namespace HandBrakeWPF.ViewModels /// </param>
public void SetEncoder(VideoEncoder encoder)
{
+ // Cache the existing string so it can be reused if the user changes the encoder back.
+ if (!string.IsNullOrEmpty(this.AdvancedOptionsString))
+ {
+ this.cachedOptions[CurrentVideoEncoder] = this.AdvancedOptionsString;
+ }
+
+ this.CurrentVideoEncoder = encoder;
+
+ // Set the option from the cached version if we have one.
+ string advacnedOptionsString;
+ if (cachedOptions.TryGetValue(encoder, out advacnedOptionsString)
+ && !string.IsNullOrEmpty(advacnedOptionsString))
+ {
+ this.AdvancedOptionsString = advacnedOptionsString;
+ }
+ else
+ {
+ this.AdvancedOptionsString = this.Preset != null && this.Preset.Task != null
+ && !string.IsNullOrEmpty(this.Preset.Task.AdvancedEncoderOptions)
+ ? this.Preset.Task.AdvancedEncoderOptions
+ : string.Empty;
+ }
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ILogViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ILogViewModel.cs index 6aa1020d4..6c7a7a2c8 100644 --- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ILogViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ILogViewModel.cs @@ -14,5 +14,9 @@ namespace HandBrakeWPF.ViewModels.Interfaces /// </summary>
public interface ILogViewModel
{
+ /// <summary>
+ /// Gets or sets the selected tab.
+ /// </summary>
+ int SelectedTab { get; set; }
}
}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs index 4c97ab412..ad76a56b2 100644 --- a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs @@ -10,7 +10,6 @@ namespace HandBrakeWPF.ViewModels
{
using System;
- using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
@@ -37,9 +36,15 @@ namespace HandBrakeWPF.ViewModels private readonly IScanServiceWrapper scanService;
/// <summary>
- /// Backing field for the selected mode
+ /// The selected tab.
/// </summary>
- private int selectedMode;
+ private int selectedTab;
+
+ /// <summary>
+ /// The encode log index.
+ /// </summary>
+ private int encodeLogIndex;
+
#endregion
/// <summary>
@@ -56,46 +61,44 @@ namespace HandBrakeWPF.ViewModels this.encodeService = encodeService;
this.scanService = scanService;
this.Title = "Log Viewer";
-
- this.SelectedMode = this.encodeService.IsEncoding ? 0 : 1;
+ this.encodeLogIndex = 0;
}
/// <summary>
- /// Gets Log.
+ /// Gets or sets the selected tab.
/// </summary>
- public string Log
+ public int SelectedTab
{
get
{
- return this.SelectedMode == 0 ? this.encodeService.ActivityLog : this.scanService.ActivityLog;
+ return this.selectedTab;
+ }
+ set
+ {
+ this.selectedTab = value;
+ this.NotifyOfPropertyChange(() => this.SelectedTab);
}
}
/// <summary>
- /// Gets LogModes.
+ /// Gets Log.
/// </summary>
- public IEnumerable<string> LogModes
+ public string ScanLog
{
get
{
- return new List<string> { "Encode Log", "Scan Log" };
+ return this.scanService.ActivityLog;
}
}
/// <summary>
- /// Gets or sets SelectedMode.
+ /// Gets the encodelog.
/// </summary>
- public int SelectedMode
+ public string EncodeLog
{
get
{
- return selectedMode;
- }
- set
- {
- selectedMode = value;
- this.NotifyOfPropertyChange(() => this.SelectedMode);
- this.ChangeLogDisplay();
+ return this.encodeService.ActivityLog;
}
}
@@ -115,7 +118,7 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void CopyLog()
{
- Clipboard.SetDataObject(this.Log, true);
+ Clipboard.SetDataObject(this.SelectedTab == 1 ? this.ScanLog : this.EncodeLog, true);
}
/// <summary>
@@ -123,13 +126,16 @@ namespace HandBrakeWPF.ViewModels /// </summary>
protected override void OnActivate()
{
- this.scanService.ScanStared += ScanServiceScanStared;
this.scanService.ScanCompleted += ScanServiceScanCompleted;
- this.encodeService.EncodeStarted += EncodeServiceEncodeStarted;
this.encodeService.EncodeCompleted += EncodeServiceEncodeCompleted;
this.encodeService.EncodeStatusChanged += this.EncodeServiceEncodeStatusChanged;
this.scanService.ScanStatusChanged += this.ScanServiceScanStatusChanged;
+ this.scanService.ScanStared += this.scanService_ScanStared;
+ this.encodeService.EncodeStarted += this.encodeService_EncodeStarted;
base.OnActivate();
+
+ this.NotifyOfPropertyChange(() => this.ScanLog);
+ this.NotifyOfPropertyChange(() => this.EncodeLog);
}
/// <summary>
@@ -143,7 +149,7 @@ namespace HandBrakeWPF.ViewModels /// </param>
private void ScanServiceScanStatusChanged(object sender, ScanProgressEventArgs e)
{
- this.NotifyOfPropertyChange(() => this.Log);
+ this.NotifyOfPropertyChange(() => this.ScanLog);
}
/// <summary>
@@ -157,7 +163,12 @@ namespace HandBrakeWPF.ViewModels /// </param>
private void EncodeServiceEncodeStatusChanged(object sender, EncodeProgressEventArgs e)
{
- this.NotifyOfPropertyChange(() => this.Log);
+ if (encodeLogIndex != this.encodeService.LogIndex || this.encodeService.LogIndex == -1)
+ {
+ this.NotifyOfPropertyChange(() => this.EncodeLog);
+ }
+
+ encodeLogIndex = this.encodeService.LogIndex;
}
/// <summary>
@@ -168,26 +179,18 @@ namespace HandBrakeWPF.ViewModels /// </param>
protected override void OnDeactivate(bool close)
{
- this.scanService.ScanStared -= ScanServiceScanStared;
this.scanService.ScanCompleted -= ScanServiceScanCompleted;
- this.encodeService.EncodeStarted -= EncodeServiceEncodeStarted;
this.encodeService.EncodeCompleted -= EncodeServiceEncodeCompleted;
this.encodeService.EncodeStatusChanged -= this.EncodeServiceEncodeStatusChanged;
this.scanService.ScanStatusChanged -= this.ScanServiceScanStatusChanged;
+ this.scanService.ScanStared -= this.scanService_ScanStared;
+ this.encodeService.EncodeStarted -= this.encodeService_EncodeStarted;
base.OnDeactivate(close);
}
/// <summary>
- /// Change the Log Display
- /// </summary>
- private void ChangeLogDisplay()
- {
- this.NotifyOfPropertyChange(() => this.Log);
- }
-
- /// <summary>
- /// Encode Started Event Handler
+ /// Scan Completed Event Handler.
/// </summary>
/// <param name="sender">
/// The sender.
@@ -195,13 +198,13 @@ namespace HandBrakeWPF.ViewModels /// <param name="e">
/// The e.
/// </param>
- private void EncodeServiceEncodeStarted(object sender, EventArgs e)
+ private void ScanServiceScanCompleted(object sender, ScanCompletedEventArgs e)
{
- this.SelectedMode = 0;
+ this.NotifyOfPropertyChange(() => this.ScanLog);
}
/// <summary>
- /// Scan Started Event Handler
+ /// Encode Completed Event Handler.
/// </summary>
/// <param name="sender">
/// The sender.
@@ -209,13 +212,13 @@ namespace HandBrakeWPF.ViewModels /// <param name="e">
/// The e.
/// </param>
- private void ScanServiceScanStared(object sender, EventArgs e)
+ private void EncodeServiceEncodeCompleted(object sender, EncodeCompletedEventArgs e)
{
- this.SelectedMode = 1;
+ this.NotifyOfPropertyChange(() => this.EncodeLog);
}
/// <summary>
- /// Scan Completed Event Handler.
+ /// The encode service encode started.
/// </summary>
/// <param name="sender">
/// The sender.
@@ -223,13 +226,13 @@ namespace HandBrakeWPF.ViewModels /// <param name="e">
/// The e.
/// </param>
- private void ScanServiceScanCompleted(object sender, ScanCompletedEventArgs e)
+ private void encodeService_EncodeStarted(object sender, EventArgs e)
{
- this.NotifyOfPropertyChange(() => this.Log);
+ this.SelectedTab = 0;
}
/// <summary>
- /// Encode Completed Event Handler.
+ /// The scan service scan stared.
/// </summary>
/// <param name="sender">
/// The sender.
@@ -237,9 +240,9 @@ namespace HandBrakeWPF.ViewModels /// <param name="e">
/// The e.
/// </param>
- private void EncodeServiceEncodeCompleted(object sender, EncodeCompletedEventArgs e)
+ private void scanService_ScanStared(object sender, EventArgs e)
{
- this.NotifyOfPropertyChange(() => this.Log);
+ this.SelectedTab = 1;
}
}
}
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 4875fd6bf..04d466062 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -95,6 +95,11 @@ namespace HandBrakeWPF.ViewModels private readonly IEncodeServiceWrapper encodeService;
/// <summary>
+ /// Windows 7 API Pack wrapper
+ /// </summary>
+ private readonly Win7 windowsSeven = new Win7();
+
+ /// <summary>
/// HandBrakes Main Window Title
/// </summary>
private string windowName;
@@ -173,6 +178,11 @@ namespace HandBrakeWPF.ViewModels /// The Source Menu Backing Field
/// </summary>
private IEnumerable<SourceMenuItem> sourceMenu;
+
+ /// <summary>
+ /// The last percentage complete value.
+ /// </summary>
+ private int lastEncodePercentage;
#endregion
/// <summary>
@@ -1002,11 +1012,15 @@ namespace HandBrakeWPF.ViewModels if (window != null)
{
+ ILogViewModel logvm = (ILogViewModel)window.DataContext;
+ logvm.SelectedTab = this.IsEncoding ? 0 : 1;
window.Activate();
}
else
{
- this.WindowManager.ShowWindow(IoC.Get<ILogViewModel>());
+ ILogViewModel logvm = IoC.Get<ILogViewModel>();
+ logvm.SelectedTab = this.IsEncoding ? 0 : 1;
+ this.WindowManager.ShowWindow(logvm);
}
}
@@ -1749,8 +1763,8 @@ namespace HandBrakeWPF.ViewModels /// </param>
private void ScanStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.ScanProgressEventArgs e)
{
- this.SourceLabel = "Scanning Title " + e.CurrentTitle + " of " + e.Titles;
- this.StatusLabel = "Scanning Title " + e.CurrentTitle + " of " + e.Titles;
+ this.SourceLabel = string.Format("Scanning Title {0} of {1} ({2}%)", e.CurrentTitle, e.Titles, e.Percentage);
+ this.StatusLabel = string.Format("Scanning Title {0} of {1} ({2}%)", e.CurrentTitle, e.Titles, e.Percentage);
}
/// <summary>
@@ -1847,6 +1861,12 @@ namespace HandBrakeWPF.ViewModels /// </param>
private void EncodeStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.EncodeProgressEventArgs e)
{
+ int percent;
+ int.TryParse(
+ Math.Round(e.PercentComplete).ToString(CultureInfo.InvariantCulture),
+ out percent);
+
+
Execute.OnUIThread(
() =>
{
@@ -1861,6 +1881,13 @@ namespace HandBrakeWPF.ViewModels e.EstimatedTimeLeft,
e.ElapsedTime,
this.queueProcessor.Count);
+
+ if (lastEncodePercentage != percent && this.windowsSeven.IsWindowsSeven)
+ {
+ this.windowsSeven.SetTaskBarProgress(percent);
+ }
+
+ lastEncodePercentage = percent;
}
});
}
@@ -1902,6 +1929,11 @@ namespace HandBrakeWPF.ViewModels {
this.ProgramStatusLabel = "Queue Finished";
this.IsEncoding = false;
+
+ if (this.windowsSeven.IsWindowsSeven)
+ {
+ this.windowsSeven.SetTaskBarProgressToNoProgress();
+ }
});
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index b611e14d6..4f2bc251b 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -1536,7 +1536,7 @@ namespace HandBrakeWPF.ViewModels this.preferredLanguages.Add(item);
// In the available languages should be no "Any" and no selected language.
- if ((item != "Any") && (!this.userSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages).Contains(item)))
+ if ((item != "(Any)") && (!this.userSettingService.GetUserSetting<StringCollection>(UserSettingConstants.SelectedLanguages).Contains(item)))
{
this.availableLanguages.Add(item);
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index 4f344db08..79532b9ee 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -101,7 +101,7 @@ namespace HandBrakeWPF.ViewModels this.errorService = errorService;
this.Title = "Queue";
this.JobsPending = "No encodes pending";
- this.JobStatus = "There are no jobs currently encoding";
+ this.JobStatus = "There are no jobs currently encoding";
}
#endregion
@@ -263,9 +263,9 @@ namespace HandBrakeWPF.ViewModels {
MessageBoxResult result =
this.errorService.ShowMessageBox(
- "This encode is currently in progress. If you delete it, the encode will be stoped. Are you sure you wish to proceed?",
- "Warning",
- MessageBoxButton.YesNo,
+ "This encode is currently in progress. If you delete it, the encode will be stoped. Are you sure you wish to proceed?",
+ "Warning",
+ MessageBoxButton.YesNo,
MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
@@ -330,7 +330,7 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void Import()
{
- VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "HandBrake Queue Files (*.hbq)|*.hbq", CheckFileExists = true };
+ VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "HandBrake Queue Files (*.hbq)|*.hbq", CheckFileExists = true };
dialog.ShowDialog();
this.queueProcessor.RestoreQueue(dialog.FileName);
@@ -374,7 +374,7 @@ namespace HandBrakeWPF.ViewModels {
this.Load();
- this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.WhenCompleteAction);
+ this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.WhenCompleteAction);
this.queueProcessor.JobProcessingStarted += this.queueProcessor_JobProcessingStarted;
this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted;
@@ -414,19 +414,23 @@ namespace HandBrakeWPF.ViewModels private void EncodeService_EncodeStatusChanged(
object sender, EncodeProgressEventArgs e)
{
- if (this.IsEncoding)
+ Caliburn.Micro.Execute.OnUIThread(() =>
{
- this.JobStatus =
- string.Format(
- "Encoding: Pass {0} of {1}, {2:00.00}%, FPS: {3:000.0}, Avg FPS: {4:000.0}, Time Remaining: {5}, Elapsed: {6:hh\\:mm\\:ss}",
- e.Task,
- e.TaskCount,
- e.PercentComplete,
- e.CurrentFrameRate,
- e.AverageFrameRate,
- e.EstimatedTimeLeft,
- e.ElapsedTime);
- }
+ if (this.IsEncoding)
+ {
+ this.JobStatus =
+ string.Format(
+ "Encoding: Pass {0} of {1}, {2:00.00}%, FPS: {3:000.0}, Avg FPS: {4:000.0}, Time Remaining: {5}, Elapsed: {6:hh\\:mm\\:ss}",
+ e.Task,
+ e.TaskCount,
+ e.PercentComplete,
+ e.CurrentFrameRate,
+ e.AverageFrameRate,
+ e.EstimatedTimeLeft,
+ e.ElapsedTime);
+ }
+
+ });
}
/// <summary>
diff --git a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs index 3fcca18aa..9149fde39 100644 --- a/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/SubtitlesViewModel.cs @@ -14,12 +14,9 @@ namespace HandBrakeWPF.ViewModels using System.IO;
using System.Linq;
- using Caliburn.Micro;
-
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
using HandBrake.ApplicationServices.Parsing;
- using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Commands;
@@ -52,13 +49,7 @@ namespace HandBrakeWPF.ViewModels /// <summary>
/// Initializes a new instance of the <see cref="HandBrakeWPF.ViewModels.SubtitlesViewModel"/> class.
/// </summary>
- /// <param name="windowManager">
- /// The window manager.
- /// </param>
- /// <param name="userSettingService">
- /// The user Setting Service.
- /// </param>
- public SubtitlesViewModel(IWindowManager windowManager, IUserSettingService userSettingService)
+ public SubtitlesViewModel()
{
this.Task = new EncodeTask();
|