From ad7a5d066591d6aa68a0ec900170d73d2da124e2 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 25 Aug 2007 20:34:42 +0000 Subject: [PATCH] WinGui: - PSP Preset Fix - Cleaned up Exception handling a bit. git-svn-id: svn://localhost/HandBrake/trunk@866 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/HandBrakeCS.csproj | 8 ++++- win/C#/Parsing/DVD.cs | 22 ++++++++----- win/C#/Parsing/Parser.cs | 65 ++++++++++++++++++++++++--------------- win/C#/Parsing/Title.cs | 28 +++++++++++------ win/C#/Properties/AssemblyInfo.cs | 10 +++--- win/C#/frmMain.cs | 2 +- win/C#/frmReadDVD.cs | 6 ++-- 7 files changed, 90 insertions(+), 51 deletions(-) diff --git a/win/C#/HandBrakeCS.csproj b/win/C#/HandBrakeCS.csproj index 1c5a64b1..33ad098d 100644 --- a/win/C#/HandBrakeCS.csproj +++ b/win/C#/HandBrakeCS.csproj @@ -11,15 +11,20 @@ Handbrake handbrakepineapple.ico Handbrake.Program + LocalIntranet + false true full - false + true bin\Debug\ DEBUG;TRACE prompt 4 + default + false + false pdbonly @@ -170,6 +175,7 @@ + diff --git a/win/C#/Parsing/DVD.cs b/win/C#/Parsing/DVD.cs index d2d21153..62a40d81 100644 --- a/win/C#/Parsing/DVD.cs +++ b/win/C#/Parsing/DVD.cs @@ -42,18 +42,24 @@ namespace Handbrake.Parsing public static DVD Parse(StreamReader output) { DVD thisDVD = new DVD(); - while (!output.EndOfStream) + try { - if ((char)output.Peek() == '+') + while (!output.EndOfStream) { - string testb = output.ReadToEnd(); - thisDVD.m_titles.AddRange(Title.ParseList(testb)); - } - else - { - output.ReadLine(); + if ((char)output.Peek() == '+') + { + thisDVD.m_titles.AddRange(Title.ParseList(output.ReadToEnd())); + } + else + { + output.ReadLine(); + } } } + catch (Exception exc) + { + MessageBox.Show("DVD.CS - Parse" + exc.ToString()); + } return thisDVD; } } diff --git a/win/C#/Parsing/Parser.cs b/win/C#/Parsing/Parser.cs index f56999a0..ea2ae57f 100644 --- a/win/C#/Parsing/Parser.cs +++ b/win/C#/Parsing/Parser.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using System.IO; using System.Text.RegularExpressions; +using System.Windows.Forms; namespace Handbrake.Parsing { @@ -79,30 +80,38 @@ namespace Handbrake.Parsing public override string ReadLine() { string tmp = base.ReadLine(); - this.m_buffer += tmp; - Match m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)"); - if (OnReadLine != null) + try { - OnReadLine(this, tmp); - } - if (m.Success && OnScanProgress != null) - { - OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value)); - } - m = Regex.Match(tmp, @"^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\.[0-9]*) %( \(([0-9]*\.[0-9]*) fps, avg ([0-9]*\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\))?"); - if (m.Success && OnEncodeProgress != null) - { - int currentTask = int.Parse(m.Groups[1].Value); - int totalTasks = int.Parse(m.Groups[2].Value); - float percent = float.Parse(m.Groups[3].Value); - float currentFps = m.Groups[5].Value == string.Empty ? 0.0F : float.Parse(m.Groups[5].Value); - float avgFps = m.Groups[6].Value == string.Empty ? 0.0F : float.Parse(m.Groups[6].Value); - TimeSpan remaining = TimeSpan.Zero; - if (m.Groups[7].Value != string.Empty) + + this.m_buffer += tmp; + Match m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)"); + if (OnReadLine != null) + { + OnReadLine(this, tmp); + } + if (m.Success && OnScanProgress != null) + { + OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value)); + } + m = Regex.Match(tmp, @"^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\.[0-9]*) %( \(([0-9]*\.[0-9]*) fps, avg ([0-9]*\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\))?"); + if (m.Success && OnEncodeProgress != null) { - remaining = TimeSpan.Parse(m.Groups[7].Value + ":" + m.Groups[8].Value + ":" + m.Groups[9].Value); + int currentTask = int.Parse(m.Groups[1].Value); + int totalTasks = int.Parse(m.Groups[2].Value); + float percent = float.Parse(m.Groups[3].Value); + float currentFps = m.Groups[5].Value == string.Empty ? 0.0F : float.Parse(m.Groups[5].Value); + float avgFps = m.Groups[6].Value == string.Empty ? 0.0F : float.Parse(m.Groups[6].Value); + TimeSpan remaining = TimeSpan.Zero; + if (m.Groups[7].Value != string.Empty) + { + remaining = TimeSpan.Parse(m.Groups[7].Value + ":" + m.Groups[8].Value + ":" + m.Groups[9].Value); + } + OnEncodeProgress(this, currentTask, totalTasks, percent, currentFps, avgFps, remaining); } - OnEncodeProgress(this, currentTask, totalTasks, percent, currentFps, avgFps, remaining); + } + catch (Exception exc) + { + MessageBox.Show("Parser.cs - ReadLine " + exc.ToString()); } return tmp; } @@ -110,10 +119,18 @@ namespace Handbrake.Parsing public override string ReadToEnd() { string tmp = base.ReadToEnd(); - this.m_buffer += tmp; - if (OnReadToEnd != null) + try + { + + this.m_buffer += tmp; + if (OnReadToEnd != null) + { + OnReadToEnd(this, tmp); + } + } + catch (Exception exc) { - OnReadToEnd(this, tmp); + MessageBox.Show("Parser.cs - ReadToEnd " + exc.ToString()); } return tmp; } diff --git a/win/C#/Parsing/Title.cs b/win/C#/Parsing/Title.cs index a78fef78..3c3aaca7 100644 --- a/win/C#/Parsing/Title.cs +++ b/win/C#/Parsing/Title.cs @@ -137,11 +137,9 @@ namespace Handbrake.Parsing public static Title Parse(StringReader output) { Title thisTitle = new Title(); - - // Match track number for this title try { - + // Match track number for this title Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):"); if (m.Success) { @@ -150,20 +148,21 @@ namespace Handbrake.Parsing output.ReadLine(); // Get duration for this title + m = Regex.Match(output.ReadLine(), @"^ \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})"); if (m.Success) { thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value); } + // Get resolution, aspect ratio and FPS for this title m = Regex.Match(output.ReadLine(), @"^ \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps"); if (m.Success) { thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value)); - thisTitle.m_aspectRatio = m.Groups[3].ToString(); // Converted to a String for French Lanuage based systems. Some weird exception thrown - // when trying to parse it as a float - // we don't need FPS right now + thisTitle.m_aspectRatio = m.Groups[3].ToString(); // Converted to a String from float. Caused issue on french systems + // French system floats are 1,78 not 1.78 and the CLI always outputs a . } // Get autocrop region for this title @@ -179,18 +178,27 @@ namespace Handbrake.Parsing } catch (Exception exc) { - MessageBox.Show(exc.ToString()); + MessageBox.Show("Title.cs - Parse " + exc.ToString()); } + + return thisTitle; } public static Title[] ParseList(string output) { List titles = new List<Title>(); - StringReader sr = new StringReader(output); - while ((char)sr.Peek() == '+') + try + { + StringReader sr = new StringReader(output); + while ((char)sr.Peek() == '+') + { + titles.Add(Title.Parse(sr)); + } + } + catch (Exception exc) { - titles.Add(Title.Parse(sr)); + MessageBox.Show("Title.cs - ParseList " + exc.ToString()); } return titles.ToArray(); } diff --git a/win/C#/Properties/AssemblyInfo.cs b/win/C#/Properties/AssemblyInfo.cs index a375c642..6af0e190 100644 --- a/win/C#/Properties/AssemblyInfo.cs +++ b/win/C#/Properties/AssemblyInfo.cs @@ -1,14 +1,15 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; +using System.Resources; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Handbrake")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyDescription("DVD to MPEG-4 converter")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] +[assembly: AssemblyCompany("Handbrake")] [assembly: AssemblyProduct("Handbrake")] [assembly: AssemblyCopyright("Copyright © 2007")] [assembly: AssemblyTrademark("")] @@ -29,5 +30,6 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.4.0.0")] -[assembly: AssemblyFileVersion("20.4.0.0")] +[assembly: AssemblyVersion("2.4.0.1")] +[assembly: AssemblyFileVersion("2.4.0.1")] +[assembly: NeutralResourcesLanguageAttribute("en-GB")] diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 30360a66..e84ccc64 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -752,7 +752,7 @@ namespace Handbrake CheckPixelRatio.CheckState = CheckState.Unchecked; text_width.Text = "368"; text_height.Text = "208"; - drp_videoEncoder.Text = "H.264"; + drp_videoEncoder.Text = "Mpeg 4"; text_bitrate.Text = "1024"; text_filesize.Text = ""; slider_videoQuality.Value = 0; diff --git a/win/C#/frmReadDVD.cs b/win/C#/frmReadDVD.cs index caef654c..526e9bd2 100644 --- a/win/C#/frmReadDVD.cs +++ b/win/C#/frmReadDVD.cs @@ -46,7 +46,7 @@ namespace Handbrake } catch(Exception exc) { - MessageBox.Show(exc.ToString()); + MessageBox.Show("frmReadDVD.cs - btn_ok_Click " + exc.ToString()); } } @@ -69,7 +69,7 @@ namespace Handbrake } catch(Exception exc) { - MessageBox.Show(exc.ToString()); + MessageBox.Show("frmReadDVD.cs - updateUIElements " + exc.ToString()); } } @@ -103,7 +103,7 @@ namespace Handbrake } catch (Exception exc) { - MessageBox.Show(exc.ToString()); + MessageBox.Show("frmReadDVD.cs - startProc " + exc.ToString()); } } -- 2.11.0