当前位置: 首页>>代码示例>>C#>>正文


C# ImageItem.UpdateDownloadedImage方法代码示例

本文整理汇总了C#中ImageItem.UpdateDownloadedImage方法的典型用法代码示例。如果您正苦于以下问题:C# ImageItem.UpdateDownloadedImage方法的具体用法?C# ImageItem.UpdateDownloadedImage怎么用?C# ImageItem.UpdateDownloadedImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageItem的用法示例。


在下文中一共展示了ImageItem.UpdateDownloadedImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddImageSelectionListItem

        /// <summary>
        /// Add image by downloading
        /// </summary>
        /// <param name="downloadLink"></param>
        /// <param name="contentSlide"></param>
        /// <param name="slideWidth"></param>
        /// <param name="slideHeight"></param>
        public void AddImageSelectionListItem(string downloadLink, 
            Slide contentSlide, float slideWidth, float slideHeight)
        {
            if (StringUtil.IsEmpty(downloadLink) || !UrlUtil.IsUrlValid(downloadLink)) // Case 1: If url not valid
            {
                View.ShowErrorMessageBox(TextCollection.PictureSlidesLabText.ErrorUrlLinkIncorrect);
                return;
            }
            var item = new ImageItem
            {
                ImageFile = StoragePath.LoadingImgPath,
                ContextLink = downloadLink
            };
            UrlUtil.GetMetaInfo(ref downloadLink, item);
            ImageSelectionList.Add(item);
            IsActiveDownloadProgressRing.Flag = true;

            var imagePath = StoragePath.GetPath("img-"
                + DateTime.Now.GetHashCode() + "-"
                + Guid.NewGuid().ToString().Substring(0, 7));
            ImageDownloader
                .Get(downloadLink, imagePath)
                .After(() =>
                {
                    try
                    {
                        VerifyIsProperImage(imagePath); // Case 2: not a proper image
                        item.UpdateDownloadedImage(imagePath);
                        UpdatePictureInPictureVariationWhenAddedNewOne(item);
                        if (ImageSelectionListSelectedItem.ImageItem != null
                            && imagePath == ImageSelectionListSelectedItem.ImageItem.FullSizeImageFile)
                        {
                            UpdatePreviewImages(ImageSelectionListSelectedItem.ImageItem,
                                contentSlide, slideWidth, slideHeight);
                        }
                        else if (IsInPictureVariation())
                        {
                            UpdatePreviewImages(
                                ImageSelectionListSelectedItem.ImageItem ?? View.CreateDefaultPictureItem(),
                                contentSlide, slideWidth, slideHeight);
                        }
                    }
                    catch
                    {
                        View.ShowErrorMessageBox(TextCollection.PictureSlidesLabText.ErrorImageDownloadCorrupted);
                        ImageSelectionList.Remove(item);
                    }
                    finally
                    {
                        IsActiveDownloadProgressRing.Flag = false;
                    }
                })
                // Case 3: Possibly network timeout
                .OnError(e =>
                {
                    IsActiveDownloadProgressRing.Flag = false;
                    ImageSelectionList.Remove(item);
                    View.ShowErrorMessageBox(TextCollection.PictureSlidesLabText.ErrorFailedToLoad + e.Message);
                })
                .Start();
        }
开发者ID:digawp,项目名称:PowerPointLabs,代码行数:68,代码来源:PictureSlidesLabWindowViewModel.cs


注:本文中的ImageItem.UpdateDownloadedImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。