internal void HandleMockDebugInfoAndFingers( IEnumerable <ITouchPoint> touchpoints, ITouchPoint primaryTouchPoint) { if (primaryTouchPoint == null || touchpoints == null || touchpoints.Count() == 0) { return; } CheckAttachDebugMode(); ExecuteHandleDebugInfoAndFingers( touchpoints.Select(tp => tp.Position).ToArray(), touchpoints.Select(tp => tp.Action).ToArray(), primaryTouchPoint.Position); }
/// <summary> /// Handle the user interaction for a particular touch/gesture type and position /// </summary> /// <param name='touchPosition'> /// Touch position and type of gesture /// </param> protected override void HandleTouch(ITouchPoint touchPosition) { if (touchPosition.Position.Y >= this.gaugeYPosition) { // We are only interested in the y-position - we know the touch is within this control so anywhere on the x axis is good enough // This ensures an improved user experience because the user can click just to the side of the gauge and now it will count as a hit. this.brushSizeGauge.HandleTouch(touchPosition.Position.Y); } }
internal void HandleMockDebugInfoAndFingers( IEnumerable<ITouchPoint> touchpoints, ITouchPoint primaryTouchPoint) { if (primaryTouchPoint == null || touchpoints == null || touchpoints.Count() == 0) { return; } CheckAttachDebugMode(); ExecuteHandleDebugInfoAndFingers( touchpoints.Select(tp => tp.Position).ToArray(), touchpoints.Select(tp => tp.Action).ToArray(), primaryTouchPoint.Position); }
/// <summary> /// Checks wheter a particular touch point (user pressing the screen) is within the bounds of one of the tools. /// </summary> /// <returns> /// True = The touchPosition was handled by this control /// False = The touchPosition was not handled by this control /// </returns> /// <param name='touchPosition' The location where the user touched the screen (and type of touch) /> public bool CheckTouchCollision(ITouchPoint touchPosition) { foreach (var tool in this.interactiveTools) { // If the tool is not fully on screen then don't check for a collision // (This happens when controls are hidden because the toolbox is minimized - however // we perform this check because there is an overlap on the borders which means we // might otherwise accidentally select a hidden tool) if (tool.Bounds.Bottom < this.ToolboxHeight && tool.CheckTouchCollision(touchPosition) == true) { // no need to check the other tools so exit now return true; } } return false; }
/// <summary> /// Handles a particular touch by the user /// </summary> /// <param name='touch'> /// The position and type of gesture/touch made /// </param> protected override void HandleTouch(ITouchPoint touchPosition) { for (int i = 0; i < GaugeCount; i++) { if (this.gaugeList[i].CheckTouchCollision(touchPosition) == true) { break; } } }
/// <summary> /// Handles a particular touch by the user /// </summary> /// <param name='touch'>The position and type of gesture/touch made</param> /// <param name='touchPosition'>Touch position.</param> protected override void HandleTouch(ITouchPoint touchPosition) { var gaugeTouchPoint = touchPosition; if (this.boundsMiddleImage.Contains(touchPosition.Position)) { // if the user starts to press the gauge but slightly misses it (as it is quite small) and hence // their Y is just above/below the gauge then we alter the Y position to ensure that the touch // will get picked up on gaugeTouchPoint = new TouchPoint( new Vector2(touchPosition.Position.X, this.gaugeBounds.Y), touchPosition.TouchType); } else if (this.boundsLeftImage.Contains(touchPosition.Position)) { // if the user presses the 'slow icon' to the left of the gauge then treat this as pressing the // far left of the gauge - i.e. the slowest speed gaugeTouchPoint = new TouchPoint( new Vector2(this.boundsMiddleImage.X, this.gaugeBounds.Y), touchPosition.TouchType); } else if (this.boundsRightImage.Contains(touchPosition.Position)) { // if the user presses the 'fast icon' to the right of the gauge then treat this as pressing the // far right of the gauge - i.e. the fastest speed gaugeTouchPoint = new TouchPoint( new Vector2(this.boundsMiddleImage.X + this.boundsMiddleImage.Width - 1, this.gaugeBounds.Y), touchPosition.TouchType); } this.gauge.CheckTouchCollision(gaugeTouchPoint); }
/// <summary> /// Handles a particular touch/gesture made by the user /// </summary> /// <param name='touch'> /// The position and type of gesture/touch made /// </param> protected override void HandleTouch(ITouchPoint touch) { this.HandleTouch(touch.Position.X); }
/// <summary> /// Handles a particular touch by the user /// </summary> /// <param name='touch'> /// The position and type of gesture/touch made /// </param> protected abstract void HandleTouch(ITouchPoint touchPosition);
/// <summary> /// Checks wheter a particular touch point (user pressing the screen) is within the bounds of this control. /// </summary> /// <returns> /// True = The touchPosition was handled by this control /// False = The touchPosition was not handled by this control /// </returns> /// <param name='touchPosition' The location where the user touched the screen (and type of touch) /> public bool CheckTouchCollision(ITouchPoint touch) { if (this.Bounds.Contains(touch.Position)) { if (touch.TouchType == TouchType.FreeDrag && inDragMode == false) { // although the drag is in this control, it did not start here so we are ignoring it return false; } switch (touch.TouchType) { case TouchType.StartDrag: this.inDragMode = true; break; case TouchType.DragComplete: this.inDragMode = false; break; } } else if (this.inDragMode == true) { // we are in drag mode, although the user has dragged outside this control if (touch.TouchType == TouchType.DragComplete) { this.inDragMode = false; } } else { return false; } this.HandleTouch(touch); return true; }
/// <summary> /// Checks whether the user has touched inside the toolbox /// </summary> /// <returns> /// true if the touch is within the toolbox, false if not /// </returns> /// <param name='touchPoint' Where the user touched the screen /> protected bool CheckToolboxCollision(ITouchPoint touchPoint) { bool touchInToolbox = false; ITouchPoint offsetCollisionPoint = touchPoint; if (this.ToolBox.DockPosition == DockPosition.Bottom) { int toolboxPositionY = (this.ImageStateData.Height - this.ToolBox.ToolboxHeight); Vector2 offsetPosition = new Vector2(touchPoint.Position.X, touchPoint.Position.Y - toolboxPositionY); offsetCollisionPoint = new TouchPoint(offsetPosition, touchPoint.TouchType); if (touchPoint.Position.Y >= toolboxPositionY) { touchInToolbox = true; } } else { if (touchPoint.Position.Y <= this.ToolBox.ToolboxHeight) { touchInToolbox = true; } } if (touchInToolbox == false) { return false; } this.ToolBox.CheckTouchCollision(offsetCollisionPoint); return true; }
/// <summary> /// Handles a particular touch by the user /// </summary> /// <param name='touch'> /// The position and type of gesture/touch made /// </param> protected override void HandleTouch(ITouchPoint touchPosition) { this.OnColorSelected(EventArgs.Empty); }