partial void newAccountButton(NSObject sender) { if (websiteField.StringValue != string.Empty && accountField.StringValue != string.Empty && PasswordGenerator.IsSecure(passwordField.StringValue)) { AddNewAccount(websiteField.StringValue, accountField.StringValue, passwordField.StringValue, indexToEdit); } else { foreach (var textField in NSTextFields) { if (textField.StringValue == string.Empty) { textField.BackgroundColor = NSColor.Red; } else { textField.BackgroundColor = NSColor.Clear; } } if (passwordField.StringValue != String.Empty && !PasswordGenerator.IsSecure(passwordField.StringValue)) { var alert = new NSAlert() { AlertStyle = NSAlertStyle.Informational, InformativeText = "Your password is insecure. Secure passwords contain at least 2 of each: special character, number, lowercase character, uppercase character.", MessageText = "Insecure Password", }; alert.AddButton("OK"); alert.AddButton("Ignore"); var result = alert.RunModal(); if (result == 1000) { passwordField.BackgroundColor = NSColor.Yellow; } if (result == 1001) { AddNewAccount(websiteField.StringValue, accountField.StringValue, passwordField.StringValue, indexToEdit); } } } }
partial void GeneratePasswordButton(NSObject sender) { passwordField.StringValue = PasswordGenerator.GeneratePassword(); }