|
|
@@ -7,10 +7,10 @@ using System;
|
|
|
using System.Diagnostics;
|
|
|
using System.IO;
|
|
|
using System.IO.Compression;
|
|
|
+using System.Linq;
|
|
|
using System.Net;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
-using System.Windows.Controls;
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
namespace LauncherIcarus
|
|
|
@@ -20,7 +20,8 @@ namespace LauncherIcarus
|
|
|
private readonly HttpRequest _httpRequest;
|
|
|
private readonly MainViewModel _mainViewModel;
|
|
|
private readonly FileConfig _fileConfig;
|
|
|
- private DirectoryInfo _lDir;
|
|
|
+ private DirectoryInfo _currentDirectory;
|
|
|
+ private DirectoryInfo _parentDirectory;
|
|
|
|
|
|
public MainWindow()
|
|
|
{
|
|
|
@@ -49,9 +50,10 @@ namespace LauncherIcarus
|
|
|
_mainViewModel.IsLogged = false;
|
|
|
_mainViewModel.Lang = _fileConfig.GetLanguage();
|
|
|
DataContext = _mainViewModel;
|
|
|
- wbSlide.Navigate(Configuration.Default.ServerIP + Configuration.Default.LauncherNewsUrl);
|
|
|
+ wbSlide.Navigate(Configuration.Default.ServerIp + Configuration.Default.LauncherNewsUrl);
|
|
|
AccountModel.Username = _fileConfig.GetUsername();
|
|
|
- _lDir = new DirectoryInfo(Environment.CurrentDirectory);
|
|
|
+ _currentDirectory = new DirectoryInfo(Environment.CurrentDirectory);
|
|
|
+ _parentDirectory = _currentDirectory.Parent;
|
|
|
|
|
|
if (AccountModel.Username != "")
|
|
|
{
|
|
|
@@ -68,9 +70,14 @@ namespace LauncherIcarus
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ if (_parentDirectory == null)
|
|
|
+ {
|
|
|
+ throw new DirectoryNotFoundException();
|
|
|
+ }
|
|
|
+
|
|
|
Process.Start(new ProcessStartInfo
|
|
|
{
|
|
|
- WorkingDirectory = _lDir.Parent.FullName,
|
|
|
+ WorkingDirectory = _parentDirectory.FullName,
|
|
|
FileName = "LauncherUpdater.exe",
|
|
|
CreateNoWindow = false
|
|
|
});
|
|
|
@@ -95,10 +102,10 @@ namespace LauncherIcarus
|
|
|
);
|
|
|
if (responseLogin?.Code == 0)
|
|
|
{
|
|
|
- _fileConfig.SetUsername(responseLogin.Accountinfo.Username);
|
|
|
+ _fileConfig.SetUsername(responseLogin.AccountInfo.Username);
|
|
|
AccountModel.Token = responseLogin.Token;
|
|
|
- AccountModel.Username = responseLogin.Accountinfo.Username;
|
|
|
- AccountModel.Version = responseLogin.Accountinfo.Version;
|
|
|
+ AccountModel.Username = responseLogin.AccountInfo.Username;
|
|
|
+ AccountModel.Version = responseLogin.AccountInfo.Version;
|
|
|
_fileConfig.SetLauncherIsChecked(EncryptionHelper.Encrypt("FALSE"));
|
|
|
lblWellcome.Visibility = Visibility.Visible;
|
|
|
lblWellcome.Content = "Seja bem vindo " + AccountModel.Username;
|
|
|
@@ -135,7 +142,8 @@ namespace LauncherIcarus
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- CheckClientFiles();
|
|
|
+ var task = CheckClientFiles();
|
|
|
+ task.Wait();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -150,68 +158,66 @@ namespace LauncherIcarus
|
|
|
Directory.CreateDirectory(Configuration.Default.DownloadDir);
|
|
|
}
|
|
|
|
|
|
+ //TODO: Проверка версии лаунчера выглядит как бесполезная.
|
|
|
var getVersionResponse = JsonConvert.DeserializeObject<ResponseLauncherVersion>(
|
|
|
await httpRequest.GetLauncherVersionAsync(AccountModel.Token, AccountModel.Username)
|
|
|
);
|
|
|
var getLauncherListResponse = JsonConvert.DeserializeObject<ResponseListLauncherFiles>(
|
|
|
- await httpRequest.GetLauncherListFilesAsync(AccountModel.Token, getVersionResponse.UpdaterVersion.ToString())
|
|
|
+ await httpRequest.GetLauncherListFilesAsync(
|
|
|
+ AccountModel.Token, $"{getVersionResponse?.UpdaterVersion}"
|
|
|
+ )
|
|
|
);
|
|
|
- if (getLauncherListResponse.TotalBytes > 0.0)
|
|
|
+ if (getLauncherListResponse?.TotalBytes > 0.0)
|
|
|
{
|
|
|
- double totalDownloaded = 0.0;
|
|
|
+ var totalDownloaded = 0.0;
|
|
|
mainWindow.progressBar.Width = 0.0;
|
|
|
mainWindow._mainViewModel.IsUpdating = true;
|
|
|
mainWindow.lblDownloadSpeed.Visibility = Visibility.Visible;
|
|
|
mainWindow.lblDownloadSpeedQtd.Visibility = Visibility.Visible;
|
|
|
mainWindow.lblFileDownloading.Visibility = Visibility.Visible;
|
|
|
mainWindow.lblFileDownloadingName.Visibility = Visibility.Visible;
|
|
|
- int LastVersion = 0;
|
|
|
- int ClientVersion = getVersionResponse.UpdaterVersion;
|
|
|
- mainWindow.lblTotalQtd.Content =
|
|
|
- (object) (Math.Round(getLauncherListResponse.TotalBytes / 1024.0, 2).ToString() + "MB");
|
|
|
- foreach (Files file in getLauncherListResponse.File)
|
|
|
+ var lastVersion = 0;
|
|
|
+ var clientVersion = getVersionResponse?.UpdaterVersion;
|
|
|
+ mainWindow.lblTotalQtd.Content = Math.Round(getLauncherListResponse.TotalBytes / 1024.0, 2) + "MB";
|
|
|
+ foreach (var file in getLauncherListResponse.File)
|
|
|
{
|
|
|
- LastVersion = (int) file.Version;
|
|
|
+ lastVersion = (int)file.Version;
|
|
|
double num1;
|
|
|
- if (LastVersion > ClientVersion)
|
|
|
+ if (lastVersion > clientVersion)
|
|
|
{
|
|
|
- Label lblAtualQtd = mainWindow.lblAtualQtd;
|
|
|
+ var lblAtualQtd = mainWindow.lblAtualQtd;
|
|
|
num1 = Math.Round(file.Size / 1024.0, 2);
|
|
|
- string str = num1.ToString() + "MB";
|
|
|
- lblAtualQtd.Content = (object) str;
|
|
|
- int num2 = await mainWindow.DownloadArchiveAsync(file.Filename,
|
|
|
- Configuration.Default.DownloadDir, file.Url)
|
|
|
- ? 1
|
|
|
- : 0;
|
|
|
+ var str = num1 + "MB";
|
|
|
+ lblAtualQtd.Content = str;
|
|
|
}
|
|
|
|
|
|
- double num3 = file.Size / getLauncherListResponse.TotalBytes * 656.0;
|
|
|
+ var num3 = file.Size / getLauncherListResponse.TotalBytes * 656.0;
|
|
|
totalDownloaded += file.Size;
|
|
|
- mainWindow.progressBar.Width += (double) (int) num3;
|
|
|
+ mainWindow.progressBar.Width += (int)num3;
|
|
|
mainWindow.ExtractFiles();
|
|
|
- Label totalAtualizadoQtd = mainWindow.lblTotalAtualizadoQtd;
|
|
|
+ var totalAtualizadoQtd = mainWindow.lblTotalAtualizadoQtd;
|
|
|
num1 = Math.Round(totalDownloaded / 1024.0, 2);
|
|
|
- string str1 = num1.ToString() + "MB";
|
|
|
- totalAtualizadoQtd.Content = (object) str1;
|
|
|
+ var str1 = num1 + "MB";
|
|
|
+ totalAtualizadoQtd.Content = str1;
|
|
|
}
|
|
|
|
|
|
+ //TODO: Запись версии лаунчера выглядит как бесполезная.
|
|
|
JsonConvert.DeserializeObject<ResponseLauncherVersion>(
|
|
|
- await httpRequest.UpdateLauncherVersionAsync(AccountModel.Token, LastVersion.ToString(),
|
|
|
- AccountModel.Username));
|
|
|
+ await httpRequest.UpdateLauncherVersionAsync(
|
|
|
+ AccountModel.Token, lastVersion.ToString(), AccountModel.Username
|
|
|
+ )
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
mainWindow._mainViewModel.IsUpdating = false;
|
|
|
- mainWindow.DataContext = (object) mainWindow._mainViewModel;
|
|
|
- mainWindow.lblTotalQtd.Content = (object) "0.0MB";
|
|
|
- mainWindow.lblTotalAtualizadoQtd.Content = (object) "0.0MB";
|
|
|
- mainWindow.lblAtualQtd.Content = (object) "0.0MB";
|
|
|
+ mainWindow.DataContext = mainWindow._mainViewModel;
|
|
|
+ mainWindow.lblTotalQtd.Content = "0.0MB";
|
|
|
+ mainWindow.lblTotalAtualizadoQtd.Content = "0.0MB";
|
|
|
+ mainWindow.lblAtualQtd.Content = "0.0MB";
|
|
|
mainWindow.lblDownloadSpeed.Visibility = Visibility.Hidden;
|
|
|
mainWindow.lblDownloadSpeedQtd.Visibility = Visibility.Hidden;
|
|
|
mainWindow.lblFileDownloading.Visibility = Visibility.Hidden;
|
|
|
mainWindow.lblFileDownloadingName.Visibility = Visibility.Hidden;
|
|
|
- httpRequest = (HttpRequest) null;
|
|
|
- getVersionResponse = (ResponseLauncherVersion) null;
|
|
|
- getLauncherListResponse = (ResponseListLauncherFiles) null;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
@@ -219,82 +225,82 @@ namespace LauncherIcarus
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public async Task CheckClientFiles()
|
|
|
+ private async Task CheckClientFiles()
|
|
|
{
|
|
|
- MainWindow mainWindow = this;
|
|
|
+ var mainWindow = this;
|
|
|
try
|
|
|
{
|
|
|
mainWindow.progressBar.Width = 0.0;
|
|
|
mainWindow._mainViewModel.IsChecking = true;
|
|
|
- double totalDownloaded = 0.0;
|
|
|
- Crc32 c = new Crc32();
|
|
|
- ResponseListLauncherFiles get =
|
|
|
- JsonConvert.DeserializeObject<ResponseListLauncherFiles>(
|
|
|
- await mainWindow._httpRequest.GetClientFilesCheckListAsync(AccountModel.Token));
|
|
|
- if (get.TotalBytes > 0.0)
|
|
|
+ var totalDownloaded = 0.0;
|
|
|
+ var c = new Crc32();
|
|
|
+ var get = JsonConvert.DeserializeObject<ResponseListLauncherFiles>(
|
|
|
+ await mainWindow._httpRequest.GetClientFilesCheckListAsync(AccountModel.Token)
|
|
|
+ );
|
|
|
+
|
|
|
+ if (get?.TotalBytes > 0.0)
|
|
|
{
|
|
|
- Label lblTotalQtd = mainWindow.lblTotalQtd;
|
|
|
- double num1 = Math.Round(get.TotalBytes / 1024.0, 2);
|
|
|
- string str1 = num1.ToString() + "MB";
|
|
|
- lblTotalQtd.Content = (object) str1;
|
|
|
+ var lblTotalQtd = mainWindow.lblTotalQtd;
|
|
|
+ var num1 = Math.Round(get.TotalBytes / 1024.0, 2);
|
|
|
+ var str1 = num1 + "MB";
|
|
|
+ lblTotalQtd.Content = str1;
|
|
|
mainWindow.lblDownloadSpeed.Visibility = Visibility.Visible;
|
|
|
mainWindow.lblDownloadSpeedQtd.Visibility = Visibility.Visible;
|
|
|
mainWindow.lblFileDownloading.Visibility = Visibility.Visible;
|
|
|
mainWindow.lblFileDownloadingName.Visibility = Visibility.Visible;
|
|
|
- foreach (Files k in get.File)
|
|
|
+ foreach (var k in get.File)
|
|
|
{
|
|
|
- string filename = k.Filename;
|
|
|
- string empty = string.Empty;
|
|
|
- string path = mainWindow._lDir.Parent.FullName + "\\" + k.Filename.Replace("/", "\\");
|
|
|
- Label lblAtualQtd = mainWindow.lblAtualQtd;
|
|
|
+ var filename = k.Filename;
|
|
|
+ var empty = string.Empty;
|
|
|
+ var path = _parentDirectory.FullName + "\\" + k.Filename.Replace("/", "\\");
|
|
|
+ var lblAtualQtd = mainWindow.lblAtualQtd;
|
|
|
num1 = Math.Round(k.Size / 1024.0, 2);
|
|
|
- string str2 = num1.ToString() + "MB";
|
|
|
- lblAtualQtd.Content = (object) str2;
|
|
|
- if (System.IO.File.Exists(path))
|
|
|
+ var str2 = num1 + "MB";
|
|
|
+ lblAtualQtd.Content = str2;
|
|
|
+ if (File.Exists(path))
|
|
|
{
|
|
|
- using (FileStream inputStream = System.IO.File.Open(path, FileMode.Open))
|
|
|
+ using (var inputStream = File.Open(path, FileMode.Open))
|
|
|
{
|
|
|
- foreach (byte num2 in c.ComputeHash((Stream) inputStream))
|
|
|
+ foreach (var num2 in c.ComputeHash(inputStream))
|
|
|
+ {
|
|
|
empty += num2.ToString("x2").ToLower();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (k.Crc32 != empty)
|
|
|
{
|
|
|
- int num3 = await mainWindow.DownloadArchiveAsync(filename,
|
|
|
- mainWindow._lDir.Parent.FullName, k.Url)
|
|
|
+ var num3 = await mainWindow
|
|
|
+ .DownloadArchiveAsync(filename, _parentDirectory.FullName, k.Url)
|
|
|
? 1
|
|
|
: 0;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- int num4 = await mainWindow.DownloadArchiveAsync(filename, mainWindow._lDir.Parent.FullName,
|
|
|
- k.Url)
|
|
|
+ var num4 = await mainWindow.DownloadArchiveAsync(filename, _parentDirectory.FullName, k.Url)
|
|
|
? 1
|
|
|
: 0;
|
|
|
}
|
|
|
|
|
|
totalDownloaded += k.Size;
|
|
|
- double num5 = k.Size / get.TotalBytes * 656.0;
|
|
|
- Label totalAtualizadoQtd = mainWindow.lblTotalAtualizadoQtd;
|
|
|
+ var num5 = k.Size / get.TotalBytes * 656.0;
|
|
|
+ var totalAtualizadoQtd = mainWindow.lblTotalAtualizadoQtd;
|
|
|
num1 = Math.Round(totalDownloaded / 1024.0, 2);
|
|
|
- string str3 = num1.ToString() + "MB";
|
|
|
- totalAtualizadoQtd.Content = (object) str3;
|
|
|
+ var str3 = num1 + "MB";
|
|
|
+ totalAtualizadoQtd.Content = str3;
|
|
|
mainWindow.progressBar.Width += Math.Round(num5, 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
mainWindow._mainViewModel.IsChecking = false;
|
|
|
- mainWindow.DataContext = (object) mainWindow._mainViewModel;
|
|
|
- mainWindow.lblTotalQtd.Content = (object) "0.0MB";
|
|
|
- mainWindow.lblTotalAtualizadoQtd.Content = (object) "0.0MB";
|
|
|
- mainWindow.lblAtualQtd.Content = (object) "0.0MB";
|
|
|
+ mainWindow.DataContext = mainWindow._mainViewModel;
|
|
|
+ mainWindow.lblTotalQtd.Content = "0.0MB";
|
|
|
+ mainWindow.lblTotalAtualizadoQtd.Content = "0.0MB";
|
|
|
+ mainWindow.lblAtualQtd.Content = "0.0MB";
|
|
|
mainWindow.lblDownloadSpeed.Visibility = Visibility.Hidden;
|
|
|
mainWindow.lblDownloadSpeedQtd.Visibility = Visibility.Hidden;
|
|
|
mainWindow.lblFileDownloading.Visibility = Visibility.Hidden;
|
|
|
mainWindow.lblFileDownloadingName.Visibility = Visibility.Hidden;
|
|
|
- c = (Crc32) null;
|
|
|
- get = (ResponseListLauncherFiles) null;
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
@@ -307,55 +313,56 @@ namespace LauncherIcarus
|
|
|
string downloadPath,
|
|
|
string url)
|
|
|
{
|
|
|
- DateTime _startedAt = DateTime.Now;
|
|
|
- DownloadProgressChangedEventHandler changedEventHandler = (DownloadProgressChangedEventHandler) ((s, e) =>
|
|
|
+ var startedAt = DateTime.Now;
|
|
|
+
|
|
|
+ void ChangedEventHandler(object s, DownloadProgressChangedEventArgs e)
|
|
|
{
|
|
|
- if (_startedAt == new DateTime())
|
|
|
+ if (startedAt == new DateTime())
|
|
|
{
|
|
|
- _startedAt = DateTime.Now;
|
|
|
+ startedAt = DateTime.Now;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- TimeSpan timeSpan = DateTime.Now - _startedAt;
|
|
|
- if (timeSpan.TotalSeconds <= 0.0)
|
|
|
- return;
|
|
|
- this.lblDownloadSpeedQtd.Content = (object) string.Format("{0} MB/s",
|
|
|
- (object) Math.Round((double) e.BytesReceived / (timeSpan.TotalSeconds * 1000000.0), 2));
|
|
|
- this.lblFileDownloadingName.Content = (object) filename;
|
|
|
+ var timeSpan = DateTime.Now - startedAt;
|
|
|
+ if (timeSpan.TotalSeconds <= 0.0) return;
|
|
|
+ lblDownloadSpeedQtd.Content =
|
|
|
+ $"{Math.Round(e.BytesReceived / (timeSpan.TotalSeconds * 1000000.0), 2)} MB/s";
|
|
|
+ lblFileDownloadingName.Content = filename;
|
|
|
}
|
|
|
- });
|
|
|
- DownloadDataCompletedEventHandler completedEventHandler =
|
|
|
- (DownloadDataCompletedEventHandler) ((s, e) => { });
|
|
|
- int num1 = filename.IndexOf("/");
|
|
|
- string str = filename;
|
|
|
+ }
|
|
|
+
|
|
|
+ DownloadDataCompletedEventHandler completedEventHandler = (s, e) => { };
|
|
|
+ var num1 = filename.IndexOf("/", StringComparison.Ordinal);
|
|
|
string fileName;
|
|
|
if (num1 > 0)
|
|
|
{
|
|
|
- int num2 = 0;
|
|
|
- string[] strArray = filename.Split(new string[1]
|
|
|
- {
|
|
|
- "/"
|
|
|
- }, StringSplitOptions.None);
|
|
|
+ var num2 = 0;
|
|
|
+ var strArray = filename.Split(new[] { "/" }, StringSplitOptions.None);
|
|
|
downloadPath += "\\";
|
|
|
- for (int index = 0; index < strArray.Length - 1; ++index)
|
|
|
+ for (var index = 0; index < strArray.Length - 1; ++index)
|
|
|
{
|
|
|
downloadPath = downloadPath + strArray[index] + "\\";
|
|
|
num2 = index;
|
|
|
}
|
|
|
|
|
|
if (!Directory.Exists(downloadPath))
|
|
|
+ {
|
|
|
Directory.CreateDirectory(downloadPath);
|
|
|
+ }
|
|
|
+
|
|
|
fileName = downloadPath + strArray[num2 + 1].Replace("/", "\\");
|
|
|
Logger.WriteLog(filename);
|
|
|
}
|
|
|
else
|
|
|
+ {
|
|
|
fileName = downloadPath + filename;
|
|
|
+ }
|
|
|
|
|
|
- using (WebClient webClient = new WebClient())
|
|
|
+ using (var webClient = new WebClient())
|
|
|
{
|
|
|
- webClient.DownloadProgressChanged += changedEventHandler;
|
|
|
+ webClient.DownloadProgressChanged += ChangedEventHandler;
|
|
|
webClient.DownloadDataCompleted += completedEventHandler;
|
|
|
- await webClient.DownloadFileTaskAsync(new Uri(Configuration.Default.ServerIP + url), fileName);
|
|
|
+ await webClient.DownloadFileTaskAsync(new Uri(Configuration.Default.ServerIp + url), fileName);
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
@@ -365,32 +372,30 @@ namespace LauncherIcarus
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- foreach (string file in Directory.GetFiles(Configuration.Default.DownloadDir, "*.zip"))
|
|
|
+ foreach (var file in Directory.GetFiles(Configuration.Default.DownloadDir, "*.zip"))
|
|
|
{
|
|
|
- using (ZipArchive zipArchive = ZipFile.Open(file, ZipArchiveMode.Read))
|
|
|
+ using (var zipArchive = ZipFile.Open(file, ZipArchiveMode.Read))
|
|
|
{
|
|
|
- foreach (ZipArchiveEntry entry in zipArchive.Entries)
|
|
|
+ foreach (var entry in zipArchive.Entries)
|
|
|
{
|
|
|
if (entry.Length > 0L || entry.Name != "")
|
|
|
{
|
|
|
- entry.ExtractToFile(Path.Combine(this._lDir.Parent.FullName, entry.FullName), true);
|
|
|
+ entry.ExtractToFile(Path.Combine(_parentDirectory.FullName, entry.FullName), true);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- string[] strArray = entry.FullName.Split(new string[1]
|
|
|
+ var strArray = entry.FullName.Split(new[] { "/" }, StringSplitOptions.None);
|
|
|
+ var path2 = strArray.Aggregate("", (current, t) => current + t + "/");
|
|
|
+
|
|
|
+ if (!Directory.Exists(Path.Combine(_parentDirectory.FullName, path2)))
|
|
|
{
|
|
|
- "/"
|
|
|
- }, StringSplitOptions.None);
|
|
|
- string path2 = "";
|
|
|
- for (int index = 0; index < strArray.Length; ++index)
|
|
|
- path2 = path2 + strArray[index] + "/";
|
|
|
- if (!Directory.Exists(Path.Combine(this._lDir.Parent.FullName, path2)))
|
|
|
- Directory.CreateDirectory(Path.Combine(this._lDir.Parent.FullName, path2));
|
|
|
+ Directory.CreateDirectory(Path.Combine(_parentDirectory.FullName, path2));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- System.IO.File.Delete(file);
|
|
|
+ File.Delete(file);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
@@ -408,7 +413,7 @@ namespace LauncherIcarus
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- var folder = _lDir.Parent?.FullName.Replace("Launcher", "");
|
|
|
+ var folder = _parentDirectory.FullName.Replace("Launcher", "");
|
|
|
var sw = new StreamWriter(folder + @"\start.bat");
|
|
|
sw.WriteLine(
|
|
|
$"cd {folder} && start Bin64/Launcher.exe /i:{AccountModel.Token} /r:123456 /O /u:3913056 /m:P");
|
|
|
@@ -427,59 +432,64 @@ namespace LauncherIcarus
|
|
|
private void Window_MouseMove(object sender, MouseEventArgs e)
|
|
|
{
|
|
|
if (e.LeftButton != MouseButtonState.Pressed)
|
|
|
+ {
|
|
|
return;
|
|
|
- this.DragMove();
|
|
|
+ }
|
|
|
+
|
|
|
+ DragMove();
|
|
|
}
|
|
|
|
|
|
private async void cmbLanguage_DropDownClosed(object sender, EventArgs e)
|
|
|
{
|
|
|
- MainWindow mainWindow = this;
|
|
|
+ var mainWindow = this;
|
|
|
try
|
|
|
{
|
|
|
if (mainWindow._fileConfig.GetLanguage() != mainWindow._mainViewModel.Lang &&
|
|
|
mainWindow._mainViewModel.Lang != string.Empty)
|
|
|
{
|
|
|
mainWindow._fileConfig.SetLanguage(mainWindow._mainViewModel.Lang);
|
|
|
- HttpRequest httpRequest = new HttpRequest();
|
|
|
+ var httpRequest = new HttpRequest();
|
|
|
if (!Directory.Exists(Configuration.Default.DownloadDir))
|
|
|
Directory.CreateDirectory(Configuration.Default.DownloadDir);
|
|
|
- ResponseListLauncherFiles listLauncherFiles =
|
|
|
- JsonConvert.DeserializeObject<ResponseListLauncherFiles>(
|
|
|
- await httpRequest.GetLauncherTranslateAsync());
|
|
|
- if (listLauncherFiles.TotalBytes > 0.0)
|
|
|
+ var listLauncherFiles = JsonConvert.DeserializeObject<ResponseListLauncherFiles>(
|
|
|
+ await httpRequest.GetLauncherTranslateAsync()
|
|
|
+ );
|
|
|
+ if (listLauncherFiles?.TotalBytes > 0.0)
|
|
|
{
|
|
|
- double totalDownloaded = 0.0;
|
|
|
+ var totalDownloaded = 0.0;
|
|
|
mainWindow.progressBar.Width = 0.0;
|
|
|
mainWindow._mainViewModel.IsUpdating = true;
|
|
|
mainWindow.lblDownloadSpeed.Visibility = Visibility.Visible;
|
|
|
mainWindow.lblDownloadSpeedQtd.Visibility = Visibility.Visible;
|
|
|
mainWindow.lblFileDownloading.Visibility = Visibility.Visible;
|
|
|
mainWindow.lblFileDownloadingName.Visibility = Visibility.Visible;
|
|
|
- foreach (Files file in listLauncherFiles.File)
|
|
|
+ foreach (var file in listLauncherFiles.File)
|
|
|
{
|
|
|
- if (file.Filename == mainWindow._mainViewModel.Lang.ToLower() + ".zip")
|
|
|
+ if (file.Filename != mainWindow._mainViewModel.Lang.ToLower() + ".zip")
|
|
|
{
|
|
|
- var lblTotalQtd = mainWindow.lblTotalQtd;
|
|
|
- var num1 = Math.Round(file.Size / 1024.0, 2);
|
|
|
- var str1 = num1 + "MB";
|
|
|
- lblTotalQtd.Content = str1;
|
|
|
- Label lblAtualQtd = mainWindow.lblAtualQtd;
|
|
|
- num1 = Math.Round(file.Size / 1024.0, 2);
|
|
|
- var str2 = num1 + "MB";
|
|
|
- lblAtualQtd.Content = str2;
|
|
|
- var num2 = await mainWindow.DownloadArchiveAsync(file.Filename,
|
|
|
- Configuration.Default.DownloadDir, file.Url)
|
|
|
- ? 1
|
|
|
- : 0;
|
|
|
- var num3 = file.Size / file.Size * 656.0;
|
|
|
- totalDownloaded += file.Size;
|
|
|
- mainWindow.progressBar.Width += (int) num3;
|
|
|
- mainWindow.ExtractFiles();
|
|
|
- var totalAtualizadoQtd = mainWindow.lblTotalAtualizadoQtd;
|
|
|
- num1 = Math.Round(totalDownloaded / 1024.0, 2);
|
|
|
- var str3 = num1 + "MB";
|
|
|
- totalAtualizadoQtd.Content = str3;
|
|
|
+ continue;
|
|
|
}
|
|
|
+
|
|
|
+ var lblTotalQtd = mainWindow.lblTotalQtd;
|
|
|
+ var num1 = Math.Round(file.Size / 1024.0, 2);
|
|
|
+ var str1 = num1 + "MB";
|
|
|
+ lblTotalQtd.Content = str1;
|
|
|
+ var lblAtualQtd = mainWindow.lblAtualQtd;
|
|
|
+ num1 = Math.Round(file.Size / 1024.0, 2);
|
|
|
+ var str2 = num1 + "MB";
|
|
|
+ lblAtualQtd.Content = str2;
|
|
|
+ var num2 = await mainWindow
|
|
|
+ .DownloadArchiveAsync(file.Filename, Configuration.Default.DownloadDir, file.Url)
|
|
|
+ ? 1
|
|
|
+ : 0;
|
|
|
+ var num3 = file.Size / file.Size * 656.0;
|
|
|
+ totalDownloaded += file.Size;
|
|
|
+ mainWindow.progressBar.Width += (int)num3;
|
|
|
+ mainWindow.ExtractFiles();
|
|
|
+ var totalAtualizadoQtd = mainWindow.lblTotalAtualizadoQtd;
|
|
|
+ num1 = Math.Round(totalDownloaded / 1024.0, 2);
|
|
|
+ var str3 = num1 + "MB";
|
|
|
+ totalAtualizadoQtd.Content = str3;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -494,7 +504,9 @@ namespace LauncherIcarus
|
|
|
mainWindow.lblFileDownloadingName.Visibility = Visibility.Hidden;
|
|
|
}
|
|
|
else
|
|
|
+ {
|
|
|
mainWindow.lblMsgStatus.Content = "Escolha um idioma para continuar!";
|
|
|
+ }
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|