\r
using HandBrake.ApplicationServices.Exceptions;\r
\r
+ using HandBrakeWPF.Utilities;\r
using HandBrakeWPF.ViewModels;\r
using HandBrakeWPF.ViewModels.Interfaces;\r
\r
protected override void OnStartup(StartupEventArgs e)\r
{\r
OperatingSystem OS = Environment.OSVersion;\r
- if ((OS.Platform == PlatformID.Win32NT) && (OS.Version.Major == 5 && OS.Version.Minor == 1 ))\r
+ if ((OS.Platform == PlatformID.Win32NT) && (OS.Version.Major == 5 && OS.Version.Minor == 1))\r
{\r
MessageBox.Show("Windows XP support is currently broken. It is not known if or when it will be fixed.", "Notice", MessageBoxButton.OK, MessageBoxImage.Warning);\r
Application.Current.Shutdown();\r
MessageBox.Show("Instant HandBrake is just a prototype for toying with ideas. It may or may not work, or even be included in future builds.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);\r
}\r
\r
+ if (e.Args.Any(f => f.Equals("--reset")))\r
+ {\r
+ HandBrakeApp.ResetToDefaults();\r
+ Application.Current.Shutdown();\r
+ return;\r
+ }\r
+\r
base.OnStartup(e);\r
\r
// If we have a file dropped on the icon, try scanning it.\r
<Compile Include="Services\Interfaces\IUserSettingService.cs" />\r
<Compile Include="Services\UserSettingService.cs" />\r
<Compile Include="Utilities\DelayedActionProcessor.cs" />\r
+ <Compile Include="Utilities\HandBrakeApp.cs" />\r
<Compile Include="ViewModels\CountdownAlertViewModel.cs" />\r
<Compile Include="ViewModels\Interfaces\ICountdownAlertViewModel.cs" />\r
<Compile Include="Controls\SourceSelection.xaml.cs">\r
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="HandBrakeApp.cs" company="HandBrake Project (http://handbrake.fr)">\r
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+// A general Helper class for HandBrake GUI\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrakeWPF.Utilities\r
+{\r
+ using System;\r
+ using System.Collections.Generic;\r
+ using System.IO;\r
+ using System.Linq;\r
+\r
+ /// <summary>\r
+ /// A general Helper class for HandBrake GUI\r
+ /// </summary>\r
+ public class HandBrakeApp\r
+ {\r
+ /// <summary>\r
+ /// The reset to defaults.\r
+ /// </summary>\r
+ public static void ResetToDefaults()\r
+ {\r
+ DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\presets.xml");\r
+ DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\user_presets.xml");\r
+ DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\settings.xml");\r
+\r
+ string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");\r
+ DirectoryInfo info = new DirectoryInfo(tempPath);\r
+ IEnumerable<FileInfo> logFiles = info.GetFiles("*.xml").Where(f => f.Name.StartsWith("hb_queue_recovery"));\r
+ foreach (FileInfo file in logFiles)\r
+ {\r
+ DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\" + file.Name);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// The delete file.\r
+ /// </summary>\r
+ /// <param name="file">\r
+ /// The file.\r
+ /// </param>\r
+ private static void DeleteFile(string file)\r
+ {\r
+ try\r
+ {\r
+ Console.WriteLine("Trying to deleting File: {0}", file);\r
+ if (File.Exists(file))\r
+ {\r
+ File.Delete(file);\r
+ Console.WriteLine("File was deleted successfully");\r
+ }\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ Console.WriteLine("Unable to Delete File: {0} {1} {2}", file, Environment.NewLine, exc);\r
+ }\r
+ }\r
+ }\r
+}\r
if (string.IsNullOrEmpty(this.CurrentTask.Destination))\r
{\r
this.errorService.ShowMessageBox(Resources.Main_SetDestination, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);\r
+ return;\r
}\r
\r
QueueTask task = new QueueTask(new EncodeTask(this.CurrentTask), HBConfigurationFactory.Create());\r
-\r
-\r
+ \r
if (!this.queueProcessor.CheckForDestinationPathDuplicates(task.Task.Destination))\r
{\r
this.queueProcessor.Add(task);\r