Touch point. Immutable class for tracking the location and type of 'touch'/gesture made by the user along with colour and size information
Inheritance: ITouchPointSizeColor
コード例 #1
0
        /// <summary>
        /// Handles any user input.
        /// Collect all gestures made since the last 'update' - stores these ready to be handled by the Canvas for drawing
        /// </summary>
        private void HandleInput()
        {
            while (TouchPanel.IsGestureAvailable)
            {
                // read the next gesture from the queue
                GestureSample gesture = TouchPanel.ReadGesture();

                TouchType touchType = this.ConvertGestureType(gesture.GestureType);

                TouchPointSizeColour touchPoint = new TouchPointSizeColour(
                    gesture.Position,
                    touchType,
                    this.paintToolBox.Color,
                    this.paintToolBox.Brush);

                // First check if this can be handled by the toolbox - if not then we will keep for the canvas
                if (this.CheckToolboxCollision(touchPoint) == false)
                {
                    this.CanvasTouchPoints.Add(this.ConvertScreenTouchToCanvasTouch(touchPoint));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Converts the screen touchpoint to a canvas touchpoint - i.e. alters the position of the touch to take into account the position and size
        /// of the toolbox
        /// </summary>
        /// <returns>
        /// A TouchPoint in Canvas co-ordinates
        /// </returns>
        /// <param name='screenTouchPoint' The touch point in screen co-ordinates/>
        protected TouchPointSizeColour ConvertScreenTouchToCanvasTouch(TouchPointSizeColour screenTouchPoint)
        {
            if (this.ToolBox.DockPosition == DockPosition.Top)
            {
                Vector2 offsetPosition = new Vector2(screenTouchPoint.Position.X, screenTouchPoint.Position.Y - this.ToolBox.ToolboxMinimizedHeight);
                return new TouchPointSizeColour(
                    offsetPosition,
                    screenTouchPoint.TouchType,
                    screenTouchPoint.Color,
                    screenTouchPoint.Size);
            }

            return screenTouchPoint;
        }