/// <summary>
        /// Load image from the given URI by downloading it.<br/>
        /// Create local file name in temp folder from the URI, if the file already exists use it as it has already been downloaded.
        /// If not download the file.
        /// </summary>
        private void SetImageFromUrl(Uri source)
        {
            var filePath = CommonUtils.GetLocalfileName(source);

            if (filePath.Exists && filePath.Length > 0)
            {
                SetImageFromFile(filePath);
            }
            else
            {
                _htmlContainer.GetImageDownloader().DownloadImage(source, filePath.FullName, !_htmlContainer.AvoidAsyncImagesLoading, OnDownloadImageCompleted);
            }
        }
示例#2
0
        /// <summary>
        /// Load image from the given URI by downloading it.<br/>
        /// Create local file name in temp folder from the URI, if the file already exists use it as it has already been downloaded.
        /// If not download the file.
        /// </summary>
        private void SetImageFromUrl(Uri source)
        {
            var filePath = CommonUtils.GetLocalfileName(source);

            // We only use the existing file if it is less than a day old
            if (filePath.Exists && filePath.Length > 0 && filePath.CreationTimeUtc > DateTime.UtcNow.AddDays(-1))
            {
                SetImageFromFile(filePath);
            }
            else
            {
                if (filePath.Exists)
                {
                    filePath.Delete();
                }

                _htmlContainer.GetImageDownloader().DownloadImage(source, filePath.FullName, !_htmlContainer.AvoidAsyncImagesLoading, OnDownloadImageCompleted);
            }
        }