private void _download_Finish(Download sender)
 {
     if (isError)
         return;
     Status = TaskStatus.Completed;
     this.Dispatcher.Invoke(new Action(() =>
         {
             this.status.Content = "已完成";
             this.progress.Value = 100;
             openButtons.Visibility = Visibility.Visible;
             _finish.Invoke(this);
         }));
 }
 private void _download_Progress(Download sender)
 {
     this.Dispatcher.Invoke(new Action(() =>
         {
             progress.Value = sender.FinishRate;
             this.status.Content = String.Format("{0}%", (int)sender.FinishRate);
         }));
 }
 private void _download_Exception(Download sender, Exception e)
 {
     this.Dispatcher.Invoke(new Action(() => 
         {
             DownloadFailed(e.Message);
             sender.Stop();
         }));
 }
        public DownloadTaskElement(BookInfo book, DownloadTaskList downloadmanager)
        {
            InitializeComponent();
            _book = book;
            _downloadmanager = downloadmanager;
            _download = new Download(book, Setting.downloadPath);
            _download.Finish += new Download.FinishedEventHandler(_download_Finish);
            _download.Exception += new Download.ExceptionEventHandler(_download_Exception);
            _download.Progress += new Download.ProgressEventHandler(_download_Progress);


            this.Exception += new ExceptionEventHandler(downloadmanager.Exception);
            this.Finish += new FinishEventHandler(downloadmanager.Finish);
            this.Status = TaskStatus.Waiting;
            initUI();
        }