Пример #1
0
        private void linkVistor_OnURILink(LinkInfoVisitor __param0, LinkInfoURI __param1)
        {
            int pos = 0;
            int pos1 = 0;
            string str = __param1.URI;
            if (str.Contains("localhost"))
            {
                if (DownloadManager.IsImage(str))
                {
                    pos = str.LastIndexOf('_');
                    if (str.Contains(".jpg") && pos > 0)
                    {
                        pos1 = str.IndexOf(".jpg");
                    }

                    if (pos >= 0 && pos1 >= 0)
                    {
                        var s = str.Substring(0, pos1);
                        var ss = s.Substring(pos + 1);
                        int x = -1;
                        try
                        {
                            x = Convert.ToInt32(ss);
                        }
                        catch { }

                        if (x > 1 && x < 50)
                        {
                            for (int i = 1; i < x; i++)
                                links.Add(str.Replace("_" + ss + ".", "_" + Convert.ToString(i) + "."));
                        }
                    }

                    links.Add(str);
                }
                else if (DownloadManager.IsVideo(str))
                {
                    pos1 = str.IndexOf(".mp4");
                    str = str.Substring(0, pos1) + ".mp4";

                    links.Add(str);
                }
            }
        }
Пример #2
0
        private void GetPDFLinks(IBuffer buffer)
        {
            var document = Document.Create(
                        buffer, // - file
                        DocumentType.PDF, // type
                        72 // - dpi
                      );

            links.Clear();

            var linkVistor = new LinkInfoVisitor();
            linkVistor.OnURILink += linkVistor_OnURILink;

            for (int i = 0; i < document.PageCount; i++)
            {
                var ls = document.GetLinks(i);

                for (int j = 0; j < ls.Count; j++)
                {
                    ls[j].AcceptVisitor(linkVistor);

                }
            }
        }