diff options
Diffstat (limited to 'win')
-rw-r--r-- | win/C#/Functions/Main.cs | 44 | ||||
-rw-r--r-- | win/C#/Functions/SystemInfo.cs | 57 | ||||
-rw-r--r-- | win/C#/HandBrakeCS.csproj | 1 | ||||
-rw-r--r-- | win/C#/Program.cs | 16 | ||||
-rw-r--r-- | win/C#/frmActivityWindow.Designer.cs | 40 | ||||
-rw-r--r-- | win/C#/frmActivityWindow.cs | 74 | ||||
-rw-r--r-- | win/C#/frmMain.Designer.cs | 1 | ||||
-rw-r--r-- | win/C#/frmMain.cs | 536 | ||||
-rw-r--r-- | win/C#/frmMain/x264Panel.cs | 1 |
9 files changed, 357 insertions, 413 deletions
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs index 0a202b15d..4018ea896 100644 --- a/win/C#/Functions/Main.cs +++ b/win/C#/Functions/Main.cs @@ -323,9 +323,10 @@ namespace Handbrake.Functions public ArrayList getCliVersionData()
{
ArrayList cliVersionData = new ArrayList();
+ String line;
+
// 0 = SVN Build / Version
// 1 = Build Date
-
Process cliProcess = new Process();
ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u");
handBrakeCLI.UseShellExecute = false;
@@ -333,28 +334,37 @@ namespace Handbrake.Functions handBrakeCLI.RedirectStandardOutput = true;
handBrakeCLI.CreateNoWindow = true;
cliProcess.StartInfo = handBrakeCLI;
- cliProcess.Start();
- // Retrieve standard output and report back to parent thread until the process is complete
- String line;
- TextReader stdOutput = cliProcess.StandardError;
-
- while (!cliProcess.HasExited)
+ try
{
- line = stdOutput.ReadLine();
- if (line == null) line = "";
- Match m = Regex.Match(line, @"HandBrake ([0-9\.]*)*(svn[0-9]*[M]*)* \([0-9]*\)");
+ cliProcess.Start();
+ // Retrieve standard output and report back to parent thread until the process is complete
+ TextReader stdOutput = cliProcess.StandardError;
- if (m.Success != false)
+ while (!cliProcess.HasExited)
{
- string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");
- string[] arr = data.Split(' ');
- cliVersionData.Add(arr[0]);
- cliVersionData.Add(arr[1]);
- return cliVersionData;
+ line = stdOutput.ReadLine();
+ if (line == null) line = "";
+ Match m = Regex.Match(line, @"HandBrake ([0-9\.]*)*(svn[0-9]*[M]*)* \([0-9]*\)");
+
+ if (m.Success != false)
+ {
+ string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");
+ string[] arr = data.Split(' ');
+ cliVersionData.Add(arr[0]);
+ cliVersionData.Add(arr[1]);
+ return cliVersionData;
+ }
}
}
- return null;
+ catch (Exception e)
+ {
+ MessageBox.Show("Unable to retrieve version information from the CLI. \nError:\n" + e);
+ }
+
+ cliVersionData.Add(0);
+ cliVersionData.Add("0");
+ return cliVersionData;
}
/// <summary>
diff --git a/win/C#/Functions/SystemInfo.cs b/win/C#/Functions/SystemInfo.cs deleted file mode 100644 index 535bda6d3..000000000 --- a/win/C#/Functions/SystemInfo.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System;
-using System.Runtime.InteropServices;
-using Microsoft.Win32;
-
-namespace Handbrake.Functions
-{
- class SystemInfo
- {
- #region CheckRam
- private struct MEMORYSTATUS
- {
- public UInt32 dwLength;
- public UInt32 dwMemoryLoad;
- public UInt32 dwTotalPhys; // Used
- public UInt32 dwAvailPhys;
- public UInt32 dwTotalPageFile;
- public UInt32 dwAvailPageFile;
- public UInt32 dwTotalVirtual;
- public UInt32 dwAvailVirtual;
- }
-
- [DllImport("kernel32.dll")]
- private static extern void GlobalMemoryStatus
- (
- ref MEMORYSTATUS lpBuffer
- );
-
-
- /// <summary>
- /// Returns the total physical ram in a system
- /// </summary>
- /// <returns></returns>
- public uint TotalPhysicalMemory()
- {
- MEMORYSTATUS memStatus = new MEMORYSTATUS();
- GlobalMemoryStatus(ref memStatus);
-
- uint MemoryInfo = memStatus.dwTotalPhys;
- MemoryInfo = MemoryInfo / 1024 / 1024;
-
- return MemoryInfo;
- }
- #endregion
-
- public Object getCpuCount()
- {
- RegistryKey RegKey = Registry.LocalMachine;
- RegKey = RegKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
- return RegKey.GetValue("ProcessorNameString");
- }
-
- public System.Windows.Forms.Screen screenBounds()
- {
- return System.Windows.Forms.Screen.PrimaryScreen;
- }
- }
-}
diff --git a/win/C#/HandBrakeCS.csproj b/win/C#/HandBrakeCS.csproj index 64d5d69ec..c24034177 100644 --- a/win/C#/HandBrakeCS.csproj +++ b/win/C#/HandBrakeCS.csproj @@ -150,7 +150,6 @@ </Compile>
<Compile Include="frmMain\PresetLoader.cs" />
<Compile Include="frmMain\QueryGenerator.cs" />
- <Compile Include="Functions\SystemInfo.cs" />
<Compile Include="Functions\Main.cs" />
<Compile Include="Presets\preset.cs" />
<Compile Include="Presets\PresetsHandler.cs" />
diff --git a/win/C#/Program.cs b/win/C#/Program.cs index ae9edec6f..6f71b80f0 100644 --- a/win/C#/Program.cs +++ b/win/C#/Program.cs @@ -30,10 +30,6 @@ namespace Handbrake [STAThread]
static void Main()
{
- // Development Code Expiry.
- // Remember to comment out on public release!!!
- //if (DateTime.Now > DateTime.Parse("2008/02/25", new CultureInfo("en-US"))) { MessageBox.Show("Sorry, This development build of Handbrake has expired."); return; }
-
// Check the system meets the system requirements.
Boolean launch = true;
try
@@ -45,16 +41,6 @@ namespace Handbrake MessageBox.Show("Your system does not meet the minimum requirements for HandBrake. \n" + "Your screen is running at: " + scr.Bounds.Width.ToString() + "x" + scr.Bounds.Height.ToString() + " \nScreen resolution is too Low. Must be 1024x720 or greater", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
launch = false;
}
-
- // Make sure the system has enough RAM. 384MB or greater
- Functions.SystemInfo info = new Functions.SystemInfo();
- uint memory = info.TotalPhysicalMemory();
-
- if (memory < 256)
- {
- MessageBox.Show("Your system does not meet the minimum requirements for HandBrake. \n Insufficient RAM. 384MB or greater required. You have: " + memory.ToString() + "MB", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- launch = false;
- }
}
catch (Exception exc)
{
@@ -69,9 +55,7 @@ namespace Handbrake Application.Run(new frmMain());
}
else
- {
Application.Exit();
- }
}
}
diff --git a/win/C#/frmActivityWindow.Designer.cs b/win/C#/frmActivityWindow.Designer.cs index 837bf372f..a57603e50 100644 --- a/win/C#/frmActivityWindow.Designer.cs +++ b/win/C#/frmActivityWindow.Designer.cs @@ -37,6 +37,8 @@ namespace Handbrake this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmActivityWindow));
this.rtf_actLog = new System.Windows.Forms.RichTextBox();
+ this.rightClickMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
+ this.mnu_copy_log = new System.Windows.Forms.ToolStripMenuItem();
this.ToolTip = new System.Windows.Forms.ToolTip(this.components);
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripDropDownButton1 = new System.Windows.Forms.ToolStripDropDownButton();
@@ -47,11 +49,9 @@ namespace Handbrake this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.lbl_slb = new System.Windows.Forms.ToolStripStatusLabel();
this.txt_log = new System.Windows.Forms.ToolStripStatusLabel();
- this.rightClickMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
- this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.rightClickMenu.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.statusStrip1.SuspendLayout();
- this.rightClickMenu.SuspendLayout();
this.SuspendLayout();
//
// rtf_actLog
@@ -67,6 +67,21 @@ namespace Handbrake this.rtf_actLog.TabIndex = 29;
this.rtf_actLog.Text = "";
//
+ // rightClickMenu
+ //
+ this.rightClickMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.mnu_copy_log});
+ this.rightClickMenu.Name = "rightClickMenu";
+ this.rightClickMenu.Size = new System.Drawing.Size(153, 48);
+ //
+ // mnu_copy_log
+ //
+ this.mnu_copy_log.Image = global::Handbrake.Properties.Resources.copy;
+ this.mnu_copy_log.Name = "mnu_copy_log";
+ this.mnu_copy_log.Size = new System.Drawing.Size(152, 22);
+ this.mnu_copy_log.Text = "Copy";
+ this.mnu_copy_log.Click += new System.EventHandler(this.mnu_copy_log_Click);
+ //
// ToolTip
//
this.ToolTip.Active = false;
@@ -156,21 +171,6 @@ namespace Handbrake this.txt_log.Size = new System.Drawing.Size(85, 17);
this.txt_log.Text = "{selected log}";
//
- // rightClickMenu
- //
- this.rightClickMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.copyToolStripMenuItem});
- this.rightClickMenu.Name = "rightClickMenu";
- this.rightClickMenu.Size = new System.Drawing.Size(153, 48);
- //
- // copyToolStripMenuItem
- //
- this.copyToolStripMenuItem.Image = global::Handbrake.Properties.Resources.copy;
- this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
- this.copyToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
- this.copyToolStripMenuItem.Text = "Copy";
- this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click);
- //
// frmActivityWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 13F);
@@ -189,11 +189,11 @@ namespace Handbrake this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Activity Window";
+ this.rightClickMenu.ResumeLayout(false);
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
- this.rightClickMenu.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -213,6 +213,6 @@ namespace Handbrake private System.Windows.Forms.ToolStripButton btn_copy;
private System.Windows.Forms.ToolStripStatusLabel lbl_slb;
private System.Windows.Forms.ContextMenuStrip rightClickMenu;
- private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem mnu_copy_log;
}
}
\ No newline at end of file diff --git a/win/C#/frmActivityWindow.cs b/win/C#/frmActivityWindow.cs index 5508d0b93..d21eecd51 100644 --- a/win/C#/frmActivityWindow.cs +++ b/win/C#/frmActivityWindow.cs @@ -16,6 +16,7 @@ using System.IO; using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;
+using Microsoft.Win32;
namespace Handbrake
@@ -62,15 +63,12 @@ namespace Handbrake /// </summary>
private void displayLogHeader()
{
- // System Information
- Functions.SystemInfo info = new Functions.SystemInfo();
-
// Add a header to the log file indicating that it's from the Windows GUI and display the windows version
rtf_actLog.AppendText(String.Format("### Windows GUI {1} {0} \n", Properties.Settings.Default.hb_build, Properties.Settings.Default.hb_version));
rtf_actLog.AppendText(String.Format("### Running: {0} \n###\n", Environment.OSVersion.ToString()));
- rtf_actLog.AppendText(String.Format("### CPU: {0} \n", info.getCpuCount()));
- rtf_actLog.AppendText(String.Format("### Ram: {0} MB \n", info.TotalPhysicalMemory()));
- rtf_actLog.AppendText(String.Format("### Screen: {0}x{1} \n", info.screenBounds().Bounds.Width, info.screenBounds().Bounds.Height));
+ rtf_actLog.AppendText(String.Format("### CPU: {0} \n", getCpuCount()));
+ rtf_actLog.AppendText(String.Format("### Ram: {0} MB \n", TotalPhysicalMemory()));
+ rtf_actLog.AppendText(String.Format("### Screen: {0}x{1} \n", screenBounds().Bounds.Width, screenBounds().Bounds.Height));
rtf_actLog.AppendText(String.Format("### Temp Dir: {0} \n", Path.GetTempPath()));
rtf_actLog.AppendText(String.Format("### Install Dir: {0} \n", Application.StartupPath));
rtf_actLog.AppendText(String.Format("### Data Dir: {0} \n", Application.UserAppDataPath));
@@ -306,12 +304,74 @@ namespace Handbrake this.Close();
}
- private void copyToolStripMenuItem_Click(object sender, EventArgs e)
+ /// <summary>
+ /// Copy Log Menu Item on the right click menu for the log rtf box
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void mnu_copy_log_Click(object sender, EventArgs e)
{
if (rtf_actLog.SelectedText != "")
Clipboard.SetDataObject(rtf_actLog.SelectedText, true);
else
Clipboard.SetDataObject(rtf_actLog.Text, true);
}
+
+ #region System Information
+ private struct MEMORYSTATUS
+ {
+ public UInt32 dwLength;
+ public UInt32 dwMemoryLoad;
+ public UInt32 dwTotalPhys; // Used
+ public UInt32 dwAvailPhys;
+ public UInt32 dwTotalPageFile;
+ public UInt32 dwAvailPageFile;
+ public UInt32 dwTotalVirtual;
+ public UInt32 dwAvailVirtual;
+ }
+
+ [DllImport("kernel32.dll")]
+ private static extern void GlobalMemoryStatus
+ (
+ ref MEMORYSTATUS lpBuffer
+ );
+
+ /// <summary>
+ /// Returns the total physical ram in a system
+ /// </summary>
+ /// <returns></returns>
+ public uint TotalPhysicalMemory()
+ {
+ MEMORYSTATUS memStatus = new MEMORYSTATUS();
+ GlobalMemoryStatus(ref memStatus);
+
+ uint MemoryInfo = memStatus.dwTotalPhys;
+ MemoryInfo = MemoryInfo / 1024 / 1024;
+
+ return MemoryInfo;
+ }
+
+ /// <summary>
+ /// Get the number of CPU Cores
+ /// </summary>
+ /// <returns>Object</returns>
+ public Object getCpuCount()
+ {
+ RegistryKey RegKey = Registry.LocalMachine;
+ RegKey = RegKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
+ return RegKey.GetValue("ProcessorNameString");
+ }
+
+ /// <summary>
+ /// Get the System screen size information.
+ /// </summary>
+ /// <returns>System.Windows.Forms.Scree</returns>
+ public System.Windows.Forms.Screen screenBounds()
+ {
+ return System.Windows.Forms.Screen.PrimaryScreen;
+ }
+
+ #endregion
+
}
}
\ No newline at end of file diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs index 28d111ed5..ebd065b65 100644 --- a/win/C#/frmMain.Designer.cs +++ b/win/C#/frmMain.Designer.cs @@ -381,6 +381,7 @@ namespace Handbrake this.text_source.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.text_source.Location = new System.Drawing.Point(99, 19);
this.text_source.Name = "text_source";
+ this.text_source.ReadOnly = true;
this.text_source.Size = new System.Drawing.Size(584, 21);
this.text_source.TabIndex = 1;
this.text_source.Text = "Click \'Source\' to continue";
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 59ae27ba2..fd65e4971 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -21,23 +21,22 @@ namespace Handbrake {
public partial class frmMain : Form
{
- // Declarations *******************************************************
// Objects which may be used by one or more other objects
Functions.Main hb_common_func = new Functions.Main();
Functions.Encode cliObj = new Functions.Encode();
Queue.Queue encodeQueue = new Queue.Queue();
Presets.PresetsHandler presetHandler = new Presets.PresetsHandler();
Parsing.Title selectedTitle;
+ Parsing.DVD thisDVD;
// Objects belonging to this window only
PresetLoader presetLoader = new PresetLoader();
x264Panel x264PanelFunctions = new x264Panel();
QueryGenerator queryGen = new QueryGenerator();
+ // Globals: Mainly used for tracking.
internal Process hbProc;
- private Parsing.DVD thisDVD;
private frmQueue queueWindow;
- private delegate void updateStatusChanger();
private string lastAction = null;
public int maxWidth = 0;
public int maxHeight = 0;
@@ -52,33 +51,19 @@ namespace Handbrake Form splash = new frmSplashScreen();
splash.Show();
- // Initialize the queue window.
- queueWindow = new frmQueue(this);
//Create a label that can be updated from the parent thread.
Label lblStatus = new Label();
lblStatus.Size = new Size(250, 20);
lblStatus.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();
- if (x != null)
- {
- try
- {
- Properties.Settings.Default.hb_build = int.Parse(x[1].ToString());
- Properties.Settings.Default.hb_version = x[0].ToString();
- }
- catch (Exception)
- {
- Properties.Settings.Default.hb_build = 0;
- Properties.Settings.Default.hb_version = "0";
- }
- }
+ Properties.Settings.Default.hb_build = int.Parse(x[1].ToString());
+ Properties.Settings.Default.hb_version = x[0].ToString();
// show the form, but leave disabled until preloading is complete then show the main form
this.Enabled = false;
@@ -97,32 +82,33 @@ namespace Handbrake // Setup the GUI components
lblStatus.Text = "Setting up the GUI ...";
Application.DoEvents();
- setupH264Panel(); // Initalize the H.264 Panel
- loadPresetPanel(); // Load the Preset Panel
+ x264PanelFunctions.reset2Defaults(this); // Initialize all the x264 widgets to their default values
+ loadPresetPanel(); // Load the Preset Panel
+ treeView_presets.ExpandAll();
+ lbl_encode.Text = "";
+ queueWindow = new frmQueue(this); // Prepare the Queue
+
// Load the user's default settings or Normal Preset
- if (Properties.Settings.Default.defaultSettings == "Checked")
- loadUserDefaults();
+ if (Properties.Settings.Default.defaultSettings == "Checked" && Properties.Settings.Default.defaultUserSettings != "")
+ {
+ Functions.QueryParser presetQuery = Functions.QueryParser.Parse(Properties.Settings.Default.defaultUserSettings);
+ presetLoader.presetLoader(this, presetQuery, "User Defaults ");
+ }
else
loadNormalPreset();
- // Expand the preset Nodes
- treeView_presets.ExpandAll();
+
// Enabled GUI tooltip's if Required
if (Properties.Settings.Default.tooltipEnable == "Checked")
ToolTip.Active = true;
- lbl_encode.Text = "";
//Finished Loading
lblStatus.Text = "Loading Complete!";
Application.DoEvents();
-
- //Close the splash screen
splash.Close();
splash.Dispose();
-
- // Turn the interface back to the user
this.Enabled = true;
- // Some event Handlers. Used for minimize to taskbar
+ // Event Handlers
this.Resize += new EventHandler(frmMain_Resize);
// Queue Recovery
@@ -130,6 +116,7 @@ namespace Handbrake }
// Startup Functions
+ private delegate void updateStatusChanger();
private void startupUpdateCheck()
{
try
@@ -149,34 +136,6 @@ namespace Handbrake }
catch (Exception) { /* Do Nothing*/ }
}
- private void setupH264Panel()
- {
- // Set the default settings of the x264 panel
- drop_bFrames.Text = "Default (0)";
- drop_refFrames.Text = "Default (1)";
- drop_subpixelMotionEstimation.Text = "Default (4)";
- drop_trellis.Text = "Default (0)";
- drop_MotionEstimationMethod.Text = "Default (Hexagon)";
- drop_MotionEstimationRange.Text = "Default (16)";
- drop_directPrediction.Text = "Default (Spatial)";
- drop_deblockAlpha.Text = "Default (0)";
- drop_deblockBeta.Text = "Default (0)";
- drop_analysis.Text = "Default (some)";
- rtf_x264Query.Text = "";
- }
- private void loadUserDefaults()
- {
- // Try to load the users default settings.
- string userDefaults = Properties.Settings.Default.defaultUserSettings;
-
- if (userDefaults == "")
- loadNormalPreset();
- else
- {
- Functions.QueryParser presetQuery = Functions.QueryParser.Parse(userDefaults);
- presetLoader.presetLoader(this, presetQuery, "User Defaults ");
- }
- }
private void queueRecovery()
{
if (hb_common_func.check_queue_recovery() == true)
@@ -194,10 +153,9 @@ namespace Handbrake }
}
}
-
#endregion
- // The Applications Main Menu and Menus *******************************
+ // User Interface Menus / Tool Strips *********************************
#region File Menu
private void mnu_exit_Click(object sender, EventArgs e)
@@ -236,7 +194,7 @@ namespace Handbrake presetHandler.updateBuiltInPresets();
loadPresetPanel();
if (treeView_presets.Nodes.Count == 0)
- MessageBox.Show("Unable to load the presets.dat file. Please select \"Update Built-in Presets\" from the Presets Menu \nMake sure you are running the program in Admin mode if running on Vista. See Windows FAQ for details!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show("Unable to load the presets.xml file. Please select \"Update Built-in Presets\" from the Presets Menu \nMake sure you are running the program in Admin mode if running on Vista. See Windows FAQ for details!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
else
MessageBox.Show("Presets have been updated!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
@@ -245,7 +203,7 @@ namespace Handbrake private void mnu_delete_preset_Click(object sender, EventArgs e)
{
// Empty the preset file
- string presetsFile = Application.StartupPath.ToString() + "\\presets.dat";
+ string presetsFile = Application.StartupPath.ToString() + "\\presets.xml";
if (File.Exists(presetsFile))
File.Delete(presetsFile);
@@ -312,7 +270,8 @@ namespace Handbrake }
#endregion
- #region Preset Menu
+ #region Preset Bar
+ // Right Click Menu Code
private void pmnu_expandAll_Click(object sender, EventArgs e)
{
treeView_presets.ExpandAll();
@@ -344,12 +303,146 @@ namespace Handbrake }
treeView_presets.Select();
}
- #endregion
- // MainWindow Components, Actions and Functions ***********************
- #region Actions
+ // Presets Management
+ private void btn_addPreset_Click(object sender, EventArgs e)
+ {
+ // Remember each nodes expanded status so we can reload it
+ List<Boolean> nodeStatus = saveTreeViewState();
+ nodeStatus.Add(true);
+
+ // Now add the new preset
+ Form preset = new frmAddPreset(this, queryGen.GenerateTheQuery(this), presetHandler);
+ preset.ShowDialog();
+
+ // Now reload the TreeView states
+ loadTreeViewStates(nodeStatus);
+ }
+ private void btn_removePreset_Click(object sender, EventArgs e)
+ {
+ DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+ if (result == DialogResult.Yes)
+ {
+ if (treeView_presets.SelectedNode != null)
+ presetHandler.remove(treeView_presets.SelectedNode.Text);
+
+ // Remember each nodes expanded status so we can reload it
+ List<Boolean> nodeStatus = saveTreeViewState();
+
+ // Now reload the preset panel
+ loadPresetPanel();
+
+ // Now reload the TreeView states
+ loadTreeViewStates(nodeStatus);
+ }
+ treeView_presets.Select();
+ }
+ private void btn_setDefault_Click(object sender, EventArgs e)
+ {
+ String query = queryGen.GenerateTheQuery(this);
+ Properties.Settings.Default.defaultUserSettings = query;
+ // Save the new default Settings
+ Properties.Settings.Default.Save();
+ MessageBox.Show("New default settings saved.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
+ }
+ private void treeView_presets_AfterSelect(object sender, TreeViewEventArgs e)
+ {
+ // Ok, so, we've selected a preset. Now we want to load it.
+ string presetName = treeView_presets.SelectedNode.Text;
+ string query = presetHandler.getCliForPreset(presetName);
+
+ if (query != null)
+ {
+ //Ok, Reset all the H264 widgets before changing the preset
+ x264PanelFunctions.reset2Defaults(this);
+
+ // Send the query from the file to the Query Parser class
+ Functions.QueryParser presetQuery = Functions.QueryParser.Parse(query);
+
+ // Now load the preset
+ presetLoader.presetLoader(this, presetQuery, presetName);
+
+ // The x264 widgets will need updated, so do this now:
+ x264PanelFunctions.X264_StandardizeOptString(this);
+ x264PanelFunctions.X264_SetCurrentSettingsInPanel(this);
+ }
+ }
+ private void treeView_presets_deleteKey(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Delete)
+ {
+ DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
+ if (result == DialogResult.Yes)
+ {
+ if (treeView_presets.SelectedNode != null)
+ presetHandler.remove(treeView_presets.SelectedNode.Text);
+
+ // Remember each nodes expanded status so we can reload it
+ List<Boolean> nodeStatus = new List<Boolean>();
+ foreach (TreeNode node in treeView_presets.Nodes)
+ nodeStatus.Add(node.IsExpanded);
+
+ // Now reload the preset panel
+ loadPresetPanel();
+
+ // And finally, re-expand any of the nodes if required
+ int i = 0;
+ foreach (TreeNode node in treeView_presets.Nodes)
+ {
+ if (nodeStatus[i] == true)
+ node.Expand();
+
+ i++;
+ }
+ }
+ }
+ }
+ private List<Boolean> saveTreeViewState()
+ {
+ // Remember each nodes expanded status so we can reload it
+ List<Boolean> nodeStatus = new List<Boolean>();
+ foreach (TreeNode node in treeView_presets.Nodes)
+ {
+ nodeStatus.Add(node.IsExpanded);
+ foreach (TreeNode subNode in node.Nodes)
+ nodeStatus.Add(node.IsExpanded);
+ }
+ return nodeStatus;
+ }
+ private void loadTreeViewStates(List<Boolean> nodeStatus)
+ {
+ // And finally, re-expand any of the nodes if required
+ int i = 0;
+ foreach (TreeNode node in treeView_presets.Nodes)
+ {
+ if (nodeStatus[i] == true)
+ node.Expand();
+
+ foreach (TreeNode subNode in node.Nodes)
+ {
+ if (nodeStatus[i] == true)
+ subNode.Expand();
+ }
- // ToolBar
+ i++;
+ }
+ }
+ private void loadNormalPreset()
+ {
+ treeView_presets.Nodes.Find("Normal", true);
+
+ foreach (TreeNode treenode in treeView_presets.Nodes)
+ {
+ foreach (TreeNode node in treenode.Nodes)
+ {
+ if (node.Text.ToString().Equals("Normal"))
+ treeView_presets.SelectedNode = treeView_presets.Nodes[treenode.Index].Nodes[0];
+ }
+ }
+ }
+ #endregion
+
+ #region ToolStrip
private void btn_source_Click(object sender, EventArgs e)
{
if (Properties.Settings.Default.drive_detection == "Checked")
@@ -420,6 +513,45 @@ namespace Handbrake frmActivityWindow ActivityWindow = new frmActivityWindow(file, this, queueWindow);
ActivityWindow.Show();
}
+ #endregion
+
+ #region System Tray Icon
+ private void frmMain_Resize(object sender, EventArgs e)
+ {
+ if (FormWindowState.Minimized == this.WindowState)
+ {
+ notifyIcon.Visible = true;
+ if (lbl_encode.Text != "")
+ notifyIcon.BalloonTipText = lbl_encode.Text;
+ else
+ notifyIcon.BalloonTipText = "Not Encoding";
+ notifyIcon.ShowBalloonTip(500);
+ this.Hide();
+ }
+ else if (FormWindowState.Normal == this.WindowState)
+ notifyIcon.Visible = false;
+ }
+ private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
+ {
+ this.Visible = true;
+ this.Activate();
+ this.WindowState = FormWindowState.Normal;
+ notifyIcon.Visible = false;
+ }
+ private void btn_minimize_Click(object sender, EventArgs e)
+ {
+ this.WindowState = FormWindowState.Minimized;
+ }
+ private void btn_restore_Click(object sender, EventArgs e)
+ {
+ this.Visible = true;
+ this.Activate();
+ this.WindowState = FormWindowState.Normal;
+ notifyIcon.Visible = false;
+ }
+ #endregion
+
+ #region Tab Control
//Source
private void btn_dvd_source_Click(object sender, EventArgs e)
@@ -722,7 +854,14 @@ namespace Handbrake setExtension(".avi");
else if (drop_format.SelectedIndex == 4)
setExtension(".ogm");
-
+ }
+ private void setExtension(string newExtension)
+ {
+ text_destination.Text = text_destination.Text.Replace(".mp4", newExtension);
+ text_destination.Text = text_destination.Text.Replace(".m4v", newExtension);
+ text_destination.Text = text_destination.Text.Replace(".mkv", newExtension);
+ text_destination.Text = text_destination.Text.Replace(".avi", newExtension);
+ text_destination.Text = text_destination.Text.Replace(".ogm", newExtension);
}
//Video Tab
@@ -1434,168 +1573,57 @@ namespace Handbrake {
rtf_query.Clear();
}
+ #endregion
- // Presets
- private void btn_addPreset_Click(object sender, EventArgs e)
- {
- // Remember each nodes expanded status so we can reload it
- List<Boolean> nodeStatus = saveTreeViewState();
- nodeStatus.Add(true);
-
- // Now add the new preset
- Form preset = new frmAddPreset(this, queryGen.GenerateTheQuery(this), presetHandler);
- preset.ShowDialog();
-
- // Now reload the TreeView states
- loadTreeViewStates(nodeStatus);
- }
- private void btn_removePreset_Click(object sender, EventArgs e)
- {
- DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (result == DialogResult.Yes)
- {
- if (treeView_presets.SelectedNode != null)
- presetHandler.remove(treeView_presets.SelectedNode.Text);
+ // MainWindow Components, Actions and Functions ***********************
- // Remember each nodes expanded status so we can reload it
- List<Boolean> nodeStatus = saveTreeViewState();
+ #region Encoding
- // Now reload the preset panel
- loadPresetPanel();
+ // Declarations
+ private delegate void UpdateUIHandler();
- // Now reload the TreeView states
- loadTreeViewStates(nodeStatus);
- }
- treeView_presets.Select();
- }
- private void btn_setDefault_Click(object sender, EventArgs e)
- {
- String query = queryGen.GenerateTheQuery(this);
- Properties.Settings.Default.defaultUserSettings = query;
- // Save the new default Settings
- Properties.Settings.Default.Save();
- MessageBox.Show("New default settings saved.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- private void treeView_presets_AfterSelect(object sender, TreeViewEventArgs e)
+ // Encoding Functions
+ private void procMonitor(object state)
{
- // Ok, so, we've selected a preset. Now we want to load it.
- string presetName = treeView_presets.SelectedNode.Text;
- string query = presetHandler.getCliForPreset(presetName);
-
- if (query != null)
+ // Make sure we are not already encoding and if we are then display an error.
+ if (hbProc != null)
+ hbProc.CloseMainWindow();
+ else
{
- //Ok, Reset all the H264 widgets before changing the preset
- x264PanelFunctions.reset2Defaults(this);
-
- // Send the query from the file to the Query Parser class
- Functions.QueryParser presetQuery = Functions.QueryParser.Parse(query);
-
- // Now load the preset
- presetLoader.presetLoader(this, presetQuery, presetName);
+ hbProc = cliObj.runCli(this, (string)state);
+ hbProc.WaitForExit();
+ setEncodeLabelFinished();
+ hbProc = null;
- // The x264 widgets will need updated, so do this now:
- x264PanelFunctions.X264_StandardizeOptString(this);
- x264PanelFunctions.X264_SetCurrentSettingsInPanel(this);
- }
- }
- private void treeView_presets_deleteKey(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Delete)
- {
- DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected preset?", "Preset", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
- if (result == DialogResult.Yes)
+ // If the window is minimized, display the notification in a popup.
+ if (FormWindowState.Minimized == this.WindowState)
{
- if (treeView_presets.SelectedNode != null)
- presetHandler.remove(treeView_presets.SelectedNode.Text);
-
- // Remember each nodes expanded status so we can reload it
- List<Boolean> nodeStatus = new List<Boolean>();
- foreach (TreeNode node in treeView_presets.Nodes)
- nodeStatus.Add(node.IsExpanded);
-
- // Now reload the preset panel
- loadPresetPanel();
-
- // And finally, re-expand any of the nodes if required
- int i = 0;
- foreach (TreeNode node in treeView_presets.Nodes)
- {
- if (nodeStatus[i] == true)
- node.Expand();
-
- i++;
- }
+ notifyIcon.BalloonTipText = lbl_encode.Text;
+ notifyIcon.ShowBalloonTip(500);
}
- }
- }
- #endregion
-
- #region Preset Expand / Collaspe
- private List<Boolean> saveTreeViewState()
- {
- // Remember each nodes expanded status so we can reload it
- List<Boolean> nodeStatus = new List<Boolean>();
- foreach (TreeNode node in treeView_presets.Nodes)
- {
- nodeStatus.Add(node.IsExpanded);
- foreach (TreeNode subNode in node.Nodes)
- nodeStatus.Add(node.IsExpanded);
+ // After the encode is done, we may want to shutdown, suspend etc.
+ cliObj.addCLIQueryToLog((string)state);
+ cliObj.copyLog((string)state, text_destination.Text); // Make a copy of the log in the users desired location if necessary
+ cliObj.afterEncodeAction();
}
- return nodeStatus;
}
-
- private void loadTreeViewStates(List<Boolean> nodeStatus)
+ private void setEncodeLabelFinished()
{
- // And finally, re-expand any of the nodes if required
- int i = 0;
- foreach (TreeNode node in treeView_presets.Nodes)
+ if (this.InvokeRequired)
{
- if (nodeStatus[i] == true)
- node.Expand();
-
- foreach (TreeNode subNode in node.Nodes)
- {
- if (nodeStatus[i] == true)
- subNode.Expand();
- }
-
- i++;
+ this.BeginInvoke(new UpdateUIHandler(setEncodeLabelFinished));
+ return;
}
+ lbl_encode.Text = "Encoding Finished";
+ btn_start.Text = "Start";
+ btn_start.ToolTipText = "Start the encoding process";
+ btn_start.Image = Properties.Resources.Play;
}
- #endregion
- #region Functions
- private void loadNormalPreset()
- {
- treeView_presets.Nodes.Find("Normal", true);
-
- foreach (TreeNode treenode in treeView_presets.Nodes)
- {
- foreach (TreeNode node in treenode.Nodes)
- {
- if (node.Text.ToString().Equals("Normal"))
- treeView_presets.SelectedNode = treeView_presets.Nodes[treenode.Index].Nodes[0];
- }
- }
- }
- /// <summary>
- /// Take in a File destination and change it's file extension to a new Extension
- /// </summary>
- /// <param name="destination"></param>
- /// <param name="newExtension"></param>
- /// <returns>String of the new file path and extension</returns>
- public void setExtension(string newExtension)
- {
- text_destination.Text = text_destination.Text.Replace(".mp4", newExtension);
- text_destination.Text = text_destination.Text.Replace(".m4v", newExtension);
- text_destination.Text = text_destination.Text.Replace(".mkv", newExtension);
- text_destination.Text = text_destination.Text.Replace(".avi", newExtension);
- text_destination.Text = text_destination.Text.Replace(".ogm", newExtension);
- }
#endregion
- #region Drive Detection
+ #region DVD Drive Detection
// Source Button Drive Detection
private delegate void ProgressUpdateHandler();
private void getDriveInfoThread()
@@ -1637,7 +1665,7 @@ namespace Handbrake }
#endregion
- #region Audio Panel Stuff
+ #region Audio Panel Code Helpers
public void setAudioByContainer(String path)
{
string oldval = "";
@@ -1892,52 +1920,6 @@ namespace Handbrake }
#endregion
- #region Encoding
-
- // Declarations
- private delegate void UpdateUIHandler();
-
- // Encoding Functions
- private void procMonitor(object state)
- {
- // Make sure we are not already encoding and if we are then display an error.
- if (hbProc != null)
- hbProc.CloseMainWindow();
- else
- {
- hbProc = cliObj.runCli(this, (string)state);
- hbProc.WaitForExit();
- setEncodeLabelFinished();
- hbProc = null;
-
- // If the window is minimized, display the notification in a popup.
- if (FormWindowState.Minimized == this.WindowState)
- {
- notifyIcon.BalloonTipText = lbl_encode.Text;
- notifyIcon.ShowBalloonTip(500);
- }
-
- // After the encode is done, we may want to shutdown, suspend etc.
- cliObj.addCLIQueryToLog((string)state);
- cliObj.copyLog((string)state, text_destination.Text); // Make a copy of the log in the users desired location if necessary
- cliObj.afterEncodeAction();
- }
- }
- private void setEncodeLabelFinished()
- {
- if (this.InvokeRequired)
- {
- this.BeginInvoke(new UpdateUIHandler(setEncodeLabelFinished));
- return;
- }
- lbl_encode.Text = "Encoding Finished";
- btn_start.Text = "Start";
- btn_start.ToolTipText = "Start the encoding process";
- btn_start.Image = Properties.Resources.Play;
- }
-
- #endregion
-
#region Public Methods
/// <summary>
@@ -2070,42 +2052,6 @@ namespace Handbrake #endregion
- #region Taskbar Tray Icon
- private void frmMain_Resize(object sender, EventArgs e)
- {
- if (FormWindowState.Minimized == this.WindowState)
- {
- notifyIcon.Visible = true;
- if (lbl_encode.Text != "")
- notifyIcon.BalloonTipText = lbl_encode.Text;
- else
- notifyIcon.BalloonTipText = "Not Encoding";
- notifyIcon.ShowBalloonTip(500);
- this.Hide();
- }
- else if (FormWindowState.Normal == this.WindowState)
- notifyIcon.Visible = false;
- }
- private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- this.Visible = true;
- this.Activate();
- this.WindowState = FormWindowState.Normal;
- notifyIcon.Visible = false;
- }
- private void btn_minimize_Click(object sender, EventArgs e)
- {
- this.WindowState = FormWindowState.Minimized;
- }
- private void btn_restore_Click(object sender, EventArgs e)
- {
- this.Visible = true;
- this.Activate();
- this.WindowState = FormWindowState.Normal;
- notifyIcon.Visible = false;
- }
- #endregion
-
// This is the END of the road ------------------------------------------------------------------------------
}
}
\ No newline at end of file diff --git a/win/C#/frmMain/x264Panel.cs b/win/C#/frmMain/x264Panel.cs index 13580665c..a4cb7ecbb 100644 --- a/win/C#/frmMain/x264Panel.cs +++ b/win/C#/frmMain/x264Panel.cs @@ -7,6 +7,7 @@ namespace Handbrake {
class x264Panel
{
+
/// <summary>
/// Reset all components to defaults and clears the x264 rtf box
/// </summary>
|