コード例 #1
0
        protected override void OnDraw(Context ctx, Rectangle cellArea)
        {
            PackageViewModel 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.
            var packageIdTextLayout = new TextLayout();

            packageIdTextLayout.Font     = packageIdTextLayout.Font.WithSize(packageIdFontSize);
            packageIdTextLayout.Markup   = packageViewModel.GetNameMarkup();
            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(PackageViewModel packageViewModel)
        {
            this.packageNameLabel.Markup   = packageViewModel.GetNameMarkup();
            this.packageVersionLabel.Text  = packageViewModel.Version.ToString();
            this.packageAuthor.Text        = packageViewModel.GetAuthors();
            this.packagePublishedDate.Text = packageViewModel.GetLastPublishedDisplayText();
            this.packageDownloads.Text     = packageViewModel.GetDownloadCountOrVersionDisplayText();
            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);
            this.packageDependenciesListHBox.Visible  = packageViewModel.HasDependencies;
            this.packageDependenciesNoneLabel.Visible = !packageViewModel.HasDependencies;
            this.packageDependenciesList.Text         = packageViewModel.GetPackageDependenciesDisplayText();

            this.packageInfoVBox.Visible = true;
        }