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


C# Rect.Height方法代码示例

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


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

示例1: CalculateStartScale

        /// <summary>
        ///   This method will determine the scaling ratio for the image view.
        /// </summary>
        /// <param name="startBounds">The visible rectangle of the thumbnail.</param>
        /// <param name="finalBounds">The visible rectangle of the expanded image view.</param>
        /// <returns></returns>
        private static float CalculateStartScale(Rect startBounds, Rect finalBounds)
        {
            float startScale;
            // First figure out width-to-height ratio of each rectangle.
            float finalBoundsRatio = finalBounds.Width() / (float)finalBounds.Height();
            float startBoundsRatio = startBounds.Width() / (float)startBounds.Height();

            if (finalBoundsRatio > startBoundsRatio)
            {
                // Extend start bounds horizontally
                startScale = (float)startBounds.Height() / finalBounds.Height();
                float startWidth = startScale * finalBounds.Width();
                float deltaWidth = (startWidth - startBounds.Width()) / 2;
                startBounds.Left -= (int)deltaWidth;
                startBounds.Right += (int)deltaWidth;
            }
            else
            {
                // Extend start bounds vertically
                startScale = (float)startBounds.Width() / finalBounds.Width();
                float startHeight = startScale * finalBounds.Height();
                float deltaHeight = (startHeight - startBounds.Height()) / 2;
                startBounds.Top -= (int)deltaHeight;
                startBounds.Bottom += (int)deltaHeight;
            }
            return startScale;
        }
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:33,代码来源:ZoomActivity.cs

示例2: GetBitmapMarker

        public Bitmap GetBitmapMarker(Context mContext, int resourceId, string text)
        {
            Resources resources = mContext.Resources;
            float scale = resources.DisplayMetrics.Density;
            Bitmap bitmap = BitmapFactory.DecodeResource(resources, resourceId);

            Bitmap.Config bitmapConfig = bitmap.GetConfig();

            // set default bitmap config if none
            if (bitmapConfig == null)
                bitmapConfig = Bitmap.Config.Argb8888;

            bitmap = bitmap.Copy(bitmapConfig, true);

            Canvas canvas = new Canvas(bitmap);
            Paint paint = new Paint(PaintFlags.AntiAlias);
            paint.Color = global::Android.Graphics.Color.Black;
            paint.TextSize = ((int)(14 * scale));
            paint.SetShadowLayer(1f, 0f, 1f, global::Android.Graphics.Color.White);

            // draw text to the Canvas center
            Rect bounds = new Rect();
            paint.GetTextBounds(text, 0, text.Length, bounds);
            int x = (bitmap.Width - bounds.Width()) / 2;
            int y = (bitmap.Height + bounds.Height()) / 2 - 20;

            canvas.DrawText(text, x, y, paint);

            return bitmap;
        }
开发者ID:sgraphics,项目名称:BindableMapTest,代码行数:30,代码来源:ExtendedMapRenderer.cs

示例3: Draw

        public override void Draw(Canvas canvas)
        {
            LoadResources ();

            var blackPaint = new Paint () { Color = black.Value };
            var whitePaint = new Paint () { Color = white.Value };

            XamGame.RenderBoard ((RectangleF rect, Square.ColourNames color) =>
            {
                var paint = color == Square.ColourNames.White ? whitePaint : blackPaint;
                canvas.DrawRect (rect.X, rect.Y, rect.Right, rect.Bottom, paint);

            }, (RectangleF rect, object image) =>
            {
                if (image != null)
                    canvas.DrawBitmap ((Bitmap) image, rect.Left, rect.Top, null);
            });

            // New Game button
            whitePaint.Color = white.Value;
            whitePaint.SetStyle (Paint.Style.Fill);
            whitePaint.TextSize = 30;
            whitePaint.AntiAlias = true;
            Rect bounds = new Rect ();
            whitePaint.GetTextBounds ("New Game", 0, 8, bounds);
            canvas.DrawText ("New Game", (this.Width - bounds.Width ()) / 2, this.Bottom - (XamGame.BoardUpperLeftCorner.Y - bounds.Height ()) / 2, whitePaint);

            whitePaint.Dispose ();
            blackPaint.Dispose ();

            base.Draw (canvas);
        }
开发者ID:rolfbjarne,项目名称:XamChess,代码行数:32,代码来源:GameView.cs

示例4: MeasureString

		//http://egoco.de/post/19077604048/calculating-the-height-of-text-in-android
		//http://stackoverflow.com/questions/16082359/how-to-auto-adjust-text-size-on-a-multi-line-textview-according-to-the-view-max
		public SizeF MeasureString(string text, int maxWidth = 2147483647)
		{
			TextPaint paint = AndroidBrush.CreateTextPaint();
			paint.TextSize = SizeInPoints;
			paint.SetTypeface(InnerFont);

			int lineCount = 0;

			int index = 0;
			int length = text.Length;

			float[] measuredWidths = new float[]{ 0 };
			float measuredWidth = 1f;
			while(index < length - 1) 
			{
				index += paint.BreakText(text, index, length, true, maxWidth, measuredWidths);
				lineCount++;
				if (measuredWidth < measuredWidths[0]) measuredWidth = measuredWidths[0];
			}

			Rect bounds = new Rect();
			paint.GetTextBounds("Py", 0, 2, bounds);
			float height = (float)System.Math.Floor((double)lineCount * bounds.Height());

			return new SizeF (measuredWidth, height);
		}
开发者ID:tzachshabtay,项目名称:MonoAGS,代码行数:28,代码来源:AndroidFont.cs

示例5: OnDraw

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

            var r = new Rect ();
            this.GetLocalVisibleRect (r);

            var half = r.Width() / 2;
            var height = r.Height();

            var percentage = (this.Limit - Math.Abs(this.CurrentValue)) / this.Limit;


            var paint = new Paint()
            {
                Color = this.CurrentValue < 0 ? this.negativeColor : this.positiveColor,
                StrokeWidth = 5
            };

            paint.SetStyle(Paint.Style.Fill);

            if (this.CurrentValue < 0)
            {
                var start = (float)percentage * half;
                var size = half - start;
                canvas.DrawRect (new Rect ((int)start, 0, (int)(start + size), height), paint);
            }
            else
            {
                canvas.DrawRect (new Rect((int)half, 0, (int)(half + percentage * half), height), paint);
            }
        }
开发者ID:GGHG72,项目名称:Xamarin-Forms-Labs,代码行数:32,代码来源:SensorBarDroidView.cs

示例6: OnBoundsChange

		protected override void OnBoundsChange (Rect bounds)
		{
			base.OnBoundsChange (bounds);
			if (oval == null)
				return;
			
			oval.Set (0, 0, bounds.Width (), bounds.Height ());
		}
开发者ID:richardboegli,项目名称:KinderChat,代码行数:8,代码来源:CircleDrawable.cs

示例7: OnBoundsChange

		protected override void OnBoundsChange (Rect bounds)
		{
			var width = bounds.Width ();
			var height = bounds.Height ();
			if (width <= 0 || height <= 0)
                		return;

            		if (Picture != null && (currentBitmap == null || currentBitmap.Height != height || currentBitmap.Width != width))
                		currentBitmap = SvgFactory.MakeBitmapFromPicture(Picture, width, height);
		}
开发者ID:jdluzen,项目名称:xamsvg,代码行数:10,代码来源:PictureBitmapDrawable.cs

示例8: Draw

 public override void Draw(Canvas canvas)
 {
     Rect bounds = Bounds;
     int height = bounds.Height();
     paint.TextSize = height;
     Rect textBounds = new Rect();
     string textValue = icon.Character.ToString();
     paint.GetTextBounds(textValue, 0, 1, textBounds);
     int textHeight = textBounds.Height();
     float textBottom = bounds.Top + (height - textHeight) / 2f + textHeight - textBounds.Bottom;
     canvas.DrawText(textValue, bounds.ExactCenterX(), textBottom, paint);
 }
开发者ID:Mitch528,项目名称:IconifyXamarin,代码行数:12,代码来源:IconDrawable.cs

示例9: OnBoundsChange

		protected override void OnBoundsChange (Rect bounds)
		{
			base.OnBoundsChange (bounds);

			int height = bounds.Height();
			int width = bounds.Width();

			numRectanglesHorizontal = (int) Math.Ceiling((double)(width / mRectangleSize));
			numRectanglesVertical = (int) Math.Ceiling((double)height / mRectangleSize);

			generatePatternBitmap();
		}
开发者ID:jeedey93,项目名称:xamarin-android-samples,代码行数:12,代码来源:AlphaPatternDrawable.cs

示例10: OnBoundsChange

		protected override void OnBoundsChange (Rect bounds)
		{
			base.OnBoundsChange (bounds);
			mRect.Set (margin, margin, bounds.Width () - margin, bounds.Height () - margin);

			if (useGradientOverlay) {
				var colors = new int[] { 0, 0, 0x20000000 };
				var pos = new float[] { 0.0f, 0.7f, 1.0f };
				RadialGradient vignette = new RadialGradient (mRect.CenterX (),
				                                              mRect.CenterY () * 1.0f / 0.7f,
				                                              mRect.CenterX () * 1.3f,
				                                              colors,
				                                              pos, Shader.TileMode.Clamp);

				Matrix oval = new Matrix ();
				oval.SetScale (1.0f, 0.7f);
				vignette.SetLocalMatrix (oval);

				paint.SetShader (new ComposeShader (bitmapShader, vignette, PorterDuff.Mode.SrcOver));
			}
		}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:21,代码来源:VignetteDrawable.cs

示例11: OnCreateDialog

        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Begin building a new dialog.
            var builder = new AlertDialog.Builder(Activity);

            Rect displayRectangle = new Rect();
            Window window = Activity.Window;
            window.DecorView.GetWindowVisibleDisplayFrame(displayRectangle);

            var inflater = Activity.LayoutInflater;
            dateView = inflater.Inflate(Resource.Layout.DateRange, null);
            dateView.SetMinimumHeight((int)(displayRectangle.Width() * 0.9f));
            dateView.SetMinimumHeight((int)(displayRectangle.Height() * 0.9f));

            Button butOk = dateView.FindViewById<Button> (Resource.Id.butok);
            butOk.Click+= ButOk_Click;
            datePicker1 = DatePicker.NewInstance(SetDateDlg1);
            datePicker2 =  DatePicker.NewInstance(SetDateDlg2);
            EditText frd = dateView.FindViewById<EditText> (Resource.Id.trxdatefr);
            EditText tod = dateView.FindViewById<EditText> (Resource.Id.trxdateto);
            frd.Text = DateTime.Today.ToString ("dd-MM-yyyy");
            frd.Click += delegate(object sender, EventArgs e) {
                datePicker1.Show(FragmentManager, "datePicker");
            };
            tod.Text = DateTime.Today.ToString ("dd-MM-yyyy");
            tod.Click += delegate(object sender, EventArgs e) {
                datePicker2.Show(FragmentManager, "datePicker2");
            };

            builder.SetView (dateView);
            builder.SetPositiveButton ("CANCEL", HandlePositiveButtonClick);
            var dialog = builder.Create();
            //Now return the constructed dialog to the calling activity
            return dialog;
        }
开发者ID:mokth,项目名称:merpV2Production,代码行数:36,代码来源:DateRangeDialog.cs

示例12: OnDraw

            public override void OnDraw(Canvas canvas, Rect bounds)
            {
                if (Log.IsLoggable (Tag, LogPriority.Debug)) {
                    Log.Debug (Tag, "onDraw");
                }
                long now = Java.Lang.JavaSystem.CurrentTimeMillis ();
                time.Set (now);
                int milliseconds = (int)(now % 1000);

                int width = bounds.Width ();
                int height = bounds.Height ();

                // Draw the background, scaled to fit.
                if (backgroundScaledBitmap == null
                    || backgroundScaledBitmap.Width != width
                    || backgroundScaledBitmap.Height != height) {
                    backgroundScaledBitmap = Bitmap.CreateScaledBitmap (backgroundBitmap,
                        width, height, true /* filter */);
                }
                canvas.DrawColor (Color.Black);
                canvas.DrawBitmap (backgroundScaledBitmap, 0, 0, null);

                float centerX = width / 2.0f;
                float centerY = height / 2.0f;

                // Draw the ticks.
                float innerTickRadius = centerX - 10;
                float outerTickRadius = centerX;
                for (int tickIndex = 0; tickIndex < 12; tickIndex++) {
                    float tickRot = (float)(tickIndex * Math.PI * 2 / 12);
                    float innerX = (float)Math.Sin (tickRot) * innerTickRadius;
                    float innerY = (float)-Math.Cos (tickRot) * innerTickRadius;
                    float outerX = (float)Math.Sin (tickRot) * outerTickRadius;
                    float outerY = (float)-Math.Cos (tickRot) * outerTickRadius;
                    canvas.DrawLine (centerX + innerX, centerY + innerY,
                        centerX + outerX, centerY + outerY, tickPaint);
                }

                float seconds = time.Second + milliseconds / 1000f;
                float secRot = seconds / 30f * (float)Math.PI;
                int minutes = time.Minute;
                float minRot = minutes / 30f * (float)Math.PI;
                float hrRot = ((time.Hour + (minutes / 60f)) / 6f) * (float)Math.PI;

                float secLength = centerX - 20;
                float minLength = centerX - 40;
                float hrLength = centerX - 80;

                if (!IsInAmbientMode) {
                    float secX = (float)Math.Sin (secRot) * secLength;
                    float secY = (float)-Math.Cos (secRot) * secLength;
                    canvas.DrawLine (centerX, centerY, centerX + secX, centerY + secY, secondPaint);
                }

                float minX = (float)Math.Sin (minRot) * minLength;
                float minY = (float)-Math.Cos (minRot) * minLength;
                canvas.DrawLine (centerX, centerY, centerX + minX, centerY + minY, minutePaint);

                float hrX = (float)Math.Sin (hrRot) * hrLength;
                float hrY = (float)-Math.Cos (hrRot) * hrLength;
                canvas.DrawLine (centerX, centerY, centerX + hrX, centerY + hrY, hourPaint);

                if (IsVisible && !IsInAmbientMode) {
                    Invalidate ();
                }
            }
开发者ID:gandersson,项目名称:android-wear-xamarin-watchface,代码行数:66,代码来源:SweepWatchFaceService.cs

示例13: MeasureText

 public BasicRectangle MeasureText(string text, BasicRectangle rectangle, string fontFace, float fontSize)
 {
     var paint = new Paint
     {
         AntiAlias = true,
         TextSize = fontSize * Density
     };
     var rectText = new Rect();
     paint.GetTextBounds(text, 0, text.Length, rectText);
     return new BasicRectangle(rectText.Left, rectText.Top, rectText.Width(), rectText.Height());
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:11,代码来源:GraphicsContextWrapper.cs

示例14: DrawHands

			void DrawHands(Canvas canvas, Rect bounds)
			{
				var width = bounds.Width();
				var height = bounds.Height();
				var centerX = width / 2.0f;
				var centerY = height / 2.0f;

				calendar.TimeInMillis = Java.Lang.JavaSystem.CurrentTimeMillis();
				var hour = calendar.Get(CalendarField.Hour);
				var minute = calendar.Get(CalendarField.Minute);
				var second = calendar.Get(CalendarField.Second);

				var secRot = second / 30f * (float)Math.PI;
				var minutes = minute;
				var minRot = minutes / 30f * (float)Math.PI;
				var hrRot = ((hour + (minutes / 60f)) / 6f) * (float)Math.PI;

				var secLength = centerX - 20;
				var minLength = centerX - 40;
				var hrLength = centerX - 80;

				if (!IsInAmbientMode)
				{
					var secX = (float)Math.Sin(secRot) * secLength;
					var secY = (float)-Math.Cos(secRot) * secLength;
					canvas.DrawLine(centerX, centerY, centerX + secX, centerY + secY, secondPaint);
				}

				var minX = (float)Math.Sin(minRot) * minLength;
				var minY = (float)-Math.Cos(minRot) * minLength;
				canvas.DrawLine(centerX, centerY, centerX + minX, centerY + minY, minutePaint);

				var hrX = (float)Math.Sin(hrRot) * hrLength;
				var hrY = (float)-Math.Cos(hrRot) * hrLength;
				canvas.DrawLine(centerX, centerY, centerX + hrX, centerY + hrY, hourPaint);
			}
开发者ID:xamarin,项目名称:mini-hacks,代码行数:36,代码来源:XFitWatchfaceService.cs

示例15: DrawFace

			void DrawFace(Canvas canvas, Rect bounds)
			{
				var width = bounds.Width();
				var height = bounds.Height();

				// Draw the background, scaled to fit.
				if (backgroundScaledBitmap == null
					|| backgroundScaledBitmap.Width != width
					|| backgroundScaledBitmap.Height != height)
				{
					backgroundScaledBitmap = Bitmap.CreateScaledBitmap(backgroundBitmap,
						width, height, true /* filter */);
				}
				canvas.DrawColor(Color.Black);
				canvas.DrawBitmap(backgroundScaledBitmap, 0, 0, null);

				var centerX = width / 2.0f;
				var centerY = height / 2.0f;

				// Draw the ticks.
				var innerTickRadius = centerX - 10;
				var outerTickRadius = centerX;
				for (var tickIndex = 0; tickIndex < 12; tickIndex++)
				{
					var tickRot = (float)(tickIndex * Math.PI * 2 / 12);
					var innerX = (float)Math.Sin(tickRot) * innerTickRadius;
					var innerY = (float)-Math.Cos(tickRot) * innerTickRadius;
					var outerX = (float)Math.Sin(tickRot) * outerTickRadius;
					var outerY = (float)-Math.Cos(tickRot) * outerTickRadius;
					canvas.DrawLine(centerX + innerX, centerY + innerY,
						centerX + outerX, centerY + outerY, tickPaint);
				}
			}
开发者ID:xamarin,项目名称:mini-hacks,代码行数:33,代码来源:XFitWatchfaceService.cs


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