Exemple #1
0
 void LoadPackageImage(int row, PackageSearchResultViewModel packageViewModel)
 {
     if (packageViewModel.HasIconUrl)
     {
         imageLoader.LoadFrom(packageViewModel.IconUrl, row);
     }
 }
Exemple #2
0
 void OnPackageChecked(PackageSearchResultViewModel packageViewModel)
 {
     if (PackageChecked != null)
     {
         PackageChecked(this, new PackageCellViewEventArgs(packageViewModel));
     }
 }
Exemple #3
0
        void PopulatePackageVersions(PackageSearchResultViewModel 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;
            }
        }
        protected override void OnDraw(Context ctx, Rectangle cellArea)
        {
            PackageSearchResultViewModel 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);
        }
Exemple #5
0
        bool PopulateMorePackageVersions()
        {
            PackageSearchResultViewModel 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);
        }
Exemple #6
0
        void ShowPackageInformation(PackageSearchResultViewModel packageViewModel)
        {
            // Use the package id and not the package title to prevent a pango crash if the title
            // contains Chinese characters.
            this.packageNameLabel.Markup   = packageViewModel.GetIdMarkup();
            this.packageAuthor.Text        = packageViewModel.Author;
            this.packagePublishedDate.Text = packageViewModel.GetLastPublishedDisplayText();
            this.packageDownloads.Text     = packageViewModel.GetDownloadCountDisplayText();
            this.packageDescription.Text   = packageViewModel.Description;
            this.packageId.Text            = packageViewModel.Id;
            this.packageId.Visible         = packageViewModel.HasNoGalleryUrl;
            ShowUri(this.packageIdLink, packageViewModel.GalleryUrl, packageViewModel.Id);
            ShowUri(this.packageProjectPageLink, packageViewModel.ProjectUrl);
            ShowUri(this.packageLicenseLink, packageViewModel.LicenseUrl);

            PopulatePackageDependencies(packageViewModel);

            PopulatePackageVersions(packageViewModel);

            this.packageInfoVBox.Visible     = true;
            this.packageVersionsHBox.Visible = true;

            packageViewModel.PropertyChanged += SelectedPackageViewModelChanged;
            viewModel.LoadPackageMetadata(packageViewModel);
        }
Exemple #7
0
        void AppendPackageToListView(PackageSearchResultViewModel packageViewModel)
        {
            int row = packageStore.AddRow();

            packageStore.SetValue(row, packageHasBackgroundColorField, IsOddRow(row));
            packageStore.SetValue(row, packageCheckBoxAlphaField, GetPackageCheckBoxAlpha());
            packageStore.SetValue(row, packageViewModelField, packageViewModel);
        }
Exemple #8
0
 public IEnumerable <PackageSearchResultViewModel> ConvertToPackageViewModels(IEnumerable <PackageItemListViewModel> itemViewModels)
 {
     foreach (PackageItemListViewModel itemViewModel in itemViewModels)
     {
         PackageSearchResultViewModel packageViewModel = CreatePackageViewModel(itemViewModel);
         UpdatePackageViewModelIfPreviouslyChecked(packageViewModel);
         yield return(packageViewModel);
     }
 }
Exemple #9
0
        public void AddPackage(PackageSearchResultViewModel viewModel, string source)
        {
            var package = new RecentPackage(viewModel, source);

            viewModel.IsRecentPackage = true;
            RemovePackageIfAlreadyAdded(package);
            AddPackageAtBeginning(package);
            RemoveLastPackageIfCurrentPackageCountExceedsMaximum();
        }
Exemple #10
0
        bool SelectedVersionMatchesIncludePreleaseFilter(PackageSearchResultViewModel package)
        {
            if (package.SelectedVersion.IsPrerelease)
            {
                return(IncludePrerelease);
            }

            return(true);
        }
Exemple #11
0
        void UncheckExistingCheckedPackageWithDifferentVersion(PackageSearchResultViewModel packageViewModel)
        {
            PackageSearchResultViewModel existingPackageViewModel = GetExistingCheckedPackageViewModel(packageViewModel.Id);

            if (existingPackageViewModel != null)
            {
                CheckedPackageViewModels.Remove(existingPackageViewModel);
                existingPackageViewModel.IsChecked = false;
            }
        }
Exemple #12
0
        public void LoadPackageMetadata(PackageSearchResultViewModel packageViewModel)
        {
            var provider = new MultiSourcePackageMetadataProvider(
                selectedPackageSource.GetSourceRepositories(),
                packageManager.PackagesFolderSourceRepository,
                packageManager.GlobalPackagesFolderSourceRepository,
                new NuGet.Logging.NullLogger());

            packageViewModel.LoadPackageMetadata(provider, cancellationTokenSource.Token);
        }
Exemple #13
0
 bool IsValidRowAndUrl(int row, Uri uri)
 {
     if (row < packageStore.RowCount)
     {
         PackageSearchResultViewModel packageViewModel = packageStore.GetValue(row, packageViewModelField);
         if (packageViewModel != null)
         {
             return(uri == packageViewModel.IconUrl);
         }
     }
     return(false);
 }
Exemple #14
0
 void PackagesListRowActivated(object sender, ListViewRowEventArgs e)
 {
     if (PackagesCheckedCount > 0)
     {
         AddPackagesButtonClicked(sender, e);
     }
     else
     {
         PackageSearchResultViewModel packageViewModel = packageStore.GetValue(e.RowIndex, packageViewModelField);
         InstallPackage(packageViewModel);
     }
 }
Exemple #15
0
        void DrawCheckBox(Context ctx, PackageSearchResultViewModel 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);
        }
Exemple #16
0
 void PackagesListRowActivated(object sender, ListViewRowEventArgs e)
 {
     if (PackagesCheckedCount > 0)
     {
         AddPackagesButtonClicked(sender, e);
     }
     else
     {
         PackageSearchResultViewModel packageViewModel = packageStore.GetValue(e.RowIndex, packageViewModelField);
         packagesToAdd = GetPackagesToAdd(new [] { packageViewModel });
         Close();
     }
 }
Exemple #17
0
 void InstallPackage(PackageSearchResultViewModel packageViewModel)
 {
     try {
         if (packageViewModel != null)
         {
             List <IPackageAction> packageActions = CreateInstallPackageActions(
                 new PackageSearchResultViewModel [] { packageViewModel });
             InstallPackages(packageActions);
         }
     } catch (Exception ex) {
         LoggingService.LogError("Installing package failed.", ex);
         ShowErrorMessage(ex.Message);
     }
 }
 public IPackageAction CreateInstallPackageAction(PackageSearchResultViewModel packageViewModel)
 {
     return(new InstallNuGetPackageAction(
                SelectedPackageSource.GetSourceRepositories(),
                solutionManager,
                dotNetProject,
                projectContext
                )
     {
         IncludePrerelease = IncludePrerelease,
         PackageId = packageViewModel.Id,
         Version = packageViewModel.SelectedVersion
     });
 }
Exemple #19
0
 void UpdatePackageViewModelIfPreviouslyChecked(PackageSearchResultViewModel packageViewModel)
 {
     ignorePackageCheckedChanged = true;
     try {
         PackageSearchResultViewModel existingPackageViewModel = GetExistingCheckedPackageViewModel(packageViewModel.Id);
         if (existingPackageViewModel != null)
         {
             packageViewModel.UpdateFromPreviouslyCheckedViewModel(existingPackageViewModel);
             CheckedPackageViewModels.Remove(existingPackageViewModel);
             CheckedPackageViewModels.Add(packageViewModel);
         }
     } finally {
         ignorePackageCheckedChanged = false;
     }
 }
Exemple #20
0
        bool OlderPackageInstalledThanPackageSelected()
        {
            if (PackagesCheckedCount != 0)
            {
                return(false);
            }

            PackageSearchResultViewModel selectedPackageViewModel = GetSelectedPackageViewModel();

            if (selectedPackageViewModel != null)
            {
                return(selectedPackageViewModel.IsOlderPackageInstalled());
            }
            return(false);
        }
Exemple #21
0
 void PopulatePackageDependencies(PackageSearchResultViewModel 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;
     }
 }
Exemple #22
0
        void PackageSearchEntryActivated(object sender, EventArgs e)
        {
            if (loadingMessageVisible)
            {
                return;
            }

            if (PackagesCheckedCount > 0)
            {
                AddPackagesButtonClicked(sender, e);
            }
            else
            {
                PackageSearchResultViewModel selectedPackageViewModel = GetSelectedPackageViewModel();
                InstallPackage(selectedPackageViewModel);
            }
        }
Exemple #23
0
        List <PackageSearchResultViewModel> GetSelectedPackageViewModels()
        {
            List <PackageSearchResultViewModel> packageViewModels = viewModel.CheckedPackageViewModels.ToList();

            if (packageViewModels.Count > 0)
            {
                return(packageViewModels);
            }

            PackageSearchResultViewModel selectedPackageViewModel = GetSelectedPackageViewModel();

            if (selectedPackageViewModel != null)
            {
                packageViewModels.Add(selectedPackageViewModel);
            }
            return(packageViewModels);
        }
Exemple #24
0
        void ShowSelectedPackage()
        {
            RemoveSelectedPackagePropertyChangedEventHandler();

            PackageSearchResultViewModel packageViewModel = GetSelectedPackageViewModel();

            if (packageViewModel != null)
            {
                ShowPackageInformation(packageViewModel);
            }
            else
            {
                ClearSelectedPackageInformation();
            }
            viewModel.SelectedPackage = packageViewModel;
            UpdateAddPackagesButton();
        }
Exemple #25
0
        public void OnPackageCheckedChanged(PackageSearchResultViewModel packageViewModel)
        {
            if (ignorePackageCheckedChanged)
            {
                return;
            }

            if (packageViewModel.IsChecked)
            {
                UncheckExistingCheckedPackageWithDifferentVersion(packageViewModel);
                CheckedPackageViewModels.Add(packageViewModel);
            }
            else
            {
                CheckedPackageViewModels.Remove(packageViewModel);
            }
        }
Exemple #26
0
        void PackageSearchEntryActivated(object sender, EventArgs e)
        {
            if (loadingMessageVisible)
            {
                return;
            }

            if (PackagesCheckedCount > 0)
            {
                AddPackagesButtonClicked(sender, e);
            }
            else
            {
                PackageSearchResultViewModel selectedPackageViewModel = GetSelectedPackageViewModel();
                packagesToAdd = GetPackagesToAdd(new [] { selectedPackageViewModel });
                Close();
            }
        }
Exemple #27
0
        protected override void OnButtonPressed(ButtonEventArgs args)
        {
            PackageSearchResultViewModel 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);
            }
        }
Exemple #28
0
        void AppendPackagesToListView()
        {
            bool packagesListViewWasEmpty = (packageStore.RowCount == 0);

            for (int row = packageStore.RowCount; row < viewModel.PackageViewModels.Count; ++row)
            {
                PackageSearchResultViewModel packageViewModel = viewModel.PackageViewModels [row];
                AppendPackageToListView(packageViewModel);
                LoadPackageImage(row, packageViewModel);
            }

            if (packagesListViewWasEmpty && (packageStore.RowCount > 0))
            {
                packagesListView.SelectRow(0);
            }

            if (!viewModel.IsReadingPackages && (packageStore.RowCount == 0))
            {
                ShowNoPackagesFoundMessage();
            }
        }
Exemple #29
0
        void ShowPackageInformation(PackageSearchResultViewModel packageViewModel)
        {
            this.packageNameLabel.Markup   = packageViewModel.GetNameMarkup();
            this.packageAuthor.Text        = packageViewModel.Author;
            this.packagePublishedDate.Text = packageViewModel.GetLastPublishedDisplayText();
            this.packageDownloads.Text     = packageViewModel.GetDownloadCountDisplayText();
            this.packageDescription.Text   = packageViewModel.Description;
            this.packageId.Text            = packageViewModel.Id;
            this.packageId.Visible         = packageViewModel.HasNoGalleryUrl;
            ShowUri(this.packageIdLink, packageViewModel.GalleryUrl, packageViewModel.Id);
            ShowUri(this.packageProjectPageLink, packageViewModel.ProjectUrl);
            ShowUri(this.packageLicenseLink, packageViewModel.LicenseUrl);

            PopulatePackageDependencies(packageViewModel);

            PopulatePackageVersions(packageViewModel);

            this.packageInfoVBox.Visible     = true;
            this.packageVersionsHBox.Visible = true;

            packageViewModel.PropertyChanged += SelectedPackageViewModelChanged;
            viewModel.LoadPackageMetadata(packageViewModel);
        }
 public PackageCellViewEventArgs(PackageSearchResultViewModel packageViewModel)
 {
     PackageViewModel = packageViewModel;
 }