X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=win%2FC%23%2FfrmDownload.cs;h=8b23df92b9d11db8116cfd6b1a844c05c7cbd725;hb=6aa1d8aec5bac19ce4430415ea2021c11fb4bf3d;hp=872ec87e7907d067af0b7ef1394e9c5a7ae7a0f6;hpb=358136d207a161738ac8966a71dc81bf150cc72f;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/win/C#/frmDownload.cs b/win/C#/frmDownload.cs index 872ec87e..8b23df92 100644 --- a/win/C#/frmDownload.cs +++ b/win/C#/frmDownload.cs @@ -5,11 +5,6 @@ It may be used under the terms of the GNU General Public License. */ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; using System.Windows.Forms; using System.Net; using System.IO; @@ -20,7 +15,7 @@ namespace Handbrake { public partial class frmDownload : Form { - private Thread downloadThread; + private readonly Thread downloadThread; private Stream responceStream; private Stream loacalStream; private HttpWebRequest webRequest; @@ -30,20 +25,21 @@ namespace Handbrake private delegate void DownloadCompleteCallback(); private delegate void DownloadFailedCallback(); + private string file; - public frmDownload() + public frmDownload(string filename) { InitializeComponent(); + file = filename; downloadThread = new Thread(Download); downloadThread.Start(); } private void Download() { - Functions.AppcastReader rssRead = new Functions.AppcastReader(); string tempPath = Path.Combine(Path.GetTempPath(), "handbrake-setup.exe"); - string hbUpdate = rssRead.downloadFile(); + string hbUpdate = file; WebClient wcDownload = new WebClient(); try @@ -59,7 +55,7 @@ namespace Handbrake responceStream = wcDownload.OpenRead(hbUpdate); loacalStream = new FileStream(tempPath, FileMode.Create, FileAccess.Write, FileShare.None); - int bytesSize = 0; + int bytesSize; byte[] downBuffer = new byte[2048]; long flength = 0; @@ -67,16 +63,16 @@ namespace Handbrake { loacalStream.Write(downBuffer, 0, bytesSize); flength = loacalStream.Length; - this.Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { loacalStream.Length, fileSize }); + Invoke(new UpdateProgessCallback(this.UpdateProgress), new object[] { loacalStream.Length, fileSize }); } responceStream.Close(); loacalStream.Close(); if (flength != fileSize) - this.Invoke(new DownloadFailedCallback(this.downloadFailed)); + Invoke(new DownloadFailedCallback(this.downloadFailed)); else - this.Invoke(new DownloadCompleteCallback(this.downloadComplete)); + Invoke(new DownloadCompleteCallback(this.downloadComplete)); } catch (Exception) { @@ -95,7 +91,7 @@ namespace Handbrake } catch (Exception exc) { - MessageBox.Show("Integer Convertion Error On Download \n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Integer Conversion Error On Download \n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -105,8 +101,7 @@ namespace Handbrake btn_cancel.Text = "Close"; string tempPath = Path.Combine(Path.GetTempPath(), "handbrake-setup.exe"); - - Process startInstall = Process.Start(tempPath); + Process.Start(tempPath); this.Close(); Application.Exit(); }