private void LoadEdit() { System.Uri resourceLocater = new System.Uri("/DataSpaceSync;component/EditWPF.xaml", System.UriKind.Relative); UserControl editWPF = Application.LoadComponent(resourceLocater) as UserControl; tab = editWPF.FindName("tab") as TabControl; // GUI workaround to remove ignore folder {{ //tabItemSelection = editWPF.FindName("tabItemSelection") as TabItem; // GUI workaround to remove ignore folder }} tabItemCredentials = editWPF.FindName("tabItemCredentials") as TabItem; tabItemCredentials.Header = Properties_Resources.Credentials; addressLabel = editWPF.FindName("addressLabel") as TextBlock; addressBox = editWPF.FindName("addressBox") as TextBox; userLabel = editWPF.FindName("userLabel") as TextBlock; userBox = editWPF.FindName("userBox") as TextBox; passwordLabel = editWPF.FindName("passwordLabel") as TextBlock; passwordBox = editWPF.FindName("passwordBox") as PasswordBox; passwordProgress = editWPF.FindName("passwordProgress") as CircularProgressBar; passwordHelp = editWPF.FindName("passwordHelp") as TextBlock; finishButton = editWPF.FindName("finishButton") as Button; cancelButton = editWPF.FindName("cancelButton") as Button; // GUI workaround to remove ignore folder {{ //tabItemSelection.Content = treeView; // GUI workaround to remove ignore folder }} addressBox.Text = Credentials.Address.ToString(); userBox.Text = Credentials.UserName; passwordBox.Password = Credentials.Password.ToString(); passwordHelp.Text = string.Empty; ContentCanvas.Children.Add(editWPF); passwordBox.LostFocus += delegate { backgroundWorker.RunWorkerAsync(); }; passwordBox.PasswordChanged += delegate { passwordChanged = true; }; passwordChanged = true; backgroundWorker.RunWorkerAsync(); }
private void LoadAddLoginWPF() { // define UI elements. Header = Properties_Resources.Where; System.Uri resourceLocater = new System.Uri("/DataSpaceSync;component/SetupAddLoginWPF.xaml", System.UriKind.Relative); UserControl LoadAddLoginWPF = Application.LoadComponent(resourceLocater) as UserControl; address_label = LoadAddLoginWPF.FindName("address_label") as TextBlock; address_box = LoadAddLoginWPF.FindName("address_box") as TextBox; address_help_label = LoadAddLoginWPF.FindName("address_help_label") as TextBlock; user_label = LoadAddLoginWPF.FindName("user_label") as TextBlock; user_box = LoadAddLoginWPF.FindName("user_box") as TextBox; user_help_label = LoadAddLoginWPF.FindName("user_help_label") as TextBlock; password_label = LoadAddLoginWPF.FindName("password_label") as TextBlock; password_box = LoadAddLoginWPF.FindName("password_box") as PasswordBox; password_progress = LoadAddLoginWPF.FindName("password_progress") as CircularProgressBar; password_help_label = LoadAddLoginWPF.FindName("password_help_label") as TextBlock; address_error_label = LoadAddLoginWPF.FindName("address_error_label") as TextBox; continue_button = LoadAddLoginWPF.FindName("continue_button") as Button; cancel_button = LoadAddLoginWPF.FindName("cancel_button") as Button; ContentCanvas.Children.Add(LoadAddLoginWPF); address_box.Text = (Controller.PreviousAddress != null) ? Controller.PreviousAddress.ToString() : String.Empty; if (Controller.saved_user == String.Empty || Controller.saved_user == null) { user_box.Text = DefaultEntries.Defaults.Name; } else { user_box.Text = Controller.saved_user; } TaskbarItemInfo.ProgressValue = 0.0; TaskbarItemInfo.ProgressState = TaskbarItemProgressState.None; if (!DefaultEntries.Defaults.CanModifyUrl) { address_box.IsEnabled = false; address_box.Visibility = Visibility.Hidden; address_help_label.Visibility = Visibility.Hidden; address_label.Visibility = Visibility.Hidden; } if (Controller.PreviousAddress == null || Controller.PreviousAddress.ToString() == String.Empty) { address_box.Text = DefaultEntries.Defaults.Url; } else { address_box.Text = Controller.PreviousAddress.ToString(); } address_box.Focus(); address_box.Select(address_box.Text.Length, 0); // Actions. ControllerLoginInsertAction(); Controller.CheckAddPage(address_box.Text); address_box.TextChanged += delegate { string error = Controller.CheckAddPage(address_box.Text); if (!String.IsNullOrEmpty(error)) { address_error_label.Text = Properties_Resources.ResourceManager.GetString(error, CultureInfo.CurrentCulture); address_error_label.Visibility = Visibility.Visible; } else { address_error_label.Visibility = Visibility.Hidden; } }; cancel_button.Click += delegate { ControllerLoginRemoveAction(); Controller.PageCancelled(); }; string binding = Controller.saved_binding; if (binding == null) { binding = CmisRepoCredentials.BindingBrowser; } continue_button.Click += delegate { // Show wait cursor password_progress.Visibility = Visibility.Visible; System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; // Try to find the CMIS server (asynchronously) GetRepositoriesDelegate dlgt = new GetRepositoriesDelegate(SetupController.GetRepositories); ServerCredentials credentials = new ServerCredentials() { UserName = user_box.Text, Password = password_box.Password, Address = new Uri(address_box.Text), Binding = binding, }; IAsyncResult ar = dlgt.BeginInvoke(credentials, null, null); while (!ar.AsyncWaitHandle.WaitOne(100)) { System.Windows.Forms.Application.DoEvents(); } var result = dlgt.EndInvoke(ar); Controller.repositories = result.Repositories.WithoutHiddenOnce(); address_box.Text = result.Credentials.Address.ToString(); binding = result.Credentials.Binding; // Hide wait cursor System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; password_progress.Visibility = Visibility.Hidden; if (Controller.repositories == null) { // Could not retrieve repositories list from server, show warning. string warning = Controller.GetConnectionsProblemWarning(result.FailedException); address_error_label.Text = warning; address_error_label.Visibility = Visibility.Visible; } else { ControllerLoginRemoveAction(); // Continue to next step, which is choosing a particular folder. Controller.Add1PageCompleted( new Uri(address_box.Text), binding, user_box.Text, password_box.Password); } }; }