public static Dialog CreateDialog(Action okAction) { PasswordGeneratorState state = new PasswordGeneratorState(); var ok = new Button(3, 14, LocMan.Get("Ok")); ok.Clicked += () => { okAction.Invoke(); }; var dialog = new Dialog(LocMan.Get("🎲 Random Password Generator"), 60, 20, ok); var passwordLengthLabel = new Label(1, 1, LocMan.Get("Password length:")); var positiveNumbersOnlyProvider = new TextRegexProvider("^[1-9]+[0-9]$") { ValidateOnInput = true }; var passwordLengthTextField = new TextValidateField(positiveNumbersOnlyProvider) { X = 1, Y = 2, Width = 4, Height = 1 }; passwordLengthTextField.Text = state.PasswordLength.ToString(); var useUppercase = new CheckBox(1, 4, "Upper-case latin characters (e.g. A, C, K, Z)", state.IncludeUpperCaseLatinLetters); useUppercase.Toggled += (bool old) => { state.IncludeUpperCaseLatinLetters = !old; }; var useLowercase = new CheckBox(1, 5, "Lower-case latin characters (e.g. a, c, k, z)", state.IncludeLowerCaseLatinLetters); useLowercase.Toggled += (bool old) => { state.IncludeLowerCaseLatinLetters = !old; }; var useDigits = new CheckBox(1, 6, "Digits (e.g. 4, 6, 9)", state.IncludeDigits); useDigits.Toggled += (bool old) => { state.IncludeDigits = !old; }; var useSpecialASCII = new CheckBox(1, 7, "Special characters ASCII", state.IncludeSpecialCharactersASCII); useSpecialASCII.Toggled += (bool old) => { state.IncludeSpecialCharactersASCII = !old; }; var useBasicEmojis = new CheckBox(1, 8, "Basic emoji (e.g. 😊)", state.IncludeEmojis); useBasicEmojis.Toggled += (bool old) => { state.IncludeEmojis = !old; }; var generatedPasswordLabel = new Label(1, 10, LocMan.Get("Generated password:"******"") { ReadOnly = true, X = 1, Y = 11, Width = Dim.Fill(), Height = 1 }; var copyToClipboardButton = new Button(3, 12, LocMan.Get("Copy to Clipboard")); var generateButton = new Button(25, 12, LocMan.Get("Generate")); generateButton.Clicked += () => { GenerateRandomPassword(state); generatedPasswordField.Text = state.GeneratedPassword; }; dialog.Add(passwordLengthLabel, passwordLengthTextField, useUppercase, useLowercase, useDigits, useSpecialASCII, useBasicEmojis, generatedPasswordLabel, generatedPasswordField, copyToClipboardButton, generateButton); return(dialog); }
public override void Setup() { var s = "TAB to jump between text fields."; var textField = new TextField(s) { X = 1, Y = 1, Width = Dim.Percent(50), //ColorScheme = Colors.Dialog }; Win.Add(textField); var labelMirroringTextField = new Label(textField.Text) { X = Pos.Right(textField) + 1, Y = Pos.Top(textField), Width = Dim.Fill(1) }; Win.Add(labelMirroringTextField); textField.TextChanged += (prev) => { labelMirroringTextField.Text = textField.Text; }; var textView = new TextView() { X = 1, Y = 3, Width = Dim.Percent(50), Height = Dim.Percent(30), ColorScheme = Colors.Dialog }; textView.Text = s; Win.Add(textView); var labelMirroringTextView = new Label(textView.Text) { X = Pos.Right(textView) + 1, Y = Pos.Top(textView), Width = Dim.Fill(1), Height = Dim.Height(textView), }; Win.Add(labelMirroringTextView); textView.TextChanged += () => { labelMirroringTextView.Text = textView.Text; }; var btnMultiline = new Button("Toggle Multiline") { X = Pos.Right(textView) + 1, Y = Pos.Top(textView) + 1 }; btnMultiline.Clicked += () => textView.Multiline = !textView.Multiline; Win.Add(btnMultiline); // BUGBUG: 531 - TAB doesn't go to next control from HexView var hexView = new HexView(new System.IO.MemoryStream(Encoding.ASCII.GetBytes(s))) { X = 1, Y = Pos.Bottom(textView) + 1, Width = Dim.Fill(1), Height = Dim.Percent(30), //ColorScheme = Colors.Dialog }; Win.Add(hexView); var dateField = new DateField(System.DateTime.Now) { X = 1, Y = Pos.Bottom(hexView) + 1, Width = 20, //ColorScheme = Colors.Dialog, IsShortFormat = false }; Win.Add(dateField); var labelMirroringDateField = new Label(dateField.Text) { X = Pos.Right(dateField) + 1, Y = Pos.Top(dateField), Width = Dim.Width(dateField), Height = Dim.Height(dateField), }; Win.Add(labelMirroringDateField); dateField.TextChanged += (prev) => { labelMirroringDateField.Text = dateField.Text; }; _timeField = new TimeField(DateTime.Now.TimeOfDay) { X = Pos.Right(labelMirroringDateField) + 5, Y = Pos.Bottom(hexView) + 1, Width = 20, //ColorScheme = Colors.Dialog, IsShortFormat = false }; Win.Add(_timeField); _labelMirroringTimeField = new Label(_timeField.Text) { X = Pos.Right(_timeField) + 1, Y = Pos.Top(_timeField), Width = Dim.Width(_timeField), Height = Dim.Height(_timeField), }; Win.Add(_labelMirroringTimeField); _timeField.TimeChanged += TimeChanged; // MaskedTextProvider var netProviderLabel = new Label(".Net MaskedTextProvider [ 999 000 LLL >LLL| AAA aaa ]") { X = Pos.Left(dateField), Y = Pos.Bottom(dateField) + 1 }; Win.Add(netProviderLabel); var netProvider = new NetMaskedTextProvider("999 000 LLL > LLL | AAA aaa"); var netProviderField = new TextValidateField(netProvider) { X = Pos.Right(netProviderLabel) + 1, Y = Pos.Y(netProviderLabel) }; Win.Add(netProviderField); // TextRegexProvider var regexProvider = new Label("Gui.cs TextRegexProvider [ ^([0-9]?[0-9]?[0-9]|1000)$ ]") { X = Pos.Left(netProviderLabel), Y = Pos.Bottom(netProviderLabel) + 1 }; Win.Add(regexProvider); var provider2 = new TextRegexProvider("^([0-9]?[0-9]?[0-9]|1000)$") { ValidateOnInput = false }; var regexProviderField = new TextValidateField(provider2) { X = Pos.Right(regexProvider) + 1, Y = Pos.Y(regexProvider), Width = 30, TextAlignment = TextAlignment.Centered }; Win.Add(regexProviderField); }
public static Dialog CreateNewFileDialog(Action okAction, Action cancelAction) { var ok = new Button(3, 14, LocMan.Get("Ok")); ok.Clicked += () => { okAction.Invoke(); }; var cancel = new Button(10, 14, LocMan.Get("Cancel")); cancel.Clicked += () => { cancelAction.Invoke(); }; var dialog = new Dialog(LocMan.Get("Pbkdf2 settings"), 60, 20, ok, cancel); var enterPasswordLabel = new Label(1, 1, LocMan.Get("Enter password:"******"") { Secret = true, X = 1, Y = 2, Width = Dim.Fill(), Height = 1 }; var confirmPasswordLabel = new Label(1, 4, LocMan.Get("Confirm password:"******"") { Secret = true, X = 1, Y = 5, Width = Dim.Fill(), Height = 1 }; var prfLabel = new Label(1, 7, LocMan.Get("Pseudo-Random Function:")); var prfRadioSelection = new RadioGroup(1, 8, prfArray); var iterationsLabel = new Label(1, 11, LocMan.Get("How many iterations:")); var positiveNumbersOnlyProvider = new TextRegexProvider("^[1-9]+[0-9]*$") { ValidateOnInput = true }; var iterationsAmount = new TextValidateField(positiveNumbersOnlyProvider) { X = 1, Y = 12, Width = Dim.Fill(), Height = 1 }; iterationsAmount.Text = suggestedIterations.ToString(); dialog.Add(enterPasswordLabel, passwordFirstTime, confirmPasswordLabel, passwordSecondTime, prfLabel, prfRadioSelection, iterationsLabel, iterationsAmount); return(dialog); }