private static void OnStatusUpdatedHandler(object sender, StatusUpdatedEventArgs args)
        {
            string message;
            string disp_progress;
            double progress;

            if (args.Progress != -1)
            {
                progress = (double)args.Progress / 100;
            }
            else
            {
                progress = 0.0;
            }

            // TODO  This could be shortened up
            if (args.FailedDownloads == 0)
            {
                disp_progress = String.Format(Catalog.GetPluralString(
                                                  "Downloading File",
                                                  "Downloading Files ({0} of {1} completed)",
                                                  args.TotalDownloads),
                                              args.DownloadsComplete, args.TotalDownloads
                                              );
            }
            else
            {
                disp_progress = String.Format(Catalog.GetString(
                                                  "Downloading Files ({0} of {1} completed)\n{2} failed"),
                                              args.DownloadsComplete, args.TotalDownloads, args.FailedDownloads);
            }


            message = String.Format(Catalog.GetPluralString(
                                        "Currently transfering 1 file at {0} kB/s",
                                        "Currently transfering {1} files at {0} kB/s",
                                        args.CurrentDownloads),
                                    args.Speed, args.CurrentDownloads
                                    );

            ThreadAssist.ProxyToMain(delegate {
                if (userEvent != null)
                {
                    if (!cancel_requested)
                    {
                        userEvent.Header   = disp_progress;
                        userEvent.Message  = message;
                        userEvent.Progress = progress;
                    }
                }
            });
        }
Пример #2
0
        protected virtual void OnStatusUpdated()
        {
            StatusUpdatedEventHandler handler = StatusUpdated;

            if (handler != null)
            {
                StatusUpdatedEventArgs args;

                lock (syncRoot)
                {
                    args = new StatusUpdatedEventArgs(speed, TotalDownloads,
                                                      FailedDownloads, CompletedDownloads,
                                                      Progress, CurrentDownloads);
                }

                handler(this, args);
            }
        }
        private static void OnStatusUpdatedHandler(object sender, StatusUpdatedEventArgs args)
        {
            string message;
            string disp_progress;
            double progress;

            if (args.Progress != -1) {
                progress = (double) args.Progress / 100;
            } else {
                progress = 0.0;
            }

            // TODO  This could be shortened up
            if (args.FailedDownloads == 0)
            {
                disp_progress = String.Format (Catalog.GetPluralString (
                   "Downloading File",
                   "Downloading Files ({0} of {1} completed)",
                   args.TotalDownloads),
                   args.DownloadsComplete, args.TotalDownloads
                );
            }
            else
            {
                disp_progress = String.Format (Catalog.GetString (
                    "Downloading Files ({0} of {1} completed)\n{2} failed"),
                    args.DownloadsComplete, args.TotalDownloads, args.FailedDownloads);
            }

            message = String.Format (Catalog.GetPluralString (
                "Currently transfering 1 file at {0} kB/s",
                "Currently transfering {1} files at {0} kB/s",
                args.CurrentDownloads),
                args.Speed, args.CurrentDownloads
            );

            ThreadAssist.ProxyToMain ( delegate {
                                           if (userEvent != null)
                                       {
                                           if (!cancel_requested)
                                               {
                                                   userEvent.Header = disp_progress;
                                                   userEvent.Message = message;
                                                   userEvent.Progress = progress;
                                               }
                                           }
                                       });
        }
        protected virtual void OnStatusUpdated()
        {
            StatusUpdatedEventHandler handler = StatusUpdated;

            if (handler != null)
            {
                StatusUpdatedEventArgs args;

                lock (syncRoot)
                {
                    args = new StatusUpdatedEventArgs ( speed, TotalDownloads,
                                                        FailedDownloads, CompletedDownloads,
                                                        Progress, CurrentDownloads);
                }

                handler (this, args);
            }
        }