本文整理汇总了C#中Android.DrawRoundRect方法的典型用法代码示例。如果您正苦于以下问题:C# Android.DrawRoundRect方法的具体用法?C# Android.DrawRoundRect怎么用?C# Android.DrawRoundRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android
的用法示例。
在下文中一共展示了Android.DrawRoundRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(Android.Graphics.Canvas canvas)
{
//base.Draw (canvas);
var box = Element as ExtendedFrame;
var rect = new Rect ();
var paint = new Paint () {
Color = box.BackgroundColor.ToAndroid (),
AntiAlias = true,
};
GetDrawingRect (rect);
canvas.DrawRoundRect (new RectF (rect), 100, 100, paint);
}
示例2: Draw
/// <Docs>The Canvas to which the View is rendered.</Docs>
/// <summary>
/// BoxViewのカスタマイズはDrawで行う
/// </summary>
/// <param name="canvas">Canvas.</param>
public override void Draw(Android.Graphics.Canvas canvas)
{
// 2重に描画してしまうので、baseは描画しない
//base.Draw(canvas);
// ElementをキャストしてFormsで定義したCustomBoxViewを取得
var formsBox = (CustomBoxView)Element;
// Androidの描画はPaintを使用
using (var paint = new Paint())
{
// 塗りつぶし色の設定
paint.Color = formsBox.FillColor.ToAndroid();
// 吹き出し部分の設定
// パスの生成
var path = new Path();
// スタート地点の設定
path.MoveTo(0, 0);
// 経由地点の設定
path.LineTo(100, 10);
path.LineTo(100, 100);
// パスを繋げる
path.Close();
// 描画
canvas.DrawPath(path, paint);
// 角の丸い四角の設定
// 角丸の直径を決める
// widthとheightを比較して小さい方を基準にする
var minSize = Math.Min(Width, Height);
// 指定するのは直径なので、指定半径を2倍する
var diameter = formsBox.Radius * 2;
// 角丸の直径はminSize以下でなければならない
if (diameter > minSize)
diameter = minSize;
// 描画領域の設定
var rect = new RectF(0, 0, (float)Width, (float)Height);
//四角形描画
canvas.DrawRoundRect(rect, diameter, diameter, paint);
}
}
示例3: 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 ();
}