Ejemplo n.º 1
0
        private double ComputeHeight(ImageCell element, CellTableViewCell target)
        {
            double height = 0;
            var    labelPreferredWidth = Globals.LogicalScreenWidth
                                         - defaultImageViewLeftPadding
                                         - element.ImageWidth
                                         - leftPadding
                                         - rightPadding;

            // text
            var textSize = new NSString(target.TextLabel.Text).GetBoundingRect(
                new CGSize((nfloat)labelPreferredWidth, 0),
                NSStringDrawingOptions.UsesLineFragmentOrigin, new UIStringAttributes
            {
                Font = target.TextLabel.Font
            }, null);

            height += textSize.Height;

            // detail
            var detailSize = new NSString(target.DetailTextLabel.Text).GetBoundingRect(
                new CGSize((nfloat)labelPreferredWidth, 0),
                NSStringDrawingOptions.UsesLineFragmentOrigin, new UIStringAttributes
            {
                Font = target.DetailTextLabel.Font
            }, null);

            height += detailSize.Height;

            height = Math.Max(height, element.ImageHeight);

            height += topPadding + bottomPadding;

            return(height);
        }
Ejemplo n.º 2
0
 private void RenderCircle(ImageCell element, CellTableViewCell target)
 {
     if (element.RenderCircle)
     {
         double num = Math.Min(element.ImageWidth, element.ImageHeight);
         target.ImageView.Layer.CornerRadius  = (nfloat)(num / 2);
         target.ImageView.Layer.MasksToBounds = false;
         target.ImageView.ClipsToBounds       = true;
     }
     else
     {
         target.ImageView.Layer.CornerRadius = 0;
     }
 }
Ejemplo n.º 3
0
        private async void SetImage(ImageCell cell, CellTableViewCell target)
        {
            ImageSource imageSource = cell.ImageSource;

            if (imageSource != null)
            {
                UIImage uiimage;
                try
                {
                    uiimage = await cell.ImageSource.GetUIImage();
                }
                catch (TaskCanceledException)
                {
                    uiimage = null;
                }

                if (uiimage == null)
                {
                    if (cell.ImagePlaceholder != null)
                    {
                        uiimage = UIImage.FromBundle(cell.ImagePlaceholder.File);
                    }
                }

                NSRunLoop.Main.BeginInvokeOnMainThread(delegate
                {
                    if (uiimage != null && cell.ImageWidth > 0 && cell.ImageHeight > 0)
                    {
                        target.ImageView.Image = uiimage.Scale(new CGSize((nfloat)cell.ImageWidth, (nfloat)cell.ImageHeight), 0);
                    }
                    else
                    {
                        target.ImageView.Image = uiimage;
                    }

                    target.SetNeedsLayout();
                });
            }
            else
            {
                target.ImageView.Image = null;
            }
        }
Ejemplo n.º 4
0
 private void SetDetailFont(ImageCell element, CellTableViewCell target)
 {
     target.DetailTextLabel.Font = UIFont.FromName(element.DetailFontFamily, (nfloat)element.DetailFontSize);
 }