private void speech_synthesizer_SpeakProgress(object sender, SpeakProgressEventArgs e)
        {
            // Add the current word to our list
            last_words.Add(e.Text);
            while (last_words.Count > 10)
            {
                last_words.RemoveAt(0);
                last_words.RemoveAt(0);
                last_words.RemoveAt(0);
                last_words.RemoveAt(0);
                last_words.RemoveAt(0);
            }

            string textwindow = ArrayFormatter.ListElements(last_words, " ");

            StatusManager.Instance.UpdateStatus("ReadOutAloud", textwindow, e.CharacterPosition, current_prompt_length);
        }
        public static void ExportBibTeX(List <PDFDocument> pdf_documents, string filename, Dictionary <string, PDFDocumentExportItem> pdf_document_export_items, bool include_additional_fields)
        {
            Logging.Info("Exporting entries to BibTex");

            // Write out the header
            DateTime      now = DateTime.Now;
            StringBuilder sb  = new StringBuilder();

            sb.AppendLine("% -------------------------------------------------------------------------");
            sb.AppendLine(String.Format("% This BibTex file was generated by Qiqqa ({0}?ref=EXPBIB)", Common.Configuration.WebsiteAccess.Url_Documentation4Qiqqa));
            sb.AppendLine(String.Format("% {0} {1}", now.ToLongDateString(), now.ToLongTimeString()));
            sb.AppendLine("% Version 3");
            sb.AppendLine("% -------------------------------------------------------------------------");
            sb.AppendLine();

            // Write out the entries
            for (int i = 0; i < pdf_documents.Count; ++i)
            {
                PDFDocument pdf_document = pdf_documents[i];

                try
                {
                    StatusManager.Instance.UpdateStatus("BibTexExport", String.Format("Exporting entry {0} of {1}", i, pdf_documents.Count), i, pdf_documents.Count);

                    // Get the bibtex
                    string bibtex = pdf_document.BibTex;

                    // If there is no bibtex, make a record
                    if (String.IsNullOrEmpty(bibtex))
                    {
                        bibtex = BibTexTools.GetEmptyArticleBibTeXTemplate();

                        string title = pdf_document.TitleCombined;
                        if (Constants.TITLE_UNKNOWN != title)
                        {
                            bibtex = BibTexTools.SetAuthor(bibtex, title);
                        }

                        string author = pdf_document.AuthorsCombined;
                        if (Constants.UNKNOWN_AUTHORS != author)
                        {
                            bibtex = BibTexTools.SetAuthor(bibtex, author);
                        }

                        string year = pdf_document.YearCombined;
                        if (Constants.UNKNOWN_YEAR != year)
                        {
                            bibtex = BibTexTools.SetYear(bibtex, year);
                        }
                    }

                    // NB: The ADDITION of the filename and tags causes the bibtex to be reparsed and formatted,
                    // which currently loses all the nifty bibtex formatting language (e.g. double braces, etc)
                    //
                    // Once the bibtex parser is smarter, we can add this back in.  Or perhaps make it an option...
                    if (include_additional_fields)
                    {
                        // If we have an export filename, fill it in!
                        if (pdf_document_export_items.ContainsKey(pdf_document.Fingerprint))
                        {
                            string bibtex_filename = pdf_document_export_items[pdf_document.Fingerprint].filename;
                            string bibtex_file     = ConvertNormalFilenameToZoteroFilename(filename, bibtex_filename);

                            bibtex = BibTexTools.SetField(bibtex, "filename", bibtex_filename);
                            bibtex = BibTexTools.SetField(bibtex, "file", bibtex_file);
                        }
                        else
                        {
                            if (pdf_document.DocumentExists)
                            {
                                string bibtex_filename = pdf_document.DocumentPath;
                                string bibtex_file     = ConvertNormalFilenameToZoteroFilename(filename, bibtex_filename);

                                bibtex = BibTexTools.SetField(bibtex, "filename", bibtex_filename);
                                bibtex = BibTexTools.SetField(bibtex, "file", bibtex_file);
                            }
                        }

                        // Fill in the tags and autotags
                        {
                            string tags = pdf_document.Tags;
                            if (!String.IsNullOrEmpty(tags))
                            {
                                bibtex = BibTexTools.SetField(bibtex, "Tags", tags);
                            }

                            HashSet <string> autotags_set = pdf_document.Library.AITagManager.AITags.GetTagsWithDocument(pdf_document.Fingerprint);
                            string           autotags     = ArrayFormatter.ListElements(autotags_set.ToList(), ";");
                            if (!String.IsNullOrEmpty(autotags))
                            {
                                bibtex = BibTexTools.SetField(bibtex, "AutoTags", autotags);
                            }

                            string keywords = BibTexTools.GetField(bibtex, "keywords");
                            if (!String.IsNullOrEmpty(tags))
                            {
                                if (!String.IsNullOrEmpty(keywords))
                                {
                                    keywords = keywords + ";";
                                }
                                keywords = keywords + tags;
                            }
                            if (!String.IsNullOrEmpty(autotags))
                            {
                                if (!String.IsNullOrEmpty(keywords))
                                {
                                    keywords = keywords + ";";
                                }
                                keywords = keywords + autotags;
                            }
                            if (!String.IsNullOrEmpty(keywords))
                            {
                                bibtex = BibTexTools.SetField(bibtex, "keywords", keywords);
                            }
                        }
                    }


                    // Append the bibtex
                    if (!String.IsNullOrEmpty(bibtex))
                    {
                        sb.AppendLine(bibtex);
                        sb.AppendLine();
                    }
                }

                catch (Exception ex)
                {
                    Logging.Error(ex, "There was a problem exporting the bibtex for " + pdf_document);
                }
            }

            // Write to disk
            File.WriteAllText(filename, sb.ToString());

            StatusManager.Instance.UpdateStatus("BibTexExport", String.Format("Exported your BibTex entries to {0}", filename));
        }
        private void TagCloud_TagClick(List <string> tags)
        {
            string search_terms = ArrayFormatter.ListElements(tags, " ", "\"", "\"");

            SetSearchKeywords(search_terms);
        }
示例#4
0
        internal static void Export(Library library, List <PDFDocument> pdf_documents, string base_path, Dictionary <string, PDFDocumentExportItem> pdf_document_export_items)
        {
            Logging.Info("Exporting entries to TAB separated");

            // Write out the header
            DateTime      now = DateTime.Now;
            StringBuilder sb  = new StringBuilder();

            sb.AppendLine("% -------------------------------------------------------------------------");
            sb.AppendLine("% This tab separated file was generated by Qiqqa (http://www.qiqqa.com/?ref=EXPTAB)");
            sb.AppendLine(String.Format("% {0} {1}", now.ToLongDateString(), now.ToLongTimeString()));
            sb.AppendLine("% Version 1");
            sb.AppendLine("% -------------------------------------------------------------------------");
            sb.AppendLine();

            // Headers
            sb.AppendFormat(
                "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13}\t{14}\t{15}\t{16}\t{17}\t{18}\t{19}\t{20}",
                "Fingerprint",
                "BibTexKey",
                "Year",
                "Title",
                "Authors",
                "Publication",
                "Rating",
                "ReadingStage",
                "IsFavourite",
                "IsVanillaReference",
                "Tags",
                "AutoTags",
                "DateAddedToDatabase",
                "DateLastRead",
                "DateLastModified",
                "Filename",
                "Comments",
                "Abstract",
                "",
                "",
                ""
                );
            sb.AppendLine();


            // Write out the entries
            for (int i = 0; i < pdf_documents.Count; ++i)
            {
                PDFDocument pdf_document = pdf_documents[i];

                try
                {
                    StatusManager.Instance.UpdateStatus("TabExport", String.Format("Exporting entry {0} of {1}", i, pdf_documents.Count), i, pdf_documents.Count);

                    HashSet <string> autotags_set = pdf_document.Library.AITagManager.AITags.GetTagsWithDocument(pdf_document.Fingerprint);
                    string           autotags     = ArrayFormatter.ListElements(autotags_set.ToList(), ";");

                    sb.AppendFormat(
                        "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\t{9}\t{10}\t{11}\t{12}\t{13}\t{14}\t{15}\t{16}\t{17}\t{18}\t{19}\t{20}",
                        pdf_document.Fingerprint,
                        pdf_document.BibTexKey,
                        pdf_document.YearCombined,
                        pdf_document.TitleCombined,
                        pdf_document.AuthorsCombined,
                        pdf_document.Publication,
                        pdf_document.Rating,
                        pdf_document.ReadingStage,
                        pdf_document.IsFavourite,
                        pdf_document.IsVanillaReference,
                        pdf_document.Tags,
                        autotags,
                        FormatDate(pdf_document.DateAddedToDatabase),
                        FormatDate(pdf_document.DateLastRead),
                        FormatDate(pdf_document.DateLastModified),
                        pdf_document_export_items.ContainsKey(pdf_document.Fingerprint) ? pdf_document_export_items[pdf_document.Fingerprint].filename : "",
                        FormatFreeText(pdf_document.Comments),
                        FormatFreeText(pdf_document.Abstract),
                        null,
                        null,
                        null
                        );

                    sb.AppendLine();
                }

                catch (Exception ex)
                {
                    Logging.Error(ex, "There was a problem exporting the tab representation for " + pdf_document);
                }
            }

            // Write to disk
            string filename = base_path + @"Qiqqa.tab";

            File.WriteAllText(filename, sb.ToString());

            StatusManager.Instance.UpdateStatus("TabExport", String.Format("Exported your tab entries to {0}", filename));
        }
示例#5
0
 public override string ToString()
 {
     return(ArrayFormatter.ListElements(list, "\n") + "\n");
 }