예제 #1
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);
        }
예제 #2
0
        void ShowPackageInformation(ManagePackagesSearchResultViewModel packageViewModel)
        {
            bool consolidate = viewModel.IsConsolidatePageSelected;

            if (consolidate)
            {
                projectsListViewLabel.Text = GettextCatalog.GetString("Select projects and a version for a consolidation.");
            }
            else
            {
                // 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);
            }

            if (viewModel.IsInstalledPageSelected)
            {
                packageVersionsLabel.WidthRequest = -1;
                currentPackageVersionHBox.Visible = false;
                packageVersionsHBox.Visible       = false;
            }
            else if (viewModel.IsUpdatesPageSelected)
            {
                PopulatePackageVersions(packageViewModel);
                ShowCurrentPackageVersion(packageViewModel);
                packageVersionsHBox.Visible = true;
            }
            else
            {
                packageVersionsLabel.WidthRequest = -1;
                currentPackageVersionHBox.Visible = false;
                PopulatePackageVersions(packageViewModel);
                packageVersionsHBox.Visible = true;
            }

            foreach (Widget child in packageInfoVBox.Children)
            {
                child.Visible = !consolidate;
            }

            if (consolidate)
            {
                PopulateProjectList();
            }
            else
            {
                projectStore?.Clear();
            }

            projectsListViewLabel.Visible = consolidate;
            projectsListViewVBox.Visible  = consolidate;
            this.packageInfoVBox.Visible  = true;

            packageViewModel.PropertyChanged += SelectedPackageViewModelChanged;
            viewModel.LoadPackageMetadata(packageViewModel);
        }