Modal
This is how I spend my days… and I like it. Throw on some tunes, a little Punk, a lot of Metal and a touch of eletronica. Green Day is playing right now. Ozzy was the previous and Emigrate before that. Add Red Bull and a burrito and I’m off.
54 public void DownloadPlugin(object sender, EventArgs e)
55 {
56
57 PluginWebServiceDomain.PluginService service = new PluginWebServiceDomain.PluginService();
58 service.Credentials = CredentialCache.DefaultCredentials;
59 PluginWebServiceDomain.PluginEntity[] plugins = service.GetPlugins();
60
61 pluginDestination = Path.Combine(pluginPath, pluginLoadInfo.CustomAttributes.Guid.ToString());
62
63 Uri downloadUri = new Uri(string.Format("{0}?Guid={1}", Properties.Settings.Default.Nwea_UnifiedModuleManager_WebHandlerAddress, pluginLoadInfo.CustomAttributes.Guid.ToString()));
64 pluginZipFile = Path.Combine(pluginPath, string.Format("{0}.zip", pluginLoadInfo.CustomAttributes.Guid.ToString()));
65
66 webClient.Credentials = System.Net.CredentialCache.DefaultCredentials;
67 webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(webClient_DownloadFileCompleted);
68 webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webClient_DownloadProgressChanged);
69
70 Debug.WriteLine(string.Format("Plugin '{0}' \n\tdownloaded to path '{1}'\n\t from {2}.", pluginLoadInfo.CustomAttributes.Guid.ToString(), pluginZipFile, downloadUri));
71
72 //webClient.DownloadFile(downloadUri, pluginZipFile);
73 webClient.DownloadFileAsync(downloadUri, pluginZipFile);
74
75 }
76
77 void webClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
78 {
79
80 Debug.WriteLine("e values: Bytes Received" + e.BytesReceived.ToString() + e.ProgressPercentage + e.TotalBytesToReceive + e.UserState
81 // reset the download size
82 if ((downloadSize == 0) && (e.TotalBytesToReceive != -1))
83 downloadSize = e.TotalBytesToReceive;
84
85 if (downloadSize != 0)
86 {
87 int delta = (int) ( ( (decimal) e.BytesReceived / (decimal) downloadSize ) * 100 );
88 if (delta > ( progressBarDownloadStatus.Value + 10 ))
89 {
90 progressBarDownloadStatus.PerformStep();
91 progressBarDownloadStatus.Update();
92 }
93 }
94
95 }
96
97 void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
98 {
99
100 FinalizeProgressBar();
101 UnzipPackage();
102 Close();
103
104 }
