示例#1
0
        static ImageLibrary()
        {
            _success = new ImageInfo
            {
                Width = 64,
                Height = 64,
                Alt = "Success!",
                Src = [email protected]_png
            };

            _alert = new ImageInfo
            {
                Width = 64,
                Height = 56,
                Alt = "Alert!",
                Src = [email protected]_png
            };

            _checkEmail = new ImageInfo
            {
                Width = 64,
                Height = 62,
                Alt = "Check your email",
                Src = [email protected]_png
            };

            _defaultProfile = new ImageInfo
            {
                Width = 78,
                Height = 82,
                Alt = "Default Profile Image",
                Src = [email protected]_png
            };
        }
示例#2
0
 public ProviderPhotoRecord(ImageInfo anImageInfo)
 {
     this.ImageUrl = new Uri(anImageInfo.Src, UriKind.Absolute);
     this.DisplayWidth = anImageInfo.Width;
     this.DisplayHeight = anImageInfo.Height;
     this.Caption = anImageInfo.Alt;
     this.PhotoImageType = ImageTypeEnum.Original;
 }
示例#3
0
 /// <summary>
 /// Get absolute image infos from document
 /// </summary>
 /// <param name="validUriHost">restricts images to the local domain or the domains specified (www.insideword.com, www.chunkng.com, ...)</param>
 /// <returns>List of image infos whose uri was valid and absolute</returns>
 public List<ImageInfo> GetImageInfos(List<string> validUriHosts)
 {
     HtmlNodeCollection imageNodeList = HtmlDoc.DocumentNode.SelectNodes("//img");
     List<ImageInfo> imageInfoList = new List<ImageInfo>();
     ImageInfo anImageInfo;
     if (imageNodeList != null)
     {
         foreach (HtmlNode imageNode in imageNodeList)
         {
             string srcAttr = imageNode.GetAttributeValue("src", String.Empty);
             if (srcAttr != String.Empty)
             {
                 Uri hrefUri;
                 if (Uri.TryCreate(srcAttr, UriKind.RelativeOrAbsolute, out hrefUri))
                 {
                     if (hrefUri.IsAbsoluteUri &&
                         (validUriHosts == null || validUriHosts.Count == 0 || validUriHosts.Contains(hrefUri.Host)))
                     {
                         anImageInfo = new ImageInfo();
                         anImageInfo.Src = hrefUri.AbsoluteUri;
                         anImageInfo.Alt = imageNode.GetAttributeValue("alt", string.Empty);
                         anImageInfo.Height = (short)imageNode.GetAttributeValue("height", 0);
                         anImageInfo.Width = (short)imageNode.GetAttributeValue("width", 0);
                         imageInfoList.Add(anImageInfo);
                     }
                     else
                     {
                         // Relative Uris not supported right now!
                         // TODO try to resolve the relative uris to absolute on any of our valid domains
                         // (check the actual paths for content or ignore all non-absolute urls
                         // imageUris.Add(uri.AbsolutePath);
                     }
                 }
             }
         }
     }
     return imageInfoList;
 }