// Controls adding an illustration to a definition and to a headword. private void btn_AddIllustration_Click(object sender, EventArgs e) { // Make sure there is a short definition before adding any illustrations. if (tb_ShortDef.Text != "") { // Open up a dialog box to add a new Illustration to our defintion. // If the user presses OK then store the information in the current illustration. IllustrationForm newIllustrationForm = new IllustrationForm(this, tb_ShortDef.Text); if (newIllustrationForm.ShowDialog(this) == DialogResult.OK) { if (newIllustrationForm.Translation == "" || newIllustrationForm.Illustration == "") { MessageBox.Show("Please enter both fields before pressing enter", "Error", MessageBoxButtons.OK); } else { // Create a new Illustration with a unique ID number, get the illustration and translation. Illustration newIllustration = new Illustration(theHeadword.Illustrations.Count + 1); newIllustration.IllDescription = newIllustrationForm.Illustration; newIllustration.Translation = newIllustrationForm.Translation; // Add remaining data to the illustration. newIllustration.Headword = tb_Headword.Text; // Add the illustration to theHeadword object and the definition. definition.Illustrations.Add(newIllustration); tb_NumberOfIllustrations.Text = theHeadword.Illustrations.Count.ToString(); } // Close the window. newIllustrationForm.Dispose(); } } else { MessageBox.Show("Enter a Short Definition before adding any Illustrations", "Error", MessageBoxButtons.OK); } }
// Controls adding an illustration to a definition and to a headword. private void btn_AddIllustration_Click(object sender, EventArgs e) { // Make sure there is a short definition before adding any illustrations. if (tb_ShortDef.Text != "") { // Open up a dialog box to add a new Illustration to our defintion. // If the user presses OK then store the information in the current illustration. IllustrationForm newIllustrationForm = new IllustrationForm(this, tb_ShortDef.Text); if (newIllustrationForm.ShowDialog(this) == DialogResult.OK ) { if (newIllustrationForm.Translation == "" || newIllustrationForm.Illustration == "") { MessageBox.Show("Please enter both fields before pressing enter","Error",MessageBoxButtons.OK); } else { // Create a new Illustration with a unique ID number, get the illustration and translation. Illustration newIllustration = new Illustration(theHeadword.Illustrations.Count + 1); newIllustration.IllDescription = newIllustrationForm.Illustration; newIllustration.Translation = newIllustrationForm.Translation; // Add remaining data to the illustration. newIllustration.Headword = tb_Headword.Text; // Add the illustration to theHeadword object and the definition. definition.Illustrations.Add(newIllustration); tb_NumberOfIllustrations.Text = theHeadword.Illustrations.Count.ToString(); } // Close the window. newIllustrationForm.Dispose(); } } else { MessageBox.Show("Enter a Short Definition before adding any Illustrations", "Error", MessageBoxButtons.OK); } }