Пример #1
0
 void OnTouchesEnded(List <CCTouch> touches, CCEvent touchEvent)
 {
     if (touches.Count > 0)
     {
         _ball.RemoveChild(_glow);
     }
 }
Пример #2
0
        /// <summary>
        /// Evaluates the lines we have in the buffer
        /// </summary>
        /// <param name="lines">Lines</param>
        /// <remarks>
        /// We keep a buffer of lines. If a list of lines cannot be
        /// evaluated we wait for another second or so to allow for more lines.
        /// When that times out and no shape can be determined, then
        /// we clear the buffer.
        /// </remarks>
        private void EvaluateLines(List <Line> lines)
        {
            _clearTTL = _clearTTLResetValue;
            _buffer.AddRange(lines);

            var result = _patternEvaluator.Evaluate(_buffer);

            if (!result.IsValid)
            {
                return;
            }

            Debug.WriteLine("evaluation succeeded: " + result.Key);

            switch (result.Key)
            {
            case "button":
                var rectShape = new RectangleShape()
                {
                    P1 = result.UpperLeft.ToCCPoint(),
                    P2 = result.LowerRight.ToCCPoint()
                };
                _shapeNode.AddChild(new ShapeNode(rectShape));
                _recognizerCanvasNode.Clear();
                break;

            case "image":
                var imageShape = new ImageShape()
                {
                    P1 = result.UpperLeft.ToCCPoint(),
                    P2 = result.LowerRight.ToCCPoint()
                };
                _shapeNode.AddChild(new ShapeNode(imageShape));
                _recognizerCanvasNode.Clear();
                break;

            case "text":
                var textShape = new TextShape()
                {
                    P1 = result.UpperLeft.ToCCPoint(),
                    P2 = result.LowerRight.ToCCPoint()
                };
                _shapeNode.AddChild(new ShapeNode(textShape));
                _recognizerCanvasNode.Clear();
                break;

            case "entry":
                var entryShape = new EntryShape()
                {
                    P1 = result.UpperLeft.ToCCPoint(),
                    P2 = result.LowerRight.ToCCPoint()
                };
                _shapeNode.AddChild(new ShapeNode(entryShape));
                _recognizerCanvasNode.Clear();
                break;

            case "lineoftext":

                var lineoftext = new LineOfTextShape()
                {
                    P1 = result.UpperLeft.ToCCPoint(),
                    P2 = result.LowerRight.ToCCPoint()
                };
                _shapeNode.AddChild(new ShapeNode(lineoftext));
                _recognizerCanvasNode.Clear();
                break;


            case "delete":
                var deleteShape = new DeleteShape()
                {
                    P1 = result.UpperLeft.ToCCPoint(),
                    P2 = result.LowerRight.ToCCPoint()
                };

                var victims = IsShapeOverOtherShapes(deleteShape);
                foreach (var victim in victims)
                {
                    _shapeNode.RemoveChild(victim);
                }
                _recognizerCanvasNode.Clear();
                break;
            }

            _canvasNode.Clear();
            _buffer.Clear();
        }