diff options
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 81 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 53 |
2 files changed, 115 insertions, 19 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 51e032e9a..420443a58 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -23,7 +23,9 @@ namespace HandBrakeWPF.ViewModels using HandBrake.ApplicationServices;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Model.Encoding;
+ using HandBrake.ApplicationServices.Model.General;
using HandBrake.ApplicationServices.Parsing;
+ using HandBrake.ApplicationServices.Services;
using HandBrake.ApplicationServices.Services.Interfaces;
using HandBrake.ApplicationServices.Utilities;
@@ -68,6 +70,11 @@ namespace HandBrakeWPF.ViewModels private readonly IErrorService errorService;
/// <summary>
+ /// Backing field for the user setting service.
+ /// </summary>
+ private readonly IUserSettingService userSettingService;
+
+ /// <summary>
/// HandBrakes Main Window Title
/// </summary>
private string windowName;
@@ -154,6 +161,7 @@ namespace HandBrakeWPF.ViewModels this.encodeService = encodeService;
this.presetService = presetService;
this.errorService = errorService;
+ this.userSettingService = userSettingService;
this.queueProcessor = IoC.Get<IQueueProcessor>(); // TODO Instance ID!
// Setup Properties
@@ -687,7 +695,14 @@ namespace HandBrakeWPF.ViewModels /// </summary>
public void CheckForUpdates()
{
- throw new NotImplementedException("Not Yet Implemented");
+ // TODO The update service needs refactoring.
+ this.userSettingService.SetUserSetting(UserSettingConstants.LastUpdateCheckDate, DateTime.Now);
+ string url = userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakePlatform).Contains("x86_64")
+ ? userSettingService.GetUserSetting<string>(UserSettingConstants.Appcast_x64)
+ : userSettingService.GetUserSetting<string>(UserSettingConstants.Appcast_i686);
+ UpdateService.BeginCheckForUpdates(UpdateCheckHelper.UpdateCheckDoneMenu, false,
+ url, userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild),
+ userSettingService.GetUserSetting<int>(UserSettingConstants.Skipversion));
}
/// <summary>
@@ -817,6 +832,26 @@ namespace HandBrakeWPF.ViewModels #region Main Window Public Methods
/// <summary>
+ /// Support dropping a file onto the main window to scan.
+ /// </summary>
+ /// <param name="e">
+ /// The DragEventArgs.
+ /// </param>
+ public void FilesDroppedOnWindow(DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(DataFormats.FileDrop))
+ {
+ string[] fileNames = e.Data.GetData(DataFormats.FileDrop, true) as string[];
+ if (fileNames != null && fileNames.Count() >= 1 && File.Exists(fileNames[0]))
+ {
+ this.StartScan(fileNames[0], 0);
+ }
+ }
+
+ e.Handled = true;
+ }
+
+ /// <summary>
/// The Destination Path
/// </summary>
public void BrowseDestination()
@@ -955,6 +990,17 @@ namespace HandBrakeWPF.ViewModels this.SelectedPreset = this.presetService.DefaultPreset;
}
+ /// <summary>
+ /// Set the selected preset.
+ /// </summary>
+ /// <param name="e">
+ /// The RoutedPropertyChangedEventArgs.
+ /// </param>
+ public void SetSelectedPreset(RoutedPropertyChangedEventArgs<object> e)
+ {
+ this.SelectedPreset = e.NewValue as Preset;
+ }
+
#endregion
#region Private Methods
@@ -993,7 +1039,7 @@ namespace HandBrakeWPF.ViewModels newExtension = this.CurrentTask.RequiresM4v ? ".m4v" : ".mp4";
break;
case 1: // MP4
- newExtension = ".mp4";
+ newExtension = ".mp4";
break;
case 2: // M4v
newExtension = ".m4v";
@@ -1070,23 +1116,22 @@ namespace HandBrakeWPF.ViewModels /// </param>
private void ScanCompleted(object sender, HandBrake.ApplicationServices.EventArgs.ScanCompletedEventArgs e)
{
- Caliburn.Micro.Execute.OnUIThread(() =>
- {
- if (e.Successful)
- {
- this.scanService.SouceData.CopyTo(this.ScannedSource);
- this.NotifyOfPropertyChange("ScannedSource");
- this.NotifyOfPropertyChange("ScannedSource.Titles");
- this.SelectedTitle = this.ScannedSource.Titles.Where(t => t.MainTitle).FirstOrDefault();
- this.JobContextService.CurrentSource = this.ScannedSource;
- this.JobContextService.CurrentTask = this.CurrentTask;
- this.SetupTabs();
- }
-
- this.SourceLabel = "Scan Completed";
-
- });
+ Caliburn.Micro.Execute.OnUIThread(() =>
+ {
+ if (e.Successful)
+ {
+ this.scanService.SouceData.CopyTo(this.ScannedSource);
+ this.NotifyOfPropertyChange("ScannedSource");
+ this.NotifyOfPropertyChange("ScannedSource.Titles");
+ this.SelectedTitle = this.ScannedSource.Titles.Where(t => t.MainTitle).FirstOrDefault()
+ ?? this.ScannedSource.Titles.FirstOrDefault();
+ this.JobContextService.CurrentSource = this.ScannedSource;
+ this.JobContextService.CurrentTask = this.CurrentTask;
+ this.SetupTabs();
+ }
+ this.SourceLabel = "Scan Completed";
+ });
// TODO Re-enable GUI.
}
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index 060d9ec38..45ea7862b 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -73,13 +73,16 @@ namespace HandBrakeWPF.ViewModels this.JobStatus = "There are no jobs currently encoding";
}
+ /// <summary>
+ /// Gets QueueJobs.
+ /// </summary>
public ObservableCollection<QueueTask> QueueJobs
{
get { return this.queueProcessor.QueueManager.Queue; }
}
/// <summary>
- /// Gets or sets IsEncoding.
+ /// Gets or sets a value indicating whether IsEncoding.
/// </summary>
public bool IsEncoding
{
@@ -178,6 +181,9 @@ namespace HandBrakeWPF.ViewModels this.JobsPending = string.Format("{0} jobs pending", this.queueProcessor.QueueManager.Count);
}
+ /// <summary>
+ /// Handle the On Window Load
+ /// </summary>
public override void OnLoad()
{
this.queueProcessor.JobProcessingStarted += queueProcessor_JobProcessingStarted;
@@ -209,18 +215,45 @@ namespace HandBrakeWPF.ViewModels base.OnActivate();
}
+ /// <summary>
+ /// Handle the Queue Paused Event
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The EventArgs.
+ /// </param>
private void queueProcessor_QueuePaused(object sender, System.EventArgs e)
{
this.JobStatus = "Queue Paused";
this.JobsPending = string.Format("{0} jobs pending", this.queueProcessor.QueueManager.Count);
}
+ /// <summary>
+ /// Handle the Queue Completed Event
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The EventArgs.
+ /// </param>
private void queueProcessor_QueueCompleted(object sender, System.EventArgs e)
{
this.JobStatus = "Queue Completed";
this.JobsPending = string.Format("{0} jobs pending", this.queueProcessor.QueueManager.Count);
}
+ /// <summary>
+ /// Handle teh Job Processing Started Event
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The QueueProgressEventArgs.
+ /// </param>
private void queueProcessor_JobProcessingStarted(object sender, HandBrake.ApplicationServices.EventArgs.QueueProgressEventArgs e)
{
this.JobStatus = "Queue Started";
@@ -228,6 +261,15 @@ namespace HandBrakeWPF.ViewModels this.queueProcessor.EncodeService.EncodeStatusChanged += EncodeService_EncodeStatusChanged;
}
+ /// <summary>
+ /// Handle the Encode Status Changed Event.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The EncodeProgressEventArgs.
+ /// </param>
private void EncodeService_EncodeStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.EncodeProgressEventArgs e)
{
this.JobStatus = string.Format(
@@ -241,6 +283,15 @@ namespace HandBrakeWPF.ViewModels e.ElapsedTime);
}
+ /// <summary>
+ /// Handle the Queue Changed Event.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
private void QueueManager_QueueChanged(object sender, System.EventArgs e)
{
// TODO
|