Ejemplo n.º 1
0
 private void FormatButton(ref JeoButton btn)
 {
     btn.Dock        = DockStyle.Fill;
     btn.ForeColor   = Color.Yellow;
     btn.BackColor   = Color.Blue;
     btn.UseMnemonic = false;
     btn.Font        = new Font("Arial", GENERALSIZE, FontStyle.Bold);
 }
Ejemplo n.º 2
0
        private Form BuildMain(RoundType round)
        {
            Form retForm = new Form();

            retForm.BackColor = Color.LightGray;

            viewPanel             = new TableLayoutPanel();
            viewPanel.Dock        = DockStyle.Fill;
            viewPanel.RowCount    = 2;
            viewPanel.ColumnCount = 6;
            viewPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 65F));
            viewPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
            viewPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.66F));
            viewPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.66F));
            viewPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.66F));
            viewPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.66F));
            viewPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.66F));
            viewPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16.66F));

            cashLabel = new Button();
            FormatButton(ref cashLabel);
            cashLabel.Text = "Your Current Winnings: $" + game.Cash.ToString();
            viewPanel.Controls.Add(cashLabel);
            viewPanel.SetColumnSpan(cashLabel, 4);

            Button newGame = new Button();

            FormatButton(ref newGame);
            newGame.Text   = "New Game";
            newGame.Click += new EventHandler(NewHandler);
            viewPanel.Controls.Add(newGame);

            Button exit = new Button();

            FormatButton(ref exit);
            exit.Click += new EventHandler(ExitHandler);
            exit.Text   = "Exit Game";
            viewPanel.Controls.Add(exit);

            List <JeoCategory <JeoQuestion> > iterateRound = new List <JeoCategory <JeoQuestion> >();

            if (round == RoundType.First)
            {
                iterateRound = game.FirstRound;
            }
            if (round == RoundType.Second)
            {
                iterateRound = game.SecondRound;
            }
            foreach (JeoCategory <JeoQuestion> category in iterateRound)
            {
                //panel that holds a single category
                TableLayoutPanel cat = new TableLayoutPanel();
                cat.Dock     = DockStyle.Fill;
                cat.RowCount = 6;
                cat.RowStyles.Add(new RowStyle(SizeType.Percent, 16.66F));
                cat.RowStyles.Add(new RowStyle(SizeType.Percent, 16.66F));
                cat.RowStyles.Add(new RowStyle(SizeType.Percent, 16.66F));
                cat.RowStyles.Add(new RowStyle(SizeType.Percent, 16.66F));
                cat.RowStyles.Add(new RowStyle(SizeType.Percent, 16.66F));
                cat.RowStyles.Add(new RowStyle(SizeType.Percent, 16.66F));

                //category heading button
                Button catButton = new Button();
                catButton.Text = category.CatName;
                FormatButton(ref catButton);
                cat.Controls.Add(catButton);

                //handles different question values for each round
                int roundMultiplier = 0;
                if (round == RoundType.First)
                {
                    roundMultiplier = 200;
                }
                if (round == RoundType.Second)
                {
                    roundMultiplier = 400;
                }

                //try to add a question for each value. If one isn't found, add the category's daily double question
                JeoButton addButton = null;
                for (int i = 0; i < 5; i++)
                {
                    addButton = new JeoButton(category.Find(x => x.Value == (i * roundMultiplier) + roundMultiplier));
                    if (addButton.Question == null)
                    {
                        addButton = new JeoButton(category.Find(x => x.Type == QType.Double));
                    }

                    //format and register question button
                    addButton.Text = "$" + ((i * roundMultiplier) + roundMultiplier).ToString();
                    FormatButton(ref addButton);
                    addButton.Font   = new Font("Arial", VALUESIZE, FontStyle.Bold);
                    addButton.Click += new EventHandler(QChosen);
                    cat.Controls.Add(addButton);
                    if (round == RoundType.First)
                    {
                        game.FRQuestions.Add(addButton);
                    }
                    if (round == RoundType.Second)
                    {
                        game.SRQuestions.Add(addButton);
                    }
                }
                viewPanel.Controls.Add(cat);
            }
            retForm.Controls.Add(viewPanel);
            retForm.FormBorderStyle = FormBorderStyle.None;
            retForm.WindowState     = FormWindowState.Maximized;
            return(retForm);
        }
Ejemplo n.º 3
0
        private void QChosen(object e, EventArgs args)
        {
            viewPanel.Hide();
            JeoButton btn = (JeoButton)e;

            btn.Text     = "";
            btn.Click   -= QChosen;
            btn.Answered = true;
            currentQ     = btn.Question;

            if (currentQ.Type == QType.Standard)
            {
                Form view = new Form();
                view.FormBorderStyle = FormBorderStyle.None;
                view.BackColor       = Color.LightGray;
                view.Size            = new Size(Screen.PrimaryScreen.WorkingArea.Width, (70 * 3));
                TableLayoutPanel parent = new TableLayoutPanel();
                parent.Dock        = DockStyle.Fill;
                parent.RowCount    = 3;
                parent.ColumnCount = 2;
                parent.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 140F));
                parent.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));

                //create and add category heading button
                Button cat = new Button();
                FormatButton(ref cat);
                cat.Text = btn.Question.Category;
                parent.Controls.Add(cat);
                parent.SetColumnSpan(cat, 2);

                //create and add value display button
                Button val = new Button();
                FormatButton(ref val);
                val.Text = "$" + btn.Question.Value;
                parent.Controls.Add(val);

                //create and add clue display button. Set font to be smaller than default formatting
                Button clu = new Button();
                FormatButton(ref clu);
                clu.Font = new Font("Arial", 15, FontStyle.Bold);
                clu.Text = btn.Question.Clue;
                parent.Controls.Add(clu);

                //create and add submit button
                Button sub = new Button();
                FormatButton(ref sub);
                sub.Text   = "Submit";
                sub.Click += new EventHandler(QSubmited);
                parent.Controls.Add(sub);
                view.AcceptButton = sub;

                //create and add input text field
                input           = new TextBox();
                input.ForeColor = Color.Blue;
                input.BackColor = Color.Yellow;
                input.Font      = new Font("Arial", 20, FontStyle.Bold);
                input.Multiline = true;
                input.Dock      = DockStyle.Fill;
                input.TextAlign = HorizontalAlignment.Center;
                parent.Controls.Add(input);

                view.Controls.Add(parent);
                view.ActiveControl = input;
                view.ShowDialog();
            }
            else if (currentQ.Type == QType.Double)
            {
                Form view = new Form();
                view.Size            = new Size(Screen.PrimaryScreen.WorkingArea.Width, (70 * 4));
                view.BackColor       = Color.LightGray;
                view.FormBorderStyle = FormBorderStyle.None;
                TableLayoutPanel parent = new TableLayoutPanel();
                parent.Dock        = DockStyle.Fill;
                parent.RowCount    = 4;
                parent.ColumnCount = 2;
                parent.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 240F));
                parent.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));
                parent.RowStyles.Add(new RowStyle(SizeType.Absolute, 70));

                //create and add category heading button
                Button cat = new Button();
                FormatButton(ref cat);
                cat.Text = btn.Question.Category;
                parent.Controls.Add(cat);
                parent.SetColumnSpan(cat, 2);

                //create and add value display button
                Button val = new Button();
                FormatButton(ref val);
                val.Text = "Daily Double!";
                parent.Controls.Add(val);

                //create and add clue display button. Set font to be smaller than default formatting
                Button clu = new Button();
                FormatButton(ref clu);
                clu.Font = new Font("Arial", 15, FontStyle.Bold);
                clu.Text = btn.Question.Clue;
                parent.Controls.Add(clu);

                //create and add bid button
                Button bidLabel = new Button();
                FormatButton(ref bidLabel);
                bidLabel.Font = new Font("Arial", 15, FontStyle.Bold);
                if (currentQ.Round == RoundType.First)
                {
                    ddMinMax = 1000;
                }
                if (currentQ.Round == RoundType.Second)
                {
                    ddMinMax = 2000;
                }
                bidLabel.Text = "Your Bid (Maximum $" + Math.Max(ddMinMax, game.Cash) + ")";
                parent.Controls.Add(bidLabel);

                //create and add bid text field
                bid           = new TextBox();
                bid.ForeColor = Color.Blue;
                bid.BackColor = Color.Yellow;
                bid.Font      = new Font("Arial", 20, FontStyle.Bold);
                bid.Multiline = true;
                bid.Dock      = DockStyle.Fill;
                bid.TextAlign = HorizontalAlignment.Center;
                parent.Controls.Add(bid);

                //create and add submit button
                Button sub = new Button();
                FormatButton(ref sub);
                sub.Text   = "Submit";
                sub.Click += new EventHandler(QSubmited);
                parent.Controls.Add(sub);
                view.AcceptButton = sub;

                //create and add input text field
                input           = new TextBox();
                input.ForeColor = Color.Blue;
                input.BackColor = Color.Yellow;
                input.Font      = new Font("Arial", 20, FontStyle.Bold);
                input.Multiline = true;
                input.Dock      = DockStyle.Fill;
                input.TextAlign = HorizontalAlignment.Center;
                parent.Controls.Add(input);

                view.Controls.Add(parent);
                view.ActiveControl = bid;
                view.ShowDialog();
            }
        }