Пример #1
0
		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);
			}
		}
Пример #2
0
        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));
        }
Пример #3
0
Файл: Map.cs Проект: 21Off/21Off
		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);
		}
 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();
     }
 }
		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;
			}
		}
Пример #6
0
		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);
		}
Пример #7
0
 public void Tap(UITapGestureRecognizer tap)
 {
     if (!IsFirstResponder)
     {
         // Inform controller that we're about to enter editing mode
         if (ViewWillEdit != null)
         {
             ViewWillEdit(this);
         }
         // Flag that underlying SimpleCoreTextView is now in edit mode
         textView.IsEditing = true;
         // Become first responder state (which shows software keyboard, if applicable)
         BecomeFirstResponder();
     }
     else
     {
         // Already in editing mode, set insertion point (via selectedTextRange)
         // Find and update insertion point in underlying SimpleCoreTextView
         int index = textView.ClosestIndex(tap.LocationInView(textView));
         textView.MarkedTextRange   = new NSRange(NSRange.NotFound, 0);
         textView.SelectedTextRange = new NSRange(index, 0);
     }
 }
Пример #8
0
        private UITapGestureRecognizer CreateTapRecognizer(Func <Command <Point> > getCommand)
        {
            return(new UITapGestureRecognizer(() => {
                var handler = getCommand();
                if (handler != null)
                {
                    var control = Control ?? Container;
                    var tapPoint = tapDetector.LocationInView(control);
                    float relativeX = (float)(tapPoint.X / control.Bounds.Size.Width);
                    float relativeY = (float)(tapPoint.Y / control.Bounds.Size.Height);
                    var point = new Point(relativeX, relativeY);

                    if (handler.CanExecute(point) == true)
                    {
                        handler.Execute(point);
                    }
                }
            })
            {
                Enabled = false,
                ShouldRecognizeSimultaneously = (recognizer, gestureRecognizer) => true,
            });
        }
Пример #9
0
        private void tapAction()
        {
            if (punchTextView.IsFirstResponder)
            {
                punchTextView.ResignFirstResponder();
            }

            else
            {
                CGRect  deletionAreaRect = new CGRect(0, this.Frame.Height / 2 - 25, 44, 50);
                CGPoint point            = tap.LocationInView(this);

                if (deletionAreaRect.Contains(point))
                {
                    int         buttonClicked = -1;
                    UIAlertView alert1        = new UIAlertView(@"Alert", @"Are you sure you want to delete?", null, NSBundle.MainBundle.LocalizedString("Cancel", "Cancel"), NSBundle.MainBundle.LocalizedString("OK", "OK"));
                    alert1.Show();

                    alert1.Clicked += (sender, buttonArgs) => {
                        buttonClicked = (int)buttonArgs.ButtonIndex;
                    };

                    //Wait for a button press.
                    while (buttonClicked == -1)
                    {
                        NSRunLoop.Current.RunUntil(NSDate.FromTimeIntervalSinceNow(0.5));
                    }

                    if (buttonClicked == 1)
                    {
                        this.punchItems.Remove(this.punch);
                        this.optionsTableView.ReloadData();
                        IsPunchValueChanged = true;
                    }
                }
            }
        }
Пример #10
0
        private void Tap(UITapGestureRecognizer tap)
        {
            if (this.IsIndicator)
            {
                return;
            }

            var p      = tap.LocationInView(this);
            var offset = p.X;

            var s = (float)(offset / (this.Bounds.Size.Width / StarNum));

            this.Rate = this.Incomplete ? s : (float)Math.Ceiling(s);

            if (this.RateChanged != null)
            {
                this.RateChanged.Invoke(this, new RatingBarRateChangeEventArgs()
                {
                    Rate = this.Rate
                });
            }

            //Step 不应该用在 Tap事件中
            //var s = (float)(offset / (this.Bounds.Size.Width / StarNum));

            //if (s < this.Step)
            //    s = this.Step;
            //else {
            //    var n = s / this.Step;
            //    if (n != (int)n) {
            //        var a = ((int)n) * this.Step;
            //        s = a;
            //    }
            //}
            //this.Rate = this.Incomplete ? s : (float)Math.Round(s);
        }
Пример #11
0
        void HandleTap()
        {
            if (_tapGestureRecognizer == null)
            {
                return;
            }

            if (_isSwiping)
            {
                return;
            }

            var state = _tapGestureRecognizer.State;

            if (state != UIGestureRecognizerState.Cancelled)
            {
                if (_contentView == null)
                {
                    return;
                }

                var point = _tapGestureRecognizer.LocationInView(this);

                if (_isOpen)
                {
                    if (!TouchInsideContent(point))
                    {
                        ProcessTouchSwipeItems(point);
                    }
                    else
                    {
                        ResetSwipe();
                    }
                }
            }
        }
Пример #12
0
 void OpenBarcodeUrl(UITapGestureRecognizer openBarcodeURLGestureRecognizer)
 {
     foreach (var metadataObjectOverlayLayer in metadataObjectOverlayLayers)
     {
         var location = openBarcodeURLGestureRecognizer.LocationInView(PreviewView);
         if (metadataObjectOverlayLayer.Path.ContainsPoint(location, false))
         {
             var barcodeMetadataObject = metadataObjectOverlayLayer.MetadataObject as AVMetadataMachineReadableCodeObject;
             if (barcodeMetadataObject != null)
             {
                 var val = barcodeMetadataObject.StringValue;
                 if (!string.IsNullOrWhiteSpace(val))
                 {
                     var url       = NSUrl.FromString(val);
                     var sharedApp = UIApplication.SharedApplication;
                     if (sharedApp.CanOpenUrl(url))
                     {
                         sharedApp.OpenUrl(url);
                     }
                 }
             }
         }
     }
 }
		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);
			}
		}
Пример #14
0
        unsafe protected void tap(UITapGestureRecognizer sender)
        {
            if (nsvc.SigningMode)
            {
                CGPoint l = sender.LocationInView(this);
                if (sender.State == UIGestureRecognizerState.Recognized)
                {
                    this.nsvc.hasBeenSigned = true;

                    GL.BindBuffer(BufferTarget.ArrayBuffer, dotsBuffer);
                    NICSignaturePoint touchPoint = this.ViewPointToGL(l, this.Frame, new Vector3 {
                        X = 1.0f, Y = 1.0f, Z = 1.0f
                    });

                    fixed(uint *pdl = &dotsLength)
                    {
                        this.AddVertex(pdl, touchPoint);
                    }

                    NICSignaturePoint centerPoint = touchPoint;
                    centerPoint.Color = GLSignatureView.StrokeColor;

                    fixed(uint *pdl = &dotsLength)
                    {
                        this.AddVertex(pdl, centerPoint);
                    }

                    const int segments = 20;
                    Vector2   radius   = new Vector2 {
                        X = penThickness * this.GenerateRandom(0.5f, 1.0f),
                        Y = penThickness * this.GenerateRandom(0.5f, 1.0f)
                    };
                    Vector2 velocityRadius = radius;
                    double  angle          = 0;

                    // Our view height is much less than width, for them dots to be more roundy
                    float uncompressY = (float)(this.Frame.Width / this.Frame.Height);

                    for (int i = 0; i <= segments; i++)
                    {
                        NICSignaturePoint p = centerPoint;
                        p.Vertex.X += velocityRadius.X * ((float)Math.Cos(angle));
                        p.Vertex.Y += velocityRadius.Y * ((float)Math.Sin(angle)) * uncompressY;

                        fixed(uint *pdl = &dotsLength)
                        {
                            this.AddVertex(pdl, p);
                        }

                        fixed(uint *pdl = &dotsLength)
                        {
                            this.AddVertex(pdl, centerPoint);
                        }

                        angle += Math.PI * 2.0f / segments;
                    }

                    fixed(uint *pdl = &dotsLength)
                    {
                        this.AddVertex(pdl, touchPoint);
                    }

                    GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
                }

                this.SetNeedsDisplay();
            }             // end if the corresponding view controller is in Signing mode
        }
Пример #15
0
        /// <summary>
        /// Called when the tap gesture recognizer detects a double tap.
        /// </summary>
        /// <param name="tap">Tap.</param>
        private void DoubleTap(UITapGestureRecognizer tap)
        {
            CGRect rect = this.Frame;
            if (this.MapAllowZoom &&
                rect.Width > 0 && rect.Height > 0 && this.Map != null)
            {
                this.StopCurrentAnimation();

                View2D view = this.CreateView(rect);
                CGPoint location = tap.LocationInView(this);
                double[] sceneCoordinates = view.FromViewPort(rect.Width, rect.Height, location.X, location.Y);
                GeoCoordinate geoLocation = this.Map.Projection.ToGeoCoordinates(sceneCoordinates[0], sceneCoordinates[1]);

                if (this.DoubleMapTapEvent != null)
                {
                    this.DoubleMapTapEvent(geoLocation);
                }
                else
                { // minimum zoom.
                    // Clamp the zoom level between the configured maximum and minimum.
                    float tapRequestZoom = MapZoom + 0.5f;
                    _doubleTapAnimator.Start(geoLocation, tapRequestZoom, new TimeSpan(0, 0, 0, 0, 500));
                }

                // notify controls map was tapped.
                this.NotifyMapTapToControls();
            }
        }
 private void DidDoubleTap(UITapGestureRecognizer recognizer)
 {
     CGPoint pointInView = recognizer.LocationInView(_imageView);
     ZoomInZoomOut(pointInView);
 }
Пример #17
0
        private void OnSingleTapped(UITapGestureRecognizer gesture)
        {
            var position = GetScreenPosition(gesture.LocationInView(this));

            OnInfo(InvokeInfo(position, position, 1));
        }
Пример #18
0
        /// <summary>
        /// Called when the tap gesture recognizer detects a double tap.
        /// </summary>
        /// <param name="tap">Tap.</param>
        private void DoubleTap(UITapGestureRecognizer tap)
        {
            //RectangleF2D rect = _rect;
            RectangleF rect = this.Frame;
            if (this.MapAllowZoom &&
                rect.Width > 0 && rect.Height > 0)
            {
                this.StopCurrentAnimation();

                View2D view = this.CreateView(rect);
                PointF location = tap.LocationInView(this);
                double[] sceneCoordinates = view.FromViewPort(rect.Width, rect.Height, location.X, location.Y);
                GeoCoordinate geoLocation = this.Map.Projection.ToGeoCoordinates(sceneCoordinates[0], sceneCoordinates[1]);

                if (this.DoubleMapTapEvent != null)
                {
                    this.DoubleMapTapEvent(geoLocation);
                }
                else
                {
                    // minimum zoom.
                    float tapRequestZoom = (float)System.Math.Max(_mapZoom + 1, 19);
                    _doubleTapAnimator.Start(geoLocation, tapRequestZoom, new TimeSpan(0, 0, 1));
                }
            }
        }
Пример #19
0
 public void HandleTapGesture(UITapGestureRecognizer tap)
 {
     if( Note != null )
     {
         if( tap.State == UIGestureRecognizerState.Ended )
         {
             try
             {
                 Note.DidDoubleTap( tap.LocationInView( UIScrollView ).ToPointF( ) );
             }
             catch( Exception e )
             {
                 // we know this exception is the too many notes one. Just show it.
                 SpringboardViewController.DisplayError( "Messages", e.Message );
             }
         }
     }
 }
Пример #20
0
        private void on_doubletap(UITapGestureRecognizer gr)
        {
            var wh = gr.LocationInView(this);

            _dp.do_doubletap(wh.X, wh.Y);
        }
        // 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;
                });
            });
        }
Пример #22
0
		public void OnDoubleTapGesture (UITapGestureRecognizer sender)
		{
			var location = sender.LocationInView (sender.View);
			var position = GetOffsetPosition (new Vector2 (location.X, location.Y), true);
			TouchPanel.GestureList.Enqueue (new GestureSample (
				GestureType.DoubleTap, new TimeSpan (DateTime.Now.Ticks),
				position, Vector2.Zero,
				Vector2.Zero, Vector2.Zero));
		}
		//
		// Respond to taps.
		//
		public void TapHandler(UITapGestureRecognizer tgr) {
			CGPoint touchPoint = tgr.LocationInView (nativeElement);
			formsElement.OnTapEvent ((int)touchPoint.X, (int)touchPoint.Y);
		}
Пример #24
0
		public static void ParseForMentionOrHash(UITapGestureRecognizer obj, NSIndexPath indexPath, UITableView tableView, FeedTypeEnum.FeedType target = 0)
		{
			UITextView textView = (UITextView)obj.View;
			UITextRange textRange;
			string text = textView.Text;

			//contains emoji fix
			if (StringUtils.ContainsEmoji(text))
			{
				//try to remove the emoji's first
				text = System.Text.RegularExpressions.Regex.Replace(text, @"\p{Cs}", "");
				if (String.IsNullOrEmpty(text))
				{
					return;
				}

				//if it has emoji's just go to the post page.
				//if (tableView != null)
				//{
				//	tableView.Delegate.RowSelected(tableView, indexPath);
				//}
				//return;
			}

			try
			{
				textRange = textView.Tokenizer.GetRangeEnclosingPosition(textView.GetClosestPositionToPoint(obj.LocationInView(textView)), UITextGranularity.Word, UITextDirection.Forward);
			}
			catch (Exception)
			{
				if (tableView != null && tableView.Delegate != null)
				{
					tableView.Delegate.RowSelected(tableView, indexPath);
				}
				return;
			}

			if (textRange == null)
			{
				if (tableView != null && tableView.Delegate != null)
				{
					tableView.Delegate.RowSelected(tableView, indexPath);
				}
				return;
			}

			nint clickedLocation = textView.GetOffsetFromPosition(textView.BeginningOfDocument, textRange.Start); //-1
			nint newLoc = text.LastIndexOf(" ", (int)clickedLocation) + 1;

			nint newLen = text.IndexOf(" ", (int)clickedLocation);//textView.GetOffsetFromPosition (textRange.Start, textRange.End);
			if (newLen == -1)
			{//no space exist after
				newLen = text.Length;
			}

			if (textRange == null || newLoc == -1)
			{
				if (tableView != null && tableView.Delegate != null)
				{
					tableView.Delegate.RowSelected(tableView, indexPath);
				}
				return;
			}

			string prefix = text.Substring((int)newLoc, 1);
			Console.WriteLine(prefix);

			if (prefix == "@")
			{
				if (target == FeedTypeEnum.FeedType.StatusFeed)
				{
					((HomeViewController)((UINavigationController)((AppDelegate)UIApplication.SharedApplication.Delegate).TabBarController.ViewControllers[0]).ViewControllers[0]).DismissModalViewController(false);
				}
				var test = text.Substring((int)newLoc, (int)(newLen - newLoc));
				TenServiceHelper.GoToGuestProfile(test); //remove -1
			}
			else if (prefix == "#")
			{
				if (target == FeedTypeEnum.FeedType.StatusFeed)
				{
					((HomeViewController)((UINavigationController)((AppDelegate)UIApplication.SharedApplication.Delegate).TabBarController.ViewControllers[0]).ViewControllers[0]).DismissModalViewController(false);
				}
				TenServiceHelper.GoToSearchTags(text.Substring((int)newLoc, (int)(newLen - newLoc))); //remove -1
			}
			else {
				if (tableView != null && tableView.Delegate != null)
				{
					tableView.Delegate.RowSelected(tableView, indexPath);
				}
				return;

			}
		}
Пример #25
0
        private void ScrollViewDoubleTapped(UITapGestureRecognizer recognizer)
        {
            CGPoint pointInView = recognizer.LocationInView(_imageView);

            double newZoomScale = _scrollView.ZoomScale * 1.5;

            newZoomScale = Math.Min(newZoomScale, _scrollView.MaximumZoomScale);

            CGSize scrollViewSize = _scrollView.Bounds.Size;
            double w = scrollViewSize.Width / newZoomScale;
            double h = scrollViewSize.Height / newZoomScale;
            double x = pointInView.X - (w / 2.0);
            double y = pointInView.Y - (h / 2.0);

            var rectToZoomTo = new CGRect(x, y, w, h);
            if (_scrollView.ContentSize.Height > View.Frame.Height && _scrollView.ContentSize.Width > View.Frame.Width)
            {
                _scrollView.ZoomToRect(View.Frame, true);
            }
            else
            {
                _scrollView.ZoomToRect(rectToZoomTo, true);
            }
        }
Пример #26
0
        private void Tapped(UITapGestureRecognizer gestureRecognizer)
        {
            var point = new SKPoint((float)gestureRecognizer.LocationInView(_view).X *(float)_scale, (float)gestureRecognizer.LocationInView(_view).Y *(float)_scale);

            _effect.Tap(point);
        }
 private void OnTap( UITapGestureRecognizer tapRecg )
 {
     CGPoint loc = tapRecg.LocationInView(this);
     if (SelectDayView((PointF) loc) && calendarMonthView.OnDateSelected != null)
         calendarMonthView.OnDateSelected(new DateTime(currentMonth.Year, currentMonth.Month,
             (int) SelectedDayView.Tag));
 }
Пример #28
0
        private void on_singletap(UITapGestureRecognizer gr)
        {
            var wh = gr.LocationInView(this);

            tab.SingleTap(wh.X, wh.Y);              // TODO do we need to use the return value of this call?
        }
Пример #29
0
 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)));
     }
 }
Пример #30
0
        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();
        }
Пример #31
0
        private void TapGestureHandler(UITapGestureRecognizer gesture)
        {
            var screenPosition = GetScreenPosition(gesture.LocationInView(this));

            Map.InvokeInfo(screenPosition, screenPosition, _skiaScale, _renderer.SymbolCache, WidgetTouch);
        }
Пример #32
0
        /// <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]));
                }
            }
        }
Пример #33
0
        //
        // Respond to taps.
        //
        public void TapHandler(UITapGestureRecognizer tgr)
        {
            CGPoint touchPoint = tgr.LocationInView(nativeElement);

            formsElement.OnTapEvent((int)touchPoint.X, (int)touchPoint.Y);
        }
		public void Tap (UITapGestureRecognizer tap)
		{
			if (!IsFirstResponder) {
				// Inform controller that we're about to enter editing mode
				if (ViewWillEdit != null)
					ViewWillEdit (this);
				// Flag that underlying SimpleCoreTextView is now in edit mode
				textView.IsEditing = true;
			// Become first responder state (which shows software keyboard, if applicable)
				BecomeFirstResponder ();
			} else {
				// Already in editing mode, set insertion point (via selectedTextRange)
				inputDelegate.SelectionWillChange (this);
				// Find and update insertion point in underlying SimpleCoreTextView
				int index = textView.ClosestIndex (tap.LocationInView (textView));
				textView.MarkedTextRange = new NSRange (NSRange.NotFound, 0);
				textView.SelectedTextRange = new NSRange (index, 0);

				// Let inputDelegate know selection has changed
				inputDelegate.SelectionDidChange (this);
			}
		}
Пример #35
0
 public void TapGestureRecognizer(UITapGestureRecognizer sender)
 {
     TouchPanel.GestureList.Enqueue(new GestureSample(GestureType.Tap, new TimeSpan(_nowUpdate.Ticks), translatedTouchPosition, new Vector2 (sender.LocationInView (sender.View)), new Vector2(0,0), new Vector2(0,0)));
 }
        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);
            }
        }
Пример #37
0
        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);
        }
 private void DidSingleTap(UITapGestureRecognizer recognizer)
 {
     if (scrollView.ZoomScale == scrollView.MinimumZoomScale)
     {
         HideDoneButton();    
     }
     else if (scrollView.ZoomScale == scrollView.MaximumZoomScale)
     {
         CGPoint pointInView = recognizer.LocationInView(_imageView);
         ZoomInZoomOut(pointInView);
     }
 }
Пример #39
0
        /// <summary>
        /// When a tap was perfomed on the map
        /// </summary>
        /// <param name="recognizer">The gesture recognizer</param>
        private void OnMapClicked(UITapGestureRecognizer recognizer)
        {
            if (recognizer.State != UIGestureRecognizerState.Ended) return;

            var pixelLocation = recognizer.LocationInView(this.Map);
            var coordinate = this.Map.ConvertPoint(pixelLocation, this.Map);

            if (this.FormsMap.RouteClickedCommand != null)
            {
                foreach (var route in this.FormsMap.Routes.Where(i => i.Selectable))
                {
                    var internalItem = this._routes.Single(i => i.Value.Overlay.Equals(route));
                    var coordinates = internalItem.Key.Points.Select(i => this.Map.ConvertPoint(new CGPoint(i.X, i.Y), this.Map));

                    if (GmsPolyUtil.IsLocationOnPath(
                        coordinate.ToPosition(),
                        coordinates.Select(i => i.ToPosition()),
                        true,
                        this.ZoomLevel,
                        this.Map.CenterCoordinate.Latitude))
                    {
                        if (this.FormsMap.RouteClickedCommand.CanExecute(route))
                        {
                            this.FormsMap.RouteClickedCommand.Execute(route);
                            return;
                        }
                    }
                }
            }

            if (this.FormsMap.MapClickedCommand != null && this.FormsMap.MapClickedCommand.CanExecute(coordinate.ToPosition()))
            {
                this.FormsMap.MapClickedCommand.Execute(coordinate.ToPosition());
            }

        }
Пример #40
0
        /// <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();
            }
        }
                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);
                    }
                }
Пример #42
0
 public void TapGestureRecognizer(UITapGestureRecognizer sender)
 {
     TouchPanel.GestureList.Enqueue(new GestureSample(GestureType.Tap, new TimeSpan(_nowUpdate.Ticks), translatedTouchPosition, new Vector2(sender.LocationInView(sender.View)), new Vector2(0, 0), new Vector2(0, 0)));
 }
        //private UIButton _someButton;
        //private void SomeButtonOnTouchUpInside(object sender, EventArgs eventArgs)
        //{
        //    var button = (UIButton) sender;
        //    Title = "Wow!";
        //    var newCenter = GetRandomPointWithinBounds(View.Bounds);
        //    button.Center = newCenter;
        //}

        //private static readonly Random Random = new Random();
        //private static CGPoint GetRandomPointWithinBounds(CGRect bounds)
        //{
        //    var x = Random.Next((int)bounds.Left, (int)bounds.Right);
        //    var y = Random.Next((int)bounds.Top, (int)bounds.Bottom);

        //    return new CGPoint(x, y);
        //}

        private void ShowMenu(UITapGestureRecognizer sender)
        {
            _radialMenu.SetAnimationOrigin(sender.LocationInView(View)).PresentInView(View);
        }
Пример #44
0
        private void OnSingleTapped(UITapGestureRecognizer gesture)
        {
            var position = GetScreenPosition(gesture.LocationInView(this));

            Map.InvokeInfo(position, position, Renderer.SymbolCache, WidgetTouched, 1);
        }
		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);
			}
		}
		void p_Tapped(UITapGestureRecognizer tapRecg)
		{
			var loc = tapRecg.LocationInView(this);
			if (SelectDayView(loc)&& _calendarMonthView.OnDateSelected!=null)
				_calendarMonthView.OnDateSelected(new DateTime(_currentMonth.Year, _currentMonth.Month, SelectedDayView.Tag));
		}
Пример #47
0
        private void OnMuralTapped(UITapGestureRecognizer tapGesture)
        {
            var position = tapGesture.LocationInView(this.muralView);

            this.viewModel.OnTapped(position.AsPointF());
        }