private async void btnAdd_Click(object sender, EventArgs e) { var name = tbName.Text.Trim(); if (string.IsNullOrWhiteSpace(name)) { MessageBox.Show(this, string.Format(Resources.Localization_InvalidRepoName_Text, name), Resources.Localization_Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var url = tbUrl.Text.ToLower().Trim(); string?repositoryUrl = GitHubRepositoryUrl.Parse(url); if (repositoryUrl == null) { MessageBox.Show(this, string.Format(Resources.Localization_InvalidRepoUrl_Text, url), Resources.Localization_Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } using var cancellationTokenSource = new CancellationTokenSource(20000); var localizationSource = new LocalizationSource(name, repositoryUrl, UpdateRepositoryType.GitHub); switch (await _repositoryManager.AddRepositoryAsync(localizationSource, cancellationTokenSource.Token)) { case RepositoryManager.AddStatus.Success: DataBindList(); break; case RepositoryManager.AddStatus.DuplicateName: MessageBox.Show(this, string.Format(Resources.Localization_DuplicateRepoName_Text, name), Resources.Localization_Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Error); break; case RepositoryManager.AddStatus.DuplicateUrl: MessageBox.Show(this, string.Format(Resources.Localization_DuplicateRepoUrl_Text, repositoryUrl), Resources.Localization_Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Error); break; case RepositoryManager.AddStatus.Unreachable: MessageBox.Show(this, string.Format(Resources.Localization_NoRepoAccess_Text, name), Resources.Localization_Error_Title, MessageBoxButtons.OK, MessageBoxIcon.Error); break; } }