private void DownloadDataAsync_Click(object sender, RoutedEventArgs e)
        {
            DownloadWindow downloadWind = new DownloadWindow();

            App.Current.MainWindow = downloadWind;
            this.Close();
            downloadWind.Show();
        }
Exemple #2
0
 //获取新版本
 private void GetNewVersion()
 {
     if (LocalVersion == NewVersion)
     {
         MessageBox.Show("你正在使用最新版本!");
     }
     else if (LocalVersion != NewVersion && File.Exists(UpdateXmlPath))
     {
         DownloadWindow DW = new DownloadWindow();
         DW.Show();
     }
 }
Exemple #3
0
        private void OnDownloadButtonClick(object sender, RoutedEventArgs e)
        {
            if (AnimeGrid.SelectedItem == null)
            {
                return;
            }
            var anime  = AnimeGrid.SelectedItem as Anime;
            var window = new DownloadWindow(anime, _password, _config);

            window.Show();
            window.StartDownload();
        }
 private void Timer_Tick(object sender, EventArgs e)
 {
     progressBar.Value += 1;
     if (progressBar.Value >= 100)
     {
         timer.Stop();
         progressBar.Value = 0;
         DownloadWindow mainWindow = new DownloadWindow();
         mainWindow.Show();
         this.Close();
     }
 }
        /// <summary>
        /// 下载
        /// </summary>
        private void DownloadNewversion_()
        {
            DownloadWindow DW = new DownloadWindow();

            DW.Show();
            Download = true;
            //添加下载完成/下载进度事件
            client.DownloadFileCompleted   += new AsyncCompletedEventHandler(Completed);
            client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
            //
            stopwatch.Start();
            // 开始异步下载
            Uri newVersionDownloadURL = new Uri(NewVersionDownloadURL);

            client.DownloadFileAsync(newVersionDownloadURL, CurrentPath + NewVersionFileName + ".zip");
        }
Exemple #6
0
        public static void AddDownload(DownloadFileInfo downloadItem)
        {
            DownloadWindow tempWindow = null;

            lock (DownloadWindows)
            {
                if (!DownloadWindows.TryGetValue(downloadItem.Id, out tempWindow))//不在缓存列表
                {
                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.FileName = downloadItem.SuggestedFileName;
                    sfd.Filter   = "所有文件|*";

                    var res = sfd.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        tempWindow = new DownloadWindow();
                        var vm = new DownloadItemViewModel()
                        {
                            FullPath      = sfd.FileName,
                            ID            = downloadItem.Id,
                            ReceivedBytes = 0,
                            Url           = downloadItem.Url,
                            TotalBytes    = downloadItem.TotalBytes
                        };
                        tempWindow.Closed += (s, e) =>
                        {
                            tempWindow.DataContext = null;
                            tempWindow.Close();
                            DownloadWindows.TryRemove(downloadItem.Id, out tempWindow);
                        };
                        tempWindow.DataContext = vm;
                        tempWindow.Show();
                        tempWindow.Activate();

                        DownloadWindows.TryAdd(downloadItem.Id, tempWindow);
                    }
                }
            }
        }
Exemple #7
0
        protected virtual async Task ShowDownloadWindow(Channel channel)
        {
            var viewModel    = new DownloadWindowViewModel(AppInfo, _logger, RemoteContentDownloader);
            var artifactPath = CreateTempPath(channel.ArtifactUrl);
            var window       = new DownloadWindow {
                DataContext = viewModel
            };

            bool[] finishedDownloading = { false };
            viewModel.ContinueWithInstallationCommand = new DelegateCommand(e =>
            {
                _logger.Log("Continue after downloading artifact");
                _analyticsLogger.LogContinueWithInstallation();
                OnArtifactDownloadedEvent(new SingleEventArgs <string>(artifactPath));
                window.Close();
                if (ShouldOpenArtifact(channel, artifactPath))
                {
                    OpenArtifact(artifactPath);
                    _logger.Log("Opened artifact");
                }
            }, o => finishedDownloading[0]);

            SetOwner(window);
            OnWindowWillBeDisplayed(window, channel);
            window.Show();

            var savedAt = await viewModel.StartAsync(channel, artifactPath).ConfigureAwait(true);

            finishedDownloading[0] = true;
            ((DelegateCommand)viewModel.ContinueWithInstallationCommand).RaiseCanExecuteChanged();

            if (string.IsNullOrWhiteSpace(savedAt))
            {
                window.Close();
                ShowErrorWindow();
            }
        }
        private void DownloadButton_Click(object sender, RoutedEventArgs e)
        {
            DownloadWindow DownloadWindow = new DownloadWindow();

            DownloadWindow.Show();
        }
        public void OnDownloadUpdated(IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
        {
            try
            {
                if (!string.IsNullOrEmpty(downloadItem.FullPath))
                {
                    DownloadWindow tempWindow = null;

                    if (DownloadWindows.TryGetValue(downloadItem.Id, out tempWindow))//存在缓存里
                    {
                        var vm = tempWindow.DataContext as DownloadItemViewModel;
                        vm.ReceivedBytes = downloadItem.ReceivedBytes;
                        vm.TotalBytes    = downloadItem.TotalBytes;

                        if (downloadItem.IsComplete)//删除完成删除
                        {
                            tempWindow.Close();
                            callback.Dispose();
                            DownloadWindows.TryRemove(downloadItem.Id, out tempWindow);
                        }
                    }
                    else
                    {
                        if (CacheList.Count(c => c.ID == downloadItem.Id) > 0)
                        {
                            return;
                        }

                        tempWindow = new DownloadWindow();
                        var vm = new DownloadItemViewModel()
                        {
                            FullPath      = downloadItem.FullPath,
                            ID            = downloadItem.Id,
                            ReceivedBytes = downloadItem.ReceivedBytes,
                            TotalBytes    = downloadItem.TotalBytes,
                            Url           = downloadItem.Url
                        };

                        tempWindow.Closed += (s, e) =>
                        {
                            CacheList.Add(new CacheModel()
                            {
                                ID = downloadItem.Id, AddTime = DateTime.Now
                            });
                            downloadItem.IsCancelled = true;
                            tempWindow.DataContext   = null;
                            tempWindow.Close();
                            callback.Dispose();
                            DownloadWindows.TryRemove(downloadItem.Id, out tempWindow);

                            Application.Current.Dispatcher.Invoke(new Action(() =>
                            {
                                if (hideWindow != null)
                                {
                                    hideWindow.Close();
                                }
                            }));
                        };
                        tempWindow.DataContext = vm;
                        tempWindow.Show();
                        tempWindow.Activate();

                        DownloadWindows.TryAdd(downloadItem.Id, tempWindow);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
        }