public static string Show(string Caption, string prompt, string DefaultValue, bool isPassword) { GetStringDlg dlg = new GetStringDlg(Caption, prompt, DefaultValue); dlg.ValueTB.UseSystemPasswordChar = isPassword; if (isPassword) { dlg.ShowIcon = true; dlg.TopMost = true; } if (dlg.ShowDialog() != DialogResult.Cancel) { if (dlg.DialogResult == DialogResult.OK) { return(dlg.Value); } } return(null); }
private void NewWorkspaceBtn_Click(object sender, EventArgs e) { this.TopMost = false; P4ScmProvider _scm = new P4ScmProvider(null); _scm.Connection.Port = ServerPort; _scm.Connection.User = UserName; _scm.Connection.Connect(true, null, true); if (_scm.Connected && _scm.Connection.isLoggedIn()) { P4.Client workspace = null; P4.Client clientInfo = new P4.Client(); string newName = GetStringDlg.Show(Resources.OpenConnectionDlg_NewWorkspaceDlgTitle, Resources.OpenConnectionDlg_NewWorkspaceDlgPrompt, null); if ((newName != null) && (newName != string.Empty)) { if (newName.Contains(" ")) { MessageBox.Show(Resources.OpenConnectionDlg_NameContainsSpacesWarning, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Information); } IList <P4.Client> checkExisting = _scm.getClients(P4.ClientsCmdFlags.None, null, newName, 1, null); if (checkExisting == null) { clientInfo = _scm.getClient(newName, null); if (clientInfo != null) { // adjust root here based on users dir string root = Environment.GetFolderPath(Environment.SpecialFolder.Personal); int idx = root.LastIndexOf(@"\"); root = root.Remove(idx + 1); root += newName; clientInfo.Root = root; workspace = DlgEditWorkspace.EditWorkspace(_scm, clientInfo); } } else { MessageBox.Show(string.Format(Resources.OpenConnectionDlg_WorkspaceExistsWarning, newName), Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Information); NewWorkspaceBtn_Click(null, null); } } else { if (newName == string.Empty) { MessageBox.Show(Resources.OpenConnectionDlg_EmptyWorkspaceNameWarning, Resources.P4VS, MessageBoxButtons.OK, MessageBoxIcon.Information); NewWorkspaceBtn_Click(null, null); } } if (workspace != null) { WorkspaceTB.Text = workspace.Name; } } this.TopMost = true; }