private void _okButton_Click(object sender, EventArgs e)
		{
			if(!_didHavePasswordSet && SettingsProtectionSingleton.Settings.RequirePassword)
			{
				using(var dlg = new SettingsPasswordDialog(SettingsProtectionSingleton.FactoryPassword, SettingsPasswordDialog.Mode.MakeSureTheyKnowPassword))
				{
					if (DialogResult.Cancel == dlg.ShowDialog())
						return; //they couldn't come up with the password
				}
			}

			SettingsProtectionSingleton.Settings.Save();
			Close();
		}
		/// <summary>
		/// The control should call this when the user clicks on it. It will challenge if necessary, and carry out the supplied code if everything is rosy.
		/// </summary>
		/// <param name="settingsLaunchingFunction"></param>
		/// <returns>DialogResult.Cancel if the challenge fails, otherwise whatever the settingsLaunchingFunction returns.</returns>
		public DialogResult LaunchSettingsIfAppropriate(Func<DialogResult> settingsLaunchingFunction)
		{
			if (SettingsProtectionSingleton.Settings.RequirePassword)
			{
				using (var dlg = new SettingsPasswordDialog(SettingsProtectionSingleton.FactoryPassword, SettingsPasswordDialog.Mode.Challenge))
				{
					if (DialogResult.OK != dlg.ShowDialog())
						return DialogResult.Cancel;
				}
			}
			var result = settingsLaunchingFunction();
			UpdateDisplay();
			return result;
		}
예제 #3
0
        private void _okButton_Click(object sender, EventArgs e)
        {
            if (!_didHavePasswordSet && SettingsProtectionSingleton.Settings.RequirePassword)
            {
                using (var dlg = new SettingsPasswordDialog(SettingsProtectionSingleton.FactoryPassword, SettingsPasswordDialog.Mode.MakeSureTheyKnowPassword))
                {
                    if (DialogResult.Cancel == dlg.ShowDialog())
                    {
                        return;                         //they couldn't come up with the password
                    }
                }
            }

            SettingsProtectionSingleton.Settings.Save();
            Close();
        }
        /// <summary>
        /// The control should call this when the user clicks on it. It will challenge if necessary, and carry out the supplied code if everything is rosy.
        /// </summary>
        /// <param name="settingsLaunchingFunction"></param>
        /// <returns>DialogResult.Cancel if the challenge fails, otherwise whatever the settingsLaunchingFunction returns.</returns>
        public DialogResult LaunchSettingsIfAppropriate(Func <DialogResult> settingsLaunchingFunction)
        {
            if (SettingsProtectionSingleton.Settings.RequirePassword)
            {
                using (var dlg = new SettingsPasswordDialog(SettingsProtectionSingleton.FactoryPassword, SettingsPasswordDialog.Mode.Challenge))
                {
                    if (DialogResult.OK != dlg.ShowDialog())
                    {
                        return(DialogResult.Cancel);
                    }
                }
            }
            var result = settingsLaunchingFunction();

            UpdateDisplay();
            return(result);
        }