From 97d4f114df3e35c559e7f1564a542631b55f2845 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 26 Jan 2013 16:21:27 +0000 Subject: [PATCH] WinGui: Code Tidyup. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5206 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Services/Base/EncodeBase.cs | 43 ++++++++++++------- .../Services/LibEncode.cs | 1 - .../Utilities/InteropModelCreator.cs | 39 +++++++++++++---- 3 files changed, 58 insertions(+), 25 deletions(-) diff --git a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs index 67cad52e5..866edb794 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs @@ -15,6 +15,8 @@ namespace HandBrake.ApplicationServices.Services.Base using System.Text; using System.Text.RegularExpressions; + using Caliburn.Micro; + using HandBrake.ApplicationServices.EventArgs; using HandBrake.ApplicationServices.Exceptions; using HandBrake.ApplicationServices.Model; @@ -150,11 +152,15 @@ namespace HandBrake.ApplicationServices.Services.Base /// public void InvokeEncodeStatusChanged(EncodeProgressEventArgs e) { - EncodeProgessStatus handler = this.EncodeStatusChanged; - if (handler != null) - { - handler(this, e); - } + Execute.OnUIThread( + () => + { + EncodeProgessStatus handler = this.EncodeStatusChanged; + if (handler != null) + { + handler(this, e); + } + }); } /// @@ -165,11 +171,15 @@ namespace HandBrake.ApplicationServices.Services.Base /// public void InvokeEncodeCompleted(EncodeCompletedEventArgs e) { - EncodeCompletedStatus handler = this.EncodeCompleted; - if (handler != null) - { - handler(this, e); - } + Execute.OnUIThread( + () => + { + EncodeCompletedStatus handler = this.EncodeCompleted; + if (handler != null) + { + handler(this, e); + } + }); } /// @@ -180,11 +190,14 @@ namespace HandBrake.ApplicationServices.Services.Base /// public void InvokeEncodeStarted(EventArgs e) { - EventHandler handler = this.EncodeStarted; - if (handler != null) - { - handler(this, e); - } + Execute.OnUIThread(() => + { + EventHandler handler = this.EncodeStarted; + if (handler != null) + { + handler(this, e); + } + }); } #endregion diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs index f194700ed..320b96f1b 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs @@ -12,7 +12,6 @@ namespace HandBrake.ApplicationServices.Services using System; using System.Diagnostics; - using HandBrake.ApplicationServices.Exceptions; using HandBrake.ApplicationServices.Model; using HandBrake.ApplicationServices.Services.Base; using HandBrake.ApplicationServices.Services.Interfaces; diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs index 8f9260079..d5bcb930e 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/InteropModelCreator.cs @@ -23,10 +23,6 @@ namespace HandBrake.ApplicationServices.Utilities /// public class InteropModelCreator { - /* - * TODO: This conversion class needs to be finished off before libencode will work. - */ - /// /// Get an EncodeJob model for a LibHB Encode. /// @@ -180,12 +176,37 @@ namespace HandBrake.ApplicationServices.Utilities // job.SourceType = work.Type; job.Title = work.Title; - // TODO Setup subtitles + // Subtitles job.Subtitles = new Subtitles { SourceSubtitles = new List(), SrtSubtitles = new List() }; - //foreach (SubtitleTrack track in work.SubtitleTracks) - //{ - // // TODO - //} + foreach (SubtitleTrack track in work.SubtitleTracks) + { + if (track.IsSrtSubtitle) + { + job.Subtitles.SrtSubtitles.Add( + new SrtSubtitle + { + CharacterCode = track.SrtCharCode, + Default = track.Default, + FileName = track.SrtFileName, + LanguageCode = track.SrtLang, + Offset = track.SrtOffset + }); + } + else + { + if (track.SourceTrack != null) + { + job.Subtitles.SourceSubtitles.Add( + new SourceSubtitle + { + BurnedIn = track.Burned, + Default = track.Default, + Forced = track.Forced, + TrackNumber = track.SourceTrack.TrackNumber + }); + } + } + } return job; } -- 2.40.0