diff options
author | sr55 <[email protected]> | 2009-03-02 18:07:36 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2009-03-02 18:07:36 +0000 |
commit | 7ddfbb43e072615b19042e852079b80061fd962c (patch) | |
tree | ba4b5b59749d9f2673b108394d9c21dc62850370 /win/C# | |
parent | c6c9195fe10b6b7e09538d8f7ae76a7e4a7db598 (diff) |
WinGui:
Patch from ExDeus - Thanks.
- Show Queue button now activates the queue window on launch.
- Code clean-up for the auto naming function.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2201 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#')
-rw-r--r-- | win/C#/Functions/Main.cs | 69 | ||||
-rw-r--r-- | win/C#/frmMain.cs | 9 |
2 files changed, 37 insertions, 41 deletions
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs index af0ce7f72..13579c9ff 100644 --- a/win/C#/Functions/Main.cs +++ b/win/C#/Functions/Main.cs @@ -187,11 +187,8 @@ namespace Handbrake.Functions string AutoNamePath = string.Empty;
if (drp_dvdtitle.Text != "Automatic")
{
- // Get the Source Name - THIS NEEDS FIXED
- string[] sourceName = source.Split('\\');
- source = sourceName[sourceName.Length - 1].Replace(".iso", "").Replace(".mpg", "").Replace(".ts", "").Replace(".ps", "");
- source.Replace(".wmv", "").Replace(".mp4", "").Replace(".m4v", "").Replace(".avi", "").Replace(".ogm", "").Replace(".tivo", "").Replace(".img", "");
- source.Replace(".mov", "").Replace(".rm", "");
+ // Get the Source Name
+ string sourceName = Path.GetFileNameWithoutExtension(source);
// Get the Selected Title Number
string[] titlesplit = drp_dvdtitle.Text.Split(' ');
@@ -209,51 +206,43 @@ namespace Handbrake.Functions if (Properties.Settings.Default.autoNameFormat != "")
{
destination_filename = Properties.Settings.Default.autoNameFormat;
- destination_filename = destination_filename.Replace("{source}", source).Replace("{title}", dvdTitle).Replace("{chapters}", combinedChapterTag);
+ destination_filename = destination_filename.Replace("{source}", sourceName).Replace("{title}", dvdTitle).Replace("{chapters}", combinedChapterTag);
}
else
- destination_filename = source + "_T" + dvdTitle + "_C" + combinedChapterTag;
+ destination_filename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag;
+
+ // Add the appropriate file extension
+ if (format == 0)
+ destination_filename += ".mp4";
+ else if (format == 1)
+ destination_filename += ".m4v";
+ else if (format == 2)
+ destination_filename += ".mkv";
+ else if (format == 3)
+ destination_filename += ".avi";
+ else if (format == 4)
+ destination_filename += ".ogm";
// Now work out the path where the file will be stored.
// First case: If the destination box doesn't already contain a path, make one.
- if (!dest.Contains("\\"))
+ if (!dest.Contains(Path.DirectorySeparatorChar.ToString()))
{
- string filePath = "";
- if (Properties.Settings.Default.autoNamePath.Trim() != "")
+ // If there is an auto name path, use it...
+ if (Properties.Settings.Default.autoNamePath.Trim() != "" &&
+ Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")
{
- if (Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")
- filePath = Properties.Settings.Default.autoNamePath + "\\";
+ AutoNamePath = Path.Combine(Properties.Settings.Default.autoNamePath, destination_filename);
+ }
+ else // ...otherwise, output to the source directory
+ {
+ AutoNamePath = null;
}
-
- if (format == 0)
- AutoNamePath = filePath + destination_filename + ".mp4";
- else if (format == 1)
- AutoNamePath = filePath + destination_filename + ".m4v";
- else if (format == 2)
- AutoNamePath = filePath + destination_filename + ".mkv";
- else if (format == 3)
- AutoNamePath = filePath + destination_filename + ".avi";
- else if (format == 4)
- AutoNamePath = filePath + destination_filename + ".ogm";
}
else // Otherwise, use the path that is already there.
{
- string destination = AutoNamePath;
- string[] destName = dest.Split('\\');
- string[] extension = dest.Split('.');
- string ext = extension[extension.Length - 1];
-
- destName[destName.Length - 1] = destination_filename + "." + ext;
-
- string fullDest = "";
- foreach (string part in destName)
- {
- if (fullDest != "")
- fullDest = fullDest + "\\" + part;
- else
- fullDest = fullDest + part;
- }
- return fullDest;
+ // Use the path and change the file extension to match the previous destination
+ AutoNamePath = Path.Combine(Path.GetDirectoryName(dest), destination_filename);
+ AutoNamePath = Path.ChangeExtension(AutoNamePath, Path.GetExtension(dest));
}
}
@@ -391,4 +380,4 @@ namespace Handbrake.Functions }
}
-}
\ No newline at end of file +}
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index b1065436c..b0e61fd27 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -647,6 +647,7 @@ namespace Handbrake {
queueWindow.setQueue();
queueWindow.Show();
+ queueWindow.Activate();
}
private void tb_preview_Click(object sender, EventArgs e)
{
@@ -852,7 +853,13 @@ namespace Handbrake // Run the autoName & chapterNaming functions
if (Properties.Settings.Default.autoNaming == "Checked")
- text_destination.Text = hb_common_func.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, text_source.Text, text_destination.Text, drop_format.SelectedIndex);
+ {
+ string autoPath = hb_common_func.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, text_source.Text, text_destination.Text, drop_format.SelectedIndex);
+ if (autoPath != null)
+ text_destination.Text = autoPath;
+ else
+ MessageBox.Show("You currently have automatic file naming enabled for the destination box, but you do not have a default direcotry set. You should set this in the program options (see Tools Menu)","Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ }
data_chpt.Rows.Clear();
DataGridView chapterGridView = hb_common_func.chapterNaming(data_chpt, drop_chapterFinish.Text);
|