Skip to content

Commit

Permalink
FutureUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
SrShadowy committed Apr 30, 2020
1 parent eeb3e5d commit 9808bad
Show file tree
Hide file tree
Showing 7 changed files with 910 additions and 5 deletions.
119 changes: 119 additions & 0 deletions LauncherDesktop/DownloadForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions LauncherDesktop/DownloadForm.cs
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();
}
}
}
Loading

0 comments on commit 9808bad

Please sign in to comment.