]> granicus.if.org Git - handbrake/commitdiff
WinGui: Few small updates to the EncodeTaskImportFactory
authorsr55 <sr55.hb@outlook.com>
Fri, 13 Jul 2018 21:19:52 +0000 (22:19 +0100)
committersr55 <sr55.hb@outlook.com>
Fri, 13 Jul 2018 21:20:05 +0000 (22:20 +0100)
win/CS/HandBrakeWPF/Extensions/StringExtensions.cs
win/CS/HandBrakeWPF/Services/Encode/Factories/EncodeTaskImportFactory.cs

index d3324a91324ec2da63bc4cac7099f91cd6c8dca3..cf7e507aaf8e3b867c3978497092746f40443eac 100644 (file)
@@ -24,8 +24,17 @@ namespace HandBrakeWPF.Extensions
         public static string ToTitleCase(this string input)\r
         {\r
             TextInfo textInfo = new CultureInfo(CultureInfo.CurrentCulture.Name, false).TextInfo;\r
-            return textInfo.ToTitleCase(input.ToLower());\r
-          \r
+            return textInfo.ToTitleCase(input.ToLower());       \r
+        }\r
+\r
+        public static int ToInt(this string input)\r
+        {\r
+            if (int.TryParse(input, out int value))\r
+            {\r
+                return value;\r
+            }\r
+\r
+            return 0;\r
         }\r
     }\r
 }\r
index 52ccf4222a0aadfd0afed7079108a715fea90038..ea19c367ec7593c72b8d4de06a8697794fb3be5f 100644 (file)
 namespace HandBrakeWPF.Services.Encode.Factories
 {
     using System;
-    using System.Collections.Generic;
     using System.Diagnostics;
     using System.Linq;
-    using System.Windows.Forms.VisualStyles;
 
     using HandBrake.Interop.Interop;
     using HandBrake.Interop.Interop.HbLib;
     using HandBrake.Interop.Interop.Json.Encode;
     using HandBrake.Interop.Interop.Model.Encoding;
     using HandBrake.Interop.Model;
-
+    using HandBrakeWPF.Extensions;
     using HandBrakeWPF.Services.Encode.Model.Models;
     using HandBrakeWPF.Services.Encode.Model.Models.Video;
     using HandBrakeWPF.Utilities;
-    using HandBrakeWPF.ViewModels.Interfaces;
-
-    using Newtonsoft.Json.Linq;
 
     using AudioEncoder = Model.Models.AudioEncoder;
     using AudioEncoderRateType = Model.Models.AudioEncoderRateType;
@@ -48,7 +43,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
          * TODO
          * 1. Reconstruct the Config
          * 2. Reconstruct Queue State
-         * 3. Filters
+         * 3. Update JSON API. See #1481
          */
 
         internal static EncodeTask Create(JsonEncodeObject job)
@@ -314,8 +309,8 @@ namespace HandBrakeWPF.Services.Encode.Factories
             if (rotationFilter != null)
             {
                 var filterSettings = rotationFilter.Settings;
-                task.Rotation = filterSettings.Value<int>("angle");  // TODO split the string.
-                task.FlipVideo = filterSettings.Value<bool>("hflip");
+                task.Rotation = filterSettings.Value<int>("angle");
+                task.FlipVideo = filterSettings.Value<string>("hflip") == "1";
             }
 
             // Deblock
@@ -323,7 +318,7 @@ namespace HandBrakeWPF.Services.Encode.Factories
             if (deblockFilter != null)
             {
                 var filterSettings = deblockFilter.Settings;
-                task.Deblock = filterSettings.Value<int>("qp");  // TODO Split the string
+                task.Deblock = filterSettings.Value<string>("qp").ToInt(); 
             }
 
             // Sharpen