public IEnumerable <IPackageAction> CreateUpdatePackageActions( ManagePackagesSearchResultViewModel packageViewModel, IEnumerable <IDotNetProject> projects) { bool firstInstall = true; foreach (IDotNetProject project in projects) { if (IsPackageInstalledInProject(project, packageViewModel.Id)) { yield return(new InstallNuGetPackageAction( SelectedPackageSource.GetSourceRepositories(), solutionManager, project, projectContext ) { IncludePrerelease = IncludePrerelease, PackageId = packageViewModel.Id, Version = packageViewModel.SelectedVersion, LicensesMustBeAccepted = firstInstall }); firstInstall = false; } } }
void ManagePackage(ManagePackagesSearchResultViewModel packageViewModel) { try { if (packageViewModel != null) { if (viewModel.IsConsolidatePageSelected) { List <IPackageAction> packageActions = viewModel.CreateConsolidatePackageActions( new ManagePackagesSearchResultViewModel [] { packageViewModel } ); RunPackageActions(packageActions); } else { var projects = SelectProjects(packageViewModel).ToList(); if (!projects.Any()) { return; } List <IPackageAction> packageActions = viewModel.CreatePackageActions( new ManagePackagesSearchResultViewModel [] { packageViewModel }, projects); RunPackageActions(packageActions); } } } catch (Exception ex) { LoggingService.LogInternalError("ManagePackage failed.", ex); ShowErrorMessage(ex.Message); } }
void PopulatePackageVersions(ManagePackagesSearchResultViewModel packageViewModel) { DisposePopulatePackageVersionsTimer(); ignorePackageVersionChanges = true; try { packageVersionComboBox.Items.Clear(); if (packageViewModel.Versions.Any()) { int count = 0; foreach (NuGetVersion version in packageViewModel.Versions) { count++; if (count > MaxVersionsToPopulate) { packageVersionsAddedCount = count - 1; if (version >= packageViewModel.SelectedVersion) { AddPackageVersionToComboBox(packageViewModel.SelectedVersion); } PopulatePackageVersionsAfterDelay(); break; } AddPackageVersionToComboBox(version); } } else { AddPackageVersionToComboBox(packageViewModel.Version); } packageVersionComboBox.SelectedItem = packageViewModel.SelectedVersion; } finally { ignorePackageVersionChanges = false; } }
void PackagesListRowActivated(object sender, ListViewRowEventArgs e) { ManagePackagesSearchResultViewModel packageViewModel = packageStore.GetValue(e.RowIndex, packageViewModelField); packageViewModel.IsChecked = !packageViewModel.IsChecked; PackageCellViewPackageChecked(null, null); }
bool PopulateMorePackageVersions() { ManagePackagesSearchResultViewModel packageViewModel = viewModel?.SelectedPackage; if (populatePackageVersionsTimer == null || packageViewModel == null) { return(false); } int count = 0; foreach (NuGetVersion version in packageViewModel.Versions.Skip(packageVersionsAddedCount)) { count++; if (count > MaxVersionsToPopulate) { packageVersionsAddedCount += count - 1; return(true); } AddPackageVersionToComboBox(version); } return(false); }
void OnPackageChecked(ManagePackagesSearchResultViewModel packageViewModel) { if (PackageChecked != null) { PackageChecked(this, new ManagePackagesCellViewEventArgs(packageViewModel)); } }
protected override void OnDraw(Context ctx, Rectangle cellArea) { ManagePackagesSearchResultViewModel packageViewModel = GetValue(PackageField); if (packageViewModel == null) { return; } FillCellBackground(ctx); UpdateTextColor(ctx); DrawCheckBox(ctx, packageViewModel, cellArea); DrawPackageImage(ctx, cellArea); double packageIdWidth = cellArea.Width - packageDescriptionPadding.HorizontalSpacing - packageDescriptionLeftOffset; // Package download count. if (packageViewModel.HasDownloadCount) { var downloadCountTextLayout = new TextLayout(); downloadCountTextLayout.Text = packageViewModel.GetDownloadCountOrVersionDisplayText(); Size size = downloadCountTextLayout.GetSize(); Point location = new Point(cellArea.Right - packageDescriptionPadding.Right, cellArea.Top + packageDescriptionPadding.Top); Point downloadLocation = location.Offset(-size.Width, 0); ctx.DrawTextLayout(downloadCountTextLayout, downloadLocation); packageIdWidth = downloadLocation.X - cellArea.Left - packageIdRightHandPaddingWidth - packageDescriptionPadding.HorizontalSpacing - packageDescriptionLeftOffset; } // Package Id. // Use the package id and not the package title to prevent a pango crash if the title // contains Chinese characters. var packageIdTextLayout = new TextLayout(); packageIdTextLayout.Font = packageIdTextLayout.Font.WithSize(packageIdFontSize); packageIdTextLayout.Markup = packageViewModel.GetIdMarkup(); packageIdTextLayout.Trimming = TextTrimming.WordElipsis; Size packageIdTextSize = packageIdTextLayout.GetSize(); packageIdTextLayout.Width = packageIdWidth; ctx.DrawTextLayout( packageIdTextLayout, cellArea.Left + packageDescriptionPadding.Left + packageDescriptionLeftOffset, cellArea.Top + packageDescriptionPadding.Top); // Package description. var descriptionTextLayout = new TextLayout(); descriptionTextLayout.Font = descriptionTextLayout.Font.WithSize(packageDescriptionFontSize); descriptionTextLayout.Width = cellArea.Width - packageDescriptionPadding.HorizontalSpacing - packageDescriptionLeftOffset; descriptionTextLayout.Height = cellArea.Height - packageIdTextSize.Height - packageDescriptionPadding.VerticalSpacing; descriptionTextLayout.Text = packageViewModel.Summary; descriptionTextLayout.Trimming = TextTrimming.Word; ctx.DrawTextLayout( descriptionTextLayout, cellArea.Left + packageDescriptionPadding.Left + packageDescriptionLeftOffset, cellArea.Top + packageIdTextSize.Height + packageDescriptionPaddingHeight + packageDescriptionPadding.Top); }
void LoadPackageImage(int row, ManagePackagesSearchResultViewModel packageViewModel) { if (packageViewModel.HasIconUrl) { imageLoader.LoadFrom(packageViewModel.IconUrl, row); } }
public IEnumerable <IPackageAction> CreateConsolidatePackageActions( ManagePackagesSearchResultViewModel packageViewModel) { bool firstInstall = true; foreach (ManageProjectViewModel project in GetProjectViewModelsForPackage(packageViewModel)) { if (!CanConsolidate(project, packageViewModel)) { continue; } yield return(new InstallNuGetPackageAction( SelectedPackageSource.GetSourceRepositories(), solutionManager, project.Project, projectContext ) { IncludePrerelease = IncludePrerelease, PackageId = packageViewModel.Id, Version = packageViewModel.SelectedVersion, LicensesMustBeAccepted = firstInstall }); firstInstall = false; } }
void AppendPackageToListView(ManagePackagesSearchResultViewModel packageViewModel) { int row = packageStore.AddRow(); packageStore.SetValue(row, packageHasBackgroundColorField, IsOddRow(row)); packageStore.SetValue(row, packageCheckBoxAlphaField, GetPackageCheckBoxAlpha()); packageStore.SetValue(row, packageViewModelField, packageViewModel); }
public void AddPackage(ManagePackagesSearchResultViewModel viewModel, string source) { var package = new RecentPackage(viewModel, source); viewModel.IsRecentPackage = true; RemovePackageIfAlreadyAdded(package); AddPackageAtBeginning(package); RemoveLastPackageIfCurrentPackageCountExceedsMaximum(); }
public IEnumerable <ManagePackagesSearchResultViewModel> ConvertToPackageViewModels(IEnumerable <PackageItemListViewModel> itemViewModels) { foreach (PackageItemListViewModel itemViewModel in itemViewModels) { ManagePackagesSearchResultViewModel packageViewModel = CreatePackageViewModel(itemViewModel); UpdatePackageViewModelIfPreviouslyChecked(packageViewModel); yield return(packageViewModel); } }
bool SelectedVersionMatchesIncludePreleaseFilter(ManagePackagesSearchResultViewModel package) { if (package.SelectedVersion.IsPrerelease) { return(IncludePrerelease); } return(true); }
void UncheckExistingCheckedPackageWithDifferentVersion(ManagePackagesSearchResultViewModel packageViewModel) { ManagePackagesSearchResultViewModel existingPackageViewModel = GetExistingCheckedPackageViewModel(packageViewModel.Id); if (existingPackageViewModel != null) { CheckedPackageViewModels.Remove(existingPackageViewModel); existingPackageViewModel.IsChecked = false; } }
IEnumerable <ManageProjectViewModel> GetProjectViewModelsForPackage(ManagePackagesSearchResultViewModel packageViewModel) { List <ManageProjectViewModel> projectViewModels; if (cachedProjectViewModels.TryGetValue(packageViewModel.Id, out projectViewModels)) { return(projectViewModels); } return(Enumerable.Empty <ManageProjectViewModel> ()); }
void PackagesListRowActivated(object sender, ListViewRowEventArgs e) { if (PackagesCheckedCount > 0) { AddPackagesButtonClicked(sender, e); } else { ManagePackagesSearchResultViewModel packageViewModel = packageStore.GetValue(e.RowIndex, packageViewModelField); ManagePackage(packageViewModel); } }
bool IsValidRowAndUrl(int row, Uri uri) { if (row < packageStore.RowCount) { ManagePackagesSearchResultViewModel packageViewModel = packageStore.GetValue(row, packageViewModelField); if (packageViewModel != null) { return(uri == packageViewModel.IconUrl); } } return(false); }
void DrawCheckBox(Context ctx, ManagePackagesSearchResultViewModel packageViewModel, Rectangle cellArea) { CreateCheckboxImages(); Image image = GetCheckBoxImage(packageViewModel.IsChecked); double alpha = GetCheckBoxImageAlpha(); ctx.DrawImage( image, cellArea.Left + checkBoxPadding.Left, cellArea.Top + ((cellArea.Height - checkBoxImageSize.Height - 2) / 2), alpha); }
void ShowCurrentPackageVersion(ManagePackagesSearchResultViewModel packageViewModel) { if (maxPackageVersionLabelWidth.HasValue) { currentPackageVersionLabel.WidthRequest = maxPackageVersionLabelWidth.Value; packageVersionsLabel.WidthRequest = maxPackageVersionLabelWidth.Value; } currentPackageVersion.Text = packageViewModel.GetCurrentPackageVersionText(); currentPackageVersionInfoPopoverWidget.Message = packageViewModel.GetCurrentPackageVersionAdditionalText(); currentPackageVersionInfoPopoverWidget.Visible = !string.IsNullOrEmpty(currentPackageVersionInfoPopoverWidget.Message); currentPackageVersionHBox.Visible = !string.IsNullOrEmpty(currentPackageVersion.Text); }
void UpdatePackageViewModelIfPreviouslyChecked(ManagePackagesSearchResultViewModel packageViewModel) { ignorePackageCheckedChanged = true; try { ManagePackagesSearchResultViewModel existingPackageViewModel = GetExistingCheckedPackageViewModel(packageViewModel.Id); if (existingPackageViewModel != null) { packageViewModel.UpdateFromPreviouslyCheckedViewModel(existingPackageViewModel); CheckedPackageViewModels.Remove(existingPackageViewModel); CheckedPackageViewModels.Add(packageViewModel); } } finally { ignorePackageCheckedChanged = false; } }
bool OlderPackageInstalledThanPackageSelected() { if (PackagesCheckedCount != 0) { return(false); } ManagePackagesSearchResultViewModel selectedPackageViewModel = GetSelectedPackageViewModel(); if (selectedPackageViewModel != null) { return(selectedPackageViewModel.IsOlderPackageInstalled()); } return(false); }
void PopulatePackageDependencies(ManagePackagesSearchResultViewModel packageViewModel) { if (packageViewModel.IsDependencyInformationAvailable) { this.packageDependenciesHBox.Visible = true; this.packageDependenciesListHBox.Visible = packageViewModel.HasDependencies; this.packageDependenciesNoneLabel.Visible = !packageViewModel.HasDependencies; this.packageDependenciesList.Text = packageViewModel.GetPackageDependenciesDisplayText(); } else { this.packageDependenciesHBox.Visible = false; this.packageDependenciesListHBox.Visible = false; this.packageDependenciesNoneLabel.Visible = false; this.packageDependenciesList.Text = String.Empty; } }
void ShowSelectedPackage() { RemoveSelectedPackagePropertyChangedEventHandler(); ManagePackagesSearchResultViewModel packageViewModel = GetSelectedPackageViewModel(); viewModel.SelectedPackage = packageViewModel; if (packageViewModel != null) { ShowPackageInformation(packageViewModel); } else { ClearSelectedPackageInformation(); } UpdateAddPackagesButton(); }
public void OnPackageCheckedChanged(ManagePackagesSearchResultViewModel packageViewModel) { if (ignorePackageCheckedChanged) { return; } if (packageViewModel.IsChecked) { UncheckExistingCheckedPackageWithDifferentVersion(packageViewModel); CheckedPackageViewModels.Add(packageViewModel); } else { CheckedPackageViewModels.Remove(packageViewModel); } }
void PackageSearchEntryActivated(object sender, EventArgs e) { if (loadingMessageVisible) { return; } if (PackagesCheckedCount > 0) { AddPackagesButtonClicked(sender, e); } else { ManagePackagesSearchResultViewModel selectedPackageViewModel = GetSelectedPackageViewModel(); ManagePackage(selectedPackageViewModel); } }
List <ManagePackagesSearchResultViewModel> GetSelectedPackageViewModels() { List <ManagePackagesSearchResultViewModel> packageViewModels = viewModel.CheckedPackageViewModels.ToList(); if (packageViewModels.Count > 0) { return(packageViewModels); } ManagePackagesSearchResultViewModel selectedPackageViewModel = GetSelectedPackageViewModel(); if (selectedPackageViewModel != null) { packageViewModels.Add(selectedPackageViewModel); } return(packageViewModels); }
bool CanConsolidate(ManageProjectViewModel projectViewModel, ManagePackagesSearchResultViewModel packageViewModel) { if (!projectViewModel.IsChecked) { return(false); } if (IsPackageInstalledInProjectWithSameVersion( projectViewModel.ProjectInfo, packageViewModel.Id, packageViewModel.SelectedVersion)) { return(false); } return(true); }
public IEnumerable <IPackageAction> CreateUninstallPackageActions( ManagePackagesSearchResultViewModel packageViewModel, IEnumerable <IDotNetProject> projects) { foreach (IDotNetProject project in projects) { if (IsPackageInstalledInProject(project, packageViewModel.Id)) { yield return(new UninstallNuGetPackageAction( solutionManager, project ) { PackageId = packageViewModel.Id, }); } } }
public IEnumerable <IPackageAction> CreateInstallPackageActions( ManagePackagesSearchResultViewModel packageViewModel, IEnumerable <IDotNetProject> projects) { return(projects.Select(project => { return new InstallNuGetPackageAction( SelectedPackageSource.GetSourceRepositories(), solutionManager, project, projectContext ) { IncludePrerelease = IncludePrerelease, PackageId = packageViewModel.Id, Version = packageViewModel.SelectedVersion }; })); }
protected override void OnButtonPressed(ButtonEventArgs args) { ManagePackagesSearchResultViewModel packageViewModel = GetValue(PackageField); if (packageViewModel == null) { base.OnButtonPressed(args); return; } double x = args.X - Bounds.X; double y = args.Y - Bounds.Y; if (checkBoxImageClickableRectangle.Contains(x, y)) { packageViewModel.IsChecked = !packageViewModel.IsChecked; OnPackageChecked(packageViewModel); } }