Пример #1
0
        private void PushShape(string shape, Cell cell)
        {
            canvas.Children.Remove(cell?.Shape);
            double size = squareHeight < squareWidth ? squareHeight : squareWidth;
            Shape  t    = ShapeFactory.CreateShape(shape, size);
            double x    = Canvas.GetLeft(cell.GridCell) + (cell.GridCell.Width / 2);
            double y    = Canvas.GetBottom(cell.GridCell) + (cell.GridCell.Height / 2);

            Canvas.SetZIndex(t, 500);
            canvas.Children.Add(t);
            cell.Shape = t;

            Point f = new Point(x, y);

            MoveShape(cell.Shape, f);
        }
Пример #2
0
        public void PointAt(double xFromMid, double yFromMid)
        {
            if (pointerFigure == null)
            {
                pointerFigure = ShapeFactory.CreatePointer(accuracyTest);
                canvas.Children.Add(pointerFigure);
                Canvas.SetZIndex(pointerFigure, 10000);
                xPoint = xFromMid;
                yPoint = yFromMid;
            }
            if (target != null)
            {
                target.GridCell.Fill = targetColor;
            }
            if (extraTarget != null)
            {
                extraTarget.GridCell.Fill = targetColor;
            }

            DrawNextTargets();
            if (AttemptRepository.SaveStatus == DatabaseSaveStatus.Saving && !savingToDB)
            {
                savingToDB = true;
                ShowStatusMessage("Saving to database...");
            }
            if (savingToDB && AttemptRepository.SaveStatus != DatabaseSaveStatus.Saving)
            {
                savingToDB = false;
                string status = AttemptRepository.SaveStatus == DatabaseSaveStatus.Failed ? "Failed!" : "Success!";
                ShowStatusMessage(status);
                Background = AttemptRepository.SaveStatus == DatabaseSaveStatus.Failed ? Brushes.Red : Brushes.Blue;
            }

            Point currentGyroPoint = new Point(GyroPositionX, -GyroPositionY);

            if (currentGyroPoint != lastGyroPoint)
            {
                lastGyroPoint = new Point(GyroPositionX, -GyroPositionY);
            }

            xPoint = xFromMid;
            yPoint = yFromMid;

            if (!lockedPointer)
            {
                pointer = GetPoint(xPoint, yPoint);
            }
            MoveShape(pointerFigure, pointer);
            if (!accuracyTest)
            {
                ColorCell(pointer);
            }
            KinectGesture gesture = GestureParser.AwaitingGesture;

            if (runningTest && runningGesture)
            {
                if (gesture != null)
                {
                    UnlockPointer();
                    GestureParser.Pause(true);
                    Cell currCell     = GetCell(pointer);
                    bool hit          = currCell == target;
                    bool correctShape = true;

                    string           shape     = target.Shape is Ellipse ? "circle" : "square";
                    GestureDirection direction = GestureParser.GetDirectionContext();
                    GestureType      type      = GestureParser.GetTypeContext();
                    if (direction == GestureDirection.Push)
                    {
                        correctShape = shape == gesture.Shape;
                    }
                    currentTest.TargetHit(hit, correctShape, target, pointer, currCell, currentLength);
                    if (hit && !correctShape)
                    {
                        hit = false;
                    }
                    TargetHit(target, hit);
                }
            }
            ExtendedDraw(gesture);
        }