Ejemplo n.º 1
0
        private void DrawLines()
        {
            for (int i = 0; i < 10; i++)
            {
                LineOfPegs line = new LineOfPegs(i);
                for (int j = 0; j < 4; j++)
                {
                    RoundButton roundButton = new RoundButton();
                    roundButton.Location  = new Point(40 + 60 * j, 20 + 40 * i);
                    roundButton.Height    = 40;
                    roundButton.Width     = 40;
                    roundButton.BackColor = Color.LightGray;
                    roundButton.Show();
                    roundButton.MouseDown += new MouseEventHandler(RoundButton_Click);
                    Controls.Add(roundButton);
                    line.Attach(roundButton);
                }

                if (i == 0)
                {
                    line.IsActive = true;
                    line.Notify();
                }
                lines.Add(line);
            }
        }
Ejemplo n.º 2
0
 private void Check_Click(object sender, EventArgs e)
 {
     if (lines[currentLine].CheckForColor())
     {
         IChecker iChecker = new Checker.Checker(results[this.currentLine]);
         Checker.Checker.GeneratedValues = generatedValues;
         LineOfPegs currentLine = lines[this.currentLine];
         bool       result      = iChecker.Check(currentLine);
         lines[this.currentLine].IsActive = false;
         lines[this.currentLine].Notify();
         if (result)
         {
             MessageBox.Show("You won");
             IScore iScore = new score.Score();
             int    score  = iScore.CalculateScore(this.currentLine);
             this.Close();
             SaveScreen saveScreen = new SaveScreen(true, score);
             saveScreen.Show();
         }
         else if (!result && this.currentLine == 9)
         {
             MessageBox.Show("You lose!");
             int score = 0;
             this.Close();
             SaveScreen saveScreen = new SaveScreen(false, score);
             saveScreen.Show();
         }
         this.currentLine++;
         lines[this.currentLine].IsActive = true;
         lines[this.currentLine].Notify();
     }
 }