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


C# UITapGestureRecognizer.LocationInView方法代码示例

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


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

示例1: tapGame

		void tapGame (UITapGestureRecognizer gestureRecognizer)
		{
			if (gestureRecognizer.State == UIGestureRecognizerState.Recognized &&
				DidSelect != null) {
				CGPoint point = gestureRecognizer.LocationInView (this);
				CGRect bounds = Bounds;

				CGPoint normalizedPoint = point;
				normalizedPoint.X -= bounds.X + bounds.Size.Width / 2;
				normalizedPoint.X *= 3 / bounds.Size.Width;
				normalizedPoint.X = (float)Math.Round (normalizedPoint.X);
				normalizedPoint.X = (float)Math.Max (normalizedPoint.X, -1);
				normalizedPoint.X = (float)Math.Min (normalizedPoint.X, 1);
				TTTMoveXPosition xPosition = (TTTMoveXPosition)(int)normalizedPoint.X;

				normalizedPoint.Y -= bounds.Y + bounds.Size.Height / 2;
				normalizedPoint.Y *= 3 / bounds.Size.Height;
				normalizedPoint.Y = (float)Math.Round (normalizedPoint.Y);
				normalizedPoint.Y = (float)Math.Max (normalizedPoint.Y, -1);
				normalizedPoint.Y = (float)Math.Min (normalizedPoint.Y, 1);
				TTTMoveYPosition yPosition = (TTTMoveYPosition)(int)normalizedPoint.Y;

				if (CanSelect == null || CanSelect (this, xPosition, yPosition))
					DidSelect (this, xPosition, yPosition);
			}
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:26,代码来源:TTTGameView.cs

示例2: OnTap

        private void OnTap(UITapGestureRecognizer recognizer)
        {
            var cgPoint = recognizer.LocationInView(Control);

            var location = ((MKMapView)Control).ConvertPoint(cgPoint, Control);

            ((MyBaseMap)Element).OnTap(new Position(location.Latitude, location.Longitude));
        }
开发者ID:HeikkiDev,项目名称:Mapas_XamarinForms,代码行数:8,代码来源:MyMapRenderer.cs

示例3: HandleSwipe

		public void HandleSwipe(UITapGestureRecognizer recognizer)
		{
			// get the point of the swipe action
			PointF point = recognizer.LocationInView(this);
		 
			// TODO: do something with the swipe
			if (OnTapped != null)
				OnTapped(point);
		}
开发者ID:21Off,项目名称:21Off,代码行数:9,代码来源:Map.cs

示例4: OnTap

 private void OnTap(UITapGestureRecognizer e)
 {
     var view = e.View;
     var location = e.LocationInView(view);
     var subview = view.HitTest(location, null);
     if (subview == view)
     {
         _element.SendBackgroundClick();
     }
 }
开发者ID:rotorgames,项目名称:Rg.Plugins.Popup,代码行数:10,代码来源:PopupPageRenderer.cs

示例5: HandleSwiperTapGesture

		public void HandleSwiperTapGesture (UITapGestureRecognizer press)
		{
			if (press.State == UIGestureRecognizerState.Recognized) {

				// Where did the user tap?
				CGPoint point = press.LocationInView (press.View);

				// Get the NSIndexPath for that cell
				NSIndexPath indexPath = TableView.IndexPathForRowAtPoint (point);

				if (indexPath == null) {
					return;
				}
					
				// Get the UITableViewCell the user tapped
				var cell = TableView.CellAt (indexPath) as SwiperTableViewCell;

				// If the cell is 'open' then check if the user is tapping the right or left button, otherwise close the drawer
				if (cell != null && cell.Open) {

					if (cell.LeftOpen && point.X < cell.LeftButtonOffset) { // Left Button

						var leftTitle = "Left Button";
						var leftMessage = SwiperStrings[indexPath.Row];

						PresentAlert (leftTitle, leftMessage);

						return;
					}

					if (cell.RightOpen && point.X > cell.RightButtonOffset) { // Right Button

						var rightTitle = "Right Button";
						var rightMessage = SwiperStrings[indexPath.Row];

						PresentAlert (rightTitle, rightMessage);

						return;
					} 


					cell.CloseSlideButtons ();

					return;
				}

				// Business as usual
				RowSelected (TableView, indexPath);	

				return;
			}
		}
开发者ID:StarCoder1,项目名称:Xamarin-iOS-SwipeButtonCells,代码行数:52,代码来源:SwiperTableViewController.cs

示例6: ColorTap

		void ColorTap(UITapGestureRecognizer tapGestureRecognizer)
		{
			if (tapGestureRecognizer.State != UIGestureRecognizerState.Ended)
				return;

			CGPoint tapLocation = tapGestureRecognizer.LocationInView (ContentView);
			UIView view = ContentView.HitTest (tapLocation, null);

			// If the user tapped on a color (identified by its tag), notify the delegate.
			ListColor color = (ListColor)(int)view.Tag;
			SelectedColor = color;
			ViewController.OnListColorCellDidChangeSelectedColor (SelectedColor);
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:13,代码来源:ListColorCell.cs

示例7: HandleTapGesture

		void HandleTapGesture (UITapGestureRecognizer sender)
		{
			if (sender.State != UIGestureRecognizerState.Ended)
				return;

			CGPoint initialPinchPoint = sender.LocationInView (CollectionView);
			NSIndexPath tappedCellPath = CollectionView.IndexPathForItemAtPoint (initialPinchPoint);

			if (tappedCellPath != null) {
				cellCount--;

				CollectionView.PerformBatchUpdates (delegate {
						CollectionView.DeleteItems (new NSIndexPath [] { tappedCellPath });
					}, null);
			} else {
				cellCount++;

				CollectionView.PerformBatchUpdates (delegate {
						CollectionView.InsertItems (new NSIndexPath[] {
								NSIndexPath.FromItemSection (0, 0)
							});
					}, null);
			}
		}
开发者ID:Rajneesh360Logica,项目名称:monotouch-samples,代码行数:24,代码来源:ViewController.cs

示例8: SingleTap

        /// <summary>
        /// Called when the map was single tapped at a certain location.
        /// </summary>
        /// <param name="tap">Tap.</param>
        private void SingleTap(UITapGestureRecognizer tap)
        {
            //RectangleF2D rect = _rect;
            RectangleF rect = this.Frame;
            if (rect.Width > 0 && rect.Height > 0)
            {
                this.StopCurrentAnimation();

                if (this.MapTapEvent != null)
                {
                    View2D view = this.CreateView(rect);
                    PointF location = tap.LocationInView(this);
                    double[] sceneCoordinates = view.FromViewPort(rect.Width, rect.Height, location.X, location.Y);
                    this.MapTapEvent(this.Map.Projection.ToGeoCoordinates(sceneCoordinates[0], sceneCoordinates[1]));
                }
            }
        }
开发者ID:nubix-biz,项目名称:OsmSharp,代码行数:21,代码来源:MapView.cs

示例9: ImageDoubleTapped

        // Gesture Recognizer Methods
        private void ImageDoubleTapped(UITapGestureRecognizer sender)
        {
            if (Flags.ScrollViewIsAnimatingAZoom)
                return;

            PointF rawLocation = sender.LocationInView (sender.View);
            PointF point = ScrollView.ConvertPointFromView (rawLocation, sender.View);
            RectangleF targetZoomRect;
            UIEdgeInsets targetInsets;

            if (ScrollView.ZoomScale == 1.0f) {
                ScrollView.AccessibilityHint = AccessibilityHintZoomedIn ();
                float zoomWidth = View.Bounds.Size.Width / JTSImageViewController.JTSImageViewController_TargetZoomForDoubleTap;
                float zoomHeight = View.Bounds.Size.Height / JTSImageViewController.JTSImageViewController_TargetZoomForDoubleTap;
                targetZoomRect = new RectangleF (point.X - (zoomWidth / 2.0f), point.Y - (zoomHeight / 2.0f), zoomWidth, zoomHeight);
                targetInsets = ContentInsetForScrollView(JTSImageViewController.JTSImageViewController_TargetZoomForDoubleTap);
            } else {
                ScrollView.AccessibilityHint = AccessibilityHintZoomedOut ();
                float zoomWidth = View.Bounds.Size.Width * ScrollView.ZoomScale;
                float zoomHeight = View.Bounds.Size.Height * ScrollView.ZoomScale;
                targetZoomRect = new RectangleF (point.X - (zoomWidth / 2.0f), point.Y - (zoomHeight / 2.0f), zoomWidth, zoomHeight);
                targetInsets = ContentInsetForScrollView (1.0f);
            }

            View.UserInteractionEnabled = false;
            Flags.ScrollViewIsAnimatingAZoom = true;
            ScrollView.ContentInset = targetInsets;
            ScrollView.ZoomToRect (targetZoomRect, true);

            InvokeInBackground(() => {
                Thread.Sleep((int)(0.35 * 1000));

                InvokeOnMainThread(() => {
                    this.View.UserInteractionEnabled = true;
                    Flags.ScrollViewIsAnimatingAZoom = false;
                });
            });
        }
开发者ID:Amplify-Social,项目名称:JTSImageViewControllerCSharp,代码行数:39,代码来源:JTSImageViewController.cs

示例10: tap

        void tap(UITapGestureRecognizer gr)
        {
            CGPoint point = gr.LocationInView(this);
            this.selectedLine = lineAtPoint(point);

            // If we just tapped, remove all lines in process
            // so that a tap does not result in a new line
            linesInProcess.Clear();

            if (selectedLine != null) {
                this.BecomeFirstResponder();

                // Grab the menu controller
                UIMenuController menu = UIMenuController.SharedMenuController;

                // Create a new "Delete" UIMenuItem
                UIMenuItem deleteItem = new UIMenuItem("Delete", new Selector("deleteLine:"));
                menu.MenuItems = new UIMenuItem[] {deleteItem};

                // Tell the menu item where it should come from and show it
                menu.SetTargetRect(new CGRect(point.X, point.Y, 2, 2), this);
                menu.SetMenuVisible(true, true);

                UIGestureRecognizer[] grs = this.GestureRecognizers;
                foreach (UIGestureRecognizer gestRec in grs) {
                    if (gestRec.GetType() != new UITapGestureRecognizer().GetType()) {
                        gestRec.Enabled = false;
                    }
                }
            } else {
                // Hide the menu if no line is selected
                UIMenuController menu = UIMenuController.SharedMenuController;
                menu.SetMenuVisible(false, true);

                UIGestureRecognizer[] grs = this.GestureRecognizers;
                foreach (UIGestureRecognizer gestRec in grs) {
                    if (gestRec.GetType() != new UITapGestureRecognizer().GetType()) {
                        gestRec.Enabled = true;
                    }
                }
            }
            this.SetNeedsDisplay();
        }
开发者ID:yingfangdu,项目名称:BNR,代码行数:43,代码来源:TouchDrawView.cs

示例11: ViewDidLoad

		public override void ViewDidLoad ()
		{
			scannerView = new ZXingScannerView(new RectangleF(0, 0, this.View.Frame.Width, this.View.Frame.Height));
			scannerView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
			
			this.View.AddSubview(scannerView);
			this.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
			
			if (Scanner.UseCustomOverlay && Scanner.CustomOverlay != null)
				overlayView = Scanner.CustomOverlay;
			else
				overlayView = new ZXingDefaultOverlayView(this.Scanner, new RectangleF(0, 0, this.View.Frame.Width, this.View.Frame.Height),
				                                          () => Scanner.Cancel(), () => Scanner.ToggleTorch());
			
			if (overlayView != null)
			{
				UITapGestureRecognizer tapGestureRecognizer = new UITapGestureRecognizer ();

				tapGestureRecognizer.AddTarget (() => {

					var pt = tapGestureRecognizer.LocationInView(overlayView);

					//scannerView.Focus(pt);

					Console.WriteLine("OVERLAY TOUCH: " + pt.X + ", " + pt.Y);

				});
				tapGestureRecognizer.CancelsTouchesInView = false;
				tapGestureRecognizer.NumberOfTapsRequired = 1;
				tapGestureRecognizer.NumberOfTouchesRequired = 1;

				overlayView.AddGestureRecognizer (tapGestureRecognizer);

				overlayView.Frame = new RectangleF(0, 0, this.View.Frame.Width, this.View.Frame.Height);
				overlayView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
				
				this.View.AddSubview(overlayView);
				this.View.BringSubviewToFront(overlayView);
			}
		}
开发者ID:rzaitov,项目名称:ZXing.Net.Mobile,代码行数:40,代码来源:ZXingScannerViewController.cs

示例12: SingleTap

        /// <summary>
        /// Called when the map was single tapped at a certain location.
        /// </summary>
        /// <param name="tap">Tap.</param>
        private void SingleTap(UITapGestureRecognizer tap)
        {
            CGRect rect = this.Frame;
            if (rect.Width > 0 && rect.Height > 0 && this.Map != null)
            {
                this.StopCurrentAnimation();

                if (this.MapTapEvent != null)
                {
                    View2D view = this.CreateView(rect);
                    CGPoint location = tap.LocationInView(this);
                    double[] sceneCoordinates = view.FromViewPort(rect.Width, rect.Height, location.X, location.Y);
                    this.MapTapEvent(this.Map.Projection.ToGeoCoordinates(sceneCoordinates[0], sceneCoordinates[1]));
                }

                // notify controls map was tapped.
                this.NotifyMapTapToControls();
            }
        }
开发者ID:UnifyKit,项目名称:OsmSharp,代码行数:23,代码来源:MapView.cs

示例13: DidSingleTap

 private void DidSingleTap(UITapGestureRecognizer recognizer)
 {
     if (scrollView.ZoomScale == scrollView.MinimumZoomScale)
     {
         HideDoneButton();    
     }
     else if (scrollView.ZoomScale == scrollView.MaximumZoomScale)
     {
         CGPoint pointInView = recognizer.LocationInView(_imageView);
         ZoomInZoomOut(pointInView);
     }
 }
开发者ID:anhvule,项目名称:MHFacebookImageViewer.Xamarin,代码行数:12,代码来源:ImageViewer.cs

示例14: HandleTap

        private void HandleTap(UITapGestureRecognizer gesture)
        {
            var locationInCanvas = gesture.LocationInView(_canvasView);
            var touchedElement = ElementUnderPoint(locationInCanvas);
            bool didTouchElement = touchedElement != null;

            ClearSelection();

            if (didTouchElement)
            {
                SetElementSelected(touchedElement, selected: true);
            }
        }
开发者ID:TheRealAdamKemp,项目名称:GestureRecognizerPresentation,代码行数:13,代码来源:GestureViewController.cs

示例15: TapGestureRecognizer

 public void TapGestureRecognizer(UITapGestureRecognizer sender)
 {
     var enabledGestures = TouchPanel.EnabledGestures;
     if ((enabledGestures & GestureType.Tap) != 0)
     {
         TouchPanel.GestureList.Enqueue(new GestureSample(GestureType.Tap, new TimeSpan(_nowUpdate.Ticks), new Vector2 (sender.LocationInView (sender.View)), new Vector2 (sender.LocationInView (sender.View)), new Vector2(0,0), new Vector2(0,0)));
     }
 }
开发者ID:Clancey,项目名称:MonoGame,代码行数:8,代码来源:IOSGameWindow.cs


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