void Slider_OnMoved(TouchInfo ti) { Value = (ti.Position.x - GetAbsoluteX()) / Size.x + 0.5f; if (Value < 0) { Value = 0; } else if (Value > 1) { Value = 1; } OnChangeValue.Fire(Value); }
public virtual bool Consume(TouchInfo touchInfo) { if (blockInput) { return(true); } UIElement toConsume = null; if (overlay != null) { toConsume = overlay.GetConsumedElement(touchInfo); } else { toConsume = CurrentPage.GetConsumedElement(touchInfo); } if (touchInfo.TouchState == TouchState.Released) { touchInfo.Delta = touchInfo.Position - lastPressPos; if (draggedObject != null) { toConsume = draggedObject; draggedObject = null; } } else if (touchInfo.TouchState == TouchState.Pressed) { if (draggedObject == null) { draggedObject = toConsume; lastPressPos.Copy(touchInfo.Position); } } else if (touchInfo.TouchState == TouchState.Moved) { if (draggedObject != null) { toConsume = draggedObject; } touchInfo.Delta = touchInfo.Position - lastPressPos; } if (toConsume == null) { return(overlay != null); } toConsume.Consume(touchInfo); return(true); }
public override UIElement GetConsumedElement(TouchInfo ti) { if (!Active) { return(null); } lastConsumed = base.GetConsumedElement(ti); if (lastConsumed != null || holding) { return(this); } return(lastConsumed); }
public void ToTouchInfo(TouchLocation tl, ref TouchInfo ti) { TouchState touchState = TouchState.Moved; if (tl.State == TouchLocationState.Pressed) { touchState = TouchState.Pressed; } else if (tl.State == TouchLocationState.Released) { touchState = TouchState.Released; } ti.id = tl.Id; ti.Set(tl.Position.X, tl.Position.Y, touchState); }
public override void Consume(TouchInfo ti) { if (ti.TouchState == TouchState.Released) { if (ti.Delta.x > 25f / 480) { SlidePrev(); } else if (ti.Delta.x < -25f / 480) { SlideNext(); } else { if (Math.Abs(maxDelta) < 25f / 480) { if (lastConsumed != null) { lastConsumed.Consume(ti); } } } holding = false; maxDelta = 0; } else if (ti.TouchState == TouchState.Moved) { if (Math.Abs(ti.Delta.x) > Math.Abs(maxDelta)) { maxDelta = ti.Delta.x; } slideContainer.Position.x = ti.Delta.x + holdPos; } else if (ti.TouchState == TouchState.Pressed) { holding = true; holdPos = slideContainer.Position.x; maxDelta = 0; } else { if (lastConsumed != null) { lastConsumed.Consume(ti); } } }
public override UIElement GetConsumedElement(TouchInfo ti) { if (!Visible) { return(null); } if (!Active) { return(null); } bool canConsume = CheckBounds(ti); mouseOver = canConsume && ti.TouchState != TouchState.Released; pressed = (ti.TouchState == TouchState.Pressed || pressed) && mouseOver; if (!canConsume) { return(null); } return(this); }
public void Copy(TouchInfo ti) { id = ti.id; Position.Copy(ti.Position); TouchState = ti.TouchState; }
protected void FireOnRelease(TouchInfo ti) { OnRelease.Fire(ti); }