예제 #1
0
 //Editing entry
 public EditEntry(int entityIndex)
 {
     InitializeComponent();
     IsNew = false;
     editEntity = BibEntity.entityList[entityIndex];
     entryType = editEntity.EntityType;
     generateFields();
     populateFields(ref editEntity);
     this.Title = editEntity.Title;
 }
예제 #2
0
 //Grab info from the entity to edit and push values to the fields
 private void populateFields(ref BibEntity editEntity)
 {
     //Populate common fields
     titleField.Text = editEntity.Title;
     authorField.Text = editEntity.Authors.Print();
     yearField.Text = editEntity.Year.ToString();
     //Type-specific fields
     switch(editEntity.EntityType)
     {
         case EntityType.BOOK:
             publisherField.Text = editEntity.Publisher;
             publisherAddrField.Text = editEntity.PublisherAddr;
             break;
         case EntityType.THESIS:
             //Turns out, setting the selected item to an item that is in the ComboBox... works!
             //https://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.selecteditem(v=vs.110).aspx
             if (editEntity.ThesisEntityType == ThesisType.MASTERSTHESIS) thesisTypeBox.SelectedItem = thesisTypeMaster;
             if (editEntity.ThesisEntityType == ThesisType.PHDTHESIS) thesisTypeBox.SelectedItem = thesisTypePHD;
             thesisTypeBox.SelectionChanged += thesisTypeChangeHandle; //Add the handle after populating this field, otherwise that will trigger a false change
             schoolField.Text = editEntity.School;
             break;
         case EntityType.ARTICLE:
             journalField.Text = editEntity.Journal;
             volumeField.Text = editEntity.Volume.ToString();
             break;
     }
 }