Beispiel #1
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            AccountInfo.Password = PasswordInput.Password;
            IsLoginRequesting    = true;

            Task.Run(() =>
            {
                using (LoadingStatus.BeginBusy("正在登录..."))
                {
                    try
                    {
                        var feature = Gallery.Feature <IGalleryAccount>();

                        feature.AccountLogin(AccountInfo);

                        if (feature.IsLoggined)
                        {
                            Toast.ShowMessage($"登录成功");

                            Dispatcher.Invoke(() => NavigationHelper.NavigationPop());
                        }
                    }
                    catch (Exception e)
                    {
                        Toast.ShowMessage($"登录失败!原因:{e.Message}");
                    }
                    Dispatcher.Invoke(() => IsLoginRequesting = false);
                }
            });
        }
        private async Task DisplayImage(DownloadableImageLink pick_download)
        {
            DetailImageBox.ImageSource = null;
            RefreshButton.IsBusy       = true;
            const string notify_content = "加载图片中......";

            using var notify = LoadingStatus.BeginBusy(notify_content);

            var downloader = Container.Default.GetExportedValue <ImageFetchDownloadScheduler>();

            var image = await ImageResourceManager.RequestImageFromNetworkAsync(pick_download.FullFileName, pick_download.DownloadLink, true, d =>
            {
                var(cur, total)    = d;
                notify.Description = $"({cur * 1.0 / total * 100:F2}%) {notify_content}";
            });

            if (image is null)
            {
                Toast.ShowMessage("加载图片失败");
            }

            CurrentDisplayImageLink = image is null ? null : pick_download;

            DetailImageBox.ImageSource = image?.ConvertToBitmapImage();

            RefreshButton.IsBusy = false;
        }
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            AccountInfo.Password = PasswordInput.Password;
            IsLoginRequesting    = true;

            var feature = Gallery.Feature <IGalleryAccount>();

            using var status = LoadingStatus.BeginBusy("正在登录...");

            await Task.Run(() =>
            {
                try
                {
                    feature.AccountLogin(AccountInfo);
                }
                catch (Exception e)
                {
                    Toast.ShowMessage($"登录失败!原因:{e.Message}");
                }
            });

            IsLoginRequesting = false;

            if (feature.IsLoggined)
            {
                Toast.ShowMessage($"登录成功");
                NavigationHelper.NavigationPop();

                if (AutoLogin.IsChecked ?? false)
                {
                    var container = SettingManager.LoadSetting <AccountInfoDataContainer>();
                    container.SaveAccountInfoData(Gallery, AccountInfo);
                }
            }
        }
Beispiel #4
0
        private async void ChangeDetailPicture(GalleryImageDetail galleryImageDetail)
        {
            //clean.
            DetailImageBox.ImageSource = null;

            if (galleryImageDetail == null)
            {
                return;
            }

            RefreshButton.IsBusy = true;

            const string notify_content = "加载图片中......";

            using (var notify = LoadingStatus.BeginBusy(notify_content))
            {
                var(pick_download, is_new) = await PickSuitableImageURL(galleryImageDetail.DownloadableImageLinks);

                if (pick_download == null)
                {
                    //notice error;
                    ExceptionHelper.DebugThrow(new Exception("No image."));
                    Toast.ShowMessage("没图片可显示");
                    return;
                }

                if (is_new)
                {
                    //force update
                    var d = DownloadList.DataContext;
                    DownloadList.DataContext = this;
                    DownloadList.DataContext = d;
                }

                var downloader = Container.Default.GetExportedValue <ImageFetchDownloadScheduler>();

                System.Drawing.Image image;

                do
                {
                    image = await ImageResourceManager.RequestImageAsync(pick_download.FullFileName, async() =>
                    {
                        return(await downloader.GetImageAsync(pick_download.DownloadLink, null, d =>
                        {
                            (long cur, long total) = d;
                            notify.Description = $"({cur * 1.0 / total * 100:F2}%) {notify_content}";
                        }));
                    });
                } while (image == null);

                var source = image.ConvertToBitmapImage();
                RefreshButton.IsBusy = false;

                if (PictureDetailInfo == galleryImageDetail)
                {
                    DetailImageBox.ImageSource = source;
                }
                else
                {
                    Log <PictureDetailViewPage> .Debug($"Picture info mismatch.");
                }
            };