Example #1
0
        private UIImage CreateImage (NSString title, float scale)
        {
            var titleAttrs = new UIStringAttributes () {
                Font = UIFont.FromName ("HelveticaNeue", 13f),
                ForegroundColor = Color.Gray,
            };

            var titleBounds = title.GetBoundingRect (
                                  new SizeF (Single.PositiveInfinity, Single.PositiveInfinity),
                                  NSStringDrawingOptions.UsesFontLeading | NSStringDrawingOptions.UsesDeviceMetrics,
                                  titleAttrs,
                                  null);

            var image = Image.TagBackground;
            var imageBounds = new RectangleF (
                                  0, 0,
                                  (float)Math.Ceiling (titleBounds.Width) + image.CapInsets.Left + image.CapInsets.Right + 4f,
                                  (float)Math.Ceiling (titleBounds.Height) + image.CapInsets.Top + image.CapInsets.Bottom
                              );

            titleBounds.X = image.CapInsets.Left + 2f;
            titleBounds.Y = image.CapInsets.Top;

            UIGraphics.BeginImageContextWithOptions (imageBounds.Size, false, scale);

            try {
                image.Draw (imageBounds);
                title.DrawString (titleBounds, titleAttrs);
                return UIGraphics.GetImageFromCurrentImageContext ();
            } finally {
                UIGraphics.EndImageContext ();
            }
        }
        public StylizedStringAttributes(
            UIFont font,
            UIColor color,
            float letterSpace,
            nfloat lineHeightMultiplier,
            StylizedStringCase stringCase,
            UITextAlignment textAlignment   = UITextAlignment.Left,
            NSUnderlineStyle underlineStyle = NSUnderlineStyle.None)
        {
            _stringCase = stringCase;

            NSMutableParagraphStyle paragraphStyle = null;

            if (lineHeightMultiplier != 1 || textAlignment != UITextAlignment.Left)
            {
                paragraphStyle = new NSMutableParagraphStyle
                {
                    LineHeightMultiple = lineHeightMultiplier,
                    Alignment          = textAlignment
                };
            }

            StringAttributes = new UIStringAttributes
            {
                Font              = font,
                ForegroundColor   = color,
                KerningAdjustment = letterSpace,
                ParagraphStyle    = paragraphStyle,
                UnderlineStyle    = underlineStyle
            };
        }
        public override void OnInitializeDisplayView(DataColumnBase dataColumn, UIView view)
        {
            base.OnInitializeDisplayView(dataColumn, view);

            UILabel label = view as UILabel;

            if (label == null)
            {
                return;
            }

            label.LineBreakMode = UILineBreakMode.WordWrap;
            label.Lines         = 2;
            if (dataColumn.GridColumn.HeaderTextAlignment == UITextAlignment.Right)
            {
                label.Text += "  .";
                var textAttributed = new NSMutableAttributedString(label.Text);
                var colorAttribute = new UIStringAttributes()
                {
                    ForegroundColor = UIColor.Clear
                };
                textAttributed.SetAttributes(colorAttribute, new NSRange(label.Text.Length - 1, 1));
                label.AttributedText = textAttributed;
            }
        }
Example #4
0
        public static UIImage UIImage(this FA fa, CGSize size, UIColor foreground, UIColor background)
        {
            var paragraph = new NSMutableParagraphStyle();

            paragraph.Alignment = UITextAlignment.Center;

            // Taken from FontAwesome.io's Fixed Width Icon CSS
            nfloat fontAspectRatio = 1.28571429f;

            nfloat fontSize   = (nfloat)Math.Min(size.Width / fontAspectRatio, size.Height);
            var    attributes = new UIStringAttributes()
            {
                Font            = fa.Font(fontSize),
                BackgroundColor = background,
                ForegroundColor = foreground,
                ParagraphStyle  = paragraph
            };

            var attributedString = new NSMutableAttributedString(fa.String(), attributes);
            var point            = new CGRect(0, (size.Height - fontSize) / 2, size.Width, fontSize);

            UIGraphics.BeginImageContextWithOptions(size, false, 0f);
            attributedString.DrawString(point);

            UIImage image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            return(image);
        }
Example #5
0
        public static float ContentSize(UITextView textView)
        {
            var frame = textView.Bounds;

            var textContainerInsets = textView.TextContainerInset;
            var contentInsents = textView.ContentInset;

            var leftRightPadding = textContainerInsets.Left + textContainerInsets.Right + textView.TextContainer.LineFragmentPadding * 2 + contentInsents.Left + contentInsents.Right;
            var topBottomPadding = textContainerInsets.Top + textContainerInsets.Bottom + contentInsents.Top + contentInsents.Bottom;

            var width = frame.Size.Width;
            width -= leftRightPadding;

            var height = frame.Size.Height;
            height -= topBottomPadding;

            frame.Size = new SizeF (width, height);

            var text = new NSString (textView.Text);

            var attributes = new UIStringAttributes {
                Font = textView.Font
            };

            var size = text.GetBoundingRect (new SizeF (frame.Width, float.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, attributes, new NSStringDrawingContext ());
            float measuredHeight = size.Height + topBottomPadding;
            return measuredHeight;
        }
Example #6
0
        public static NSMutableAttributedString BuildAttributedString(this ExtendedFont font, string text, UITextAlignment textAlignment = UITextAlignment.Natural)
        {
            if (font == null)
            {
                return(new NSMutableAttributedString(text));
            }

            var attributes = new UIStringAttributes();

            attributes.Font              = font.ToUIFont();
            attributes.ForegroundColor   = font.Color.ToUIColor();
            attributes.BackgroundColor   = UIColor.Clear;
            attributes.KerningAdjustment = font.Kerning;

            if (font.IsUnderlined)
            {
                attributes.UnderlineStyle = NSUnderlineStyle.Single;
            }

            var attribString = new NSMutableAttributedString(text, attributes);

            if (font.LineSpacing != 0)
            {
                var paragraphStyle = new NSMutableParagraphStyle()
                {
                    LineSpacing = (nfloat)font.LineSpacing,
                    Alignment   = textAlignment
                };

                attribString.AddAttribute(UIStringAttributeKey.ParagraphStyle, paragraphStyle, new NSRange(0, attribString.Length));
            }

            return(attribString);
        }
        public void SetAppearance(UINavigationController controller, ShellAppearance appearance)
        {
            var background = appearance.BackgroundColor;
            var foreground = appearance.ForegroundColor;
            var titleColor = appearance.TitleColor;

            var navBar = controller.NavigationBar;

            if (_defaultTint == null)
            {
                _defaultBarTint         = navBar.BarTintColor;
                _defaultTint            = navBar.TintColor;
                _defaultTitleAttributes = navBar.TitleTextAttributes;
            }

            if (background != null)
            {
                navBar.BarTintColor = background.ToUIColor();
            }
            if (foreground != null)
            {
                navBar.TintColor = foreground.ToUIColor();
            }
            if (titleColor != null)
            {
                navBar.TitleTextAttributes = new UIStringAttributes
                {
                    ForegroundColor = titleColor.ToUIColor()
                };
            }
        }
        public void GenView(MKClusterAnnotation cluster)
        {
            AnnotationViewSize annotationSize = MapSettings.AnnotationSize;

            if (cluster != null)
            {
                var renderer = new UIGraphicsImageRenderer(new CGSize(annotationSize.Width,
                                                                      annotationSize.Height));
                var count = cluster.MemberAnnotations.Length;

                Image = renderer.CreateImage((context) => {
                    //circle
                    UIColor.FromRGB(230, 141, 119).SetFill();
                    UIBezierPath.FromOval(new CGRect(0,
                                                     0,
                                                     annotationSize.Width,
                                                     annotationSize.Height)).Fill();

                    //text
                    var attributes = new UIStringAttributes()
                    {
                        ForegroundColor = UIColor.Black,
                        Font            = UIFont.BoldSystemFontOfSize(20)
                    };
                    var text = new NSString($"{count}");
                    var size = text.GetSizeUsingAttributes(attributes);
                    var rect = new CGRect(20 - size.Width / 2, 20 - size.Height / 2, size.Width, size.Height);
                    text.DrawString(rect, attributes);
                });
            }
        }
Example #9
0
        public void RetainCount_7()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(7, 0))
            {
                Assert.Inconclusive("Requires iOS 7+");
            }

            var sa = new UIStringAttributes();

            sa.Expansion = 0.0f;

            var uc = UIColor.FromRGBA(0.1f, 0.2f, 0.3f, 0.4f);

            Assert.That(uc.RetainCount, Is.EqualTo((nint)2), "UnderlineColor-new");
            sa.UnderlineColor = uc;
            Assert.That(uc.RetainCount, Is.EqualTo((nint)3), "UnderlineColor-set");

            var sc = UIColor.FromRGBA(0.5f, 0.6f, 0.7f, 0.8f);

            Assert.That(sc.RetainCount, Is.EqualTo((nint)2), "StrikethroughColor-new");
            sa.StrikethroughColor = sc;
            Assert.That(sc.RetainCount, Is.EqualTo((nint)3), "StrikethroughColor-set");

            var u = new NSUrl("http://xamarin.com");

            Assert.That(u.RetainCount, Is.EqualTo((nint)1), "Link-new");
            sa.Link = u;
            Assert.That(u.RetainCount, Is.EqualTo((nint)2), "Link-set");

#if !__WATCHOS__
            var ta = new NSTextAttachment();
            Assert.That(ta.RetainCount, Is.EqualTo((nint)1), "TextAttachment-new");
            sa.TextAttachment = ta;
            Assert.That(ta.RetainCount, Is.EqualTo((nint)2), "TextAttachment-set");
#endif // !__WATCHOS__

            for (int i = 0; i < 16; i++)
            {
                Assert.NotNull(sa.UnderlineColor, "UnderlineColor-get");
                Assert.NotNull(sa.StrikethroughColor, "StrikethroughColor-get");
                Assert.NotNull(sa.Link, "Link-get");
#if !__WATCHOS__
                Assert.NotNull(sa.TextAttachment, "TextAttachment-get");
#endif
            }

            Assert.That(sa.UnderlineColor.RetainCount, Is.EqualTo((nint)3), "UnderlineColor");
            Assert.That(sa.StrikethroughColor.RetainCount, Is.EqualTo((nint)3), "StrikethroughColor");
            Assert.That(sa.Link.RetainCount, Is.EqualTo((nint)2), "Link");
#if !__WATCHOS__
            Assert.That(sa.TextAttachment.RetainCount, Is.EqualTo((nint)2), "TextAttachment");
#endif

            GC.KeepAlive(uc);
            GC.KeepAlive(sc);
            GC.KeepAlive(u);
#if !__WATCHOS__
            GC.KeepAlive(ta);
#endif
        }
Example #10
0
        public override void Draw(CGRect rect)
        {
            base.Draw(rect);
            var cgContext = UIGraphics.GetCurrentContext();

            if (_mathList != null)
            {
                var appleContext = new AppleGraphicsContext()
                {
                    CgContext = cgContext
                };
                cgContext.SaveState();
                cgContext.SetStrokeColor(TextColor.CGColor);
                cgContext.SetFillColor(TextColor.CGColor);
                _displayList.Draw(appleContext);
                cgContext.RestoreState();
            }
            else if (ErrorMessage.IsNonEmpty())
            {
                cgContext.SaveState();
                float errorFontSize = 20;
                var   attributes    = new UIStringAttributes
                {
                    ForegroundColor = NColor.Red,
                    Font            = UIFont.SystemFontOfSize(errorFontSize),
                };
                var attributedString = new NSAttributedString(ErrorMessage, attributes);
                var ctLine           = new CTLine(attributedString);
                cgContext.TextPosition = new CGPoint(0, Bounds.Size.Height - errorFontSize);
                ctLine.Draw(cgContext);
                cgContext.RestoreState();
            }
        }
Example #11
0
        public static void reloadOption()
        {
            option = null;
            option = UIAlertController.Create("",
                                              null,
                                              UIAlertControllerStyle.ActionSheet);//(null, null, "Отменить", null, "Выйти");
            var titleAttributes = new UIStringAttributes
            {
                ForegroundColor = UIColor.Red,
            };
            var premium_vc = sb.InstantiateViewController(nameof(PremiumViewController));

            // Add Actions
            if (!QRViewController.is_premium)
            {
                option.AddAction(UIAlertAction.Create("Подробнее о Premium", UIAlertActionStyle.Default, (action) =>
                {
                    close_menu();
                    ViewController.navigationController.PushViewController(premium_vc, true);
                }));
                option.SetValueForKey(new NSAttributedString("Вы собираетесь выйти из учетной записи. Облачное хранение данных предусмотрено только для Premium-подписки, поэтому при следующем входе Вам придется создать свою визитку заново",
                                                             titleAttributes),
                                      new NSString("attributedTitle"));
            }
            else
            {
                option.SetValueForKey(new NSAttributedString("Выход", titleAttributes), new NSString("attributedTitle"));
            }
            option.AddAction(UIAlertAction.Create("Выйти из профиля", UIAlertActionStyle.Default, (action) => log_out()));
            option.AddAction(UIAlertAction.Create("Отменить", UIAlertActionStyle.Cancel, null /*, (action) => Console.WriteLine("Cancel button pressed.")*/));
        }
Example #12
0
        public static float GetFontSizeToFitWidth(string fontName, float width)
        {
            UIFont font = UIFont.FromName(fontName, 100);
            UIStringAttributes attributes = new UIStringAttributes();
            float measuredWidth = 0;
            float min = 10;
            float max = 1000;
            float fontSize = (max - min) / 2.0f + min;

            while (Math.Abs(measuredWidth - width) > 20)
            {
                fontSize = (max - min) / 2.0f + min;
                attributes.Font = font.WithSize(fontSize);
                measuredWidth = NSStringDrawing.GetSizeUsingAttributes((MonoTouch.Foundation.NSString)"00:00:00", attributes).Width;
                if (measuredWidth < width)
                    min = fontSize;
                else
                    max = fontSize;
            }

            if (measuredWidth > width)
                fontSize = min;

            return fontSize;
        }
Example #13
0
        private static void SetLinksStyles(HtmlLabel element, NSMutableAttributedString mutableHtmlString)
        {
            using var linkAttributeName = new NSString("NSLink");
            UIStringAttributes linkAttributes = null;

            if (!element.UnderlineText)
            {
                linkAttributes ??= new UIStringAttributes();
                linkAttributes.UnderlineStyle = NSUnderlineStyle.None;
            }
            ;
            if (!element.LinkColor.IsDefault)
            {
                linkAttributes ??= new UIStringAttributes();
                linkAttributes.ForegroundColor = element.LinkColor.ToUIColor();
            }
            ;

            mutableHtmlString.EnumerateAttribute(linkAttributeName, new NSRange(0, mutableHtmlString.Length), NSAttributedStringEnumeration.LongestEffectiveRangeNotRequired,
                                                 (NSObject value, NSRange range, ref bool stop) =>
            {
                if (value != null && value is NSUrl)
                {
                    // Replace the standard NSLink because iOS does not change the aspect of it otherwise.
                    mutableHtmlString.AddAttribute(LinkTapHelper.CustomLinkAttribute, value, range);
                    mutableHtmlString.RemoveAttribute("NSLink", range);

                    // Applies the style
                    if (linkAttributes != null)
                    {
                        mutableHtmlString.AddAttributes(linkAttributes, range);
                    }
                }
            });
        }
Example #14
0
        public SearchTextField(Action returnButtonTapped)
        {
            ClearButton        = new UIButton();
            ClearButton.Hidden = true;
            ClearButton.SetImage(UIImage.FromBundle("ic_delete_tag"), UIControlState.Normal);
            ClearButton.Frame      = new CGRect(0, 0, 16, 16);
            ClearButton.TouchDown += (sender, e) =>
            {
                Text = string.Empty;
                ClearButton.Hidden = true;
                ((TagFieldDelegate)Delegate).ChangeBackground(this);
                ClearButtonTapped?.Invoke();
            };
            RightView     = ClearButton;
            RightViewMode = UITextFieldViewMode.Always;

            var _searchPlaceholderAttributes = new UIStringAttributes
            {
                Font            = Constants.Regular14,
                ForegroundColor = Constants.R151G155B158,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString("Hashtag", _searchPlaceholderAttributes));
            AttributedPlaceholder  = at;
            AutocorrectionType     = UITextAutocorrectionType.No;
            AutocapitalizationType = UITextAutocapitalizationType.None;
            Font = Constants.Regular14;
            Layer.CornerRadius = 20;

            Delegate = new TagFieldDelegate(returnButtonTapped);
        }
Example #15
0
        /// <summary>
        /// Applies a theme to the navigation bar. Note, this does not update the theme for the title.
        /// </summary>
        /// <param name="navigationBar">A navigation bar to apply the theme to.</param>
        /// <param name="theme">The theme to apply to the navigation bar.</param>
        public static void ApplyTheme(this UINavigationBar navigationBar, NavigationBarTheme theme)
        {
            UIColor backgroundColor = theme.BackgroundColor.ToUIColor();

            navigationBar.BackgroundColor = backgroundColor;
            navigationBar.BarTintColor    = backgroundColor;
            navigationBar.Translucent     = theme.BackgroundColor.Alpha == 0;
            navigationBar.TintColor       = theme.ItemColor.ToUIColor();

            if (theme.ShadowColor.Alpha > 0)
            {
                nfloat height = 1.0f / UIScreen.MainScreen.Scale;
                UIView shadow = new UIView(new CGRect(0, navigationBar.Frame.Height, navigationBar.Frame.Width, height));
                shadow.BackgroundColor = theme.ShadowColor.ToUIColor();

                navigationBar.ShadowImage = null;
                navigationBar.AddSubview(shadow);
            }
            else
            {
                navigationBar.ShadowImage = new UIImage();
            }

            UIStringAttributes attributes = new UIStringAttributes();

            attributes.Font            = ViewThemeExtensions.GetFont(theme.FontName, ViewFontSizes.LargeFontSize, FontStyle.Bold);
            attributes.ForegroundColor = theme.FontColor.ToUIColor();

            navigationBar.TitleTextAttributes = attributes;
        }
Example #16
0
        private static void addProjectAttachmentsIfNeeded(TextFieldInfo info, NSMutableAttributedString finalString)
        {
            if (string.IsNullOrEmpty(info.ProjectColor))
            {
                return;
            }

            var color = MvxColor.ParseHexString(info.ProjectColor).ToNativeColor();

            var projectName = new NSAttributedString(info.ProjectName.TruncatedAt(maxTextLength), new UIStringAttributes
            {
                Font            = tokenFont,
                ForegroundColor = color
            });

            var textAttachment = new TokenTextAttachment(
                projectName,
                textVerticalOffset,
                color,
                regularFont.Descender,
                textFieldInfoTokenLeftMargin,
                textFieldInfoTokenRightMargin
                );
            var tokenString = new NSMutableAttributedString(NSAttributedString.FromAttachment(textAttachment));
            var attributes  = new UIStringAttributes {
                ParagraphStyle = paragraphStyle
            };

            attributes.Dictionary[Project] = new NSObject();
            tokenString.AddAttributes(attributes, new NSRange(0, tokenString.Length));

            finalString.Append(tokenString);
        }
        public SettingsInstructionView()
        {
            Layer.BorderColor = UIColor.LightGray.CGColor;
            Layer.CornerRadius = 10f;
            Layer.BorderWidth = 1f;
            BackgroundColor = UIColor.LightGray.ColorWithAlpha (.1f);

            Add(topLabel = new UILabel ());

            var firstAttributes = new UIStringAttributes {
                ForegroundColor = UIColor.Blue,
                BackgroundColor = UIColor.Yellow,
                Font = UIFont.FromName("Courier", 18f)
            };

            var secondAttributes = new UIStringAttributes {
                ForegroundColor = UIColor.Red,
                BackgroundColor = UIColor.Gray,
                StrikethroughStyle = NSUnderlineStyle.Single
            };

            var thirdAttributes = new UIStringAttributes {
                ForegroundColor = UIColor.Green,
                BackgroundColor = UIColor.Black
            };

            var prettyString = new NSMutableAttributedString ("UITextField is not pretty!");
            prettyString.SetAttributes (firstAttributes.Dictionary, new NSRange (0, 11));
            prettyString.SetAttributes (secondAttributes.Dictionary, new NSRange (15, 3));
            prettyString.SetAttributes (thirdAttributes.Dictionary, new NSRange (19, 6));

            // assign the styled text
            topLabel.AttributedText = prettyString;
        }
        void ChangeTheme(Page page)
        {
            var basePage = page as MainBaseContentPage;

            if (basePage != null)
            {
                NavigationBar.BarTintColor = basePage.BarBackgroundColor.ToUIColor();
                NavigationBar.TintColor    = basePage.BarTextColor.ToUIColor();

                var titleAttributes = new UIStringAttributes();
                titleAttributes.Font              = UIFont.FromName("SegoeUI", 22);
                titleAttributes.ForegroundColor   = basePage.BarTextColor == Color.Default ? titleAttributes.ForegroundColor ?? UINavigationBar.Appearance.TintColor : basePage.BarTextColor.ToUIColor();
                NavigationBar.TitleTextAttributes = titleAttributes;


                UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;

                //Hoping to animate the color transition at some point
//				var atts = new UITextAttributes {
//					TextColor = basePage.BarTextColor.ToUIColor(),
//					Font = UIFont.FromName("SegoeUI", 22),
//				};
//				UINavigationBar.Appearance.SetTitleTextAttributes(atts);
//
//				await UIView.AnimateAsync(250, () =>
//				{
//					NavigationBar.BarTintColor = basePage.BarBackgroundColor.ToUIColor();
//					NavigationBar.TintColor = basePage.BarTextColor.ToUIColor();
//				});
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomAttributedString" /> class.
        /// </summary>
        /// <param name="icon">The icon.</param>
        /// <param name="font">The font.</param>
        /// <param name="iconSizePx">The icon size px.</param>
        /// <param name="iconSizeRatio">The icon size ratio.</param>
        /// <param name="iconColor">Color of the icon.</param>
        /// <param name="rotate">if set to <c>true</c> [rotate].</param>
        /// <param name="baselineAligned">if set to <c>true</c> [baseline aligned].</param>
        public CustomAttributedString(IIcon icon, UIFont font, Single iconSizePx, Single iconSizeRatio, UIColor iconColor, Boolean rotate, Boolean baselineAligned)
        {
            _rotate            = rotate;
            _baselineAligned   = baselineAligned;
            _icon              = icon.Character.ToString();
            _font              = font;
            _iconSizePx        = iconSizePx;
            _iconSizeRatio     = iconSizeRatio;
            _iconColor         = iconColor;
            _rotationStartTime = DateTime.Now.Ticks;

            var opt = new UIStringAttributes
            {
                Font = font
            };

            if (baselineAligned == true)
            {
                opt.BaselineOffset = 0f;
            }

            if (iconColor != UIColor.DarkTextColor)
            {
                opt.ForegroundColor = iconColor;
            }
        }
        public NSAttributedString GetAttributedTitle(UIPickerView pickerView, nint row, nint component)
        {
            var colorValue = row * RGB.Offset;

            var value               = colorValue / RGB.Max;
            var redColorComponent   = RGB.Min;
            var greenColorComponent = RGB.Min;
            var blueColorComponent  = RGB.Min;

            switch ((ColorComponent)(int)component)
            {
            case ColorComponent.Red:
                redColorComponent = value;
                break;

            case ColorComponent.Green:
                greenColorComponent = value;
                break;

            case ColorComponent.Blue:
                blueColorComponent = value;
                break;

            default:
                throw new InvalidOperationException("Invalid row/component combination for picker view.");
            }

            // Set the foreground color for the entire attributed string.
            var foregroundColor = new UIColor(redColorComponent, greenColorComponent, blueColorComponent, 1f);
            var attributes      = new UIStringAttributes {
                ForegroundColor = foregroundColor
            };

            return(new NSAttributedString($"{colorValue}", attributes));
        }
Example #21
0
        public void UpdateCellData(RewardItemModel item)
        {
            this.SelectionStyle = UITableViewCellSelectionStyle.None;
            UIStringAttributes stringAttributes = new UIStringAttributes
            {
                Font            = RewardName.Font,
                ForegroundColor = UIColor.Black,
                ParagraphStyle  = new NSMutableParagraphStyle()
                {
                    LineSpacing = 6.0f
                }
            };
            var AttributedText = new NSMutableAttributedString(item.Name);

            AttributedText.AddAttributes(stringAttributes, new NSRange(0, item.Name.Length));
            RewardName.AttributedText = AttributedText;
            RewardName.SizeToFit();
            //if (((RewardName.ContentSize.Height - RewardName.TextContainerInset.Top - RewardName.TextContainerInset.Bottom) / RewardName.Font.LineHeight) < 2)
            //{
            //    var frame = RewardName.Frame;
            //    frame.Y += (nfloat)(RewardName.Font.LineHeight * 0.6);
            //    RewardName.Frame = frame;
            //}
            RewardImage.Image = UIImage.FromBundle("CellImagePlaceholder");
        }
Example #22
0
        public static float ContentSize(UITextView textView)
        {
            var frame = textView.Bounds;

            var textContainerInsets = textView.TextContainerInset;
            var contentInsents      = textView.ContentInset;

            var leftRightPadding = textContainerInsets.Left + textContainerInsets.Right + textView.TextContainer.LineFragmentPadding * 2 + contentInsents.Left + contentInsents.Right;
            var topBottomPadding = textContainerInsets.Top + textContainerInsets.Bottom + contentInsents.Top + contentInsents.Bottom;

            frame.Size.Width  -= leftRightPadding;
            frame.Size.Height -= topBottomPadding;

            var text           = new NSString(textView.Text);
            var paragraphStyle = new NSMutableParagraphStyle {
                LineBreakMode = UILineBreakMode.WordWrap,
            };

            var attributes = new UIStringAttributes {
                Font = textView.Font
            };

            var   size           = text.GetBoundingRect(new SizeF(frame.Width, float.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, attributes, new NSStringDrawingContext());
            float measuredHeight = size.Height + topBottomPadding;

            return(measuredHeight);
        }
Example #23
0
        public void SetTitleTheme(ITextViewTheme theme)
        {
            var strAttr = new UIStringAttributes();

            strAttr.ForegroundColor            = (UIColor)theme.TextColor;
            _navigationBar.TitleTextAttributes = strAttr;
        }
        public void RefreshDisplayedCreditCount()
        {
            if (_seekiosSelected == null)
            {
                return;
            }
            var seekios = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(el => el.UIdSeekios == _seekiosSelected.UIdSeekios);

            // If there is any free credit on the seekios we display freeCredit
            if (CreditsLabel != null)
            {
                CreditsLabel.Text = SeekiosApp.Helper.CreditHelper.TotalCredits;
                var firstAttributes = new UIStringAttributes
                {
                    ForegroundColor = UIColor.FromRGB(98, 218, 115)
                };
                var resultTuple        = SeekiosApp.Helper.StringHelper.GetStartAndEndIndexOfStringInString(Application.LocalizedString("CreditOfferedAmount"), SeekiosApp.Helper.CreditHelper.CreditsOffered);
                var offeredCreditsText = new NSMutableAttributedString(string.Format(Application.LocalizedString("CreditOfferedAmount")
                                                                                     , SeekiosApp.Helper.CreditHelper.CreditsOffered));
                offeredCreditsText.SetAttributes(firstAttributes.Dictionary
                                                 , new NSRange(resultTuple.Item1, SeekiosApp.Helper.CreditHelper.CreditsOffered.Length));
                CreditsFreeLabel.AttributedText = offeredCreditsText;
            }

            if (Tableview != null)
            {
                Tableview.BeginUpdates();
                Tableview.ReloadSections(Foundation.NSIndexSet.FromIndex(1), UITableViewRowAnimation.None);
                Tableview.EndUpdates();
            }
        }
Example #25
0
        public override void Draw(PdfDisplayBox box, CoreGraphics.CGContext context)
        {
            // Draw original content
            base.Draw(box, context);

            using (context)
            {
                // Draw watermark underlay
                UIGraphics.PushContext(context);
                context.SaveState();

                var pageBounds = this.GetBoundsForBox(box);
                context.TranslateCTM(0.0f, pageBounds.Size.Height);
                context.ScaleCTM(1.0f, -1.0f);
                context.RotateCTM((float)(Math.PI / 4.0f));


                Console.WriteLine($"{pageBounds}");

                var attributes = new UIStringAttributes()
                {
                    ForegroundColor = UIColor.FromRGBA(255, 0, 0, 125),
                    Font            = UIFont.BoldSystemFontOfSize(84)
                };

                var text = new NSAttributedString("WATERMARK", attributes);

                text.DrawString(new CGPoint(250, 40));

                context.RestoreState();
                UIGraphics.PopContext();
            }
        }
Example #26
0
        private CGSize MessageSize()
        {
            if (!HasMessage)
            {
                return(CGSize.Empty);
            }

            var    boundedSize = new CGSize(AvailableWidth, float.MaxValue);
            CGSize descriptionLabelSize;

            if (!IsRunningiOS7OrLater())
            {
                var attr = new UIStringAttributes(NSDictionary.FromObjectAndKey(MessageFont, (NSString)MessageFont.Name));
                descriptionLabelSize = Message.GetBoundingRect(
                    boundedSize,
                    NSStringDrawingOptions.TruncatesLastVisibleLine,
                    attr,
                    null).Size;
            }
            else
            {
                descriptionLabelSize = Message.StringSize(
                    MessageFont,
                    boundedSize,
                    UILineBreakMode.TailTruncation);
            }

            return(descriptionLabelSize);
        }
Example #27
0
        public void UpdateCard(AccountHistoryResponse transaction, bool isFirst, bool isLast)
        {
            _topLine.Hidden    = isFirst;
            _bottomLine.Hidden = isLast;
            _action.Text       = transaction.Type.ToString();
            _amount.Text       = transaction.Amount;

            var _noLinkAttribute = new UIStringAttributes
            {
                Font            = Constants.Regular12,
                ForegroundColor = Constants.R151G155B158,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString(transaction.From.Equals(AppSettings.User.Login) ? $"to " : $"from ", _noLinkAttribute));
            var login = transaction.From.Equals(AppSettings.User.Login) ? transaction.To : transaction.From;

            var linkAttribute = new UIStringAttributes
            {
                Font            = Constants.Semibold12,
                ForegroundColor = Constants.R255G34B5,
                Link            = new NSUrl(login),
            };

            at.Append(new NSAttributedString($"@{login}", linkAttribute));

            _to.SetText(at);;
        }
Example #28
0
        internal static void SetLinksStyles(this NSMutableAttributedString mutableHtmlString, HtmlLabel element)
        {
            UIStringAttributes linkAttributes = null;

            if (!element.UnderlineText)
            {
                linkAttributes ??= new UIStringAttributes();
                linkAttributes.UnderlineStyle = NSUnderlineStyle.None;
            }
            ;
            if (!element.LinkColor.IsDefault)
            {
                linkAttributes ??= new UIStringAttributes();
                linkAttributes.ForegroundColor = element.LinkColor.ToUIColor();
            }
            ;

            mutableHtmlString.EnumerateAttribute(UIStringAttributeKey.Link, new NSRange(0, mutableHtmlString.Length), NSAttributedStringEnumeration.LongestEffectiveRangeNotRequired,
                                                 (NSObject value, NSRange range, ref bool stop) =>
            {
                if (value != null && value is NSUrl url)
                {
                    // Applies the style
                    if (linkAttributes != null)
                    {
                        mutableHtmlString.AddAttributes(linkAttributes, range);
                    }
                }
            });
        }
Example #29
0
        // ReSharper disable once MethodOverloadWithOptionalParameter
        public double CalculateHeight(string text, double width, float textSize, string fontName = null)
        {
            //uiLabel = new UILabel
            //{
            //    Text = text,
            //};
            //var font = uiLabel.Font;
            //font = font.WithSize(textSize);
            //uiLabel.Font = font;
            //uiLabel.SetNeedsLayout();
            //return uiLabel.Frame.Size.Height;

            var nsText    = new NSString(text);
            var boundSize = new SizeF((float)width, float.MaxValue);
            var options   = NSStringDrawingOptions.UsesFontLeading |
                            NSStringDrawingOptions.UsesLineFragmentOrigin;

            if (fontName == null)
            {
                fontName = "HelveticaNeue";
            }

            var attributes = new UIStringAttributes
            {
                Font = UIFont.FromName(fontName, textSize)
            };

            var sizeF = nsText.GetBoundingRect(boundSize, options, attributes, null).Size;

            return(sizeF.Height);
        }
        private UIImage CreateImage(NSString title, float scale)
        {
            var titleAttrs = new UIStringAttributes()
            {
                Font            = UIFont.FromName("HelveticaNeue", 13f),
                ForegroundColor = Color.Gray,
            };

            var titleBounds = new RectangleF(
                new PointF(0, 0),
                title.GetSizeUsingAttributes(titleAttrs)
                );

            var image       = Image.TagBackground;
            var imageBounds = new RectangleF(
                0, 0,
                (float)Math.Ceiling(titleBounds.Width) + image.CapInsets.Left + image.CapInsets.Right + 4f,
                (float)Math.Ceiling(titleBounds.Height) + image.CapInsets.Top + image.CapInsets.Bottom
                );

            titleBounds.X = image.CapInsets.Left + 2f;
            titleBounds.Y = image.CapInsets.Top;

            UIGraphics.BeginImageContextWithOptions(imageBounds.Size, false, scale);

            try {
                image.Draw(imageBounds);
                title.DrawString(titleBounds, titleAttrs);
                return(UIGraphics.GetImageFromCurrentImageContext());
            } finally {
                UIGraphics.EndImageContext();
            }
        }
        //
        private void SetConferenceLocationButton(string location)
        {
            var encodedAddress = System.Net.WebUtility.UrlEncode(location.Replace("\\n", " "));
            var mapAddress     = $@"http://maps.apple.com/?address={encodedAddress}";

            conferenceAddress.TouchUpInside += (sender, e) => {
                UIApplication.SharedApplication.OpenUrl(new NSUrl(mapAddress));
            };

            var statusAttributes = new UIStringAttributes
            {
                ForegroundColor = UIColor.FromRGBA(red: 0f, blue: 1.0f, green: 0.478431f, alpha: 1.0f),
                Font            = UIFont.FromName("FontAwesome", 16f)
            };

            var textAttributes = new UIStringAttributes
            {
                ForegroundColor = UIColor.FromRGBA(red: 0f, blue: 1.0f, green: 0.478431f, alpha: 1.0f),
                Font            = UIFont.FromName("OpenSans-Light", 14f)
            };

            location = "\xf041 " + location;
            var endOfString  = location.Length - 2;
            var prettyString = new NSMutableAttributedString(location);

            prettyString.SetAttributes(statusAttributes.Dictionary, new NSRange(0, 1));
            prettyString.SetAttributes(textAttributes.Dictionary, new NSRange(2, endOfString));
            this.conferenceAddress.SetAttributedTitle(prettyString, UIControlState.Normal);
        }
Example #32
0
 private SizeF GetButtonSize()
 {
     var attr = new UIStringAttributes {Font = buttonFont};
     var size1 = ((NSString) ShowText).GetSizeUsingAttributes(attr);
     var size2 = ((NSString) HideText).GetSizeUsingAttributes(attr);
     return size1.Width > size2.Width ? size1 : size2;
 }
Example #33
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method
            UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
            UINavigationBar.Appearance.BarTintColor        = UIColor.LightGray;
            UINavigationBar.Appearance.TintColor           = UIColor.White;

            var firstAttributes = new UIStringAttributes
            {
                ForegroundColor = UIColor.White,
                //Font = UIFont.FromName("Courier", 18f)
            };

            UINavigationBar.Appearance.TitleTextAttributes = firstAttributes;
            // create a new window instance based on the screen size
            Window = new UIWindow(UIScreen.MainScreen.Bounds)
            {
                RootViewController = new RootViewController()
            };

            // If you have defined a root view controller, set it here:
            Window.MakeKeyAndVisible();

            return(true);
        }
Example #34
0
        void ChangeTheme(Page page)
        {
            var item = page.ToolbarItems.FirstOrDefault(t => t.ClassId == "basket");

            if (item != null)
            {
                toolBarItem = item;
                page.ToolbarItems.Remove(item);
            }
            var basePage = page as MainBaseContentPage;

            if (basePage != null)
            {
                NavigationBar.BarTintColor             = basePage.ActionBarBackgroundColor.ToUIColor();
                NavigationBar.TintColor                = basePage.ActionBarTextColor.ToUIColor();
                UINavigationBar.Appearance.ShadowImage = new UIImage();
                UINavigationBar.Appearance.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);

                var titleAttributes = new UIStringAttributes();
                titleAttributes.Font              = UIFont.FromName("SegoeUI", 22);
                titleAttributes.ForegroundColor   = basePage.ActionBarTextColor == Color.Default ? titleAttributes.ForegroundColor ?? UINavigationBar.Appearance.TintColor : basePage.ActionBarTextColor.ToUIColor();
                NavigationBar.TitleTextAttributes = titleAttributes;

                UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
            }
        }
Example #35
0
        private void UpdateTabBadgeTextAttributes(UITabBarItem tabBarItem, Element element)
        {
            if (!tabBarItem.RespondsToSelector(new ObjCRuntime.Selector("setBadgeTextAttributes:forState:")))
            {
                // method not available, ios < 10
                Console.WriteLine("Plugin.Badge: badge text attributes only available starting with iOS 10.0.");
                return;
            }

            var attrs = new UIStringAttributes();

            var textColor = TabBadge.GetBadgeTextColor(element);

            if (textColor != Color.Default)
            {
                attrs.ForegroundColor = textColor.ToUIColor();
            }

            var font = TabBadge.GetBadgeFont(element);

            if (font != Font.Default)
            {
                attrs.Font = font.ToUIFont();
            }

            tabBarItem.SetBadgeTextAttributes(attrs, UIControlState.Normal);
        }
		public void Print (object sender, EventArgs args)
		{
			UIPrintInteractionController controller = UIPrintInteractionController.SharedPrintController;
			if (controller == null) {
				Console.WriteLine ("Couldn't get shared UIPrintInteractionController");
				return;
			}

			controller.CutLengthForPaper = delegate (UIPrintInteractionController printController, UIPrintPaper paper) {
				// Create a font with arbitrary size so that you can calculate the approximate
  				// font points per screen point for the height of the text. 
				UIFont font = textformatter.Font;

				NSString str = new NSString (textField.Text);
				UIStringAttributes attributes = new UIStringAttributes ();
				attributes.Font = font;
				SizeF size = str.GetSizeUsingAttributes (attributes);

				float approximateFontPointPerScreenPoint = font.PointSize / size.Height;

				// Create a new font using a size  that will fill the width of the paper 
				font = SelectFont (paper.PrintableRect.Size.Width * approximateFontPointPerScreenPoint);

				// Calculate the height and width of the text with the final font size
				attributes.Font = font;
				SizeF finalTextSize = str.GetSizeUsingAttributes (attributes);

				// Set the UISimpleTextFormatter font to the font with the size calculated
				textformatter.Font = font;

				// Calculate the margins of the roll. Roll printers may have unprintable areas
			    // before and after the cut.  We must add this to our cut length to ensure the
			    // printable area has enough room for our text.
				float lengthOfMargins = paper.PaperSize.Height - paper.PrintableRect.Size.Height;

				// The cut length is the width of the text, plus margins, plus some padding 
				return finalTextSize.Width + lengthOfMargins + paper.PrintableRect.Size.Width * PaddingFactor;
			};

			UIPrintInfo printInfo = UIPrintInfo.PrintInfo;
			printInfo.OutputType = UIPrintInfoOutputType.General;
			printInfo.Orientation = UIPrintInfoOrientation.Landscape;
			printInfo.JobName = textField.Text;

			textformatter = new UISimpleTextPrintFormatter (textField.Text) {
				Color = SelectedColor,
				Font = SelectFont ()
			};

			controller.PrintInfo = printInfo;
			controller.PrintFormatter = textformatter;

			if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
				controller.PresentFromRectInView (printButton.Frame, View, true, PrintingComplete);
			else
				controller.Present (true, PrintingComplete);
		}
        private static void SetText(Labs.Controls.IconButton iconButton, UIButton targetButton)
        {
            var renderedIcon = iconButton.Icon;

            // if no IconFontName is provided on the IconButton, default to FontAwesome
            var iconFontName = string.IsNullOrEmpty(iconButton.IconFontName)
                ? "fontawesome"
                : iconButton.IconFontName;

            var iconSize = iconButton.IconSize == default(float)
                ? 17f
                : iconButton.IconSize;

            var faFont = UIFont.FromName(iconFontName, iconSize);

            // set the icon to either be on the left or right of the button's text
            string combinedText = iconButton.Orientation == ImageOrientation.ImageToLeft 
                ? string.Format("{0}  {1}", renderedIcon, iconButton.Text) 
                : string.Format("{0}  {1}", iconButton.Text, renderedIcon);


            // string attributes for the icon
            var iconAttributes = new UIStringAttributes
            {
                ForegroundColor = iconButton.IconColor.ToUIColor(),
                BackgroundColor = targetButton.BackgroundColor,
                Font = faFont,
                TextAttachment = new NSTextAttachment()
            };

            // string attributes for the button's text. 
            // TODO: Calculate an appropriate BaselineOffset for the main button text in order to center it vertically relative to the icon
            var btnAttributes = new UIStringAttributes
            {
                BackgroundColor = iconButton.BackgroundColor.ToUIColor(),
                ForegroundColor = iconButton.TextColor.ToUIColor(),
                Font = GetButtonFont(iconButton,targetButton)
            };

            // Give the overall string the attributes of the button's text
            var prettyString = new NSMutableAttributedString(combinedText,btnAttributes);

            // Set the font for only the icon (1 char)
            prettyString.SetAttributes(iconAttributes.Dictionary,
                iconButton.Orientation == ImageOrientation.ImageToLeft
                    ? new NSRange(0, 1)
                    : new NSRange(prettyString.Length - 1, 1));


            // set the final formatted string as the button's text
            targetButton.SetAttributedTitle(prettyString, UIControlState.Normal);

            // center the button's contents
            targetButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            targetButton.TitleLabel.TextAlignment = UITextAlignment.Center;
        }
		private void ConfigureAttributedTextSystemButton()
		{
			UIStringAttributes attribs = new UIStringAttributes {
				ForegroundColor = ApplicationColors.Blue,
				StrikethroughStyle = NSUnderlineStyle.Single,
			};
			var titleAttributes = new NSAttributedString ("Button".Localize(), attribs);
			AttributedTextButton.SetAttributedTitle (titleAttributes, UIControlState.Normal);

			var highlightedTitleAttributes = new UIStringAttributes {
				ForegroundColor = UIColor.Green,
				StrikethroughStyle = NSUnderlineStyle.Thick
			};
			var highlightedAttributedTitle = new NSAttributedString ("Button".Localize (), highlightedTitleAttributes);
			AttributedTextButton.SetAttributedTitle (highlightedAttributedTitle, UIControlState.Highlighted);

			AttributedTextButton.TouchUpInside += OnButtonClicked;
		}
 private UIStringAttributes GetTitleTextAttributes()
 {
     var attributes = new UIStringAttributes();
     if (Font != null)
         attributes.Font = Font;
     if (TextColor != null)
         attributes.ForegroundColor = TextColor;
     return attributes;
 }
		static internal NSDictionary ToDictionary (
						  UIFont font,
						  UIColor foregroundColor,
						  UIColor backgroundColor,
						  UIColor strokeColor,
						  NSParagraphStyle paragraphStyle,
						  NSLigatureType ligature,
						  float kerning,
						  NSUnderlineStyle underlineStyle,
						  NSShadow shadow,
						  float strokeWidth,
						  NSUnderlineStyle strikethroughStyle)
		{
			var attr = new UIStringAttributes ();
			if (font != null){
				attr.Font = font;
			}
			if (foregroundColor != null){
				attr.ForegroundColor = foregroundColor;
			}
			if (backgroundColor != null){
				attr.BackgroundColor = backgroundColor;
			}
			if (strokeColor != null){
				attr.StrokeColor = strokeColor;
			}
			if (paragraphStyle != null){
				attr.ParagraphStyle = paragraphStyle;
			}
			if (ligature != NSLigatureType.Default){
				attr.Ligature = ligature;
			}
			if (kerning != 0){
				attr.KerningAdjustment = kerning;
			}
			if (underlineStyle != NSUnderlineStyle.None){
				attr.UnderlineStyle = underlineStyle;
			}
			if (shadow != null){
				attr.Shadow = shadow;
			}
			if (strokeWidth != 0){
				attr.StrokeWidth = strokeWidth;
			}
			if (strikethroughStyle != NSUnderlineStyle.None){
				attr.StrikethroughStyle = strikethroughStyle;
			}
			var dict = attr.Dictionary;
			return dict.Count == 0 ? null : dict;
		}				
		SizeF DescriptionSize ()
		{
			var boundedSize = new SizeF (AvailableWidth, float.MaxValue);
			SizeF descriptionLabelSize;
			if (!IsRunningiOS7OrLater ()) {
				var attr = new UIStringAttributes (NSDictionary.FromObjectAndKey (TitleFont, (NSString)TitleFont.Name));
				descriptionLabelSize = Description.GetBoundingRect (
					boundedSize, NSStringDrawingOptions.TruncatesLastVisibleLine, attr, null)
					.Size;

			} else {
				descriptionLabelSize = Description.StringSize (
					DescriptionFont, boundedSize, UILineBreakMode.TailTruncation);
			}

			return descriptionLabelSize;
		}
		public void UpdateFrom(TradeDoneModel model) {

			//
			// Currencies 'one, 'two' are always base, counter for the time being.
			// TODO: Understand when they might swap, eg if notional currency changed?
			//

			string currencyOne = "???";
			string currencyTwo = "???";
			string tradeStatus = "";

			UIStringAttributes strikethroughAttributes;

			switch (model.Trade.TradeStatus) {
			case Domain.Models.Execution.TradeStatus.Rejected:
				strikethroughAttributes = new UIStringAttributes {
					StrikethroughStyle = NSUnderlineStyle.Single
				};
				tradeStatus = "(REJECTED)";
				break;

			case Domain.Models.Execution.TradeStatus.Done:
			default:
				strikethroughAttributes = new UIStringAttributes {
					StrikethroughStyle = NSUnderlineStyle.None
				};
				break;
			}

			// Always displayed 'plain'...

			Direction.Text = model.Trade.Direction.ToString ();
			TradeId.Text = String.Format("{0} {1}", model.Trade.TradeId.ToString (), tradeStatus);

			// Displayed plain but needs some formatting to make nice...

			if (model.Trade.CurrencyPair.Length == 6) {
				currencyOne = model.Trade.CurrencyPair.Substring (0, 3);
				currencyTwo = model.Trade.CurrencyPair.Substring (3, 3);
				CurrencyPair.Text = String.Format("{0} / {1}", currencyOne, currencyTwo);
			} else {
				// We expect the currency pair to always be 3 + 3, but just in case...
				CurrencyPair.Text = model.Trade.CurrencyPair;
			}


			//			System.Console.WriteLine ("Trade details: {0}", model.Trade.ToString());

			// The following fields may be struck through in the event of trade failure...

			//
			// Note that we always use currencyTwo here for now...
			// This will be wrong when we allow notional to be in the counter currency.
			// TODO: Complete this implementation at that point. And work out what DealtCurrency means then.
			//

			CounterCCY.AttributedText = new NSAttributedString(currencyTwo, strikethroughAttributes);
			DirectionAmount.AttributedText = new NSAttributedString(Styles.FormatNotional(model.Trade.Notional, true), strikethroughAttributes);
			Rate.AttributedText = new NSAttributedString(model.Trade.SpotRate.ToString (), strikethroughAttributes);

			//
			// Note that 'Proper' trade dates (with spot date calculated with holidays etc taken into account).
			// TODO: Make sure we bind the correct date when it becomes available in future.
			//

			string valueDateFormatted = String.Format("SP. {0}", model.Trade.ValueDate.ToString ("dd MMM"));
			ValueDate.AttributedText = new NSAttributedString(valueDateFormatted, strikethroughAttributes);

			// We use some BOLD if the trader id matches the current user...

			UIStringAttributes maybeStrikeMaybeBold = new UIStringAttributes();
			maybeStrikeMaybeBold.StrikethroughStyle = strikethroughAttributes.StrikethroughStyle;
			if (model.Trade.TraderName == UserModel.Instance.TraderId) {
				maybeStrikeMaybeBold.Font = UIFont.BoldSystemFontOfSize(TraderId.Font.PointSize);
			}

			TraderId.AttributedText = new NSAttributedString(model.Trade.TraderName, maybeStrikeMaybeBold);

			//
			// Not directly available from ITrade, so we derive it thus?
			// At first was hardcoded 'EUR'!
			// So... using currencyOne is better but may not be right once UI and models allow notional currency to change.
			//
			// Maybe we'll end up with something akin to this...
			//			string directionCurrency = (model.Trade.Direction == Adaptive.ReactiveTrader.Client.Domain.Models.Direction.BUY) ? currencyOne : currencyTwo;
			//

			string directionCurrency = currencyOne;
			DirectionCCY.AttributedText = new NSAttributedString(directionCurrency, strikethroughAttributes);

			DoneButton.Hidden = true;

		}
		public NSAttributedString (string str, UIStringAttributes attributes)
			: this (str, attributes != null ? attributes.Dictionary : null)
		{
		}
		private NSAttributedString GetAttributedTitle (UIPickerView pickerView, int row, int component)
		{
			float colorValue = row * RGB.offset;

			float value = colorValue / RGB.max;
			float redColorComponent = RGB.min;
			float greenColorComponent = RGB.min;
			float blueColorComponent = RGB.min;

			switch( (ColorComponent)component)
			{
				case ColorComponent.Red:
					redColorComponent = value;
					break;

				case ColorComponent.Green:
					greenColorComponent = value;
					break;

				case ColorComponent.Blue:
					blueColorComponent = value;
					break;
			
				default:
					throw new InvalidOperationException ("Invalid row/component combination for picker view.");
			}

			UIColor foregroundColor = new UIColor (redColorComponent, greenColorComponent, blueColorComponent, alpha: 1f);

			// Set the foreground color for the entire attributed string.
			UIStringAttributes attributes = new UIStringAttributes {
				ForegroundColor = foregroundColor
			};

			var title = new NSAttributedString (string.Format ("{0}", (int)colorValue), attributes);
			return title;
		}
			private NSAttributedString BoldFirstLine(string firstLine, string secondLine)
			{
				var str = new NSMutableAttributedString(firstLine + "\n" + secondLine);

				var att = new UIStringAttributes ();
				att.Font = Fonts.BoldPrimaryFont(12f);
				att.ForegroundColor = Colors.PrimaryTextColor;
				
				str.AddAttributes (att.Dictionary, new NSRange (0, firstLine.Length));

				return str;
			}