Пример #1
0
        TagEntry GetAuthorTagFromParser(string name)
        {
            var text     = @"@article{Test, author = {" + name + @"}}";
            var database = BibTexHelper.CreateBibTexDatabase(text);

            return(database["Test"]["author"]);
        }
Пример #2
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                Title         = "Choose BibTex database...",
                ValidateNames = true,
            };

            if (!string.IsNullOrEmpty(CustomDatabaseFilename))
            {
                try
                {
                    var fileInfo = new FileInfo(CustomDatabaseFilename);

                    openFileDialog.InitialDirectory = fileInfo.DirectoryName;
                    openFileDialog.FileName         = fileInfo.Name;
                }
                catch
                {}
            }

            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                var newDatabase = BibTexHelper.LoadBibTexDatabase(openFileDialog.FileName);
                if (newDatabase == null)
                {
                    Helper.ShowCorruptBibtexDatabaseMessage(openFileDialog.FileName);
                    return;
                }

                CustomDatabaseFilename   = openFileDialog.FileName;
                UseDocearDefaultDatabase = false;
            }
        }
Пример #3
0
        public BibTexDatabase GetDatabaseTest()
        {
            string         documentDatabaseFilename = "E:\\D4W_Test\\XML.bib";
            BibTexDatabase result = BibTexHelper.LoadBibTexDatabase(documentDatabaseFilename);

            return(result);
        }
Пример #4
0
        public void XXX()
        {
            var database = BibTexHelper.LoadBibTextDatabase(@"Sample Files\Mendeley 2.bib");
            //var database = BibTexHelper.LoadBibTextDatabase(@"Sample Files\b4w.bib");
            //var database = BibTexHelper.LoadBibTextDatabase(@"Sample Files\BigFile.bib");
            var converter = new BibTexToCSLConverter();

            var q = converter.ToJSON(database);

            Console.WriteLine(q);
            File.WriteAllText(@"F:\old.txt", q);
        }
Пример #5
0
        public void TestBibTexToCSLConverter()
        {
            var database  = BibTexHelper.LoadBibTextDatabase(@"Sample Files\Docear.bib");
            var converter = new BibTexToCSLConverter();

/*
 * var temp = new BibTeXDatabase();
 * temp.AddEntry(database[0]);
 * temp.AddEntry(database[1]);
 * database = temp;
 */
            Console.WriteLine(converter.ToJSON(database));
        }
Пример #6
0
        public void XXX2()
        {
            var text      = @"
@techreport{Brandstadt91a,
author = {Andreas Brandst\""{a}dt},
title = {Special Graph Classes --- A Survey (preliminary version)},
institution = {University of Duisburg},
year = 1991}
";
            var database  = BibTexHelper.CreateBibTextDatabase(text);
            var converter = new BibTexToCSLConverter();

            Console.WriteLine(converter.ToJSON(database));
        }
Пример #7
0
        public void XXXNew()
        {
            var database = BibTexHelper.LoadBibTextDatabase(@"Sample Files\Mendeley 2.bib");
            //var database = BibTexHelper.LoadBibTextDatabase(@"Sample Files\b4w.bib");
            //var database = BibTexHelper.LoadBibTextDatabase(@"Sample Files\BigFile.bib");
            var citeproc  = new CiteProcRunner(HavardCslStyle, () => database);
            var converter = new BibTexToCSLConverter(citeproc);

            var result = converter.CreateItem(database);
            var q      = citeproc.ToJSON(result.JSObject);

            File.WriteAllText(@"F:\new.txt", q);

//			Debug.WriteLine(q);
        }
Пример #8
0
        public void Test02()
        {
            var database = BibTexHelper.LoadBibTexDatabase(@"Sample Files\Docear.bib");
            var citeproc = new CiteProcRunner(HavardCslStyle, () => database);

            var idList = database.GetEntryNames().ToArray();

            idList = database.GetEntryNames().Take(300).ToArray();
            Console.WriteLine("Total of " + idList.Length + " items.");


            citeproc.UpdateItems(idList, false, true);

            //var bib = citeproc.MakeBibliography();

            //foreach (var entry in bib.Entries) Console.WriteLine(entry);
        }
        void btnChooseDatabase_Click(object sender, EventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                Title         = "Choose BibTex database...",
                ValidateNames = true,
            };

            if (database != null)
            {
                if (database.Filename != null)
                {
                    var fileInfo = new FileInfo(database.Filename);

                    openFileDialog.InitialDirectory = fileInfo.DirectoryName;
                    openFileDialog.FileName         = fileInfo.Name;
                }
            }

            if (openFileDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            // If the user selected the same file we already had, then do nothing
            if (database != null && openFileDialog.FileName == database.Filename)
            {
                return;
            }

            var newDatabase = BibTexHelper.LoadBibTexDatabase(openFileDialog.FileName);

            if (newDatabase == null)
            {
                Helper.ShowCorruptBibtexDatabaseMessage(openFileDialog.FileName);

                return;
            }

            Reset(newDatabase);
        }