public PlatformGestureEffect() { //if (!allSubviews) // tapDetector.ShouldReceiveTouch = (s, args) => args.View != null && (args.View == view || view.Subviews.Any(v => v == args.View)); //else // tapDetector.ShouldReceiveTouch = (s, args) => true; tapDetector = CreateTapRecognizer(() => Tuple.Create(tapCommand, tapCommand2)); doubleTapDetector = CreateTapRecognizer(() => Tuple.Create((ICommand)null, doubleTapCommand)); doubleTapDetector.NumberOfTapsRequired = 2; swipeLeftDetector = CreateSwipeRecognizer(() => swipeLeftCommand, UISwipeGestureRecognizerDirection.Left); swipeRightDetector = CreateSwipeRecognizer(() => swipeRightCommand, UISwipeGestureRecognizerDirection.Right); swipeUpDetector = CreateSwipeRecognizer(() => swipeTopCommand, UISwipeGestureRecognizerDirection.Up); swipeDownDetector = CreateSwipeRecognizer(() => swipeBottomCommand, UISwipeGestureRecognizerDirection.Down); panDetector = CreatePanRecognizer(() => panCommand); recognizers = new List <UIGestureRecognizer> { tapDetector, doubleTapDetector, swipeLeftDetector, swipeRightDetector, swipeUpDetector, swipeDownDetector, panDetector }; }
public GestureControl(UIView view, IGestureControleDelegate gestureDelegate) { _delegate = gestureDelegate; //superInit this.Frame = CoreGraphics.CGRect.Empty; var swipeLeft = new UISwipeGestureRecognizer(SwipeHandler); //swipeLeft.AddTarget(this, SwipeHandler); swipeLeft.Direction = UISwipeGestureRecognizerDirection.Left; AddGestureRecognizer(swipeLeft); var swipeRight = new UISwipeGestureRecognizer(SwipeHandler); //swipeLeft.AddTarget(this, SwipeHandler); swipeRight.Direction = UISwipeGestureRecognizerDirection.Right; AddGestureRecognizer(swipeRight); TranslatesAutoresizingMaskIntoConstraints = false; BackgroundColor = UIColor.Clear; view.AddSubview(this); //Add constraint var attrs = new NSLayoutAttribute[] { NSLayoutAttribute.Left, NSLayoutAttribute.Right, NSLayoutAttribute.Top, NSLayoutAttribute.Bottom }; foreach (var attr in attrs) { (view, this).ConstraintOps((ConstraintInfo obj) => obj.Attribute = attr); } }
public override void ViewDidLoad() { base.ViewDidLoad(); tableView.DataSource = this; tableView.Delegate = this; var gk = new UITapGestureRecognizer(() => { focusListView = false; SetNeedsFocusUpdate(); UpdateFocusIfNeeded(); }); gk.AllowedPressTypes = new NSNumber[] { (int)UIPressType.LeftArrow, (int)UIPressType.RightArrow }; var gs = new UISwipeGestureRecognizer(() => { focusListView = false; SetNeedsFocusUpdate(); UpdateFocusIfNeeded(); }); gs.Direction = UISwipeGestureRecognizerDirection.Right; this.tableView.AddGestureRecognizer(gk); this.tableView.AddGestureRecognizer(gs); }
protected override void OnElementChanged(ElementChangedEventArgs <Frame> e) { base.OnElementChanged(e); swipeLeft = new UISwipeGestureRecognizer(() => { var control = this.Element as SwipeFrame; control.OnSwipeLeft(); }); swipeRight = new UISwipeGestureRecognizer(() => { var control = this.Element as SwipeFrame; control.OnSwipeRight(); }); swipeLeft.Direction = UISwipeGestureRecognizerDirection.Left; swipeRight.Direction = UISwipeGestureRecognizerDirection.Right; if (e.NewElement == null) { if (swipeLeft != null) { this.RemoveGestureRecognizer(swipeLeft); } if (swipeRight != null) { this.RemoveGestureRecognizer(swipeRight); } } if (e.OldElement == null) { this.AddGestureRecognizer(swipeRight); this.AddGestureRecognizer(swipeLeft); } }
/// <summary> /// Called when [element changed]. /// </summary> /// <param name="e">The e.</param> protected override void OnElementChanged (ElementChangedEventArgs<Editor> e) { base.OnElementChanged (e); var view = (ExtendedEditor)Element; if (view != null) { Control.Font = view.Font.ToUIFont(); } if (e.OldElement == null) { _leftSwipeGestureRecognizer = new UISwipeGestureRecognizer(() => view.OnLeftSwipe(this, EventArgs.Empty)) { Direction = UISwipeGestureRecognizerDirection.Left }; _rightSwipeGestureRecognizer = new UISwipeGestureRecognizer(()=> view.OnRightSwipe(this, EventArgs.Empty)) { Direction = UISwipeGestureRecognizerDirection.Right }; Control.AddGestureRecognizer(_leftSwipeGestureRecognizer); Control.AddGestureRecognizer(_rightSwipeGestureRecognizer); } if (e.NewElement == null) { Control.RemoveGestureRecognizer(_leftSwipeGestureRecognizer); Control.RemoveGestureRecognizer(_rightSwipeGestureRecognizer); } }
public override void ViewDidLoad() { View.BackgroundColor = UIColor.White; _imageView = new UIImageView(View.Frame) { MultipleTouchEnabled = true, UserInteractionEnabled = true, ContentMode = UIViewContentMode.ScaleAspectFit, AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight }; var tapGesture = new UITapGestureRecognizer(OnImageTap); _imageView.AddGestureRecognizer(tapGesture); var leftSwipe = new UISwipeGestureRecognizer(OnImageSwipe) { Direction = UISwipeGestureRecognizerDirection.Left }; _imageView.AddGestureRecognizer(leftSwipe); var rigthSwipe = new UISwipeGestureRecognizer(OnImageSwipe) { Direction = UISwipeGestureRecognizerDirection.Right }; _imageView.AddGestureRecognizer(rigthSwipe); View.AddSubview(_imageView); PHAsset asset = _imageCache.GetAsset(_image.LocalIdentifier); UpdateImage(asset); }
private void ConfigureGestures() { AddTapToDismissGesture(); // Only add the swipe gestures if the user is creating a new time entry. // Users are not allowed to change the job type when editing. if (EditingItem != null) { return; } // When the user swipes left or right, change the value of the selected job type var swipeLeft = new UISwipeGestureRecognizer((s) => HandleSwipeGesture(UISwipeGestureRecognizerDirection.Left)) { Direction = UISwipeGestureRecognizerDirection.Left }; var swipeRight = new UISwipeGestureRecognizer((s) => HandleSwipeGesture(UISwipeGestureRecognizerDirection.Right)) { Direction = UISwipeGestureRecognizerDirection.Right }; View.AddGestureRecognizer(swipeLeft); View.AddGestureRecognizer(swipeRight); }
protected override void OnElementChanged(ElementChangedEventArgs <LRMasterDetailPage> e) { base.OnElementChanged(e); longPressGestureRecognizer = new UILongPressGestureRecognizer(() => Console.WriteLine("Long Press")); pinchGestureRecognizer = new UIPinchGestureRecognizer(() => Console.WriteLine("Pinch")); //panGestureRecognizer = new UIPanGestureRecognizer (() => Console.WriteLine ("Pan")); swipeRightGestureRecognizer = new UISwipeGestureRecognizer(() => UpdateRight()) { Direction = UISwipeGestureRecognizerDirection.Right }; swipeLeftGestureRecognizer = new UISwipeGestureRecognizer(() => UpdateLeft()) { Direction = UISwipeGestureRecognizerDirection.Left }; rotationGestureRecognizer = new UIRotationGestureRecognizer(() => Console.WriteLine("Rotation")); if (e.NewElement == null) { if (longPressGestureRecognizer != null) { this.RemoveGestureRecognizer(longPressGestureRecognizer); } if (pinchGestureRecognizer != null) { this.RemoveGestureRecognizer(pinchGestureRecognizer); } /* * if (panGestureRecognizer != null) { * this.RemoveGestureRecognizer (panGestureRecognizer); * } */ if (swipeRightGestureRecognizer != null) { this.RemoveGestureRecognizer(swipeRightGestureRecognizer); } if (swipeLeftGestureRecognizer != null) { this.RemoveGestureRecognizer(swipeLeftGestureRecognizer); } if (rotationGestureRecognizer != null) { this.RemoveGestureRecognizer(rotationGestureRecognizer); } } if (e.OldElement == null) { this.AddGestureRecognizer(longPressGestureRecognizer); this.AddGestureRecognizer(pinchGestureRecognizer); //this.AddGestureRecognizer (panGestureRecognizer); this.AddGestureRecognizer(swipeRightGestureRecognizer); this.AddGestureRecognizer(swipeLeftGestureRecognizer); this.AddGestureRecognizer(rotationGestureRecognizer); } }
private void HandleSwipeDown(UISwipeGestureRecognizer gestureRecognizer) { if (gestureRecognizer.State == UIGestureRecognizerState.Recognized) { SayGoodbye(_goodbyeAction); } }
public override void ViewDidLoad () { base.ViewDidLoad (); MainBackButtonTmp.BackButtonClick = true; _tabController = this; _localizer = new Localizer (); CustomUIViewController tabVAC, tabILL, tabOVT, tabPOV, tabEXV; tabVAC = CreateTabViewController ("VAC", 0); tabILL = CreateTabViewController ("ILL", 1); tabOVT = CreateTabViewController ("OVT", 2); tabPOV = CreateTabViewController ("POV", 3); tabEXV = CreateTabViewController ("EXV", 4); var tabs = new CustomUIViewController[] { tabVAC, tabILL, tabOVT, tabPOV, tabEXV }; ViewControllers = tabs; SelectedViewController = tabVAC; _swipeRecognizerRight = new UISwipeGestureRecognizer (OnSwipeRight){ Direction = UISwipeGestureRecognizerDirection.Right }; _swipeRecognizerLeft = new UISwipeGestureRecognizer (OnSwipeLeft){ Direction = UISwipeGestureRecognizerDirection.Left }; View.AddGestureRecognizer (_swipeRecognizerRight); View.AddGestureRecognizer (_swipeRecognizerLeft); }
void SwipeRecognizer(UISwipeGestureRecognizer x) { if (x.State == UIGestureRecognizerState.Began) { this._swipeStart = x.LocationInView(this).ToPoint(); } if (x.State == UIGestureRecognizerState.Ended) { var endpoint = x.LocationInView(this).ToPoint(); var distance = this._swipeStart.Distance(endpoint); var distanceX = Math.Abs(this._swipeStart.X - endpoint.X); var distanceY = Math.Abs(this._swipeStart.Y - endpoint.Y); var direction = Directionality.None; direction |= ((x.Direction & UISwipeGestureRecognizerDirection.Left) == UISwipeGestureRecognizerDirection.Left ? Directionality.Left : Directionality.None); direction |= ((x.Direction & UISwipeGestureRecognizerDirection.Right) == UISwipeGestureRecognizerDirection.Right ? Directionality.Right : Directionality.None); direction |= ((x.Direction & UISwipeGestureRecognizerDirection.Up) == UISwipeGestureRecognizerDirection.Up ? Directionality.Up : Directionality.None); direction |= ((x.Direction & UISwipeGestureRecognizerDirection.Down) == UISwipeGestureRecognizerDirection.Down ? Directionality.Down : Directionality.None); this.Element.ProcessGesture(new GestureResult { Direction = direction, GestureType = GestureType.Swipe, HorizontalDistance = distanceX, VerticalDistance = distanceY, Origin = _swipeStart, Length = distance, ViewStack = Element.ExcludeChildren ? ViewsContaining(_swipeStart) : null }); } }
public override void ViewDidLoad() { base.ViewDidLoad(); myWebView.BackgroundColor = Utils.getThemeColor(); View.BackgroundColor = Utils.getThemeColor(); UISwipeGestureRecognizer recognizerLeft = new UISwipeGestureRecognizer(OnSwipeDetectedLeft); recognizerLeft.Direction = UISwipeGestureRecognizerDirection.Left; View.AddGestureRecognizer(recognizerLeft); UISwipeGestureRecognizer recognizerRight = new UISwipeGestureRecognizer(OnSwipeDetectedRight); recognizerRight.Direction = UISwipeGestureRecognizerDirection.Right; View.AddGestureRecognizer(recognizerRight); btnLeft.Clicked += (s, e) => { if (myWebView.CanGoBack) { myWebView.GoBack(); } }; barbtnRight.Clicked += (s, e) => { if (myWebView.CanGoForward) { myWebView.GoForward(); } }; }
public override void ViewDidLoad() { base.ViewDidLoad (); var table = new UITableView (new CoreGraphics.CGRect (0f, 20f, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height)); // defaults to Plain style quotes.Add(new Quote("列表", "向右慢拉返回", "")); quotes.Add(new Quote("", "Loading...", "")); table.Source = new QuoteTableSource (quotes); UISwipeGestureRecognizer swipeGestureRecognizerRight = new UISwipeGestureRecognizer (() => { DismissViewController(true, null); }){ Direction = UISwipeGestureRecognizerDirection.Right }; this.View.AddGestureRecognizer (swipeGestureRecognizerRight); Thread thread = new Thread(() => { update(location, model); InvokeOnMainThread(delegate { table.ReloadData(); }); }); thread.Start (); Add (table); }
private void setupSwipeControls() { UISwipeGestureRecognizer upswipe = new UISwipeGestureRecognizer(this, new Selector("up:")); upswipe.NumberOfTouches = 1; upswipe.Direction = UISwipeGestureRecognizerDirection.Up; View.AddGestureRecognizer(upswipe); UISwipeGestureRecognizer downswipe = new UISwipeGestureRecognizer(this, new Selector("down:")); downswipe.NumberOfTouches = 1; downswipe.Direction = UISwipeGestureRecognizerDirection.Down; View.AddGestureRecognizer(downswipe); UISwipeGestureRecognizer leftswipe = new UISwipeGestureRecognizer(this, new Selector("left:")); leftswipe.NumberOfTouches = 1; leftswipe.Direction = UISwipeGestureRecognizerDirection.Left; View.AddGestureRecognizer(leftswipe); UISwipeGestureRecognizer rightswipe = new UISwipeGestureRecognizer(this, new Selector("right:")); rightswipe.NumberOfTouches = 1; rightswipe.Direction = UISwipeGestureRecognizerDirection.Left; View.AddGestureRecognizer(rightswipe); }
public Easter(UIView viewForGestures, params Egg[] eggs) : base(eggs) { swipeUp = new UISwipeGestureRecognizer (() => AddCommand (new SwipeUpCommand())); swipeUp.Direction = UISwipeGestureRecognizerDirection.Up; viewForGestures.AddGestureRecognizer (swipeUp); swipeDown = new UISwipeGestureRecognizer (() => AddCommand (new SwipeDownCommand())); swipeDown.Direction = UISwipeGestureRecognizerDirection.Down; viewForGestures.AddGestureRecognizer (swipeDown); swipeLeft = new UISwipeGestureRecognizer (() => AddCommand (new SwipeLeftCommand())); swipeLeft.Direction = UISwipeGestureRecognizerDirection.Left; viewForGestures.AddGestureRecognizer (swipeLeft); swipeRight = new UISwipeGestureRecognizer (() => AddCommand (new SwipeRightCommand())); swipeRight.Direction = UISwipeGestureRecognizerDirection.Right; viewForGestures.AddGestureRecognizer (swipeRight); tap = new UITapGestureRecognizer (() => AddCommand (new TapCommand())); tap.NumberOfTapsRequired = 1; viewForGestures.AddGestureRecognizer (tap); longTap = new UILongPressGestureRecognizer (() => AddCommand (new LongTapCommand())); longTap.NumberOfTapsRequired = 1; viewForGestures.AddGestureRecognizer (longTap); }
protected override void OnElementChanged (ElementChangedEventArgs<View> e) { base.OnElementChanged (e); //If the NewElement has been queued up if (e.NewElement != null) { //Set SliderView Instance _sliderView = e.NewElement as SliderView; //Make the currentView the same dimensions of the SliderView _sliderView.Children [currentViewIndex].HeightRequest = _sliderView.Height; _sliderView.Children [currentViewIndex].WidthRequest = _sliderView.Width; //This is an optional thing, really depends on how you want to use this SliderView _sliderView.Children [currentViewIndex].BackgroundColor = _sliderView.BackgroundColor; } //Create the gesture that brings the view in from the right side rightGesture = new UISwipeGestureRecognizer (swipe => { Console.WriteLine("Swipe Left"); //Check to make sure we aren't on the current view if (_sliderView.Children.Count > currentViewIndex + 1 ) { //Add one to the index currentViewIndex++; _sliderView.CurrentView = _sliderView.Children [currentViewIndex]; _sliderView.CurrentView.HeightRequest = _sliderView.Height; _sliderView.CurrentView.WidthRequest = _sliderView.Width; _sliderView.CurrentView.BackgroundColor = _sliderView.BackgroundColor; //Translate the CurrentView onto the ViewScreen TranslateToCurrentView ("Left"); } }) { Direction = UISwipeGestureRecognizerDirection.Left }; //Create the gesture that brings the view in from the left side leftGesture = new UISwipeGestureRecognizer (swipe => { //Check to make sure we aren't at the first view if (currentViewIndex != 0) { //Drop the index one currentViewIndex--; //Set the new CurrentView _sliderView.CurrentView = _sliderView.Children [currentViewIndex]; //Set the size of the CurrentView to the size of the SliderView _sliderView.CurrentView.HeightRequest = _sliderView.Height; _sliderView.CurrentView.WidthRequest = _sliderView.Width; //This is an optional thing, really depends on how you want to use this SliderView _sliderView.CurrentView.BackgroundColor = _sliderView.BackgroundColor; //Translate the CurrentView onto the ViewScreen TranslateToCurrentView ("Right"); } }) { Direction = UISwipeGestureRecognizerDirection.Right }; //Add the Gesture Recognizers to the SliderView AddGestureRecognizer (rightGesture); AddGestureRecognizer (leftGesture); }
protected override void OnElementChanged (VisualElementChangedEventArgs e) { base.OnElementChanged (e); if (e.NewElement != null) { tabbedController = (UITabBarController)ViewController; } if (!isInitialized) { rightGesture = new UISwipeGestureRecognizer (swipe => { //Check to make sure we aren't at the last view Console.WriteLine ("Swipe Left"); if(this.SelectedIndex != ViewControllers.Length - 1) tabbedController.SelectedViewController = ViewControllers [this.SelectedIndex + 1]; }) { Direction = UISwipeGestureRecognizerDirection.Left }; leftGesture = new UISwipeGestureRecognizer (swipe => { //Check to make sure we aren't at the first view Console.WriteLine ("Swipe Right"); if(this.SelectedIndex != 0) tabbedController.SelectedViewController = ViewControllers [this.SelectedIndex - 1]; }) { Direction = UISwipeGestureRecognizerDirection.Right }; View.AddGestureRecognizer (rightGesture); View.AddGestureRecognizer (leftGesture); isInitialized = true; } }
public void IsRewardCollectionEmpty() { var itemsCount = CollectionView.Source.GetItemsCount(CollectionView, 0); if (itemsCount == 0) { EmptyCollectionView.Hidden = false; _swipe = new UISwipeGestureRecognizer(); _swipe.AddTarget(() => HideAreaCollection()); _swipe.Direction = UISwipeGestureRecognizerDirection.Up | UISwipeGestureRecognizerDirection.Down; EmptyCollectionView.AddGestureRecognizer(_swipe); _tap = new UITapGestureRecognizer(); _tap.AddTarget(() => HideAreaCollection()); EmptyCollectionView.AddGestureRecognizer(_tap); var data = NSData.FromFile("Images/panda-ohno.gif"); var image = AnimatedImageView.GetAnimatedImageView(data, ViewForImage); ViewForImage.Image = image.Image; ViewForImage.StartAnimating(); } if (itemsCount != 0) { EmptyCollectionView.Hidden = true; } }
private void InitializeGestures() { _singleTapRecognizer = new UITapGestureRecognizer( () => CloseButton.Hidden = !CloseButton.Hidden) { NumberOfTapsRequired = (uint)1 }; _doubleTapRecognizer = new UITapGestureRecognizer(ZoomTo) { NumberOfTapsRequired = (uint)2 }; _swipeRecognizer = new UISwipeGestureRecognizer(RaiseToHide) { Direction = UISwipeGestureRecognizerDirection.Down | UISwipeGestureRecognizerDirection.Up }; _singleTapRecognizer.RequireGestureRecognizerToFail(_doubleTapRecognizer); ScrollView.AddGestureRecognizer(_singleTapRecognizer); ScrollView.AddGestureRecognizer(_doubleTapRecognizer); View.AddGestureRecognizer(_swipeRecognizer); }
private void HandleSwipe(UISwipeGestureRecognizer swipe) { var gestureRecognizers = new List <Tuple <MycoView, IMycoGestureRecognizerController> >(); var location = swipe.LocationInView(Control); (Element as IMycoController).GetGestureRecognizers(new Xamarin.Forms.Point(location.X, location.Y), gestureRecognizers); foreach (var gestureRecognizer in gestureRecognizers) { var swipeGesture = gestureRecognizer.Item2 as IMycoSwipeGestureRecognizerController; if (swipeGesture != null) { switch (swipe.Direction) { case UISwipeGestureRecognizerDirection.Left: swipeGesture.SendSwipeLeft(gestureRecognizer.Item1); break; case UISwipeGestureRecognizerDirection.Right: swipeGesture.SendSwipeRight(gestureRecognizer.Item1); break; } } } }
void FnInitializeView() { CGRect rectBounds = UIScreen.MainScreen.Bounds; //flViewBringDownY = rectBounds.Height - 30f; //complete collapse viewContainer //flViewShiftUpY = rectBounds.Height - 120f;//200 is the heght of viewContainer var recognizerRight = new UISwipeGestureRecognizer(FnSwipeLeftToRight); recognizerRight.Direction = UISwipeGestureRecognizerDirection.Right; View.AddGestureRecognizer(recognizerRight); var recognizerLeft = new UISwipeGestureRecognizer(FnSwipeRightToLeft); recognizerLeft.Direction = UISwipeGestureRecognizerDirection.Left; View.AddGestureRecognizer(recognizerLeft); // viewDecriptionContainer.Hidden = true; btnIcon1.SetBackgroundImage(UIImage.FromBundle("Images/menu_icon"), UIControlState.Normal); btnIcon1.TouchUpInside += delegate(object sender, EventArgs e) { FnPerformTableTransition(); }; }
void FnInitializeView() { var recognizerRight = new UISwipeGestureRecognizer(FnSwipeLeftToRight); recognizerRight.Direction = UISwipeGestureRecognizerDirection.Right; View.AddGestureRecognizer(recognizerRight); var recognizerLeft = new UISwipeGestureRecognizer(FnSwipeRightToLeft); recognizerLeft.Direction = UISwipeGestureRecognizerDirection.Left; View.AddGestureRecognizer(recognizerLeft); btnIcon.SetBackgroundImage(UIImage.FromBundle("Menu.png"), UIControlState.Normal); btnIcon.TouchUpInside += delegate(object sender, EventArgs e) { if (leftmenu.Frame.X >= 0) { leftmenu.Frame = new RectangleF(-250, 0, 250, (float)UIScreen.MainScreen.Bounds.Height); DashboardMainView.Frame = new RectangleF(0, 0, (float)UIScreen.MainScreen.Bounds.Width, (float)UIScreen.MainScreen.Bounds.Height); } else { leftmenu.Frame = new RectangleF(0, 0, 250, (float)UIScreen.MainScreen.Bounds.Height); DashboardMainView.Frame = new RectangleF(250, 0, (float)UIScreen.MainScreen.Bounds.Width, (float)UIScreen.MainScreen.Bounds.Height); } //leftmenu.Hidden = false; //FnPerformTableTransition(); }; }
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; }
public void Swipped(UISwipeGestureRecognizer sender) { if (!ShouldStayOpen) { ShowMenu(); } }
private void AddSwipeGestures(ViewCell cell, UITableViewCell tableViewCell, UITableView tableView) { swipeRight = new UISwipeGestureRecognizer(() => { if (!(cell as CustomViewCell).Checked) { UIView.Animate(0.2, 0.0, UIViewAnimationOptions.TransitionNone, () => { tableViewCell.Frame = new RectangleF( new PointF((float)(tableViewCell.Frame.Location.X + 26), (float)tableViewCell.Frame.Location.Y), (SizeF)tableViewCell.Frame.Size); }, () => { tableViewCell.Frame = new RectangleF( new PointF((float)(tableViewCell.Frame.Location.X - 26), (float)tableViewCell.Frame.Location.Y), (SizeF)tableViewCell.Frame.Size); (cell as CustomViewCell).Checked = true; }); } }); swipeRight.Direction = UISwipeGestureRecognizerDirection.Right; swipeLeft = new UISwipeGestureRecognizer(() => (cell as CustomViewCell).Checked = false) { Direction = UISwipeGestureRecognizerDirection.Left, Delegate = new SwipeRecogniserDelegate(cell as CustomViewCell) }; tableViewCell.AddGestureRecognizer(swipeRight); tableViewCell.AddGestureRecognizer(swipeLeft); }
private void PrepareSurfaceView() { _surfaceView = new UIView(ParentView.Bounds); ParentView.Superview.AddSubview(_surfaceView); ParentView.BringSubviewToFront(_surfaceView); _surfaceView.UserInteractionEnabled = true; _tapGesture = new UITapGestureRecognizer((UITapGestureRecognizer obj) => { HideSideBar(); }); _tapGesture.ShouldReceiveTouch += (UIGestureRecognizer recognizer, UITouch touch) => { bool isSurfaceView = (touch.View != _surfaceView); return(!isSurfaceView); }; _swipeGesture = new UISwipeGestureRecognizer((UISwipeGestureRecognizer obj) => { HideSideBar(); }); _swipeGesture.Direction = UISwipeGestureRecognizerDirection.Left; _swipeGesture.ShouldReceiveTouch += (UIGestureRecognizer recognizer, UITouch touch) => { return(true); }; _surfaceView.AddGestureRecognizer(_tapGesture); _surfaceView.AddGestureRecognizer(_swipeGesture); }
private void HandleSwipeUp(UISwipeGestureRecognizer gestureRecognizer) { if (gestureRecognizer.State == UIGestureRecognizerState.Recognized) { SayHello(_helloAction); } }
public override void ViewDidLoad() { base.ViewDidLoad(); MainViewController = (NavigationViewController)Storyboard.InstantiateViewController(NavigationViewController.STORYBOARD_ID); MainViewController.ContainerController = this; SetupContainerController(MainContainerView, MainViewController); MenuViewController = (MenuViewController)Storyboard.InstantiateViewController(MenuViewController.STORYBOARD_ID); MenuViewController.ContainerController = this; SetupContainerController(MenuContainerView, MenuViewController); MenuContainerView.TranslatesAutoresizingMaskIntoConstraints = false; MenuContainerView.ClipsToBounds = true; ShowMenu(false, false); UISwipeGestureRecognizer rightSwipeGesture = new UISwipeGestureRecognizer(() => { ShowMenu(); }); rightSwipeGesture.Direction = UISwipeGestureRecognizerDirection.Right; MainContainerView.AddGestureRecognizer(rightSwipeGesture); UISwipeGestureRecognizer leftSwipeGesture = new UISwipeGestureRecognizer(() => { HideMenu(); }); leftSwipeGesture.Direction = UISwipeGestureRecognizerDirection.Left; MenuContainerView.AddGestureRecognizer(leftSwipeGesture); }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.BoxView> e) { base.OnElementChanged(e); gestureBoxView = (GestureBoxView)e.NewElement; swipeUpGestureRecognizer = new UISwipeGestureRecognizer(() => gestureBoxView.RaiseSwipedUp()) { Direction = UISwipeGestureRecognizerDirection.Up }; swipeDownGestureRecognizer = new UISwipeGestureRecognizer(() => gestureBoxView.RaiseSwipedDown()) { Direction = UISwipeGestureRecognizerDirection.Down }; if (e.NewElement == null) { if (swipeUpGestureRecognizer != null) { this.RemoveGestureRecognizer(swipeUpGestureRecognizer); } if (swipeDownGestureRecognizer != null) { this.RemoveGestureRecognizer(swipeDownGestureRecognizer); } } if (e.OldElement == null) { this.AddGestureRecognizer(swipeUpGestureRecognizer); this.AddGestureRecognizer(swipeDownGestureRecognizer); } }
public override void ViewDidLoad() { NSNotificationCenter.DefaultCenter.AddObserver((Foundation.NSString) "SaveClicked", notify : delegate(NSNotification obj) { SaveDetails(obj); }); base.ViewDidLoad(); ContactUsPanelView.Layer.BorderColor = UIColor.DarkGray.CGColor; ContactUsPanelView.Layer.BorderWidth = 1.0f; ContactUsPanelView.Layer.ShadowColor = UIColor.DarkGray.CGColor; ContactUsPanelView.Layer.ShadowRadius = 2.0f; ContactUsPanelView.Layer.ShadowOpacity = 0.8f; swipeUp = new UISwipeGestureRecognizer(didSwipe); swipeUp.Direction = UISwipeGestureRecognizerDirection.Up; this.ContactUsPanelView.AddGestureRecognizer(swipeUp); swipeDown = new UISwipeGestureRecognizer(didSwipe); swipeDown.Direction = UISwipeGestureRecognizerDirection.Down; this.ContactUsPanelView.AddGestureRecognizer(swipeDown); // UITapGestureRecognizer tapGesture = new UITapGestureRecognizer(ShowPopUp); // ViewUpArrow.AddGestureRecognizer(tapGesture); // UITapGestureRecognizer tapGesture1 = new UITapGestureRecognizer(HidePopUp); // ViewDownArrow.AddGestureRecognizer(tapGesture1); // UITapGestureRecognizer tapGestureMail = new UITapGestureRecognizer(ShowMail); // lblMail.AddGestureRecognizer(tapGestureMail); // UITapGestureRecognizer tapGestureContact = new UITapGestureRecognizer(DialContact); // lblDial.AddGestureRecognizer(tapGestureContact); //// lblDial. //viewcellmail.AddGestureRecognizer(tapGestureMail); //viewcelldial.AddGestureRecognizer(tapGestureContact); }
// This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. public override bool FinishedLaunching(UIApplication app, NSDictionary options) { window = new UIWindow(UIScreen.MainScreen.Bounds); // create and initialize a UICollectionViewFlowLayout layout = new UICollectionViewFlowLayout() { HeaderReferenceSize = new SizeF(UIScreen.MainScreen.Bounds.Width, 50), SectionInset = new UIEdgeInsets(10, 5, 10, 5), MinimumInteritemSpacing = 5, MinimumLineSpacing = 5, ItemSize = new System.Drawing.SizeF(100, 100) }; // create a CollectionViewController (which is a UICollectionViewController) with a layout viewController = new CollectionViewController(layout); // toggle the layout in response to a swipe left swipeLeft = new UISwipeGestureRecognizer(g => { if (customLayout == null) { // create and initialize a CustomLayout customLayout = new CustomLayout(viewController.Speakers.Count) { ItemSize = new SizeF(100, 100) }; } if (viewController.CollectionView.CollectionViewLayout is UICollectionViewFlowLayout) { // switch to a custom layout viewController.CollectionView.SetCollectionViewLayout(customLayout, true); } else { // invalidate the flow layout in case the orientation changed layout.InvalidateLayout(); // switch to a flow layout viewController.CollectionView.SetCollectionViewLayout(layout, true); // scroll to the top viewController.CollectionView.SetContentOffset(new PointF(0, 0), false); } }) { Direction = UISwipeGestureRecognizerDirection.Left }; // add the gesture recognizer to the UICollectionView viewController.CollectionView.AddGestureRecognizer(swipeLeft); window.RootViewController = viewController; window.MakeKeyAndVisible(); return(true); }
void p_monthViewSwipedUp(UISwipeGestureRecognizer ges) { if (SwipedUp != null) { SwipedUp(); } }
/// <summary> /// The on element changed callback. /// </summary> /// <param name="e">The event arguments.</param> protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); var view = (ExtendedEntry)Element; SetFont(view); SetTextAlignment(view); SetBorder(view); SetPlaceholderTextColor(view); ResizeHeight(); if (e.OldElement == null) { _leftSwipeGestureRecognizer = new UISwipeGestureRecognizer(() => view.OnLeftSwipe(this, EventArgs.Empty)) { Direction = UISwipeGestureRecognizerDirection.Left }; _rightSwipeGestureRecognizer = new UISwipeGestureRecognizer(() => view.OnRightSwipe(this, EventArgs.Empty)) { Direction = UISwipeGestureRecognizerDirection.Right }; Control.AddGestureRecognizer(_leftSwipeGestureRecognizer); Control.AddGestureRecognizer(_rightSwipeGestureRecognizer); } if (e.NewElement == null) { Control.RemoveGestureRecognizer(_leftSwipeGestureRecognizer); Control.RemoveGestureRecognizer(_rightSwipeGestureRecognizer); } }
private Direction GetDirection(UISwipeGestureRecognizer gr) { UISwipeGestureRecognizerDirection direction = gr.Direction; if (direction <= UISwipeGestureRecognizerDirection.Up) { if (direction < UISwipeGestureRecognizerDirection.Right) { return Direction.NotClear; } switch ((int)(direction - UISwipeGestureRecognizerDirection.Right)) { case 0: return Direction.Right; case 1: return Direction.Left; case 2: return Direction.NotClear; case 3: return Direction.Up; } } if (direction == UISwipeGestureRecognizerDirection.Down) { return Direction.Down; } return Direction.NotClear; }
protected override void OnElementChanged(ElementChangedEventArgs <Editor> e) { base.OnElementChanged(e); var view = (ExtendedEditor)Element; Control.Font = view.Font.ToUIFont(); if (e.OldElement == null) { this.leftSwipeGestureRecognizer = new UISwipeGestureRecognizer(() => view.OnLeftSwipe(this, EventArgs.Empty)) { Direction = UISwipeGestureRecognizerDirection.Left }; this.rightSwipeGestureRecognizer = new UISwipeGestureRecognizer(() => view.OnRightSwipe(this, EventArgs.Empty)) { Direction = UISwipeGestureRecognizerDirection.Right }; this.Control.AddGestureRecognizer(this.leftSwipeGestureRecognizer); this.Control.AddGestureRecognizer(this.rightSwipeGestureRecognizer); } if (e.NewElement == null) { this.Control.RemoveGestureRecognizer(this.leftSwipeGestureRecognizer); this.Control.RemoveGestureRecognizer(this.rightSwipeGestureRecognizer); } }
public override async void ViewDidLoad() { base.ViewDidLoad(); TopMenuEvents(true, btnMonth, btnQuarter, btnHalfYear, btnYear); ClickServicesEvents(true, btnCost, btnQuality, btnService, btnAll); btnCost.TouchUpInside += btnOneTouch; btnQuality.TouchUpInside += btnTwoTouch; btnService.TouchUpInside += btnThreeTouch; btnAll.TouchUpInside += btnFourTouch; HttpServiceConn conn = new HttpServiceConn(); try { _Questions = await conn.GetQuestions(Token, Company); CreateButtonForGraphics(btnCost, btnQuality, btnService, btnAll); } catch (Exception ex) { UIAlertView error = new UIAlertView("Ошибка", ex.Message, null, "Закрыть", null); error.Show(); } btnMonth.SendActionForControlEvents(UIControlEvent.TouchUpInside); UISwipeGestureRecognizer gest = new UISwipeGestureRecognizer(); gest.Direction = UISwipeGestureRecognizerDirection.Right; gest.AddTarget(() => MoveBack(gest)); MainBackGroubd.AddGestureRecognizer(gest); }
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; }
protected override void OnElementChanged(ElementChangedEventArgs <ImageCarousel> e) { base.OnElementChanged(e); if (e.OldElement != null) { if (swipeLeftGestureRecognizer != null) { this.RemoveGestureRecognizer(swipeLeftGestureRecognizer); } if (swipeRightGestureRecognizer != null) { this.RemoveGestureRecognizer(swipeRightGestureRecognizer); } } if (e.NewElement != null) { swipeLeftGestureRecognizer = new UISwipeGestureRecognizer(Element.OnSwipeLeft); swipeLeftGestureRecognizer.Direction = UISwipeGestureRecognizerDirection.Left; swipeRightGestureRecognizer = new UISwipeGestureRecognizer(Element.OnSwipeRight); swipeRightGestureRecognizer.Direction = UISwipeGestureRecognizerDirection.Right; this.AddGestureRecognizer(swipeLeftGestureRecognizer); this.AddGestureRecognizer(swipeRightGestureRecognizer); } }
public void HandleRightSwipe(UISwipeGestureRecognizer recogniser) { Debug.WriteLine("Got a right swipe."); SetRandomCurrent (); RenderCurrent (); }
// This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. public override bool FinishedLaunching (UIApplication app, NSDictionary options) { window = new UIWindow (UIScreen.MainScreen.Bounds); // create and initialize a UICollectionViewFlowLayout layout = new UICollectionViewFlowLayout () { HeaderReferenceSize = new SizeF (UIScreen.MainScreen.Bounds.Width, 50), SectionInset = new UIEdgeInsets (10,5,10,5), MinimumInteritemSpacing = 5, MinimumLineSpacing = 5, ItemSize = new System.Drawing.SizeF (100, 100) }; // create a CollectionViewController (which is a UICollectionViewController) with a layout viewController = new CollectionViewController (layout); //TODO: Step 4b: uncomment to implement a left swipe gesture to switch between Collection View Layouts // toggle the layout in response to a swipe left swipeLeft = new UISwipeGestureRecognizer (g => { if (customLayout == null) { // create and initialize a CustomLayout customLayout = new CustomLayout (viewController.Speakers.Count){ ItemSize = new SizeF (100, 100) }; } if (viewController.CollectionView.CollectionViewLayout is UICollectionViewFlowLayout) { // switch to a custom layout viewController.CollectionView.SetCollectionViewLayout (customLayout, true); } else { // invalidate the flow layout in case the orientation changed layout.InvalidateLayout(); // switch to a flow layout viewController.CollectionView.SetCollectionViewLayout (layout, true); // scroll to the top viewController.CollectionView.SetContentOffset(new PointF(0,0), false); } }){ Direction = UISwipeGestureRecognizerDirection.Left }; // add the gesture recognizer to the UICollectionView viewController.CollectionView.AddGestureRecognizer (swipeLeft); window.RootViewController = viewController; window.MakeKeyAndVisible (); return true; }
protected override void OnElementChanged(ElementChangedEventArgs<Frame> e) { base.OnElementChanged (e); if (e.NewElement == null) { RemoveGestureRecognizer (); return; } var gestureView = e.NewElement as GestureAwareContentView; _longPressGestureRecognizer = new UILongPressGestureRecognizer ( sender => { var offset = sender.LocationInView(NativeView); GestureUtil.ExecuteCommand(gestureView.LongPress, new GestureOffset(sender.State.ToGestureState(), offset.X, offset.Y)); }); _pinchGestureRecognizer = new UIPinchGestureRecognizer ( sender => { var scale = sender.Scale; GestureUtil.ExecuteCommand(gestureView.Pinch, new GestureScale(sender.State.ToGestureState(), scale)); }); _panGestureRecognizer = new UIPanGestureRecognizer ( sender => { var offset = sender.TranslationInView(NativeView); GestureUtil.ExecuteCommand(gestureView.Pan, new GestureOffset(sender.State.ToGestureState(), offset.X, offset.Y)); }); _swipeGestureRecognizer = new UISwipeGestureRecognizer ( sender => { var offset = sender.LocationInView(NativeView); GestureUtil.ExecuteCommand(gestureView.Swipe, new GestureOffset(sender.State.ToGestureState(), offset.X, offset.Y)); }); _rotationGestureRecognizer = new UIRotationGestureRecognizer ( sender => { GestureUtil.ExecuteCommand (gestureView.Rotate); }); AddGestureRecognizer (_longPressGestureRecognizer); AddGestureRecognizer (_pinchGestureRecognizer); AddGestureRecognizer (_panGestureRecognizer); AddGestureRecognizer (_swipeGestureRecognizer); AddGestureRecognizer (_rotationGestureRecognizer); }
/// <summary> /// Adds the gesture. /// </summary> private void addGesture() { UISwipeGestureRecognizer swipe = new UISwipeGestureRecognizer (this, new Selector ("HandleSwipe:")) { Direction = UISwipeGestureRecognizerDirection.Up }; DetailTextView.AddGestureRecognizer (swipe); swipe = new UISwipeGestureRecognizer (this, new Selector ("HandleSwipe:")) { Direction = UISwipeGestureRecognizerDirection.Down }; DetailTextView.AddGestureRecognizer (swipe); }
protected override void Dispose(bool disposing) { if (disposing) { if (_swipeDown != null) { _swipeDown.Dispose(); _swipeDown = null; } if (_swipeLeft != null) { _swipeLeft.Dispose(); _swipeLeft = null; } if (_swipeRight != null) { _swipeRight.Dispose(); _swipeRight = null; } if (_swipeUp != null) { _swipeUp.Dispose(); _swipeUp = null; } if (_doubleTap != null) { _doubleTap.Dispose(); _doubleTap = null; } if (_singleTap != null) { _singleTap.Dispose(); _singleTap = null; } if (_pinch != null) { _pinch.Dispose(); _pinch = null; } } // don't try and dispose the base - it will try and dispose of the native control that we didn't create //base.Dispose(disposing); }
public override void ViewDidLoad() { base.ViewDidLoad (); View.BackgroundColor = UIColor.Clear; Front = new FrontView (reviewableVerses[0]); View.BackgroundColor = UIColor.FromPatternImage (UIImage.FromFile (Images.TableViewBackground)); Back = new BackView (reviewableVerses[position]); MemorizedImage = UIImage.FromFile (Images.HeartRedButton); NotMemorizedImage = UIImage.FromFile (Images.HeartGreyButton); TapGesture = new UITapGestureRecognizer { NumberOfTapsRequired = 1 }; TapGesture.AddTarget (FlipCardHandler); SwipeUpGesture = new UISwipeGestureRecognizer { Direction = UISwipeGestureRecognizerDirection.Up }; SwipeUpGesture.AddTarget (NextCardHandler); SwipeDownGesture = new UISwipeGestureRecognizer { Direction = UISwipeGestureRecognizerDirection.Down, }; SwipeDownGesture.AddTarget (NextCardHandler); RightSwipeGesture = new UISwipeGestureRecognizer { Direction = UISwipeGestureRecognizerDirection.Right }; RightSwipeGesture.AddTarget (RightSwipeHandler); HandleProductTourStep6 (); View.Add (Front); View.AddGestureRecognizer (SwipeUpGesture); View.AddGestureRecognizer (SwipeDownGesture); View.AddGestureRecognizer (RightSwipeGesture); View.AddGestureRecognizer (TapGesture); }
/// <summary> /// Handles the <see cref="E:ElementChanged" /> event. /// </summary> /// <param name="e">The <see cref="VisualElementChangedEventArgs"/> instance containing the event data.</param> protected override void OnElementChanged(VisualElementChangedEventArgs e) { base.OnElementChanged(e); var page = (ExtendedTabbedPage)Element; TabBar.TintColor = page.TintColor.ToUIColor(); TabBar.BarTintColor = page.BarTintColor.ToUIColor(); TabBar.BackgroundColor = page.BackgroundColor.ToUIColor(); if (!page.SwipeEnabled) { return; } var gesture1 = new UISwipeGestureRecognizer(sw => { sw.ShouldReceiveTouch += (recognizer, touch) => !(touch.View is UITableView) && !(touch.View is UITableViewCell); if (sw.Direction == UISwipeGestureRecognizerDirection.Right) { page.InvokeSwipeLeftEvent(null, null); } }) { Direction = UISwipeGestureRecognizerDirection.Right }; var gesture2 = new UISwipeGestureRecognizer(sw => { sw.ShouldReceiveTouch += (recognizer, touch) => !(touch.View is UITableView) && !(touch.View is UITableViewCell); if (sw.Direction == UISwipeGestureRecognizerDirection.Left) { page.InvokeSwipeRightEvent(null, null); } }) { Direction = UISwipeGestureRecognizerDirection.Left }; View.AddGestureRecognizer(gesture1); View.AddGestureRecognizer(gesture2); }
void FnInitializeView() { CGRect rectBounds= UIScreen.MainScreen.Bounds; flViewBringDownY = rectBounds.Height - 30f; //complete collapse viewContainer flViewShiftUpY = rectBounds.Height - 120f;//200 is the heght of viewContainer var recognizerRight = new UISwipeGestureRecognizer (FnSwipeLeftToRight); recognizerRight.Direction = UISwipeGestureRecognizerDirection.Right; View.AddGestureRecognizer ( recognizerRight ); var recognizerLeft = new UISwipeGestureRecognizer (FnSwipeRightToLeft); recognizerLeft.Direction = UISwipeGestureRecognizerDirection.Left; View.AddGestureRecognizer ( recognizerLeft ); viewDecriptionContainer.Hidden = true; btnIcon.SetBackgroundImage ( UIImage.FromBundle ( "Images/menu_icon" ) , UIControlState.Normal ); // btnBottom.SetBackgroundImage ( UIImage.FromBundle ( "Images/up_arrow" ) , UIControlState.Normal ); btnBottom.SetBackgroundImage ( UIImage.FromBundle ( "Images/down_arrow" ) , UIControlState.Selected ); btnBottom.TouchUpInside+= delegate(object sender , EventArgs e ) { if(viewDecriptionContainer.Hidden) viewDecriptionContainer.Hidden=false; if(!btnBottom.Selected) FnAnimateView(flViewShiftUpY,viewDecriptionContainer); else FnAnimateView(flViewBringDownY,viewDecriptionContainer); btnBottom.Selected = !btnBottom.Selected; }; btnIcon.TouchUpInside += delegate(object sender , EventArgs e ) { FnPerformTableTransition(); }; }
/// <summary> /// The on element changed callback. /// </summary> /// <param name="e">The event arguments.</param> protected override void OnElementChanged(ElementChangedEventArgs<Entry> e) { base.OnElementChanged(e); var view = e.NewElement as ExtendedEntry; if (view != null) { SetFont (view); SetTextAlignment (view); SetBorder (view); SetPlaceholderTextColor (view); SetMaxLength (view); ResizeHeight (); } if (e.OldElement == null) { _leftSwipeGestureRecognizer = new UISwipeGestureRecognizer(() => view.OnLeftSwipe(this, EventArgs.Empty)) { Direction = UISwipeGestureRecognizerDirection.Left }; _rightSwipeGestureRecognizer = new UISwipeGestureRecognizer(()=> view.OnRightSwipe(this, EventArgs.Empty)) { Direction = UISwipeGestureRecognizerDirection.Right }; Control.AddGestureRecognizer(_leftSwipeGestureRecognizer); Control.AddGestureRecognizer(_rightSwipeGestureRecognizer); } if (e.NewElement == null) { Control.RemoveGestureRecognizer(_leftSwipeGestureRecognizer); Control.RemoveGestureRecognizer(_rightSwipeGestureRecognizer); } }
protected override void OnElementChanged(ElementChangedEventArgs<Image> e) { base.OnElementChanged (e); if (e.NewElement is MyImage) { image = e.NewElement as MyImage; UIView view = this as UIView; view.UserInteractionEnabled = true; UISwipeGestureRecognizer gestureRecognizerLeft = new UISwipeGestureRecognizer (() => { image.SwipedLeft(); }); gestureRecognizerLeft.Direction = UISwipeGestureRecognizerDirection.Left; UISwipeGestureRecognizer gestureRecognizerRight = new UISwipeGestureRecognizer (() => { image.SwipedRight(); }); gestureRecognizerRight.Direction = UISwipeGestureRecognizerDirection.Right; view.AddGestureRecognizer (gestureRecognizerLeft); view.AddGestureRecognizer (gestureRecognizerRight); } }
private void setupSwipeControls() { UISwipeGestureRecognizer upswipe = new UISwipeGestureRecognizer (this, new Selector ("up:")); upswipe.NumberOfTouches = 1; upswipe.Direction = UISwipeGestureRecognizerDirection.Up; View.AddGestureRecognizer (upswipe); UISwipeGestureRecognizer downswipe = new UISwipeGestureRecognizer (this, new Selector ("down:")); downswipe.NumberOfTouches = 1; downswipe.Direction = UISwipeGestureRecognizerDirection.Down; View.AddGestureRecognizer (downswipe); UISwipeGestureRecognizer leftswipe = new UISwipeGestureRecognizer (this, new Selector ("left:")); leftswipe.NumberOfTouches = 1; leftswipe.Direction = UISwipeGestureRecognizerDirection.Left; View.AddGestureRecognizer (leftswipe); UISwipeGestureRecognizer rightswipe = new UISwipeGestureRecognizer (this, new Selector ("right:")); rightswipe.NumberOfTouches = 1; rightswipe.Direction = UISwipeGestureRecognizerDirection.Left; View.AddGestureRecognizer (rightswipe); }
protected override void OnElementChanged (ElementChangedEventArgs<Label> e) { base.OnElementChanged (e); longPressGestureRecognizer = new UILongPressGestureRecognizer (() => Console.WriteLine ("Long Press")); pinchGestureRecognizer = new UIPinchGestureRecognizer (() => Console.WriteLine ("Pinch")); panGestureRecognizer = new UIPanGestureRecognizer (() => Console.WriteLine ("Pan")); swipeGestureRecognizer = new UISwipeGestureRecognizer (() => Console.WriteLine ("Swipe")); rotationGestureRecognizer = new UIRotationGestureRecognizer (() => Console.WriteLine ("Rotation")); if (e.NewElement == null) { if (longPressGestureRecognizer != null) { this.RemoveGestureRecognizer (longPressGestureRecognizer); } if (pinchGestureRecognizer != null) { this.RemoveGestureRecognizer (pinchGestureRecognizer); } if (panGestureRecognizer != null) { this.RemoveGestureRecognizer (panGestureRecognizer); } if (swipeGestureRecognizer != null) { this.RemoveGestureRecognizer (swipeGestureRecognizer); } if (rotationGestureRecognizer != null) { this.RemoveGestureRecognizer (rotationGestureRecognizer); } } if (e.OldElement == null) { this.AddGestureRecognizer (longPressGestureRecognizer); this.AddGestureRecognizer (pinchGestureRecognizer); this.AddGestureRecognizer (panGestureRecognizer); this.AddGestureRecognizer (swipeGestureRecognizer); this.AddGestureRecognizer (rotationGestureRecognizer); } }
public CalendarMonthView(DateTime selectedDate, bool showHeader, float width = 320) { _showHeader = showHeader; if (_showHeader) headerHeight = 20; if (_showHeader) this.Frame = new RectangleF(0, 0, width, 218); else this.Frame = new RectangleF(0, 0, width, 198); BoxWidth = Convert.ToInt32(Math.Ceiling( width / 7 )); BackgroundColor = UIColor.White; ClipsToBounds = true; CurrentSelectedDate = selectedDate; CurrentDate = DateTime.Now.Date; CurrentMonthYear = new DateTime(CurrentSelectedDate.Year, CurrentSelectedDate.Month, 1); var swipeLeft = new UISwipeGestureRecognizer(p_monthViewSwipedLeft); swipeLeft.Direction = UISwipeGestureRecognizerDirection.Left; this.AddGestureRecognizer(swipeLeft); var swipeRight = new UISwipeGestureRecognizer(p_monthViewSwipedRight); swipeRight.Direction = UISwipeGestureRecognizerDirection.Right; this.AddGestureRecognizer(swipeRight); var swipeUp = new UISwipeGestureRecognizer(p_monthViewSwipedUp); swipeUp.Direction = UISwipeGestureRecognizerDirection.Up; this.AddGestureRecognizer(swipeUp); }
void p_monthViewSwipedRight (UISwipeGestureRecognizer ges) { MoveCalendarMonths(false, true); }
void p_monthViewSwipedLeft (UISwipeGestureRecognizer ges) { MoveCalendarMonths(true, true); }
/// <summary> /// Handles left and right swipes to hide and show the menu. /// </summary> /// <param name="swipe"></param> void HandleSwipe(UISwipeGestureRecognizer swipe) { if (!this.EnableSwipeGesture) { return; } if(swipe.State == UIGestureRecognizerState.Recognized) { this.ShowMenu(false); } }
void p_monthViewSwipedUp (UISwipeGestureRecognizer ges) { if (SwipedUp != null) SwipedUp (); }
public override void ViewDidLoad() { base.ViewDidLoad (); this.View.BackgroundColor = UIColor.FromRGB (22, 22, 22); var text = new NSString ("Begin"); var size = MeasureTextSize (text, this.View.Frame.Width, _fontSize, _fontName); _fontHeight = (float)size.Height; var frame = new Rectangle (new Point (0, (int)(this.View.Frame.Height / 2f - _fontHeight)), new Size ((int)this.View.Frame.Width, 96)); // Perform any additional setup after loading the view, typically from a nib. _begin = new UILabel (frame) { Text = "Begin", TextColor = UIColor.White, TextAlignment = UITextAlignment.Center, BackgroundColor = UIColor.FromRGBA(0,0,0,0), Font = UIFont.FromName(_fontName, _fontSize), Alpha = 0, ShadowColor = UIColor.FromRGBA(255,255,255,125), ShadowOffset = Size.Empty }; _currentTile = new MazeTile (Movements2D.Left | Movements2D.Backward | Movements2D.Forward | Movements2D.Right) { Frame = this.View.Frame, Alpha = 0 }; this.View.Add (_currentTile); this.View.Add (_begin); _swipeUp = new UISwipeGestureRecognizer (SwipedUp){ Direction = UISwipeGestureRecognizerDirection.Up }; _swipeDown = new UISwipeGestureRecognizer (SwipedDown){ Direction = UISwipeGestureRecognizerDirection.Down }; _swipeLeft = new UISwipeGestureRecognizer (SwipedLeft){ Direction = UISwipeGestureRecognizerDirection.Left }; _swipeRight = new UISwipeGestureRecognizer (SwipedRight){ Direction = UISwipeGestureRecognizerDirection.Right }; _currentTile.AddGestureRecognizer (_swipeUp); _currentTile.AddGestureRecognizer (_swipeDown); _currentTile.AddGestureRecognizer (_swipeLeft); _currentTile.AddGestureRecognizer (_swipeRight); }
public CalendarMonthView( DateTime selectedDate, bool showHeader, float width = 320 ) { if (Math.Abs(width - 320) < 0.1) width = (float) UIScreen.MainScreen.Bounds.Size.Width; this.width = width; this.showHeader = showHeader; if (showHeader) headerHeight = 20; BoxWidth = Convert.ToInt32(Math.Ceiling(width/7)) - (int) Math.Ceiling(2*HorizontalPadding/7.0); int height = BoxHeight*LinesCount + 2*VerticalPadding + 10; // Calendar view frame (header, calendar, paddings). Frame = showHeader ? new RectangleF(0, 0, width, height + headerHeight) : new RectangleF(0, 0, width, height); BackgroundColor = UIColor.White; ClipsToBounds = true; CurrentSelectedDate = selectedDate; CurrentDate = DateTime.Now.Date; CurrentMonthYear = new DateTime(CurrentSelectedDate.Year, CurrentSelectedDate.Month, 1); // Actions on swipe. var swipeLeft = new UISwipeGestureRecognizer(MonthViewSwipedLeft) { Direction = UISwipeGestureRecognizerDirection.Left }; AddGestureRecognizer(swipeLeft); var swipeRight = new UISwipeGestureRecognizer(MonthViewSwipedRight) { Direction = UISwipeGestureRecognizerDirection.Right }; AddGestureRecognizer(swipeRight); var swipeUp = new UISwipeGestureRecognizer(MonthViewSwipedUp) { Direction = UISwipeGestureRecognizerDirection.Up }; AddGestureRecognizer(swipeUp); }
private void MonthViewSwipedUp( UISwipeGestureRecognizer ges ) { SwipedUp.Dispatch(); }
private void MonthViewSwipedRight( UISwipeGestureRecognizer ges ) { // Move to previous month. MoveCalendarMonths(false, true); }
private void MonthViewSwipedLeft( UISwipeGestureRecognizer ges ) { // Move to next month. MoveCalendarMonths(true, true); }