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


C# Rect.CenterX方法代码示例

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


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

示例1: CalculateXPos

		private int CalculateXPos(Rect anchorRect)
		{
			int xPos;
			if (anchorRect.Left + RootSize.X > _displaySize.X)
			{
				xPos = _displaySize.X - RootSize.X;
			}

			else if (anchorRect.Left - (RootSize.X / 2) < 0)
			{
				xPos = anchorRect.Left;
			}
			else
			{
				xPos = anchorRect.CenterX() - (RootSize.X / 2);
			}
			return xPos;
		}
开发者ID:mdanz92,项目名称:teco.SkillStore,代码行数:18,代码来源:HelpPopUp.cs

示例2: OnDraw

 protected override void OnDraw(Canvas canvas)
 {
     base.OnDraw (canvas);
                 //create an instance of class Paint, set color and font size
                 var textPaint = new Paint {
                         AntiAlias = true,
                         Color = _textColor,
                         TextSize = _textSize };
                 //In order to show text in a middle, we need to know its size
                 var bounds = new Rect ();
                 textPaint.GetTextBounds (_text, 0, _text.Length, bounds);
                 //Now we store font size in bounds variable and can calculate it's position
                 var x = (Width / 2) - bounds.CenterX ();
                 var y = (Height / 2) - bounds.CenterY ();
                 //drawing text with appropriate color and size in the center
                 canvas.DrawText (_text, x, y, textPaint);
 }
开发者ID:shuoguo,项目名称:cross-copy,代码行数:17,代码来源:ProgressBarX.cs

示例3: getRectForArrowDown

		/**
	 * Calculates the rect for showing the view with Arrow Down
	 * @param originRect The origin rect
	 * @return The calculated rect to show the view
	 */
		private Rect getRectForArrowDown (Rect originRect)
		{

			//Get available space		
			int xAvailable = popoverLayoutRect.Width ();
			if (xAvailable < 0)
				xAvailable = 0;
			int yAvailable = (originRect.Top - popoverLayoutRect.Top);
			if (yAvailable < 0)
				yAvailable = 0;

			//Get final width and height
			int finalX = xAvailable;
			if ((realContentSize.X > 0) && (realContentSize.X < finalX))
				finalX = realContentSize.X;
			int finalY = yAvailable;
			if ((realContentSize.Y > 0) && (realContentSize.Y < finalY))
				finalY = realContentSize.Y;

			//Get final origin X and Y
			int originX = (originRect.CenterX () - popoverLayoutRect.Left) - (finalX / 2);
			if (originX < 0)
				originX = 0;
			else if (originX + finalX > popoverLayoutRect.Width ())
				originX = popoverLayoutRect.Width () - finalX;
			int originY = (originRect.Top - popoverLayoutRect.Top) - finalY;

			//Create rect
			Rect finalRect = new Rect (originX, originY, originX + finalX, originY + finalY);
			//And return
			return finalRect;

		}
开发者ID:jeedey93,项目名称:xamarin-android-samples,代码行数:38,代码来源:PopoverView.cs

示例4: Draw

        internal void Draw(Canvas canvas, bool isRound)
        {
            if (Hidden)
            {
                return;
            }

            canvas.Save();
            var resizerPaint = new Paint { Color = new Color(255, 255, 255, 200) };

            //if (!Focused)
            //{
            //    outlinePaint.Color = Color.White;
            //    canvas.DrawRect(DrawRect, outlinePaint);
            //    //canvas.DrawCircle(DrawRect.CenterX(), DrawRect.CenterY(), DrawRect.Width(), resizerPaint);
            //}
            //else
            //{
            Rect viewDrawingRect = new Rect();
            context.GetDrawingRect(viewDrawingRect);

            outlinePaint.Color = Color.White;// new Color(0XFF, 0xFF, 0x8A, 0x00);
            focusPaint.Color = new Color(50, 50, 50, 125);

            Path path = new Path();

            if (isRound)
            {
                path.AddCircle(DrawRect.CenterX(), DrawRect.CenterY(), DrawRect.Width() / 2, Path.Direction.Cw);
                canvas.ClipPath(path, Region.Op.Difference);
                canvas.DrawCircle(viewDrawingRect.CenterX(), viewDrawingRect.CenterY(), viewDrawingRect.Width(), focusPaint);
            }
            else
            {
                path.AddRect(new RectF(DrawRect), Path.Direction.Cw);
                canvas.ClipPath(path, Region.Op.Difference);
                canvas.DrawRect(viewDrawingRect, focusPaint);

            }

            //canvas.ClipPath(path, Region.Op.Difference);

            //if (isRound)
            //    canvas.DrawCircle(viewDrawingRect.CenterX(), viewDrawingRect.CenterY(), viewDrawingRect.Width(), focusPaint);
            //else
            //    canvas.DrawRect(viewDrawingRect, focusPaint);

            canvas.Restore();
            canvas.DrawPath(path, outlinePaint);

            var resizerTriangle = new Path();
            var resizerOffset = 4;
            var triangleSize = resizerSize + resizerOffset;
            resizerTriangle.MoveTo(DrawRect.Right - resizerOffset, DrawRect.Bottom - triangleSize);
            resizerTriangle.LineTo(DrawRect.Right - resizerOffset, DrawRect.Bottom - resizerOffset);
            resizerTriangle.LineTo(DrawRect.Right - triangleSize, DrawRect.Bottom - resizerOffset);
            resizerPaint.SetStyle(Paint.Style.Fill);
            canvas.DrawPath(resizerTriangle, resizerPaint);

            if (isRound)
            {
                // Draw the rectangle around the round cropper                
                var roundCropperRectangle = new Path();
                roundCropperRectangle.MoveTo(DrawRect.Left, DrawRect.Top);
                roundCropperRectangle.LineTo(DrawRect.Right, DrawRect.Top);
                roundCropperRectangle.LineTo(DrawRect.Right, DrawRect.Bottom);
                roundCropperRectangle.LineTo(DrawRect.Left, DrawRect.Bottom);
                roundCropperRectangle.LineTo(DrawRect.Left, DrawRect.Top);

                resizerPaint.SetStyle(Paint.Style.Stroke);
                canvas.DrawPath(roundCropperRectangle, resizerPaint);
            }
        }
开发者ID:nielscup,项目名称:ImageCrop,代码行数:73,代码来源:HighlightView.cs

示例5: addArrow

		private void addArrow (Rect originRect, int arrowDirection)
		{
			//Add arrow drawable
			ImageView arrowImageView = new ImageView (Application.Context);
			Drawable arrowDrawable = null;
			int xPos = 0;
			int arrowWidth = 0;
			int yPos = 0;
			int arrowHeight = 0;
			//Get correct drawable, and get Width, Height, Xpos and yPos depending on the selected arrow direction
			if (arrowDirection == PopoverView.PopoverArrowDirectionUp) {
				arrowDrawable = Resources.GetDrawable (popoverArrowUpDrawable);
				arrowWidth = arrowDrawable.IntrinsicWidth;
				arrowHeight = arrowDrawable.IntrinsicHeight;
				xPos = originRect.CenterX () - (arrowWidth / 2) - popoverLayoutRect.Left;
				yPos = originRect.Bottom - popoverLayoutRect.Top;
			} else if (arrowDirection == PopoverView.PopoverArrowDirectionDown) {
				arrowDrawable = Resources.GetDrawable (popoverArrowDownDrawable);
				arrowWidth = arrowDrawable.IntrinsicWidth;
				arrowHeight = arrowDrawable.IntrinsicHeight;
				xPos = originRect.CenterX () - (arrowWidth / 2) - popoverLayoutRect.Left;
				yPos = originRect.Top - arrowHeight - popoverLayoutRect.Top;
			} else if (arrowDirection == PopoverView.PopoverArrowDirectionLeft) {
				arrowDrawable = Resources.GetDrawable (popoverArrowLeftDrawable);
				arrowWidth = arrowDrawable.IntrinsicWidth;
				arrowHeight = arrowDrawable.IntrinsicHeight;
				xPos = originRect.Right - popoverLayoutRect.Left;
				yPos = originRect.CenterY () - (arrowHeight / 2) - popoverLayoutRect.Top;
			} else if (arrowDirection == PopoverView.PopoverArrowDirectionRight) {
				arrowDrawable = Resources.GetDrawable (popoverArrowRightDrawable);
				arrowWidth = arrowDrawable.IntrinsicWidth;
				arrowHeight = arrowDrawable.IntrinsicHeight;
				xPos = originRect.Left - arrowWidth - popoverLayoutRect.Left;
				yPos = originRect.CenterY () - (arrowHeight / 2) - popoverLayoutRect.Top;
			}
			//Set drawable
			arrowImageView.SetImageDrawable (arrowDrawable);
			//Init layout params
			LayoutParams arrowParams = new LayoutParams (arrowWidth, arrowHeight);
			arrowParams.LeftMargin = xPos;
			arrowParams.TopMargin = yPos;
			//add view :)
			AddView (arrowImageView, arrowParams);
		}
开发者ID:jeedey93,项目名称:xamarin-android-samples,代码行数:44,代码来源:PopoverView.cs


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