// x264Panel\r
// \r
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;\r
+ this.BackColor = System.Drawing.Color.Transparent;\r
this.Controls.Add(this.slider_psytrellis);\r
this.Controls.Add(this.lbl_psytrellis);\r
this.Controls.Add(this.lbl_psyrd);\r
<metadata name="ToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
<value>17, 17</value>\r
</metadata>\r
- <metadata name="ToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>17, 17</value>\r
- </metadata>\r
<data name="slider_psyrd.ToolTip" xml:space="preserve">\r
<value>Psychovisual Rate Distortion Optimization sure is a mouthful, isn't it? Basically, it means x264 tries to retain detail, for better quality to the human eye, \r
as opposed to trying to maximize quality the way a computer understands it, through signal-to-noise ratios that have trouble telling apart fine detail and noise.</value>\r
using System;\r
using System.Xml;\r
using System.Text.RegularExpressions;\r
+using System.IO;\r
\r
namespace Handbrake.Functions\r
{\r
/// <summary>\r
/// Get the build information from the required appcasts. Run before accessing the public vars.\r
/// </summary>\r
- public void getInfo()\r
+ public void getInfo(string input)\r
{\r
// Get the correct Appcast and set input.\r
- XmlNode nodeItem = Properties.Settings.Default.hb_build.ToString().EndsWith("1") ? readRss(new XmlTextReader(Properties.Settings.Default.appcast_unstable)) : readRss(new XmlTextReader(Properties.Settings.Default.appcast));\r
- string input = nodeItem.InnerXml;\r
+ XmlNode nodeItem = readRss(new XmlTextReader(new StringReader(input)));\r
+ string result = nodeItem.InnerXml;\r
\r
// Regular Expressions\r
- Match ver = Regex.Match(input, @"sparkle:version=""([0-9]*)\""");\r
- Match verShort = Regex.Match(input, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\""");\r
+ Match ver = Regex.Match(result, @"sparkle:version=""([0-9]*)\""");\r
+ Match verShort = Regex.Match(result, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\""");\r
\r
build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");\r
version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");\r
using System.Xml.Serialization;\r
using System.Threading;\r
using Handbrake.EncodeQueue;\r
+using System.Net;\r
\r
namespace Handbrake.Functions\r
{\r
return AutoNamePath;\r
}\r
\r
- /// <summary>\r
- /// Checks for updates and returns true if an update is available.\r
- /// </summary>\r
- /// <param name="debug">Turns on debug mode. Don't use on program startup</param>\r
- /// <returns>Boolean True = Update available</returns>\r
- public static Boolean updateCheck(Boolean debug)\r
- {\r
- try\r
- {\r
- AppcastReader rssRead = new AppcastReader();\r
- rssRead.getInfo(); // Initializes the class.\r
- string build = rssRead.build;\r
-\r
- int latest = int.Parse(build);\r
- int current = Properties.Settings.Default.hb_build;\r
- int skip = Properties.Settings.Default.skipversion;\r
-\r
- if (latest == skip)\r
- return false;\r
-\r
- Properties.Settings.Default.lastUpdateCheckDate = DateTime.Now;\r
- Properties.Settings.Default.Save();\r
-\r
- Boolean update = (latest > current);\r
- return update;\r
- }\r
- catch (Exception exc)\r
- {\r
- if (debug)\r
- MessageBox.Show("Unable to check for updates, Please try again later. \n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
- return false;\r
- }\r
- }\r
-\r
/// <summary>\r
/// Get's HandBrakes version data from the CLI.\r
/// </summary>\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Begins checking for an update to HandBrake.\r
+ /// </summary>\r
+ /// <param name="callback">The method that will be called when the check is finished.</param>\r
+ /// <param name="debug">Whether or not to execute this in debug mode.</param>\r
+ public static void BeginCheckForUpdates(AsyncCallback callback, bool debug)\r
+ {\r
+ ThreadPool.QueueUserWorkItem(new WaitCallback(delegate\r
+ {\r
+ try\r
+ {\r
+ // Is this a stable or unstable build?\r
+ string url = Properties.Settings.Default.hb_build.ToString().EndsWith("1") ? Properties.Settings.Default.appcast_unstable : Properties.Settings.Default.appcast;\r
+\r
+ // Initialize variables\r
+ WebRequest request = WebRequest.Create(url);\r
+ WebResponse response = request.GetResponse();\r
+ AppcastReader reader = new AppcastReader();\r
+\r
+ // Get the data, convert it to a string, and parse it into the AppcastReader\r
+ reader.getInfo(new StreamReader(response.GetResponseStream()).ReadToEnd());\r
+\r
+ // Further parse the information\r
+ string build = reader.build;\r
+\r
+ int latest = int.Parse(build);\r
+ int current = Properties.Settings.Default.hb_build;\r
+ int skip = Properties.Settings.Default.skipversion;\r
+\r
+ // If the user wanted to skip this version, don't report the update\r
+ if (latest == skip)\r
+ {\r
+ UpdateCheckInformation info = new UpdateCheckInformation() { NewVersionAvailable = false, BuildInformation = null };\r
+ callback(new UpdateCheckResult(debug, info));\r
+ return;\r
+ }\r
+\r
+ // Set when the last update was\r
+ Properties.Settings.Default.lastUpdateCheckDate = DateTime.Now;\r
+ Properties.Settings.Default.Save();\r
+\r
+ UpdateCheckInformation info2 = new UpdateCheckInformation() { NewVersionAvailable = latest > current, BuildInformation = reader };\r
+ callback(new UpdateCheckResult(debug, info2));\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ callback(new UpdateCheckResult(debug, new UpdateCheckInformation() { Error = exc }));\r
+ }\r
+ }));\r
+ }\r
+\r
+ /// <summary>\r
+ /// \r
+ /// </summary>\r
+ /// <param name="result"></param>\r
+ /// <returns></returns>\r
+ public static UpdateCheckInformation EndCheckForUpdates(IAsyncResult result)\r
+ {\r
+ UpdateCheckResult checkResult = (UpdateCheckResult)result;\r
+ return checkResult.Result;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Used in EndUpdateCheck() for update checking and the IAsyncResult design pattern.\r
+ /// </summary>\r
+ private class UpdateCheckResult : IAsyncResult\r
+ {\r
+ public UpdateCheckResult(object asyncState, UpdateCheckInformation info)\r
+ {\r
+ AsyncState = asyncState;\r
+ Result = info;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets whether the check was executed in debug mode.\r
+ /// </summary>\r
+ public object AsyncState { get; private set; }\r
+\r
+ /// <summary>\r
+ /// Gets the result of the update check.\r
+ /// </summary>\r
+ public UpdateCheckInformation Result { get; private set; }\r
+\r
+ public WaitHandle AsyncWaitHandle { get { throw new NotImplementedException(); } }\r
+ public bool CompletedSynchronously { get { throw new NotImplementedException(); } }\r
+ public bool IsCompleted { get { throw new NotImplementedException(); } }\r
+ }\r
}\r
}\r
--- /dev/null
+using System;\r
+\r
+namespace Handbrake.Functions\r
+{\r
+ /// <summary>\r
+ /// Provides information about an update check.\r
+ /// </summary>\r
+ public struct UpdateCheckInformation\r
+ {\r
+ public bool NewVersionAvailable { get; set; }\r
+ public bool ErrorOccured { get { return Error != null; } }\r
+\r
+ /// <summary>\r
+ /// Gets information about the new build, if any. This will be null if there is no new verison.\r
+ /// </summary>\r
+ public AppcastReader BuildInformation { get; set; }\r
+\r
+ /// <summary>\r
+ /// Gets the error that occurred, if any. This will be null if no error occured.\r
+ /// </summary>\r
+ public Exception Error { get; set; }\r
+ }\r
+}\r
<Compile Include="Functions\PresetLoader.cs" />\r
<Compile Include="Functions\QueryGenerator.cs" />\r
<Compile Include="Functions\Main.cs" />\r
+ <Compile Include="Functions\UpdateCheckInformation.cs" />\r
<Compile Include="Functions\Win32.cs" />\r
<Compile Include="Presets\preset.cs" />\r
<Compile Include="Presets\PresetsHandler.cs" />\r
this.lbl_source = new System.Windows.Forms.Label();\r
this.label4 = new System.Windows.Forms.Label();\r
this.groupBox_output = new System.Windows.Forms.Label();\r
+ this.lbl_updateCheck = new System.Windows.Forms.ToolStripStatusLabel();\r
this.PictureSettings = new Handbrake.Controls.PictureSettings();\r
this.Filters = new Handbrake.Controls.Filters();\r
this.AudioSettings = new Handbrake.Controls.AudioPanel();\r
// Label47\r
// \r
this.Label47.AutoSize = true;\r
+ this.Label47.BackColor = System.Drawing.Color.Transparent;\r
this.Label47.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
this.Label47.ForeColor = System.Drawing.Color.Black;\r
this.Label47.Location = new System.Drawing.Point(13, 39);\r
// radio_cq\r
// \r
this.radio_cq.AutoSize = true;\r
+ this.radio_cq.BackColor = System.Drawing.Color.Transparent;\r
this.radio_cq.Location = new System.Drawing.Point(336, 97);\r
this.radio_cq.Name = "radio_cq";\r
this.radio_cq.Size = new System.Drawing.Size(125, 17);\r
this.radio_cq.TabIndex = 18;\r
this.radio_cq.Text = "Constant Quality:";\r
- this.radio_cq.UseVisualStyleBackColor = true;\r
+ this.radio_cq.UseVisualStyleBackColor = false;\r
this.radio_cq.CheckedChanged += new System.EventHandler(this.radio_cq_CheckedChanged);\r
// \r
// radio_avgBitrate\r
// \r
this.radio_avgBitrate.AutoSize = true;\r
+ this.radio_avgBitrate.BackColor = System.Drawing.Color.Transparent;\r
this.radio_avgBitrate.Checked = true;\r
this.radio_avgBitrate.Location = new System.Drawing.Point(336, 64);\r
this.radio_avgBitrate.Name = "radio_avgBitrate";\r
this.radio_avgBitrate.TabIndex = 17;\r
this.radio_avgBitrate.TabStop = true;\r
this.radio_avgBitrate.Text = "Avg Bitrate (kbps):";\r
- this.radio_avgBitrate.UseVisualStyleBackColor = true;\r
+ this.radio_avgBitrate.UseVisualStyleBackColor = false;\r
this.radio_avgBitrate.CheckedChanged += new System.EventHandler(this.radio_avgBitrate_CheckedChanged);\r
// \r
// radio_targetFilesize\r
// \r
this.radio_targetFilesize.AutoSize = true;\r
+ this.radio_targetFilesize.BackColor = System.Drawing.Color.Transparent;\r
this.radio_targetFilesize.Location = new System.Drawing.Point(336, 37);\r
this.radio_targetFilesize.Name = "radio_targetFilesize";\r
this.radio_targetFilesize.Size = new System.Drawing.Size(126, 17);\r
this.radio_targetFilesize.TabIndex = 16;\r
this.radio_targetFilesize.Text = "Target Size (MB):";\r
- this.radio_targetFilesize.UseVisualStyleBackColor = true;\r
+ this.radio_targetFilesize.UseVisualStyleBackColor = false;\r
this.radio_targetFilesize.CheckedChanged += new System.EventHandler(this.radio_targetFilesize_CheckedChanged);\r
// \r
// label25\r
// StatusStrip\r
// \r
this.StatusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
- this.lbl_encode});\r
+ this.lbl_encode,\r
+ this.lbl_updateCheck});\r
this.StatusStrip.Location = new System.Drawing.Point(0, 599);\r
this.StatusStrip.Name = "StatusStrip";\r
this.StatusStrip.Size = new System.Drawing.Size(1000, 22);\r
+ this.StatusStrip.SizingGrip = false;\r
this.StatusStrip.TabIndex = 7;\r
this.StatusStrip.Text = "statusStrip1";\r
// \r
this.groupBox_output.TabIndex = 47;\r
this.groupBox_output.Text = "Output Settings: (Preset: None)";\r
// \r
+ // lbl_updateCheck\r
+ // \r
+ this.lbl_updateCheck.BackColor = System.Drawing.Color.Transparent;\r
+ this.lbl_updateCheck.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;\r
+ this.lbl_updateCheck.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+ this.lbl_updateCheck.Name = "lbl_updateCheck";\r
+ this.lbl_updateCheck.Size = new System.Drawing.Size(139, 17);\r
+ this.lbl_updateCheck.Text = "Checking for Updates ...";\r
+ this.lbl_updateCheck.Visible = false;\r
+ // \r
// PictureSettings\r
// \r
this.PictureSettings.BackColor = System.Drawing.Color.Transparent;\r
// \r
// x264Panel\r
// \r
+ this.x264Panel.BackColor = System.Drawing.Color.Transparent;\r
this.x264Panel.Location = new System.Drawing.Point(0, 0);\r
this.x264Panel.Name = "x264Panel";\r
this.x264Panel.Size = new System.Drawing.Size(720, 306);\r
this.Controls.Add(this.frmMainMenu);\r
this.Controls.Add(this.StatusStrip);\r
this.DoubleBuffered = true;\r
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;\r
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
+ this.MaximizeBox = false;\r
this.Name = "frmMain";\r
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;\r
this.Text = "HandBrake";\r
internal Label lbl_source;\r
private Label label4;\r
internal Label groupBox_output;\r
+ private ToolStripStatusLabel lbl_updateCheck;\r
\r
\r
}\r
\r
// Delegates **********************************************************\r
private delegate void UpdateWindowHandler();\r
- private delegate void UpdateStatusChanger();\r
\r
// Applicaiton Startup ************************************************\r
\r
lblStatus.Text = "Checking for updates ...";\r
Application.DoEvents();\r
\r
- Thread updateCheckThread = new Thread(startupUpdateCheck);\r
- updateCheckThread.Start();\r
+ Main.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false);\r
}\r
}\r
\r
queueRecovery();\r
}\r
\r
- // Startup Functions \r
- private void startupUpdateCheck()\r
+ private void UpdateCheckDone(IAsyncResult result)\r
{\r
+ if (InvokeRequired)\r
+ {\r
+ Invoke(new MethodInvoker(() => UpdateCheckDone(result)));\r
+ return;\r
+ }\r
+\r
+ UpdateCheckInformation info;\r
+\r
try\r
{\r
- if (InvokeRequired)\r
- {\r
- BeginInvoke(new UpdateStatusChanger(startupUpdateCheck));\r
- return;\r
- }\r
+ info = Main.EndCheckForUpdates(result);\r
\r
- Boolean update = Main.updateCheck(false);\r
- if (update)\r
+ if (info.NewVersionAvailable)\r
{\r
- frmUpdater updateWindow = new frmUpdater();\r
- updateWindow.Show();\r
+ frmUpdater updateWindow = new frmUpdater(info.BuildInformation);\r
+ updateWindow.ShowDialog();\r
}\r
}\r
- catch (Exception exc)\r
+ catch (Exception ex)\r
{\r
- MessageBox.Show(splash, "Unable to perform update check. If this problem persists, you can turn of update checking in the program options. \nError Information: \n\n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ if ((bool)result.AsyncState)\r
+ MessageBox.Show("Unable to check for updates, Please try again later. \n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
}\r
}\r
+\r
+ // Startup Functions \r
private void queueRecovery()\r
{\r
if (Main.check_queue_recovery())\r
}\r
private void mnu_UpdateCheck_Click(object sender, EventArgs e)\r
{\r
- Boolean update = Main.updateCheck(true);\r
- if (update)\r
+ Main.BeginCheckForUpdates(new AsyncCallback(updateCheckDoneMenu), false);\r
+ }\r
+ private void updateCheckDoneMenu(IAsyncResult result)\r
+ {\r
+ // Make sure it's running on the calling thread\r
+ if (InvokeRequired)\r
{\r
- frmUpdater updateWindow = new frmUpdater();\r
- updateWindow.Show();\r
+ Invoke(new MethodInvoker(() => updateCheckDoneMenu(result)));\r
+ return;\r
+ }\r
+\r
+ UpdateCheckInformation info;\r
+\r
+ try\r
+ {\r
+ // Get the information about the new build, if any, and close the window\r
+ info = Main.EndCheckForUpdates(result);\r
+ lbl_updateCheck.Visible = true;\r
+ if (info.NewVersionAvailable && info.BuildInformation != null)\r
+ {\r
+ frmUpdater updateWindow = new frmUpdater(info.BuildInformation);\r
+ updateWindow.ShowDialog();\r
+ }\r
+ else\r
+ MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
+ lbl_updateCheck.Visible = false;\r
+ return;\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ if ((bool)result.AsyncState)\r
+ MessageBox.Show("Unable to check for updates, Please try again later. \n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
}\r
- else\r
- MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
}\r
private void mnu_about_Click(object sender, EventArgs e)\r
{\r
- Form About = new frmAbout();\r
- About.ShowDialog();\r
+ using (frmAbout About = new frmAbout())\r
+ {\r
+ About.ShowDialog();\r
+ }\r
}\r
#endregion\r
\r
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>\r
</resheader>\r
<metadata name="notifyIconMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>977, 15</value>\r
+ <value>17, 54</value>\r
</metadata>\r
<metadata name="notifyIconMenu.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
<value>False</value>\r
<value>106, 15</value>\r
</metadata>\r
<metadata name="AudioMenuRowHeightHack.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>123, 52</value>\r
+ <value>392, 54</value>\r
</metadata>\r
<metadata name="presets_menu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>1224, 15</value>\r
+ <value>265, 54</value>\r
</metadata>\r
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
<value>767, 15</value>\r
</value>\r
</data>\r
<metadata name="StatusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>1113, 15</value>\r
+ <value>155, 54</value>\r
</metadata>\r
<metadata name="hbproc.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
- <value>308, 52</value>\r
+ <value>595, 54</value>\r
</metadata>\r
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">\r
<value>98</value>\r
InitializeComponent();\r
\r
this.queue = q;\r
- queue.OnEncodeStart += new EventHandler(queue_OnEncodeStart);\r
- queue.OnQueueFinished += new EventHandler(queue_OnQueueFinished);\r
- queue.OnPaused += new EventHandler(queue_OnPaused);\r
+ queue.OnEncodeStart += new EventHandler(queueOnEncodeStart);\r
+ queue.OnQueueFinished += new EventHandler(queueOnQueueFinished);\r
+ queue.OnPaused += new EventHandler(queueOnPaused);\r
}\r
- void queue_OnPaused(object sender, EventArgs e)\r
+ void queueOnPaused(object sender, EventArgs e)\r
{\r
setUIEncodeFinished();\r
updateUIElements();\r
}\r
- void queue_OnQueueFinished(object sender, EventArgs e)\r
+ void queueOnQueueFinished(object sender, EventArgs e)\r
{\r
setUIEncodeFinished();\r
resetQueue(); // Reset the Queue Window\r
}\r
- void queue_OnEncodeStart(object sender, EventArgs e)\r
+ void queueOnEncodeStart(object sender, EventArgs e)\r
{\r
setUIEncodeStarted(); // make sure the UI is set correctly\r
setCurrentEncodeInformation();\r
/// </summary>\r
public new void Show()\r
{\r
- Show(true);\r
+ Show(true);\r
}\r
\r
/// <summary>\r
{\r
if (doSetQueue) setQueue();\r
base.Show();\r
- Activate();\r
+\r
+ //Activate();\r
}\r
\r
// Start and Stop Controls\r
{\r
public partial class frmUpdater : Form\r
{\r
- AppcastReader appcast = new AppcastReader();\r
- public frmUpdater()\r
+ AppcastReader appcast;\r
+ public frmUpdater(AppcastReader reader)\r
{\r
InitializeComponent();\r
\r
- appcast.getInfo(); // Initializes the appcast\r
+ appcast = reader;\r
getRss();\r
setVersions();\r
}\r
private void btn_installUpdate_Click(object sender, EventArgs e)\r
{\r
frmDownload download = new frmDownload(appcast.downloadFile);\r
- download.Show();\r
+ download.ShowDialog();\r
this.Close();\r
}\r
\r