private void DontShowThisAgainButton_Click(object sender, System.EventArgs e) { if (_settings == null) { Debug.Fail("You need to call GetOKToShow() on the DontShowThisAgainButton."); } var key = DialogsToHide + _key + ","; DialogsToHide = DialogsToHide.Replace(key, ""); if (this.Checked) { DialogsToHide = key; } }
/// <summary> /// Call this to decide whether to show the dialog /// </summary> /// <param name="settings">enter your Settings.Default. Make sure you have a string property named DontShowThisAgain</param> /// <param name="key">A key to use for the list of things not-to-show. You're welcome to use a big long string (like a tip message itself); a hash will be used</param> /// <returns>true if you should show it</returns> public bool GetOKToShow(ApplicationSettingsBase settings, string key = null) { if (string.IsNullOrEmpty(key)) { _key = FindForm().Name; } else { _key = key.GetHashCode().ToString(); } _settings = settings; if (settings == null || DesignMode) { return(true); } return(!DialogsToHide.Contains(_key + ",")); }