public override void ViewDidLoad () { base.ViewDidLoad (); this.longPressRecognizer = new UILongPressGestureRecognizer (() => { if (this.longPressRecognizer.NumberOfTouches > 0) { var point = this.longPressRecognizer.LocationOfTouch (0, this.cvSpotlight); var indexPath = this.cvSpotlight.IndexPathForItemAtPoint (point); if (indexPath != null) { var cell = this.cvSpotlight.CellForItem (indexPath) as IMovieCell; if (this.longPressRecognizer.State == UIGestureRecognizerState.Began) { cell.SetHighlighted (true, true); } else if (this.longPressRecognizer.State == UIGestureRecognizerState.Ended) { cell.SetHighlighted (false, true, () => { var movie = this.spotlight [indexPath.Row]; Data.Current.ToggleFavorite (movie); }); } } else { foreach (MovieCollectionViewCell cell in this.cvSpotlight.VisibleCells) cell.SetHighlighted (false, false); } } }); this.cvSpotlight.AddGestureRecognizer (this.longPressRecognizer); var searchResults = PresentationUtility.CreateFromStoryboard<SearchResultsTableViewController> ("SearchResults"); this.search = new UISearchController (searchResults); this.search.SearchResultsUpdater = this; this.search.DimsBackgroundDuringPresentation = false; this.search.DefinesPresentationContext = true; searchResults.TableView.TableHeaderView = this.search.SearchBar; }
public override void ViewDidLoad() { base.ViewDidLoad (); // Create a custom gesture recognizer var longPressGesture = new UILongPressGestureRecognizer (gesture => { // Take action based on state switch (gesture.State) { case UIGestureRecognizerState.Began: var selectedIndexPath = CollectionView.IndexPathForItemAtPoint (gesture.LocationInView (View)); if (selectedIndexPath != null) { CollectionView.BeginInteractiveMovementForItem (selectedIndexPath); } break; case UIGestureRecognizerState.Changed: CollectionView.UpdateInteractiveMovement (gesture.LocationInView (View)); break; case UIGestureRecognizerState.Ended: CollectionView.EndInteractiveMovement (); break; default: CollectionView.CancelInteractiveMovement (); break; } }); // Add the custom recognizer to the collection view CollectionView.AddGestureRecognizer(longPressGesture); }
protected override void OnAttached() { host = Touch.GetHost(Element); View.UserInteractionEnabled = true; _layer = new UIView { UserInteractionEnabled = false, Opaque = false, Alpha = 0, TranslatesAutoresizingMaskIntoConstraints = false, }; gestureTap = new UILongPressGestureRecognizer(OnTap); gestureTap.MinimumPressDuration = 0; gestureTap.Delegate = new TouchGestureDelegate(View); TimerInit(); UpdateEffectColor(); View.AddGestureRecognizer(gestureTap); View.AddSubview(_layer); View.BringSubviewToFront(_layer); _layer.TopAnchor.ConstraintEqualTo(View.TopAnchor).Active = true; _layer.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active = true; _layer.BottomAnchor.ConstraintEqualTo(View.BottomAnchor).Active = true; _layer.RightAnchor.ConstraintEqualTo(View.RightAnchor).Active = true; }
protected override void OnElementChanged(ElementChangedEventArgs <GradientButton> e) { base.OnElementChanged(e); if (e.NewElement == null) { return; } button = e.NewElement as GradientButton; nButton = new UIButton(UIButtonType.System); nButton.TranslatesAutoresizingMaskIntoConstraints = true; nButton.Frame = new CGRect(0, 0, button.WidthRequest != -1 ? button.WidthRequest : DEFAULT_WIDTH, button.HeightRequest > 30 ? button.HeightRequest : DEFAULT_HEIGHT); button.CornerRadius = button.CornerRadius > (int)(nButton.Frame.Height / 2) ? (int)nButton.Frame.Height / 2 : button.CornerRadius; nButton.Layer.CornerRadius = button.CornerRadius; nButton.SetTitle(button.Text, UIControlState.Normal); nButton.SetTitleColor(button.TextColor.ToUIColor(), UIControlState.Normal); nButton.TitleLabel.Font = button.Font.ToUIFont(); nButton.Layer.MasksToBounds = true; nButton.TouchUpInside += Handler; var longPress = new UILongPressGestureRecognizer(); longPress.AddTarget(() => button.SendLongClick()); nButton.GestureRecognizers = new UIGestureRecognizer[] { longPress }; SetNativeControl(nButton); }
void HandleLongPress(UILongPressGestureRecognizer sender) { if (sender.State != UIGestureRecognizerState.Ended) { return; } var point = sender.LocationInView(TableView); var indexPath = TableView.IndexPathForRowAtPoint(point); var attributeCell = TableView.CellAt(indexPath) as AttributeTableViewCell; var attributeValue = attributeCell?.AttributeValue; if (attributeValue == null) { return; } BecomeFirstResponder(); selectedAttributeValue = attributeValue.Text ?? string.Empty; var menuController = UIMenuController.SharedMenuController; menuController.SetTargetRect(attributeValue.Frame, attributeCell); menuController.MenuItems = new UIMenuItem [] { new UIMenuItem("Copy attribute value", new Selector("copyAttributeToClipboard:")) }; menuController.SetMenuVisible(true, true); }
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); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Create a custom gesture recognizer var longPressGesture = new UILongPressGestureRecognizer((gesture) => { // Take action based on state switch (gesture.State) { case UIGestureRecognizerState.Began: var selectedIndexPath = CollectionView.IndexPathForItemAtPoint(gesture.LocationInView(View)); if (selectedIndexPath != null) { CollectionView.BeginInteractiveMovementForItem(selectedIndexPath); } break; case UIGestureRecognizerState.Changed: CollectionView.UpdateInteractiveMovementTargetPosition(gesture.LocationInView(View)); break; case UIGestureRecognizerState.Ended: CollectionView.EndInteractiveMovement(); break; default: CollectionView.CancelInteractiveMovement(); break; } }); // Add the custom recognizer to the collection view CollectionView.AddGestureRecognizer(longPressGesture); }
private void PressHandler(UILongPressGestureRecognizer gestureRecognizer) { var image = gestureRecognizer.View; if (gestureRecognizer.State == UIGestureRecognizerState.Began) { var locationTouched = gestureRecognizer.LocationInView(View); var nodeAtLocation = GetNodeAtPoint(locationTouched); // If no Info Text is visible update the nodes with a blur factor if (nodeAtLocation.Name != "infoNode" && nodeAtLocation.Name != "infoLabel") { nfloat coordX = locationTouched.X; nfloat coordY = locationTouched.Y; SetDimensions(coordX, coordY); if (blurFactor == 1) { blurFactor = 5; UpdateBlurNode(blurFactor); } else { blurFactor = 1; UpdateBlurNode(blurFactor); } // Add vibration that user recognizes that the nodes are changing SystemSound.Vibrate.PlaySystemSound(); } } }
//ViewDidLoad-Methode (wird beim instanzieren der View aufgerufen) public override void ViewDidLoad() { base.ViewDidLoad(); //Initialisieren der TaskList taskList = new List <Task>(); //Verbinden der TableSource mit unserer TableView "tableTasks" tableSource = new TableSource(this, taskList); tableTasks.Source = tableSource; //ausgelagertes TouchUpInside-Event unseres Add-Buttons btnAdd.TouchUpInside += BtnAdd_TouchUpInside; //ausgelagertes TouchUpInside-Event unseres Edit-Buttons btnEdit.TouchUpInside += BtnEdit_TouchUpInside; //ausgelagertes TouchUpInside-Event unseres Delete-Buttons btnDelete.TouchUpInside += BtnDelete_TouchUpInside; //LongPress-Gesture der TableView hinzufügen UILongPressGestureRecognizer longPressGestureRecognizer = new UILongPressGestureRecognizer(LongPress); tableTasks.AddGestureRecognizer(longPressGestureRecognizer); //Swipe-Gesture der TableView hinzufügen UISwipeGestureRecognizer leftSwipeGesture = new UISwipeGestureRecognizer(SwipeLeftToRight) { Direction = UISwipeGestureRecognizerDirection.Left }; tableTasks.AddGestureRecognizer(leftSwipeGesture); }
private UILabel CreateLabel(LinkString.Part part) { UILabel label = new UILabel(); label.Font = this.Font; label.HighlightedTextColor = this.TintColor; label.Text = part.Text; label.TextColor = this.TextColor; label.TranslatesAutoresizingMaskIntoConstraints = false; if (part.HasHandler) { UILongPressGestureRecognizer pressGesture = new UILongPressGestureRecognizer(gesture => this.OnPartPressed(gesture, part, label)); pressGesture.MinimumPressDuration = 0.001; label.AddGestureRecognizer(pressGesture); label.UserInteractionEnabled = true; this.SetUnderLineStyle(label, NSUnderlineStyle.Single); } label.SizeToFit(); return(label); }
protected override void OnDetached() { base.OnDetached(); _view.RemoveGestureRecognizer(_tapGesture); _tapGesture.Dispose(); _tapGesture = null; if (_longTapGesture != null) { _view.RemoveGestureRecognizer(_longTapGesture); _longTapGesture.Dispose(); _longTapGesture = null; } if (_command != null) { _command.CanExecuteChanged -= CommandCanExecuteChanged; } if (_longCommand != null) { _longCommand.CanExecuteChanged -= CommandCanExecuteChanged; } _command = null; _longCommand = null; _commandParameter = null; _longCommandParameter = null; _view = null; System.Diagnostics.Debug.WriteLine($"Detached {GetType().Name} from {Element.GetType().FullName}"); }
public RecyclerUICollectionView(RecyclerViewRenderer renderer, CGRect frame, UICollectionViewLayout layout) : base(frame, layout) { RendererReference = new WeakReference <RecyclerViewRenderer>(renderer); LongPressGestureRecognizer = new UILongPressGestureRecognizer(this, new ObjCRuntime.Selector(nameof(LongPressGestureRecognizer))); AddGestureRecognizer(LongPressGestureRecognizer); }
public override void ViewDidLoad() { base.ViewDidLoad(); tableView.Source = new TableSource(); tableSource = (TableSource)tableView.Source; dbHelper.CreateDB(); tableSource.taskList = dbHelper.getAllTasks(); UIBarButtonItem buttonAdd = new UIBarButtonItem(UIBarButtonSystemItem.Add, (sender, args) => { CreateAlertDialog(tableSource); }); UIBarButtonItem buttonDeleteAll = new UIBarButtonItem(UIBarButtonSystemItem.Trash, (object sender, EventArgs args) => { dbHelper.deleteAllTasks(); tableSource.taskList.Clear(); tableView.ReloadData(); }); UIBarButtonItem[] buttons = new UIBarButtonItem[] { buttonAdd, buttonDeleteAll }; NavigationItem.SetRightBarButtonItems(buttons, false); UILongPressGestureRecognizer longPressGestureRecognizer = new UILongPressGestureRecognizer(LongPress); tableView.AddGestureRecognizer(longPressGestureRecognizer); UISwipeGestureRecognizer leftSwipeGesture = new UISwipeGestureRecognizer(SwipeLefttoRight) { Direction = UISwipeGestureRecognizerDirection.Right }; tableView.AddGestureRecognizer(leftSwipeGesture); }
private void SetUpCustomMap() { _mKMapView.ZoomEnabled = true; _mKMapView.ScrollEnabled = true; CLLocationManager locationManager = new CLLocationManager(); locationManager.RequestWhenInUseAuthorization(); _mKMapView.ShowsUserLocation = true; _mKMapView.DidUpdateUserLocation += delegate { if (_mKMapView.UserLocation != null) { CLLocationCoordinate2D coordinateUser = _mKMapView.UserLocation.Coordinate; MKCoordinateSpan coordinateSpanUser = new MKCoordinateSpan(0.02, 0.02); _mKMapView.Region = new MKCoordinateRegion(coordinateUser, coordinateSpanUser); } }; if (!_mKMapView.UserLocationVisible) { CLLocationCoordinate2D coords = new CLLocationCoordinate2D(49.99181, 36.23572); MKCoordinateSpan span = new MKCoordinateSpan(0.05, 0.05); _mKMapView.Region = new MKCoordinateRegion(coords, span); } var longGesture = new UILongPressGestureRecognizer(LongPress); longGesture.MinimumPressDuration = 0.5; _mKMapView.AddGestureRecognizer(longGesture); _mKMapView.GetViewForAnnotation += GetViewForAnnotation; }
/// <summary> /// Show the specified uivMainContainerView, uivcMainController and location. /// </summary> /// <param name="uivMainContainerView">Uiv main container view.</param> /// <param name="uivcMainController">Uivc main controller.</param> /// <param name="location">Location.</param> public void Show(UIView uivMainContainerView, UIViewController uivcMainController, Point location) { //define scroll view width scrollViewWidth = uivMainContainerView.Frame.Width; //change location Location = location; //add group view to main view uivMainContainerView.AddSubview(vwStoryCardView); //assign controller and container this.uivcMainController = uivcMainController; //add gestures recognizers UITapGestureRecognizer tapGesture = new UITapGestureRecognizer(Tap); UIPinchGestureRecognizer pinchGesture = new UIPinchGestureRecognizer(Pinch); UISwipeGestureRecognizer swipeGesture = new UISwipeGestureRecognizer(Swipe); UILongPressGestureRecognizer longPressGesture = new UILongPressGestureRecognizer(LongPress); vwStoryCardView.AddGestureRecognizer(tapGesture); vwStoryCardView.AddGestureRecognizer(pinchGesture); vwStoryCardView.AddGestureRecognizer(swipeGesture); vwStoryCardView.AddGestureRecognizer(longPressGesture); }
void HandleGesture(UILongPressGestureRecognizer gesture) { if(gesture.State == UIGestureRecognizerState.Began) { if (handler != null) handler (gesture); } }
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); }
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; }
private void SetupGestureInteraction() { this.longPress = new UILongPressGestureRecognizer(); this.longPress.AddTarget(this, new MonoTouch.ObjCRuntime.Selector("HandleLongPress")); this.longPress.Delegate = new GestureRecognizerDelegate(); this.View.AddGestureRecognizer(longPress); }
public void handleLongPress (UILongPressGestureRecognizer recognizer) { if (recognizer.State == UIGestureRecognizerState.Began) { PointF longPressPoint = recognizer.LocationInView (mainMapView); dropPinAtPoint (longPressPoint); } }
public override void ViewDidLoad () { base.ViewDidLoad (); this.imgBackground.Alpha = 0.3f; this.longPressRecognizer = new UILongPressGestureRecognizer (() => { if (this.longPressRecognizer.NumberOfTouches > 0) { var point = this.longPressRecognizer.LocationOfTouch (0, this.cvSimilarMovies); var indexPath = this.cvSimilarMovies.IndexPathForItemAtPoint (point); if (indexPath != null) { var cell = this.cvSimilarMovies.CellForItem (indexPath) as MovieCollectionViewCell; if (this.longPressRecognizer.State == UIGestureRecognizerState.Began) { cell.SetHighlighted (true, true); } else if (this.longPressRecognizer.State == UIGestureRecognizerState.Ended) { cell.SetHighlighted (false, true, () => { var movie = this.similarMovies [indexPath.Row]; Data.Current.ToggleFavorite (movie); }); } } else { foreach (MovieCollectionViewCell cell in this.cvSimilarMovies.VisibleCells) cell.SetHighlighted (false, false); } } }); this.cvSimilarMovies.AddGestureRecognizer (this.longPressRecognizer); }
private void DD() { int from = -1; NSIndexPath pathTo = null; //var draggedViewCell = null; var longPressGesture = new UILongPressGestureRecognizer(gesture => { switch (gesture.State) { case UIGestureRecognizerState.Began: var selectedIndexPath = Control.IndexPathForRowAtPoint(gesture.LocationInView(Control)); if (selectedIndexPath != null) { from = (int)selectedIndexPath.Item; var cell = Control.CellAt(selectedIndexPath); cell.DragStateDidChange(UITableViewCellDragState.Dragging); } break; case UIGestureRecognizerState.Changed: break; case UIGestureRecognizerState.Ended: break; default: break; } }); Control.AddGestureRecognizer(longPressGesture); }
private void showUserMap() { map.MapType = MKMapType.HybridFlyover; map.ShowsUserLocation = true; map.ZoomEnabled = true; map.ScrollEnabled = true; map.ShowsBuildings = true; map.PitchEnabled = true; map.ShowsCompass = false; double lat = 30.2652233534254; double lon = -97.73815460962083; CLLocationCoordinate2D mapCenter = new CLLocationCoordinate2D(lat, lon); CLLocationCoordinate2D viewPoint = new CLLocationCoordinate2D(lat + 0.0050, lon - 0.0072); MKCoordinateRegion mapRegion = MKCoordinateRegion.FromDistance(mapCenter, 1500, 1500); map.CenterCoordinate = mapCenter; map.Region = mapRegion; var camera = MKMapCamera.CameraLookingAtCenterCoordinate(mapCenter, viewPoint, 500); map.Camera = camera; mapDelegate = new MapDelegate(); map.Delegate = mapDelegate; askUserPermissions(); var tapRecogniser = new UITapGestureRecognizer(this, new Selector("MapTapSelector:")); var longTapRecogniser = new UILongPressGestureRecognizer(this, new Selector("MapLongTapSelector:")); map.AddGestureRecognizer(tapRecogniser); map.AddGestureRecognizer(longTapRecogniser); var hotelOverlay = MKCircle.Circle(mapCenter, 1000); map.AddOverlay(hotelOverlay); }
private void HandlePress(UILongPressGestureRecognizer press) { var location = press.LocationInView(Control); switch (press.State) { case UIGestureRecognizerState.Began: var gestureRecognizers = new List <Tuple <MycoView, IMycoGestureRecognizerController> >(); (Element as IMycoController).GetGestureRecognizers(new Xamarin.Forms.Point(location.X, location.Y), gestureRecognizers); _activeGestures.Clear(); foreach (var gesture in gestureRecognizers) { gesture.Item2.SendTouchDown(gesture.Item1, location.X - gesture.Item1.RenderBounds.X, location.Y - gesture.Item1.RenderBounds.Y); _activeGestures.Add(gesture); } break; case UIGestureRecognizerState.Failed: case UIGestureRecognizerState.Cancelled: case UIGestureRecognizerState.Ended: foreach (var gesture in _activeGestures) { var isCanceled = !gesture.Item1.RenderBounds.Contains(new Xamarin.Forms.Point(location.X, location.Y)); gesture.Item2.SendTouchUp(gesture.Item1, location.X - gesture.Item1.RenderBounds.X, location.Y - gesture.Item1.RenderBounds.Y, isCanceled); } _activeGestures.Clear(); break; } }
public void SetupCollectionView() { if (LongPressGestureRecognizer != null) { CollectionView.RemoveGestureRecognizer(LongPressGestureRecognizer); } if (PanGestureRecognizer != null) { CollectionView.RemoveGestureRecognizer(PanGestureRecognizer); } LongPressGestureRecognizer = new UILongPressGestureRecognizer(HandleLongPressGesture); LongPressGestureRecognizer.Delegate = new DraggableGestureRecognizerDelegate(this); foreach (var gestureRecognizer in CollectionView.GestureRecognizers) { if (gestureRecognizer is UILongPressGestureRecognizer) { gestureRecognizer.RequireGestureRecognizerToFail(LongPressGestureRecognizer); } } CollectionView.AddGestureRecognizer(LongPressGestureRecognizer); PanGestureRecognizer = new UIPanGestureRecognizer(HandlePanGesture); PanGestureRecognizer.Delegate = new DraggableGestureRecognizerDelegate(this); CollectionView.AddGestureRecognizer(PanGestureRecognizer); NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.WillResignActiveNotification, HandleApplicationWillResignActive); }
void UpdateLongCommand() { _longCommand = AddCommand.GetLongCommand(Element); if (_longTapGesture != null) { _view.RemoveGestureRecognizer(_longTapGesture); _longTapGesture.Dispose(); } if (_longCommand == null) { return; } _longTapGesture = new UILongPressGestureRecognizer(async(obj) => { if (obj.State == UIGestureRecognizerState.Began) { _longCommand?.Execute(_longCommandParameter ?? Element); await TapAnimation(0.5, 0, _alpha, false); } else if (obj.State == UIGestureRecognizerState.Ended || obj.State == UIGestureRecognizerState.Cancelled || obj.State == UIGestureRecognizerState.Failed) { await TapAnimation(0.5, _alpha, 0); } }); _view.AddGestureRecognizer(_longTapGesture); }
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; }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); var longPressGesture = new UILongPressGestureRecognizer(gestureRecognizer => { if (gestureRecognizer.State == UIGestureRecognizerState.Began) { Editing = !Editing; } }); View.AddGestureRecognizer(longPressGesture); Title = Localization.VacationsPageTitle; var barItem = new UIBarButtonItem(UIImage.FromBundle("add"), UIBarButtonItemStyle.Plain, async(sender, args) => { var vac = new VacationModel(); vac.Id = await Context.App.Factory.Resolve <IVacationProvider>().AddAsync(vac); _itemsSource.Add(vac); ((UITableView)View).ReloadData(); } ); NavigationItem.SetLeftBarButtonItem(barItem, true); TableView.RegisterClassForCellReuse(typeof(VacationInfoCell), ReuseId); }
private void UpdateCurrentLocation(UILongPressGestureRecognizer gesture) { NSIndexPath indexPath = null; var location = new PointF(); // refresh index path location = gesture.LocationInView(this); indexPath = IndexPathForRowAtPoint(location); indexPath = Source.CustomizeMoveTarget(this, initialIndexPath, indexPath); // if (RespondsToSelector(tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:)]) { // indexPath = TargetIndexPathForMoveFromRowAtIndexPath(InitialIndexPath, indexPath); // } var oldHeight = RectForRowAtIndexPath(currentLocationIndexPath).Size.Height; var newHeight = RectForRowAtIndexPath(indexPath).Size.Height; if (indexPath != null && !indexPath.Equals(currentLocationIndexPath) && gesture.LocationInView(CellAt(indexPath)).Y > newHeight - oldHeight) { BeginUpdates(); DeleteRows(new NSIndexPath[] { currentLocationIndexPath }, UITableViewRowAnimation.Automatic); InsertRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Automatic); ((IReorder)Source).MoveRowAtIndexPath(currentLocationIndexPath, indexPath); currentLocationIndexPath = indexPath; EndUpdates(); } }
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); } }
public void Bind (MovieCategory data, ConfigurationResponse configuration, Action<Movie> selectionAction) { this.category = data; this.configuration = configuration; this.selectionAction = selectionAction; this.lblCategoryName.Text = this.category.CategoryName; this.collectionViewSource = new MovieCollectionViewSource (this.category.Movies, this.configuration); this.collectionViewSource.MovieSelected += this.collectionViewSource_MovieSelected; Data.Current.FavoriteChanged += this.favoriteChanged; this.longPressRecognizer = new UILongPressGestureRecognizer (() => { if (this.longPressRecognizer.NumberOfTouches > 0) { var point = this.longPressRecognizer.LocationOfTouch (0, this.cvMovies); var indexPath = this.cvMovies.IndexPathForItemAtPoint (point); if (indexPath != null) { var cell = this.cvMovies.CellForItem (indexPath) as MovieCollectionViewCell; if (this.longPressRecognizer.State == UIGestureRecognizerState.Began) { cell.SetHighlighted (true, true); } else if (this.longPressRecognizer.State == UIGestureRecognizerState.Ended) { cell.SetHighlighted (false, true, () => { var movie = this.category.Movies [indexPath.Row]; Data.Current.ToggleFavorite (movie); }); } } else { foreach (MovieCollectionViewCell cell in this.cvMovies.VisibleCells) cell.SetHighlighted (false, false); } } }); this.cvMovies.AddGestureRecognizer (this.longPressRecognizer); this.cvMovies.Source = this.collectionViewSource; this.cvMovies.ReloadData (); }
public void setUpGesture() { longPress = new UILongPressGestureRecognizer(); longPress.AddTarget(this, new ObjCRuntime.Selector("HandleLongPress:")); longPress.Delegate = new GestureDelegate(); View.AddGestureRecognizer(longPress); }
/// <summary> /// Sets up the gestures to display and dismiss the menu performing the paste operation on the pin board. /// </summary> void SetupPasteMenu() { var longPressGesture = new UILongPressGestureRecognizer((longPress) => { if (longPress.State == UIGestureRecognizerState.Began) { DropPoint = longPress.LocationInView(View); // Only show the paste menu if we are // not over an image in the pin board. if (ImageIndex(DropPoint) < 0) { View.BecomeFirstResponder(); var menu = UIMenuController.SharedMenuController; var rect = new CGRect(DropPoint, new CGSize(10, 10)); menu.SetTargetRect(rect, View); menu.SetMenuVisible(true, true); } } else if (longPress.State == UIGestureRecognizerState.Cancelled) { UIMenuController.SharedMenuController.SetMenuVisible(false, true); } }); View.AddGestureRecognizer(longPressGesture); var tapGesture = new UITapGestureRecognizer((obj) => { UIMenuController.SharedMenuController.SetMenuVisible(false, true); }); View.AddGestureRecognizer(tapGesture); }
private void HandleLongClick(UILongPressGestureRecognizer recognizer) { if (recognizer.State == UIGestureRecognizerState.Ended) { var command = PressedEffect.GetLongTapCommand(Element); command?.Execute(PressedEffect.GetLongParameter(Element)); } }
public void handleLongPress(UILongPressGestureRecognizer recognizer) { if (recognizer.State == UIGestureRecognizerState.Began) { CGPoint longPressPoint = recognizer.LocationInView(mainMapView); dropPinAtPoint(longPressPoint); } }
public void setUpGesture () { longPress = new UILongPressGestureRecognizer (); longPress.AddTarget (this, new MonoTouch.ObjCRuntime.Selector ("HandleLongPress")); longPress.Delegate = new GestureDelegate (); View.AddGestureRecognizer (longPress); }
partial void HandleLongPress(UILongPressGestureRecognizer recognizer) { if (recognizer.State == UIGestureRecognizerState.Began) { var longPressPoint = recognizer.LocationInView(mapView); DropPinAtPoint(longPressPoint); } }
private void on_longpress(UILongPressGestureRecognizer gr) { if (gr.State == UIGestureRecognizerState.Ended) { var wh = gr.LocationInView(this); _dp.do_longpress(wh.X, wh.Y); } }
private void ViewLongPressed(UILongPressGestureRecognizer tapInfo) { if (tapInfo.State == UIGestureRecognizerState.Ended) { State = NextState(); UpdateLayer(); } }
private void onLongPress(UILongPressGestureRecognizer gesture) { if (shouldSkipGesture(gesture)) { return; } fireEvent(OnUserLongPress, gesture); }
public void LongPress(UILongPressGestureRecognizer gesture) { var point = gesture.LocationInView(Table); var indexPath = Table.IndexPathForRowAtPoint(point); if (indexPath == null) return; View.Model.RowLongPressed(indexPath.Section, indexPath.Row); }
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); }
public override void PrepareForReuse () { if (this.collectionViewSource != null) this.collectionViewSource.MovieSelected -= this.collectionViewSource_MovieSelected; this.collectionViewSource = null; this.category = null; this.configuration = null; this.selectionAction = null; this.cvMovies.RemoveGestureRecognizer (this.longPressRecognizer); this.longPressRecognizer = null; base.PrepareForReuse (); }
private static void OnRecognizing(UILongPressGestureRecognizer r) { LongPressGestureRecognizer recognizer = r as LongPressGestureRecognizer; UITableView tableView; recognizer.TableView.TryGetTarget(out tableView); ViewCell cell; recognizer.ViewCell.TryGetTarget(out cell); if (tableView == null || cell == null) { return; } OnRecognizing(recognizer, tableView, cell); }
public LongPressElement(ShoppingItem item, MonoTouch.Foundation.NSAction tappedAction,MonoTouch.Foundation.NSAction longPressAction) : base(item.Item,tappedAction) { this.item = item; this.longPressAction = longPressAction; gester = new UILongPressGestureRecognizer (); gester.Delegate = new LongPressGestureDelegate (); gester.MinimumPressDuration = .5; gester.AddTarget (x => { if ((x as UILongPressGestureRecognizer).State == UIGestureRecognizerState.Began) { longPressAction(); } }); }
public override void ViewDidLoad() { tableView.WeakDataSource = this; tableView.WeakDelegate = this; this.View.BackgroundColor = GlobalTheme.BackgroundColor; viewSync.BackgroundColor = GlobalTheme.BackgroundColor; btnSelect.SetTitle("Select all", UIControlState.Normal); activityIndicator.StartAnimating(); UILongPressGestureRecognizer longPress = new UILongPressGestureRecognizer(HandleLongPress); longPress.MinimumPressDuration = 0.7f; longPress.WeakDelegate = this; tableView.AddGestureRecognizer(longPress); var btnSync = new SessionsFlatButton(); btnSync.LabelAlignment = UIControlContentHorizontalAlignment.Right; btnSync.Label.Text = "Sync"; btnSync.Label.TextAlignment = UITextAlignment.Right; btnSync.Label.Frame = new RectangleF(0, 0, 44, 44); btnSync.ImageChevron.Image = UIImage.FromBundle("Images/Tables/chevron_blue"); btnSync.ImageChevron.Frame = new RectangleF(70 - 22, 0, 22, 44); btnSync.Frame = new RectangleF(0, 0, 70, 44); btnSync.OnButtonClick += HandleButtonSyncTouchUpInside; var btnSyncView = new UIView(new RectangleF(UIScreen.MainScreen.Bounds.Width - 70, 0, 70, 44)); var rect2 = new RectangleF(btnSyncView.Bounds.X - 16, btnSyncView.Bounds.Y, btnSyncView.Bounds.Width, btnSyncView.Bounds.Height); btnSyncView.Bounds = rect2; btnSyncView.AddSubview(btnSync); _btnSync = new UIBarButtonItem(btnSyncView); NavigationItem.SetRightBarButtonItem(_btnSync, true); viewLoading.Hidden = false; viewSync.Hidden = true; tableView.Hidden = true; if (UIDevice.CurrentDevice.CheckSystemVersion(7, 0)) { NavigationController.InteractivePopGestureRecognizer.WeakDelegate = this; NavigationController.InteractivePopGestureRecognizer.Enabled = true; } var navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>(); navigationManager.BindSyncMenuView(this, _device); base.ViewDidLoad(); }
public override void LoadView () { RectangleF rect = UIScreen.MainScreen.Bounds; View = new UIView (rect); commentView = commentViewController.View; commentView.Layer.CornerRadius = 8.0f; commentView.Alpha = 0.0f; contentController.View.Frame = rect; commentView.Bounds = new RectangleF (0.0f, 0.0f, rect.Size.Width / 2.0f, rect.Size.Height / 4.0f); View.AddSubview (contentController.View); UILongPressGestureRecognizer gestureRecognizer = new UILongPressGestureRecognizer (this, new MonoTouch.ObjCRuntime.Selector ("LongPressGesture")); View.AddGestureRecognizer (gestureRecognizer); # if USE_AUTOLAYOUT commentView.TranslatesAutoresizingMaskIntoConstraints = false; # endif }
void LongPress(UILongPressGestureRecognizer gesture) { LichThiCell cell = (LichThiCell )gesture.View; VCHomeReminder remid = new VCHomeReminder (controller); remid.lt = tableItems [cell.num]; LTRemindItem rmItem = BRemind.GetLTRemind (SQLite_iOS.GetConnection (), remid.lt.MaMH, remid.lt.NamHoc, remid.lt.HocKy); if (rmItem != null) { remid.LoadEvent (rmItem.EventID,null); } else { remid.RemindLT (); } }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear (animated); btnTotems.TouchUpInside += btnTotemsTouchUpInsideHandler; btnEigenschappen.TouchUpInside += btnEigenschappenTouchUpInside; btnProfielen.TouchUpInside += btnProfielenTouchUpInside; btnChecklist.TouchUpInside += BtnChecklistTouchUpInside; btnTip.TouchUpInside += ShowTipPopup; //long press on title var uitgr = new UILongPressGestureRecognizer(TapTitle); uitgr.MinimumPressDuration = 0.5; lblTitle.AddGestureRecognizer(uitgr); _appController.NavigationController.GotoTotemListEvent += gotoTotemListHandler; _appController.NavigationController.GotoEigenschapListEvent += gotoEigenschapListHandler; _appController.NavigationController.GotoProfileListEvent += gotoProfileListHandler; _appController.NavigationController.GotoChecklistEvent += gotoChecklistEvent; }
public override async void ViewDidLoad () { base.ViewDidLoad (); this.Title = "Popular Events"; this.TabBarController.TabBar.TintColor = UIColor.White; ParentViewController.NavigationController.SetNavigationBarHidden (true, true); NavigationItem.SetRightBarButtonItem( new UIBarButtonItem("Sign Out", UIBarButtonItemStyle.Plain, (object sender, EventArgs e) => { ParentViewController.NavigationController.DismissViewController(true, null); RestAPI.Session = null; KeychainUtil.ClearCredential(); Database.DB.ClearDatabase(); }), true); var infoButton = new UIBarButtonItem("", UIBarButtonItemStyle.Plain, (object sender, EventArgs e) => { Console.WriteLine("Info button pressed..."); }); NavigationItem.SetLeftBarButtonItem (infoButton, true); var gestureRecognizer = new UILongPressGestureRecognizer ((UILongPressGestureRecognizer gesture) => { if (gesture.State == UIGestureRecognizerState.Began) { Console.WriteLine("Info button long pressed..."); PerformSegue("SegueToBuildInfo", this); } }); gestureRecognizer.MinimumPressDuration = 1.0; // 1 second infoButton.GetView().AddGestureRecognizer (gestureRecognizer); var events = Database.DB.GetEventsStartingAtDate (DateTime.Today); tableSource = new EventTableSource<HomeTableViewController> (events, this, "HomeTableCellId"); TableView.Source = tableSource; await UpdateEvents (); // Get favorites on first load, so the heart buttons will be correctly populated // when navigating to an event. if (firstLoad) { await GetFavorites (); firstLoad = false; } }
//fades info in and back out (after two seconds) public void TapTitle(UILongPressGestureRecognizer uitgr) { if (!info) { info = true; //fade in UIView.Animate (0.3, () => { lblInfo.Alpha = 1; }); TaskScheduler uiContext = TaskScheduler.FromCurrentSynchronizationContext (); Task.Delay (2000).ContinueWith (task => { //fade out UIView.Animate (0.5, () => { lblInfo.Alpha = 0; }); info = false; }, uiContext); } }
public void Bind (MovieCategory data, ConfigurationResponse configuration, Action<Movie> selectionAction) { this.category = data; this.configuration = configuration; this.selectionAction = selectionAction; this.lblCategoryName.Text = this.category.CategoryName; this.collectionViewSource = new MovieCollectionViewSource (this.category.Movies, this.configuration); this.collectionViewSource.MovieSelected += this.collectionViewSource_MovieSelected; this.longPressRecognizer = new UILongPressGestureRecognizer (() => { if (this.longPressRecognizer.NumberOfTouches > 0) { var point = this.longPressRecognizer.LocationOfTouch (0, this.cvMovies); var indexPath = this.cvMovies.IndexPathForItemAtPoint (point); if (indexPath != null) { var cell = this.cvMovies.CellForItem (indexPath) as MovieCollectionViewCell; if (this.longPressRecognizer.State == UIGestureRecognizerState.Began) { cell.SetHighlighted (true); } else { if (this.longPressRecognizer.State != UIGestureRecognizerState.Ended) return; var movie = this.category.Movies [indexPath.Row]; if (Data.Current.IsInFavorites (movie)) Data.Current.RemoveFromFavorites (movie); else Data.Current.AddToFavorites (movie); cell.SetHighlighted (false); NSNotificationCenter.DefaultCenter.PostNotificationName ("FavoriteListChanged", this); } } else { foreach (MovieCollectionViewCell cell in this.cvMovies.VisibleCells) cell.SetHighlighted (false, false); } } }); this.cvMovies.AddGestureRecognizer (this.longPressRecognizer); this.cvMovies.Source = this.collectionViewSource; this.cvMovies.ReloadData (); }
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) { // in a Storyboard, Dequeue will ALWAYS return a cell, if (!isHeader) { LichThiCell cell = tableView.DequeueReusableCell (cellIdentifier) as LichThiCell; if (cell == null) { cell = new LichThiCell (cellIdentifier); } MonHoc mh = BMonHoc.GetMH (SQLite_iOS.GetConnection (), tableItems [indexPath.Row].MaMH); LTRemindItem rmItem = BRemind.GetLTRemind (SQLite_iOS.GetConnection (), tableItems [indexPath.Row].MaMH, tableItems [indexPath.Row].NamHoc, tableItems [indexPath.Row].HocKy); bool hasRM = false; if (rmItem != null) { hasRM = true; } cell.UpdateCell (mh.TenMH, tableItems [indexPath.Row].NgayThi, tableItems [indexPath.Row].PhongThi ,tableItems [indexPath.Row].GioBD,indexPath.Row,hasRM); UILongPressGestureRecognizer longPress = new UILongPressGestureRecognizer (LongPress); cell.AddGestureRecognizer (longPress); if (indexPath.Row % 2 != 0) { cell.BackgroundColor = UIColor.FromRGBA((float)0.8, (float)0.8, (float)0.8, (float)1); } else { cell.BackgroundColor = UIColor.White; } return cell; // now set the properties as normal } else { LichThiCell cell = tableView.DequeueReusableCell (cellIdentifier) as LichThiCell; if (cell == null) { cell = new LichThiCell (cellIdentifier,true); } return cell; } }
async void LongPress(UILongPressGestureRecognizer gesture) { if (gesture.State == UIGestureRecognizerState.Ended) { LichHocHKCell cell = (LichHocHKCell)gesture.View; string monhoc = BMonHoc.GetMH (SQLite_iOS.GetConnection (), BLichHoc.GetLH (SQLite_iOS.GetConnection (), tableItems [cell.num].Id).MaMH).TenMH; VCHomeReminder remid = new VCHomeReminder (controller); List<LHRemindItem> rmItem=BRemind.GetLHRemind(SQLite_iOS.GetConnection (),tableItems [cell.num].Id); bool hasRM=false; if (rmItem.Count>0) { hasRM=true; } if (!hasRM) { remid.lh = BLichHoc.GetLH (SQLite_iOS.GetConnection (), tableItems [cell.num].Id); List<LichHoc> list = new List<LichHoc> (); list.Add (remid.lh); var mycontent = ShowAlert (monhoc); string content = await mycontent; await remid.RemindALLLH (list, content); if (VCLichHoc.instance != null) VCLichHoc.Instance.LoadData (); if (VCLichHocTuan.instance != null) VCLichHocTuan.Instance.LoadData_Tuan (VCLichHocTuan.LoadedDate); } else { bool accepted = await ShowAlert("Xoá Nhắc Lịch", "Bạn muốn xoá hết các nhắc lịch cho môn "+monhoc); if (accepted) { remid.RemoveEvents (rmItem); UIAlertView _error = new UIAlertView ("Xoá Nhắc Lịch", "Xoá Nhắc Lịch Thành Công", null, "Ok", null); _error.Show (); } } } }
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) { if (!isHeader) { LichHocHKCell cell = tableView.DequeueReusableCell (cellIdentifier) as LichHocHKCell; if (cell == null) { cell = new LichHocHKCell (cellIdentifier); } string monhoc = BMonHoc.GetMH (SQLite_iOS.GetConnection (), BLichHoc.GetLH (SQLite_iOS.GetConnection (), tableItems [indexPath.Row].Id).MaMH).TenMH; List<LHRemindItem> rmItem=BRemind.GetLHRemind(SQLite_iOS.GetConnection (),tableItems [indexPath.Row].Id); bool hasRM=false; if (rmItem.Count>0) { hasRM=true; } cell.UpdateCell (monhoc, tableItems [indexPath.Row].Thu, tableItems [indexPath.Row].TietBatDau , tableItems [indexPath.Row].SoTiet,tableItems [indexPath.Row].Phong,indexPath.Row,hasRM); UILongPressGestureRecognizer longPress = new UILongPressGestureRecognizer (LongPress); cell.AddGestureRecognizer (longPress); if (indexPath.Row % 2 != 0) { cell.BackgroundColor = UIColor.FromRGBA ((float)0.8, (float)0.8, (float)0.8, (float)1); } else { cell.BackgroundColor = UIColor.White; } return cell; // now set the properties as normal } else { LichHocHKCell cell = tableView.DequeueReusableCell (cellIdentifier) as LichHocHKCell; if (cell == null) { cell = new LichHocHKCell (cellIdentifier, true); } return cell; } }
public override void ViewDidLoad () { base.ViewDidLoad (); var screenBounds = UIScreen.MainScreen.Bounds; var length = Math.Floor (0.1 * Math.Max (screenBounds.Width, screenBounds.Height)); itemView = new UIView (new CGRect (0.0, 0.0, length, Math.Floor (length / ItemAspectRatio))) { AutoresizingMask = UIViewAutoresizing.None, BackgroundColor = UIColor.Red }; var panGestureRecognizer = new UIPanGestureRecognizer (Pan); itemView.AddGestureRecognizer (panGestureRecognizer); View.AddSubview (itemView); var longPressGestureRecognizer = new UILongPressGestureRecognizer (LongPress); View.AddGestureRecognizer (longPressGestureRecognizer); animator = new UIDynamicAnimator (View); stickyBehavior = new StickyCornersBehavior (itemView, (float)length * 0.5f); animator.AddBehavior (stickyBehavior); }
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 void SetupCollectionView() { if (LongPressGestureRecognizer != null) { CollectionView.RemoveGestureRecognizer(LongPressGestureRecognizer); } if (PanGestureRecognizer != null) { CollectionView.RemoveGestureRecognizer(PanGestureRecognizer); } LongPressGestureRecognizer = new UILongPressGestureRecognizer(HandleLongPressGesture); LongPressGestureRecognizer.Delegate = new DraggableGestureRecognizerDelegate(this); foreach (var gestureRecognizer in CollectionView.GestureRecognizers) { if (gestureRecognizer is UILongPressGestureRecognizer) { gestureRecognizer.RequireGestureRecognizerToFail(LongPressGestureRecognizer); } } CollectionView.AddGestureRecognizer(LongPressGestureRecognizer); PanGestureRecognizer = new UIPanGestureRecognizer(HandlePanGesture); PanGestureRecognizer.Delegate = new DraggableGestureRecognizerDelegate(this); CollectionView.AddGestureRecognizer(PanGestureRecognizer); NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.WillResignActiveNotification, HandleApplicationWillResignActive); }
private void HandleTouchDown(UILongPressGestureRecognizer gesture) { switch (gesture.State) { case UIGestureRecognizerState.Began: HandleTouchDownBegan(gesture); break; case UIGestureRecognizerState.Changed: break; case UIGestureRecognizerState.Ended: case UIGestureRecognizerState.Cancelled: CleanupAfterTouchDown(); break; } }
private void HandleTouchDownBegan(UILongPressGestureRecognizer gesture) { var locationInCanvas = gesture.LocationInView(_canvasView); var touchedElement = ElementUnderPoint(locationInCanvas); _panShouldBegin = touchedElement != null && IsElementSelected(touchedElement); }