Пример #1
0
        void ButtonGrabPDFs_Click(object sender, RoutedEventArgs e)
        {
            Uri    current_uri = CurrentWebBrowserControl.CurrentUri;
            string html        = CurrentWebBrowserControl.PageHTML;

            List <string> urls = DownloadableFileGrabber.Grab(html, "pdf");

            List <Uri> uris = new List <Uri>();

            foreach (string url in urls)
            {
                Uri uri;
                if (Uri.TryCreate(current_uri, url, out uri))
                {
                    uris.Add(uri);
                }
            }

            if (0 < uris.Count)
            {
                string msg = String.Format(
                    "Qiqqa has found {0} PDFs on this page.  Please choose the library into which you want to import them."
                    , uris.Count
                    );

                WebLibraryDetail web_library_detail = WebLibraryPicker.PickWebLibrary(msg);
                if (null != web_library_detail)
                {
                    foreach (Uri uri in uris)
                    {
                        ImportingIntoLibrary.AddNewDocumentToLibraryFromInternet_ASYNCHRONOUS(web_library_detail.library, uri.ToString());
                    }
                }
                else
                {
                    MessageBoxes.Warn("No PDFs have been imported.");
                }
            }
            else
            {
                MessageBoxes.Info("Qiqqa could not find links to any PDFs on this page (with URLs ending in .pdf");
            }
        }