Пример #1
0
        public void Apply(ScrollViewer view, ClientImageModel model)
        {
            if (zoomFactor != null)
            {
                if (width != null && width != model.Width)
                {
                    float ratio = (float)width / model.Width;
                    zoomFactor = Math.Abs(zoomFactor.Value * ratio);
                }

                view.ChangeView(horizontalOffset, verticalOffset, zoomFactor);
            }

            width  = model.Width;
            height = model.Height;
        }
        private async void btnDownload_Click(object sender, RoutedEventArgs e)
        {
            ShowMessage("Downloading image...");
            await HandleErrorAsync(() => client.DownloadLatestAsync(quality), model =>
            {
                downloadModel        = model;
                imgBackground.Source = model.Image;
                ClearMessage();

                string date = model.Date.ToString("HH:mm:ss");
                if (model.Date.Date != DateTime.Today)
                {
                    date += model.Date.ToString(" dd.MM.yyyy");
                }

                ShowMessage(date);
            });
        }
        protected override async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            try
            {
                viewModel.IsDownloading = true;

                ClientImageModel image = await client.DownloadLatestAsync(viewModel.Quality, cancellationToken);

                Completed?.Invoke(image);
            }
            catch (ClientException)
            {
                Failed?.Invoke(FailType.ClientError);
            }
            catch (OperationCanceledException)
            {
                Failed?.Invoke(FailType.Cancelled);
            }
            finally
            {
                viewModel.IsDownloading = false;
            }
        }