void OnPinchMove( PinchGestureRecognizer source ) { UI.StatusText = "Pinch updated by " + source.Delta + " degrees"; // change the scale of the target based on the pinch delta value target.transform.localScale += source.Delta * pinchScaleFactor * Vector3.one; }
public void PinchCompletedTest () { var view = new View (); var pinch = new PinchGestureRecognizer (); GestureStatus result = GestureStatus.Canceled; pinch.PinchUpdated += (object sender, PinchGestureUpdatedEventArgs e) => { result = e.Status; }; ((IPinchGestureController)pinch).SendPinchEnded (view); Assert.AreEqual (GestureStatus.Completed, result); }
public void PinchUpdatedTest () { var view = new View (); var pinch = new PinchGestureRecognizer (); var point = new Point (10, 10); var resultPoint = Point.Zero; double result = -1; pinch.PinchUpdated += (object sender, PinchGestureUpdatedEventArgs e) => { result = e.Scale; resultPoint = e.ScaleOrigin; }; ((IPinchGestureController)pinch).SendPinch (view, 2, point); Assert.AreEqual (2, result); }
public void PinchStartedTest () { var view = new View (); var pinch = new PinchGestureRecognizer (); GestureStatus result = GestureStatus.Canceled; var point = new Point (10, 10); var resultPoint = Point.Zero; pinch.PinchUpdated += (object sender, PinchGestureUpdatedEventArgs e) => { result = e.Status; resultPoint = e.ScaleOrigin; }; ((IPinchGestureController)pinch).SendPinchStarted (view,point); Assert.AreEqual (GestureStatus.Started, result); Assert.AreEqual (point, resultPoint); }
public void AddPinch () { var pinch = new PinchGestureRecognizer (); double xOffset = 0; double yOffset = 0; double startScale = 1; pinch.PinchUpdated += (sender, e) => { if (e.Status == GestureStatus.Started) { startScale = Content.Scale; Content.AnchorX = Content.AnchorY = 0; } if (e.Status == GestureStatus.Running) { _currentScale += (e.Scale - 1) * startScale; _currentScale = Math.Max (1, _currentScale); var renderedX = Content.X + xOffset; var deltaX = renderedX / Width; var deltaWidth = Width / (Content.Width * startScale); var originX = (e.ScaleOrigin.X - deltaX) * deltaWidth; var renderedY = Content.Y + yOffset; var deltaY = renderedY / Height; var deltaHeight = Height / (Content.Height * startScale); var originY = (e.ScaleOrigin.Y - deltaY) * deltaHeight; double targetX = xOffset - (originX * Content.Width) * (_currentScale - startScale); double targetY = yOffset - (originY * Content.Height) * (_currentScale - startScale); Content.TranslationX = targetX.Clamp (-Content.Width * (_currentScale - 1), 0); Content.TranslationY = targetY.Clamp (-Content.Height * (_currentScale - 1), 0); Content.Scale = _currentScale; } if (e.Status == GestureStatus.Completed) { xOffset = Content.TranslationX; yOffset = Content.TranslationY; } }; GestureRecognizers.Add (pinch); }
private void PinchTest() { var ract = new PinchGestureRecognizer(); ract.PinchUpdated += (s, e) => { log.Text = $"{e.Scale}"; }; back.GestureRecognizers.Add(ract); var tap = new TapGestureRecognizer(); tap.Tapped += (s, e) => { }; back.GestureRecognizers.Add(tap); }
public void PinchStartedTest() { var view = new View(); var pinch = new PinchGestureRecognizer(); GestureStatus result = GestureStatus.Canceled; var point = new Point(10, 10); var resultPoint = Point.Zero; pinch.PinchUpdated += (object sender, PinchGestureUpdatedEventArgs e) => { result = e.Status; resultPoint = e.ScaleOrigin; }; ((IPinchGestureController)pinch).SendPinchStarted(view, point); Assert.AreEqual(GestureStatus.Started, result); Assert.AreEqual(point, resultPoint); }
public MainPage() { InitializeComponent(); var tapGesture = new TapGestureRecognizer(); tapGesture.Tapped += OnTapped; contentLabel.GestureRecognizers.Add(tapGesture); var panGesture = new PanGestureRecognizer(); panGesture.PanUpdated += OnPanUpdated; contentLabel.GestureRecognizers.Add(panGesture); var pinchGesture = new PinchGestureRecognizer(); pinchGesture.PinchUpdated += OnPinchUpdated; contentLabel.GestureRecognizers.Add(pinchGesture); }
private bool _secondDoubleTapp = false; //boolean checking if the user doubletapped for the first time or second time public PinchZoom() { var pinchGesture = new PinchGestureRecognizer(); pinchGesture.PinchUpdated += PinchUpdated; GestureRecognizers.Add(pinchGesture); var panGesture = new PanGestureRecognizer(); panGesture.PanUpdated += OnPanUpdated; GestureRecognizers.Add(panGesture); var tapGesture = new TapGestureRecognizer { NumberOfTapsRequired = 2 }; tapGesture.Tapped += DoubleTapped; GestureRecognizers.Add(tapGesture); }
public PinchToZoomContainer() { var tap = new TapGestureRecognizer { NumberOfTapsRequired = 2 }; tap.Tapped += OnTapped; GestureRecognizers.Add(tap); var pinchGesture = new PinchGestureRecognizer(); pinchGesture.PinchUpdated += OnPinchUpdated; GestureRecognizers.Add(pinchGesture); var pan = new PanGestureRecognizer(); pan.PanUpdated += OnPanUpdated; GestureRecognizers.Add(pan); }
protected override void Init() { var taps = new Label { Text = "Taps: 0" }; var pans = new Label(); var pinches = new Label(); var pangr = new PanGestureRecognizer(); var tapgr = new TapGestureRecognizer(); var pinchgr = new PinchGestureRecognizer(); var frame = new Frame { HasShadow = false, HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, BackgroundColor = Color.White, Padding = new Thickness(5), HeightRequest = 300, WidthRequest = 300, AutomationId = "frame" }; var tapCount = 0; tapgr.Command = new Command(() => { tapCount += 1; taps.Text = $"Taps: {tapCount}"; }); pangr.PanUpdated += (sender, args) => pans.Text = $"Panning: {args.StatusType}"; pinchgr.PinchUpdated += (sender, args) => pinches.Text = $"Pinching: {args.Status}"; frame.GestureRecognizers.Add(tapgr); frame.GestureRecognizers.Add(pangr); frame.GestureRecognizers.Add(pinchgr); Content = new StackLayout { BackgroundColor = Color.Olive, Children = { taps, pans, pinches, frame } }; }
protected override void OnAppearing() { var pinch = new PinchGestureRecognizer(); pinch.PinchUpdated += OnPinchUpdated; CapturedImage.GestureRecognizers.Add(pinch); var pan = new PanGestureRecognizer(); pan.PanUpdated += OnPanUpdated; CapturedImage.GestureRecognizers.Add(pan); var tap = new TapGestureRecognizer { NumberOfTapsRequired = 2 }; tap.Tapped += OnTapped; CapturedImage.GestureRecognizers.Add(tap); }
public MapView() { //Content = new StackLayout { // Children = { // new Label { Text = "Welcome to Xamarin.Forms!" } // } //}; // Set PanGestureRecognizer.TouchPoints to control the // number of touch points needed to pan var panGesture = new PanGestureRecognizer(); panGesture.PanUpdated += OnPanUpdated; GestureRecognizers.Add(panGesture); var pinchGesture = new PinchGestureRecognizer(); pinchGesture.PinchUpdated += OnPinchUpdated; GestureRecognizers.Add(pinchGesture); }
public ZoomContainer() { var pinchGesture = new PinchGestureRecognizer(); pinchGesture.PinchUpdated += OnPinchUpdated; GestureRecognizers.Add(pinchGesture); // Set PanGestureRecognizer.TouchPoints to control the // number of touch points needed to pan var panGesture = new PanGestureRecognizer(); panGesture.PanUpdated += OnPanUpdated; GestureRecognizers.Add(panGesture); var doubleTap = new TapGestureRecognizer(); doubleTap.NumberOfTapsRequired = 2; doubleTap.Tapped += DoubleTap_Tapped; GestureRecognizers.Add(doubleTap); }
/// <summary> /// constructor /// </summary> public PinchPanImage() { var pinchGesture = new PinchGestureRecognizer(); pinchGesture.PinchUpdated += OnPinchUpdated; GestureRecognizers.Add(pinchGesture); var panGesture = new PanGestureRecognizer(); panGesture.PanUpdated += OnPanUpdated; GestureRecognizers.Add(panGesture); var tapGesture = new TapGestureRecognizer(); tapGesture.Tapped += OnTapped; tapGesture.NumberOfTapsRequired = 1; GestureRecognizers.Add(tapGesture); ResetView(); }
public ZoomImage() { var pinch = new PinchGestureRecognizer(); pinch.PinchUpdated += OnPinchUpdated; GestureRecognizers.Add(pinch); var pan = new PanGestureRecognizer(); pan.PanUpdated += OnPanUpdated; GestureRecognizers.Add(pan); //var tap = new TapGestureRecognizer { NumberOfTapsRequired = 2 }; //tap.Tapped += OnTapped; //GestureRecognizers.Add(tap); Scale = MIN_SCALE; TranslationX = TranslationY = 0; AnchorX = AnchorY = 0.5; }
public ZoomGestureContainer() { var pinchGesture = new PinchGestureRecognizer(); var swipeGestureUp = new SwipeGestureRecognizer() { Direction = SwipeDirection.Up, Threshold = 10 }; var swipeGestureDown = new SwipeGestureRecognizer() { Direction = SwipeDirection.Down, Threshold = 10 }; var swipeGestureLeft = new SwipeGestureRecognizer() { Direction = SwipeDirection.Left, Threshold = 10 }; var swipeGestureRight = new SwipeGestureRecognizer() { Direction = SwipeDirection.Right, Threshold = 10 }; swipeGestureUp.Swiped += SwipeGesture_Swiped; swipeGestureDown.Swiped += SwipeGesture_Swiped; swipeGestureLeft.Swiped += SwipeGesture_Swiped; swipeGestureRight.Swiped += SwipeGesture_Swiped; pinchGesture.PinchUpdated += OnPinchUpdated; GestureRecognizers.Add(pinchGesture); GestureRecognizers.Add(swipeGestureUp); GestureRecognizers.Add(swipeGestureDown); GestureRecognizers.Add(swipeGestureLeft); GestureRecognizers.Add(swipeGestureRight); }
protected override void Init () { var taps = new Label { Text = "Taps: 0" }; var pans = new Label (); var pinches = new Label (); var pangr = new PanGestureRecognizer (); var tapgr = new TapGestureRecognizer (); var pinchgr = new PinchGestureRecognizer (); var frame = new Frame { HasShadow = false, HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, BackgroundColor = Color.White, Padding = new Thickness (5), HeightRequest = 300, WidthRequest = 300, AutomationId = "frame" }; var tapCount = 0; tapgr.Command = new Command (() => { tapCount += 1; taps.Text = $"Taps: {tapCount}"; }); pangr.PanUpdated += (sender, args) => pans.Text = $"Panning: {args.StatusType}"; pinchgr.PinchUpdated += (sender, args) => pinches.Text = $"Pinching: {args.Status}"; frame.GestureRecognizers.Add (tapgr); frame.GestureRecognizers.Add (pangr); frame.GestureRecognizers.Add(pinchgr); Content = new StackLayout { BackgroundColor = Color.Olive, Children = { taps, pans, pinches, frame } }; }
// private double density; public PinchToZoomContainer() { var pinchGesture = new PinchGestureRecognizer(); pinchGesture.PinchUpdated += OnPinchUpdated; GestureRecognizers.Add(pinchGesture); var panGesture = new PanGestureRecognizer(); panGesture.PanUpdated += OnPanUpdated; GestureRecognizers.Add(panGesture); // Get Metrics var mainDisplayInfo = DeviceDisplay.MainDisplayInfo; screenWidth = mainDisplayInfo.Width; screenHeight = mainDisplayInfo.Height; // Screen density var density = mainDisplayInfo.Density; }
public CustomPanPinchToZoomContainer() { var pinchGesture = new PinchGestureRecognizer(); pinchGesture.PinchUpdated += OnPinchUpdated; GestureRecognizers.Add(pinchGesture); //var panGestureRecognizer = new PanGestureRecognizer(); //panGestureRecognizer.PanUpdated += MovePicture; //GestureRecognizers.Add(panGestureRecognizer); panGestureRecognizer = new PanGestureRecognizer(); var doubleTapRecognizer = new TapGestureRecognizer { NumberOfTapsRequired = 2 }; doubleTapRecognizer.Tapped += DoubleTapRecognizer_Tapped; GestureRecognizers.Add(doubleTapRecognizer); }
public bool OnPinch(float scale, Point scalePoint) { View view = GetView(); if (view == null) { return(false); } PinchGestureRecognizer pinchGesture = PinchGesture; if (pinchGesture == null) { return(true); } var scalePointTransformed = new Point(scalePoint.X / view.Width, scalePoint.Y / view.Height); ((IPinchGestureController)pinchGesture).SendPinch(view, 1 + (scale - 1) * _pinchStartingScale, scalePointTransformed); return(true); }
//private readonly double OVERSHOOT = 0.15; public MyZoomImage() { // обработчик нажатия на изображение var tap = new TapGestureRecognizer { NumberOfTapsRequired = 2 }; tap.Tapped += OnTapped; GestureRecognizers.Add(tap); // обработчик перемещения изображения var panGesture = new PanGestureRecognizer(); panGesture.PanUpdated += OnPanUpdated; GestureRecognizers.Add(panGesture); // обработчик масштабирования изображения var pinchGesture = new PinchGestureRecognizer(); pinchGesture.PinchUpdated += OnPinchUpdated; GestureRecognizers.Add(pinchGesture); }
public ImageZoomContainer() { var pinchGesture = new PinchGestureRecognizer(); pinchGesture.PinchUpdated += OnPinchUpdated; GestureRecognizers.Add(pinchGesture); var pan = new PanGestureRecognizer(); pan.PanUpdated += OnPanUpdated; GestureRecognizers.Add(pan); var tap = new TapGestureRecognizer { NumberOfTapsRequired = 2 }; tap.Tapped += OnTapped; GestureRecognizers.Add(tap); Scale = MinScale; TranslationX = TranslationY = 0; AnchorX = AnchorY = 0; }
public ZoomImage() { var pinch = new PinchGestureRecognizer(); pinch.PinchUpdated += OnPinchUpdated; GestureRecognizers.Add(pinch); var pan = new PanGestureRecognizer(); pan.PanUpdated += OnPanUpdated; GestureRecognizers.Add(pan); var tap = new TapGestureRecognizer { NumberOfTapsRequired = 2 }; tap.Tapped += OnTapped; GestureRecognizers.Add(tap); SizeChanged += ZoomImage_SizeChanged; Initialize(); }
public bool OnPinchStarted(Point scalePoint) { View view = GetView(); if (view == null) { return(false); } PinchGestureRecognizer pinchGesture = PinchGesture; if (pinchGesture == null) { return(false); } _pinchStartingScale = view.Scale; var scalePointTransformed = new Point(scalePoint.X / view.Width, scalePoint.Y / view.Height); pinchGesture.SendPinchStarted(view, scalePointTransformed); return(true); }
private void AttachEvents() { if (TapAction != null) { NativeControl.GestureRecognizers.Add(_tapGestureRecognizer = new TapGestureRecognizer() { Command = new ActionCommand(TapAction) }); } if (DoubleTapAction != null) { NativeControl.GestureRecognizers.Add(_doubleTapGestureRecognizer = new TapGestureRecognizer() { Command = new ActionCommand(DoubleTapAction), NumberOfTapsRequired = 2 }); } if (PinchAction != null) { NativeControl.GestureRecognizers.Add(_pinchGestureRecognizer = new PinchGestureRecognizer()); _pinchGestureRecognizer.PinchUpdated += PinchGestureRecognizer_PinchUpdated; } if (PanAction != null) { NativeControl.GestureRecognizers.Add(_panGestureRecognizer = new PanGestureRecognizer()); _panGestureRecognizer.PanUpdated += PanGestureRecognizer_PanUpdated; } if (SwipeAction != null) { NativeControl.GestureRecognizers.Add(_swipeGestureRecognizer = new SwipeGestureRecognizer()); _swipeGestureRecognizer.Swiped += SwipeGestureRecognizer_Swiped; } }
public void Constructor() { var pinch = new PinchGestureRecognizer(); }
/// <summary> /// Adds gesture recognizers to a view and adds it to the view cache /// </summary> /// <param name="view"></param> private void MonitorView(View view) { switch (GesturesTracked) { case GestureType.Tap: view.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => TrackEvent(view, GestureType.Tap)) }); break; case GestureType.Pan: var panGesture = new PanGestureRecognizer(); panGesture.PanUpdated += (s, e) => { if (e.StatusType == GestureStatus.Completed) { TrackEvent(view, GestureType.Pan); } }; view.GestureRecognizers.Add(panGesture); break; case GestureType.Pinch: var pinchGesture = new PinchGestureRecognizer(); pinchGesture.PinchUpdated += (s, e) => { if (e.Status == GestureStatus.Completed) { TrackEvent(view, GestureType.Pan); } }; view.GestureRecognizers.Add(pinchGesture); break; case GestureType.All: default: view.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => TrackEvent(view, GestureType.Tap)) }); var panGestureAll = new PanGestureRecognizer(); panGestureAll.PanUpdated += (s, e) => { if (e.StatusType == GestureStatus.Completed) { TrackEvent(view, GestureType.Pan); } }; view.GestureRecognizers.Add(panGestureAll); var pinchGestureAll = new PinchGestureRecognizer(); pinchGestureAll.PinchUpdated += (s, e) => { if (e.Status == GestureStatus.Completed) { TrackEvent(view, GestureType.Pan); } }; view.GestureRecognizers.Add(pinchGestureAll); break; } ScannedViewsCache.Add(view); }
private void HandleTouchInput(Camera uicamera) { //TODO: this method is now extremely unwieldly - now that we have the basics down, refactor and consolidate the various checks if (GamePadInput.ActiveMode != GamePadInput.InputMode.Touch) { return; } // If the mouse took over from the touch, it should clear any // highlights the touch had going. Boku.InGame.inGame.MouseEdit.Clear(); Camera camera = Boku.InGame.inGame.shared.camera; TouchEdit touchEdit = Boku.InGame.inGame.TouchEdit; TouchEdit.TouchHitInfo hitInfo = null; //keep track of previous focus actor for comparisons this frame GameActor previousFocusActor = FocusActor; hitInfo = TouchEdit.HitInfo; //Check for color pallet hits if (Boku.InGame.ColorPalette.Active && (FocusActor != null) && !actorMenu.Active && !noActorMenu.Active) { Classification.Colors touchColor = Boku.InGame.ColorPalette.GetColorFromTouch(); if ((touchColor != Classification.Colors.None) && (FocusActor.ClassColor != touchColor)) { FocusActor.ClassColor = touchColor; focusColorIndex = ColorPalette.GetIndexFromColor(touchColor); Foley.PlayColorChange(); Boku.InGame.IsLevelDirty = true; } // For the duration of the color palette handling touch, all touch inputs are deferred. if (Boku.InGame.ColorPalette.HandlingTouch) { return; } } bool hasNonUITouch = touchEdit.HasNonUITouch(); bool hasValidTap = TouchGestureManager.Get().TapGesture.WasValidEditObjectTap; touchEdit.DoObject(camera); //check for tap to adjust hit actor if (hasValidTap || TouchGestureManager.Get().DoubleTapGesture.WasRecognized || TouchGestureManager.Get().TouchHoldGesture.WasRecognized || TouchGestureManager.Get().TouchHoldGesture.SlightHoldMade || (TouchGestureManager.Get().DragGesture.IsDragging&& TouchInput.InitialActorHit != null)) { if (hasNonUITouch && TouchGestureManager.Get().DragGesture.IsDragging&& TouchInput.InitialActorHit != null) { FocusActor = TouchInput.InitialActorHit; focusColorIndex = ColorPalette.GetIndexFromColor(FocusActor.Classification.Color); Boku.InGame.ColorPalette.Active = true; } else if (hasNonUITouch && hitInfo.HaveActor) { FocusActor = hitInfo.ActorHit; focusColorIndex = ColorPalette.GetIndexFromColor(FocusActor.Classification.Color); Boku.InGame.ColorPalette.Active = true; } else { FocusActor = null; Boku.InGame.ColorPalette.Active = false; } } //check for double tap on terrain to bring up add actor if (hasNonUITouch && TouchGestureManager.Get().DoubleTapGesture.WasRecognized&& FocusActor == null && !MenusActive && !SliderActive && inGame.editObjectUpdateObj.newItemSelectorShim.State != UIShim.States.Active) { // No actor in focus so activate AddItem menu. Vector2 position = new Vector2(hitInfo.TerrainPosition.X, hitInfo.TerrainPosition.Y); inGame.editObjectUpdateObj.ActivateNewItemSelector(position, true); } //handle dragging an actor if (TouchGestureManager.Get().DragGesture.IsDragging&& TouchInput.InitialActorHit != null && FocusActor != null) { //clear out menu if up actorMenu.Deactivate(); noActorMenu.Deactivate(); //select the focus actor when we start dragging if (selectedActor == null) { // Start draggin if over actor. selectedActor = FocusActor; actorOffset = selectedActor.Movement.Position - hitInfo.TerrainPosition; } Vector3 position = hitInfo.TerrainPosition + actorOffset; selectedActor.Movement.Position = Boku.InGame.SnapPosition(position); // Try and keep the bot directly under the mouse cursor while still being at the correct height. // A possible alternative would be to use the cursor's 2d position for the bot and just have the // bot float at the appropriate height over the cursor. This would allow more exact placement of // bots over terrain but it would mean a visual disconnect between where the cursor is and where // the bot is. There would also be a jump when the bot is first clicked on since the terrain // position of the cursor is most likely further back than the bot's current position. if (hitInfo.VerticalOffset == 0.0f) { Vector3 terrainToCameraDir = hitInfo.TerrainPosition - camera.From; terrainToCameraDir.Normalize(); position = hitInfo.TerrainPosition + terrainToCameraDir * (selectedActor.EditHeight / terrainToCameraDir.Z); selectedActor.Movement.Position = Boku.InGame.SnapPosition(position); } // If the actor is supposed to stay above water, try to enforce that. // This can have some strange visual effects since it forces the actor to // float above where the mouse cursor is but the alternative is to have // actor get dragged under water. if (selectedActor.StayAboveWater) { float waterAlt = Terrain.GetWaterBase(position); if (waterAlt != 0) { position.Z = waterAlt + selectedActor.EditHeight; selectedActor.Movement.Position = Boku.InGame.SnapPosition(position); } } Boku.InGame.IsLevelDirty = true; } else { selectedActor = null; //rules for context menus: // tap + hold -> always bring up menu (terrain or actor accordingly) // double tap -> bring up menu if over an actor (actor only) // single tap -> bring up menu if over an actor that was already selected (actor only) if (hasNonUITouch && (TouchGestureManager.Get().TouchHoldGesture.WasRecognized || (FocusActor != null && TouchGestureManager.Get().DoubleTapGesture.WasRecognized) || (FocusActor != null && hasValidTap && FocusActor == previousFocusActor))) { menuActor = FocusActor; menuCursorPosition = hitInfo.TerrainPosition; // We need to do this repeatedly since the Paste option will // change depending on what's in the cut/paste buffer. SetUpMenus(); if (FocusActor == null) { actorMenu.Deactivate(); noActorMenu.Activate(TouchInput.GetOldestTouch().position); } else { noActorMenu.Deactivate(); actorMenu.Activate(TouchInput.GetOldestTouch().position); // Turn off any thought balloons so they don't clutter the menu. ThoughtBalloonManager.RemoveThoughts(FocusActor); } } // Handle two finger actions. Only enabled when not dragging. if (hasNonUITouch && TouchInput.TouchCount == 2 && selectedActor == null) { PinchGestureRecognizer pinchGesture = TouchGestureManager.Get().GetActiveGesture(TouchGestureType.Pinch, TouchGestureType.Rotate) as PinchGestureRecognizer; if (pinchGesture != null && pinchGesture.IsPinching) { //Debug.WriteLine("Pinching... Scale: "+ pinchGesture.Scale ); DoScaleActor(pinchGesture.DeltaScale, FocusActor); } RotationGestureRecognizer rotationGesture = TouchGestureManager.Get().GetActiveGesture(TouchGestureType.Rotate, TouchGestureType.Pinch) as RotationGestureRecognizer; if (null != rotationGesture && rotationGesture.IsRotating) { DoRotateActor(rotationGesture.RotationDelta, FocusActor); } } } if (TouchGestureManager.Get().RotateGesture.IsValidated || TouchGestureManager.Get().PinchGesture.IsValidated || TouchGestureManager.Get().DoubleDragGesture.IsValidated) { //turn off menu if rotating, pinching or double dragging (i.e. terrain manipulation) actorMenu.Deactivate(); noActorMenu.Deactivate(); } noActorMenu.Update(); actorMenu.Update(); // Support for changing tree types via up/down arrow keys. if (FocusActor != null && FocusActor.Classification.name == "tree") { inGame.editObjectUpdateObj.MakeTreeChange(FocusActor); } // // Figure out help overlay mode. // if (inGame.editObjectUpdateObj.newItemSelectorShim.State == UIShim.States.Active) { // The pie menu is active. HelpOverlay.ReplaceTop("MouseEditAddItemMenu"); } else if (hitInfo != null && hitInfo.HaveActor) { // We have an actor in focus. if (FocusActor != null && FocusActor.Classification.name == "tree") { HelpOverlay.ReplaceTop("MouseEditEditObjectFocusTree"); } else { HelpOverlay.ReplaceTop("MouseEditEditObjectFocus"); } } }
/// <summary> /// Initialise the Gesture Recognizers. /// </summary> private void InitialiseRecognizers() { _pinchGestureRecognizer = new PinchGestureRecognizer(); _panGestureRecognizer = new PanGestureRecognizer(); }
public XamarinFormsClase07Page() { InitializeComponent(); //Fade effect btnFadeIn.Clicked += (sender, e) => { txtFade.FadeTo(0.7, //Grado de opacidad de 0 a 1 3000, //Tiempo en milisegundos Easing.SpringIn //Efecto para la transición ); }; btnFadeOut.Clicked += (sender, e) => { txtFade.FadeTo(1, //Grado de opacidad de 0 a 1 3000, //Tiempo en milisegundos Easing.BounceOut //Efecto para la transición ); }; //Layout To Effect btnLayoutTo.Clicked += (sender, e) => { txtLayout.LayoutTo(new Rectangle(txtLayout.X, txtLayout.Y, txtLayout.Width + 50, txtLayout.Height + 50), 5000, Easing.SinInOut); }; //Rotate to effect btnRotateTo.Clicked += async(sender, e) => { await txtRotate.RotateTo(txtRotate.Rotation + 45, //Grados de rotacion 300, Easing.SpringIn); // txtRotate.Rotation = 0; }; btnRotateToRel.Clicked += async(sender, e) => { await txtRotate.RelRotateTo(45, //Grados de rotacion 300); }; //Animacion combinada btnAnimacionCombinada.Clicked += async(object sender, System.EventArgs e) => { await txtRotate.RelRotateTo(45, //Grados de rotacion 300); await txtRotate.TranslateTo(txtRotate.X + 20, //nueva posicion horizontal txtRotate.Y + 15, //Nueva posicion vertical 300); await txtRotate.FadeTo(0.2, //Grado de opacidad de 0 a 1 1000, //Tiempo en milisegundos Easing.BounceOut //Efecto para la transición ); }; //Animacion compuesta btnAnimacionCompuesta.Clicked += (object sender, System.EventArgs e) => { txtRotate.Opacity = 1; txtRotate.RelRotateTo(45, //Grados de rotacion 300); txtRotate.TranslateTo(txtRotate.X + 500, //nueva posicion horizontal txtRotate.Y + 500, //Nueva posicion vertical 30000); }; //Cancelar animacion btnCancelAnimation.Clicked += (sender, e) => { ViewExtensions.CancelAnimations(txtRotate); }; //Animacion personalizada btnPersonalizadas.Clicked += (sender, e) => { ViewExtensions_Custom.ColorTo(btnPersonalizadas, btnPersonalizadas.BackgroundColor, Color.Brown, (color) => { btnPersonalizadas.BackgroundColor = color; }, 1000); }; //Gestos //Pinch var zoom = new PinchGestureRecognizer(); zoom.PinchUpdated += (sender, e) => { Debug.WriteLine("El usuario está haciendo zoom"); }; img.GestureRecognizers.Add(zoom); //pan var drag = new PanGestureRecognizer(); drag.PanUpdated += (sender, e) => { Debug.WriteLine("El usuario está arrastrando : x= " + e.TotalX + " y: " + e.TotalY); img.TranslateTo(e.TotalX, e.TotalY, 50); }; img.GestureRecognizers.Add(drag); }
private readonly Android_GestureListener androidGestureListener; public Android_PinchGestureEventArgs(PinchGestureRecognizer gestureRecognizer, Android_GestureListener androidGestureListener)
public PanContainer () { var pan = new PanGestureRecognizer { TouchPoints = 1 }; pan.PanUpdated += (object s, PanUpdatedEventArgs e) => { switch (e.StatusType) { case GestureStatus.Started: break; case GestureStatus.Running: Content.TranslationX = e.TotalX; Content.TranslationY = e.TotalY; break; default: Content.TranslationX = Content.TranslationY = 0; break; } }; var pinch = new PinchGestureRecognizer (); double xOffset = 0; double yOffset = 0; double startScale = 1; pinch.PinchUpdated += (sender, e) => { if (e.Status == GestureStatus.Started) { startScale = Content.Scale; Content.AnchorX = Content.AnchorY = 0; } if (e.Status == GestureStatus.Running) { _currentScale += (e.Scale - 1) * startScale; _currentScale = Math.Max (1, _currentScale); var renderedX = Content.X + xOffset; var deltaX = renderedX / Width; var deltaWidth = Width / (Content.Width * startScale); var originX = (e.ScaleOrigin.X - deltaX) * deltaWidth; var renderedY = Content.Y + yOffset; var deltaY = renderedY / Height; var deltaHeight = Height / (Content.Height * startScale); var originY = (e.ScaleOrigin.Y - deltaY) * deltaHeight; double targetX = xOffset - (originX * Content.Width) * (_currentScale - startScale); double targetY = yOffset - (originY * Content.Height) * (_currentScale - startScale); Content.TranslationX = targetX.Clamp (-Content.Width * (_currentScale - 1), 0); Content.TranslationY = targetY.Clamp (-Content.Height * (_currentScale - 1), 0); Content.Scale = _currentScale; } if (e.Status == GestureStatus.Completed) { xOffset = Content.TranslationX; yOffset = Content.TranslationY; } }; GestureRecognizers.Add (pinch); GestureRecognizers.Add (pan); }
protected virtual void OnPinch(PinchGestureRecognizer gestureRecognizer) { }
public static PinchGestureRecognizer PinchUpdatedEvent(this PinchGestureRecognizer pinch, Action <object> action, object parameter) { pinch.PinchUpdated += (sender, args) => { action.Invoke(parameter); }; return(pinch); }
public static PinchGestureRecognizer PinchUpdatedEvent(this PinchGestureRecognizer pinch, Action action) { pinch.PinchUpdated += (sender, args) => { action.Invoke(); }; return(pinch); }
public FormList() { value = ""; asyncValue = "Altitude : 0\n" + "Latitude : 0\n" + "Longitude : 0"; labelBouton = new Label { AutomationId = "AutomationId_LabelBouton", Text = value, TextColor = Color.Black, HorizontalOptions = LayoutOptions.EndAndExpand }; labelSlider = new Label { AutomationId = "AutomationId_LabelSlider", Text = value, TextColor = Color.Black, HorizontalOptions = LayoutOptions.EndAndExpand }; labelStepper = new Label { AutomationId = "AutomationId_LabelStepper", Text = value, TextColor = Color.Black, HorizontalOptions = LayoutOptions.EndAndExpand }; labelSwitch = new Label { AutomationId = "AutomationId_LabelSwitch", Text = value, TextColor = Color.Black, HorizontalOptions = LayoutOptions.EndAndExpand }; labelTap = new Label { AutomationId = "AutomationId_LabelTap", Text = value, TextColor = Color.Black, HorizontalOptions = LayoutOptions.EndAndExpand }; labelPan = new Label { AutomationId = "AutomationId_LabelPan", Text = value, TextColor = Color.Black, HorizontalOptions = LayoutOptions.EndAndExpand }; labelPinch = new Label { AutomationId = "AutomationId_LabelPinch", Text = value, TextColor = Color.Black, HorizontalOptions = LayoutOptions.EndAndExpand }; geoLabel = new Label { AutomationId = "AutomationId_geoLabel", Text = asyncValue, TextColor = Color.Black, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; labels = new List <Label>(); labels.Add(labelBouton); labels.Add(labelSlider); labels.Add(labelStepper); labels.Add(labelSwitch); labels.Add(labelTap); labels.Add(labelPan); labels.Add(labelPinch); Button boutonReset = new Button { AutomationId = "AutomationId_RESET", Text = "Reset", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, FontSize = 12, BorderWidth = 1, BorderColor = Color.Black }; boutonReset.Clicked += Reset; Button bouton = new Button { AutomationId = "AutomationId_CLICK", Text = "Click!", FontSize = 12, BorderWidth = 1, BorderColor = Color.Black }; bouton.Clicked += OnButtonClicked; slider = new Slider { AutomationId = "AutomationId_Slider", Minimum = 0, Maximum = 100, HorizontalOptions = LayoutOptions.FillAndExpand }; slider.ValueChanged += OnSliderValueChanged; Stepper stepper = new Stepper { AutomationId = "AutomationId_Stepper", Minimum = 0, Maximum = 10, Increment = 0.1, }; stepper.ValueChanged += OnStepperValueChanged; switcher = new Switch { AutomationId = "AutomationId_Switch", HorizontalOptions = LayoutOptions.StartAndExpand }; switcher.Toggled += switcher_Toggled; datePicker = new DatePicker { AutomationId = "AutomationId_Date-picker", Format = "D", HorizontalOptions = LayoutOptions.FillAndExpand }; timePicker = new TimePicker { AutomationId = "AutomationId_Time-picker", Format = "T", HorizontalOptions = LayoutOptions.FillAndExpand }; imageTap = new Image { AutomationId = "AutomationId_Tap", Source = ImageSource.FromFile("icon.png"), HorizontalOptions = LayoutOptions.StartAndExpand }; tapGestureRecognizer = new TapGestureRecognizer(); tapGestureRecognizer.Tapped += gesture_tapped; imageTap.GestureRecognizers.Add(tapGestureRecognizer); imagePan = new Image { AutomationId = "AutomationId_Drag", Source = ImageSource.FromFile("icon.png"), HorizontalOptions = LayoutOptions.StartAndExpand }; panGestureRecognizer = new PanGestureRecognizer(); panGestureRecognizer.PanUpdated += onPanUpdated; imagePan.GestureRecognizers.Add(panGestureRecognizer); imagePinch = new Image { AutomationId = "AutomationId_Pinch", Source = ImageSource.FromFile("iconPlusGrande.png"), HorizontalOptions = LayoutOptions.CenterAndExpand, }; pinchGestureRecognizer = new PinchGestureRecognizer(); pinchGestureRecognizer.PinchUpdated += onPinchUpdated; imagePinch.GestureRecognizers.Add(pinchGestureRecognizer); geoBouton = new Button { AutomationId = "AutomationId_Geobouton", Text = "Get Geo-position", FontSize = 10, BorderWidth = 1, BorderColor = Color.Black }; geoBouton.Clicked += async(object sender, EventArgs e) => { await getGeoPos(); }; // Build the page. this.Content = new ScrollView { Content = new TableView { HasUnevenRows = true, Intent = TableIntent.Settings, Root = new TableRoot { new TableSection("Reset") { new ViewCell { View = boutonReset, } }, new TableSection("Form list") { new ViewCell { View = new StackLayout { Padding = new Thickness(0, 5), Orientation = StackOrientation.Horizontal, Children = { bouton, labelBouton } } }, new ViewCell { View = new StackLayout { Padding = new Thickness(0, 5), Orientation = StackOrientation.Horizontal, Children = { slider, labelSlider } } }, new ViewCell { View = new StackLayout { Padding = new Thickness(0, 5), Orientation = StackOrientation.Horizontal, Children = { stepper, labelStepper } } }, new ViewCell { View = new StackLayout { Padding = new Thickness(0, 5), Orientation = StackOrientation.Horizontal, Children = { switcher, labelSwitch } } }, new ViewCell { View = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { datePicker } } }, new ViewCell { View = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { timePicker } } }, new ViewCell { View = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { imageTap, new Label { Text = "Tap",HorizontalOptions = LayoutOptions.CenterAndExpand }, labelTap } } }, new ViewCell { View = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { imagePan, new Label { Text = "Drag",HorizontalOptions = LayoutOptions.CenterAndExpand }, labelPan } } }, new ViewCell { Height = 300, View = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { new Label { Text = "Pinch", HorizontalOptions = LayoutOptions.StartAndExpand }, imagePinch, labelPinch } } }, new ViewCell { View = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { geoBouton, geoLabel } } } } } }, }; }
public iOS_PinchGestureEventArgs(PinchGestureRecognizer gestureRecognizer, UIPinchGestureRecognizer platformGestureRecognizer) { this.gestureRecognizer = gestureRecognizer; this.platformGestureRecognizer = platformGestureRecognizer; }
public PanContainer() { var pan = new PanGestureRecognizer { TouchPoints = 1 }; pan.PanUpdated += (object s, PanUpdatedEventArgs e) => { switch (e.StatusType) { case GestureStatus.Started: break; case GestureStatus.Running: Content.TranslationX = e.TotalX; Content.TranslationY = e.TotalY; break; default: Content.TranslationX = Content.TranslationY = 0; break; } }; var pinch = new PinchGestureRecognizer(); double xOffset = 0; double yOffset = 0; double startScale = 1; pinch.PinchUpdated += (sender, e) => { if (e.Status == GestureStatus.Started) { startScale = Content.Scale; Content.AnchorX = Content.AnchorY = 0; } if (e.Status == GestureStatus.Running) { _currentScale += (e.Scale - 1) * startScale; _currentScale = Math.Max(1, _currentScale); var renderedX = Content.X + xOffset; var deltaX = renderedX / Width; var deltaWidth = Width / (Content.Width * startScale); var originX = (e.ScaleOrigin.X - deltaX) * deltaWidth; var renderedY = Content.Y + yOffset; var deltaY = renderedY / Height; var deltaHeight = Height / (Content.Height * startScale); var originY = (e.ScaleOrigin.Y - deltaY) * deltaHeight; double targetX = xOffset - (originX * Content.Width) * (_currentScale - startScale); double targetY = yOffset - (originY * Content.Height) * (_currentScale - startScale); Content.TranslationX = targetX.Clamp(-Content.Width * (_currentScale - 1), 0); Content.TranslationY = targetY.Clamp(-Content.Height * (_currentScale - 1), 0); Content.Scale = _currentScale; } if (e.Status == GestureStatus.Completed) { xOffset = Content.TranslationX; yOffset = Content.TranslationY; } }; GestureRecognizers.Add(pinch); GestureRecognizers.Add(pan); }
void OnPinchMove( PinchGestureRecognizer source ) { if (ScreenLog.I.IsShowing == false) myCam.fieldOfView = Mathf.Clamp(myCam.fieldOfView - (source.Delta * pinchScaleFactor), 20, 90); }
public void Constructor () { var pinch = new PinchGestureRecognizer (); }