Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace TextBoxTeste
- {
- public partial class Form1 : Form
- {
- TextBox[,] txts = new TextBox[16, 16];
- public Form1()
- {
- CriarGrelhaTextBoxs();
- InitializeComponent();
- //=========================================
- comboBox1.Text = "Select one Bag of Words";
- comboBox1.Items.Add("Animais");
- comboBox1.SelectedItem = "";
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- public void CriarGrelhaTextBoxs() // Função que cria a matriz e as texbox's.
- {
- for (int y = 0; y < 16; y++)
- {
- for (int x = 0; x < 16; x++)
- {
- TextBox txt = new TextBox();
- txt.Left = x * 20;
- txt.Top = y * 20;
- txt.Width = 21;
- txt.MaxLength = 1;
- txt.Font = new System.Drawing.Font("Perpetua Titling MT", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- txt.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
- this.Controls.Add(txt);
- txts[x, y] = txt;
- txts[x, y].CharacterCasing = CharacterCasing.Upper; // Tornar todas as letras em Maisculas*
- }
- }
- Cores(); // Chamar a função para introduzir as cores no tabuleiro
- NumerarTabuleiro(); // Chamar a função para introduzir os numeros ao redor do tabuleiro
- }
- public void Cores()
- {
- txts[8, 8].BackColor = System.Drawing.Color.Yellow; // centro
- txts[14, 14].BackColor = System.Drawing.Color.LightGreen; // LightGreen
- txts[13, 13].BackColor = System.Drawing.Color.LightGreen;
- txts[12, 12].BackColor = System.Drawing.Color.LightGreen;
- txts[11, 11].BackColor = System.Drawing.Color.LightGreen;
- txts[10, 10].BackColor = System.Drawing.Color.LightGreen;
- txts[9, 9].BackColor = System.Drawing.Color.LightGreen;
- txts[7, 7].BackColor = System.Drawing.Color.LightGreen;
- txts[6, 6].BackColor = System.Drawing.Color.LightGreen;
- txts[5, 5].BackColor = System.Drawing.Color.LightGreen;
- txts[4, 4].BackColor = System.Drawing.Color.LightGreen;
- txts[3, 3].BackColor = System.Drawing.Color.LightGreen;
- txts[2, 2].BackColor = System.Drawing.Color.LightGreen;
- txts[2, 14].BackColor = System.Drawing.Color.LightGreen;
- txts[3, 13].BackColor = System.Drawing.Color.LightGreen;
- txts[4, 12].BackColor = System.Drawing.Color.LightGreen;
- txts[5, 11].BackColor = System.Drawing.Color.LightGreen;
- txts[6, 10].BackColor = System.Drawing.Color.LightGreen;
- txts[7, 9].BackColor = System.Drawing.Color.LightGreen;
- txts[14, 2].BackColor = System.Drawing.Color.LightGreen;
- txts[13, 3].BackColor = System.Drawing.Color.LightGreen;
- txts[12, 4].BackColor = System.Drawing.Color.LightGreen;
- txts[11, 5].BackColor = System.Drawing.Color.LightGreen;
- txts[10, 6].BackColor = System.Drawing.Color.LightGreen;
- txts[9, 7].BackColor = System.Drawing.Color.LightGreen;
- txts[8, 1].BackColor = System.Drawing.Color.LightSalmon; // vermelho
- txts[1, 8].BackColor = System.Drawing.Color.LightSalmon;
- txts[8, 15].BackColor = System.Drawing.Color.LightSalmon;
- txts[15, 8].BackColor = System.Drawing.Color.LightSalmon;
- txts[15, 1].BackColor = System.Drawing.Color.LightSalmon;
- txts[1, 15].BackColor = System.Drawing.Color.LightSalmon;
- txts[1, 1].BackColor = System.Drawing.Color.LightSalmon;
- txts[15, 15].BackColor = System.Drawing.Color.LightSalmon;
- txts[6, 14].BackColor = System.Drawing.Color.CornflowerBlue; // azul
- txts[10, 14].BackColor = System.Drawing.Color.CornflowerBlue;
- txts[2, 6].BackColor = System.Drawing.Color.CornflowerBlue;
- txts[2, 10].BackColor = System.Drawing.Color.CornflowerBlue;
- txts[6, 2].BackColor = System.Drawing.Color.CornflowerBlue;
- txts[10, 2].BackColor = System.Drawing.Color.CornflowerBlue;
- txts[14, 10].BackColor = System.Drawing.Color.CornflowerBlue;
- txts[14, 6].BackColor = System.Drawing.Color.CornflowerBlue;
- txts[8, 12].BackColor = System.Drawing.Color.LightBlue; // LightBlue
- txts[7, 13].BackColor = System.Drawing.Color.LightBlue;
- txts[9, 13].BackColor = System.Drawing.Color.LightBlue;
- txts[3, 7].BackColor = System.Drawing.Color.LightBlue;
- txts[3, 9].BackColor = System.Drawing.Color.LightBlue;
- txts[4, 8].BackColor = System.Drawing.Color.LightBlue;
- txts[7, 3].BackColor = System.Drawing.Color.LightBlue;
- txts[9, 3].BackColor = System.Drawing.Color.LightBlue;
- txts[8, 4].BackColor = System.Drawing.Color.LightBlue;
- txts[13, 7].BackColor = System.Drawing.Color.LightBlue;
- txts[13, 9].BackColor = System.Drawing.Color.LightBlue;
- txts[12, 8].BackColor = System.Drawing.Color.LightBlue;
- txts[1, 4].BackColor = System.Drawing.Color.LightBlue;
- txts[4, 1].BackColor = System.Drawing.Color.LightBlue;
- txts[1, 12].BackColor = System.Drawing.Color.LightBlue;
- txts[4, 15].BackColor = System.Drawing.Color.LightBlue;
- txts[12, 15].BackColor = System.Drawing.Color.LightBlue;
- txts[15, 12].BackColor = System.Drawing.Color.LightBlue;
- txts[12, 1].BackColor = System.Drawing.Color.LightBlue;
- txts[15, 3].BackColor = System.Drawing.Color.LightBlue;
- } // Função para por as cores no tabuleiro
- public void NumerarTabuleiro()
- {
- // Escrever os limites do tabuleiro
- txts[0, 0].Text = "0";
- txts[0, 1].Text = "1";
- txts[0, 2].Text = "2";
- txts[0, 3].Text = "3";
- txts[0, 4].Text = "4";
- txts[0, 5].Text = "5";
- txts[0, 6].Text = "6";
- txts[0, 7].Text = "7";
- txts[0, 8].Text = "8";
- txts[0, 9].Text = "9";
- txts[0, 10].Text = "10";
- txts[0, 11].Text = "11";
- txts[0, 12].Text = "12";
- txts[0, 13].Text = "13";
- txts[0, 14].Text = "14";
- txts[0, 15].Text = "15";
- //====================
- txts[0, 0].Text = "0";
- txts[1, 0].Text = "1";
- txts[2, 0].Text = "2";
- txts[3, 0].Text = "3";
- txts[4, 0].Text = "4";
- txts[5, 0].Text = "5";
- txts[6, 0].Text = "6";
- txts[7, 0].Text = "7";
- txts[8, 0].Text = "8";
- txts[9, 0].Text = "9";
- txts[10, 0].Text = "10";
- txts[11, 0].Text = "11";
- txts[12, 0].Text = "12";
- txts[13, 0].Text = "13";
- txts[14, 0].Text = "14";
- txts[15, 0].Text = "15";
- } // Função para enumerar o tabuleiro
- private void button1_Click(object sender, EventArgs e)
- {
- if (txts[7, 3].Text == "E" && txts[7, 4].Text == "L" && txts[7, 5].Text == "E" && txts[7, 6].Text == "F" && txts[7, 7].Text == "A" && txts[7, 8].Text == "N" && txts[7, 9].Text == "T" && txts[7, 10].Text == "E" &&// Elefante
- txts[12, 4].Text == "U" && txts[12, 5].Text == "R" && txts[12, 6].Text == "S" && txts[12, 7].Text == "O" && // Urso
- txts[13, 4].Text == "G" && txts[13, 5].Text == "A" && txts[13, 6].Text == "T" && txts[13, 7].Text == "O" && // Gato
- txts[9, 5].Text == "C" && txts[10, 5].Text == "O" && txts[11, 5].Text == "B" && txts[12, 5].Text == "R" && txts[13, 5].Text == "A" && // Cobra
- txts[9, 5].Text == "C" && txts[9, 6].Text == "A" && txts[9, 7].Text == "O" && // cao /*
- txts[3, 7].Text == "P" && txts[4, 7].Text == "A" && txts[5, 7].Text == "S" && txts[6, 7].Text == "S" && txts[7, 7].Text == "A" && txts[8, 7].Text == "R" && txts[9, 7].Text == "O" && // Passaro
- txts[3, 7].Text == "P" && txts[3, 8].Text == "A" && txts[3, 9].Text == "P" && txts[3, 10].Text == "A" && txts[3, 11].Text == "G" && txts[3, 12].Text == "A" && txts[3, 13].Text == "I" && txts[3, 14].Text == "O" && // Papagaio
- txts[2, 12].Text == "V" && txts[3, 12].Text == "A" && txts[4, 12].Text == "C" && txts[5, 12].Text == "A" && // Vaca
- txts[2, 13].Text == "G" && txts[3, 13].Text == "I" && txts[4, 13].Text == "R" && txts[5, 13].Text == "A" && txts[6, 13].Text == "F" && txts[7, 13].Text == "A" && // Girafa
- txts[3, 14].Text == "O" && txts[4, 14].Text == "V" && txts[5, 14].Text == "E" && txts[6, 14].Text == "L" && txts[7, 14].Text == "H" && txts[8, 14].Text == "A" ) // Ovelha
- {
- MessageBox.Show("Parabéns, conseguiste completar as palavras!");
- }
- else
- {
- MessageBox.Show("Ups, parece que algo não está bem!");
- }
- } // Função para verificar se todas as posições correspondem ao que é pedido
- private void btnVerificarBoW_Click(object sender, EventArgs e)
- {
- if (comboBox1.Text == "Animais")
- {
- listBox1.Items.Clear();
- listBox1.Items.AddRange(new Object[] { "Passaro", "Cao", "Gato", "Elefante", "Cobra", "Ovelha", "Papagaio", "Vaca", "Urso", "Girafa" });
- txts[7, 3].Text = "E";
- txts[12, 4].Text = "U";
- txts[13, 4].Text = "G";
- txts[9, 5].Text = "C";
- txts[3, 7].Text = "P";
- txts[2, 12].Text = "V";
- txts[2, 13].Text = "G";
- txts[3, 14].Text = "O";
- }
- else
- {
- MessageBox.Show("Sistema: ERRO btnVerificarBoW_Click");
- }
- } // Função de seleção de palavras e inserção de letras no tabuleiro
- private void button2_Click(object sender, EventArgs e)
- {
- if (comboBox1.Text == "Animais")
- {
- txts[7, 3].Text = "E";
- txts[7, 4].Text = "L";
- txts[7, 5].Text = "E";
- txts[7, 6].Text = "F";
- txts[7, 7].Text = "A";
- txts[7, 8].Text = "N";
- txts[7, 9].Text = "T";
- txts[7, 10].Text = "E";
- // Elefante
- txts[12, 4].Text = "U";
- txts[12, 5].Text = "R";
- txts[12, 6].Text = "S";
- txts[12, 7].Text = "O";
- // Urso
- txts[13, 4].Text = "G";
- txts[13, 5].Text = "A";
- txts[13, 6].Text = "T";
- txts[13, 7].Text = "O";
- // Gato
- txts[9, 5].Text = "C";
- txts[10, 5].Text = "O";
- txts[11, 5].Text = "B";
- txts[12, 5].Text = "R";
- txts[13, 5].Text = "A";
- // Cobra
- txts[9, 5].Text = "C";
- txts[9, 6].Text = "A";
- txts[9, 7].Text = "O";
- // cao
- txts[3, 7].Text = "P";
- txts[4, 7].Text = "A";
- txts[5, 7].Text = "S";
- txts[6, 7].Text = "S";
- txts[7, 7].Text = "A";
- txts[8, 7].Text = "R";
- txts[9, 7].Text = "O";
- // Passaro
- txts[3, 7].Text = "P";
- txts[3, 8].Text = "A";
- txts[3, 9].Text = "P";
- txts[3, 10].Text = "A";
- txts[3, 11].Text = "G";
- txts[3, 12].Text = "A";
- txts[3, 13].Text = "I";
- txts[3, 14].Text = "O";
- // Papagaio
- txts[2, 12].Text = "V";
- txts[3, 12].Text = "A";
- txts[4, 12].Text = "C";
- txts[5, 12].Text = "A";
- // Vaca
- txts[2, 13].Text = "G";
- txts[3, 13].Text = "I";
- txts[4, 13].Text = "R";
- txts[5, 13].Text = "A";
- txts[6, 13].Text = "F";
- txts[7, 13].Text = "A";
- // Girafa
- txts[3, 14].Text = "O";
- txts[4, 14].Text = "V";
- txts[5, 14].Text = "E";
- txts[6, 14].Text = "L";
- txts[7, 14].Text = "H";
- txts[8, 14].Text = "A";
- }
- } // Função preencher o tabuleiro
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement