-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDownloaderBox.cs
More file actions
96 lines (85 loc) · 3.65 KB
/
DownloaderBox.cs
File metadata and controls
96 lines (85 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* LauncherShyax, un launcher pour World Of Warcraft avec téléchargement de mise à jour
Copyright (C) 2011 Shyax — Tous droits réservés.
Ce programme est un logiciel libre ; vous pouvez le redistribuer ou le
modifier suivant les termes de la “GNU General Public License” telle que
publiée par la Free Software Foundation : soit la version 3 de cette
licence, soit (à votre gré) toute version ultérieure.
Ce programme est distribué dans l’espoir qu’il vous sera utile, mais SANS
AUCUNE GARANTIE : sans même la garantie implicite de COMMERCIALISABILITÉ
ni d’ADÉQUATION À UN OBJECTIF PARTICULIER. Consultez la Licence Générale
Publique GNU pour plus de détails.
Vous devriez avoir reçu une copie de la Licence Générale Publique GNU avec
ce programme ; si ce n’est pas le cas, consultez :
<http://www.gnu.org/licenses/>.
* */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Xml;
using System.Windows.Forms;
namespace LauncherShyax
{
public partial class DownloaderBox : Form
{
public DownloaderBox()
{
InitializeComponent();
}
private void DownloaderBox_Load(object sender, EventArgs e)
{
}
/// <summary>
/// Download the MPQ Files which are in nodeList and not in mpqFiles
/// </summary>
/// <param name="nodeList">Node List existing in version.xml</param>
/// <param name="mpqFiles">MPQ Files existing in Data/ directory</param>
/// <param name="dataDir">Absolute path to Data/ directory</param>
public void Download(XmlNodeList nodeList, FileInfo[] mpqFiles, string dataDir)
{
DialogResult result = MessageBox.Show("Une nouvelle mise à jour a été trouvée !\r\n Télécharger ?", "Avertissement", MessageBoxButtons.OKCancel);
if (result == DialogResult.Cancel)
{
Close();
}
else
{
foreach (XmlNode node in nodeList)
{
if (!mpqFiles.Contains(new FileInfo(node.InnerText)))
{
// Have to create two WebClient
WebClient webClient = new WebClient();
WebClient webClient2 = new WebClient();
labelDl.Text = "Téléchargement de la mise à jour : " + node.Attributes["nom"].Value;
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
webClient2.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient2_DownloadStringCompleted);
webClient2.DownloadStringAsync(new Uri(node.Attributes["desc"].Value));
webClient.DownloadFileAsync(new Uri(node.Attributes["lien"].Value), Path.Combine(dataDir, node.InnerText));
}
}
buttonClose.Visible = true;
}
}
#region Events
void webClient2_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
labelMaj.Text = e.Result;
}
void webClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
progressBarDl.Value = (int)(e.BytesReceived*100/e.TotalBytesToReceive);
}
private void buttonClose_Click(object sender, EventArgs e)
{
Close();
}
#endregion
}
}