// // Copyright 2014 Perforce Software Inc. // using Perforce.Helper; using System; using System.Windows; using System.Windows.Forms; using System.Windows.Input; namespace Perforce.View { /// /// Interaction logic for CreateWorkspaceForm.xaml /// public partial class CreateWorkspaceForm : System.Windows.Controls.UserControl { public CreateWorkspaceForm() { InitializeComponent(); this.Loaded += CreateWorkspaceForm_Loaded; } void CreateWorkspaceForm_Loaded(object sender, RoutedEventArgs e) { Keyboard.Focus(WorkspaceNameText); } private void BrowseButton_Click(object sender, RoutedEventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); DialogResult result = fbd.ShowDialog(); WorkspaceRootText.Text = fbd.SelectedPath; CheckFields(); } private void WorkspaceNameText_LostFocus(object sender, RoutedEventArgs e) { var helper = Utility.GetPerforceHelper(check: false); var ws = WorkspaceNameText.Text.Trim(); if (!string.IsNullOrEmpty(ws)) { if (helper.ClientExists(ws)) { System.Windows.MessageBox.Show(string.Format("Sorry, workspace name {0} is already in use", ws)); WorkspaceNameText.Clear(); FocusManager.SetFocusedElement(this, WorkspaceNameText); Keyboard.Focus(WorkspaceNameText); } } } public Technewlogic.WpfDialogManagement.Contracts.ICustomContentDialog ParentDialog { get; set; } private void Textfield_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) { CheckFields(); } private void CheckFields() { if (WorkspaceNameText.Text.Trim().Length > 0 && WorkspaceRootText.Text.Trim().Length > 0) { ParentDialog.CanOk = true; } else { ParentDialog.CanOk = false; } } } }