コード例 #1
0
ファイル: HtmlHelper.cs プロジェクト: yuxi214/Cloud_Trading
        internal static List <ImgItem> GetImgList(string html)
        {
            List <ImgItem> list    = null;
            string         imgList = RegexString.ImgList;

            if (Regex.IsMatch(html, imgList, RegexOptions.IgnoreCase))
            {
                list = new List <ImgItem>();
                foreach (Match match in Regex.Matches(html, imgList, RegexOptions.IgnoreCase))
                {
                    ImgItem imgItem = null;
                    try
                    {
                        imgItem = new ImgItem
                        {
                            Src  = match.Groups[1].Value,
                            Html = match.Value
                        };
                    }
                    catch
                    {
                        imgItem = null;
                    }
                    if (imgItem != null)
                    {
                        list.Add(imgItem);
                    }
                }
            }
            return(list);
        }
コード例 #2
0
ファイル: HtmlHelper.cs プロジェクト: fbkc/soft_AutoSend
        /// <summary>
        /// 获取所有的Img标签
        /// </summary>
        /// <param name="html">要分析的Html代码</param>
        /// <returns>返回一个List存储所有的Img标签</returns>
        internal static List <ImgItem> GetImgList(string html)
        {
            List <ImgItem> list = null;
            string         ra   = RegexString.ImgList;

            if (Regex.IsMatch(html, ra, RegexOptions.IgnoreCase))
            {
                list = new List <ImgItem>();
                foreach (Match item in Regex.Matches(html, ra, RegexOptions.IgnoreCase))
                {
                    ImgItem a = null;
                    try
                    {
                        a = new ImgItem()
                        {
                            Src  = item.Groups[1].Value,
                            Html = item.Value
                        };
                    }
                    catch { a = null; }
                    if (a != null)
                    {
                        list.Add(a);
                    }
                }
            }
            return(list);
        }
コード例 #3
0
        private async Task _DownloadImgAsync(string srcUrl)
        {
            try
            {
                var newFileName = Convert.ToBase64String(new UTF8Encoding().GetBytes(srcUrl)).Replace('/', '?');
                newFileName += HublUtils.GetExt(srcUrl);
                var newFolder = await KnownFolders.PicturesLibrary.CreateFolderAsync(Package.Current.DisplayName, CreationCollisionOption.OpenIfExists);


                if (!await newFolder.Hubl_ExistsAsync(newFileName))
                {
                    return;
                }



                var newFile = await newFolder.CreateFileAsync(newFileName, CreationCollisionOption.ReplaceExisting);

                var item = new ImgItem();
                item.Url      = srcUrl;
                item.Progress = 0;
                item.FileSize = 100;
                _items.Add(item);

                await HublUtils.HttpGetFileAsync(srcUrl, newFile, (prog, max) =>
                {
                    item.Progress = prog;
                    item.FileSize = max;
                });

                var bm       = new BitmapImage();
                var bmStream = await newFile.OpenAsync(FileAccessMode.Read);

                await bm.SetSourceAsync(bmStream);

                item.FileBmSource = bm;
            }
            catch (Exception ex)
            {
                Log.exception(ex);
            }
        }
コード例 #4
0
        private async Task _DownloadImgAsync(string srcUrl)
        {
            try
            {
                var newFileName = Convert.ToBase64String(new UTF8Encoding().GetBytes(srcUrl)).Replace('/', '?');
                newFileName += HublUtils.GetExt(srcUrl);
                var newFolder = await KnownFolders.PicturesLibrary.CreateFolderAsync(Package.Current.DisplayName, CreationCollisionOption.OpenIfExists);


                if (!await newFolder.Hubl_ExistsAsync(newFileName))
                    return;



                var newFile = await newFolder.CreateFileAsync(newFileName, CreationCollisionOption.ReplaceExisting);
                var item = new ImgItem();
                item.Url = srcUrl;
                item.Progress = 0;
                item.FileSize = 100;
                _items.Add(item);

                await HublUtils.HttpGetFileAsync(srcUrl, newFile, (prog, max) =>
                {
                    item.Progress = prog;
                    item.FileSize = max;
                });

                var bm = new BitmapImage();
                var bmStream = await newFile.OpenAsync(FileAccessMode.Read);
                await bm.SetSourceAsync(bmStream);
                item.FileBmSource = bm;
            }
            catch (Exception ex)
            {
                Log.exception(ex);
            }
        }
コード例 #5
0
ファイル: HtmlHelper.cs プロジェクト: SaintLoong/Framework
 /// <summary>
 /// 获取所有的Img标签
 /// </summary>
 /// <param name="html">要分析的Html代码</param>
 /// <returns>返回一个List存储所有的Img标签</returns>
 internal static List<ImgItem> GetImgList(string html)
 {
     List<ImgItem> list = null;
     string ra = RegexString.ImgList;
     if (Regex.IsMatch(html, ra, RegexOptions.IgnoreCase))
     {
         list = new List<ImgItem>();
         foreach (Match item in Regex.Matches(html, ra, RegexOptions.IgnoreCase))
         {
             ImgItem a = null;
             try
             {
                 a = new ImgItem()
                 {
                     Src = item.Groups[1].Value,
                     Html = item.Value
                 };
             }
             catch { a = null; }
             if (a != null)
             {
                 list.Add(a);
             }
         }
     }
     return list;
 }