summaryrefslogtreecommitdiffstats
path: root/win/C#/Functions
diff options
context:
space:
mode:
Diffstat (limited to 'win/C#/Functions')
-rw-r--r--win/C#/Functions/Main.cs77
-rw-r--r--win/C#/Functions/PresetLoader.cs4
-rw-r--r--win/C#/Functions/QueryGenerator.cs76
-rw-r--r--win/C#/Functions/QueryParser.cs4
4 files changed, 73 insertions, 88 deletions
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs
index be46465d4..84ba26398 100644
--- a/win/C#/Functions/Main.cs
+++ b/win/C#/Functions/Main.cs
@@ -54,62 +54,6 @@ namespace Handbrake.Functions
}
/// <summary>
- /// Calculate the non-anamorphic resoltuion of the source
- /// </summary>
- /// <param name="width"></param>
- /// <param name="top"></param>
- /// <param name="bottom"></param>
- /// <param name="left"></param>
- /// <param name="right"></param>
- /// <param name="selectedTitle"></param>
- /// <returns></returns>
- public static int cacluateNonAnamorphicHeight(int width, decimal top, decimal bottom, decimal left, decimal right, Parsing.Title selectedTitle)
- {
- float aspect = selectedTitle.AspectRatio;
- int aw = 0;
- int ah = 0;
- if (aspect.ToString() == "1.78")
- {
- aw = 16;
- ah = 9;
- }
- else if (aspect.ToString() == "1.33")
- {
- aw = 4;
- ah = 3;
- }
-
- if (aw != 0)
- {
- double a = width * selectedTitle.Resolution.Width * ah * (selectedTitle.Resolution.Height - (double)top - (double)bottom);
- double b = selectedTitle.Resolution.Height * aw * (selectedTitle.Resolution.Width - (double)left - (double)right);
-
- double y = a / b;
-
- // If it's not Mod 16, make it mod 16
- if ((y % 16) != 0)
- {
- double mod16 = y % 16;
- if (mod16 >= 8)
- {
- mod16 = 16 - mod16;
- y = y + mod16;
- }
- else
- {
- y = y - mod16;
- }
- }
-
- //16 * (421 / 16)
- //double z = ( 16 * (( y + 8 ) / 16 ) );
- int x = int.Parse(y.ToString());
- return x;
- }
- return 0;
- }
-
- /// <summary>
/// Select the longest title in the DVD title dropdown menu on frmMain
/// </summary>
public static Parsing.Title selectLongestTitle(ComboBox drp_dvdtitle)
@@ -315,8 +259,7 @@ namespace Handbrake.Functions
Properties.Settings.Default.hb_version = arr[0];
}
if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.
- killCLI();
-
+ killCLI(cliProcess.Id);
}
}
catch (Exception e)
@@ -328,21 +271,11 @@ namespace Handbrake.Functions
/// <summary>
/// Search through the running processes on the system and kill HandBrakeCLI
/// </summary>
- private static void killCLI()
+ private static void killCLI(int id)
{
- string AppName = "HandBrakeCLI";
- AppName = AppName.ToUpper();
-
- Process[] prs = Process.GetProcesses();
- foreach (Process proces in prs)
- {
- if (proces.ProcessName.ToUpper() == AppName)
- {
- proces.Refresh();
- if (!proces.HasExited)
- proces.Kill();
- }
- }
+ Process cli = Process.GetProcessById(id);
+ if (!cli.HasExited)
+ cli.Kill();
}
/// <summary>
diff --git a/win/C#/Functions/PresetLoader.cs b/win/C#/Functions/PresetLoader.cs
index 44f9016ee..15eb741a8 100644
--- a/win/C#/Functions/PresetLoader.cs
+++ b/win/C#/Functions/PresetLoader.cs
@@ -246,7 +246,7 @@ namespace Handbrake.Functions
mainWindow.audioPanel.addTrackForPreset(newTrack);
}
- // Subtitle Stuff
+ /*/ Subtitle Stuff
mainWindow.drp_subtitle.Text = presetQuery.Subtitles;
if (presetQuery.ForcedSubtitles)
@@ -255,7 +255,7 @@ namespace Handbrake.Functions
mainWindow.check_forced.Enabled = true;
}
else
- mainWindow.check_forced.CheckState = CheckState.Unchecked;
+ mainWindow.check_forced.CheckState = CheckState.Unchecked;*/
#endregion
diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs
index c90d7dbb0..2f6e474fa 100644
--- a/win/C#/Functions/QueryGenerator.cs
+++ b/win/C#/Functions/QueryGenerator.cs
@@ -391,18 +391,74 @@ namespace Handbrake.Functions
if (audioItems.Trim() != String.Empty)
query += " -D " + audioItems;
- // Subtitles
- string subtitles = mainWindow.drp_subtitle.Text;
- if (subtitles == "Autoselect")
- query += " -U ";
- else if (subtitles != "" && subtitles != "None")
+ #endregion
+
+ #region Subtitles Tab
+
+ if (mainWindow.Subtitles.lv_subList.Items.Count != 0) // If we have subtitle tracks
{
- string[] tempSub = subtitles.Split(' ');
- query += " -s " + tempSub[0];
- }
+ // Find --subtitle <string>
+ query += " --subtitle ";
+ String subtitleTracks = "";
+ String itemToAdd;
+ foreach (ListViewItem item in mainWindow.Subtitles.lv_subList.Items)
+ {
+ if (item.SubItems[1].Text.Contains("Foreign Audio Search"))
+ itemToAdd = "scan";
+ else
+ {
+ string[] tempSub = item.SubItems[1].Text.Split(' ');
+ itemToAdd = tempSub[0];
+ }
+
+ subtitleTracks += subtitleTracks == "" ? itemToAdd : "," + itemToAdd;
+ }
+ query += subtitleTracks;
+
+
+ // Find --subtitle-forced
+ String forcedTrack = "";
+ foreach (ListViewItem item in mainWindow.Subtitles.lv_subList.Items)
+ {
+ itemToAdd = "";
+ string[] tempSub = item.SubItems[1].Text.Split(' ');
+ string trackID = tempSub[0];
+
+ if (item.SubItems[2].Text == "Yes")
+ itemToAdd = trackID;
- if (mainWindow.check_forced.Checked)
- query += " -F ";
+ if (itemToAdd != "")
+ forcedTrack += forcedTrack == "" ? itemToAdd : "," + itemToAdd;
+ }
+ if (forcedTrack != "")
+ query += " --subtitle-forced " + forcedTrack;
+
+
+ // Find --subtitle-burn and --subtitle-default
+ String burned = "";
+ String defaultTrack = "";
+ foreach (ListViewItem item in mainWindow.Subtitles.lv_subList.Items)
+ {
+ string[] tempSub = item.SubItems[1].Text.Split(' ');
+ string trackID = tempSub[0];
+
+ if (trackID.Trim() == "Foreign")
+ trackID = "scan";
+
+ if (item.SubItems[3].Text == "Yes") // Burned
+ burned = trackID;
+
+ if (item.SubItems[4].Text == "Yes") // Burned
+ defaultTrack = trackID;
+
+ }
+ if (burned != "")
+ query += " --subtitle-burn " + burned;
+
+ if (defaultTrack != "")
+ query += " --subtitle-default " + defaultTrack;
+
+ }
#endregion
diff --git a/win/C#/Functions/QueryParser.cs b/win/C#/Functions/QueryParser.cs
index 659073adf..5c1576cd4 100644
--- a/win/C#/Functions/QueryParser.cs
+++ b/win/C#/Functions/QueryParser.cs
@@ -97,10 +97,6 @@ namespace Handbrake.Functions
#region Regular Expressions
- // Useful Destination Finder
- //Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9?';!^%&*()_\-:\\\s\.]+)(?:\"")");
- //Match source = r1.Match(input.Replace('"', '\"'));
-
//Source
Match title = Regex.Match(input, @"-t ([0-9]*)");
Match chapters = Regex.Match(input, @"-c ([0-9-]*)");