예제 #1
0
        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;
                }
            }
        }
예제 #2
0
        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;
            }
        }
예제 #4
0
        void PackagesListRowActivated(object sender, ListViewRowEventArgs e)
        {
            ManagePackagesSearchResultViewModel packageViewModel = packageStore.GetValue(e.RowIndex, packageViewModelField);

            packageViewModel.IsChecked = !packageViewModel.IsChecked;
            PackageCellViewPackageChecked(null, null);
        }
예제 #5
0
        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);
        }
예제 #6
0
 void OnPackageChecked(ManagePackagesSearchResultViewModel packageViewModel)
 {
     if (PackageChecked != null)
     {
         PackageChecked(this, new ManagePackagesCellViewEventArgs(packageViewModel));
     }
 }
예제 #7
0
        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);
        }
예제 #8
0
 void LoadPackageImage(int row, ManagePackagesSearchResultViewModel packageViewModel)
 {
     if (packageViewModel.HasIconUrl)
     {
         imageLoader.LoadFrom(packageViewModel.IconUrl, row);
     }
 }
예제 #9
0
        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;
            }
        }
예제 #10
0
        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();
        }
예제 #12
0
 public IEnumerable <ManagePackagesSearchResultViewModel> ConvertToPackageViewModels(IEnumerable <PackageItemListViewModel> itemViewModels)
 {
     foreach (PackageItemListViewModel itemViewModel in itemViewModels)
     {
         ManagePackagesSearchResultViewModel packageViewModel = CreatePackageViewModel(itemViewModel);
         UpdatePackageViewModelIfPreviouslyChecked(packageViewModel);
         yield return(packageViewModel);
     }
 }
예제 #13
0
        bool SelectedVersionMatchesIncludePreleaseFilter(ManagePackagesSearchResultViewModel package)
        {
            if (package.SelectedVersion.IsPrerelease)
            {
                return(IncludePrerelease);
            }

            return(true);
        }
예제 #14
0
        void UncheckExistingCheckedPackageWithDifferentVersion(ManagePackagesSearchResultViewModel packageViewModel)
        {
            ManagePackagesSearchResultViewModel existingPackageViewModel = GetExistingCheckedPackageViewModel(packageViewModel.Id);

            if (existingPackageViewModel != null)
            {
                CheckedPackageViewModels.Remove(existingPackageViewModel);
                existingPackageViewModel.IsChecked = false;
            }
        }
예제 #15
0
        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);
     }
 }
예제 #17
0
 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);
 }
예제 #18
0
        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);
        }
예제 #19
0
        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);
        }
예제 #20
0
 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;
     }
 }
예제 #21
0
        bool OlderPackageInstalledThanPackageSelected()
        {
            if (PackagesCheckedCount != 0)
            {
                return(false);
            }

            ManagePackagesSearchResultViewModel selectedPackageViewModel = GetSelectedPackageViewModel();

            if (selectedPackageViewModel != null)
            {
                return(selectedPackageViewModel.IsOlderPackageInstalled());
            }
            return(false);
        }
예제 #22
0
 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;
     }
 }
예제 #23
0
        void ShowSelectedPackage()
        {
            RemoveSelectedPackagePropertyChangedEventHandler();

            ManagePackagesSearchResultViewModel packageViewModel = GetSelectedPackageViewModel();

            viewModel.SelectedPackage = packageViewModel;
            if (packageViewModel != null)
            {
                ShowPackageInformation(packageViewModel);
            }
            else
            {
                ClearSelectedPackageInformation();
            }
            UpdateAddPackagesButton();
        }
예제 #24
0
        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);
            }
        }
예제 #26
0
        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);
        }
예제 #27
0
        bool CanConsolidate(ManageProjectViewModel projectViewModel, ManagePackagesSearchResultViewModel packageViewModel)
        {
            if (!projectViewModel.IsChecked)
            {
                return(false);
            }

            if (IsPackageInstalledInProjectWithSameVersion(
                    projectViewModel.ProjectInfo,
                    packageViewModel.Id,
                    packageViewModel.SelectedVersion))
            {
                return(false);
            }

            return(true);
        }
예제 #28
0
 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,
             });
         }
     }
 }
예제 #29
0
 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
         };
     }));
 }
예제 #30
0
        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);
            }
        }