コード例 #1
0
        public ImageViewerPostViewModel(Post p)
        {
            Number          = p.Number;
            RenamedFileName = p.RenamedFileName;
            ThumbnailSrc    = p.ThumbnailSrc;
            ImageSrc        = p.ImageSrc;
            AspectRatio     = p.ImageWidth / (double)p.ImageHeight;
            FileType        = p.FileType;

            UpdateProgress = new ModelCommand <int>(DoUpdateProgress);
            IsDownloading  = true;
        }
コード例 #2
0
        public async Task Save()
        {
            if (SelectedIndex >= 0 && SelectedIndex < ImagePosts.Count)
            {
                bool cantSave = false;

                Models.API.APIPost.FileTypes fileType = (ImagePosts[SelectedIndex] as ImageViewerPostViewModel).FileType;
                if (fileType == Models.API.APIPost.FileTypes.webm || fileType == Models.API.APIPost.FileTypes.swf || fileType == Models.API.APIPost.FileTypes.gif)
                {
                    cantSave = true;
                }

                ProgressIndicator progress = new ProgressIndicator
                {
                    IsVisible       = true,
                    IsIndeterminate = true,
                    Text            = cantSave ? AppResources.ImageViewerPage_CantSave : AppResources.ImageViewerPage_SavingImage
                };

                PhoneApplicationPage page = (App.Current.RootVisual as PhoneApplicationFrame).Content as PhoneApplicationPage;

                SystemTray.SetOpacity(page, 0.99);
                SystemTray.SetIsVisible(page, true);
                SystemTray.SetProgressIndicator(page, progress);

                if (cantSave)
                {
                    await Task.Delay(1000);
                }
                else
                {
                    bool result = await SaveInternal(ImagePosts[SelectedIndex] as ImageViewerPostViewModel);

                    if (result)
                    {
                        progress.Text = AppResources.ImageViewerPage_ImageSaved;
                        await Task.Delay(400);
                    }
                    else
                    {
                        progress.Text = AppResources.ImageViewerPage_ImageFailed;
                        await Task.Delay(1000);
                    }
                }

                SystemTray.SetProgressIndicator(page, null);
                SystemTray.SetIsVisible(page, false);
            }
        }