diff options
author | sr55 <[email protected]> | 2011-08-17 14:05:33 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2011-08-17 14:05:33 +0000 |
commit | ebc5352895fbb61f31d7e6f4b48718e5f9be2a0e (patch) | |
tree | b6425004a46d2aeff48a43df1a8b51285a2b74d0 /win/CS/HandBrake.ApplicationServices/Services | |
parent | 1bd57899117e7b796d95cade71520dc87984a197 (diff) |
WinGui: Finish migrating the settings over to the new user setting service.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4183 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services')
7 files changed, 42 insertions, 36 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs index 6ab0e52a8..f88e7a06e 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs @@ -214,17 +214,17 @@ namespace HandBrake.ApplicationServices.Services.Base File.Copy(tempLogFile, Path.Combine(logDir, encodeLogFile));
// Save a copy of the log file in the same location as the enocde.
- if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogWithVideo))
+ if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SaveLogWithVideo))
{
File.Copy(tempLogFile, Path.Combine(encodeDestinationPath, encodeLogFile));
}
// Save a copy of the log file to a user specified location
- if (Directory.Exists(this.userSettingService.GetUserSetting<string>(UserSettingConstants.SaveLogCopyDirectory)) &&
- this.userSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogToCopyDirectory))
+ if (Directory.Exists(this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SaveLogCopyDirectory)) &&
+ this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SaveLogToCopyDirectory))
{
File.Copy(
- tempLogFile, Path.Combine(this.userSettingService.GetUserSetting<string>(UserSettingConstants.SaveLogCopyDirectory), encodeLogFile));
+ tempLogFile, Path.Combine(this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.SaveLogCopyDirectory), encodeLogFile));
}
}
catch (Exception)
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs index 70f8f86ee..ade0f5e29 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs @@ -107,7 +107,7 @@ namespace HandBrake.ApplicationServices.Services }
}
- if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep))
+ if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))
{
Win32.PreventSleep();
}
@@ -121,7 +121,7 @@ namespace HandBrake.ApplicationServices.Services RedirectStandardOutput = true,
RedirectStandardError = enableLogging ? true : false,
UseShellExecute = false,
- CreateNoWindow = !this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowCLI) ? true : false
+ CreateNoWindow = !this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.ShowCLI) ? true : false
};
this.HbProcess = new Process { StartInfo = cliStart };
@@ -147,7 +147,7 @@ namespace HandBrake.ApplicationServices.Services }
// Set the Process Priority
- switch (this.userSettingService.GetUserSetting<string>(UserSettingConstants.ProcessPriority))
+ switch (this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.ProcessPriority))
{
case "Realtime":
this.HbProcess.PriorityClass = ProcessPriorityClass.RealTime;
@@ -258,7 +258,7 @@ namespace HandBrake.ApplicationServices.Services this.WindowsSeven.SetTaskBarProgressToNoProgress();
}
- if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep))
+ if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))
{
Win32.AllowSleep();
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs index 7ee9a9df3..57f4b18fd 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/LibEncode.cs @@ -114,7 +114,7 @@ namespace HandBrake.ApplicationServices.Services }
// Prvent the system from sleeping if the user asks
- if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep) )
+ if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep) )
{
Win32.PreventSleep();
}
@@ -126,7 +126,7 @@ namespace HandBrake.ApplicationServices.Services this.instance.StartEncode(encodeJob);
// Set the Process Priority
- switch (this.userSettingService.GetUserSetting<string>(UserSettingConstants.ProcessPriority))
+ switch (this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.ProcessPriority))
{
case "Realtime":
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
@@ -285,7 +285,7 @@ namespace HandBrake.ApplicationServices.Services this.WindowsSeven.SetTaskBarProgressToNoProgress();
}
- if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PreventSleep))
+ if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))
{
Win32.AllowSleep();
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs index b856577a9..d416624dc 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs @@ -262,7 +262,7 @@ namespace HandBrake.ApplicationServices.Services Category = category,
Name = presetName[0].Replace("+", string.Empty).Trim(),
Query = presetName[2],
- Version = this.userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion),
+ Version = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion),
CropSettings = pic,
Description = string.Empty, // Maybe one day we will populate this.
IsBuildIn = true
@@ -302,7 +302,7 @@ namespace HandBrake.ApplicationServices.Services List<Preset> preset = this.presets.Where(p => p.IsBuildIn).ToList();
if (preset.Count > 0)
{
- if (preset[0].Version != this.userSettingService.GetUserSetting<string>(UserSettingConstants.HandBrakeVersion))
+ if (preset[0].Version != this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion))
{
this.UpdateBuiltInPresets();
return true;
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs index 478fa3661..91667debe 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs @@ -201,7 +201,7 @@ namespace HandBrake.ApplicationServices.Services this.QueueManager.LastProcessedJob.Status = QueueItemStatus.Completed;
// Growl
- if (userSettingService.GetUserSetting<bool>(UserSettingConstants.GrowlEncode))
+ if (userSettingService.GetUserSetting<bool>(ASUserSettingConstants.GrowlEncode))
GrowlCommunicator.Notify("Encode Completed",
"Put down that cocktail...\nyour Handbrake encode is done.");
@@ -271,10 +271,10 @@ namespace HandBrake.ApplicationServices.Services /// <param name="file"> The file path</param>
private static void SendToApplication(string file)
{
- if (userSettingService.GetUserSetting<bool>(UserSettingConstants.SendFile) && !string.IsNullOrEmpty(userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo)))
+ if (userSettingService.GetUserSetting<bool>(ASUserSettingConstants.SendFile) && !string.IsNullOrEmpty(userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo)))
{
- string args = string.Format("{0} \"{1}\"", userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileToArgs), file);
- ProcessStartInfo vlc = new ProcessStartInfo(userSettingService.GetUserSetting<string>(UserSettingConstants.SendFileTo), args);
+ string args = string.Format("{0} \"{1}\"", userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileToArgs), file);
+ ProcessStartInfo vlc = new ProcessStartInfo(userSettingService.GetUserSetting<string>(ASUserSettingConstants.SendFileTo), args);
Process.Start(vlc);
}
}
@@ -285,13 +285,13 @@ namespace HandBrake.ApplicationServices.Services private static void Finish()
{
// Growl
- if (userSettingService.GetUserSetting<bool>(UserSettingConstants.GrowlQueue))
+ if (userSettingService.GetUserSetting<bool>(ASUserSettingConstants.GrowlQueue))
{
GrowlCommunicator.Notify("Queue Completed", "Put down that cocktail...\nyour Handbrake queue is done.");
}
// Do something whent he encode ends.
- switch (userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction))
+ switch (userSettingService.GetUserSetting<string>(ASUserSettingConstants.WhenCompleteAction))
{
case "Shutdown":
Process.Start("Shutdown", "-s -t 60");
diff --git a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs index a9c9e07ce..26bfd582a 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs @@ -195,12 +195,12 @@ namespace HandBrake.ApplicationServices.Services extraArguments += " --previews " + previewCount;
}
- if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav))
+ if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav))
{
extraArguments += " --no-dvdnav";
}
- extraArguments += string.Format(" --min-duration={0}", this.userSettingService.GetUserSetting<int>(UserSettingConstants.MinScanDuration));
+ extraArguments += string.Format(" --min-duration={0}", this.userSettingService.GetUserSetting<int>(ASUserSettingConstants.MinScanDuration));
if (title > 0)
{
diff --git a/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs b/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs index 6a8584018..ace53f97f 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/UserSettingService.cs @@ -104,6 +104,12 @@ namespace HandBrake.ApplicationServices.Services /// </summary>
private void Save()
{
+ string directory = Path.GetDirectoryName(this.settingsFile);
+ if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
+ {
+ Directory.CreateDirectory(directory);
+ }
+
using (FileStream strm = new FileStream(this.settingsFile, FileMode.Create, FileAccess.Write))
{
serializer.Serialize(strm, this.userSettings);
@@ -157,21 +163,21 @@ namespace HandBrake.ApplicationServices.Services private void SetAllDefaults()
{
userSettings = new SerializableDictionary<string, object>();
- userSettings[UserSettingConstants.X264Step] = 0.25;
- userSettings[UserSettingConstants.Verbosity] = 1;
- userSettings[UserSettingConstants.WhenCompleteAction] = "Do Nothing";
- userSettings[UserSettingConstants.GrowlEncode] = false;
- userSettings[UserSettingConstants.GrowlQueue] = false;
- userSettings[UserSettingConstants.ProcessPriority] = "Below Normal";
- userSettings[UserSettingConstants.PreventSleep] = true;
- userSettings[UserSettingConstants.ShowCLI] = false;
- userSettings[UserSettingConstants.SaveLogToCopyDirectory] = false;
- userSettings[UserSettingConstants.SaveLogWithVideo] = false;
- userSettings[UserSettingConstants.DisableLibDvdNav] = false;
- userSettings[UserSettingConstants.SendFile] = false;
- userSettings[UserSettingConstants.MinScanDuration] = 10;
- userSettings[UserSettingConstants.HandBrakeBuild] = 0;
- userSettings[UserSettingConstants.HandBrakeVersion] = string.Empty;
+ userSettings[ASUserSettingConstants.X264Step] = 0.25;
+ userSettings[ASUserSettingConstants.Verbosity] = 1;
+ userSettings[ASUserSettingConstants.WhenCompleteAction] = "Do Nothing";
+ userSettings[ASUserSettingConstants.GrowlEncode] = false;
+ userSettings[ASUserSettingConstants.GrowlQueue] = false;
+ userSettings[ASUserSettingConstants.ProcessPriority] = "Below Normal";
+ userSettings[ASUserSettingConstants.PreventSleep] = true;
+ userSettings[ASUserSettingConstants.ShowCLI] = false;
+ userSettings[ASUserSettingConstants.SaveLogToCopyDirectory] = false;
+ userSettings[ASUserSettingConstants.SaveLogWithVideo] = false;
+ userSettings[ASUserSettingConstants.DisableLibDvdNav] = false;
+ userSettings[ASUserSettingConstants.SendFile] = false;
+ userSettings[ASUserSettingConstants.MinScanDuration] = 10;
+ userSettings[ASUserSettingConstants.HandBrakeBuild] = 0;
+ userSettings[ASUserSettingConstants.HandBrakeVersion] = string.Empty;
userSettings["updateStatus"] = true;
userSettings["tooltipEnable"] = true;
userSettings["defaultPreset"] = string.Empty;
|