public int cacluateNonAnamorphicHeight(int width, decimal top, decimal bottom, decimal left, decimal right, Parsing.Title selectedTitle)\r
{\r
float aspect = selectedTitle.AspectRatio;\r
- int aw;\r
- int ah;\r
+ int aw = 0;\r
+ int ah = 0;\r
if (aspect.ToString() == "1.78")\r
{\r
aw = 16;\r
ah = 9;\r
}\r
- else\r
+ else if (aspect.ToString() == "1.33")\r
{\r
aw = 4;\r
ah = 3;\r
}\r
\r
- double a = width * selectedTitle.Resolution.Width * ah * (selectedTitle.Resolution.Height - (double)top - (double)bottom);\r
- double b = selectedTitle.Resolution.Height * aw * (selectedTitle.Resolution.Width - (double)left - (double)right);\r
+ if (aw != 0)\r
+ {\r
+ double a = width * selectedTitle.Resolution.Width * ah * (selectedTitle.Resolution.Height - (double)top - (double)bottom);\r
+ double b = selectedTitle.Resolution.Height * aw * (selectedTitle.Resolution.Width - (double)left - (double)right);\r
\r
- double y = a / b;\r
+ double y = a / b;\r
\r
- // If it's not Mod 16, make it mod 16\r
- if ((y % 16) != 0)\r
- {\r
- double mod16 = y % 16;\r
- if (mod16 >= 8)\r
- {\r
- mod16 = 16 - mod16;\r
- y = y + mod16;\r
- }\r
- else\r
+ // If it's not Mod 16, make it mod 16\r
+ if ((y % 16) != 0)\r
{\r
- y = y - mod16;\r
+ double mod16 = y % 16;\r
+ if (mod16 >= 8)\r
+ {\r
+ mod16 = 16 - mod16;\r
+ y = y + mod16;\r
+ }\r
+ else\r
+ {\r
+ y = y - mod16;\r
+ }\r
}\r
- }\r
\r
- //16 * (421 / 16)\r
- //double z = ( 16 * (( y + 8 ) / 16 ) );\r
- int x = int.Parse(y.ToString());\r
- return x;\r
+ //16 * (421 / 16)\r
+ //double z = ( 16 * (( y + 8 ) / 16 ) );\r
+ int x = int.Parse(y.ToString());\r
+ return x;\r
+ }\r
+ return 0;\r
}\r
\r
/// <summary>\r
/// <param name="mainWindow"></param>\r
public DataGridView chapterNaming(DataGridView data_chpt, string chapter_start, string chapter_end)\r
{\r
- try\r
- {\r
- int i = 0;\r
- int rowCount = 0;\r
- int start = 0;\r
- int finish = 0;\r
- if (chapter_end != "Auto")\r
- finish = int.Parse(chapter_end);\r
+ int i = 0, rowCount = 0, start = 0, finish = 0;\r
\r
- if (chapter_start != "Auto")\r
- start = int.Parse(chapter_start);\r
+ if (chapter_end != "Auto")\r
+ int.TryParse(chapter_end, out finish);\r
\r
- rowCount = finish - (start - 1);\r
+ if (chapter_start != "Auto")\r
+ int.TryParse(chapter_start, out start);\r
\r
- while (i < rowCount)\r
- {\r
- DataGridViewRow row = new DataGridViewRow();\r
+ rowCount = finish - (start - 1);\r
\r
- data_chpt.Rows.Insert(i, row);\r
- data_chpt.Rows[i].Cells[0].Value = (i + 1);\r
- data_chpt.Rows[i].Cells[1].Value = "Chapter " + (i + 1);\r
- i++;\r
- }\r
- return data_chpt;\r
- }\r
- catch (Exception exc)\r
+ while (i < rowCount)\r
{\r
- MessageBox.Show("chapterNaming() Error has occured: \n" + exc.ToString());\r
- return null;\r
+ DataGridViewRow row = new DataGridViewRow();\r
+\r
+ data_chpt.Rows.Insert(i, row);\r
+ data_chpt.Rows[i].Cells[0].Value = (i + 1);\r
+ data_chpt.Rows[i].Cells[1].Value = "Chapter " + (i + 1);\r
+ i++;\r
}\r
+ return data_chpt;\r
}\r
\r
/// <summary>\r
/// <param name="mainWindow"></param>\r
public string autoName(ComboBox drp_dvdtitle, string chapter_start, string chatper_end, string source, string dest, int format)\r
{\r
-\r
string AutoNamePath = string.Empty;\r
-\r
if (drp_dvdtitle.Text != "Automatic")\r
{\r
- // Todo: This code is a tad messy. Clean it up at some point.\r
- // Get the Source Name\r
+ // Get the Source Name - THIS NEEDS FIXED\r
string[] sourceName = source.Split('\\');\r
source = sourceName[sourceName.Length - 1].Replace(".iso", "").Replace(".mpg", "").Replace(".ts", "").Replace(".ps", "");\r
+ source.Replace(".wmv", "").Replace(".mp4", "").Replace(".m4v", "").Replace(".avi", "").Replace(".ogm", "").Replace(".tivo", "").Replace(".img", "");\r
+ source.Replace(".mov", "").Replace(".rm", "");\r
\r
// Get the Selected Title Number\r
- string title = drp_dvdtitle.Text;\r
- string[] titlesplit = title.Split(' ');\r
- title = titlesplit[0];\r
+ string[] titlesplit = drp_dvdtitle.Text.Split(' ');\r
+ string dvdTitle = titlesplit[0].Replace("Automatic", "");\r
\r
// Get the Chapter Start and Chapter End Numbers\r
- string cs = chapter_start;\r
- string cf = chatper_end;\r
-\r
- // Just incase the above are set to their default Automatic values, set the varible to ""\r
- if (title == "Automatic")\r
- title = "";\r
- if (cs == "Auto")\r
- cs = "";\r
- if (cf == "Auto")\r
- cf = "";\r
-\r
- // If both CS and CF are populated, set the dash varible\r
- string dash = "";\r
- if (cf != "Auto")\r
- dash = "-";\r
+ string chapterStart = chapter_start.Replace("Auto", "");\r
+ string chapterFinish = chatper_end.Replace("Auto", "");\r
+ string combinedChapterTag = chapterStart;\r
+ if (chapterFinish != chapterStart && chapterFinish != "")\r
+ combinedChapterTag = chapterStart + "-" + chapterFinish;\r
\r
// Get the destination filename.\r
string destination_filename = "";\r
if (Properties.Settings.Default.autoNameFormat != "")\r
{\r
destination_filename = Properties.Settings.Default.autoNameFormat;\r
- destination_filename = destination_filename.Replace("{source}", source).Replace("{title}", title).Replace("{chapters}", cs + dash + cf);\r
+ destination_filename = destination_filename.Replace("{source}", source).Replace("{title}", dvdTitle).Replace("{chapters}", combinedChapterTag);\r
}\r
else\r
- destination_filename = source + "_T" + title + "_C" + cs + dash + cf;\r
+ destination_filename = source + "_T" + dvdTitle + "_C" + combinedChapterTag;\r
\r
- // If the text box is blank\r
+ // Now work out the path where the file will be stored.\r
+ // First case: If the destination box doesn't already contain a path, make one.\r
if (!dest.Contains("\\"))\r
{\r
string filePath = "";\r
else if (format == 4)\r
AutoNamePath = filePath + destination_filename + ".ogm";\r
}\r
- else // If the text box already has a path and file\r
+ else // Otherwise, use the path that is already there.\r
{\r
string destination = AutoNamePath;\r
string[] destName = dest.Split('\\');\r
return fullDest;\r
}\r
}\r
+\r
return AutoNamePath;\r
}\r
\r
{\r
MessageBox.Show("Unable to retrieve version information from the CLI. \nError:\n" + e);\r
}\r
- \r
+\r
cliVersionData.Add(0);\r
cliVersionData.Add("0");\r
return cliVersionData;\r