summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2009-04-14 22:41:45 +0000
committersr55 <[email protected]>2009-04-14 22:41:45 +0000
commita1365b1285c50c34e58172289330c089125c6f93 (patch)
tree5164c3395abac68d2293996569b233e3ad403fa3
parent7d4c044ebd62fdeac7a5665ec8fcd2548611ff51 (diff)
WinGui:
- Patch by ExDeus - http://forum.handbrake.fr/viewtopic.php?f=4&t=9642&start=25#p54267 - Few redundant code functions removed, code layout tweaks. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2328 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--win/C#/Controls/x264Panel.cs5
-rw-r--r--win/C#/Functions/Main.cs14
-rw-r--r--win/C#/Functions/PresetLoader.cs25
-rw-r--r--win/C#/frmMain.Designer.cs1
-rw-r--r--win/C#/frmMain.cs246
5 files changed, 142 insertions, 149 deletions
diff --git a/win/C#/Controls/x264Panel.cs b/win/C#/Controls/x264Panel.cs
index 6790bb743..dd1572abb 100644
--- a/win/C#/Controls/x264Panel.cs
+++ b/win/C#/Controls/x264Panel.cs
@@ -8,6 +8,11 @@ namespace Handbrake.Controls
public x264Panel()
{
InitializeComponent();
+
+ if (Properties.Settings.Default.tooltipEnable == "Checked")
+ setToolTipActive(true);
+
+ reset2Defaults();
}
public string x264Query
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs
index a7e0626b5..93b29399c 100644
--- a/win/C#/Functions/Main.cs
+++ b/win/C#/Functions/Main.cs
@@ -278,9 +278,8 @@ namespace Handbrake.Functions
/// Get's HandBrakes version data from the CLI.
/// </summary>
/// <returns>Arraylist of Version Data. 0 = hb_version 1 = hb_build</returns>
- public ArrayList getCliVersionData()
+ public void setCliVersionData()
{
- ArrayList cliVersionData = new ArrayList();
String line;
// 0 = SVN Build / Version
@@ -298,6 +297,7 @@ namespace Handbrake.Functions
try
{
cliProcess.Start();
+ cliProcess.Kill();
// Retrieve standard output and report back to parent thread until the process is complete
TextReader stdOutput = cliProcess.StandardError;
@@ -310,9 +310,9 @@ namespace Handbrake.Functions
{
string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");
string[] arr = data.Split(' ');
- cliVersionData.Add(arr[0]);
- cliVersionData.Add(arr[1]);
- return cliVersionData;
+
+ Properties.Settings.Default.hb_build = int.Parse(arr[1]);
+ Properties.Settings.Default.hb_version = arr[0];
}
if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.
killCLI();
@@ -323,10 +323,6 @@ namespace Handbrake.Functions
{
MessageBox.Show("Unable to retrieve version information from the CLI. \nError:\n" + e);
}
-
- cliVersionData.Add(0);
- cliVersionData.Add("0");
- return cliVersionData;
}
private static void killCLI()
{
diff --git a/win/C#/Functions/PresetLoader.cs b/win/C#/Functions/PresetLoader.cs
index 21bd5f974..53cc363aa 100644
--- a/win/C#/Functions/PresetLoader.cs
+++ b/win/C#/Functions/PresetLoader.cs
@@ -14,13 +14,12 @@ namespace Handbrake.Functions
/// <param name="presetQuery">The Parsed CLI Query</param>
/// <param name="name">Name of the preset</param>
/// <param name="pictureSettings">Save picture settings in the preset</param>
- public static void presetLoader(frmMain mainWindow, Functions.QueryParser presetQuery, string name, Boolean pictureSettings)
+ public static void presetLoader(frmMain mainWindow, QueryParser presetQuery, string name, Boolean pictureSettings)
{
// ---------------------------
// Setup the GUI
// ---------------------------
- // Source tab
#region source
// Reset some vaules to stock first to prevent errors.
mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;
@@ -37,7 +36,6 @@ namespace Handbrake.Functions
#endregion
- // Destination tab
#region destination
mainWindow.drp_videoEncoder.Text = presetQuery.VideoEncoder;
@@ -59,9 +57,12 @@ namespace Handbrake.Functions
mainWindow.check_optimiseMP4.CheckState = presetQuery.OptimizeMP4 ? CheckState.Checked : CheckState.Unchecked;
+ mainWindow.check_largeFile.CheckState = presetQuery.LargeMP4 ? CheckState.Checked : CheckState.Unchecked;
+
+ mainWindow.setContainerOpts(); // select the container options according to the selected format
+
#endregion
- // Picture Settings Tab
#region Picture
mainWindow.check_autoCrop.Checked = true;
if (presetQuery.CropBottom == "0" && presetQuery.CropTop == "0")
@@ -122,7 +123,6 @@ namespace Handbrake.Functions
#endregion
- // Filters Tab
#region Filters
mainWindow.ctl_decomb.setOption(presetQuery.Decomb);
@@ -147,8 +147,7 @@ namespace Handbrake.Functions
}
#endregion
- // Video Settings Tab
- #region video
+ #region Video
if (presetQuery.AverageVideoBitrate != null)
{
mainWindow.radio_avgBitrate.Checked = true;
@@ -209,16 +208,8 @@ namespace Handbrake.Functions
mainWindow.check_turbo.CheckState = presetQuery.TurboFirstPass ? CheckState.Checked : CheckState.Unchecked;
- if (presetQuery.LargeMP4)
- mainWindow.check_largeFile.CheckState = CheckState.Checked;
- else
- {
- mainWindow.check_largeFile.CheckState = CheckState.Unchecked;
- mainWindow.check_largeFile.BackColor = Color.Transparent;
- }
#endregion
- // Chapter Markers Tab
#region Chapter Markers
if (presetQuery.ChapterMarkers)
@@ -231,7 +222,6 @@ namespace Handbrake.Functions
#endregion
- // Audio Settings Tab
#region Audio
// Clear the audio listing
mainWindow.lv_audioList.Items.Clear();
@@ -295,8 +285,7 @@ namespace Handbrake.Functions
#endregion
- // H264 Tab & Preset Name
- #region other
+ #region Other
mainWindow.x264Panel.x264Query = presetQuery.H264Query;
// Set the preset name
diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs
index 31a435507..6f5afee36 100644
--- a/win/C#/frmMain.Designer.cs
+++ b/win/C#/frmMain.Designer.cs
@@ -273,7 +273,6 @@ namespace Handbrake
//
// DVD_Save
//
- this.DVD_Save.CheckFileExists = true;
this.DVD_Save.Filter = "mp4|*.mp4|m4v|*.m4v|mkv|*.mkv";
this.DVD_Save.SupportMultiDottedExtensions = true;
//
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs
index ded23908b..759a1023d 100644
--- a/win/C#/frmMain.cs
+++ b/win/C#/frmMain.cs
@@ -14,31 +14,34 @@ using System.Diagnostics;
using System.Threading;
using Handbrake.Functions;
using Handbrake.Presets;
+using Handbrake.Queue;
+using Handbrake.Parsing;
namespace Handbrake
{
public partial class frmMain : Form
{
// Objects which may be used by one or more other objects
- private delegate void UpdateWindowHandler();
Main hb_common_func = new Main();
Encode encodeHandler = new Encode();
- Queue.QueueHandler encodeQueue = new Queue.QueueHandler();
+ QueueHandler encodeQueue = new QueueHandler();
PresetsHandler presetHandler = new PresetsHandler();
- Parsing.Title selectedTitle;
- Parsing.DVD thisDVD;
-
- // Objects belonging to this window only
QueryGenerator queryGen = new QueryGenerator();
// Globals: Mainly used for tracking.
+ Title selectedTitle;
+ DVD thisDVD;
+ Process hbproc;
private frmQueue queueWindow;
private frmPreview qtpreview;
+ private Form splash;
private string lastAction;
public int maxWidth;
public int maxHeight;
- Process hbproc;
- private Form splash;
+
+ // Delegates
+ private delegate void UpdateWindowHandler();
+ private delegate void updateStatusChanger();
// Applicaiton Startup ************************************************
@@ -46,28 +49,25 @@ namespace Handbrake
public frmMain()
{
- // Load the splash screen in this thread
+ // Load and setup the splash screen in this thread
splash = new frmSplashScreen();
splash.Show();
-
- //Create a label that can be updated from the parent thread.
Label lblStatus = new Label { Size = new Size(250, 20), Location = new Point(10, 280) };
splash.Controls.Add(lblStatus);
+
InitializeComponent();
// Update the users config file with the CLI version data.
lblStatus.Text = "Setting Version Data ...";
Application.DoEvents();
- ArrayList x = hb_common_func.getCliVersionData();
- Properties.Settings.Default.hb_build = int.Parse(x[1].ToString());
- Properties.Settings.Default.hb_version = x[0].ToString();
+ hb_common_func.setCliVersionData();
- // show the form, but leave disabled until preloading is complete then show the main form
+ // Show the form, but leave disabled until preloading is complete then show the main form
this.Enabled = false;
this.Show();
Application.DoEvents(); // Forces frmMain to draw
- // update the status
+ // Check for new versions, if update checking is enabled
if (Properties.Settings.Default.updateStatus == "Checked")
{
lblStatus.Text = "Checking for updates ...";
@@ -80,7 +80,6 @@ namespace Handbrake
// Setup the GUI components
lblStatus.Text = "Setting up the GUI ...";
Application.DoEvents();
- x264Panel.reset2Defaults(); // Initialize all the x264 widgets to their default values
loadPresetPanel(); // Load the Preset Panel
treeView_presets.ExpandAll();
lbl_encode.Text = "";
@@ -92,7 +91,6 @@ namespace Handbrake
// Load the user's default settings or Normal Preset
if (Properties.Settings.Default.defaultSettings == "Checked" && Properties.Settings.Default.defaultPreset != "")
{
- // Ok, so, we've selected a preset. Now we want to load it.
if (presetHandler.getPreset(Properties.Settings.Default.defaultPreset) != null)
{
string query = presetHandler.getPreset(Properties.Settings.Default.defaultPreset).Query;
@@ -120,10 +118,7 @@ namespace Handbrake
// Enabled GUI tooltip's if Required
if (Properties.Settings.Default.tooltipEnable == "Checked")
- {
- x264Panel.setToolTipActive(true);
ToolTip.Active = true;
- }
//Finished Loading
lblStatus.Text = "Loading Complete!";
@@ -139,8 +134,7 @@ namespace Handbrake
queueRecovery();
}
- // Startup Functions
- private delegate void updateStatusChanger();
+ // Startup Functions
private void startupUpdateCheck()
{
try
@@ -226,7 +220,7 @@ namespace Handbrake
}
private void encodeStarted(object sender, EventArgs e)
{
- setLastAction("encode");
+ lastAction = "encode";
setEncodeStarted();
}
private void encodeEnded(object sender, EventArgs e)
@@ -978,8 +972,10 @@ namespace Handbrake
{
// This removes the file extension from the filename box on the save file dialog.
// It's daft but some users don't realise that typing an extension overrides the dropdown extension selected.
- if (Path.HasExtension(text_destination.Text))
- DVD_Save.FileName = Path.Combine(Path.GetDirectoryName(text_destination.Text), Path.GetFileNameWithoutExtension(text_destination.Text));
+ DVD_Save.FileName = Path.GetFileNameWithoutExtension(text_destination.Text);
+
+ if (Path.IsPathRooted(text_destination.Text))
+ DVD_Save.InitialDirectory = Path.GetDirectoryName(text_destination.Text);
// Show the dialog and set the main form file path
if (drop_format.SelectedIndex.Equals(0))
@@ -994,13 +990,31 @@ namespace Handbrake
if (DVD_Save.FileName.StartsWith("\\"))
MessageBox.Show("Sorry, HandBrake does not support UNC file paths. \nTry mounting the share as a network drive in My Computer", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
else
- {
- setAudioByContainer(DVD_Save.FileName);
+ {
+ // Add a file extension manually, as FileDialog.AddExtension has issues with dots in filenames
+ switch (DVD_Save.FilterIndex)
+ {
+ case 1:
+ if (!Path.GetExtension(DVD_Save.FileName).Equals(".mp4", StringComparison.InvariantCultureIgnoreCase))
+ DVD_Save.FileName += ".mp4";
+ break;
+ case 2:
+ if (!Path.GetExtension(DVD_Save.FileName).Equals(".m4v", StringComparison.InvariantCultureIgnoreCase))
+ DVD_Save.FileName += ".m4v";
+ break;
+ case 3:
+ if (!Path.GetExtension(DVD_Save.FileName).Equals(".mkv", StringComparison.InvariantCultureIgnoreCase))
+ DVD_Save.FileName += ".mkv";
+ break;
+ default:
+ //do nothing
+ break;
+ }
text_destination.Text = DVD_Save.FileName;
// Quicktime requires .m4v file for chapter markers to work. If checked, change the extension to .m4v (mp4 and m4v are the same thing)
if (Check_ChapterMarkers.Checked)
- text_destination.Text = text_destination.Text.Replace(".mp4", ".m4v");
+ drop_format.SelectedIndex = 1;
}
}
}
@@ -1038,21 +1052,7 @@ namespace Handbrake
//Video Tab
private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)
{
- if ((text_destination.Text.Contains(".mp4")) || (text_destination.Text.Contains(".m4v")))
- {
- check_largeFile.Enabled = true;
- check_optimiseMP4.Enabled = true;
- check_iPodAtom.Enabled = true;
- }
- else
- {
- check_largeFile.Enabled = false;
- check_optimiseMP4.Enabled = false;
- check_iPodAtom.Enabled = false;
- check_largeFile.Checked = false;
- check_optimiseMP4.Checked = false;
- check_iPodAtom.Checked = false;
- }
+ setContainerOpts();
//Turn off some options which are H.264 only when the user selects a non h.264 encoder
if (drp_videoEncoder.Text.Contains("H.264"))
@@ -1061,7 +1061,7 @@ namespace Handbrake
check_turbo.Enabled = true;
h264Tab.Enabled = true;
- if ((text_destination.Text.Contains(".mp4")) || (text_destination.Text.Contains(".m4v")))
+ if ((drop_format.Text.Contains("MP4")) || (drop_format.Text.Contains("M4V")))
check_iPodAtom.Enabled = true;
else
check_iPodAtom.Enabled = false;
@@ -1121,6 +1121,28 @@ namespace Handbrake
break;
}
}
+
+ /// <summary>
+ /// Set the container format options
+ /// </summary>
+ public void setContainerOpts()
+ {
+ if ((text_destination.Text.Contains(".mp4")) || (text_destination.Text.Contains(".m4v")))
+ {
+ check_largeFile.Enabled = true;
+ check_optimiseMP4.Enabled = true;
+ check_iPodAtom.Enabled = true;
+ }
+ else
+ {
+ check_largeFile.Enabled = false;
+ check_optimiseMP4.Enabled = false;
+ check_iPodAtom.Enabled = false;
+ check_largeFile.Checked = false;
+ check_optimiseMP4.Checked = false;
+ check_iPodAtom.Checked = false;
+ }
+ }
private void slider_videoQuality_Scroll(object sender, EventArgs e)
{
switch (drp_videoEncoder.Text)
@@ -1728,6 +1750,64 @@ namespace Handbrake
}
#endregion
+ #region GUI
+ /// <summary>
+ /// Set the GUI to it's finished encoding state.
+ /// </summary>
+ private void setEncodeFinished()
+ {
+ try
+ {
+ if (InvokeRequired)
+ {
+ BeginInvoke(new UpdateWindowHandler(setEncodeFinished));
+ return;
+ }
+
+ lbl_encode.Text = "Encoding Finished";
+ btn_start.Text = "Start";
+ btn_start.ToolTipText = "Start the encoding process";
+ btn_start.Image = Properties.Resources.Play;
+
+ // If the window is minimized, display the notification in a popup.
+ if (FormWindowState.Minimized == this.WindowState)
+ {
+ notifyIcon.BalloonTipText = lbl_encode.Text;
+ notifyIcon.ShowBalloonTip(500);
+ }
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show(exc.ToString());
+ }
+ }
+
+ /// <summary>
+ /// Set the GUI to it's started encoding state.
+ /// </summary>
+ private void setEncodeStarted()
+ {
+ try
+ {
+ if (InvokeRequired)
+ {
+ BeginInvoke(new UpdateWindowHandler(setEncodeStarted));
+ return;
+ }
+
+ lbl_encode.Visible = true;
+ lbl_encode.Text = "Encoding in Progress";
+ btn_start.Text = "Stop";
+ btn_start.ToolTipText = "Stop the encoding process. \nWarning: This may break your file. Press ctrl-c in the CLI window if you wish it to exit cleanly.";
+ btn_start.Image = Properties.Resources.stop;
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show(exc.ToString());
+ }
+ }
+ #endregion
+
#region DVD Drive Detection
// Source Button Drive Detection
private delegate void ProgressUpdateHandler();
@@ -1895,81 +1975,6 @@ namespace Handbrake
#endregion
#region Public Methods
-
- /// <summary>
- /// Setup the GUI for Encoding or finished Encoding.
- /// 1 = Encode Running
- /// 0 = Encode Finished.
- /// </summary>
- public void setEncodeFinished()
- {
- try
- {
- if (InvokeRequired)
- {
- BeginInvoke(new UpdateWindowHandler(setEncodeFinished));
- return;
- }
-
- lbl_encode.Text = "Encoding Finished";
- btn_start.Text = "Start";
- btn_start.ToolTipText = "Start the encoding process";
- btn_start.Image = Properties.Resources.Play;
-
- // If the window is minimized, display the notification in a popup.
- if (FormWindowState.Minimized == this.WindowState)
- {
- notifyIcon.BalloonTipText = lbl_encode.Text;
- notifyIcon.ShowBalloonTip(500);
- }
- }
- catch (Exception exc)
- {
- MessageBox.Show(exc.ToString());
- }
- }
- public void setEncodeStarted()
- {
- try
- {
- if (InvokeRequired)
- {
- BeginInvoke(new UpdateWindowHandler(setEncodeStarted));
- return;
- }
-
- lbl_encode.Visible = true;
- lbl_encode.Text = "Encoding in Progress";
- btn_start.Text = "Stop";
- btn_start.ToolTipText = "Stop the encoding process. \nWarning: This may break your file. Press ctrl-c in the CLI window if you wish it to exit cleanly.";
- btn_start.Image = Properties.Resources.stop;
- }
- catch (Exception exc)
- {
- MessageBox.Show(exc.ToString());
- }
- }
-
- /// <summary>
- /// Action can be "encode" or "scan"
- /// Set the last action varible in the main window.
- /// This is used to control which log file is displayed when the Activity window is displayed.
- /// </summary>
- /// <param name="last">String</param>
- public void setLastAction(string last)
- {
- this.lastAction = last;
- }
-
- /// <summary>
- /// DVD parseing. Pass in a parsed DVD.
- /// </summary>
- /// <param name="dvd"></param>
- public void setStreamReader(Parsing.DVD dvd)
- {
- this.thisDVD = dvd;
- }
-
/// <summary>
/// Reload the preset panel display
/// </summary>
@@ -2058,7 +2063,6 @@ namespace Handbrake
treeView_presets.Nodes.Add(preset_treeview);
}
}
-
#endregion
#region overrides