private void btnDeleteProfile_Click(object sender, EventArgs e) { if (lbProfiles.SelectedIndex > -1) { // Make sure they are sure! if (MessageBox.Show("Are you sure you want to delete this profile?" + Environment.NewLine + "This cannot be undone!", "SpamGrabber", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { // See if this was one of the defaults Profile objProfile = UserProfiles.GetProfileByName(GetSelectedProfileName()); if (GlobalSettings.DefaultSpamProfileId.Equals(objProfile.Id)) { GlobalSettings.DefaultSpamProfileId = string.Empty; GlobalSettings.ResetDefaultProfile(GlobalSettings.DefaultType.Spam); } if (GlobalSettings.DefaultHamProfileId.Equals(objProfile.Id)) { GlobalSettings.DefaultHamProfileId = string.Empty; GlobalSettings.ResetDefaultProfile(GlobalSettings.DefaultType.Ham); } // Delete the profile UserProfiles.DeleteProfile(objProfile.Name); // Clear all required caches and fire update event UserProfiles.ClearProfileCache(); PopulateList(); ProfileListChanged(this); } } }
private void ManageProfilesControl_ProfileListChanged(object sender) { // Clear the profile cache just in case UserProfiles.ClearProfileCache(); // Update the treeview LoadTreeView(); }
private void btnAddProfile_Click(object sender, EventArgs e) { frmNewProfile objNewProfile = new frmNewProfile(); objNewProfile.ShowDialog(); if (objNewProfile.Result == DialogResult.OK) { // Clear all required caches and fire update event UserProfiles.ClearProfileCache(); PopulateList(); ProfileListChanged(this); } }
private void cancelButton_Click(object sender, EventArgs e) { // Clear the profile cache UserProfiles.ClearProfileCache(); // Clear the loaded profile cache this.LoadedProfiles.Clear(); // Reset any changes made to global settings GlobalSettings.LoadSettings(); // Close the form this.DialogResult = DialogResult.Cancel; this.Close(); }