本文整理汇总了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();
}