/// <summary> /// Displays the dialog. /// </summary> public bool ShowDialog(ApplicationAccessRule accessRule) { AccessTypeCB.SelectedItem = accessRule.RuleType; IdentityNameTB.Text = accessRule.IdentityName; m_identity = accessRule.IdentityReference; if (m_identity == null) { AccountInfo account = AccountInfo.Create(IdentityNameTB.Text); if (account != null) { m_identity = account.GetIdentityReference(); } } if (accessRule.Right != ApplicationAccessRight.None) { AccessRightCB.SelectedItem = accessRule.Right; } if (ShowDialog() != DialogResult.OK) { return(false); } accessRule.RuleType = (AccessControlType)AccessTypeCB.SelectedItem; accessRule.Right = (ApplicationAccessRight)AccessRightCB.SelectedItem; accessRule.IdentityReference = m_identity; return(true); }
private void OkBTN_Click(object sender, EventArgs e) { try { if (m_identity == null) { AccountInfo account = AccountInfo.Create(IdentityNameTB.Text); if (account == null) { throw new ApplicationException("Please specified a valid identity."); } m_identity = account.GetIdentityReference(); } // close the dialog. DialogResult = DialogResult.OK; } catch (Exception exception) { GuiUtils.HandleException(this.Text, System.Reflection.MethodBase.GetCurrentMethod(), exception); } }