/// <summary> /// Fetch repository in repository TextBox /// </summary> /// <returns></returns> private async Task FetchSelectedRepository() { if (string.IsNullOrWhiteSpace(RepositoryTextBox.Text)) { MessageBox.Show(@"Requires a repository"); return; } WorkingPictureBox.Image = spinner; if (RepositoryListBox.DataSource != null) { _lastSelectedRepositoryName = RepositoryListBox.Text; } RepositoryListBox.DataSource = null; try { _repositoriesBindingList = new BindingList <Repository>(await GitOperations.DownLoadPublicRepositoriesAsync(RepositoryTextBox.Text)); } catch (Exception ex) { WorkingPictureBox.Image = null; // a consideration is rate limit MessageBox.Show($@"Failed to get repositories {ex.Message}"); return; } _repositoriesBindingSource.DataSource = _repositoriesBindingList; RepositoryListBox.DataSource = _repositoriesBindingSource; if (_repositoriesBindingSource.Count > 0) { RepositoryListBox.SelectedIndex = 0; } BindControls(); ControlHelpers.SetWaterMarkers(this); if (!string.IsNullOrWhiteSpace(_lastSelectedRepositoryName)) { var index = RepositoryListBox.FindString(_lastSelectedRepositoryName); if (index >= 0) { RepositoryListBox.SelectedIndex = index; } } ActiveControl = RepositoryListBox; WorkingPictureBox.Image = null; }