예제 #1
0
        private void ButtonAddDocumentsFromLibrary_Click(object sender, RoutedEventArgs e)
        {
            using (AugmentedPopupAutoCloser apac = new AugmentedPopupAutoCloser(ButtonAddPDFPopup))
            {
                // First choose the source library
                string           message = String.Format("You are about to import a lot of PDFs into the library named '{0}'.  Please choose the library FROM WHICH you wish to import the PDFs.", web_library_detail.Title);
                WebLibraryDetail picked_web_library_detail = WebLibraryPicker.PickWebLibrary(message);
                if (null != picked_web_library_detail)
                {
                    if (picked_web_library_detail == web_library_detail)
                    {
                        MessageBoxes.Error("You can not copy documents into the same library.");
                        return;
                    }

                    // Then check that they still want to do this
                    string message2 = String.Format("You are about to copy ALL of the PDFs from the library named '{0}' into the library named '{1}'.  Are you sure you want to do this?", picked_web_library_detail.Title, web_library_detail.Title);
                    if (!MessageBoxes.AskQuestion(message2))
                    {
                        return;
                    }

                    // They are sure!
                    ImportingIntoLibrary.ClonePDFDocumentsFromOtherLibrary_ASYNCHRONOUS(picked_web_library_detail.Xlibrary.PDFDocuments, web_library_detail);
                }
            }
        }
예제 #2
0
        public void OnDrop(object sender, DragEventArgs e)
        {
            // Pick the library
            Library library = default_library;

            if (null == library)
            {
                WebLibraryDetail web_library_detail = WebLibraryPicker.PickWebLibrary();
                if (null != web_library_detail)
                {
                    library = web_library_detail.library;
                }
            }

            // If there still is no library (the user cancelled perhaps)
            if (null == library)
            {
                Logging.Info("No library was selected for the DragToLibraryManager.");
                return;
            }

            //if (false)
            //{
            //    StringBuilder sb = new StringBuilder();
            //    sb.AppendLine("The available formats are:");
            //    foreach (string format in e.Data.GetFormats(true))
            //    {
            //        sb.AppendFormat(" - {0}\n", format);
            //    }
            //    Logging.Debug(sb.ToString());
            //}

            if (false)
            {
            }

            else if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] filenames = (string[])e.Data.GetData(DataFormats.FileDrop);

                // IF they have dragged and dropped a single directory
                if (0 < filenames.Length && Directory.Exists(filenames[0]))
                {
                    if (1 == filenames.Length)
                    {
                        // Invoke the directory handler
                        new ImportFromFolder(library, filenames[0]).ShowDialog();
                    }
                    else
                    {
                        MessageBoxes.Warn("You can drag only one directory at a time to Qiqqa.");
                    }
                }
                else
                {
                    ImportingIntoLibrary.AddNewPDFDocumentsToLibrary_ASYNCHRONOUS(library, false, false, filenames);
                }
            }

            else if (e.Data.GetDataPresent("UniformResourceLocator"))
            {
                string download_url = DragDropTools.GetDataString("UniformResourceLocator", e);
                Logging.Info("The dropped item is {0}", download_url);
                ImportingIntoLibrary.AddNewDocumentToLibraryFromInternet_ASYNCHRONOUS(library, download_url);
            }

            else if (e.Data.GetDataPresent(typeof(PDFDocument)))
            {
                PDFDocument pdf_document = (PDFDocument)e.Data.GetData(typeof(PDFDocument));
                Logging.Info("The dropped item is {0}", pdf_document);
                ImportingIntoLibrary.ClonePDFDocumentsFromOtherLibrary_ASYNCHRONOUS(pdf_document, library, false);
            }

            else if (e.Data.GetDataPresent(typeof(List <PDFDocument>)))
            {
                List <PDFDocument> pdf_documents = (List <PDFDocument>)e.Data.GetData(typeof(List <PDFDocument>));
                ImportingIntoLibrary.ClonePDFDocumentsFromOtherLibrary_ASYNCHRONOUS(pdf_documents, library);
            }

            else
            {
                Logging.Info("Not using any of:");
                foreach (string s in e.Data.GetFormats())
                {
                    Logging.Info(s);
                }
            }

            e.Handled = true;
        }