private void FormSubmit_FormClosing(object sender, FormClosingEventArgs e) { // If the post-review was successful, save the review info to the list for next time. if (DialogResult == DialogResult.OK) { PostReview.ReviewInfo reviewInfo = Review; if (reviewInfo != null) { // Always insert new items just below the "<New>" entry if (!comboReviewIds.Items.Contains(reviewInfo)) { comboReviewIds.Items.Insert(1, Review); Properties.Settings.Default.reviewIdHistory = new ArrayList(comboReviewIds.Items); } } } else { Review = null; } Properties.Settings.Default.Location = this.DesktopBounds.Location; Properties.Settings.Default.Size = this.DesktopBounds.Size; Properties.Settings.Default.Save(); }
private int GetSelectedReviewId() { int reviewId; switch (comboReviewIds.SelectedIndex) { case -1: // Pre-validated comboReviewIds_KeyDown in and comboReviewIds_TextUpdate // Should never throw an exception reviewId = int.Parse(comboReviewIds.Text); break; case 0: reviewId = 0; break; default: // Should never throw InvalidCastException PostReview.ReviewInfo reviewInfo = (PostReview.ReviewInfo)comboReviewIds.SelectedItem; reviewId = reviewInfo.Id; break; } return(reviewId); }