public frmInfoLiterature(string LiteratureTitle) { literature = G.glb.lstLiterature.Find(o => o.Title == LiteratureTitle); lstLiteratureTag = G.glb.lstLiteratureTag.FindAll(o => o.Title == LiteratureTitle).ToList(); lstLiteratureAuthor = G.glb.lstLiteratureAuthor.FindAll(o => o.Title == LiteratureTitle).ToList(); lstLiteratureAuthor = lstLiteratureAuthor.OrderBy(o => o.Rank).ToList(); InOneSentence = literature.InOneSentence; lstLiteratureInstitution = G.glb.lstLiteratureInstitution.FindAll(o => o.Title == LiteratureTitle).ToList(); lstLiteratureInCiting = G.glb.lstLiteratureCiting.FindAll(o => o.Title == LiteratureTitle).ToList(); lstLiteratureOutsource = G.glb.lstLiteratureOutSource.FindAll(o => o.Title == LiteratureTitle).ToList(); lstNote = G.glb.lstNote.FindAll(o => o.LiteratureTitle == LiteratureTitle).ToList(); lstSurveyLiterature = G.glb.lstSurveyLiterature.FindAll(o => o.LiteratureTitle == LiteratureTitle).ToList(); literatureBib = literature.BibTeX; InitializeComponent(); LoadLiterature(); modifiedFlag = false; }
public frmBibArticle(CLiterature inputLiterature, List <RLiteratureAuthor> inputAuthorList) { InitializeComponent(); bibTeX.BibEntry = EBibEntry.Article; literature = inputLiterature; txtTitle.Text = literature.Title; txtBibKey.Text = literature.BibKey; bibTeX.BibKey = literature.BibKey; if (inputLiterature.BibTeX != null) { if (inputLiterature.BibTeX.BibEntry != EBibEntry.Article) { 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) { txtBibAuthor.Text = ParseBib.GetAuthor(inputAuthorList); bibTeX.Author = txtBibAuthor.Text; } else { txtBibAuthor.Text = inputLiterature.BibTeX.Author; bibTeX.Author = inputLiterature.BibTeX.Author; } if (inputLiterature.BibTeX == null || inputLiterature.BibTeX.Journal == "" || inputLiterature.BibTeX.Journal == null) { txtBibJournal.Text = literature.JournalOrConferenceName; bibTeX.Journal = literature.JournalOrConferenceName; } else { txtBibJournal.Text = literature.BibTeX.Journal; bibTeX.Journal = literature.BibTeX.Journal; } 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.Volume != null) { txtBibVolume.Text = inputLiterature.BibTeX.Volume; bibTeX.Volume = inputLiterature.BibTeX.Volume; } if (inputLiterature.BibTeX.Number != null) { txtBibNumber.Text = inputLiterature.BibTeX.Number; bibTeX.Number = inputLiterature.BibTeX.Number; } if (inputLiterature.BibTeX.Pages != null) { txtBibPages.Text = inputLiterature.BibTeX.Pages; bibTeX.Pages = inputLiterature.BibTeX.Pages; } 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.ParseBibTeXArticle(bibTeX, dateAdded, DateTime.Today); }
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; } }
private void frmAddLiterature_FormClosing(object sender, FormClosingEventArgs e) { bool CanSaveFlag = true; bool EntirelyEmptyFlag = true; if (modifiedFlag) { if (txtTitle.Text == "") { MessageBox.Show("Title is missing."); CanSaveFlag = false; } else { EntirelyEmptyFlag = false; } if (G.glb.lstLiterature.Exists(o => o.Title == txtTitle.Text) && txtTitle.Enabled == true) { MessageBox.Show("Literature exists."); CanSaveFlag = false; } if (G.glb.lstLiterature.Exists(o => o.BibKey != "" && o.BibKey == txtBibKey.Text && o.Title != txtTitle.Text)) { MessageBox.Show("Bibkey exists."); CanSaveFlag = false; } if (txtYear.Text == "") { MessageBox.Show("Publish year is missing"); CanSaveFlag = false; } else { EntirelyEmptyFlag = false; } if (txtJournalConference.Text == "") { MessageBox.Show("Journal/Conference Name is missing"); CanSaveFlag = false; } else { EntirelyEmptyFlag = false; } if (lsbAuthor.Items.Count == 0) { MessageBox.Show("Add author"); CanSaveFlag = false; } else { EntirelyEmptyFlag = false; } if (lsbTag.Items.Count == 0) { MessageBox.Show("Add tag"); CanSaveFlag = false; } else { EntirelyEmptyFlag = false; } if (lsbInstitution.Items.Count == 0) { MessageBox.Show("Add institution"); CanSaveFlag = false; } else { EntirelyEmptyFlag = false; } if (CanSaveFlag) { // 如果本来没有这篇文献,说明是新增文献,否则是删改文献 if (!G.glb.lstLiterature.Exists(o => o.Title == txtTitle.Text)) { CLiterature newLiterature = new CLiterature(); newLiterature.Title = txtTitle.Text; newLiterature.PublishYear = Convert.ToInt32(txtYear.Text); newLiterature.JournalOrConferenceName = txtJournalConference.Text; newLiterature.InOneSentence = txtInOneSentence.Text; newLiterature.BibKey = txtBibKey.Text; newLiterature.BibTeX = literatureBib; newLiterature.DateAdded = DateTime.Today; newLiterature.DateModified = DateTime.Today; newLiterature.Star = chkStar.Checked; newLiterature.PredatoryAlert = chkPredatroyAlert.Checked; foreach (RLiteratureAuthor author in lstLiteratureAuthor) { author.Title = txtTitle.Text; } foreach (RLiteratureOutSource outSource in lstLiteratureOutsource) { outSource.Title = txtTitle.Text; } foreach (RLiteratureTag tag in lstLiteratureTag) { tag.Title = txtTitle.Text; } foreach (RLiteratureInstitution institution in lstLiteratureInstitution) { institution.Title = txtTitle.Text; } foreach (RLiteratureInCiting inCiting in lstLiteratureInCiting) { inCiting.Title = txtTitle.Text; } foreach (RSurveyLiterature surveyLiterature in lstSurveyLiterature) { surveyLiterature.LiteratureTitle = txtTitle.Text; if (!G.glb.lstSurvey.Exists(o => o.SurveyTitle == surveyLiterature.SurveyTitle)) { CSurvey survey = new CSurvey(); survey.SurveyTitle = surveyLiterature.SurveyTitle; G.glb.lstSurvey.Add(survey); } } G.glb.lstLiterature.Add(newLiterature); G.glb.lstLiteratureTag.AddRange(lstLiteratureTag); G.glb.lstLiteratureAuthor.AddRange(lstLiteratureAuthor); G.glb.lstLiteratureOutSource.AddRange(lstLiteratureOutsource); G.glb.lstLiteratureInstitution.AddRange(lstLiteratureInstitution); G.glb.lstLiteratureCiting.AddRange(lstLiteratureInCiting); G.glb.lstSurveyLiterature.AddRange(lstSurveyLiterature); } else { G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).PublishYear = Convert.ToInt32(txtYear.Text); G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).JournalOrConferenceName = txtJournalConference.Text; G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).InOneSentence = txtInOneSentence.Text; G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).BibKey = txtBibKey.Text; G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).BibTeX = literatureBib; G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).DateModified = DateTime.Today; G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).Star = chkStar.Checked; G.glb.lstLiterature.Find(o => o.Title == txtTitle.Text).PredatoryAlert = chkPredatroyAlert.Checked; foreach (RLiteratureAuthor author in lstLiteratureAuthor) { author.Title = txtTitle.Text; } foreach (RLiteratureTag tag in lstLiteratureTag) { tag.Title = txtTitle.Text; } foreach (RLiteratureOutSource outSource in lstLiteratureOutsource) { outSource.Title = txtTitle.Text; } foreach (RLiteratureInstitution institution in lstLiteratureInstitution) { institution.Title = txtTitle.Text; } foreach (RLiteratureInCiting inCiting in lstLiteratureInCiting) { inCiting.Title = txtTitle.Text; } G.glb.lstLiteratureAuthor.RemoveAll(o => o.Title == txtTitle.Text); G.glb.lstLiteratureTag.RemoveAll(o => o.Title == txtTitle.Text); G.glb.lstLiteratureOutSource.RemoveAll(o => o.Title == txtTitle.Text); G.glb.lstLiteratureInstitution.RemoveAll(o => o.Title == txtTitle.Text); G.glb.lstLiteratureCiting.RemoveAll(o => o.Title == txtTitle.Text); G.glb.lstLiteratureTag.AddRange(lstLiteratureTag); G.glb.lstLiteratureAuthor.AddRange(lstLiteratureAuthor); G.glb.lstLiteratureOutSource.AddRange(lstLiteratureOutsource); G.glb.lstLiteratureInstitution.AddRange(lstLiteratureInstitution); G.glb.lstLiteratureCiting.AddRange(lstLiteratureInCiting); } foreach (object item in lsbAuthor.Items) { if (!G.glb.lstAuthor.Exists(o => o.Author == item.ToString())) { CAuthor author = new CAuthor(); author.Author = item.ToString(); author.IsReliable = false; author.PrimeAffiliation = ""; G.glb.lstAuthor.Add(author); } } RefreshTab(); Dispose(); } else { if (!EntirelyEmptyFlag) { e.Cancel = true; } } } }
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); }
public frmBibConference(CLiterature inputLiterature, List <RLiteratureAuthor> inputAuthorList) { InitializeComponent(); bibTeX.BibEntry = EBibEntry.Conference; literature = inputLiterature; txtTitle.Text = literature.Title; txtBibKey.Text = literature.BibKey; bibTeX.BibKey = literature.BibKey; if (inputLiterature.BibTeX != null) { if (inputLiterature.BibTeX.BibEntry != EBibEntry.Conference) { 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) { txtBibAuthor.Text = ParseBib.GetAuthor(inputAuthorList); bibTeX.Author = txtBibAuthor.Text; } else { txtBibAuthor.Text = inputLiterature.BibTeX.Author; bibTeX.Author = inputLiterature.BibTeX.Author; } if (inputLiterature.BibTeX == null || inputLiterature.BibTeX.Booktitle == "" || inputLiterature.BibTeX.Booktitle == null) { txtBibBooktitle.Text = literature.JournalOrConferenceName; bibTeX.Booktitle = literature.JournalOrConferenceName; } else { txtBibBooktitle.Text = literature.BibTeX.Booktitle; bibTeX.Booktitle = literature.BibTeX.Booktitle; } 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.Editor != null) { txtBibEditor.Text = inputLiterature.BibTeX.Editor; bibTeX.Editor = inputLiterature.BibTeX.Editor; } if (inputLiterature.BibTeX.Pages != null) { txtBibPages.Text = inputLiterature.BibTeX.Pages; bibTeX.Pages = inputLiterature.BibTeX.Pages; } if (inputLiterature.BibTeX.Organization != null) { txtBibOrganization.Text = inputLiterature.BibTeX.Organization; bibTeX.Organization = inputLiterature.BibTeX.Organization; } if (inputLiterature.BibTeX.Publisher != null) { txtBibPublisher.Text = inputLiterature.BibTeX.Publisher; bibTeX.Publisher = inputLiterature.BibTeX.Publisher; } 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.ParseBibTeXConference(bibTeX, dateAdded, DateTime.Today); }