示例#1
0
 private void GetInstitution(string strInstitution)
 {
     if (!lsbInstitution.Items.Contains(strInstitution))
     {
         RLiteratureInstitution newInstitution = new RLiteratureInstitution();
         newInstitution.Institution = strInstitution;
         lstLiteratureInstitution.Add(newInstitution);
         lsbInstitution.Items.Add(strInstitution);
     }
 }
示例#2
0
        private void btnBibTeX_Click(object sender, EventArgs e)
        {
            // First, create a temp literature log, use it to generate BibTeX
            // So that we don't need to care if the BibTeX is generated for new literature log or existing literature log
            // Anyway, BibTeX is just a set of attribution and eventually become a string
            CLiterature tmpLiterature = new CLiterature();

            tmpLiterature.Title  = txtTitle.Text;
            tmpLiterature.BibKey = txtBibKey.Text;
            tmpLiterature.JournalOrConferenceName = txtJournalConference.Text;
            tmpLiterature.BibTeX = literatureBib;
            modifiedFlag         = true;

            if (txtTitle.Enabled == false)
            {
                tmpLiterature.DateAdded = G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).DateAdded;
            }
            else
            {
                tmpLiterature.DateAdded = DateTime.Today;
            }
            tmpLiterature.DateModified = DateTime.Today;
            if (txtYear.Text == "")
            {
                tmpLiterature.PublishYear = 9999;
            }
            else
            {
                tmpLiterature.PublishYear = Convert.ToInt32(txtYear.Text);
            }
            List <RLiteratureAuthor> tmpAuthorList = new List <RLiteratureAuthor>();

            for (int i = 0; i < lsbAuthor.Items.Count; i++)
            {
                RLiteratureAuthor tmpAuthor = new RLiteratureAuthor();
                tmpAuthor.Author = lsbAuthor.Items[i].ToString();
                tmpAuthor.Rank   = i;
                tmpAuthorList.Add(tmpAuthor);
            }
            List <RLiteratureInstitution> tmpInstitutionList = new List <RLiteratureInstitution>();

            for (int i = 0; i < lsbInstitution.Items.Count; i++)
            {
                RLiteratureInstitution tmpInstitution = new RLiteratureInstitution();
                tmpInstitution.Institution = lsbInstitution.Items[i].ToString();
                tmpInstitutionList.Add(tmpInstitution);
            }

            switch (cbxBibEntryType.Text)
            {
            case "Article":
                frmBibArticle frmBibArticle = new frmBibArticle(tmpLiterature, tmpAuthorList);
                frmBibArticle.BuildBibTeX += new frmBibArticle.BuildBibTeXHandler(ParseBibTeXText);
                frmBibArticle.Show();
                break;

            case "Mastersthesis":
                RLiteratureAuthor tmpMasterAuthor = new RLiteratureAuthor();
                if (tmpAuthorList.Count > 0)
                {
                    tmpMasterAuthor = tmpAuthorList[0];
                }
                else
                {
                    tmpMasterAuthor.Author = "";
                }
                RLiteratureInstitution tmpMasterInstitution = new RLiteratureInstitution();
                if (tmpInstitutionList.Count > 0)
                {
                    tmpMasterInstitution = tmpInstitutionList[0];
                }
                else
                {
                    tmpMasterInstitution.Institution = "";
                }
                frmBibMasterThesis frmBibMasterThesis = new frmBibMasterThesis(tmpLiterature, tmpMasterAuthor, tmpMasterInstitution);
                frmBibMasterThesis.BuildBibTeX += new frmBibMasterThesis.BuildBibTeXHandler(ParseBibTeXText);
                frmBibMasterThesis.Show();
                break;

            case "Phdthesis":
                RLiteratureAuthor tmpPhDAuthor = new RLiteratureAuthor();
                if (tmpAuthorList.Count > 0)
                {
                    tmpPhDAuthor = tmpAuthorList[0];
                }
                else
                {
                    tmpPhDAuthor.Author = "";
                }
                RLiteratureInstitution tmpPhDInstitution = new RLiteratureInstitution();
                if (tmpInstitutionList.Count > 0)
                {
                    tmpPhDInstitution = tmpInstitutionList[0];
                }
                else
                {
                    tmpPhDInstitution.Institution = "";
                }
                frmBibPhDThesis frmBibPhDThesis = new frmBibPhDThesis(tmpLiterature, tmpPhDAuthor, tmpPhDInstitution);
                frmBibPhDThesis.BuildBibTeX += new frmBibPhDThesis.BuildBibTeXHandler(ParseBibTeXText);
                frmBibPhDThesis.Show();
                break;

            case "Conference":
                frmBibConference frmBibConference = new frmBibConference(tmpLiterature, tmpAuthorList);
                frmBibConference.BuildBibTeX += new frmBibConference.BuildBibTeXHandler(ParseBibTeXText);
                frmBibConference.Show();
                break;

            case "Unpublished":
                frmBibUnpublished frmBibUnpublished = new frmBibUnpublished(tmpLiterature, tmpAuthorList);
                frmBibUnpublished.BuildBibTeX += new frmBibUnpublished.BuildBibTeXHandler(ParseBibTeXText);
                frmBibUnpublished.Show();
                break;

            default:
                break;
            }
        }
示例#3
0
        public frmBibPhDThesis(CLiterature inputLiterature, RLiteratureAuthor inputAuthor, RLiteratureInstitution inputSchool)
        {
            InitializeComponent();
            bibTeX.BibEntry = EBibEntry.Phdthesis;
            literature      = inputLiterature;
            txtTitle.Text   = literature.Title;
            txtBibKey.Text  = literature.BibKey;
            bibTeX.BibKey   = literature.BibKey;

            if (inputLiterature.BibTeX != null)
            {
                if (inputLiterature.BibTeX.BibEntry != EBibEntry.Phdthesis)
                {
                    inputLiterature.BibTeX = null;
                }
            }

            if (inputLiterature.BibTeX == null || inputLiterature.BibTeX.Title == "" || inputLiterature.BibTeX.Title == null)
            {
                txtBibTitle.Text = literature.Title;
                bibTeX.Title     = literature.Title;
            }
            else
            {
                txtBibTitle.Text = literature.BibTeX.Title;
                bibTeX.Title     = literature.BibTeX.Title;
            }

            if (inputLiterature.BibTeX == null || inputLiterature.BibTeX.Author == "" || inputLiterature.BibTeX.Author == null)
            {
                string[] thesisAuthorFullName = inputAuthor.Author.Split(" ".ToCharArray());
                string   thesisAuthor         = thesisAuthorFullName[0].Substring(0, 1).ToUpper() + ". " + thesisAuthorFullName[thesisAuthorFullName.Length - 1];
                txtBibAuthor.Text = thesisAuthor;
                bibTeX.Author     = thesisAuthor;
            }
            else
            {
                txtBibAuthor.Text = inputLiterature.BibTeX.Author;
                bibTeX.Author     = inputLiterature.BibTeX.Author;
            }

            if (inputLiterature.BibTeX == null || inputLiterature.BibTeX.Booktitle == "" || inputLiterature.BibTeX.Booktitle == null)
            {
                txtBibSchool.Text = inputSchool.Institution;
                bibTeX.School     = inputSchool.Institution;
            }
            else
            {
                txtBibSchool.Text = literature.BibTeX.School;
                bibTeX.School     = literature.BibTeX.School;
            }

            if (inputLiterature.BibTeX == null || inputLiterature.BibTeX.Year == "" || inputLiterature.BibTeX.Year == null)
            {
                if (literature.PublishYear != 9999)
                {
                    txtBibYear.Text = literature.PublishYear.ToString();
                    bibTeX.Year     = literature.PublishYear.ToString();
                }
                else
                {
                    txtBibYear.Text = "";
                    bibTeX.Year     = "";
                }
            }
            else
            {
                txtBibYear.Text = inputLiterature.BibTeX.Year;
                bibTeX.Year     = inputLiterature.BibTeX.Year;
            }

            if (inputLiterature.BibTeX != null)
            {
                if (inputLiterature.BibTeX.Address != null)
                {
                    txtBibAddress.Text = inputLiterature.BibTeX.Address;
                    bibTeX.Address     = inputLiterature.BibTeX.Address;
                }
                if (inputLiterature.BibTeX.Month != null)
                {
                    cbxBibMonth.Text = inputLiterature.BibTeX.Month;
                    bibTeX.Month     = inputLiterature.BibTeX.Month;
                }
                if (inputLiterature.BibTeX.Note != null)
                {
                    txtBibNote.Text = inputLiterature.BibTeX.Note;
                    bibTeX.Note     = inputLiterature.BibTeX.Note;
                }
                if (inputLiterature.BibTeX.Key != null)
                {
                    txtBibKeyBackup.Text = inputLiterature.BibTeX.Key;
                    bibTeX.Key           = inputLiterature.BibTeX.Key;
                }
            }
            dateAdded      = literature.DateAdded;
            txtBibTeX.Text = ParseBib.ParseBibTeXPhdthesis(bibTeX, dateAdded, DateTime.Today);
        }