Exemple #1
0
        static void Display_TouchEvent(object sender, Driver.TouchEventArgs args)
        {
            var ctrl = args.ResolveControl();

            if (ctrl == DisplayConfiguration.Page2.btnDate)
            {
                DateFormat = "dd.MM.yyyy";
            }
            else if (ctrl == DisplayConfiguration.Page2.btnTime)
            {
                DateFormat = "HH:mm:ss";
            }
            else if (ctrl == DisplayConfiguration.Page2.btnSleep)
            {
                Display.SetSleepMode(true);
                SleepMode        = true;
                SleepAllowWakeup = DateTime.Now.AddSeconds(1);
            }
            else if (ctrl == DisplayConfiguration.Page2.btnDraw5)
            {
                CurrentPage    = Page.Draw5;
                Display.PageId = DisplayConfiguration.Page3.Id;

                int width  = Display.Width;
                int height = Display.Height;
                //Draw border
                Display.GUI.DrawRectangle(0, 0, width - 1, height - 1, (int)Driver.Color.Red);
                Display.GUI.DrawRectangle(1, 1, width - 2, height - 2, (int)Driver.Color.Red);
                Display.GUI.DrawRectangle(2, 2, width - 3, height - 3, (int)Driver.Color.Red);


                Display.TouchMode   = Driver.TouchMode.Coordinates;
                Draw5Count          = 0;
                Draw5AllowNextTouch = DateTime.Now.AddSeconds(1);
            }
        }
Exemple #2
0
        static void Display_TouchEvent(object sender, Driver.TouchEventArgs args)
        {
            //Process command on another thread
            var thread = new Thread(new ThreadStart(() =>
            {
                if (State == GameState.Game)
                {
                    //When player already won
                    if (SkipGameTouch)
                    {
                        return;
                    }

                    //To be on safe side
                    var ctrl = args.ResolveControl();
                    if (ctrl == null)
                    {
                        return;
                    }

                    //To be on safe side
                    int playGroundIndex = Array.IndexOf(DisplayConfiguration.Page1.PlayGround, ctrl);
                    if (playGroundIndex < 0)
                    {
                        return;
                    }

                    //Is position occupied?
                    if (PlayGroundPositions[playGroundIndex] != Position.Empty)
                    {
                        return;
                    }

                    var position = NextMoveO ? Position.O : Position.X;

                    PlayGroundPositions[playGroundIndex] = position;

                    //Render change
                    DisplayConfiguration.Page1.PlayGround[playGroundIndex].PictureId = NextMoveO ? (byte)DisplayConfiguration.MyPictures.O : (byte)DisplayConfiguration.MyPictures.X;

                    MoveNumber++;
                    if (CheckForWinningPosition(position))
                    {
                        SkipGameTouch = true;
                        if (NextMoveO)
                        {
                            ScoreO++;
                        }
                        else
                        {
                            ScoreX++;
                        }

                        Display.GUI.WriteText("You won!!!", 0, 0, horizontalAligment: Driver.HorizontalAlignment.Center);

                        Thread.Sleep(3000);
                        RenderScorePage();
                        return;
                    }
                    else
                    {
                        if (MoveNumber == 9)
                        {
                            SkipGameTouch = true;
                            Display.GUI.WriteText("It's a tie!", 0, 0, horizontalAligment: Driver.HorizontalAlignment.Center);
                            Thread.Sleep(3000);
                            RenderScorePage();
                            return;
                        }

                        NextMoveO = !NextMoveO;
                        RenderGamePageNextMove();
                    }
                }
            }));

            thread.Start();
        }