Ejemplo n.º 1
1
        public static CATextLayer RenderLabel(Mapsui.Geometries.Point point, LabelStyle style, IFeature feature, IViewport viewport, string text)
        {
            // Offset stackOffset,
            Mapsui.Geometries.Point p = viewport.WorldToScreen(point);
            //var pointF = new xPointF((float)p.X, (float)p.Y);
            var label = new CATextLayer ();

            var aString = new Foundation.NSAttributedString (text,
                                                                       new CoreText.CTStringAttributes(){
                Font = new CoreText.CTFont("ArialMT", 10)
            });

            var frame = new CGRect(new CoreGraphics.CGPoint((int)p.X, (int)p.Y), GetSizeForText(0, aString));
            //label.Frame = frame;
            //frame.Width = (float)(p2.X - p1.X);// + margin);
            //frame.Height = (float)(p1.Y - p2.Y);

            label.FontSize = 10;
            label.ForegroundColor = new CoreGraphics.CGColor (0, 0, 255, 150);
            label.BackgroundColor = new CoreGraphics.CGColor (255, 0, 2, 150);
            label.String = text;

            label.Frame = frame;

            Console.WriteLine ("Pos " + label.Frame.X + ":" + label.Frame.Y + " w " + label.Frame.Width + " h " + label.Frame.Height);

            // = MonoTouch.UIKit.UIScreen.MainScreen.Scale;
            //	label.ContentsScale = scale;

            return label;
        }
Ejemplo n.º 2
0
        private static CATextLayer CreateCATextLayer(LabelStyle style, string text)
        {
            var label = new CATextLayer();

            var ctFont  = new CoreText.CTFont(style.Font.FontFamily, (float)style.Font.Size);
            var aString = new Foundation.NSAttributedString(text,
                                                            new CoreText.CTStringAttributes()
            {
                Font = ctFont
            });

            label.SetFont(ctFont);
            label.FontSize        = (float)style.Font.Size;
            label.ForegroundColor = ToCGColor(style.ForeColor);
            label.BackgroundColor = TransparentColor;
            label.ShadowOpacity   = 0;
            label.BorderWidth     = 0;

            label.String = text;

            var size = GetSizeForText(0, aString);

            label.Frame = new CGRect(0, 0, size.Width, size.Height);

            return(label);
        }
Ejemplo n.º 3
0
        public static CATextLayer RenderLabel(Mapsui.Geometries.Point point, LabelStyle style, IFeature feature, IViewport viewport, string text)
        {
            // Offset stackOffset,
            Mapsui.Geometries.Point p = viewport.WorldToScreen(point);
            //var pointF = new xPointF((float)p.X, (float)p.Y);
            var label = new CATextLayer();


            var aString = new Foundation.NSAttributedString(text,
                                                            new CoreText.CTStringAttributes()
            {
                Font = new CoreText.CTFont("ArialMT", 10)
            });

            var frame = new CGRect(new CoreGraphics.CGPoint((int)p.X, (int)p.Y), GetSizeForText(0, aString));

            //label.Frame = frame;
            //frame.Width = (float)(p2.X - p1.X);// + margin);
            //frame.Height = (float)(p1.Y - p2.Y);

            label.FontSize        = 10;
            label.ForegroundColor = new CoreGraphics.CGColor(0, 0, 255, 150);
            label.BackgroundColor = new CoreGraphics.CGColor(255, 0, 2, 150);
            label.String          = text;

            label.Frame = frame;

            Console.WriteLine("Pos " + label.Frame.X + ":" + label.Frame.Y + " w " + label.Frame.Width + " h " + label.Frame.Height);

            // = MonoTouch.UIKit.UIScreen.MainScreen.Scale;
            //	label.ContentsScale = scale;

            return(label);
        }
Ejemplo n.º 4
0
        private static CGSize GetSizeForText(int width, Foundation.NSAttributedString aString)
        {
            var frameSetter = new CoreText.CTFramesetter(aString);

            Foundation.NSRange range;
            var size = (CGSize)frameSetter.SuggestFrameSize((NSRange) new Foundation.NSRange(0, 0), (CTFrameAttributes)null,
                                                            (CGSize)                                new CoreGraphics.CGSize(width, Int32.MaxValue), out range);

            return(size);
        }
Ejemplo n.º 5
0
        private static CGSize GetSizeForText(int width, Foundation.NSAttributedString aString)
        {
            var frameSetter = new CoreText.CTFramesetter(aString);

            Foundation.NSRange range;
            //CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString( (CFMutableAttributedStringRef) attributedString);
            var size = (CGSize)frameSetter.SuggestFrameSize((NSRange) new Foundation.NSRange(0, 0), (CTFrameAttributes)null,
                                                            (CGSize)                                                                 new CoreGraphics.CGSize(width, Int32.MaxValue), out range);

            //CGSize suggestedSize = CTFramesetterSuggestFrameSizeWithConstraints(framesetter, CFRangeMake(0, 0), NULL, CGSizeMake(inWidth, CGFLOAT_MAX), NULL);
            //CFRelease(framesetter);
            Console.WriteLine("Size = " + size.Width + ":" + size.Height + "Range = " + range.Length);

            return(size);
        }
Ejemplo n.º 6
0
 public void Append(NSAttributedString first, params object [] rest)
 {
     Append(first);
     foreach (var obj in rest)
     {
         if (obj is NSAttributedString)
         {
             Append((NSAttributedString)obj);
         }
         else if (obj is string)
         {
             Append(new NSAttributedString((string)obj));
         }
         else
         {
             Append(new NSAttributedString(obj.ToString()));
         }
     }
 }
Ejemplo n.º 7
0
		private static CATextLayer CreateCATextLayer(LabelStyle style, string text)
		{
			var label = new CATextLayer ();

			var ctFont = new CoreText.CTFont (style.Font.FontFamily, (float)style.Font.Size);
			var aString = new Foundation.NSAttributedString (text, 
				new CoreText.CTStringAttributes() { Font = ctFont });

			label.SetFont(ctFont);
			label.FontSize = (float)style.Font.Size;
			label.ForegroundColor = ToCGColor(style.ForeColor);
			label.BackgroundColor = TransparentColor;
			label.ShadowOpacity = 0;
			label.BorderWidth = 0;

			label.String = text;

			var size = GetSizeForText (0, aString);

			label.Frame = new CGRect (0, 0, size.Width, size.Height);

			return label;
		}
Ejemplo n.º 8
0
 public virtual void AppendAttributedString(NSAttributedString attributedString)
 {
 }
Ejemplo n.º 9
0
 public virtual void SetAttributedString(NSAttributedString attributedString)
 {
 }
Ejemplo n.º 10
0
 public virtual void ReplaceCharactersInRange(NSRange aRange, NSAttributedString withAttributedString)
 {
 }
Ejemplo n.º 11
0
 public virtual void InsertAttributedString(NSAttributedString attributedString, int atIndex)
 {
 }
Ejemplo n.º 12
0
 public NSAttributedString(NSAttributedString attributedString)
 {
 }
Ejemplo n.º 13
0
 public virtual bool IsEqualToAttributedString(NSAttributedString otherString)
 {
     return(default(bool));
 }