Ejemplo n.º 1
0
        public override void Draw(RectangleF rect)
        {
            RectangleF r = Offset;

            string clearText = Text.Substring(0, ShowTextOffset);
            string grayText  = Text.Substring(ShowTextOffset, Text.Length - ShowTextOffset);

            CGContext context = UIGraphics.GetCurrentContext();

            CGColor clearColor = UIColor.Clear.CGColor;

            context.SetStrokeColor(clearColor);
            context.SetFillColor(clearColor);
            context.FillRect(rect);

            if (clearText.Length != 0)
            {
                r.Location = new PointF(r.Location.X + clearText.DrawString(Offset.Location, Font).Width, r.Location.Y);
            }

            CSRange charsToDraw = new CSRange(0, grayText.Length);

            if (charsToDraw.Length != 0)
            {
                CGColor grayColor = UIColor.LightGray.CGColor;

                context.SetStrokeColor(grayColor);
                context.SetFillColor(grayColor);

                var chars = grayText.ToCharArray();
                int i;
                for (i = 0; i < chars.Length; i++)
                {
                    char character = chars [i];
                    if (character == ' ')
                    {
                        r.Location = new PointF(r.Location.X + Offset.Size.Width, r.Location.Y);
                        continue;
                    }
                    if (character == 'X')
                    {
                        #if LED_FONT
                        RectangleF box = rect.Inset(2, 1);
                        #else
                        CGRect box = rect.Inset(3, 3);
                        #endif
                        nfloat radius = 3;
                        context.BeginPath();
                        context.MoveTo(box.GetMinX() + radius, box.GetMinY());
                        var    mask     = "0";
                        UIFont drawFont = JudoSDKManager.FIXED_WIDTH_FONT_SIZE_20;
                        mask.DrawString(box, drawFont);
                        r.Location = new PointF(r.Location.X + Offset.Size.Width, r.Location.Y);
                        continue;
                    }
                    break;
                }

                charsToDraw.Location += i;
                charsToDraw.Length   -= i;
                if (charsToDraw.Length != 0)
                {
                    grayText.Substring((int)charsToDraw.Location, (int)charsToDraw.Length).DrawString(r.Location, JudoSDKManager.FIXED_WIDTH_FONT_SIZE_20);
                }
            }
        }
		public override void Draw (RectangleF rect)
		{
			RectangleF r = Offset;

			string clearText = Text.Substring (0, ShowTextOffset);
			string grayText = Text.Substring (ShowTextOffset, Text.Length - ShowTextOffset);

			CGContext context = UIGraphics.GetCurrentContext ();

			CGColor clearColor = UIColor.Clear.CGColor;
			context.SetStrokeColor(clearColor);
			context.SetFillColor(clearColor);
			context.FillRect(rect);

			if (clearText.Length !=0) 
			{
				r.Location = new PointF(r.Location.X+ clearText.DrawString (Offset.Location, Font).Width,r.Location.Y);
			}

			CSRange charsToDraw = new CSRange(0, grayText.Length);

			if (charsToDraw.Length !=0) 
			{
				CGColor grayColor = UIColor.LightGray.CGColor;

				context.SetStrokeColor (grayColor);
				context.SetFillColor (grayColor);

				var chars = grayText.ToCharArray();
				int i;
				for (i = 0; i < chars.Length; i++) 
				{
					char character = chars[i];
					if (character == ' ') {
						r.Location= new PointF(r.Location.X+  Offset.Size.Width, r.Location.Y);
						continue;
					}
					if (character == 'X') {
						#if LED_FONT
						RectangleF box = rect.Inset(2, 1);
						#else
						CGRect box = rect.Inset (3, 3);
						#endif
						nfloat radius = 3;
						context.BeginPath ();
						context.MoveTo (box.GetMinX () + radius, box.GetMinY ());
						var mask = "0";
						UIFont drawFont = JudoSDKManager.FIXED_WIDTH_FONT_SIZE_20;
						mask.DrawString(box, drawFont);
						r.Location= new PointF(r.Location.X+  Offset.Size.Width, r.Location.Y);
						continue;
					}
					break;
				}

				charsToDraw.Location += i;
				charsToDraw.Length -= i;
				if (charsToDraw.Length != 0) 
				{					
					grayText.Substring((int)charsToDraw.Location, (int)charsToDraw.Length).DrawString (r.Location, JudoSDKManager.FIXED_WIDTH_FONT_SIZE_20);
				}
			}
		}