当前位置: 首页>>代码示例>>C#>>正文


C# Android.DrawText方法代码示例

本文整理汇总了C#中Android.DrawText方法的典型用法代码示例。如果您正苦于以下问题:C# Android.DrawText方法的具体用法?C# Android.DrawText怎么用?C# Android.DrawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android的用法示例。


在下文中一共展示了Android.DrawText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnDraw

		protected override void OnDraw (Android.Graphics.Canvas canvas)
		{
			TextPaint paint = Paint;
			paint.Color = new Color(CurrentTextColor);
			paint.DrawableState = GetDrawableState();
			mViewWidth = MeasuredWidth;
			String text = (String) this.Text;
			mLineY = 0;
			mLineY += (int)TextSize;
			Layout layout = Layout;
			for (int i = 0; i < layout.LineCount; i++) {
				int lineStart = layout.GetLineStart(i);
				int lineEnd = layout.GetLineEnd(i);
				String line = text.Substring(lineStart, lineEnd-lineStart);

				float width = StaticLayout.GetDesiredWidth(text, lineStart, lineEnd, Paint);
				if (NeedScale(line)) {
					DrawScaledText(canvas, lineStart, line, width);
				} else {
					canvas.DrawText(line, 0, mLineY, paint);
				}

				mLineY += LineHeight;
			}
		}
开发者ID:aocsa,项目名称:CInca,代码行数:25,代码来源:JustifiedTextView.cs

示例2: Draw

        /// <Docs>The Canvas to which the View is rendered.</Docs>
        /// <summary>
        /// Draw the specified canvas.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        public override void Draw(Android.Graphics.Canvas canvas)
        {  
            base.Draw(canvas);

            var paintForAngle = new Paint { Color = (Android.Graphics.Color.White), TextSize = 37f };
            paintForAngle.SetStyle(Paint.Style.Stroke);
            paintForAngle.SetTypeface(Typeface.CreateFromAsset(Forms.Context.Assets, "Fonts/fontawesome.ttf"));

            canvas.DrawText('\uf078'.ToString(), (float)(canvas.ClipBounds.CenterX() * 1.65), (float)(canvas.ClipBounds.CenterY() * 1.15), paintForAngle);


            #region Disposing 
            paintForAngle.Dispose();
            canvas.Dispose();
            #endregion
        }
开发者ID:kosomgua,项目名称:CustomPicker,代码行数:21,代码来源:CustomPickerRenderer.cs

示例3: OnDraw

      protected override void OnDraw(Android.Graphics.Canvas canvas)
      {
         base.OnDraw(canvas);

         lock (this)
         {
            Image<Bgr, byte> image = _bgrBuffers.GetBuffer(0);

            if (image != null && !_imageSize.IsEmpty && canvas != null)
            {
               Stopwatch w = Stopwatch.StartNew();

               if ((_bmpImage != null) && (!_imageSize.Equals(_bmpImage.Size)))
               {
                  _bmpImage.Dispose();
                  _bmpImage = null;
                  _bmp.Dispose();
                  _bmp = null;
               }

               if (_bmpImage == null)
               {
                  _bmp = Android.Graphics.Bitmap.CreateBitmap(_imageSize.Width, _imageSize.Height, Android.Graphics.Bitmap.Config.Rgb565);
                  _bmpImage = new BitmapRgb565Image(_bmp);
               }

               _bmpImage.ConvertFrom(image);

               canvas.DrawBitmap(_bmp, 0, 0, _paint);

               w.Stop();

               _watch.Stop();
               
#if DEBUG
               canvas.DrawText(String.Format("{0:F2} FPS; {1}x{2}; Render Time: {3} ms",
                  1.0 / _watch.ElapsedMilliseconds * 1000,
                  _imageSize.Width,
                  _imageSize.Height,
                  w.ElapsedMilliseconds), 20, 20, _paint);
#endif
               _watch.Reset();
               _watch.Start();
            }
         }
      }
开发者ID:reidblomquist,项目名称:emgucv,代码行数:46,代码来源:ProcessedCameraPreview.cs

示例4: OnDraw

        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            if (mixerValue == null) // don't do anything if we're not connected to a mixervalue
                return;

            if (bmp == null) {
                bmp = BitmapFactory.DecodeResource (Resources, Resource.Drawable.Fader_Knob);
                Bitmap scaled = Bitmap.CreateScaledBitmap (bmp, 25, 55, true);
                bmp.Recycle();
                bmp = scaled;
            }

            int margin = 60;
            float radius = 4;
            int center = (Width / 2) + 5;
            int minY1 = margin - (bmp.Height / 2);
            int maxY1 = Height - margin - (bmp.Height / 2);
            rangeY = maxY1 - minY1;
            float factor = (float)mixerValue.GetValue() / (float)maxValue;

            bitmapX1 = center - bmp.Width / 2;
            bitmapY1 = maxY1 - (int)(factor * (float)rangeY);

            base.OnDraw (canvas);

            var paint = new Paint ();
            paint.Color = Color.White;
            paint.TextAlign = Paint.Align.Center;
            paint.TextSize = (float)12.0;
            paint.SetTypeface(Typeface.DefaultBold);

            if (channel_name != null)
                canvas.DrawText (channel_name, center - 5, 14, paint); // align with pan control

            int levelX1 = center - (bmp.Width / 2) - 2;
            int levelX2 = center + (bmp.Width / 2);

            paint.TextSize = (float)10.0;
            paint.TextAlign = Paint.Align.Right;

            foreach (var level in faderLevels) {
                float factorLevel = (float)level.Key / (float)maxValue;
                int levelY = maxY1 - (int)(factorLevel * (float)rangeY) + (bmp.Height / 2);

                canvas.DrawRect (levelX1, levelY - 1, levelX2, levelY, paint);
                canvas.DrawText (level.Value, levelX1 - 4, levelY + 3, paint);
            }

            paint.Color = Color.DarkGray;
            RectF rect = new RectF (center - 2, margin, center + 2, Height - margin);
            canvas.DrawRoundRect(rect, radius, radius, paint);
            paint.Color = Color.Black;
            rect = new RectF (center - 1, margin + 1, center + 1, Height - margin - 1);
            canvas.DrawRoundRect(rect, radius, radius, paint);

            bitmapX2 = bitmapX1 + bmp.Width;
            bitmapY2 = bitmapY1 + bmp.Height;

            if (isActive) {
                paint.Alpha = 255;
            } else {
                paint.Alpha = 180;
            }

            canvas.DrawBitmap (bmp, bitmapX1, bitmapY1, paint);

            //bmp.Recycle ();
        }
开发者ID:GeorgeWieggers,项目名称:QuMixDroid_xamarin,代码行数:68,代码来源:Fader.cs

示例5: Draw

            public override void Draw(Android.Graphics.Canvas canvas)
            {
                if (Control == null) return;

                Control.CreateGraphicBuffers();

                var ctime = System.Environment.TickCount;
                Fleux.UIElements.Canvas.drawtime = 0;

                if (Control.offUpdated)
                {
                    lock(Control.offBmp)
                    {

                        Control.Draw(new PaintEventArgs(Control.offGr, new Rectangle(0,0, Control.offBmp.Width, Control.offBmp.Height)));

                        updcnt++;
                    }
                }
                Control.offUpdated = false;

                lock(Control.offBmp)
                {
                    if (Fleux.Core.FleuxApplication.HorizontalMirror)
                    {
                        canvas.Save();
                        canvas.Scale (-1, 1);
                        canvas.Translate (-(float)Control.drect.Width(), 0);
                    }else if (Fleux.Core.FleuxApplication.VerticalMirror)
                    {
                        canvas.Save();
                        canvas.Scale (1, -1);
                        canvas.Translate (0, -(float)Control.drect.Height());
                    }

                    Control.offGr.Flush();

                    canvas.DrawBitmap(Control.offBmp.ABitmap, Control.srect, Control.drect, paint);

                    updcntflush++;
                }
                if (PerfData)
                {
                    ctime = System.Environment.TickCount - ctime;
                    {
                        totime += ctime;
                    }
                    var cavg = totime / (updcnt+1);

                    var cpaint = new Android.Graphics.Paint();
                    cpaint.Color = new Android.Graphics.Color(0xA0, 0xFF, 0xFF, 0xFF);
                    cpaint.SetStyle(Android.Graphics.Paint.Style.Fill);
                    canvas.DrawRect(0,0, 250, 20, cpaint);
                    canvas.DrawText(""+updcnt+":"+updcntflush+":"+updcntinval+" ctime: "+ctime+"cavg:"+cavg+" canv: "+Fleux.UIElements.Canvas.drawtime, 0,20, spaint);
                    cpaint.Dispose();
                    if (updcnt > 100)
                    {
                        totime = 0;
                        updcnt = 0;
                    }
                }
            }
开发者ID:cail,项目名称:fleux,代码行数:62,代码来源:DoubleBufferedControl.cs

示例6: Draw

        public override void Draw(Android.Graphics.Canvas canvas)
        {
            canvas.DrawCircle (mainCenter, mainCenter + 2, radius + radiusBorder, shadowPaint);
            canvas.DrawCircle (mainCenter, mainCenter, radius + radiusBorder, darkerBackPaint);
            canvas.DrawCircle (mainCenter, mainCenter, radius, backPaint);
            canvas.DrawBitmap (icon, mainCenter - icon.Width / 2, mainCenter - icon.Height / 2, imgPaint);

            if (Count != 0) {
                int bubbleCenter = center - removeRadius - bubbleOffset;
                greenPaint.Alpha = redPaint.Alpha = currentBubbleTransparency;
                removePaint.Alpha = 255 - currentBubbleTransparency;
                canvas.DrawCircle (bubbleCenter, bubbleCenter, removeRadius, removePaint);
                canvas.DrawCircle (bubbleCenter, bubbleCenter, innerRadius, Count < 0 ? redPaint : greenPaint);

                var c = Math.Abs (Count).ToString ();
                var textBounds = new Rect ();
                removePaint.GetTextBounds (c, 0, c.Length, textBounds);

                canvas.DrawText (c, bubbleCenter, bubbleCenter + textBounds.Height () / 2, removePaint);
            }
            DrawingCacheEnabled = true;
        }
开发者ID:Andrea,项目名称:FriendTab,代码行数:22,代码来源:CategoryBadge.cs

示例7: Draw

            public override void Draw(Android.Graphics.Canvas canvas)
            {
                if (Control == null) return;

                Control.CreateGraphicBuffers();

                if (origMatrix == null)
                {
                    origMatrix = new Android.Graphics.Matrix();
                    origMatrix.Set (canvas.Matrix);
                }
                if (hMatrix == null)
                {
                    hMatrix = new Android.Graphics.Matrix();
                    hMatrix.Set(origMatrix);
                    hMatrix.PostTranslate(-Control.offBmp.Width, 0);
                    hMatrix.PostScale(-1, 1);
                }
                if (vMatrix == null)
                {
                    vMatrix = new Android.Graphics.Matrix();
                    vMatrix.Set(origMatrix);
                    vMatrix.PostTranslate(0, -Control.offBmp.Height);
                    vMatrix.PostScale(1, -1);
                }

                var ctime = System.Environment.TickCount;
                var realupdate = false;
                Fleux.UIElements.Canvas.drawtime = 0;
                /**/
                if (Control.offNeedExtraDraw && Control.offUpdated)
                lock(Control.offBmp){
                    Control.offNeedExtraDraw = false;
                    Control.offUpdated = false;

                    Control.offBmpDraw = true;
                    Control.Draw(new PaintEventArgs(Control.offGr, new Rectangle(0,0, Control.offBmp.Width, Control.offBmp.Height)));
                    Control.offBmpDraw = false;

                    updcnt++;
                    realupdate = true;
                }
                //*/
                lock(Control.offBmp)
                {
                    if (Fleux.Core.FleuxApplication.HorizontalMirror)
                    {
                        canvas.Matrix = hMatrix;
                    }else if (Fleux.Core.FleuxApplication.VerticalMirror)
                    {
                        canvas.Matrix = vMatrix;
                    }else
                        canvas.Matrix = origMatrix;

                    // Thats for FastGraphics.cs
                    Control.offGr.Flush();

                    canvas.DrawBitmap(Control.offBmp.ABitmap, 0,0, paint);
                    Control.offUpdated = false;
                    updcntflush++;
                }
                if (PerfData)
                {
                    ctime = System.Environment.TickCount - ctime;
                    //if (realupdate)
                    {
                        totime += ctime;
                    }
                    var cavg = totime / (updcnt+1);

                    var cpaint = new Android.Graphics.Paint();
                    cpaint.Color = new Android.Graphics.Color(0xA0, 0xFF, 0xFF, 0xFF);
                    cpaint.SetStyle(Android.Graphics.Paint.Style.Fill);
                    canvas.DrawRect(0,0, 250, 20, cpaint);
                    canvas.DrawText(""+updcnt+":"+updcntflush+":"+updcntinval+" ctime: "+ctime+"cavg:"+cavg+" canv: "+Fleux.UIElements.Canvas.drawtime, 0,20, spaint);
                    cpaint.Dispose();
                    if (updcnt > 100)
                    {
                        totime = 0;
                        updcnt = 0;
                    }
                }
            }
开发者ID:flts,项目名称:fleux,代码行数:83,代码来源:DoubleBufferedControl.cs

示例8: OnDraw

        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            base.OnDraw(canvas);

            // Fill the background
            canvas.DrawPaint(mBackgroundPaint);

            // Test Text
            canvas.Save();
            var textWidth = mTextPaint.MeasureText("Hello");
            Rect textBounds = new Rect();
            mTextPaint.GetTextBounds("Hello", 0, 1, textBounds);
            canvas.DrawText("Hello", canvas.Width/2-textWidth/2, canvas.Height/2 - textBounds.Height()/2, mTextPaint);

            textWidth = mTextPaint.MeasureText("World");
            textBounds = new Rect();
            mTextPaint.GetTextBounds("World", 0, 1, textBounds);
            mTextPaint.Color = Color.Green;
            canvas.DrawText("World", (canvas.Width/2-textWidth/2) +100, (canvas.Height/2 - textBounds.Height()/2) + 100, mTextPaint);

            canvas.Restore();

            foreach (Box box in mBoxes) {
                float left = Math.Min(box.Origin.X, box.Current.X);
                float right = Math.Max(box.Origin.X, box.Current.X);
                float top = Math.Min(box.Origin.Y, box.Current.Y);
                float bottom = Math.Max(box.Origin.Y, box.Current.Y);
                canvas.Save();
                canvas.Rotate(box.Rotation, (box.Origin.X + box.Current.X)/2, (box.Origin.Y + box.Current.Y)/2 );
                canvas.DrawRect(left, top, right, bottom, mBoxPaint);
                canvas.Restore();
            }
        }
开发者ID:yingfangdu,项目名称:BNR,代码行数:33,代码来源:BoxDrawingView.cs


注:本文中的Android.DrawText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。