void PrivateKeyLocationButton_Clicked(object sender, EventArgs e) { var dialog = new SelectFileDialog(GettextCatalog.GetString("Select a private SSH key to use.")) { ShowHidden = true, CurrentFolder = System.IO.File.Exists(privateKeyLocationTextEntry.Text) ? System.IO.Path.GetDirectoryName(privateKeyLocationTextEntry.Text) : Environment.GetFolderPath(Environment.SpecialFolder.Personal) }; dialog.AddFilter(GettextCatalog.GetString("Private Key Files"), "*"); if (dialog.Run()) { privateKeyLocationTextEntry.Text = dialog.SelectedFile; if (System.IO.File.Exists(privateKeyLocationTextEntry.Text + ".pub")) { publicKeyLocationTextEntry.Text = privateKeyLocationTextEntry.Text + ".pub"; } OnCredentialsChanged(); if (string.IsNullOrEmpty(Credentials.PublicKey)) { publicKeyLocationTextEntry.SetFocus(); } else if (passphraseEntry.Sensitive) { passphraseEntry.SetFocus(); } } ; }
public Login() { var table = new Table(); var image = new ImageView { Image = Icons.UserInfo.WithBoxSize(96), }; userEntry = new TextEntry { Text = Environment.UserName, PlaceholderText = Application.TranslationCatalog.GetString("User"), }; passwordEntry = new PasswordEntry { PlaceholderText = Application.TranslationCatalog.GetString("Password"), }; var userLabel = new Label { Text = Application.TranslationCatalog.GetString("User"), TextAlignment = Alignment.Center, }; var passwordLabel = new Label { Text = Application.TranslationCatalog.GetString("Password"), TextAlignment = Alignment.Center, }; info = new Label { TextAlignment = Alignment.Center, TextColor = new Color(1, 0, 0), Visible = false, }; userEntry.Activated += delegate { passwordEntry.SetFocus(); }; passwordEntry.Activated += OnAutenticate; table.Add(image, 0, 0, 4); table.Add(userLabel, 1, 0); table.Add(userEntry, 1, 1); table.Add(passwordLabel, 1, 2); table.Add(passwordEntry, 1, 3); table.Add(info, 0, 4, colspan: 2); Content = table; if (string.IsNullOrWhiteSpace(userEntry.Text)) { userEntry.SetFocus(); } else { passwordEntry.SetFocus(); } Resizable = false; ShowInTaskbar = false; Title = Application.TranslationCatalog.GetString("Login"); Icon = Image.FromResource(GetType(), Resources.Icon); }