• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Net.DownloadDataCompletedEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Net.DownloadDataCompletedEventArgs的典型用法代码示例。如果您正苦于以下问题:C# DownloadDataCompletedEventArgs类的具体用法?C# DownloadDataCompletedEventArgs怎么用?C# DownloadDataCompletedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DownloadDataCompletedEventArgs类属于System.Net命名空间,在下文中一共展示了DownloadDataCompletedEventArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: client_DownloadDataCompleted

        void client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            if (e.Cancelled || e.Error != null)
            {
                return;
            }

            int width = 200;
            int height = 200;

            if (e.UserState != null)
            {
                FlickrNet.Photo photo = (FlickrNet.Photo)e.UserState;

                width = photo.SmallWidth.HasValue ? photo.SmallWidth.Value : width;
                height = photo.SmallHeight.HasValue ? photo.SmallHeight.Value : height;
            }

            byte[] imageData = e.Result;
            PictureBox pictureBox = new PictureBox();
            pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox.Size = new Size(width, height);

            using (MemoryStream stream = new MemoryStream(imageData))
            {
                pictureBox.Image = Image.FromStream(stream);
            }

            progressBar1.PerformStep();

            flowLayoutPanel1.Controls.Add(pictureBox);
        }
开发者ID:usmanghani,项目名称:Quantae,代码行数:32,代码来源:Form1.cs


示例2: mClient_DownloadDataCompleted

		void mClient_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
		{

			RunOnUiThread(() =>
				{
					string json = Encoding.UTF8.GetString(e.Result);
					if (json == "Sem Registro")
					{
						lProduto = new List<RegistroProdutos>();
						mProdutoAdapter = new ProdutosViewAdapter(this, Resource.Layout.ProdutosListItem, lProduto);
						lstProdutoView.Adapter = mProdutoAdapter;

						AlertDialog.Builder builder = new AlertDialog.Builder(this);
						builder.SetMessage("Seleção sem Registro");
						builder.SetCancelable(false);
						builder.SetPositiveButton("OK", delegate {builder.Dispose(); });
						builder.Show();
						return;

					} else {

						lProduto = JsonConvert.DeserializeObject<List<RegistroProdutos>>(json);
						mProdutoAdapter = new ProdutosViewAdapter(this, Resource.Layout.ProdutosListItem, lProduto);
						lstProdutoView.Adapter = mProdutoAdapter;
						mProgressBar.Visibility = ViewStates.Gone;
					}
				});
		} 
开发者ID:RMDesenvolvimento,项目名称:Xamarin,代码行数:28,代码来源:ProdutosList.cs


示例3: webClient_DownloadRssCompleted

 private void webClient_DownloadRssCompleted(object sender, DownloadDataCompletedEventArgs e)
 {
     if (!e.Cancelled)
     {
         try
         {
             if (e.Error != null)
             {
                 throw e.Error;
             }
             else
             {
                 toolStripStatusLabel1.Text = "";
                 RssListViewItem r = e.UserState as RssListViewItem;
                 r.channel = new RssChannel(new MemoryStream(e.Result));
                 if (r.channel.Image.Url != null && Uri.IsWellFormedUriString(r.channel.Image.Url, UriKind.Absolute) && !FeedImageList.Images.ContainsKey(r.Name))
                 {
                     imageWebClient.CancelAsync();
                     imageWebClient.DownloadDataAsync(new Uri(r.channel.Image.Url), r);
                 }
                 FillListView(r.channel);
             }
         }
         catch (Exception ee)
         {
             HandleException(ee);
         }
     }
 }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:29,代码来源:RssForm.cs


示例4: cl_DownloadDataCompleted

        private void cl_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            var lab = e.UserState as Label;

            if (e.Cancelled)
            {
                if (lab != null)
                {
                    lab.Text = LanguageHolder.Instance()[WordEnum.CANCEL_BY_USER];
                }
                return;
            }

            if (e.Error != null)
            {
                if (lab != null)
                {
                    lab.Text = LanguageHolder.Instance()[WordEnum.PROBLEM_WITH_INTERNET];
                }
                return;
            }
            byte[] data = e.Result;

            RefreshNews0(lab, data);
        }
开发者ID:VISTALL,项目名称:game-updater,代码行数:25,代码来源:RSSPanel.cs


示例5: Completed

        private void Completed(object sender, DownloadDataCompletedEventArgs e)
        {
            int major, minor, build;

            var raw = e.Result;
            var file = Encoding.UTF8.GetString(raw);
            var regex = new Regex(@"#define _AppVersion ""(\d+)\.(\d+)\.(\d+)""");
            var match = regex.Match(file);

            if (match.Groups.Count == 4)
            {
                if (Int32.TryParse(match.Groups[1].ToString(), out major) &&
                    Int32.TryParse(match.Groups[2].ToString(), out minor) &&
                    Int32.TryParse(match.Groups[3].ToString(), out build))
                {
                    var verRemote = new Version(major, minor, build);
                    var assembly = Assembly.GetExecutingAssembly();
                    var verLocal = assembly.GetName().Version;

                    if (verRemote > verLocal)
                        textUpdate.Text = String.Format(Properties.Resources.UpdateAvailable0,
                            verRemote.ToString());
                    else
                        textUpdate.Text = Properties.Resources.NoUpdateAvailable;
                }
                else
                    textUpdate.Text = Properties.Resources.CheckFailed;
            }
            else
                textUpdate.Text = Properties.Resources.CheckFailed; ;
        }
开发者ID:EarToEarOak,项目名称:Location-Bridge,代码行数:31,代码来源:WindowUpdate.xaml.cs


示例6: DownloadCompleted

 private static void DownloadCompleted(IRuntime runtime, int caller, DownloadDataCompletedEventArgs e)
 {
     // item 255
     if (e.Cancelled) {
     // item 258
     runtime.SendMessage(
         caller,
         Cancel,
         null,
         0
     );
     } else {
     // item 259
     if (e.Error == null) {
         // item 262
         runtime.SendMessage(
             caller,
             CallResult.Completed,
             e.Result,
             0
         );
     } else {
         // item 261
         runtime.SendMessage(
             caller,
             CallResult.Error,
             e.Error,
             0
         );
     }
     }
 }
开发者ID:snjee,项目名称:actor-http,代码行数:32,代码来源:GuiMachines.cs


示例7: client_DownloadDataCompleted

        private void client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                GoEnd(WordEnum.CANCEL_BY_USER);
                return;
            }

            if (e.Error != null)
            {
                if (e.Error is WebException)
                {
                    GoEnd(WordEnum.PROBLEM_WITH_INTERNET);
                    return;
                }
                else
                {
                    _log.Info("Exception: while downloading list: " + e.Error.Message, e.Error);

                    GoEnd(WordEnum.ERROR_DOWNLOAD_LIST);
                    return;
                }
            }

            if (e.Result == null)
            {
                GoEnd(WordEnum.PROBLEM_WITH_SERVER);
                return;
            }

            GoNextStep(e.Result);
        }
开发者ID:VISTALL,项目名称:game-updater,代码行数:32,代码来源:GUListLoaderTask.cs


示例8: downloader_DownloadDataCompleted

        private void downloader_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            //progressBar1.Value = (int)e.BytesReceived;
            //progressBar1.Maximum = (int)e.TotalBytesToReceive;
            //this.lblPercent.Text = String.Format("已完成 {0}%  {1} 字节/{2} 字节", progressBar1.Value * 100 / progressBar1.Maximum, progressBar1.Value, progressBar1.Maximum);

            byte[] fileBytes = e.Result;
            FileItem fileItem = e.UserState as FileItem;
            string currentFolder = Application.StartupPath;
            var tempFolderInfo = Directory.CreateDirectory(currentFolder + "\\" + Constants.TEMP_DIRECTORY_FOR_DOWNLOAD);

            // use a temporary download location in case something goes wrong, we don't want to
            // corrupt the program and make it unusable without making the user manually delete files.
            string temporaryFilePath = tempFolderInfo.FullName + "\\" + fileItem.FileName;
            System.IO.File.WriteAllBytes(temporaryFilePath, fileBytes);

            //copy file
            if (File.Exists(tempFolderInfo + "\\" + fileItem.FileName))
            {
                File.Copy(tempFolderInfo + "\\" + fileItem.FileName, currentFolder + "\\" + fileItem.FileName, true);
            }
            //Thread.Sleep(3000);
            // delete temp directory
            Directory.Delete(currentFolder + "\\" + Constants.TEMP_DIRECTORY_FOR_DOWNLOAD, true);
            this.Close();
        }
开发者ID:Jackie2014,项目名称:W1-IPC,代码行数:26,代码来源:progressForm.cs


示例9: OnDownloadComplete

        private void OnDownloadComplete(object sender, DownloadDataCompletedEventArgs e)
        {
            try
            {

                if (!e.Cancelled)
                {
                    while (File.Exists(Destination))
                    {
                        string[] temp = Destination.Split('.');
                        Destination = temp[0] + "_." + temp[1];
                    }
                    BinaryWriter bw = new BinaryWriter(new FileStream(Destination, FileMode.CreateNew));
                    bw.Write(e.Result);
                    bw.Close();
                }
                CallProcess(new ExcutionResult(ResultFlag.Result, "", "Download complete :\r\n" + Destination));
                DownloadCmdList.Remove(this);
            }catch(Exception ex)
            {
                CallProcess(new ExcutionResult(ResultFlag.Error, "", "Download Error :\r\n" + ex.ToString()));
                DownloadCmdList.Remove(this);

            }
        }
开发者ID:charuwat,项目名称:code,代码行数:25,代码来源:DownloadCommand.cs


示例10: mClient_DownloadDataCompleted

		void mClient_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
		{

			RunOnUiThread(() =>
				{
					string json = Encoding.UTF8.GetString(e.Result);
					if ((json == "Usuario ou Senha nao encontrado") || (json == "Usuario ou Senha sem preenchimento"))
					{

						AlertDialog.Builder builder = new AlertDialog.Builder(this);
						builder.SetMessage(json);
						builder.SetCancelable(false);
						builder.SetPositiveButton("OK", delegate {builder.Dispose(); });
						builder.Show();
						return;

					} else {
						
						lUsuario = JsonConvert.DeserializeObject<List<RegistroUsuario>>(json);

						AlertCenter.Default.BackgroundColor = Color.White;
						AlertCenter.Default.PostMessage ("Seja Bem Vindo", lUsuario[0].nome,Resource.Drawable.Icon);

						StartActivity(typeof(MenuPrincipal));
						this.Finish();
					}
				});
		} 
开发者ID:RMDesenvolvimento,项目名称:Xamarin,代码行数:28,代码来源:MainActivity.cs


示例11: OnImageReady

        static void OnImageReady(object sender, DownloadDataCompletedEventArgs e)
        {
            AsyncImage d = e.UserState as AsyncImage;

            if (d == null)
                return;

            if (e.Error != null)
            {
                d.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback(a =>
                {
                    d.Source = null;
                    d.Visibility = Visibility.Collapsed;
                    return null;
                }), null);
                return;
            }

            byte[] data = e.Result;
            if (data == null)
                return;

            d.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new DispatcherOperationCallback(a =>
            {
                MemoryStream stream = new MemoryStream(data);
                BitmapImage imageSource = new BitmapImage();
                imageSource.BeginInit();
                imageSource.StreamSource = stream;
                imageSource.EndInit();
                d.Source = imageSource;

                return null;
            }), null);
        }
开发者ID:headdetect,项目名称:Chatterbox-Desktop,代码行数:34,代码来源:AsyncImage.xaml.cs


示例12: _wc_DownloadDataCompleted

 void _wc_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
 {
     if (!e.Cancelled && e.Error == null)
     {
         _owner.LoadCompleted(e.Result, e.UserState as string);
     }
 }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:7,代码来源:ImageDownloader.cs


示例13: client_DownloadDataCompleted

		void client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
		{
			try // if we get a bad result we can get a target invocation exception. In that case just don't show anything
			{
				byte[] raw = e.Result;
				Stream stream = new MemoryStream(raw);
				ImageBuffer unScaledImage = new ImageBuffer(10, 10, 32, new BlenderBGRA());
				StaticData.Instance.LoadImageData(stream, unScaledImage);
				// If the source image (the one we downloaded) is more than twice as big as our dest image.
				while (unScaledImage.Width > Image.Width * 2)
				{
					// The image sampler we use is a 2x2 filter so we need to scale by a max of 1/2 if we want to get good results.
					// So we scale as many times as we need to to get the Image to be the right size.
					// If this were going to be a non-uniform scale we could do the x and y separately to get better results.
					ImageBuffer halfImage = new ImageBuffer(unScaledImage.Width / 2, unScaledImage.Height / 2, 32, scalingBlender);
					halfImage.NewGraphics2D().Render(unScaledImage, 0, 0, 0, halfImage.Width / (double)unScaledImage.Width, halfImage.Height / (double)unScaledImage.Height);
					unScaledImage = halfImage;
				}
				Image.NewGraphics2D().Render(unScaledImage, 0, 0, 0, Image.Width / (double)unScaledImage.Width, Image.Height / (double)unScaledImage.Height);
				Image.MarkImageChanged();
				Invalidate();

				if (LoadComplete != null)
				{
					LoadComplete(this, null);
				}
			}
			catch (Exception)
			{
				GuiWidget.BreakInDebugger();
			}
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:32,代码来源:ImageWidget_AsyncLoadOnDraw.cs


示例14: snapshot_DownloadDataCompleted

        void snapshot_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            mainForm.statusBar.Value = 0;
            if (e.Error != null) {
                MessageBox.Show(e.Error.Message);
            }
            byte[] webPage = { };
            webPage = e.Result;

            String lineArray = Encoding.UTF8.GetString(webPage);
            String[] lines = lineArray.Split(new Char[] { });
            int i = 0;
            bool b = false;
            while (b != true) {
                if (lines[i].Contains("assets") & lines[i].Contains("minecraft.jar")) {
                    mainForm.link = lines[i];
                    mainForm.link = mainForm.link.Substring(6, mainForm.link.Length - 6); // Remove first 6.
                    mainForm.link = mainForm.link.Substring(0, mainForm.link.IndexOf("\""));
                    String[] mysplit = mainForm.link.Split('/');
                    mainForm.version = mysplit[3];
                    b = true;
                }
                i++;
            }

            Download download = new Download(mainForm);
            download.downloadAndInstall();
        }
开发者ID:umby24,项目名称:Resolute-Launcher,代码行数:28,代码来源:Snapshot.cs


示例15: GZipUtf8ResultToString

        public static string GZipUtf8ResultToString(DownloadDataCompletedEventArgs e)
        {
            if(e.Cancelled || (e.Error != null) || (e.Result == null))
                return null;

            MemoryStream msZipped = new MemoryStream(e.Result);
            GZipStream gz = new GZipStream(msZipped, CompressionMode.Decompress);
            BinaryReader br = new BinaryReader(gz);
            MemoryStream msUTF8 = new MemoryStream();

            while(true)
            {
                byte[] pb = null;

                try { pb = br.ReadBytes(4096); }
                catch(Exception) { }

                if((pb == null) || (pb.Length == 0)) break;

                msUTF8.Write(pb, 0, pb.Length);
            }

            br.Close();
            gz.Close();
            msZipped.Close();

            return Encoding.UTF8.GetString(msUTF8.ToArray());
        }
开发者ID:jonbws,项目名称:strengthreport,代码行数:28,代码来源:NetUtil.cs


示例16: CheckForCertUpdates_DownloadDataCompleted

        void CheckForCertUpdates_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            try
            {
                Exception ex = e.Error;
                if (ex is WebException)
                {
                    main.Log.Error("Cert Update: Unable to reach server for updates - " + ex.Message);
                }
                else
                {
                    byte[] bytesCert = e.Result;
                    if (bytesCert.Length > 0)
                    {
                        File.WriteAllBytes(AppDomain.CurrentDomain.BaseDirectory + lastCertFile, bytesCert);
                        main.SetCertFile(lastCertFile);
                        main.Load("cert");
                    }
                }

            }
            catch (Exception ex)
            {
                if (ex is WebException || ex is System.Reflection.TargetInvocationException)
                {
                    main.Log.Error("Link Update: Unable to reach server for updates - " + ex.InnerException.Message);
                }
                else
                {
                    main.Log.Error("Link Update: non-connection error - " + ex.Message);
                }
            }

        }
开发者ID:geexmmo,项目名称:SmartConnect,代码行数:34,代码来源:ServerUpdater.cs


示例17: OnDownloadCompleted

        private void OnDownloadCompleted(object sender, DownloadDataCompletedEventArgs eventArgs)
        {
            if (eventArgs.Error != null)
            {
                throw eventArgs.Error;
            }

            string file = Path.Combine(Application.StartupPath, DownloadUrl.Split('/')[DownloadUrl.Split('/').Length - 1]);

            File.WriteAllBytes(file, eventArgs.Result);

            string batch = string.Format(
                "@echo off{1}" +
                "TASKKILL /F /PID {0}{1}" +
                "PING 1.1.1.1 -n 1 -w 2000 >NUL{1}" +
                "DEL %2{1}" +
                "MOVE %1 %2{1}" +
                "%2{1}" +
                "DEL %1{1}" +
                "DEL %3", Process.GetCurrentProcess().Id, Environment.NewLine);
            string batchFile = Path.Combine(Application.StartupPath, "update.bat");

            File.WriteAllText(batchFile, batch);

            ProcessStartInfo info = new ProcessStartInfo(batchFile,
                string.Format("\"{0}\" \"{1}\" \"{2}\"", file, Application.ExecutablePath, batchFile))
                                        {CreateNoWindow = true, UseShellExecute = false};
            Process.Start(info);
        }
开发者ID:banksyhf,项目名称:Auxilium,代码行数:29,代码来源:Updater.cs


示例18: Completed

 private void Completed(object sender, DownloadDataCompletedEventArgs e)
 {
     DelegateStatusTextAktualisieren textAktualisieren = new DelegateStatusTextAktualisieren(AktualisiereStatus);
     txtStatus.Invoke(textAktualisieren, "Download abgeschlossen");
     File.WriteAllBytes(Directory.GetCurrentDirectory() + "/UpdatePacket.zip", e.Result);
     txtStatus.Invoke(textAktualisieren, "Das Update wurde als \"UpdatePacket.zip\" gespeichert.");
     Updatefertig = true;
 }
开发者ID:markellus,项目名称:vektorrechner_jbs2012,代码行数:8,代码来源:Form1.cs


示例19: OnDownloadDataCompleted

        /// <summary>Occurs when an asynchronous data download operation completes.</summary>
        protected override void OnDownloadDataCompleted(DownloadDataCompletedEventArgs e)
        {
            // Reset the Stopwatch
            p_Stopwatch.Reset();

            // Continue processing the event as usual
            base.OnDownloadDataCompleted(e);
        }
开发者ID:AdamWarnock,项目名称:Speed-Test-Loggger,代码行数:9,代码来源:CustomWebClient.cs


示例20: OnWebClientOnDownloadDataCompleted

        private void OnWebClientOnDownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            var webClient = (WebClient) sender;

            webClient.DownloadProgressChanged -= OnWebClientOnDownloadProgressChanged;
            webClient.DownloadDataCompleted -= OnWebClientOnDownloadDataCompleted;

            DownloadCompleted.SafeInvoke(this);
        }
开发者ID:telefunkenvf14,项目名称:Orc.AutomaticSupport,代码行数:9,代码来源:AutomaticSupportService.cs



注:本文中的System.Net.DownloadDataCompletedEventArgs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Net.DownloadProgressChangedEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Net.DnsEndPoint类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap