當前位置: 首頁>>代碼示例>>C#>>正文


C# Android.DrawRoundRect方法代碼示例

本文整理匯總了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);
        }
開發者ID:silent162,項目名稱:Design_masterpage,代碼行數:13,代碼來源:ExtendedFrameRenderer.cs

示例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);
			}
		}
開發者ID:mattsuDev,項目名稱:Xamarin.Forms.CustomBox,代碼行數:55,代碼來源:CustomBoxViewRenderer.cs

示例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 ();
        }
開發者ID:GeorgeWieggers,項目名稱:QuMixDroid_xamarin,代碼行數:68,代碼來源:Fader.cs


注:本文中的Android.DrawRoundRect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。