/* frmDownload.cs $\r
\r
- This file is part of the HandBrake source code.\r
- Homepage: <http://handbrake.fr>.\r
- It may be used under the terms of the GNU General Public License. */\r
-\r
-using System;\r
-using System.Windows.Forms;\r
-using System.Net;\r
-using System.IO;\r
-using System.Threading;\r
-using System.Diagnostics;\r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr>.\r
+ It may be used under the terms of the GNU General Public License. */\r
\r
namespace Handbrake\r
{\r
+ using System;\r
+ using System.Diagnostics;\r
+ using System.IO;\r
+ using System.Net;\r
+ using System.Threading;\r
+ using System.Windows.Forms;\r
+\r
public partial class frmDownload : Form\r
{\r
private readonly Thread _downloadThread;\r
private HttpWebRequest _webRequest;\r
private HttpWebResponse _webResponse;\r
private static int _progress;\r
- private Boolean _killThread;\r
- private delegate void UpdateProgessCallback(Int64 bytesRead, Int64 totalBytes);\r
+ private bool _killThread;\r
+\r
+ private delegate void UpdateProgessCallback(long bytesRead, long totalBytes);\r
+\r
private delegate void DownloadCompleteCallback();\r
+\r
private delegate void DownloadFailedCallback();\r
\r
\r
private void Download(object file)\r
{\r
string tempPath = Path.Combine(Path.GetTempPath(), "handbrake-setup.exe");\r
- string hbUpdate = (string)file;\r
+ string hbUpdate = (string) file;\r
WebClient wcDownload = new WebClient();\r
\r
try\r
if (File.Exists(tempPath))\r
File.Delete(tempPath);\r
\r
- _webRequest = (HttpWebRequest)WebRequest.Create(hbUpdate);\r
+ _webRequest = (HttpWebRequest) WebRequest.Create(hbUpdate);\r
_webRequest.Credentials = CredentialCache.DefaultCredentials;\r
- _webResponse = (HttpWebResponse)_webRequest.GetResponse();\r
- Int64 fileSize = _webResponse.ContentLength;\r
+ _webResponse = (HttpWebResponse) _webRequest.GetResponse();\r
+ long fileSize = _webResponse.ContentLength;\r
\r
_responceStream = wcDownload.OpenRead(hbUpdate);\r
_loacalStream = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.None);\r
return;\r
_loacalStream.Write(downBuffer, 0, bytesSize);\r
flength = _loacalStream.Length;\r
- Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { _loacalStream.Length, fileSize });\r
+ Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] {_loacalStream.Length, fileSize});\r
}\r
\r
_responceStream.Close();\r
}\r
}\r
\r
- private void UpdateProgress(Int64 bytesRead, Int64 totalBytes)\r
+ private void UpdateProgress(long bytesRead, long totalBytes)\r
{\r
- long p = (bytesRead * 100) / totalBytes;\r
+ long p = (bytesRead*100)/totalBytes;\r
int.TryParse(p.ToString(), out _progress);\r
progress_download.Value = _progress;\r
- lblProgress.Text = (bytesRead / 1024) + "k of " + (totalBytes / 1024) + "k ";\r
+ lblProgress.Text = (bytesRead/1024) + "k of " + (totalBytes/1024) + "k ";\r
}\r
\r
private void DownloadComplete()\r