Exemple #1
0
        // Show final result at the top
        private void showResultCode(GHI.Glide.UI.Canvas canvas)
        {
            int xPos = 180;

            for (int i = 0; i < 4; i++)
            {
                if (listColors[solution[i]] == 255)
                {
                    canvas.DrawRectangle(GHI.Glide.Colors.Red, 1, xPos, 10, 15, 15, 0, 0, GHI.Glide.Colors.Red, 0, 0, GHI.Glide.Colors.Red, 0, 0, 100);
                }
                else if (listColors[solution[i]] == 32768)
                {
                    canvas.DrawRectangle(GHI.Glide.Colors.Green, 1, xPos, 10, 15, 15, 0, 0, GHI.Glide.Colors.Green, 0, 0, GHI.Glide.Colors.Green, 0, 0, 100);
                }
                else if (listColors[solution[i]] == 16777215)
                {
                    canvas.DrawRectangle(GHI.Glide.Colors.White, 1, xPos, 10, 15, 15, 0, 0, GHI.Glide.Colors.White, 0, 0, GHI.Glide.Colors.White, 0, 0, 100);
                }
                else if (listColors[solution[i]] == 16711680)
                {
                    canvas.DrawRectangle(GHI.Glide.Colors.Blue, 1, xPos, 10, 15, 15, 0, 0, GHI.Glide.Colors.Blue, 0, 0, GHI.Glide.Colors.Blue, 0, 0, 100);
                }
                else if (listColors[solution[i]] == 65535)
                {
                    canvas.DrawRectangle(GHI.Glide.Colors.Yellow, 1, xPos, 10, 15, 15, 0, 0, GHI.Glide.Colors.Yellow, 0, 0, GHI.Glide.Colors.Yellow, 0, 0, 100);
                }
                else if (listColors[solution[i]] == 42495)
                {
                    canvas.DrawRectangle(GHI.Glide.Colors.Orange, 1, xPos, 10, 15, 15, 0, 0, GHI.Glide.Colors.Orange, 0, 0, GHI.Glide.Colors.Orange, 0, 0, 100);
                }
                xPos += 20;
            }
        }
Exemple #2
0
        // Show result for each row in the rectangles
        private bool populateVisualResult(int fc, int hc)
        {
            bool result    = false;
            int  fullWrong = 4 - (fc + hc);

            GHI.Glide.UI.Canvas canvas = new GHI.Glide.UI.Canvas();
            int xPosition = 100;

            masterMind.AddChild(canvas);
            for (int i = 0; i < fc; i++)
            {
                xPosition += 20;
                canvas.DrawRectangle(GHI.Glide.Colors.Green, 1, xPosition, yPostition, 10, 10, 0, 0, GHI.Glide.Colors.Green, 0, 0, GHI.Glide.Colors.Green, 0, 0, 100);
            }

            for (int i = 0; i < hc; i++)
            {
                xPosition += 20;
                canvas.DrawRectangle(GHI.Glide.Colors.Gray, 1, xPosition, yPostition, 10, 10, 0, 0, GHI.Glide.Colors.Gray, 0, 0, GHI.Glide.Colors.Gray, 0, 0, 100);
            }

            for (int i = 0; i < fullWrong; i++)
            {
                xPosition += 20;
                canvas.DrawRectangle(GHI.Glide.Colors.Red, 1, xPosition, yPostition, 10, 10, 0, 0, GHI.Glide.Colors.Red, 0, 0, GHI.Glide.Colors.Red, 0, 0, 100);
            }


            if (fc == 4 | round == 10)
            {
                showResultCode(canvas);
                txtResult = (GHI.Glide.UI.TextBlock)masterMind.GetChildByName("txtResult");
                if (fc == 4)
                {
                    txtResult.Text      = "You Win!  ";
                    txtResult.FontColor = GHI.Glide.Colors.Green;
                }
                else
                {
                    txtResult.Text      = "You Lost ! Code is :  ";
                    txtResult.FontColor = GHI.Glide.Colors.Red;
                }
                result = true;
            }

            return(result);
        }
        // Show result for each row in the rectangles
        private bool populateVisualResult(int fc, int hc)
        {
            bool result = false;
            int fullWrong = 4 - (fc + hc);
            GHI.Glide.UI.Canvas canvas = new GHI.Glide.UI.Canvas();
            int xPosition = 100;
            masterMind.AddChild(canvas);
            for (int i = 0; i < fc; i++)
            {
                xPosition += 20;
                canvas.DrawRectangle(GHI.Glide.Colors.Green, 1, xPosition, yPostition, 10, 10, 0, 0, GHI.Glide.Colors.Green, 0, 0, GHI.Glide.Colors.Green, 0, 0, 100);

            }

            for (int i = 0; i < hc; i++)
            {
                xPosition += 20;
                canvas.DrawRectangle(GHI.Glide.Colors.Gray, 1, xPosition, yPostition, 10, 10, 0, 0, GHI.Glide.Colors.Gray, 0, 0, GHI.Glide.Colors.Gray, 0, 0, 100);

            }

            for (int i = 0; i < fullWrong; i++)
            {
                xPosition += 20;
                canvas.DrawRectangle(GHI.Glide.Colors.Red, 1, xPosition, yPostition, 10, 10, 0, 0, GHI.Glide.Colors.Red, 0, 0, GHI.Glide.Colors.Red, 0, 0, 100);
            }

            if (fc == 4 | round == 10)
            {
                showResultCode(canvas);
                txtResult = (GHI.Glide.UI.TextBlock)masterMind.GetChildByName("txtResult");
                if (fc == 4)
                {
                    txtResult.Text = "You Win!  ";
                    txtResult.FontColor = GHI.Glide.Colors.Green;
                }
                else
                {
                    txtResult.Text = "You Lost ! Code is :  ";
                    txtResult.FontColor = GHI.Glide.Colors.Red;
                }
                result = true;
            }

            return result;
        }