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


C# CGRect.Contains方法代码示例

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


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

示例1: RenderPointLabels

		public override void RenderPointLabels (TKChartSeries series, CGRect bounds, CGContext ctx)
		{
			if (labelLayer != null) {
				labelLayer.RemoveFromSuperLayer ();
			}

			for (int i = 0; i < series.Items.Length; i++) {
				TKChartData dataPoint = (TKChartData)series.Items [i];
				CGPoint location = base.LocationForDataPoint (dataPoint, series, bounds);
				if (!bounds.Contains(location)) {
					continue;
				}

				TKChartPointLabel label = this.LabelForDataPoint (dataPoint, series, (uint)i);
				CGRect labelRect;
				TKChartPointLabelStyle labelStyle = series.Style.PointLabelStyle;
				if (this.isSelectedPoint) {
					labelRect = new CGRect ((float)(location.X - 17.5), (float)(location.Y - 10 - 2.5 * Math.Abs (labelStyle.LabelOffset.Vertical)), 35, 30);
					if (labelRect.Y < bounds.Y) {
						this.labelLayer.IsOutsideBounds = true;
						labelRect.Y = (float)(location.Y + 10 + 2.5 * Math.Abs (labelStyle.LabelOffset.Vertical) - labelRect.Size.Height);
					} else {
						this.labelLayer.IsOutsideBounds = false;
					}

					this.labelLayer.Frame = labelRect;
					this.Render.AddSublayer (this.labelLayer);
					this.labelLayer.SetNeedsDisplay ();
				} else {
					CGSize labelSize = label.SizeThatFits (bounds.Size);
					labelRect = new CGRect ((float)(location.X - labelSize.Width / 2.0 + labelStyle.LabelOffset.Horizontal),
						(float)(location.Y - labelSize.Height / 2.0 + labelStyle.LabelOffset.Vertical), labelSize.Width, labelSize.Height);

					if (labelRect.Y < this.Render.Bounds.Y) {
						labelRect.Y = (float)(location.Y - labelSize.Height / 2.0 + Math.Abs (labelStyle.LabelOffset.Vertical));
					}

					label.DrawInContext (ctx, labelRect, new TKChartVisualPoint(new PointF(0, 0)), UIColor.White);
				}
			}
		}
开发者ID:tremors,项目名称:ios-sdk,代码行数:41,代码来源:MyPointLabelRender.cs

示例2: TappedTickerView

        public void TappedTickerView(UITapGestureRecognizer recog)
        {
            if (tapHandler==null)
                return;

            CGPoint point = recog.LocationInView(this);
            point.X = point.X + VisibleContentRect.X;
            UIView tappedView = null;
            Console.WriteLine("point is " + point.ToString());
            foreach (UIView v in scrollView.Subviews)
            {
                if (!(v is UIImageView))
                {
                    Console.WriteLine("v with tag {0} and frame {1}",v.Tag,v.Frame.ToString());
                    tempFrame = v.Frame;
                    tempFrame.Height = Bounds.Height;
                    if (tempFrame.Contains(point))
                    {
                        tappedView = v;
                        break;
                    }
                }
            }

            if (tapHandler!=null && tappedView!=null)
                tapHandler(tappedView);
        }
开发者ID:skela,项目名称:DMScrollingTicker,代码行数:27,代码来源:TickerView.cs

示例3: CellTapped

                void CellTapped(UITapGestureRecognizer tapRecognizer)
                {
                    var point = tapRecognizer.LocationInView (this);
                    var totalWidth = Columns * 75 + (Columns - 1) * 4;
                    var startX = (Bounds.Size.Width - totalWidth) / 2;

                    var frame = new CGRect (startX, 2, 75, 75);
                    for (int i = 0; i < RowAssets.Count; ++i) {
                        if (frame.Contains (point)) {
                            ELCAsset asset = RowAssets [i];
                            asset.Selected = !asset.Selected;
                            var overlayView = OverlayViewArray [i];
                            overlayView.Hidden = !asset.Selected;
                            break;
                        }
                        var x = frame.X + frame.Width + 4;
                        frame = new CGRect (x, frame.Y, frame.Width, frame.Height);
                    }
                }
开发者ID:rzee7,项目名称:XamarinSharpPlus,代码行数:19,代码来源:ELCImagePickerViewController.cs

示例4: ResizeRegionOfInterestWithGestureRecognizer

		void ResizeRegionOfInterestWithGestureRecognizer (UIPanGestureRecognizer pan)
		{
			var touchLocation = pan.LocationInView (pan.View);
			var oldRegionOfInterest = RegionOfInterest;

			switch (pan.State) {
			case UIGestureRecognizerState.Began:
				// When the gesture begins, save the corner that is closes to
				// the resize region of interest gesture recognizer's touch location.
				currentControlCorner = CornerOfRect (oldRegionOfInterest, touchLocation);
				break;


			case UIGestureRecognizerState.Changed:
				var newRegionOfInterest = oldRegionOfInterest;

				switch (currentControlCorner) {
				case ControlCorner.None:
					// Update the new region of interest with the gesture recognizer's translation.
					var translation = pan.TranslationInView (pan.View);
					// Move the region of interest with the gesture recognizer's translation.
					if (RegionOfInterest.Contains (touchLocation)) {
						newRegionOfInterest.X += translation.X;
						newRegionOfInterest.Y += translation.Y;
					}

					// If the touch location goes outside the preview layer,
					// we will only translate the region of interest in the
					// plane that is not out of bounds.
					var normalizedRect = new CGRect (0, 0, 1, 1);
					if (!normalizedRect.Contains (VideoPreviewLayer.PointForCaptureDevicePointOfInterest (touchLocation))) {
						if (touchLocation.X < RegionOfInterest.GetMinX () || touchLocation.X > RegionOfInterest.GetMaxX ()) {
							newRegionOfInterest.Y += translation.Y;
						} else if (touchLocation.Y < RegionOfInterest.GetMinY () || touchLocation.Y > RegionOfInterest.GetMaxY ()) {
							newRegionOfInterest.X += translation.X;
						}
					}

					// Set the translation to be zero so that the new gesture
					// recognizer's translation is in respect to the region of
					// interest's new position.
					pan.SetTranslation (CGPoint.Empty, pan.View);
					break;

				case ControlCorner.TopLeft:
					newRegionOfInterest = new CGRect (touchLocation.X, touchLocation.Y,
													 oldRegionOfInterest.Width + oldRegionOfInterest.X - touchLocation.X,
													 oldRegionOfInterest.Height + oldRegionOfInterest.Y - touchLocation.Y);
					break;

				case ControlCorner.TopRight:
					newRegionOfInterest = new CGRect (newRegionOfInterest.X,
												 touchLocation.Y,
												 touchLocation.X - newRegionOfInterest.X,
												 oldRegionOfInterest.Height + newRegionOfInterest.Y - touchLocation.Y);
					break;


				case ControlCorner.BottomLeft:
					newRegionOfInterest = new CGRect (touchLocation.X, oldRegionOfInterest.Y,
												 oldRegionOfInterest.Width + oldRegionOfInterest.X - touchLocation.X,
												 touchLocation.Y - oldRegionOfInterest.Y);
					break;

				case ControlCorner.BottomRight:
					newRegionOfInterest = new CGRect (oldRegionOfInterest.X, oldRegionOfInterest.Y,
												 touchLocation.X - oldRegionOfInterest.X,
												 touchLocation.Y - oldRegionOfInterest.Y);
					break;
				}

				// Update the region of intresest with a valid CGRect.
				SetRegionOfInterestWithProposedRegionOfInterest (newRegionOfInterest);
				break;

			case UIGestureRecognizerState.Ended:
				RegionOfInterestDidChange?.Invoke (this, EventArgs.Empty);

				// Reset the current corner reference to none now that the resize.
				// gesture recognizer has ended.
				currentControlCorner = ControlCorner.None;
				break;

			default:
				return;
			}
		}
开发者ID:xamarin,项目名称:monotouch-samples,代码行数:87,代码来源:PreviewView.cs

示例5: CanStartSliding

		/// <summary>
		/// Determines whether this instance can start sliding given the touch position and the 
		/// current location/size of the top view. 
		/// Note that touchPosition is in Screen coordinate.
		/// </summary>
		/// <returns>true</returns>
		/// <c>false</c>
		/// <param name="touchPosition">Touch position.</param>
		/// <param name="topViewCurrentFrame">Top view's current frame.</param>
		public override bool CanStartSliding(CGPoint touchPosition, CGRect topViewCurrentFrame)
		{
			// touchPosition is in Screen coordinate.

			float offset = 0;
			touchPosition.Y += offset;

			if (!IsVisible)
			{
				return (touchPosition.Y >= (View.Bounds.Height - EdgeTolerance) && touchPosition.Y <= View.Bounds.Height);
			}
			else
			{
				return topViewCurrentFrame.Contains (touchPosition);
			}
		}
开发者ID:caseyjb,项目名称:SlidingPanels.Touch,代码行数:25,代码来源:BottomPanelContainer.cs

示例6: CanStartSliding

		/// <summary>
		/// Determines whether this instance can start sliding given the touch position and the 
		/// current location/size of the top view. 
		/// Note that touchPosition is in Screen coordinate.
		/// </summary>
		/// <returns>true</returns>
		/// <c>false</c>
		/// <param name="touchPosition">Touch position.</param>
		/// <param name="topViewCurrentFrame">Top view's current frame.</param>
		public override bool CanStartSliding(CGPoint touchPosition, CGRect topViewCurrentFrame)
		{
			if (!IsVisible)
			{
				return (touchPosition.X >= View.Bounds.Size.Width - EdgeTolerance && touchPosition.X <= View.Bounds.Size.Width);
			}
			else
			{
				return topViewCurrentFrame.Contains (touchPosition);
			}
		}
开发者ID:RocketPop,项目名称:SlidingPanels.Touch,代码行数:20,代码来源:RightPanelContainer.cs

示例7: TouchIsInRect

		bool TouchIsInRect (UITouch touch, CGRect rect)
		{
			rect = CGAffineTransform.CGRectApplyAffineTransform (rect, CGAffineTransform.MakeScale (Bounds.Width, Bounds.Height));
			return rect.Contains (touch.LocationInView (this));
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:5,代码来源:GameView.cs

示例8: CanStartSliding

		/// <summary>
		/// Determines whether this instance can start sliding given the touch position and the 
		/// current location/size of the top view. 
		/// Note that touchPosition is in Screen coordinate.
		/// </summary>
		/// <returns>true</returns>
		/// <c>false</c>
		/// <param name="touchPosition">Touch position.</param>
		/// <param name="topViewCurrentFrame">Top view's current frame.</param>
		public override bool CanStartSliding(CGPoint touchPosition, CGRect topViewCurrentFrame)
		{
			if (!IsVisible)
			{
				return (touchPosition.X >= 0.0f && touchPosition.X <= EdgeTolerance);
			}
			else
			{
				return topViewCurrentFrame.Contains (touchPosition);
			}
		}
开发者ID:RocketPop,项目名称:SlidingPanels.Touch,代码行数:20,代码来源:LeftPanelContainer.cs


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