public SplitElement(Row row) : base(UITableViewCellStyle.Default, "splitelement") { Value = row; BackgroundColor = UIColor.White; _font = Font.WithSize(Font.PointSize * Element.FontSizeRatio); }
private static Tuple<NSMutableAttributedString,List<NewsCellView.Link>> CreateAttributedStringFromBlocks(UIFont font, UIColor primaryColor, IEnumerable<TextBlock> blocks) { var attributedString = new NSMutableAttributedString(); var links = new List<NewsCellView.Link>(); nint lengthCounter = 0; int i = 0; foreach (var b in blocks) { UIColor color = null; if (b.Tapped != null) color = LinkColor; color = color ?? primaryColor; var ctFont = new CoreText.CTFont(font.Name, font.PointSize); var str = new NSAttributedString(b.Value, new CoreText.CTStringAttributes() { ForegroundColor = color.CGColor, Font = ctFont }); attributedString.Append(str); var strLength = str.Length; if (b.Tapped != null) { var weakTapped = new WeakReference<Action>(b.Tapped); links.Add(new NewsCellView.Link { Range = new NSRange(lengthCounter, strLength), Callback = () => weakTapped.Get()?.Invoke(), Id = i++ }); } lengthCounter += strLength; } return new Tuple<NSMutableAttributedString, List<NewsCellView.Link>>(attributedString, links); }
/// <summary> /// Adds the text. /// </summary> /// <param name="image">The image.</param> /// <param name="text">The text.</param> /// <param name="point">The point.</param> /// <param name="font">The font.</param> /// <param name="color">The color.</param> /// <param name="alignment">The alignment.</param> /// <returns>UIImage.</returns> public static UIImage AddText( this UIImage image, string text, CGPoint point, UIFont font, UIColor color, UITextAlignment alignment = UITextAlignment.Left) { //var labelRect = new RectangleF(point, new SizeF(image.Size.Width - point.X, image.Size.Height - point.Y)); var h = text.StringHeight(font, image.Size.Width); var labelRect = new CGRect(point, new CGSize(image.Size.Width - point.X, h)); var label = new UILabel(labelRect) { Font = font, Text = text, TextColor = color, TextAlignment = alignment, BackgroundColor = UIColor.Clear }; var labelImage = label.ToNativeImage(); using (var context = image.Size.ToBitmapContext()) { var rect = new CGRect(new CGPoint(0, 0), image.Size); context.DrawImage(rect, image.CGImage); context.DrawImage(labelRect, labelImage.CGImage); context.StrokePath(); return UIImage.FromImage(context.ToImage()); } }
public TCProfileView (TCSpecialistProfileViewController parentVC) { this.parentVC = parentVC; fontBody = MUtils.getFontWithSize (false, 16.0f); fontTitle = MUtils.getFontWithSize (false, 20.0f); fontBodyBold = MUtils.getFontWithSize (true, 16.0f); }
static MessageView() { TitleFont = UIFont.BoldSystemFontOfSize(16.0f); DescriptionFont = UIFont.SystemFontOfSize(14.0f); TitleColor = UIColor.FromWhiteAlpha(1.0f, 1.0f); DescriptionColor = UIColor.FromWhiteAlpha(1.0f, 1.0f); }
public LoadMoreElement (string normalCaption, string loadingCaption, Action<LoadMoreElement> tapped, UIFont font, UIColor textColor) : base ("") { NormalCaption = normalCaption; LoadingCaption = loadingCaption; Tapped += tapped; Font = font; TextColor = textColor; }
/// <summary> /// Gets the rectangle of a string. /// </summary> /// <param name="text">The text.</param> /// <param name="font">The font.</param> /// <param name="width">The width.</param> /// <returns>CGRect.</returns> public static CGRect StringRect(this string text, UIFont font, nfloat width) { return text.ToNativeString().GetBoundingRect( new CGSize(width, nfloat.MaxValue), NSStringDrawingOptions.OneShot,//.UsesFontLeading | NSStringDrawingOptions.UsesLineFragmentOrigin, new UIStringAttributes { Font = font }, null); }
public StringElement() { Font = DefaultTitleFont.WithSize(DefaultTitleFont.PointSize); SubtitleFont = DefaultDetailFont.WithSize(DefaultDetailFont.PointSize); BackgroundColor = BgColor; TextColor = DefaultTitleColor; DetailColor = DefaultDetailColor; }
public LoadMoreElement (string normalCaption, string loadingCaption, Action<LoadMoreElement> tapped, UIFont font, UIColor textColor) : base (UITableViewCellStyle.Default, key.ToString()) { NormalCaption = normalCaption; LoadingCaption = loadingCaption; Tapped += tapped; Font = font; TextColor = textColor; }
public UIFont ResizeProportionalAndAlternative (UIFont font) { var attributes = new UIFontAttributes ( new UIFontFeature (CTFontFeatureNumberSpacing.Selector.ProportionalNumbers), new UIFontFeature ((CTFontFeatureCharacterAlternatives.Selector)1)); var newDesc = font.FontDescriptor.CreateWithAttributes (attributes); return UIFont.FromDescriptor (newDesc, 40); }
public static nfloat MonoStringHeight(this string s, UIFont font, nfloat maxWidth) { if (string.IsNullOrEmpty(s)) return 0f; using (var str = new NSString (s)) { return str.StringSize(font, new CGSize(maxWidth, 1000), UILineBreakMode.WordWrap).Height; } }
public static nfloat MonoStringLength(this string s, UIFont font) { if (string.IsNullOrEmpty(s)) return 0f; using (var str = new NSString (s)) { return str.StringSize(font).Width; } }
Style GenerateStyle(UIFont font) { var result = new Style(typeof(Label)); result.Setters.Add(new Setter { Property = Label.FontSizeProperty, Value = (double)font.PointSize }); result.Setters.Add(new Setter { Property = Label.FontFamilyProperty, Value = font.Name }); return result; }
/// <summary> /// Gets the rectangle of a string. /// </summary> /// <param name="text">The text.</param> /// <param name="font">The font.</param> /// <param name="width">The width.</param> /// <returns>CGRect.</returns> public static CGRect StringRect(this string text, UIFont font, nfloat width) { var nativeString = new NSString(text); return nativeString.GetBoundingRect( new CGSize(width, float.MaxValue), NSStringDrawingOptions.UsesLineFragmentOrigin, new UIStringAttributes { Font = font }, null); }
public FloatLabeledTextField(CGRect frame) : base(frame) { _floatingLabel = new UILabel() { Alpha = 0.0f }; AddSubview(_floatingLabel); FloatingLabelTextColor = UIColor.Gray; FloatingLabelActiveTextColor = UIColor.Blue; FloatingLabelFont = UIFont.BoldSystemFontOfSize(12); }
private static void UpdateUi(CustomLabel view, UILabel control) { /* * // bold * var font = view.IsBold ? UIFont.BoldSystemFontOfSize((view.FontSize > 0) ? (float)view.FontSize : 12.0f) // bold * : UIFont.SystemFontOfSize((view.FontSize > 0) ? (float)view.FontSize : 12.0f); // regular * control.Font = font; */ if (string.IsNullOrEmpty(control.Text)) { return; } if (view.IsHtml) { UIKit.UIFont font = control.Font; string fontName = font.Name; System.nfloat fontSize = font.PointSize; string htmlContents = "<span style=\"font-family: '" + fontName + "'; font-size: " + fontSize + "\">" + view.Text + "</span>"; var nsAttr = new NSAttributedStringDocumentAttributes() { DocumentType = NSDocumentType.HTML }; var html = NSData.FromString(htmlContents, NSStringEncoding.Unicode); var nsError = new NSError(); control.AttributedText = new NSAttributedString(html, nsAttr, ref nsError); } else { var attrString = new NSMutableAttributedString(control.Text); if (view.IsUnderline) { attrString.AddAttribute(UIStringAttributeKey.UnderlineStyle, NSNumber.FromInt32((int)NSUnderlineStyle.Single), new NSRange(0, attrString.Length)); } if (view.IsStrikeThrough) { attrString.AddAttribute(UIStringAttributeKey.StrikethroughStyle, NSNumber.FromInt32((int)NSUnderlineStyle.Single), new NSRange(0, attrString.Length)); } control.AttributedText = attrString; } }
public static UIImage ImageFromFont(UIFont font, char character, UIColor fillColor) { var s = new NSString("" + character); var stringSize = s.StringSize(font); var maxSize = (nfloat)Math.Max(stringSize.Height, stringSize.Width); var size = new CGSize(maxSize, maxSize); UIGraphics.BeginImageContextWithOptions(size, false, 0f); fillColor.SetFill(); var drawPoint = new CGPoint((size.Width / 2f) - (stringSize.Width / 2f), (size.Height / 2f) - (stringSize.Height / 2f)); s.DrawString(drawPoint, font); var img = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); return img; }
public ScrollingTabView(List<UIViewController> viewControllers, UIFont titleFont, float tabBarHeight = 42) { //Create views tabbarBackground = new UIView(); selectedTabUnderlineView = new UIStackView(); contentScrollView = new UIScrollView(); ViewControllers = viewControllers; DefaultColors(); CurrentIndex = 0; TabItemSelected += HandleTabItemSelected; TabBarHeight = tabBarHeight; TitleFont = titleFont; contentScrollView.ShowsHorizontalScrollIndicator = false; contentScrollView.ShowsVerticalScrollIndicator = false; }
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 static void SetHighlightText(this UILabel label, string fullText, int substringIndex, UIColor highlightColor, bool reverse = false, UIFont font = null) { if(substringIndex != -1) { font = font ?? UIFont.FromName (label.Font.FamilyName, label.Font.PointSize); var substring = fullText.Substring (substringIndex); var startIndex = fullText.IndexOf(substring, StringComparison.CurrentCulture); var range = (reverse == true) ? new NSRange(0,startIndex) : new NSRange (startIndex, substring.Length); var titleText = new NSMutableAttributedString (fullText); titleText.SetAttributes (new UIStringAttributes () { Font = font, ForegroundColor = highlightColor }, range); label.AttributedText = titleText; } else { label.Text = fullText; } }
public static CGSize DrawString (this NSString item, CGRect rect, UIFont font, UILineBreakMode mode, UITextAlignment alignment) { // Get paragraph style var labelStyle = new NSMutableParagraphStyle(NSParagraphStyle.DefaultParagraphStyle.MutableCopy() as AppKit.NSMutableParagraphStyle); // Adjust alignment labelStyle.Alignment = alignment; // Adjust line break mode labelStyle.LineBreakMode = mode; // Define attributes var attributes = new NSStringAttributes () { Font = font.NSFont, ForegroundColor = UIStringDrawing.FillColor, ParagraphStyle = labelStyle }; // Preform drawing item.DrawInRect(rect, attributes); // Return new bounding size return new CGSize (rect.Width, rect.Height); }
public override bool Equals(object obj) { UIFont font = (obj as UIFont); return(this == font); }
public static CGSize StringSize(this string This, UIFont font, CGSize constrainedToSize, UILineBreakMode lineBreakMode) { using (var self = ((NSString)This)) return(self.StringSize(font, constrainedToSize, lineBreakMode)); }
/// <summary> /// Draws the centered string. /// </summary> /// <param name="text">The text.</param> /// <param name="color">The color.</param> /// <param name="rect">The rect.</param> /// <param name="font">The font.</param> private static void DrawCenteredString(NSString text, UIColor color, CGRect rect, UIFont font) { var paragraphStyle = (NSMutableParagraphStyle)NSParagraphStyle.Default.MutableCopy(); paragraphStyle.LineBreakMode = UILineBreakMode.TailTruncation; paragraphStyle.Alignment = UITextAlignment.Center; var attrs = new UIStringAttributes { Font = font, ForegroundColor = color, ParagraphStyle = paragraphStyle }; var size = text.GetSizeUsingAttributes(attrs); var targetRect = new CGRect( rect.X + (float)Math.Floor((rect.Width - size.Width) / 2f), rect.Y + (float)Math.Floor((rect.Height - size.Height) / 2f), size.Width, size.Height); text.DrawString(targetRect, attrs); }
public TVFont (UIFont font) { // Intialize this.UIFont = font; }
public void SetLabelFont(UIFont labelFont) { _labelFont = labelFont; SetNeedsDisplay(); // Need to redraw with new label font }
public static CGSize StringSize(this string This, UIFont font) { using (var self = ((NSString)This)) return(self.StringSize(font)); }
public static string GetFontName(this NativeFont f) => f.FontName;
public static NativeFont Font(string name, int size) => NativeFont.FromFontName(name, size);
public static CGSize StringSize(this string This, UIFont font, global::System.nfloat minFontSize, ref global::System.nfloat actualFontSize, global::System.nfloat forWidth, UILineBreakMode lineBreakMode) { using (var self = ((NSString)This)) return(self.StringSize(font, minFontSize, ref actualFontSize, forWidth, lineBreakMode)); }
private UILabel GetLabel (UIFont font, UIColor color) { var label = new UILabel (); FitpulseTheme.Apply (label); label.Font = font; label.TextColor = color; label.BackgroundColor = UIColor.Clear; return label; }
public void ResetToDefaults() { statusBarStyle = colorTheme.StatusBarStyle; screenTitleColor = colorTheme.ScreenTitleColor; mainGradientStartColor = colorTheme.MainGradientStartColor; mainGradientEndColor = colorTheme.MainGradientEndColor; mainSaturatedColor = colorTheme.MainSaturatedColor; disabledButtonColor = colorTheme.DisabledButtonColor; titleTextColor = colorTheme.TitleTextColor; descriptionDimmedColor = colorTheme.DescriptionDimmedColor; backgroundColor = colorTheme.BackgroundColor; navigationBarButtonColor = colorTheme.NavigationBarButtonColor; friendNameColor = colorTheme.FriendNameColor; lastMessageTextColor = colorTheme.LastMessageTextColor; dateMessageLabelColor = colorTheme.DateMessageLabelColor; conversationSelectedCellColor = colorTheme.ConversationSelectedCellColor; incomingBubbleStroke = colorTheme.IncomingBubbleStroke; incomingTextColor = colorTheme.IncomingTextColor; outgoingTextColor = colorTheme.OutgoingTextColor; outgoingBubbleColor = colorTheme.OutgoingBubbleColor; badgeTitleColor = colorTheme.BadgeTitleColor; screenTitleFont = fontTheme.ScreenTitleFont; navigationButtonTitleFont = fontTheme.NavigationButtonTitleFont; sausageContrinueButtonFont = fontTheme.SausageContrinueButtonFont; sausageSwitchIdentityButtonFont = fontTheme.SausageSwitchIdentityButtonFont; tabBarItemTitle = fontTheme.TabBarItemTitle; friendNameFont = fontTheme.FriendNameFont; lastMessageTextFont = fontTheme.LastMessageTextFont; dateMessageLabelFont = fontTheme.DateMessageLabelFont; messageFont = fontTheme.MessageFont; textTitleFont = fontTheme.TextTitleFont; badgeValueFont = fontTheme.BadgeValueFont; IsDirty = false; RaiseThemeChanged (this); }
private void InitDefaultValuesWithRadius(nfloat radius) { _radius = radius; _maximumValue = 100.0f; _minimumValue = 0.0f; _lineWidth = 5; _unfilledColor = UIColor.Black; _filledColor = UIColor.Red; _labelFont = UIFont.SystemFontOfSize(10.0f); _snapToLabels = false; _handleType = CircularSliderHandleType.CircularSliderHandleTypeSemiTransparentWhiteCircle; _labelColor = UIColor.Red; _labelDisplacement = 0; _angleFromNorth = 0; _innerMarkingLabels = new List<string> (); BackgroundColor = UIColor.Clear; }
public FontViewerScreen_iPhone (UIFont font) : base("FontViewerScreen_iPhone", null) { Initialize (); displayFont = font; }
private CGSize SizeOfString(NSString nsString, UIFont font) { NSDictionary attributes = NSDictionary.FromObjectAndKey(font, UIStringAttributeKey.Font); return new NSAttributedString(nsString, attributes).Size; }
public Theme(bool isDark, double fontScale) { this.IsDark = isDark; FontScale = fontScale; this.LineHeightMultiple = 1.2f; codeFont = Font(FindFontFamily(), (int)(NativeFont.SystemFontSize * fontScale + 0.5)); defaultParagraph = new NSMutableParagraphStyle { LineHeightMultiple = LineHeightMultiple, }; defaultAttrs = new NativeStringAttributes { Font = codeFont, ForegroundColor = !isDark?Rgb(101, 121, 140) : Rgb(127, 140, 152), ParagraphStyle = defaultParagraph, }.Dictionary; SelectedAttributes = new NativeStringAttributes { #if __MACOS__ BackgroundColor = !isDark ? NativeColor.SelectedTextBackground : NativeColor.SelectedTextBackground.ColorWithAlphaComponent(0.5f), #elif __IOS__ BackgroundColor = Rgb(0, 0x84, 0xD1).ColorWithAlpha(0.5f), #endif }.Dictionary; BackgroundColor = !isDark?Rgb(0xFF, 0xFF, 0xFF) : Rgb(41, 42, 47); ErrorBubbleBackgroundColor = !isDark?Rgb(0xC5, 0, 0xB) : Rgb(0xC5 * 5 / 8, 0, 0xB); ErrorBubbleTextAttributes = new NativeStringAttributes { ForegroundColor = Gray(255).ColorWithAlphaComponent(0.9375f), Font = NativeFont.BoldSystemFontOfSize((nfloat)(NativeFont.SystemFontSize)), ParagraphStyle = new NSMutableParagraphStyle { #if __MACOS__ LineBreakMode = NativeLineBreakMode.ByWordWrapping, #elif __IOS__ LineBreakMode = NativeLineBreakMode.WordWrap, #endif }, }.Dictionary; LineNumberFont = Font(codeFont.GetFontName(), (int)(NativeFont.SystemFontSize * 0.8 * fontScale + 0.5)); LineNumberColor = !isDark?Gray(0).ColorWithAlphaComponent(0.25f) : Gray(255).ColorWithAlphaComponent(0.125f); LineNumberAttributes = MakeLineNumberAttrs(); ColorAttributes = Enumerable.Repeat(defaultAttrs, 16).ToArray(); // Xcode Colors ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.Number] = MakeAttrs(Rgb(38, 42, 215), Rgb(166, 157, 247)); ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.String] = MakeAttrs(Rgb(197, 0, 11), Rgb(255, 128, 112)); ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.Identifier] = MakeAttrs(Gray(0x33), Gray(0xE0)); ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.Operator] = MakeAttrs(Gray(0x88), Gray(0xAA)); ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.Keyword] = MakeAttrs(Rgb(173, 61, 164), Rgb(255, 122, 178)); ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.Type] = MakeAttrs(Rgb(0, 128, 128), Rgb(0, 192, 164)); ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.Function] = MakeAttrs(Rgb(204, 102, 0), Rgb(255, 161, 79)); // Arduino Colors //ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.Number] = MakeAttrs (Rgb (197, 0, 11), Rgb (255, 211, 32)); //ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.String] = MakeAttrs (Rgb (197, 0, 11), Rgb (255, 211, 32)); //ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.Identifier] = MakeAttrs (NativeColor.Black, NativeColor.White); //ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.Keyword] = MakeAttrs (Rgb (52, 120, 184), Rgb (52, 120, 184)); //ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.Type] = MakeAttrs (Rgb (0, 128, 128), Rgb (0, 164, 164)); //ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.Function] = MakeAttrs (Rgb (204, 102, 0), Rgb (204, 102, 0)); //ColorAttributes[(int)CLanguage.Syntax.SyntaxColor.Operator] = MakeAttrs (Rgb (96, 96, 96), Rgb (164, 164, 192)); }
public static CGSize DrawString(this string This, CGRect rect, UIFont font, UILineBreakMode mode, UITextAlignment alignment) { using (var self = ((NSString)This)) return(self.DrawString(rect, font, mode, alignment)); }
public void SetFont(UIFont font) { this.labelTitle.Font = font; }
public static CGSize DrawString(this string This, CGRect rect, UIFont font) { using (var self = ((NSString)This)) return(self.DrawString(rect, font)); }
public static CGSize DrawString(this string This, CGPoint point, global::System.nfloat width, UIFont font, global::System.nfloat minFontSize, ref global::System.nfloat actualFontSize, UILineBreakMode breakMode, UIBaselineAdjustment adjustment) { using (var self = ((NSString)This)) return(self.DrawString(point, width, font, minFontSize, ref actualFontSize, breakMode, adjustment)); }
public static CGSize DrawString(this string This, CGPoint point, global::System.nfloat width, UIFont font, UILineBreakMode breakMode) { using (var self = ((NSString)This)) return(self.DrawString(point, width, font, breakMode)); }
public TextBlock(string value, UIFont font = null, UIColor color = null, Action tapped = null) : this(value, tapped) { Font = font; Color = color; }
public static CGSize StringSize(this string This, UIFont font, global::System.nfloat forWidth, UILineBreakMode breakMode) { using (var self = ((NSString)This)) return(self.StringSize(font, forWidth, breakMode)); }