private async void btnCreateNewWebResource_Click(object sender, RoutedEventArgs e) { if (!this.IsControlsEnabled) { return; } ToggleControls(false, Properties.WindowStatusStrings.PreparingCreatingNewWebResource); var extension = _file.Extension; if (string.IsNullOrEmpty(extension) || !WebResourceRepository.IsSupportedExtension(extension)) { ToggleControls(true, Properties.WindowStatusStrings.CreatingNewWebResourceDeniedFormat1, extension); var message = string.Format(Properties.MessageBoxStrings.FileExtensionIsNotAllowedForWebResourceFormat1, extension); MessageBox.Show(message, Properties.MessageBoxStrings.InformationTitle, MessageBoxButton.OK, MessageBoxImage.Information); return; } Solution solution = null; if (!string.IsNullOrEmpty(_connectionData.LastSelectedSolutionsUniqueName.FirstOrDefault()) && this.ForAllOther) { var repositorySolution = new SolutionRepository(_service); solution = await repositorySolution.GetSolutionByUniqueNameAsync(_connectionData.LastSelectedSolutionsUniqueName.FirstOrDefault()); } if (solution == null) { var formSelectSolution = new WindowSolutionSelect(_iWriteToOutput, _service); formSelectSolution.ShowForAllOther(); var dialogResult = formSelectSolution.ShowDialog().GetValueOrDefault(); _connectionData.AddLastSelectedSolution(formSelectSolution.SelectedSolution?.UniqueName); if (!dialogResult) { this.ForAllOther = false; ToggleControls(true, Properties.WindowStatusStrings.CreatingNewWebResourceCanceled); return; } solution = formSelectSolution.SelectedSolution; _connectionData.AddLastSelectedSolution(solution?.UniqueName); this.ForAllOther = !string.IsNullOrEmpty(_connectionData.LastSelectedSolutionsUniqueName.FirstOrDefault()) && formSelectSolution.ForAllOther; } if (solution == null) { this.ForAllOther = false; ToggleControls(true, Properties.WindowStatusStrings.SolutionForCreatingNewWebResouceNotSelected); return; } this._iWriteToOutput.WriteToOutputSolutionUri(_connectionData, solution.UniqueName, solution.Id); var formWebResourceInfo = new WindowWebResourceCreate(_file.FileName, _file.FriendlyFilePath, solution.UniqueName, solution.PublisherCustomizationPrefix); { var dialogResult = formWebResourceInfo.ShowDialog().GetValueOrDefault(); if (!dialogResult) { ToggleControls(true, Properties.WindowStatusStrings.CreatingNewWebResourceCanceled); return; } } var name = formWebResourceInfo.WebResourceName; var displayName = formWebResourceInfo.WebResourceDisplayName; var description = formWebResourceInfo.WebResourceDescription; name = WebResourceRepository.GenerateWebResouceName(name, solution.PublisherCustomizationPrefix); UpdateStatus(Properties.WindowStatusStrings.CreatingNewWebResourceFormat1, name); WebResourceRepository repository = new WebResourceRepository(_service); try { Guid id = await repository.CreateNewWebResourceAsync(name, displayName, description, extension, solution.UniqueName); this.SelectedWebResourceId = id; this.DialogResult = true; this.Close(); ToggleControls(true, Properties.WindowStatusStrings.CreatingNewWebResourceCompletedFormat1, name); } catch (Exception ex) { ToggleControls(true, Properties.WindowStatusStrings.CreatingNewWebResourceFailed, name); this._iWriteToOutput.WriteErrorToOutput(_service.ConnectionData, ex); } }