예제 #1
0
        /// <summary>
        /// Handles the download progress changed event.
        /// </summary>
        /// <param name="sender">The object triggering this event/</param>
        /// <param name="e">Event argument.</param>
        private void downloader_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (InvokeRequired)
            {
                if (updateListDownloader.CancellationPending)
                {
                    throw new OperationCanceledException();
                }

                Invoke((EventHandler <ProgressChangedEventArgs>)downloader_ProgressChanged,
                       sender, e);
                return;
            }

            DownloadInfo           download        = (DownloadInfo)sender;
            DownloadUIInfo         downloadUIInfo  = DownloadItems[download];
            SteppedProgressManager overallProgress = (SteppedProgressManager)e.Progress;

            if (e.UserState is Exception)
            {
                downloadUIInfo.ListViewItem.ImageIndex       = 3;
                downloadUIInfo.ListViewItem.SubItems[1].Text = S._("Error");
                downloadUIInfo.ListViewItem.ToolTipText      = ((Exception)e.UserState).Message;
            }
            else
            {
                if (overallProgress.CurrentStep.Progress.Progress >= 1.0f)
                {
                    downloadUIInfo.ListViewItem.ImageIndex       = -1;
                    downloadUIInfo.ListViewItem.SubItems[1].Text = S._("Downloaded");
                }
                else
                {
                    downloadUIInfo.Downloaded = (long)
                                                (overallProgress.CurrentStep.Progress.Progress * download.FileSize);
                    downloadUIInfo.ListViewItem.ImageIndex       = 0;
                    downloadUIInfo.ListViewItem.SubItems[1].Text = FileSize.ToString(download.FileSize -
                                                                                     downloadUIInfo.Downloaded);
                }
            }

            downloadingItemLbl.Text    = S._("Downloading: {0}", download.Name);
            downloadingItemPb.Value    = (int)(overallProgress.CurrentStep.Progress.Progress * 100);
            downloadingOverallPb.Value = (int)(overallProgress.Progress * 100);
            downloadingOverallLbl.Text = S._("Overall progress: {0} left",
                                             FileSize.ToString(DownloadItems.Values.Sum(delegate(DownloadUIInfo item)
            {
                return(item.Download.FileSize - item.Downloaded);
            }
                                                                                        )));
        }
예제 #2
0
        /// <summary>
        /// Handles the progress events generated during update installation.
        /// </summary>
        /// <param name="sender">The object triggering this event/</param>
        /// <param name="e">Event argument.</param>
        private void installer_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            if (InvokeRequired)
            {
                if (updateListDownloader.CancellationPending)
                {
                    throw new OperationCanceledException();
                }

                Invoke((EventHandler <ProgressChangedEventArgs>)installer_ProgressChanged,
                       sender, e);
                return;
            }

            DownloadInfo   download       = (DownloadInfo)sender;
            DownloadUIInfo downloadUIInfo = DownloadItems[download];

            if (e.UserState is Exception)
            {
                downloadUIInfo.Error = (Exception)e.UserState;
                downloadUIInfo.ListViewItem.ImageIndex       = 3;
                downloadUIInfo.ListViewItem.SubItems[1].Text =
                    S._("Error: {0}", downloadUIInfo.Error.Message);
            }
            else
            {
                switch (downloadUIInfo.ListViewItem.ImageIndex)
                {
                case -1:
                    downloadUIInfo.ListViewItem.SubItems[1].Text =
                        S._("Installing {0}", download.Name);
                    downloadUIInfo.ListViewItem.ImageIndex = 1;
                    break;

                case 1:
                    downloadUIInfo.ListViewItem.SubItems[1].Text =
                        S._("Installed {0}", download.Name);
                    downloadUIInfo.ListViewItem.ImageIndex = 2;
                    break;
                }
            }
        }
예제 #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="update">The DownloadInfo object containing the
 /// information about the download.</param>
 /// <param name="item">The ListViewItem used for the display of the
 /// update.</param>
 public DownloadUIInfo(DownloadInfo download, ListViewItem item)
 {
     Download     = download;
     ListViewItem = item;
 }
예제 #4
0
 public DownloadUIInfo(DownloadInfo download, ListViewItem item)
 {
     Download = download;
     ListViewItem = item;
 }