-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
910 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Diagnostics; | ||
using System.Net; | ||
using System.Windows.Forms; | ||
|
||
namespace LauncherDesktop | ||
{ | ||
public partial class DownloadForm : Form | ||
{ | ||
readonly Form1 nInformation; | ||
public DownloadForm(Form1 fm1) | ||
{ | ||
InitializeComponent(); | ||
nInformation = fm1; | ||
} | ||
//informações | ||
string NewVersion; | ||
string url; | ||
string newFile; | ||
private void DownloadForm_Load(object sender, EventArgs e) | ||
{ | ||
NewVersion = nInformation.NewVersion; | ||
newFile = Application.StartupPath + @"\\LauncherDesktop v" + NewVersion + ".exe"; | ||
url = "https://github.com/SrShadowy/AppLauncher/releases/download/v" + NewVersion + "/LauncherDesktop.exe"; | ||
BeginDownload(); | ||
} | ||
|
||
void BeginDownload() | ||
{ | ||
WebClient downloaded = new WebClient(); | ||
downloaded.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged); | ||
downloaded.DownloadFileCompleted += new AsyncCompletedEventHandler(ProgressEnd); | ||
downloaded.DownloadFileAsync(new Uri(url), newFile); | ||
} | ||
|
||
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e) | ||
{ | ||
progressBar1.Value = e.ProgressPercentage; | ||
this.Text = "fazendo download: " + ((e.BytesReceived / 1024f)).ToString() + "kb /" + (( e.TotalBytesToReceive / 1024f)).ToString() + " kb"; | ||
} | ||
private void ProgressEnd(object sender, AsyncCompletedEventArgs e) | ||
{ | ||
try | ||
{ | ||
lbl_info.Text = "Concluido você pode fecha essa versão fico obsoleta"; | ||
btn_closeAll.Enabled = true; | ||
btn_closeAll.Visible = true; | ||
} | ||
catch | ||
{ | ||
lbl_info.Text = "Ops, algo deu errado, mas você pode tentar denovo, ou ir no site e baixar manualmente "; | ||
Process.Start("https://github.com/SrShadowy/AppLauncher/releases"); | ||
btn_download.Visible = true; | ||
btn_site.Visible = true; | ||
} | ||
} | ||
private void Btn_download_Click(object sender, EventArgs e) | ||
{ | ||
BeginDownload(); | ||
} | ||
|
||
private void Btn_closeAll_Click(object sender, EventArgs e) | ||
{ | ||
Process.Start(newFile); | ||
nInformation.Close(); | ||
} | ||
} | ||
} |
Oops, something went wrong.