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


C# UIPanGestureRecognizer类代码示例

本文整理汇总了C#中UIPanGestureRecognizer的典型用法代码示例。如果您正苦于以下问题:C# UIPanGestureRecognizer类的具体用法?C# UIPanGestureRecognizer怎么用?C# UIPanGestureRecognizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: BMarkerImageView

        public BMarkerImageView(WeakReference parentView, CGPoint location)
        {
            WeakParent = parentView;
             _location = location;

             UserInteractionEnabled = true;

             Frame = new CGRect (Location.X - 22, Location.Y - 22, 44, 44);
             using (var image = UIImage.FromFile ("Images/icon_marker.png"))
             {
            Image = image;
             }

             _pan = new UIPanGestureRecognizer (() =>
             {
            if ((_pan.State == UIGestureRecognizerState.Began || _pan.State == UIGestureRecognizerState.Changed) && (_pan.NumberOfTouches == 1))
            {
               Center = _pan.LocationInView (_parent);
               Location = Center;
               _parent.SetNeedsDisplay ();
            }
            else if (_pan.State == UIGestureRecognizerState.Ended)
            {
            }
             });

             _doubleTap = new UITapGestureRecognizer ((gesture) => Crop ()) {
            NumberOfTapsRequired = 2, NumberOfTouchesRequired = 1
             };

             AddGestureRecognizer (_pan);
             AddGestureRecognizer (_doubleTap);
        }
开发者ID:bkmza,项目名称:XamCropBkmzaSampleIOS,代码行数:33,代码来源:BMarkerImageView.cs

示例2: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			_panGesture = new UIPanGestureRecognizer(PanGestureRecognized);
			View.AddGestureRecognizer(_panGesture);
		}
开发者ID:TMAgostinho,项目名称:REFrostedViewController,代码行数:7,代码来源:DEMONavigationController.cs

示例3: TouchDrawView

        public TouchDrawView(CGRect rect)
            : base(rect)
        {
            linesInProcess = new Dictionary<string, Line>();
            this.BackgroundColor = UIColor.White;
            this.MultipleTouchEnabled = true;

            UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer(tap);
            this.AddGestureRecognizer(tapRecognizer);

            UITapGestureRecognizer dbltapRecognizer = new UITapGestureRecognizer(dblTap);
            dbltapRecognizer.NumberOfTapsRequired = 2;
            this.AddGestureRecognizer(dbltapRecognizer);

            UILongPressGestureRecognizer pressRecognizer = new UILongPressGestureRecognizer(longPress);
            this.AddGestureRecognizer(pressRecognizer);

            moveRecognizer = new UIPanGestureRecognizer(moveLine);
            moveRecognizer.WeakDelegate = this;
            moveRecognizer.CancelsTouchesInView = false;
            this.AddGestureRecognizer(moveRecognizer);

            UISwipeGestureRecognizer swipeRecognizer = new UISwipeGestureRecognizer(swipe);
            swipeRecognizer.Direction = UISwipeGestureRecognizerDirection.Up;
            swipeRecognizer.NumberOfTouchesRequired = 3;
            this.AddGestureRecognizer(swipeRecognizer);

            selectedColor = UIColor.Red;
        }
开发者ID:yingfangdu,项目名称:BNR,代码行数:29,代码来源:TouchDrawView.cs

示例4: HandlePanGesture

		void HandlePanGesture (UIPanGestureRecognizer gesture)
		{
			if (gesture.State == UIGestureRecognizerState.Began) {
				gestureStartingPoint = gesture.TranslationInView (textView);
				gestureStartingCenter = imageView.Center;
			}
			else if (gesture.State == UIGestureRecognizerState.Changed) {
				CGPoint currentPoint = gesture.TranslationInView(textView);
				nfloat distanceX = currentPoint.X - gestureStartingPoint.X;
				nfloat distanceY = currentPoint.Y - gestureStartingPoint.Y;

				CGPoint newCenter = gestureStartingCenter;

				newCenter.X += distanceX;
				newCenter.Y += distanceY;

				imageView.Center = newCenter;

				textView.TextContainer.ExclusionPaths = TranslatedBezierPath ();
			}
			else if (gesture.State == UIGestureRecognizerState.Ended) {
				gestureStartingPoint  = new CGPoint (0, 0);
				gestureStartingCenter = new CGPoint (0, 0);
			}
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:25,代码来源:ExclusionPathsViewController.cs

示例5: SlideoutNavigationController

        /// <summary>
        /// Initializes a new instance of the <see cref="SlideoutNavigationController"/> class.
        /// </summary>
        public SlideoutNavigationController()
        {
            SlideSpeed = 0.2f;
            SlideWidth = 245f;
            // HACK to detect pan gesture from the whole viewport
            SlideHeight = float.MaxValue;
            LayerShadowing = false;

            _internalMenuViewLeft = new ProxyNavigationController {
                ParentController = this,
                View = { AutoresizingMask = UIViewAutoresizing.FlexibleHeight }
            };
            _internalMenuViewRight = new ProxyNavigationController {
                ParentController = this,
                View = { AutoresizingMask = UIViewAutoresizing.FlexibleHeight }
            };

            _internalMenuViewLeft.SetNavigationBarHidden (DisplayNavigationBarOnLeftMenu, false);
            _internalMenuViewRight.SetNavigationBarHidden (DisplayNavigationBarOnRightMenu, false);

            _internalTopView = new UIViewController { View = { UserInteractionEnabled = true } };
            _internalTopView.View.Layer.MasksToBounds = false;

            _tapGesture = new UITapGestureRecognizer ();
            _tapGesture.AddTarget (() => Hide ());
            _tapGesture.NumberOfTapsRequired = 1;

            _panGesture = new UIPanGestureRecognizer {
                Delegate = new SlideoutPanDelegate(this),
                MaximumNumberOfTouches = 1,
                MinimumNumberOfTouches = 1
            };
            _panGesture.AddTarget (() => Pan (_internalTopView.View));
            _internalTopView.View.AddGestureRecognizer (_panGesture);
        }
开发者ID:jgrozdanov,项目名称:mono-sport,代码行数:38,代码来源:SlideoutNavigationController.cs

示例6: AddGestures

        private void AddGestures()
        {
            var touchDownGesture = new UILongPressGestureRecognizer(HandleTouchDown) { MinimumPressDuration = 0 };
            _canvasView.AddGestureRecognizer(touchDownGesture);

            // Tap to select
            var tapGesture = new UITapGestureRecognizer(HandleTap);
            _canvasView.AddGestureRecognizer(tapGesture);

            // Move an element
            var elementDragGesture = new UIPanGestureRecognizer(HandlePan);
            _canvasView.AddGestureRecognizer(elementDragGesture);

            elementDragGesture.ShouldBegin = g => _panShouldBegin;

            var selectLongPressGesture = new UILongPressGestureRecognizer(HandleLongPress) { MinimumPressDuration = 0.1 };
            _canvasView.AddGestureRecognizer(selectLongPressGesture);

            selectLongPressGesture.ShouldReceiveTouch = (g, touch) =>
            {
                var locationInCanvas = touch.LocationInView(_canvasView);
                var touchedElement = ElementUnderPoint(locationInCanvas);

                return touchedElement != null && !IsElementSelected(touchedElement);
            };

            selectLongPressGesture.ShouldRecognizeSimultaneously = (g1, g2) => g2 == elementDragGesture;
            touchDownGesture.ShouldRecognizeSimultaneously = (g1, g2) => true;
        }
开发者ID:TheRealAdamKemp,项目名称:GestureRecognizerPresentation,代码行数:29,代码来源:GestureViewController.cs

示例7: CreatePanGestureRecognizer

        private void CreatePanGestureRecognizer()
        {
            panGesture = new UIPanGestureRecognizer(() =>
            {
                if ((panGesture.State == UIGestureRecognizerState.Began || panGesture.State == UIGestureRecognizerState.Changed) && (panGesture.NumberOfTouches == 1))
                {

                    var p0 = panGesture.LocationInView(this);

                    if (dx == 0)
                        dx = p0.X - Subviews[0].Center.X;

                    if (dy == 0)
                        dy = p0.Y - Subviews[0].Center.Y;

                    var p1 = new PointF((float)(p0.X - dx), (float)(p0.Y - dy));

                    Subviews[0].Center = p1;
                }
                else if (panGesture.State == UIGestureRecognizerState.Ended)
                {
                    dx = 0;
                    dy = 0;
                }
            });
        }
开发者ID:dimgrek,项目名称:TabbedAppXamarin,代码行数:26,代码来源:NativeScrollViewRenderer.cs

示例8: RangeSlider

        public RangeSlider()
        {
            _background = new UIView();
            _background.BackgroundColor = UIColor.LightGray;

            _range = new UIView();
            _range.BackgroundColor = UIColor.Blue;

            _leftIndicator = CreateIndicator();
            _leftIndicatorGesture = new UIPanGestureRecognizer(OnPan);

            _rightIndicator = CreateIndicator();
            _rightIndicatorGesture = new UIPanGestureRecognizer(OnPan);

            _leftTouchArea = new UIView();
            _leftTouchArea.BackgroundColor = UIColor.Clear;
            _leftTouchArea.AddGestureRecognizer(_leftIndicatorGesture);

            _rightTouchArena = new UIView();
            _rightTouchArena.BackgroundColor = UIColor.Clear;
            _rightTouchArena.AddGestureRecognizer(_rightIndicatorGesture);

            AddSubview(_background);
            AddSubview(_range);
            AddSubview(_leftIndicator);
            AddSubview(_rightIndicator);
            AddSubview(_leftTouchArea);
            AddSubview(_rightTouchArena);
        }
开发者ID:mjohanss,项目名称:flipper,代码行数:29,代码来源:RangeSlider.cs

示例9: RevealGesture

        public void RevealGesture(UIPanGestureRecognizer recognizer)
        {
            MenuViewController rearVC = (MenuViewController)SidebarViewController;
            rearVC.searchBar.ResignFirstResponder ();

            base.DragContentView (recognizer);
        }
开发者ID:alleeclark,项目名称:morganHack,代码行数:7,代码来源:MainViewController.cs

示例10: SlideoutNavigationController

        /// <summary>
        /// Initializes a new instance of the <see cref="SlideoutNavigationController"/> class.
        /// </summary>
        public SlideoutNavigationController()
        {
            SlideSpeed = 0.2f;
            SlideWidth = 260f;
            SlideHeight = 44f;
            LayerShadowing = true;

            _internalMenuView = new ProxyNavigationController
                                    {
                                        ParentController = this,
                                        View = { AutoresizingMask = UIViewAutoresizing.FlexibleHeight }
                                    };
            //_internalMenuView.SetNavigationBarHidden(true, false);

            _internalTopView = new UIViewController { View = { UserInteractionEnabled = true } };
            _internalTopView.View.Layer.MasksToBounds = false;

            _tapGesture = new UITapGestureRecognizer();
            //            _tapGesture.AddTarget(new )
            _tapGesture.AddTarget(Hide);
            _tapGesture.NumberOfTapsRequired = 1;

            _panGesture = new UIPanGestureRecognizer
                              {
                                  Delegate = new SlideoutPanDelegate(this),
                                  MaximumNumberOfTouches = 1,
                                  MinimumNumberOfTouches = 1
                              };
            _panGesture.AddTarget(() => Pan(_internalTopView.View));
            _internalTopView.View.AddGestureRecognizer(_panGesture);
        }
开发者ID:sinhpham,项目名称:Harvest_Loss,代码行数:34,代码来源:SlideoutNavigationController.cs

示例11: createGrab

        private void createGrab()
        {
            float dx = 0;
                var panGesture = new UIPanGestureRecognizer ((pg) => {
                    if ((pg.State == UIGestureRecognizerState.Began || pg.State == UIGestureRecognizerState.Changed) && (pg.NumberOfTouches == 1)) {

                        var p0 = pg.LocationInView (content);

                        if (dx == 0)
                            dx = p0.X - content.Center.X;

                        var p1 = new PointF (p0.X - dx, content.Center.Y);
                    //Dont let it go to far right
                        if (p1.X <= content.Center.X)
                            content.Center = p1;
                    //Auto withdrawl after 33%
                        if (p1.X < content.Frame.Width/3) {
                        closeIt();
                        }
                    } else if (pg.State == UIGestureRecognizerState.Ended) {
                        dx = 0;
                    }
                });
                content.AddGestureRecognizer (panGesture);
        }
开发者ID:RayLynn,项目名称:Xamarin-IOS-FlyInSlider,代码行数:25,代码来源:SlideOutPracticeViewController.cs

示例12: ViewDidAppear

        public override void ViewDidAppear(bool animated)
        {
            base.ViewWillAppear (animated);

            UINavigationController nav = NavigationController;
            MainViewController controller = (MainViewController)nav.ParentViewController; // MainViewController : ZUUIRevealController

            // Check if a UIPanGestureRecognizer already sits atop our NavigationBar.
            if (nav.NavigationBar.GestureRecognizers == null ||
                !(nav.NavigationBar.GestureRecognizers.Contains (navigationBarPanGestureRecognizer))) {
                // If not, allocate one and add it.
                UIPanGestureRecognizer panGestureRecognizer = new UIPanGestureRecognizer (controller.RevealGesture);
                navigationBarPanGestureRecognizer = panGestureRecognizer;

                NavigationController.NavigationBar.AddGestureRecognizer (navigationBarPanGestureRecognizer);
            }

            // Check if we have a revealButton already.
            if (NavigationItem.LeftBarButtonItem == null) {
                // If not, allocate one and add it.
                UIImage imageMenu = UIImage.FromFile ("action_menu.png");
                UIButton menuButton = new UIButton (UIButtonType.Custom);
                menuButton.SetImage (imageMenu, UIControlState.Normal);
                menuButton.Frame = new RectangleF (0.0f, 0.0f, (float)imageMenu.Size.Width, (float)imageMenu.Size.Height);
                menuButton.TouchUpInside += (sender, e) => controller.RevealToggle ();

                NavigationItem.LeftBarButtonItem = new UIBarButtonItem (menuButton);
            }
        }
开发者ID:alleeclark,项目名称:morganHack,代码行数:29,代码来源:SecondViewController.cs

示例13: ViewDidLoad

        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();

            View.Apply (Style.Screen);
            NavigationBar.Apply (Style.NavigationBar);
            Delegate = new NavDelegate ();

            panGesture = new UIPanGestureRecognizer (OnPanGesture) {
                // TODO: TableView scroll gestures are not
                // compatible with the open / close pan gesture.
                ShouldRecognizeSimultaneously = (a, b) => ! (b.View is UITableView),
                CancelsTouchesInView = true,
            };
            View.AddGestureRecognizer (panGesture);

            fadeView = new UIView();
            fadeView.BackgroundColor = UIColor.FromRGBA (29f / 255f, 29f / 255f, 28f / 255f, 0.5f);
            fadeView.Frame = new CGRect (0, 0, View.Frame.Width, View.Frame.Height);
            fadeView.Hidden = true;

            tapGesture = new UITapGestureRecognizer (CloseMenu) {
                ShouldReceiveTouch = (a, b) => true,
                ShouldRecognizeSimultaneously = (a, b) => true,
                CancelsTouchesInView = true,
            };
            fadeView.AddGestureRecognizer (tapGesture);
            View.Add (fadeView);
        }
开发者ID:eatskolnikov,项目名称:mobile,代码行数:29,代码来源:MainViewController.cs

示例14: OnPanningGesture

        private void OnPanningGesture (UIPanGestureRecognizer gesture)
        {
            switch (gesture.State) {
            case UIGestureRecognizerState.Began:
                panStart = gesture.TranslationInView (actualContentView);
                panLockInHorizDirection = false;
                break;
            case UIGestureRecognizerState.Changed:
                var currentPoint = gesture.TranslationInView (actualContentView);
                panDeltaX = panStart.X - currentPoint.X;

                if (panDeltaX > 0) {
                    panDeltaX = 0;
                    return;
                }

                if (!panLockInHorizDirection) {
                    if (Math.Abs (panDeltaX) > 30) {
                        // User is swiping the cell, lock them into this direction
                        panLockInHorizDirection = true;
                    } else if (Math.Abs (panStart.Y - currentPoint.Y) > 5) {
                        // User is starting to move upwards, let them scroll
                        gesture.Enabled = false;
                    }
                }

                if (-SwipeWidth > panDeltaX) {
                    panDeltaX = -SwipeWidth;
                }

                UIView.AnimateNotify (0.1, 0, UIViewAnimationOptions.CurveEaseOut, LayoutActualContentView, null);
                break;
            case UIGestureRecognizerState.Ended:
                if (Editing) {
                    break;
                }

                if (!gesture.Enabled) {
                    gesture.Enabled = true;
                }

                var velocityX = gesture.VelocityInView (gesture.View).X;
                var absolutePanDeltaX = Math.Abs (panDeltaX);
                var duration = Math.Max (MinDuration, Math.Min (MaxDuration, (absolutePanDeltaX) / velocityX));

                UIView.AnimateNotify (duration, () => LayoutActualContentView (0), isFinished => {
                    if (isFinished && absolutePanDeltaX > SwipeWidth - 5) {
                        OnContinueGestureFinished ();
                    }
                });

                break;
            case UIGestureRecognizerState.Cancelled:
                UIView.AnimateNotify (0.3, () => LayoutActualContentView (0), isFinished => gesture.Enabled = isFinished);
                break;
            }

        }
开发者ID:BradChang,项目名称:mobile,代码行数:58,代码来源:SwipableTimeEntryTableViewCell.cs

示例15: WireUpDragGestureRecognizer

 protected void WireUpDragGestureRecognizer()
 {
     // create a new tap gesture
     UIPanGestureRecognizer gesture = new UIPanGestureRecognizer();
     // wire up the event handler (have to use a selector)
     gesture.AddTarget(() => HandleDrag(gesture));
     // add the gesture recognizer to the view
     imgDragMe.AddGestureRecognizer(gesture);
 }
开发者ID:Adameg,项目名称:mobile-samples,代码行数:9,代码来源:GestureRecognizers_iPhone.xib.cs


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