IDictionary<int, string> chapterMap = new Dictionary<int, string>();\r
try\r
{\r
- StreamReader sr = new StreamReader(filename);\r
- string csv = sr.ReadLine();\r
- while (csv != null)\r
+ using (StreamReader sr = new StreamReader(filename))\r
{\r
- if (csv.Trim() != string.Empty)\r
+ string csv = sr.ReadLine();\r
+ while (csv != null)\r
{\r
- csv = csv.Replace("\\,", "<!comma!>");\r
- string[] contents = csv.Split(',');\r
- int chapter;\r
- int.TryParse(contents[0], out chapter);\r
- chapterMap.Add(chapter, contents[1].Replace("<!comma!>", ","));\r
+ if (csv.Trim() != string.Empty)\r
+ {\r
+ csv = csv.Replace("\\,", "<!comma!>");\r
+ string[] contents = csv.Split(',');\r
+ int chapter;\r
+ int.TryParse(contents[0], out chapter);\r
+ chapterMap.Add(chapter, contents[1].Replace("<!comma!>", ","));\r
+ }\r
+ csv = sr.ReadLine();\r
}\r
- csv = sr.ReadLine();\r
}\r
}\r
catch (Exception)\r
}\r
catch (Exception exc)\r
{\r
- throw new GeneralApplicationException("Unable to save Chapter Makrers file! ", "Chapter marker names will NOT be saved in your encode.", exc);\r
+ throw new GeneralApplicationException("Unable to save the chapter information to csv.", "The file may already be in use by another application.", exc);\r
}\r
}\r
\r
using System.Text;\r
\r
using HandBrake.ApplicationServices.EventArgs;\r
+ using HandBrake.ApplicationServices.Exceptions;\r
using HandBrake.ApplicationServices.Functions;\r
using HandBrake.ApplicationServices.Model;\r
using HandBrake.ApplicationServices.Services.Interfaces;\r
/// </summary>\r
public EncodeBase()\r
{\r
- this.logBuffer = new StringBuilder(); \r
+ this.logBuffer = new StringBuilder();\r
}\r
\r
#region Events\r
protected void VerifyEncodeDestinationPath(QueueTask task)\r
{\r
// Make sure the path exists, attempt to create it if it doesn't\r
- string path = Directory.GetParent(task.Destination).ToString();\r
- if (!Directory.Exists(path))\r
+ try\r
{\r
- try\r
+ string path = Directory.GetParent(task.Destination).ToString();\r
+ if (!Directory.Exists(path))\r
{\r
Directory.CreateDirectory(path);\r
}\r
- catch (Exception)\r
- {\r
- throw new Exception(\r
- "Unable to create directory for the encoded output. Please verify the drive and path is correct.");\r
- }\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ throw new GeneralApplicationException(\r
+ "Unable to create directory for the encoded output.", "Please verify that you have a valid path.", exc);\r
}\r
}\r
\r
{\r
XmlSerializer serializer = new XmlSerializer(typeof(List<QueueTask>));\r
\r
- List<QueueTask> list = serializer.Deserialize(strm) as List<QueueTask>;\r
+ List<QueueTask> list;\r
+\r
+ try\r
+ {\r
+ list = serializer.Deserialize(strm) as List<QueueTask>; \r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ throw new GeneralApplicationException("Unable to restore queue file.", "The file may be corrupted or from an older incompatible version of HandBrake", exc);\r
+ }\r
\r
if (list != null)\r
foreach (QueueTask item in list)\r
{\r
this.QueueManager.LastProcessedJob.Status = QueueItemStatus.Error;\r
this.Pause();\r
+ if (e.Exception.GetType() == typeof(GeneralApplicationException))\r
+ {\r
+ throw e.Exception;\r
+ }\r
throw new GeneralApplicationException(e.ErrorInformation, e.Exception.Message, e.Exception);\r
}\r
\r
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>\r
<IsWebBootstrapper>false</IsWebBootstrapper>\r
<SignManifests>false</SignManifests>\r
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>\r
<PublishUrl>publish\</PublishUrl>\r
<Install>true</Install>\r
<InstallFrom>Disk</InstallFrom>\r
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>\r
<UseApplicationTrust>false</UseApplicationTrust>\r
<BootstrapperEnabled>true</BootstrapperEnabled>\r
- <TargetFrameworkProfile>Client</TargetFrameworkProfile>\r
</PropertyGroup>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">\r
<PlatformTarget>x86</PlatformTarget>\r
<PlatformTarget>x86</PlatformTarget>\r
<OutputPath>bin\x86\Release\</OutputPath>\r
<UseVSHostingProcess>false</UseVSHostingProcess>\r
- <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+ <DefineConstants>\r
+ </DefineConstants>\r
<Optimize>true</Optimize>\r
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>\r
</PropertyGroup>\r
\r
// Handle any unhandled exceptions\r
AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;\r
+ Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);\r
\r
// Check that HandBrakeCLI is availabl.\r
string failedInstall = "HandBrake is not installed properly. Please reinstall HandBrake. \n\n";\r
this.ChaptersMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
this.mnu_resetChapters});\r
this.ChaptersMenu.Name = "presets_menu";\r
- this.ChaptersMenu.OwnerItem = this.btn_file_source;\r
+ this.ChaptersMenu.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;\r
this.ChaptersMenu.Size = new System.Drawing.Size(188, 26);\r
this.ChaptersMenu.Text = ";";\r
// \r