Beispiel #1
0
        private async void InitializeAsync()
        {
            //恢复上次关闭时保存的控件
            var list = await TXDataFileIO.GetMessagesAsync();

            if (list != null)
            {
                foreach (Models.DownloaderMessage ms in list)
                {
                    DownloadBar db = new DownloadBar();
                    DownloadBarCollection.Add(db);
                    AbstractDownloader dw = AbstractDownloader.GetDownloaderFromType(ms.DownloaderType);
                    db.SetDownloader(dw);
                    dw.SetDownloaderFromBreakpoint(ms);
                }
            }

            if (Settings.DownloadsFolderToken == null)
            {
                var contentDialog = new ContentDialog()
                {
                    Title               = Strings.AppResources.GetString("DownloadFolderPathIllegal"),
                    Content             = Strings.AppResources.GetString("SetDownloadFolder"),
                    PrimaryButtonText   = Strings.AppResources.GetString("Select"),
                    SecondaryButtonText = Strings.AppResources.GetString("Cancel"),
                    FullSizeDesired     = false,
                };

                contentDialog.PrimaryButtonClick += async(sender, e) =>
                {
                    var folderPicker = new FolderPicker();
                    folderPicker.FileTypeFilter.Add(".");
                    StorageFolder folder = null;
                    folder = await folderPicker.PickSingleFolderAsync();

                    if (folder == null)
                    {
                        App.Current.Exit();
                    }
                    else
                    {
                        Settings.DownloadsFolderToken = StorageApplicationPermissions
                                                        .MostRecentlyUsedList.Add(folder);
                    }
                };

                contentDialog.SecondaryButtonClick += (sender, e) =>
                                                      App.Current.Exit();

                await contentDialog.ShowAsync();
            }
        }
Beispiel #2
0
        private async void InitializeAsync()
        {
            DownloadBarCollection.CollectionChanged += DownloadBarCollection_CollectionChanged;//订阅内容变化事件
            //恢复上次关闭时保存的控件
            var list = await StorageManager.GetMessagesAsync();

            if (list != null)
            {
                foreach (Models.DownloaderMessage ms in list)
                {
                    DownloadBar db = new DownloadBar();
                    DownloadBarCollection.Add(db);
                    AbstractDownloader dw = AbstractDownloader.GetDownloaderFromType(ms.DownloaderType);
                    db.SetDownloader(dw);
                    dw.SetDownloaderFromBreakpoint(ms);
                }
            }
        }