Example #1
0
 public Sudoku()
 {
     InitializeComponent();
     SudokuGrid = GetTwoDimensionalTextBoxArray(this);
     SolvedSudokuGrid = new string[9, 9];
     handlersOn = true;
 }
Example #2
0
 public frmMain()
 {
     InitializeComponent();
     ventanaNewBoard = new NewBoard();
     ventanaPosicionInicial = new PosicionInicial();
     _chessBoardPanels = null;
 }
        private void BuildSudokuTable()
        {
            cells = new TextBox[Program.TABLEWIDTH, Program.TABLEHEIGHT];

            int yCellOffset = 1;
            int xCellOffset = 1;

            int hMargin = 2;
            int vMargin = 0;

            int hlineCellsCounter = 1;
            int vLineCellsCounter = 1;

            for (int i = 0; i < Program.TABLEWIDTH; i++)
            {
                for (int j = 0; j < Program.TABLEHEIGHT; j++)
                {
                    TextBox cell = new TextBox();

                    cell.Parent = panelSudokuTable;
                    cell.BorderStyle = BorderStyle.FixedSingle;
                    cell.Location = new Point(40 * (xCellOffset - 1) + hMargin - 1, 30 * (yCellOffset - 1) + vMargin + 1);
                    cell.Width = 40;
                    cell.Height = 0;
                    cell.TextAlign = HorizontalAlignment.Center;
                    cell.MaxLength = 1;
                    cell.Font = Program.cellsFont;
                    cell.TextChanged += new EventHandler(cell_TextChanged);
                    cell.Show();

                    cells[i, j] = cell;

                    if (hlineCellsCounter % Program.CELLRANKGROUP == 0)
                        hMargin = hMargin + 2;

                    hlineCellsCounter++;
                    xCellOffset++;
                }
                if (vLineCellsCounter % Program.CELLRANKGROUP == 0)
                    vMargin = vMargin + 1;

                vLineCellsCounter++;
                hlineCellsCounter = 1;
                xCellOffset = 1;
                yCellOffset++;
                hMargin = 2;
            }
            cellsRank = Program.MAXVALUE;

            panelSudokuTable.Width = cells[Program.TABLEWIDTH - 1, Program.TABLEWIDTH - 1].Right + 1;
            panelSudokuTable.Height = cells[Program.TABLEHEIGHT - 1, Program.TABLEHEIGHT - 1].Bottom + 1;

            this.Width = panelSudokuTable.Width + 62;
            this.Height = panelSudokuTable.Height + 188;

            panelSudokuTable.Location = new Point(((groupBox1.Width - panelSudokuTable.Width) / 2),
            ((groupBox1.Height - panelSudokuTable.Height) / 2) + 3 );
        }
        public static void SolverMain(formMain _frmMain, TextBox[,] _cells, Delegate _endCallback)
        {
            frmMain = _frmMain;
            cells = _cells;
            endCallBack = _endCallback;

            Tuple<String[,], List<Tuple<int, int>>> solveParam = PrepareToSolve();

            SolverEngine newSolver = new SolverEngine(Program.MAXVALUE, solveParam.Item1, solveParam.Item2, new SolveResultDlg(SolveResult));
            newSolver.StartSolveTask();
        }
    protected void GenerateTextboxes(object sender, EventArgs e)
    {
        Session["state"] = "phase2";

        int x = Convert.ToInt32(this.VariablesTextBox.Text);
        int y = Convert.ToInt32(this.BaseVarsTextBox.Text);

        if (Session["VarTextBoxes"] != null)
            this.VarTextBoxes = (TextBox[,]) Session["VarTextBoxes"];
        else
            this.VarTextBoxes = new TextBox[x + 1,y + 1];

        Table table = new Table();

        for (int i = 0; i < y + 1; i++)
        {
            TableRow trow = new TableRow();

            for (int i2 = 0; i2 < x + 1; i2++)
            {
                TableCell cell = new TableCell();
                Label label = new Label();

                if (VarTextBoxes[i2, i] == null)
                    VarTextBoxes[i2, i] = new TextBox();

                VarTextBoxes[i2, i].Width = 30;
                VarTextBoxes[i2, i].ID = "var[" + i2.ToString() + "," + i.ToString() + "]";
                VarTextBoxes[i2, i].TextChanged += new EventHandler(TextBox_TextChanged);

                if (i2 == x)
                {
                    label.Text = " = ";
                    cell.Controls.Add(label);
                }

                cell.Controls.Add(VarTextBoxes[i2, i]);

                if (i2 < x)
                {
                    label.Text = "x" + (i2 + 1).ToString();
                    cell.Controls.Add(label);
                }

                trow.Cells.Add(cell);
            }

            table.Rows.Add(trow);
        }

        Session["VarTextBoxes"] = VarTextBoxes;
        this.View2.Controls.Add(table);
        this.ShowView();
    }
        private void button1_Click(object sender, EventArgs e)
        {
            linha1 = Convert.ToInt16(matriz1_Linha.Text);
                coluna1 = Convert.ToInt16(matriz1_Coluna.Text);
                linha2 = Convert.ToInt16(matriz2_Linha.Text);
                coluna2 = Convert.ToInt16(matriz2_Coluna.Text);

                TextBoxOverride();

                Matrix1 = new TextBox[linha1, coluna1];
                Matrix2 = new TextBox[linha2, coluna2];
                Criar();
        }
        public SudokuForm()
        {
            InitializeComponent();

            bgWorker = new BackgroundWorker();
            //bgWorker.WorkerSupportsCancellation = true;
            bgWorker.WorkerReportsProgress = true;

            bgWorker.DoWork += new DoWorkEventHandler(bgWorker_DoWork);
            bgWorker.ProgressChanged += new ProgressChangedEventHandler(bgWorker_ProgressChanged);
            bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgWorker_Done);

            textBoxes = new TextBox[9, 9];
        }
        private void btnCriarMatriz2_Click(object sender, EventArgs e)
        {
            groupBoxMatriz2.Controls.Clear();
                /*if (textBox2.Text == null)
                {
                    MessageBox.Show("A linha da matriz 2 é nula.", "Erro");
                    return;
                }

                if (textBox4.Text == null)
                {
                    MessageBox.Show("A coluna da matriz 2 é nula.", "Erro");
                    return;
                }
            linha2 = Convert.ToInt32(textBox2.Text);
            coluna2 = Convert.ToInt32(textBox4.Text);*/
            if (!int.TryParse(textBox2.Text, out linha2))
            {
                MessageBox.Show("A linha da matriz 2 é nula.", "Erro");
                return;
            }
            if (!int.TryParse(textBox4.Text, out coluna2))
            {
                MessageBox.Show("A coluna da matriz 2 é nula.", "Erro");
                return;
            }
            int TamanhoText = groupBoxMatriz2.Width / coluna2;
            Matriz2 = new TextBox[linha2, coluna2];
            TamanhoText = groupBoxMatriz2.Width / coluna2;
            for (int x = 0; x < Matriz2.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz2.GetLength(1); y++)
                {
                    Matriz2[x, y] = new TextBox();
                    Matriz2[x, y].Text = "0";
                    Matriz2[x, y].Top = (x * Matriz2[x, y].Height) + 20;
                    Matriz2[x, y].Left = y * TamanhoText + 6;
                    Matriz2[x, y].Width = TamanhoText;
                    groupBoxMatriz2.Controls.Add(Matriz2[x, y]);
                }
            }
        }
Example #9
0
        private void Criar_Matriz(object sender, EventArgs e)
        {
            int linha = Int16.Parse(Linhas1.Text);
            int coluna = Int16.Parse(Colunas1.Text);

            Matriz = new TextBox[linha, coluna];

            for (i = 0; i < Matriz.GetLength(0); i++)
            {
                for (j = 0; j < Matriz.GetLength(1); j++)
                {
                    Matriz[i, j] = new TextBox();
                    Matriz[i, j].Text = "0";
                    Matriz[i, j].Top = (i * Matriz[i, j].Height) + 100;
                    Matriz[i, j].Left = j * 35 + 15;
                    Matriz[i, j].Width = 30;
                    this.Controls.Add(Matriz[i, j]);
                }
            }
        }
Example #10
0
        public Form1()
        {
            InitializeComponent();
            textBoxArray = new TextBox[9, 9];

            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    var myTextBox = new TextBox();
                    myTextBox.TextAlign = HorizontalAlignment.Center;
                    if (i < 3 && j < 3 || i < 3 && j>5 || i > 2 && i < 6 && j > 2 && j < 6 || i >5 && j < 3 || i > 5 && j > 5)
                    {
                        myTextBox.BackColor = Color.LightBlue;
                    }
                    textBoxArray[i, j] = myTextBox;
                    tableLayoutPanel1.Controls.Add(myTextBox, j, i);
                }
            }
        }
Example #11
0
        /// <summary>
        /// Initiate start values in the form
        /// </summary>
        private void initializeGUI()
        {

            ///Initiate the objects that is needed from the start
            loadSaveManager = new LoadSave();
            lingoGame = new Lingo();
            wordManager = new WordManager();
            resultColors = new Colors[5];
            foundLetters = new Colors[5] { Colors.Red, Colors.Red, Colors.Red,
                    Colors.Red, Colors.Red };
            
            ///Initiate the playboard and put all the 
            ///textboxes to the playboard-array
            playBoard = new TextBox[5, 5];
            getGuiBoxesToArray();

            getFirstLetter(); ///Get the first letter to ease up the game

            updateGUI();
        }
Example #12
0
 public NeoGrade(List<string> NomeColunas, int _linhasQtq, int _largura, int _altura)
 {
     largura = _largura;
     Width = largura;
     Height = _altura;
     linhas = _linhasQtq;
     colunas = NomeColunas.Count;
     Tabela = new TextBox[colunas, linhas + 1];
     for (int y = 0; y <= linhas; ++y)
         for (int x = 0; x < colunas; ++x)
         {
             Tabela[x, y] = new TextBox();
         }
     Panel.AutoScroll = true;
     LstColunaNome = NomeColunas;
     colunaLargura = Width / colunas;
     CorCabecalho = Color.LightBlue;
     CorLinhaImpar = Color.AliceBlue;
     CorLinhaPar = Color.LightGray;
     Mostrar();
 }
Example #13
0
 /// <summary>
 /// Метод, создаёт массив TextBox'ов. Так же задаёт размер дочерней формы.
 /// </summary>
 private void CreateArrayTextBox(int numberOfLines, int numberOfColumns)
 {
     TextBox = new TextBox[numberOfLines, numberOfColumns];
     int amount = 1;
     for (int i = 0; i < numberOfLines; i++)
         for (int j = 0; j < numberOfColumns; j++)
         {
             TextBox[i, j] = new TextBox();
             TextBox[i, j].Name = "TextBox[" + i.ToString() + ", " + j.ToString() + "]";
             TextBox[i, j].Size = new Size(40, 20);
             if (numberOfColumns == 2)
             {
                 TextBox[i, j].Location = new Point(55 + (TextBox[i, j].Size.Width + 5) * j, 34 + (TextBox[i, j].Size.Height + 5) * i);
             }
             if (numberOfColumns == 3)
             {
                 TextBox[i, j].Location = new Point(32 + (TextBox[i, j].Size.Width + 5) * j, 34 + (TextBox[i, j].Size.Height + 5) * i);
             }
             if (numberOfColumns > 3)
             {
                 TextBox[i, j].Location = new Point(10 + (TextBox[i, j].Size.Width + 5) * j, 34 + (TextBox[i, j].Size.Height + 5) * i);
             }
             TextBox[i, j].MaxLength = 5;
             TextBox[i, j].KeyPress += new KeyPressEventHandler(TextBox_KeyPress);
             TextBox[i, j].TabIndex = amount;
             TextBox[i, j].TextAlign = HorizontalAlignment.Center;
             amount++;
             this.Controls.Add(TextBox[i, j]);
         }
     if (numberOfColumns <= 3)
     {
         this.MinimumSize = new Size(32 + (TextBox[0, 0].Size.Width + 5) * 4, 64 + TextBox[numberOfLines - 1, numberOfColumns - 1].Location.Y + 5);
         this.MaximumSize = new Size(32 + (TextBox[0, 0].Size.Width + 5) * 4, 64 + TextBox[numberOfLines - 1, numberOfColumns - 1].Location.Y + 5);
     }
     else
     {
         this.MinimumSize = new Size(65 + TextBox[numberOfLines - 1, numberOfColumns - 1].Location.X, 64 + TextBox[numberOfLines - 1, numberOfColumns - 1].Location.Y + 5);
         this.MaximumSize = new Size(65 + TextBox[numberOfLines - 1, numberOfColumns - 1].Location.X, 64 + TextBox[numberOfLines - 1, numberOfColumns - 1].Location.Y + 5);
     }
 }
        //butao criar --ok
        private void button1_Click(object sender, EventArgs e)
        {
            /*
            if (diferenciadorL1 == matriz1_Linha.SelectedIndex) { recriarM1 = false; } else { recriarM1 = true; }
            if (diferenciadorC1 == matriz1_Coluna.SelectedIndex) { recriarM1 = false; } else { recriarM1 = true; }
            if (diferenciadorL2 == matriz2_Linha.SelectedIndex) { recriarM2 = false; } else { recriarM2 = true; }
            if (diferenciadorC2 == matriz2_Coluna.SelectedIndex) { recriarM2 = false; } else { recriarM2 = true; }

            diferenciadorL1 = matriz1_Linha.SelectedIndex;
            diferenciadorC1 = matriz1_Coluna.SelectedIndex;
            diferenciadorL2 = matriz2_Linha.SelectedIndex;
            diferenciadorC2 = matriz2_Coluna.SelectedIndex;
            */
            if (matriz1_Linha.SelectedIndex == -1) linha1 = 0; else linha1 = Convert.ToInt32(matriz1_Linha.Text);
            if (matriz1_Coluna.SelectedIndex == -1) coluna1 = 0; else coluna1 = Convert.ToInt32(matriz1_Coluna.Text);
            if (matriz2_Linha.SelectedIndex == -1) linha2 = 0; else linha2 = Convert.ToInt16(matriz2_Linha.Text);
            if (matriz2_Coluna.SelectedIndex == -1) coluna2 = 0; else coluna2 = Convert.ToInt16(matriz2_Coluna.Text);

                TextBoxOverride();
                Matrix1 = new TextBox[linha1, coluna1];
                Matrix2 = new TextBox[linha2, coluna2];
                Criar();
        }
 public override void Calcular(TextBox[,] matriz1, TextBox[,] matriz2)
 {
     base.Calcular(matriz1, matriz2);
     TextBox[,] Resultado = Gerador.getInstance().getMatriz3();
     MessageBox.Show("Determinante: " + Determinante(matriz1).ToString());
 }
Example #16
0
 private void InitMatrixA()
 {
     matrixA = InitTextBoxMatrix(layoutMatrixA, n, false);
 }
 public NearestEditableGUICellFinder(TextBox[,] guiTable)
 {
     this.guiTable = guiTable;
 }
        //troca linha por coluna -- ok
        private void Transposta()
        {
            if (MatrixR != null)
            {
                for (int i = 0; i < MatrixR.GetLength(0); i++)
                {
                    for (int j = 0; j < MatrixR.GetLength(1); j++)
                    {
                        if (MatrixR[i, j] != null)
                            groupBox3.Controls.Remove(MatrixR[i, j]);
                    }
                }
            }

            MatrixR = new TextBox[coluna1,linha1];

            for (int i = 0; i < MatrixR.GetLength(0); i++)
            {
                for (int j = 0; j < MatrixR.GetLength(1); j++)
                {
                    MatrixR[i, j] = new TextBox();
                    if(matrizReferente == "Matriz1")MatrixR[i, j].Text = Convert.ToString(Matrix1[j,i].Text);
                    else if (matrizReferente == "Matriz2") MatrixR[i, j].Text = Convert.ToString(Matrix2[j, i].Text);
                    MatrixR[i, j].Top = (i * MatrixR[i, j].Height) + 10;
                    MatrixR[i, j].Left = (j * 35) + 10;
                    MatrixR[i, j].Width = 30;
                    groupBox3.Controls.Add(MatrixR[i, j]);
                }
            }
        }
Example #19
0
 // função para gerar os TextBox da matriz F
 void ReloadF()
 {
     foreach (TextBox text in MF)
     {
         tabPage3.Controls.Remove(text);
     }
     MF = new TextBox[int.Parse(M3C_.Text), int.Parse(M3L_.Text)];
     for (int i = 0; i < int.Parse(M3C_.Text); i++)
     {
         for (int j = 0; j < int.Parse(M3L_.Text); j++)
         {
             MF[i, j] = new TextBox();
             MF[i, j].Location = new Point(M3L_.Location.X + i * 40, 100 + j * 30);
             MF[i, j].Width = 30;
             tabPage3.Controls.Add(MF[i, j]);
         }
     }
 }
        private void btnGerarTranspostM2_Click(object sender, EventArgs e)
        {
            if (Matriz2 == null)
            {
                MessageBox.Show("Matriz nula !", "Error - Matriz");
                return;
            }
            float[,] tempResultante = new float[Matriz2.GetLength(0), Matriz2.GetLength(1)];

            for (int x = 0; x < Matriz2.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz2.GetLength(1); y++)
                {
                    float n = 0;
                    float.TryParse(Matriz2[x, y].Text, out n);
                    tempResultante[x, y] = n;
                    //tempResultante[x, y] = Convert.ToInt32(Matriz2[x, y].Text);
                }
            }

            float[,] tempMatrizResultante = CalculosMatrizes.GerarTransposta(tempResultante);
            int TamanhoText = groupBoxMatriz2.Width / Matriz2.GetLength(1);
            Matriz2 = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
            groupBoxMatriz2.Controls.Clear();
            for (int x = 0; x < Matriz2.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz2.GetLength(1); y++)
                {
                    Matriz2[x, y] = new TextBox();
                    Matriz2[x, y].Text = tempMatrizResultante[x, y].ToString();
                    Matriz2[x, y].Top = (x * Matriz2[x, y].Height) + 20;
                    Matriz2[x, y].Left = y * TamanhoText + 6;
                    Matriz2[x, y].Width = TamanhoText;
                    groupBoxMatriz2.Controls.Add(Matriz2[x, y]);
                }
            }
        }
        //multiplicação -- ok
        private void Mult(object sender, EventArgs e)
        {
            if (MatrixR != null)
            {
                for (int i = 0; i < MatrixR.GetLength(0); i++)
                {
                    for (int j = 0; j < MatrixR.GetLength(1); j++)
                    {
                        if (MatrixR[i, j] != null)
                            groupBox3.Controls.Remove(MatrixR[i, j]);

                    }
                }
            }
            linhaResposta = linha1;
            colunaResposta = coluna2;
            MatrixR = new TextBox[linha1, coluna2];
            double CasasR = 0;
            bool ok = false;
            //enche essa bregueça de ifs
            if (coluna1 == linha2) ok = true;
            if (coluna1 != linha1)
            {
                int m1L = linha2;
                int m1c = coluna2;
                int m2L = linha1;
                int m2c = coluna1;
                if (m1L != m2c) { MessageBox.Show("Impossivel Multiplicar Essas Matrizes"); ; ok = false; }
                else
                {
                    linha1 = m1L;
                    coluna1 = m1c;
                    linha2 = m2L;
                    coluna2 = m2c;
                    MessageBox.Show("A ordem das matrizes foi alterada para tornar possivel a multiplicação");
                    ok = true;
                }
            }

            if (ok)
            {
                if (MatrixR != null)
                {
                    for (int i = 0; i < MatrixR.GetLength(0); i++)
                    {
                        for (int j = 0; j < MatrixR.GetLength(1); j++)
                        {
                            if (MatrixR[i, j] != null)
                                groupBox3.Controls.Remove(MatrixR[i, j]);

                        }
                    }
                }

                for (int i = 0; i < MatrixR.GetLength(0); i++)
                {
                    for (int j = 0; j < MatrixR.GetLength(1); j++)
                    {

                        for (int n = 0; n < coluna1; n++)
                        {
                            CasasR += Convert.ToDouble(Matrix1[i, n].Text) * Convert.ToDouble(Matrix2[n, j].Text);
                        }
                        MatrixR[i, j] = new TextBox();
                        MatrixR[i, j].Text = Convert.ToString(CasasR);
                        MatrixR[i, j].Top = (i * MatrixR[i, j].Height) + 10;
                        MatrixR[i, j].Left = (j * 35) + 10;
                        MatrixR[i, j].Width = 30;
                        groupBox3.Controls.Add(MatrixR[i, j]);
                        CasasR = 0;

                    }
                }
            }
        }
Example #22
0
        private void ViewMatches()
        {
            string    checkup = "SELECT * FROM tblGames WHERE finished = 0";
            DataTable dtCheck = dbh.FillDT(checkup);

            if (dtCheck.Rows.Count > 0)
            {
                string    countPoules = "SELECT DISTINCT pouleId FROM tblGames";
                DataTable pouleCount  = dbh.FillDT(countPoules);

                string    query   = "SELECT team1.teamName AS Home, team2.teamName AS Away, game.HomeTeamScore AS HomeScore, game.AwayTeamScore AS AwayScore, game.Game_ID AS Game_ID FROM ((tblGames AS game INNER JOIN tblTeams AS team1 ON game.HomeTeam = team1.teamNr AND game.PouleId = team1.PouleId) INNER JOIN tblTeams AS team2 ON game.AwayTeam = team2.teamNr AND game.PouleID = team2.PouleId) ORDER BY game.PouleId, game.Game_Id ASC";
                DataTable results = dbh.FillDT(query);
                dbh.CloseConnectionToDB();

                lengthOutterArray = results.Rows.Count;
                rows  = new TextBox[lengthOutterArray, lengthInnerArray];
                index = new int[lengthOutterArray];
                for (int i = 0; i < results.Rows.Count; i++)
                {
                    DataRow match       = results.Rows[i];
                    Label   lblHomeTeam = new Label();
                    Label   lblAwayTeam = new Label();
                    TextBox txtHomePred = new TextBox();
                    TextBox txtAwayPred = new TextBox();

                    lblHomeTeam.TextAlign = ContentAlignment.BottomRight;
                    lblHomeTeam.Text      = match["Home"].ToString();
                    lblHomeTeam.Location  = new Point(15, txtHomePred.Bottom + (i * 30));
                    lblHomeTeam.AutoSize  = true;

                    txtHomePred.Text     = "";
                    txtHomePred.Location = new Point(lblHomeTeam.Width, lblHomeTeam.Top - 3);
                    txtHomePred.Width    = 40;
                    rows[i, 0]           = txtHomePred;

                    txtAwayPred.Text     = "";
                    txtAwayPred.Location = new Point(txtHomePred.Width + lblHomeTeam.Width, txtHomePred.Top);
                    txtAwayPred.Width    = 40;
                    rows[i, 1]           = txtAwayPred;

                    int.TryParse(match["Game_ID"].ToString(), out index[i]);

                    lblAwayTeam.Text     = match["Away"].ToString();
                    lblAwayTeam.Location = new Point(txtHomePred.Width + lblHomeTeam.Width + txtAwayPred.Width, txtHomePred.Top + 3);
                    lblAwayTeam.AutoSize = true;

                    pnlScores.Controls.Add(lblHomeTeam);
                    pnlScores.Controls.Add(txtHomePred);
                    pnlScores.Controls.Add(txtAwayPred);
                    pnlScores.Controls.Add(lblAwayTeam);
                }
            }
            else
            {
                string    quarterQuery  = "SELECT * FROM tblPlayoffs WHERE playoffRankingA = 0 AND playoffRankingB = 0 AND finished = 0";
                DataTable quarterFinals = dbh.FillDT(quarterQuery);

                string    semiQuery  = "SELECT * FROM tblPlayoffs WHERE playoffRankingA = 1 AND playoffRankingB = 1 AND finished = 0";
                DataTable semiFinals = dbh.FillDT(semiQuery);

                string    finalQuery = "SELECT * FROM tblPlayoffs WHERE playoffRankingA = 2 AND playoffRankingB = 2 AND finished = 0";
                DataTable finals     = dbh.FillDT(finalQuery);

                if (quarterFinals.Rows.Count > 0)
                {
                    lengthOutterArray = quarterFinals.Rows.Count;
                    rows  = new TextBox[lengthOutterArray, lengthInnerArray];
                    index = new int[lengthOutterArray];

                    for (int i = 0; i < quarterFinals.Rows.Count; i++)
                    {
                        object[,] obj = { { "id", quarterFinals.Rows[i]["pouleIdA"] }, { "poule", quarterFinals.Rows[i]["pouleRankingA"] } };
                        string    quarterIntern1a = "SELECT * FROM tblTeams WHERE pouleId=@id AND pouleRanking = @poule";
                        DataTable quarterIntern1b = dbh.FillDT(quarterIntern1a, obj);

                        object[,] obj2 = { { "id", quarterFinals.Rows[i]["pouleIdB"] }, { "poule", quarterFinals.Rows[i]["pouleRankingB"] } };
                        string    quarterIntern2a = "SELECT * FROM tblTeams WHERE pouleId=@id AND pouleRanking = @poule";
                        DataTable quarterIntern2b = dbh.FillDT(quarterIntern2a, obj2);



                        //if (quarterFinals.Rows[i]["finished"].ToString() == "0")
                        //{
                        DataRow match       = quarterFinals.Rows[i];
                        Label   lblHomeTeam = new Label();
                        Label   lblAwayTeam = new Label();
                        TextBox txtHomePred = new TextBox();
                        TextBox txtAwayPred = new TextBox();

                        lblHomeTeam.TextAlign = ContentAlignment.BottomRight;
                        lblHomeTeam.Text      = quarterIntern1b.Rows[0]["teamName"].ToString();
                        lblHomeTeam.Location  = new Point(15, txtHomePred.Bottom + (i * 30));
                        lblHomeTeam.AutoSize  = true;

                        txtHomePred.Text     = "";
                        txtHomePred.Location = new Point(lblHomeTeam.Width, lblHomeTeam.Top - 3);
                        txtHomePred.Width    = 40;
                        rows[i, 0]           = txtHomePred;

                        txtAwayPred.Text     = "";
                        txtAwayPred.Location = new Point(txtHomePred.Width + lblHomeTeam.Width, txtHomePred.Top);
                        txtAwayPred.Width    = 40;
                        rows[i, 1]           = txtAwayPred;

                        int.TryParse(match["id"].ToString(), out index[i]);

                        lblAwayTeam.Text     = quarterIntern2b.Rows[0]["teamName"].ToString();
                        lblAwayTeam.Location = new Point(txtHomePred.Width + lblHomeTeam.Width + txtAwayPred.Width, txtHomePred.Top + 3);
                        lblAwayTeam.AutoSize = true;

                        pnlScores.Controls.Add(lblHomeTeam);
                        pnlScores.Controls.Add(txtHomePred);
                        pnlScores.Controls.Add(txtAwayPred);
                        pnlScores.Controls.Add(lblAwayTeam);
                    }
                }
                if (quarterFinals.Rows.Count == 0)
                {
                    lengthOutterArray = semiFinals.Rows.Count;
                    rows  = new TextBox[lengthOutterArray, lengthInnerArray];
                    index = new int[lengthOutterArray];
                    for (int i = 0; i < semiFinals.Rows.Count; i++)
                    {
                        object[,] obj = { { "id", semiFinals.Rows[i]["pouleIdA"] }, { "rank", semiFinals.Rows[i]["pouleRankingA"] } };
                        string    semiIntern1a = "SELECT * FROM tblTeams WHERE pouleId=@id AND pouleRanking = @rank";
                        DataTable semiIntern1b = dbh.FillDT(semiIntern1a, obj);

                        object[,] obj2 = { { "id", semiFinals.Rows[i]["PouleIdB"] }, { "rank", semiFinals.Rows[i]["pouleRankingB"] } };
                        string    semiIntern2a = "SELECT * FROM tblTeams WHERE pouleId=@id AND pouleRanking = @rank";
                        DataTable semiIntern2b = dbh.FillDT(semiIntern2a, obj2);

                        DataRow match       = semiFinals.Rows[i];
                        Label   lblHomeTeam = new Label();
                        Label   lblAwayTeam = new Label();
                        TextBox txtHomePred = new TextBox();
                        TextBox txtAwayPred = new TextBox();

                        lblHomeTeam.TextAlign = ContentAlignment.BottomRight;
                        lblHomeTeam.Text      = semiIntern1b.Rows[0]["teamName"].ToString();
                        lblHomeTeam.Location  = new Point(15, txtHomePred.Bottom + (i * 30));
                        lblHomeTeam.AutoSize  = true;

                        txtHomePred.Text     = "";
                        txtHomePred.Location = new Point(lblHomeTeam.Width, lblHomeTeam.Top - 3);
                        txtHomePred.Width    = 40;
                        rows[i, 0]           = txtHomePred;

                        txtAwayPred.Text     = "";
                        txtAwayPred.Location = new Point(txtHomePred.Width + lblHomeTeam.Width, txtHomePred.Top);
                        txtAwayPred.Width    = 40;
                        rows[i, 1]           = txtAwayPred;

                        int.TryParse(match["id"].ToString(), out index[i]);

                        lblAwayTeam.Text     = semiIntern2b.Rows[0]["teamName"].ToString();
                        lblAwayTeam.Location = new Point(txtHomePred.Width + lblHomeTeam.Width + txtAwayPred.Width, txtHomePred.Top + 3);
                        lblAwayTeam.AutoSize = true;

                        pnlScores.Controls.Add(lblHomeTeam);
                        pnlScores.Controls.Add(txtHomePred);
                        pnlScores.Controls.Add(txtAwayPred);
                        pnlScores.Controls.Add(lblAwayTeam);
                    }
                }
                if (quarterFinals.Rows.Count == 0 && semiFinals.Rows.Count == 0)
                {
                    lengthOutterArray = finals.Rows.Count;
                    rows  = new TextBox[lengthOutterArray, lengthInnerArray];
                    index = new int[lengthOutterArray];

                    for (int i = 0; i < finals.Rows.Count; i++)
                    {
                        object[,] obj = { { "id", finals.Rows[i]["PouleIdA"] }, { "rank", finals.Rows[i]["pouleRankingA"] } };
                        string    finalIntern1a = "SELECT * FROM tblTeams WHERE pouleId=@id AND pouleRanking =@rank";
                        DataTable finalIntern1b = dbh.FillDT(finalIntern1a, obj);

                        object[,] obj2 = { { "id", finals.Rows[i]["PouleIdB"] }, { "rank", finals.Rows[i]["pouleRankingB"] } };
                        string    finalIntern2a = "SELECT * FROM tblTeams WHERE pouleId=@id AND pouleRanking = @rank";
                        DataTable finalIntern2b = dbh.FillDT(finalIntern2a, obj2);

                        DataRow match       = finals.Rows[i];
                        Label   lblHomeTeam = new Label();
                        Label   lblAwayTeam = new Label();
                        TextBox txtHomePred = new TextBox();
                        TextBox txtAwayPred = new TextBox();

                        lblHomeTeam.TextAlign = ContentAlignment.BottomRight;
                        lblHomeTeam.Text      = finalIntern1b.Rows[0]["teamName"].ToString();
                        lblHomeTeam.Location  = new Point(15, txtHomePred.Bottom + (i * 30));
                        lblHomeTeam.AutoSize  = true;

                        txtHomePred.Text     = "";
                        txtHomePred.Location = new Point(lblHomeTeam.Width, lblHomeTeam.Top - 3);
                        txtHomePred.Width    = 40;
                        rows[i, 0]           = txtHomePred;

                        txtAwayPred.Text     = "";
                        txtAwayPred.Location = new Point(txtHomePred.Width + lblHomeTeam.Width, txtHomePred.Top);
                        txtAwayPred.Width    = 40;
                        rows[i, 1]           = txtAwayPred;

                        int.TryParse(match["id"].ToString(), out index[i]);

                        lblAwayTeam.Text     = finalIntern2b.Rows[0]["teamName"].ToString();
                        lblAwayTeam.Location = new Point(txtHomePred.Width + lblHomeTeam.Width + txtAwayPred.Width, txtHomePred.Top + 3);
                        lblAwayTeam.AutoSize = true;

                        pnlScores.Controls.Add(lblHomeTeam);
                        pnlScores.Controls.Add(txtHomePred);
                        pnlScores.Controls.Add(txtAwayPred);
                        pnlScores.Controls.Add(lblAwayTeam);
                    }
                }
            }
        }
Example #23
0
        private void btnGerarFuncaoInv_Click(object sender, EventArgs e)
        {
            if (Matriz == null)
            {
                MessageBox.Show("Matriz nula !", "Error - Matriz");
                return;
            }
            float[,] tempResultante = new float[Matriz.GetLength(0), Matriz.GetLength(1)];
            float[,] inversa        = new float[Matriz.GetLength(0), Matriz.GetLength(1)];
            if (tempResultante.GetLength(0) != 2 || tempResultante.GetLength(1) != 2)
            {
                if (tempResultante.GetLength(0) != 3 || tempResultante.GetLength(1) != 3)
                {
                    MessageBox.Show("Matriz invalida !", "Error - Matriz");
                    return;
                }
            }
            for (int x = 0; x < Matriz.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz.GetLength(1); y++)
                {
                    float n = 0;
                    float.TryParse(Matriz[x, y].Text, out n);
                    tempResultante[x, y] = n;
                }
            }
            matrix = new Matriz(tempResultante);
            if (tempResultante.GetLength(0) == tempResultante.GetLength(1))
            {
                determinante = matrix.Determinante();
            }
            else
            {
                MessageBox.Show("Matriz invalida !", "Error - Matriz");
                return;
            }
            if (determinante == 0)
            {
                MessageBox.Show("Matriz invalida, determinante igual a 0 !", "Error - Matriz");
                return;
            }
            inversa = matrix.Inversa();
            int TamanhoText = groupBoxMatriz.Width / Matriz.GetLength(1);

            for (int x = 0; x < Matriz.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz.GetLength(1); y++)
                {
                    Matriz[x, y].Text = inversa[x, y].ToString();
                }
            }

            if (inversa == null || MatrizResultante == null)
            {
                MessageBox.Show("Matriz nula !", "Error - Matriz");
                return;
            }
            float[,] tempMatrizInversa    = new float[inversa.GetLength(0), inversa.GetLength(1)];
            float[,] tempMatrizResultante = new float[MatrizResultante.GetLength(0), MatrizResultante.GetLength(1)];
            if (tempMatrizInversa.GetLength(1) != tempMatrizResultante.GetLength(0))
            {
                MessageBox.Show("So e possivel a multiplicacao de matrizes onde a coluna da matriz 1 e igual a linha da matriz 2!", "Erro - Multiplicacao Matrizes");
                return;
            }

            for (int x = 0; x < inversa.GetLength(0); x++)
            {
                for (int y = 0; y < inversa.GetLength(1); y++)
                {
                    float n = 0;
                    float.TryParse(inversa[x, y].ToString(), out n);
                    tempMatrizInversa[x, y] = n;
                }
            }
            matrix = new Matriz(tempMatrizInversa);
            for (int x = 0; x < MatrizResultante.GetLength(0); x++)
            {
                for (int y = 0; y < MatrizResultante.GetLength(1); y++)
                {
                    float n = 0;
                    float.TryParse(MatrizResultante[x, y].Text, out n);
                    tempMatrizResultante[x, y] = n;
                }
            }
            result = new Matriz(tempMatrizResultante);

            float[,] tempMatrizResultado = matrix.Multiplicacao(tempMatrizResultante);
            MatrizResultado = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
            int TamanhoText1 = groupBoxResultante.Width;

            groupBoxResultante.Controls.Clear();
            for (int x = 0; x < MatrizResultado.GetLength(0); x++)
            {
                for (int y = 0; y < MatrizResultado.GetLength(1); y++)
                {
                    MatrizResultado[x, y]       = new TextBox();
                    MatrizResultado[x, y].Text  = tempMatrizResultado[x, y].ToString();
                    MatrizResultado[x, y].Top   = (x * MatrizResultado[x, y].Height) + 20;
                    MatrizResultado[x, y].Left  = y * TamanhoText1 + 6;
                    MatrizResultado[x, y].Width = TamanhoText1;
                    groupBoxResultante.Controls.Add(MatrizResultado[x, y]);
                }
            }
        }
Example #24
0
        private void btn_Generate_Click(object sender, EventArgs e)
        {
            try
            {
                _inmultire?.Hide();
                _egal?.Hide();

                if (_matriceInit1 != null)
                {
                    foreach (var box in _matriceInit1)
                    {
                        try
                        {
                            box.Visible = false;
                        }
                        catch
                        {
                            // ignored
                        }
                    }
                }
                if (_matriceInit2 != null)
                {
                    foreach (var box in _matriceInit2)
                    {
                        try
                        {
                            box.Visible = false;
                        }
                        catch
                        {
                            // ignored
                        }
                    }
                }
                if (_matriceFin != null)
                {
                    foreach (var box in _matriceFin)
                    {
                        try
                        {
                            box.Visible = false;
                        }
                        catch
                        {
                            // ignored
                        }
                    }
                }

                _nrLinii = int.Parse(tb_LinesNr.Text);
                if (_nrLinii < 2)
                {
                    MessageBox.Show(@"Matricile trebuie sa aiba cel putin doua linii / coloane");
                    return;
                }
                _matriceInitiala1 = new double[_nrLinii, _nrLinii];
                _matriceInitiala2 = new double[_nrLinii, _nrLinii];
                _matriceFinala    = new double[_nrLinii, _nrLinii];
                _matriceInit1     = new TextBox[_nrLinii, _nrLinii];
                _matriceInit2     = new TextBox[_nrLinii, _nrLinii];
                _matriceFin       = new TextBox[_nrLinii, _nrLinii];

                AfiseazaMatricea(15, _matriceInit1);
                _inmultire = new Label
                {
                    Location = new Point(_matriceInit1[_nrLinii - 1, _nrLinii - 1].Right + 17,
                                         (_matriceInit1[0, _nrLinii - 1].Top + _matriceInit1[_nrLinii - 1, _nrLinii - 1].Bottom) / 2 - 8),
                    Text     = @"*",
                    AutoSize = true,
                    Parent   = this
                };
                AfiseazaMatricea(_matriceInit1[_nrLinii - 1, _nrLinii - 1].Right + 45, _matriceInit2);
                _egal = new Label
                {
                    Location = new Point(_matriceInit2[_nrLinii - 1, _nrLinii - 1].Right + 17,
                                         (_matriceInit2[0, _nrLinii - 1].Top + _matriceInit2[_nrLinii - 1, _nrLinii - 1].Bottom) / 2 - 8),
                    Text     = @"=",
                    AutoSize = true,
                    Parent   = this
                };
                AfiseazaMatricea(_matriceInit2[_nrLinii - 1, _nrLinii - 1].Right + 45, _matriceFin);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Example #25
0
        private void LoadInputLabelsTextBoxes(int num)
        {
            Point     stPt = new Point(25, 50);
            const int gapLT = 20, gapTL = 0;
            const int lableLength = 30, txtBoxLength = 40;
            const int gapRow = 40;

            //Labels and TextBoxes for Giving inputs
            textBoxArray    = new TextBox[num, num + 1];
            ansTextBoxArray = new TextBox[num];

            int tGapX = txtBoxLength + gapTL + lableLength + gapLT;

            for (int i = 0; i < num; i++)
            {
                for (int j = 0; j < num + 1; j++)
                {
                    //Create TextBox
                    TextBox textBox = new TextBox();
                    textBox.Location = new Point(stPt.X + tGapX * j, stPt.Y + i * gapRow);
                    textBox.Size     = new Size(txtBoxLength, 20);
                    textBox.Text     = "0";

                    this.Controls.Add(textBox);
                    textBoxArray[i, j] = textBox;

                    //Create Lable
                    Label label = new Label();
                    label.Location = new Point(stPt.X + lableLength + gapLT + tGapX * j, 3 + stPt.Y + i * gapRow);
                    label.Size     = new Size(lableLength, 13);
                    if (j < num - 1)
                    {
                        label.Text = "X" + (j + 1).ToString() + " +";
                    }
                    else if (j == num - 1)
                    {
                        label.Text = "X" + (j + 1).ToString() + " =";
                    }
                    else
                    {
                        continue;
                    }

                    this.Controls.Add(label);
                }

                //Create TextBox for Answers
                TextBox txtBox = new TextBox();
                txtBox.Location = new Point(stPt.X + lableLength + gapTL + tGapX * i, stPt.Y + (num + 2) * gapRow);
                txtBox.Size     = new Size(txtBoxLength + 20, 20);
                txtBox.ReadOnly = true;

                this.Controls.Add(txtBox);
                ansTextBoxArray[i] = txtBox;

                //Create Lable for answer
                Label lbl = new Label();
                lbl.Location = new Point(stPt.X + tGapX * i, 3 + stPt.Y + (num + 2) * gapRow);
                lbl.Size     = new Size(lableLength, 13);
                lbl.Text     = "X" + (i + 1).ToString() + " =";

                this.Controls.Add(lbl);
            }

            this.Size = new Size(stPt.X + tGapX * (num + 1), 170 + stPt.Y + num * gapRow);
        }
Example #26
0
        public void TaoBangPhepToan(int n)
        {
            this.Text = "Bảng phép nhân " + MainForm.Ten(code) + n.ToString(); TextBox Cell; this.SuspendLayout();

            // Phép toán
            Cell           = new System.Windows.Forms.TextBox();
            Cell.Location  = new System.Drawing.Point(Col_Start, Row_Start);
            Cell.Name      = "Cell";
            Cell.Size      = new System.Drawing.Size(Cell_Width, 20);
            Cell.ReadOnly  = true;
            Cell.TextAlign = HorizontalAlignment.Center;
            this.Controls.Add(Cell);
            txtPhepToan = Cell;

            // Các ô hàng đầu tiên
            txtCot = new TextBox[n];
            for (int j = 0; j < n; j++)
            {
                Cell           = new System.Windows.Forms.TextBox();
                Cell.Location  = new System.Drawing.Point(Col_Start + (Cell_Width + Cell_VGap) * (j + 1), Row_Start);
                Cell.Name      = "Cell";
                Cell.Size      = new System.Drawing.Size(Cell_Width, 20);
                Cell.ReadOnly  = true;
                Cell.TextAlign = HorizontalAlignment.Center;
                this.Controls.Add(Cell);
                txtCot[j] = Cell;
            }

            // Các hàng chi tiết
            txtDong = new TextBox[n];
            txtCell = new TextBox[n, n];

            for (int i = 0; i < n; i++)
            {                 // Ô trên cột đầu tiên
                Cell           = new System.Windows.Forms.TextBox();
                Cell.Location  = new System.Drawing.Point(Col_Start, Row_Start + (Row_Height + Cell_HGap) * (i + 1));
                Cell.Name      = "Cell";
                Cell.Size      = new System.Drawing.Size(Cell_Width, 20);
                Cell.ReadOnly  = true;
                Cell.TextAlign = HorizontalAlignment.Center;
                this.Controls.Add(Cell);
                txtDong[i] = Cell;

                // Các ô chi tiết
                for (int j = 0; j < n; j++)
                {
                    Cell          = new System.Windows.Forms.TextBox();
                    Cell.Location = new System.Drawing.Point(Col_Start + (Cell_Width + Cell_VGap) * (j + 1),
                                                             Row_Start + (Row_Height + Cell_HGap) * (i + 1));
                    Cell.Name      = "Cell";
                    Cell.Size      = new System.Drawing.Size(Cell_Width, 20);
                    Cell.ReadOnly  = true;
                    Cell.TextAlign = HorizontalAlignment.Center;
                    this.Controls.Add(Cell);
                    txtCell[i, j] = Cell;
                }
            }
            //  this.AutoScroll = true;

            this.ResumeLayout(); TinhToan();
        }
Example #27
0
        private void generateBoard(int n, int m)
        {
            const int TxtBoxWidth   = 25;
            const int TxtBoxHeight  = 25;
            const int SquarePadding = 5;
            const int StartPosX     = 20;
            const int StartPosY     = 40;
            const int PanelPadding  = 8;
            const int MaxTextLength = 2;

            if (boardTextBoxes != null && boardTextBoxes.GetLength(0) == m)
            {
                foreach (var box in boardTextBoxes)
                {
                    box.Text = "";
                    styleAsDefault(box);
                }
            }
            else
            {
                SuspendLayout();

                if (boardTextBoxes != null)
                {
                    foreach (var box in boardTextBoxes)
                    {
                        box.Dispose();
                    }
                }
                if (boardPanel != null)
                {
                    boardPanel.Dispose();
                }

                boardPanel          = new Panel();
                boardPanel.Location = new Point(StartPosX, StartPosY);
                boardPanel.Size     = new Size(PanelPadding * 2 + SquarePadding * (n - 1) + m * TxtBoxWidth,
                                               PanelPadding * 2 + SquarePadding * (n - 1) + m * TxtBoxHeight);
                boardPanel.BackColor = Color.Lavender;
                Controls.Add(boardPanel);
                boardTextBoxes = new TextBox[m, m];

                for (var row = 0; row < boardTextBoxes.GetLength(0); row++)
                {
                    for (var col = 0; col < boardTextBoxes.GetLength(1); col++)
                    {
                        boardTextBoxes[row, col]           = new TextBox();
                        boardTextBoxes[row, col].Multiline = true;
                        boardTextBoxes[row, col].Size      = new Size(TxtBoxWidth, TxtBoxHeight);

                        boardTextBoxes[row, col].Location = new Point(
                            PanelPadding + (TxtBoxWidth * col) + (SquarePadding * (col / n))
                            , PanelPadding + (TxtBoxHeight * row) + (SquarePadding * (row / n)));
                        boardTextBoxes[row, col].MaxLength = MaxTextLength;
                        boardTextBoxes[row, col].TextAlign = HorizontalAlignment.Center;

                        boardPanel.Controls.Add(boardTextBoxes[row, col]);
                    }
                }

                ResumeLayout();
            }
        }
Example #28
0
        public Form1()
        {
            CallBackMy.callbackEventHandler  = new CallBackMy.callbackEvent(this.log_updating);
            CallBackMy.callbackEventHandler2 = new CallBackMy.callbackEvent2(this.block_log_updating);
            InitializeComponent();
            numericUpDown1.ValueChanged += new EventHandler(numericUpDown_ValueChanged);
            exmpls.Owner = this;
            meth.Owner   = this;

            //объявление
            mas       = new TextBox[max_value, max_value];
            mas_sum   = new TextBox[4, max_value];
            mas_Panel = new Panel[max_value, max_value];
            mas_Label = new Label[max_value, max_value, max_value];

            //создание и рендер начальной таблицы-базы максимального размера
            tableLayoutPanel1.Visible = false;
            #region Заполнение массивов графических элементов
            //шапка
            for (int column = 0; column < max_value; column++)
            {
                mas_sum[0, column] = new TextBox();
                tableLayoutPanel1.Controls.Add(mas_sum[0, column], 1 + column, 0);
            }

            //тело
            for (int row = 0; row < max_value; row++)
            {
                //левая сумма
                mas_sum[2, row] = new TextBox();
                tableLayoutPanel1.Controls.Add(mas_sum[2, row], 0, 1 + row);

                //тело
                for (int column = 0; column < max_value; column++)
                {
                    //панель
                    mas_Panel[column, row] = new Panel();
                    tableLayoutPanel1.Controls.Add(mas_Panel[column, row], 1 + column, 1 + row);

                    //текстбоксы
                    mas[column, row] = new TextBox();
                    mas_Panel[column, row].Controls.Add(mas[column, row]);

                    //кандидаты
                    for (int k = 0; k < max_value; k++)
                    {
                        int i = (int)(k / 3);
                        int j = k % 3;
                        mas_Label[column, row, k]          = new Label();
                        mas_Label[column, row, k].Text     = Convert.ToString(k + 1);
                        mas_Label[column, row, k].Location = new Point(4 + (10 * (j)), 4 + (12 * (i)));
                        mas_Panel[column, row].Controls.Add(mas_Label[column, row, k]);
                    }
                }

                //правая сумма
                mas_sum[3, row] = new TextBox();
                tableLayoutPanel1.Controls.Add(mas_sum[3, row], max_value + 2, 1 + row);
            }

            //хвост
            for (int column = 0; column < max_value; column++)
            {
                mas_sum[1, column] = new TextBox();
                tableLayoutPanel1.Controls.Add(mas_sum[1, column], 1 + column, 1 + max_value);
            }
            #endregion
            creating_table(max_value, 1);
            #region Общие свойства для всех полей
            for (int i = 0; i < main.n; i++)
            {
                for (int s = 0; s < 4; s++)
                {
                    TextBox ts = mas_sum[s, i];
                    ts.Font         = new System.Drawing.Font("Microsoft Sans Serif", 25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
                    ts.MaxLength    = 1;
                    ts.Width        = 43;
                    ts.Height       = 45;
                    ts.TextAlign    = HorizontalAlignment.Center;
                    ts.TextChanged += new EventHandler(sum_textBox_TextChanged);
                    ts.KeyPress    += new KeyPressEventHandler(textBox_KeyPress);
                    ts.Tag          = Convert.ToString(s);
                }
                for (int j = 0; j < main.n; j++)
                {
                    TextBox t = mas[i, j];
                    t.MaxLength    = 1;
                    t.Width        = 43;
                    t.Height       = 45;
                    t.Font         = new System.Drawing.Font("Microsoft Sans Serif", 25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
                    t.TextAlign    = HorizontalAlignment.Center;
                    t.TextChanged += new EventHandler(textBox_TextChanged);
                    t.KeyPress    += new KeyPressEventHandler(textBox_KeyPress);
                    t.MouseLeave  += new EventHandler(textBox_Leave);
                    t.Location     = new System.Drawing.Point(0, 0);
                    t.Visible      = false;

                    Panel tp = mas_Panel[i, j];
                    tp.Size        = new Size(43, 45);
                    tp.MouseEnter += new EventHandler(panel_Enter);
                    tp.MouseLeave += new EventHandler(panel_Leave);
                    tp.Click      += new EventHandler(panel_Click);
                    tp.Location    = new System.Drawing.Point(0, 0);

                    for (int k = 0; k < main.n; k++)
                    {
                        Label tl = mas_Label[i, j, k];
                        tl.DoubleClick += new EventHandler(label_Click);
                        tl.MouseEnter  += new EventHandler(label_Enter);
                        tl.MouseLeave  += new EventHandler(label_Leave);
                        tl.TextAlign    = ContentAlignment.MiddleCenter;
                        tl.Size         = new Size(13, 13);
                    }
                }
            }
            #endregion
            tableLayoutPanel1.Visible = true;
        }
Example #29
0
        void setLink()
        {
            text = new TextBlock[4,5];
            text[0, 0] = t00;
            text[0, 1] = t01;
            text[0, 2] = t02;
            text[0, 3] = t03;
            text[0, 4] = t04;

            text[1, 0] = t10;
            text[1, 1] = t11;
            text[1, 2] = t12;
            text[1, 3] = t13;
            text[1, 4] = t14;

            text[2, 0] = t20;
            text[2, 1] = t21;
            text[2, 2] = t22;
            text[2, 3] = t23;
            text[2, 4] = t24;

            text[3, 0] = t30;
            text[3, 1] = t31;
            text[3, 2] = t32;
            text[3, 3] = t33;
            text[3, 4] = t34;

            box = new TextBox[4,5];
            box[0, 0] = b00;
            box[0, 1] = b01;
            box[0, 2] = b02;
            box[0, 3] = b03;
            box[0, 4] = b04;

            box[1, 0] = b10;
            box[1, 1] = b11;
            box[1, 2] = b12;
            box[1, 3] = b13;
            box[1, 4] = b14;

            box[2, 0] = b20;
            box[2, 1] = b21;
            box[2, 2] = b22;
            box[2, 3] = b23;
            box[2, 4] = b24;

            box[3, 0] = b30;
            box[3, 1] = b31;
            box[3, 2] = b32;
            box[3, 3] = b33;
            box[3, 4] = b34;

            prob = new KeyValuePair<int, int>[4,5];

            ans = new int[4, 5];
        }
        private void AddEditVisitPlanList_Load(object sender, EventArgs e)
        {
            Sql       sql1 = new Sql();
            DataTable dt1  = sql1.GetRecords("exec SelVisitPlanByUser @p1, @p2", userID, date);

            int y = 0, i = 0;

            visit1 = new Visit[dt1.Rows.Count];

            gb1         = new GroupBox[dt1.Rows.Count];
            cb1         = new ComboBox[dt1.Rows.Count, 3];
            lb1         = new Label[dt1.Rows.Count, 7];
            tb1         = new TextBox[dt1.Rows.Count, 4];
            btn1        = new Button[dt1.Rows.Count, 2];
            check1      = new CheckBox[dt1.Rows.Count];
            dateNew1    = new DateTimePicker[dt1.Rows.Count];
            tbCommentRD = new string[dt1.Rows.Count];

            foreach (DataRow row in dt1.Rows)
            {
                visit1[i] = new Visit(Convert.ToInt32(row.ItemArray[0]), Convert.ToInt32(userID));

                gb1[i] = new GroupBox();

                gb1[i].Location = new Point(10, 40 + y);
                gb1[i].Size     = new Size(807, 320);
                gb1[i].Name     = "gb" + row[0].ToString();

                DateTime date2 = Convert.ToDateTime(row[2]);
                if (date2.Hour < 10)
                {
                    gb1[i].Text = "0" + date2.Hour.ToString() + ":00";
                }
                else
                {
                    gb1[i].Text = date2.Hour.ToString() + ":00";
                }

                lb1[i, 0]          = new Label();
                lb1[i, 0].Location = new Point(8, 20);
                lb1[i, 0].Text     = "Статус:";
                lb1[i, 0].Size     = new Size(44, 13);
                gb1[i].Controls.Add(lb1[i, 0]);

                lb1[i, 1]          = new Label();
                lb1[i, 1].Location = new Point(134, 20);
                lb1[i, 1].Text     = "Название ЛПУ:";
                lb1[i, 1].Size     = new Size(87, 13);
                gb1[i].Controls.Add(lb1[i, 1]);

                lb1[i, 2]          = new Label();
                lb1[i, 2].Location = new Point(311, 20);
                lb1[i, 2].Text     = "Вид деятельности:";
                lb1[i, 2].Size     = new Size(102, 13);
                gb1[i].Controls.Add(lb1[i, 2]);

                lb1[i, 3]          = new Label();
                lb1[i, 3].Location = new Point(8, 67);
                lb1[i, 3].Text     = "1 - План действий:";
                lb1[i, 3].Size     = new Size(101, 13);
                gb1[i].Controls.Add(lb1[i, 3]);

                lb1[i, 4]          = new Label();
                lb1[i, 4].Location = new Point(271, 67);
                lb1[i, 4].Text     = "2 - Выполнение:";
                lb1[i, 4].Size     = new Size(88, 13);
                gb1[i].Controls.Add(lb1[i, 4]);

                lb1[i, 5]          = new Label();
                lb1[i, 5].Location = new Point(535, 67);
                lb1[i, 5].Text     = "3 - Последующие шаги:";
                lb1[i, 5].Size     = new Size(125, 13);
                gb1[i].Controls.Add(lb1[i, 5]);

                lb1[i, 6]          = new Label();
                lb1[i, 6].Location = new Point(8, 197);
                lb1[i, 6].Text     = "Комментарии руководителя:";
                lb1[i, 6].Size     = new Size(153, 13);
                gb1[i].Controls.Add(lb1[i, 6]);


                cb1[i, 0]                   = new ComboBox();
                cb1[i, 0].Location          = new Point(10, 35);
                cb1[i, 0].Size              = new Size(105, 21);
                cb1[i, 0].DropDownStyle     = ComboBoxStyle.DropDownList;
                cb1[i, 0].FormattingEnabled = true;
                cb1[i, 0].Name              = "cmb" + i.ToString();

                DataTable dt2 = new DataTable();
                dt2 = sql1.GetRecords("exec SelVPStatus");
                fillComboBox(dt2, cb1[i, 0], "vpst_name", "vpst_id");
                cb1[i, 0].Enabled = canChangeStatus(visit1[i]);
                cb1[i, 0].SelectedValueChanged += new EventHandler(valid);
                gb1[i].Controls.Add(cb1[i, 0]);

                cb1[i, 1]               = new ComboBox();
                cb1[i, 1].Location      = new Point(137, 35);
                cb1[i, 1].Size          = new Size(171, 21);
                cb1[i, 1].DropDownStyle = ComboBoxStyle.DropDownList;

                DataTable dt3 = new DataTable();
                dt3 = sql1.GetRecords("exec SelULPUbyUserIDVisPlan @p1", userID);
                fillComboBox(dt3, cb1[i, 1], "ulpu_sname", "ulpu_id");
                cb1[i, 1].Enabled = !readlyOnlyEditPlan(visit1[i]);
                gb1[i].Controls.Add(cb1[i, 1]);

                cb1[i, 2]               = new ComboBox();
                cb1[i, 2].Location      = new Point(314, 35);
                cb1[i, 2].Size          = new Size(171, 21);
                cb1[i, 2].DropDownStyle = ComboBoxStyle.DropDownList;

                DataTable dt4 = new DataTable();
                dt4 = sql1.GetRecords("exec SelActivity");
                fillComboBox(dt4, cb1[i, 2], "act_name", "act_id");
                cb1[i, 2].Enabled = !readlyOnlyEditPlan(visit1[i]);
                gb1[i].Controls.Add(cb1[i, 2]);

                tb1[i, 0]                   = new TextBox();
                tb1[i, 0].Location          = new Point(10, 83);
                tb1[i, 0].Multiline         = true;
                tb1[i, 0].MaxLength         = 500;
                tb1[i, 0].Size              = new Size(258, 110);
                tb1[i, 0].Text              = row.ItemArray[6].ToString();
                tb1[i, 0].Name              = "txb0" + i.ToString();
                tb1[i, 0].TextChanged      += new EventHandler(valid);
                tb1[i, 0].MouseDoubleClick += new MouseEventHandler(tbPlan_MouseDoubleClick);

                tb1[i, 0].ReadOnly = readlyOnlyEditPlan(visit1[i]);
                gb1[i].Controls.Add(tb1[i, 0]);

                tb1[i, 1]                   = new TextBox();
                tb1[i, 1].Location          = new Point(274, 83);
                tb1[i, 1].Multiline         = true;
                tb1[i, 1].MaxLength         = 500;
                tb1[i, 1].Size              = new Size(258, 110);
                tb1[i, 1].Text              = row.ItemArray[7].ToString();
                tb1[i, 1].Name              = "txb1" + i.ToString();
                tb1[i, 1].TextChanged      += new EventHandler(valid);
                tb1[i, 1].MouseDoubleClick += new MouseEventHandler(tbFact_MouseDoubleClick);
                tb1[i, 1].ReadOnly          = readlyOnlyEditFact(visit1[i]);
                gb1[i].Controls.Add(tb1[i, 1]);

                tb1[i, 2]                   = new TextBox();
                tb1[i, 2].Location          = new Point(538, 83);
                tb1[i, 2].Multiline         = true;
                tb1[i, 2].MaxLength         = 500;
                tb1[i, 2].Size              = new Size(258, 110);
                tb1[i, 2].Text              = row.ItemArray[8].ToString();
                tb1[i, 2].Name              = "txb2" + i.ToString();
                tb1[i, 2].TextChanged      += new EventHandler(valid);
                tb1[i, 2].MouseDoubleClick += new MouseEventHandler(tbNext_MouseDoubleClick);
                tb1[i, 2].ReadOnly          = readlyOnlyEditFact(visit1[i]);
                gb1[i].Controls.Add(tb1[i, 2]);

                tb1[i, 3]                   = new TextBox();
                tb1[i, 3].Location          = new Point(11, 213);
                tb1[i, 3].Multiline         = true;
                tb1[i, 3].MaxLength         = 500;
                tb1[i, 3].Size              = new Size(500, 100);
                tb1[i, 3].Text              = row.ItemArray[10].ToString();
                tb1[i, 3].TextChanged      += new EventHandler(valid);
                tb1[i, 3].MouseDoubleClick += new MouseEventHandler(tbCom_MouseDoubleClick);
                tb1[i, 3].ReadOnly          = readlyOnlyAddCommRD(visit1[i]);
                tbCommentRD[i]              = row.ItemArray[10].ToString().Trim();
                gb1[i].Controls.Add(tb1[i, 3]);

                check1[i]          = new CheckBox();
                check1[i].Location = new Point(538, 197);
                check1[i].Text     = "Назначена новая встреча";
                check1[i].Size     = new Size(157, 17);
                check1[i].Name     = "chk" + i.ToString();
                if (row.ItemArray[14].ToString() != String.Empty)
                {
                    check1[i].Checked = true;
                }
                check1[i].CheckedChanged += new EventHandler(checkBox1_CheckedChanged);
                gb1[i].Controls.Add(check1[i]);

                dateNew1[i]          = new DateTimePicker();
                dateNew1[i].Location = new Point(538, 220);
                dateNew1[i].Name     = "date" + i.ToString();
                if (row.ItemArray[14].ToString() != String.Empty)
                {
                    dateNew1[i].Value = Convert.ToDateTime(row.ItemArray[14].ToString());
                }
                else
                {
                    dateNew1[i].Visible = false;
                }
                dateNew1[i].Size          = new Size(139, 20);
                dateNew1[i].ValueChanged += new EventHandler(dateNewVisit_ValueChanged);
                gb1[i].Controls.Add(dateNew1[i]);

                btn1[i, 0]          = new Button();
                btn1[i, 0].Location = new Point(725, 290);
                btn1[i, 0].Size     = new Size(75, 23);
                btn1[i, 0].Text     = "Сохранить";
                btn1[i, 0].Name     = "btn0" + i.ToString();
                btn1[i, 0].Click   += new EventHandler(button1_Click);
                gb1[i].Controls.Add(btn1[i, 0]);

                btn1[i, 1]          = new Button();
                btn1[i, 1].Location = new Point(690, 215);
                btn1[i, 1].Size     = new Size(113, 23);
                btn1[i, 1].Text     = "Создать визит";
                btn1[i, 1].Name     = "btn1" + i.ToString();
                btn1[i, 1].Click   += new EventHandler(button2_Click);
                if (row.ItemArray[14].ToString() == String.Empty)
                {
                    btn1[i, 1].Visible = false;
                }
                gb1[i].Controls.Add(btn1[i, 1]);

                y += 330;
                i++;
            }

            this.Controls.AddRange(gb1);
        }
        private void AddEditVisitPlanList_Load(object sender, EventArgs e)
        {
            Sql sql1 = new Sql();
            DataTable dt1 = sql1.GetRecords("exec SelVisitPlanByUser @p1, @p2", userID, date);

            int y = 0, i = 0;

            visit1 = new Visit[dt1.Rows.Count];

            gb1 = new GroupBox[dt1.Rows.Count];
            cb1 = new ComboBox[dt1.Rows.Count, 3];
            lb1 = new Label[dt1.Rows.Count, 7];
            tb1 = new TextBox[dt1.Rows.Count, 4];
            btn1 = new Button[dt1.Rows.Count, 2];
            check1 = new CheckBox[dt1.Rows.Count];
            dateNew1 = new DateTimePicker[dt1.Rows.Count];
            tbCommentRD = new string[dt1.Rows.Count];

            foreach (DataRow row in dt1.Rows)
            {
                visit1[i] = new Visit(Convert.ToInt32(row.ItemArray[0]), Convert.ToInt32(userID));

                gb1[i] = new GroupBox();

                gb1[i].Location = new Point(10, 40 + y);
                gb1[i].Size = new Size(807, 320);
                gb1[i].Name = "gb" + row[0].ToString();

                DateTime date2 = Convert.ToDateTime(row[2]);
                if (date2.Hour < 10)
                    gb1[i].Text = "0" + date2.Hour.ToString() + ":00";
                else
                    gb1[i].Text = date2.Hour.ToString() + ":00";

                lb1[i, 0] = new Label();
                lb1[i, 0].Location = new Point(8, 20);
                lb1[i, 0].Text = "Статус:";
                lb1[i, 0].Size = new Size(44, 13);
                gb1[i].Controls.Add(lb1[i, 0]);

                lb1[i, 1] = new Label();
                lb1[i, 1].Location = new Point(134, 20);
                lb1[i, 1].Text = "Название ЛПУ:";
                lb1[i, 1].Size = new Size(87, 13);
                gb1[i].Controls.Add(lb1[i, 1]);

                lb1[i, 2] = new Label();
                lb1[i, 2].Location = new Point(311, 20);
                lb1[i, 2].Text = "Вид деятельности:";
                lb1[i, 2].Size = new Size(102, 13);
                gb1[i].Controls.Add(lb1[i, 2]);

                lb1[i, 3] = new Label();
                lb1[i, 3].Location = new Point(8, 67);
                lb1[i, 3].Text = "1 - План действий:";
                lb1[i, 3].Size = new Size(101, 13);
                gb1[i].Controls.Add(lb1[i, 3]);

                lb1[i, 4] = new Label();
                lb1[i, 4].Location = new Point(271, 67);
                lb1[i, 4].Text = "2 - Выполнение:";
                lb1[i, 4].Size = new Size(88, 13);
                gb1[i].Controls.Add(lb1[i, 4]);

                lb1[i, 5] = new Label();
                lb1[i, 5].Location = new Point(535, 67);
                lb1[i, 5].Text = "3 - Последующие шаги:";
                lb1[i, 5].Size = new Size(125, 13);
                gb1[i].Controls.Add(lb1[i, 5]);

                lb1[i, 6] = new Label();
                lb1[i, 6].Location = new Point(8, 197);
                lb1[i, 6].Text = "Комментарии руководителя:";
                lb1[i, 6].Size = new Size(153, 13);
                gb1[i].Controls.Add(lb1[i, 6]);

                cb1[i, 0] = new ComboBox();
                cb1[i, 0].Location = new Point(10, 35);
                cb1[i, 0].Size = new Size(105, 21);
                cb1[i, 0].DropDownStyle = ComboBoxStyle.DropDownList;
                cb1[i, 0].FormattingEnabled = true;
                cb1[i, 0].Name = "cmb" + i.ToString();

                DataTable dt2 = new DataTable();
                dt2 = sql1.GetRecords("exec SelVPStatus");
                fillComboBox(dt2, cb1[i, 0], "vpst_name", "vpst_id");
                cb1[i, 0].Enabled = canChangeStatus(visit1[i]);
                cb1[i, 0].SelectedValueChanged += new EventHandler(valid);
                gb1[i].Controls.Add(cb1[i, 0]);

                cb1[i, 1] = new ComboBox();
                cb1[i, 1].Location = new Point(137, 35);
                cb1[i, 1].Size = new Size(171, 21);
                cb1[i, 1].DropDownStyle = ComboBoxStyle.DropDownList;

                DataTable dt3 = new DataTable();
                dt3 = sql1.GetRecords("exec SelULPUbyUserIDVisPlan @p1", userID);
                fillComboBox(dt3, cb1[i, 1], "ulpu_sname", "ulpu_id");
                cb1[i, 1].Enabled = !readlyOnlyEditPlan(visit1[i]);
                gb1[i].Controls.Add(cb1[i, 1]);

                cb1[i, 2] = new ComboBox();
                cb1[i, 2].Location = new Point(314, 35);
                cb1[i, 2].Size = new Size(171, 21);
                cb1[i, 2].DropDownStyle = ComboBoxStyle.DropDownList;

                DataTable dt4 = new DataTable();
                dt4 = sql1.GetRecords("exec SelActivity");
                fillComboBox(dt4, cb1[i, 2], "act_name", "act_id");
                cb1[i, 2].Enabled = !readlyOnlyEditPlan(visit1[i]);
                gb1[i].Controls.Add(cb1[i, 2]);

                tb1[i, 0] = new TextBox();
                tb1[i, 0].Location = new Point(10, 83);
                tb1[i, 0].Multiline = true;
                tb1[i, 0].MaxLength = 500;
                tb1[i, 0].Size = new Size(258, 110);
                tb1[i, 0].Text = row.ItemArray[6].ToString();
                tb1[i, 0].Name = "txb0" + i.ToString();
                tb1[i, 0].TextChanged += new EventHandler(valid);
                tb1[i, 0].MouseDoubleClick += new MouseEventHandler(tbPlan_MouseDoubleClick);

                tb1[i, 0].ReadOnly = readlyOnlyEditPlan(visit1[i]);
                gb1[i].Controls.Add(tb1[i, 0]);

                tb1[i, 1] = new TextBox();
                tb1[i, 1].Location = new Point(274, 83);
                tb1[i, 1].Multiline = true;
                tb1[i, 1].MaxLength = 500;
                tb1[i, 1].Size = new Size(258, 110);
                tb1[i, 1].Text = row.ItemArray[7].ToString();
                tb1[i, 1].Name = "txb1" + i.ToString();
                tb1[i, 1].TextChanged += new EventHandler(valid);
                tb1[i, 1].MouseDoubleClick += new MouseEventHandler(tbFact_MouseDoubleClick);
                tb1[i, 1].ReadOnly = readlyOnlyEditFact(visit1[i]);
                gb1[i].Controls.Add(tb1[i, 1]);

                tb1[i, 2] = new TextBox();
                tb1[i, 2].Location = new Point(538, 83);
                tb1[i, 2].Multiline = true;
                tb1[i, 2].MaxLength = 500;
                tb1[i, 2].Size = new Size(258, 110);
                tb1[i, 2].Text = row.ItemArray[8].ToString();
                tb1[i, 2].Name = "txb2" + i.ToString();
                tb1[i, 2].TextChanged += new EventHandler(valid);
                tb1[i, 2].MouseDoubleClick += new MouseEventHandler(tbNext_MouseDoubleClick);
                tb1[i, 2].ReadOnly = readlyOnlyEditFact(visit1[i]);
                gb1[i].Controls.Add(tb1[i, 2]);

                tb1[i, 3] = new TextBox();
                tb1[i, 3].Location = new Point(11, 213);
                tb1[i, 3].Multiline = true;
                tb1[i, 3].MaxLength = 500;
                tb1[i, 3].Size = new Size(500, 100);
                tb1[i, 3].Text = row.ItemArray[10].ToString();
                tb1[i, 3].TextChanged += new EventHandler(valid);
                tb1[i, 3].MouseDoubleClick += new MouseEventHandler(tbCom_MouseDoubleClick);
                tb1[i, 3].ReadOnly = readlyOnlyAddCommRD(visit1[i]);
                tbCommentRD[i] = row.ItemArray[10].ToString().Trim();
                gb1[i].Controls.Add(tb1[i, 3]);

                check1[i] = new CheckBox();
                check1[i].Location = new Point(538, 197);
                check1[i].Text = "Назначена новая встреча";
                check1[i].Size = new Size(157, 17);
                check1[i].Name = "chk" + i.ToString();
                if (row.ItemArray[14].ToString() != String.Empty)
                    check1[i].Checked = true;
                check1[i].CheckedChanged += new EventHandler(checkBox1_CheckedChanged);
                gb1[i].Controls.Add(check1[i]);

                dateNew1[i] = new DateTimePicker();
                dateNew1[i].Location = new Point(538, 220);
                dateNew1[i].Name = "date" + i.ToString();
                if (row.ItemArray[14].ToString() != String.Empty)
                    dateNew1[i].Value = Convert.ToDateTime(row.ItemArray[14].ToString());
                else
                    dateNew1[i].Visible = false;
                dateNew1[i].Size = new Size(139, 20);
                dateNew1[i].ValueChanged += new EventHandler(dateNewVisit_ValueChanged);
                gb1[i].Controls.Add(dateNew1[i]);

                btn1[i, 0] = new Button();
                btn1[i, 0].Location = new Point(725, 290);
                btn1[i, 0].Size = new Size(75, 23);
                btn1[i, 0].Text = "Сохранить";
                btn1[i, 0].Name = "btn0" + i.ToString();
                btn1[i, 0].Click += new EventHandler(button1_Click);
                gb1[i].Controls.Add(btn1[i, 0]);

                btn1[i, 1] = new Button();
                btn1[i, 1].Location = new Point(690, 215);
                btn1[i, 1].Size = new Size(113, 23);
                btn1[i, 1].Text = "Создать визит";
                btn1[i, 1].Name = "btn1" + i.ToString();
                btn1[i, 1].Click += new EventHandler(button2_Click);
                if (row.ItemArray[14].ToString() == String.Empty)
                    btn1[i, 1].Visible = false;
                gb1[i].Controls.Add(btn1[i, 1]);

                y += 330;
                i++;
            }

            this.Controls.AddRange(gb1);
        }
        private void PreprocessingForm_Load(object sender, EventArgs e)
        {
            var firstLabel = new Label();

            if (compressedMatrix1.GetLength(1) < 3)
            {
                firstLabel.Text = "Left";
            }
            else
            {
                firstLabel.Text = "Left" + "\n" + "compressed matrix";
            }
            firstLabel.Font      = new Font("Comic Sans MS", 10, System.Drawing.FontStyle.Bold);
            firstLabel.ForeColor = Color.MidnightBlue;
            firstLabel.Location  = new System.Drawing.Point(10, 10);
            firstLabel.Height    = 20;
            firstLabel.AutoSize  = true;
            this.Controls.Add(firstLabel);

            var secondLabel = new Label();

            if (compressedMatrix2.GetLength(1) < 3)
            {
                secondLabel.Text = "Right";
            }
            else
            {
                secondLabel.Text = "Right" + "\n" + "compressed matrix";
            }
            secondLabel.Font      = new Font("Comic Sans MS", 10, System.Drawing.FontStyle.Bold);
            secondLabel.ForeColor = Color.MidnightBlue;
            secondLabel.Location  = new System.Drawing.Point(30 + compressedMatrix1.GetLength(1) * dx, 10);
            secondLabel.Height    = 20;
            secondLabel.AutoSize  = true;
            this.Controls.Add(secondLabel);

            var thirdLabel = new Label();

            thirdLabel.Text      = "Preprocessing" + "\n" + "Dictionary";
            thirdLabel.Font      = new Font("Comic Sans MS", 10, System.Drawing.FontStyle.Bold);
            thirdLabel.ForeColor = Color.MidnightBlue;
            thirdLabel.Location  = new System.Drawing.Point(50 + compressedMatrix1.GetLength(1) * dx + compressedMatrix2.GetLength(1) * dx, 10);
            thirdLabel.Height    = 20;
            thirdLabel.AutoSize  = true;
            this.Controls.Add(thirdLabel);

            firstCompressedMatrix  = new TextBox[compressedMatrix1.GetLength(0), compressedMatrix1.GetLength(1)];
            secondCompressedMatrix = new TextBox[compressedMatrix2.GetLength(0), compressedMatrix2.GetLength(1)];
            dictTextBox            = new TextBox[dict.Count, 2];
            for (int i = 0; i < compressedMatrix1.GetLength(0); i++)
            {
                for (int j = 0; j < compressedMatrix1.GetLength(1); j++)
                {
                    firstCompressedMatrix[i, j]          = new TextBox();
                    firstCompressedMatrix[i, j].Text     = compressedMatrix1[i, j];
                    firstCompressedMatrix[i, j].Location = new System.Drawing.Point(10 + j * dx, 20 + firstLabel.Height + i * dy);
                    firstCompressedMatrix[i, j].Size     = new System.Drawing.Size(dx, dy);
                    firstCompressedMatrix[i, j].Visible  = true;
                    this.Controls.Add(firstCompressedMatrix[i, j]);
                }
            }

            for (int i = 0; i < compressedMatrix2.GetLength(0); i++)
            {
                for (int j = 0; j < compressedMatrix2.GetLength(1); j++)
                {
                    secondCompressedMatrix[i, j]          = new TextBox();
                    secondCompressedMatrix[i, j].Text     = compressedMatrix2[i, j];
                    secondCompressedMatrix[i, j].Location = new System.Drawing.Point(20 + compressedMatrix1.GetLength(1) * dx + 10 + j * dx, 20 + firstLabel.Height + i * dy);
                    secondCompressedMatrix[i, j].Size     = new System.Drawing.Size(dx, dy);
                    secondCompressedMatrix[i, j].Visible  = true;
                    this.Controls.Add(secondCompressedMatrix[i, j]);
                }
            }

            int l = 0;

            foreach (KeyValuePair <string, int> keyValue in dict)
            {
                dictTextBox[l, 0]          = new TextBox();
                dictTextBox[l, 0].Text     = keyValue.Key;
                dictTextBox[l, 0].Location = new System.Drawing.Point(50 + compressedMatrix1.GetLength(1) * dx + compressedMatrix2.GetLength(1) * dx, 20 + firstLabel.Height + l * dy);
                dictTextBox[l, 0].Size     = new System.Drawing.Size(dx, dy);
                dictTextBox[l, 0].Visible  = true;
                this.Controls.Add(dictTextBox[l, 0]);

                dictTextBox[l, 1]          = new TextBox();
                dictTextBox[l, 1].Text     = keyValue.Value.ToString();
                dictTextBox[l, 1].Location = new System.Drawing.Point(60 + dx + compressedMatrix1.GetLength(1) * dx + compressedMatrix2.GetLength(1) * dx, 20 + firstLabel.Height + l * dy);
                dictTextBox[l, 1].Size     = new System.Drawing.Size(dx, dy);
                dictTextBox[l, 1].Visible  = true;
                this.Controls.Add(dictTextBox[l, 1]);

                l++;
            }

            this.Size = new Size(110 + firstCompressedMatrix.GetLength(1) * dx + secondCompressedMatrix.GetLength(1) * dx + 2 * dx,
                                 100 + Math.Max(firstCompressedMatrix.GetLength(0), dict.Count) * dy);
        }
Example #33
0
        private void Generate_Click(object sender, EventArgs e)
        {
            if (WidthBox.Text == "" || HeightBox.Text == "")
            {
                MessageBox.Show("Please set the width and height !!", "Opps", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                width = Convert.ToInt32(WidthBox.Text);
                height = Convert.ToInt32(HeightBox.Text);
            }
            boxLocation = this.label1.Location;
            boxes = new TextBox[width, height];
            grid = new double[width, height];
            int a = boxLocation.X;
            int b = boxLocation.Y;

            for (int i = 0; i < width; ++i)
            {
                a = boxLocation.X;
                b += 30;
                for (int j = 0; j < height; ++j)
                {
                    boxes[i, j] = new TextBox();
                    string name ="A" + i.ToString() + j.ToString();
                    boxes[i, j].Name = name;
                    boxes[i, j].Width = 25;
                    boxes[i, j].Height = 25;
                    boxes[i, j].Location = new Point(a, b + 5);
                    a += 30;
                    this.Controls.Add(boxes[i, j]);
                }
            }
        }
Example #34
0
        private void SendButton_Click(object sender, EventArgs e)
        {
            int    n   = 0;
            string sql = "";

            while (n < writes.GetLength(1))
            {
                if (delete[n].Checked)
                {
                    sql += "exec deleteuser @username = '******', @usersurname = '" + txtbox[5, n].Text + "'; ";
                    n++;
                }
                else
                {
                    for (int i = 0; i < 7; i++)
                    {
                        if (i != 3 && i != 4)
                        {
                            if (writes[i, n].Equals(txtbox[i, n].Text))
                            {
                            }
                            else
                            {
                                if ((txtbox[0, n].Text.Equals("")) || (txtbox[5, n].Text.Equals("")))
                                {
                                    MessageBox.Show("Фамилия либо имя пользователя не могут быть пустыми, заполните их");
                                    for (int k = 0; k < 7; k++)
                                    {
                                        if (txtbox[k, n] != null)
                                        {
                                            txtbox[k, n].BackColor = Color.Red;
                                        }
                                    }
                                    break;
                                }
                                else if (n != (writes.GetLength(1) - 1))
                                {
                                    sql += (sqlupdateusers(n));
                                    break;
                                }
                                else
                                {
                                    sql += (sqlinsertusers(n));
                                    break;
                                }
                            }
                        }
                        else
                        {
                            if (writes[i, n].Equals(timebox[i, n].Text))
                            {
                            }
                            else
                            {
                                if ((txtbox[0, n].Text.Equals("")) || (txtbox[5, n].Text.Equals("")))
                                {
                                    MessageBox.Show("Фамилия либо имя пользователя не могут быть пустыми, заполните их");
                                    for (int k = 0; k < 6; k++)
                                    {
                                        if (txtbox[k, n] != null)
                                        {
                                            txtbox[k, n].BackColor = Color.Red;
                                        }
                                    }
                                    break;
                                }
                                else if (n != (writes.GetLength(1) - 1))
                                {
                                    sql += (sqlupdateusers(n));
                                    break;
                                }
                                else
                                {
                                    sql += (sqlinsertusers(n));
                                    break;
                                }
                            }
                        }
                    }
                    if (updatelate[n].Checked)
                    {
                        sql += "exec updatelates @username='******'; ";
                        sql += "exec WorkTimeUpdate @username='******'; ";
                    }
                    n++;
                }
            }
            execsql(sql);
            this.writes  = null;
            this.txtbox  = null;
            this.timebox = null;
            this.Controls.OfType <TextBox>().ToList().ForEach(t => this.Controls.Remove(t));
            this.Controls.OfType <DateTimePicker>().ToList().ForEach(t => this.Controls.Remove(t));
            this.Controls.OfType <CheckBox>().ToList().ForEach(t => this.Controls.Remove(t));
            UsersForm_Load(sender, e);
        }
 /*
 private int diferenciadorL1 = 0;
 private int diferenciadorC1 = 0;
 private int diferenciadorL2;
 private int diferenciadorC2;
 //ajeitar
 private bool recriarM1 = true;
 private bool recriarM2 = true;
 */
 public Form1()
 {
     InitializeComponent();
     Matrix1 = new TextBox[0, 0];
     Matrix2 = new TextBox[0, 0];
 }
Example #36
0
        private void UsersForm_Load(object sender, EventArgs e)
        {
            string        workStartTime = logon_class.get_settings.getWstartTime();
            string        workEndTime   = logon_class.get_settings.getWendTIme();
            int           culumn_count  = 7;
            Form1         mainform      = new Form1();
            string        sql           = "";
            SqlConnection myConnection  = new SqlConnection(Program.sqlstring);
            SqlDataReader myReader      = null;

            myConnection.Open();
            sql = "select * from DbUserLoginUsers order by surname; ";
            SqlCommand write = new SqlCommand(sql, myConnection);

            myReader = write.ExecuteReader();
            count    = 0;
            Label[] label_name = new Label[9];
            for (int i = 0; i < culumn_count; i++)
            {
                label_name[i] = new Label();
                switch (i)
                {
                case 0:
                {
                    label_name[i].Text = "Фамилия";
                    break;
                }

                case 1:
                {
                    label_name[i].Text = "Имя";
                    break;
                }

                case 2:
                {
                    label_name[i].Text = "Отчество";
                    break;
                }

                case 3:
                {
                    label_name[i].Text = "Начало";
                    break;
                }

                case 4:
                {
                    label_name[i].Text = "Окончание";
                    break;
                }

                case 5:
                {
                    label_name[i].Text = "Пользователь";
                    break;
                }

                case 6:
                {
                    label_name[i].Text = "Компьютер";
                    break;
                }
                }
                label_name[i].TextAlign = ContentAlignment.MiddleCenter;
                label_name[i].Name      = "label" + i + "_" + count;
                label_name[i].Location  = new Point(30 + i * 92, 10);
                label_name[i].Size      = new Size(90, 20);
                label_name[i].Visible   = true;
                this.Controls.Add(label_name[i]);
            }
            while (myReader.Read())
            {
                count++;
            }
            myConnection.Close();
            myConnection.Open();
            myReader = write.ExecuteReader();
            timebox  = new DateTimePicker[culumn_count, count + 1];
            txtbox   = new TextBox[culumn_count, count + 1];
            writes   = new string[culumn_count, count + 1];
            int n = 0;

            while (myReader.Read())
            {
                for (int i = 0; i < culumn_count; i++)

                {
                    writes[i, n] = myReader[i].ToString();
                    if (i == 3 || i == 4)
                    {
                        writes[i, n]             = myReader[i].ToString();
                        timebox[i, n]            = new DateTimePicker();
                        timebox[i, n].Name       = n + " " + i;
                        timebox[i, n].Text       = myReader[i].ToString();
                        timebox[i, n].Location   = new Point(label_name[i].Location.X, (label_name[i].Location.Y + 20) * (n + 1));
                        timebox[i, n].Size       = new Size(90, 20);
                        timebox[i, n].ShowUpDown = true;
                        timebox[i, n].Visible    = true;
                        timebox[i, n].Format     = DateTimePickerFormat.Time;
                        this.Controls.Add(timebox[i, n]);
                    }
                    else
                    {
                        writes[i, n]          = myReader[i].ToString();
                        txtbox[i, n]          = new TextBox();
                        txtbox[i, n].Name     = n + " " + i;
                        txtbox[i, n].Text     = myReader[i].ToString();
                        txtbox[i, n].Location = new Point(label_name[i].Location.X, (label_name[i].Location.Y + 20) * (n + 1));
                        txtbox[i, n].Size     = new Size(90, 20);
                        txtbox[i, n].Visible  = true;
                        this.Controls.Add(txtbox[i, n]);
                    }
                }
                n++;
            }
            for (int i = 0; i < culumn_count; i++)
            {
                if (i == 3 || i == 4)
                {
                    timebox[i, n]      = new DateTimePicker();
                    timebox[i, n].Name = n + " " + i;
                    if (i == 3)
                    {
                        writes[i, n]       = workStartTime;
                        timebox[i, n].Text = workStartTime;
                    }
                    else
                    {
                        writes[i, n]       = workEndTime;
                        timebox[i, n].Text = workEndTime;
                    }
                    timebox[i, n].Location   = new Point(label_name[i].Location.X, (label_name[i].Location.Y + 20) * (n + 1));
                    timebox[i, n].Size       = new Size(90, 20);
                    timebox[i, n].Visible    = true;
                    timebox[i, n].ShowUpDown = true;
                    timebox[i, n].Format     = DateTimePickerFormat.Time;
                    this.Controls.Add(timebox[i, n]);
                }
                else
                {
                    writes[i, n]          = "";
                    txtbox[i, n]          = new TextBox();
                    txtbox[i, n].Name     = n + " " + i;
                    txtbox[i, n].Text     = "";
                    txtbox[i, n].Location = new Point(label_name[i].Location.X, (label_name[i].Location.Y + 20) * (n + 1));
                    txtbox[i, n].Size     = new Size(90, 20);
                    txtbox[i, n].Visible  = true;
                    this.Controls.Add(txtbox[i, n]);
                }
            }
            delete     = new CheckBox[n + 1];
            updatelate = new CheckBox[n + 1];
            ToolTip tooltip1 = new ToolTip();

            for (int i = 0; i < count + 1; i++)
            {
                updatelate[i] = new CheckBox();
                delete[i]     = new CheckBox();
                tooltip1.SetToolTip(delete[i], "Удалить пользователя");
                tooltip1.SetToolTip(updatelate[i], "Обновить опоздания для отмеченных пользователей");
                delete[i].Location     = new Point(txtbox[culumn_count - 1, 0].Location.X + 100, txtbox[0, i].Location.Y);
                updatelate[i].Location = new Point(delete[i].Location.X + 20, txtbox[0, i].Location.Y);
                if (i == count)
                {
                    updatelate[i].Visible = false;
                    delete[i].Visible     = false;
                }
                Controls.Add(updatelate[i]);
                Controls.Add(delete[i]);
            }
            this.SendButton.Location = new Point(updatelate[0].Location.X + 20, updatelate[0].Location.Y);
            this.Size = new Size(SendButton.Location.X + SendButton.Size.Width + 40, 640);
        }
Example #37
0
        public void setMatrix(int con, int dec, String type)
        {
            int horizontal = 32;
            int vertical   = 32;

            txtArray = new TextBox[con, dec];
            lblDec   = new Label[dec];
            lblCon   = new Label[con];
            eqCon    = new TextBox[con];
            eqDec    = new Label[dec];
            LP       = new TextBox[dec];
            matCon   = con;
            matDec   = dec;

            lblType          = new Label();
            lblType.Size     = new Size(60, 60);
            lblType.Location = new Point(0, 0);
            lblType.Font     = new Font("Arial", 12);
            lblType.Text     = type;
            lblType.Show();
            this.Controls.Add(lblType);
            InitializeComponent();
            cbConBoxes        = new ComboBox[] { cbCon1, cbCon2, cbCon3, cbCon4, cbCon5, cbCon6, cbCon7 };
            cbDecBoxes        = new ComboBox[] { cbDec1, cbDec2, cbDec3, cbDec4, cbDec5, cbDec6, cbDec7 };
            this.Size         = new System.Drawing.Size(150 + (dec + 2) * (horizontal), vertical * (con + 2) + 150);
            btnSolve.Location = new Point(30 + (dec + 2) * (horizontal), vertical * (con + 2) + 30);
            for (int i = 0; i < con; i++)
            {
                lblCon[i]          = new Label();
                eqCon[i]           = new TextBox();
                lblCon[i].Size     = new Size(20, 20);
                eqCon[i].Size      = new Size(30, 30);
                lblCon[i].Location = new Point(50, 50 + vertical * (i + 1));
                eqCon[i].Location  = new Point(50 + (dec + 2) * (horizontal), 50 + vertical * (i + 1));
                lblCon[i].Text     = "c" + i;
                lblCon[i].Show();
                eqCon[i].Show();
                this.Controls.Add(lblCon[i]);
                this.Controls.Add(eqCon[i]);
                cbConBoxes[i].Visible = true;


                for (int j = 0; j < dec; j++)
                {
                    txtArray[i, j]          = new TextBox();
                    txtArray[i, j].Size     = new Size(30, 30);
                    txtArray[i, j].Location = new Point(50 + horizontal * (j + 1), 50 + vertical * (i + 1));
                    txtArray[i, j].Show();
                    this.Controls.Add(txtArray[i, j]);
                }
            }
            for (int j = 0; j < dec; j++)
            {
                lblDec[j]          = new Label();
                eqDec[j]           = new Label();
                eqDec[j].Text      = "0";
                LP[j]              = new TextBox();
                lblDec[j].Size     = new Size(20, 20);
                eqDec[j].Size      = new Size(30, 30);
                LP[j].Size         = new Size(30, 30);
                lblDec[j].Location = new Point(50 + horizontal * (j + 1), 50);
                eqDec[j].Location  = new Point(50 + horizontal * (j + 1), vertical * (con + 2) + 50);
                LP[j].Location     = new Point(50 + horizontal * (j + 1), 0);
                lblDec[j].Text     = "x" + j;
                lblDec[j].Show();
                eqDec[j].Show();
                LP[j].Show();
                this.Controls.Add(lblDec[j]);
                this.Controls.Add(eqDec[j]);
                this.Controls.Add(LP[j]);
                cbDecBoxes[j].Visible = true;
            }

            panelCon.Location = new Point(50 + horizontal * (dec + 1), 80);
            panelCon.Visible  = true;
            panelDec.Location = new Point(80, 50 + vertical * (con + 1));
            panelDec.Visible  = true;
        }
Example #38
0
        private void btn_Generate_Click(object sender, EventArgs e)
        {
            try
            {
                _adunare?.Hide();
                _egal?.Hide();
                if (_matriceInit != null)
                {
                    foreach (var box in _matriceInit)
                    {
                        try
                        {
                            box.Visible = false;
                        }
                        catch
                        {
                            // ignored
                        }
                    }
                }
                if (_matriceFin1 != null)
                {
                    foreach (var box in _matriceFin1)
                    {
                        try
                        {
                            box.Visible = false;
                        }
                        catch
                        {
                            // ignored
                        }
                    }
                }
                if (_matriceFin2 != null)
                {
                    foreach (var box in _matriceFin2)
                    {
                        try
                        {
                            box.Visible = false;
                        }
                        catch
                        {
                            // ignored
                        }
                    }
                }

                _nrLinii = int.Parse(tb_LinesNr.Text);
                if (_nrLinii < 2)
                {
                    MessageBox.Show(@"Matricile trebuie sa aiba cel putin doua linii / coloane");
                    return;
                }
                _matriceInitiala = new double[_nrLinii, _nrLinii];
                _matriceFinala1  = new double[_nrLinii, _nrLinii];
                _matriceFinala2  = new double[_nrLinii, _nrLinii];
                _matriceInit     = new TextBox[_nrLinii, _nrLinii];
                _matriceFin1     = new TextBox[_nrLinii, _nrLinii];
                _matriceFin2     = new TextBox[_nrLinii, _nrLinii];

                AfiseazaMatricea(15, _matriceInit);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Example #39
0
 // função para gerar os TextBox da matriz O
 void ReloadO(TextBox[,] lastValues)
 {
     MO = new TextBox[int.Parse(M1C_.Value.ToString()), int.Parse(M1L_.Value.ToString())];
     for (int i = 0; i < M1C_.Value; i++)
     {
         for (int j = 0; j < M1L_.Value; j++)
         {
             MO[i, j] = new TextBox();
             MO[i, j].Location = new Point(M1L_.Location.X + i * 40, 100 + j * 30);
             MO[i, j].Width = 30;
             tabPage3.Controls.Add(MO[i, j]);
             try
             {
                 MO[i, j].Text = lastValues[i, j].Text;
             }
             catch { }
         }
     }
 }
Example #40
0
        public void Create(int max, string image, XmlTextReader reader, bool isKids)
        {
            check = true;
            if (checkcombo == false)
            {
                if (isKids == true)
                {
                    checkcombo = true;
                    int ind = 0;
                    pictures = new string[] { "g.jpg", "r.jpg", "e.jpg", "l.jpg", "sh.jpg", "k.jpg" };
                    pb       = new PictureBox();
                    pb.Size  = new Size(150, 180);

                    pb.Location = new Point(485, 250);
                    this.Controls.Add(pb);
                    comboBox1          = new ComboBox();
                    comboBox1.Size     = new Size(80, 17);
                    comboBox1.Text     = "1";
                    comboBox1.Location = new Point(640, 260);
                    this.Controls.Add(comboBox1);
                    pb.ImageLocation = pictures[ind];
                    pb.SizeMode      = PictureBoxSizeMode.StretchImage;
                    comboBox1.Items.Add("1");
                    comboBox1.Items.Add("2");
                    comboBox1.Items.Add("3");
                    comboBox1.Items.Add("4");
                    comboBox1.Items.Add("5");
                    comboBox1.Items.Add("6");
                    comboBox1.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
                }
            }
            else
            {
                comboBox1.Visible = true;
                pb.Visible        = true;
            }
            //else
            //{

            //    comboBox1.Visible = false;
            //    pb.Visible = false;

            //}
            panel.BackgroundImage       = Image.FromFile(image);
            panel.BackgroundImageLayout = ImageLayout.Stretch;

            w.WordRead(reader);
            t      = new TextBox[25, 25];
            lables = new Label[words.Count];

            int    x = 0, y = 0;
            string tmp;
            bool   ch = true;

            for (int i = 0; i < t.GetLength(0); i++)
            {
                for (int j = 0; j < t.GetLength(1); j++)
                {
                    t[i, j]          = new TextBox();
                    t[i, j].Font     = new Font("New Romans", 9F);
                    t[i, j].Location = new Point(i * 21 + 25, j * 21 + 25);
                    t[i, j].Size     = new Size(20, 20);
                    t[i, j].Visible  = false;
                    panel.Controls.Add(t[i, j]);
                    t[i, j].TextChanged += Form1_TextChanged;
                }
            }


            lables = new Label[words.Count];
            quest  = new Label[words.Count];
            Label across = new Label();

            across.Text     = "ACROSS";
            across.Size     = new Size(70, 20);
            across.Location = new Point(40, panel.Size.Height + 20);
            this.Controls.Add(across);
            Label down = new Label();

            down.Text     = "DOWN";
            down.Size     = new Size(70, 20);
            down.Location = new Point(200, panel.Size.Height + 20);
            this.Controls.Add(down);
            int h = 1, hh = 1;

            for (int k = 0; k < words.Count; k++)
            {
                if (words[k].IsVertical == true)
                {
                    x   = words[k].X - 1;
                    y   = words[k].Y - 1;
                    tmp = words[k].Wrd;

                    lables[k]          = new Label();
                    lables[k].Text     = words[k].Num + "";
                    lables[k].Size     = new Size(20, 15);
                    lables[k].Location = new Point(t[x, y].Location.X, t[x, y].Location.Y - 15);
                    panel.Controls.Add(lables[k]);
                    quest[k] = new Label();
                    if (words[k].Q != "")
                    {
                        quest[k].Text = words[k].Num + "  " + words[k].Q;
                    }
                    quest[k].Size     = new Size(200, 20);
                    quest[k].Location = new Point(150, panel.Size.Height + 30 + 20 * hh);
                    hh++;
                    this.Controls.Add(quest[k]);
                    for (int l = 0; l < words[k].L; l++)
                    {
                        t[x, y++].Visible = true;
                    }
                }

                if (words[k].IsVertical == false)
                {
                    x                  = words[k].X - 1;
                    y                  = words[k].Y - 1;
                    tmp                = words[k].Wrd;
                    lables[k]          = new Label();
                    lables[k].Text     = words[k].Num + "";
                    lables[k].Size     = new Size(25, 15);
                    lables[k].Location = new Point(t[x, y].Location.X - 15, t[x, y].Location.Y);
                    panel.Controls.Add(lables[k]);

                    quest[k] = new Label();
                    if (words[k].Q != "")
                    {
                        quest[k].Text = words[k].Num + "  " + words[k].Q;
                    }
                    quest[k].Size     = new Size(200, 20);
                    quest[k].Location = new Point(20, panel.Size.Height + 30 + 20 * h);
                    h++;
                    this.Controls.Add(quest[k]);
                    for (int l = 0; l < words[k].L; l++)
                    {
                        t[x++, y].Visible = true;
                    }
                }
            }
        }
Example #41
0
        public Form1(string[] args)
        {
            InitializeComponent();
            data            = new TextBox[9, 9];
            global_filename = "";
            //code for nice displayed
            foreach (TextBox tb in this.Controls.OfType <TextBox>())
            {
                //all textboks have names "textBox№", № - number of textbox
                var name = tb.Name;
                //find number of textbox
                var num = Convert.ToInt32(name.Substring(7)) - 1;
                //put the textbox in its cell
                data[num / 9, num % 9] = tb;
                //calculate coordinates of textbox
                var x = 15 + ((num % 9) / 3) * 15 + (num % 9) * 35;
                var y = 65 + ((num / 9) / 3) * 15 + (num / 9) * 35;
                //set parameters of textbox
                tb.Size      = new Size(30, 30);
                tb.Location  = new Point(x, y);
                tb.ForeColor = Color.Red;
                //add event handlers for validation
                tb.TextChanged += new System.EventHandler(Validation);
            }
            //this cicle for nice displayed of vertical and horizontal lines
            foreach (MyLine ml in this.Controls.OfType <MyLine>())
            {
                //all lines have names "myLine№", № - number of line
                //find number of line
                var num = Convert.ToInt32(ml.Name.Substring(6));
                //for same line set size and position
                switch (num)
                {
                case 1:
                    ml.Size     = new Size(350, 1);
                    ml.Location = new Point(10, 60);
                    break;

                case 2:
                    ml.Size     = new Size(350, 1);
                    ml.Location = new Point(10, 175);
                    break;

                case 3:
                    ml.Size     = new Size(350, 1);
                    ml.Location = new Point(10, 295);
                    break;

                case 4:
                    ml.Size     = new Size(350, 1);
                    ml.Location = new Point(10, 410);
                    break;

                case 5:
                    ml.Size     = new Size(1, 350);
                    ml.Location = new Point(10, 60);
                    break;

                case 6:
                    ml.Size     = new Size(1, 350);
                    ml.Location = new Point(125, 60);
                    break;

                case 7:
                    ml.Size     = new Size(1, 350);
                    ml.Location = new Point(245, 60);
                    break;

                case 8:
                    ml.Size     = new Size(1, 350);
                    ml.Location = new Point(360, 60);
                    break;
                }
            }

            if (args.Length > 0)
            {
                try
                {
                    var dat = Load_from_file(args[0]);
                    //write the read sudoku in field
                    for (int k = 0; k < 9; k++)
                    {
                        for (int h = 0; h < 9; h++)
                        {
                            data[k, h].ForeColor = Color.Red;
                            if (dat[k, h] != 0)
                            {
                                data[k, h].Text = dat[k, h].ToString();
                            }
                        }
                    }
                    global_filename = args[0];
                    //check corectness the read sudoku
                    Check_sudoku();
                }
                catch (Exception ea)
                {
                    for (int k = 0; k < 9; k++)
                    {
                        for (int h = 0; h < 9; h++)
                        {
                            data[k, h].ForeColor = Color.Red;
                            data[k, h].Text      = "";
                        }
                    }
                    MessageBox.Show("Attention! Error!\n" + ea.Message);
                }
            }
        }
Example #42
0
        public virtual void InsertRow(int nR)
        {
            if (nR < 0)
            {
                nR = 0;
            }
            double hMar, vMar, bW, bH;

            bW = (g.Width - (this.nCol + 1) * this.sp) / this.nCol;
            bH = (g.Height - (this.nRow + nR + 1) * this.sp) / (this.nRow + nR);
            if (bH > bW)
            {
                bH = bW;
            }
            else
            {
                bW = bH;
            }
            hMar = (g.Width - this.sp * (this.nCol + 1) - bW * this.nCol) / 2;
            vMar = (g.Height - this.sp * (this.nRow + nR + 1) - bH * (this.nRow + nR)) / 2;
            TextBox[,] txtBxs2 = new TextBox[this.nRow + nR, this.nCol];
            for (int i = 0; i < this.nRow; i++)
            {
                for (int j = 0; j < this.nCol; j++)
                {
                    txtBxs2[i, j] = txtBxs[i, j];
                }
            }
            txtBxs  = txtBxs2;
            txtBxs2 = null;
            for (int i = 0; i < this.nRow; i++)
            {
                for (int j = 0; j < this.nCol; j++)
                {
                    TextBox tb = txtBxs[i, j];
                    tb.Width    = bW;
                    tb.Height   = bH;
                    tb.FontSize = tb.Height / FontMult;
                    Thickness myTh = new Thickness();
                    myTh.Left = hMar + this.sp * (j + 1) + tb.Width * j;
                    myTh.Top  = vMar + this.sp * (i + 1) + tb.Height * i;
                    tb.Margin = myTh;
                }
            }
            for (int j = 0; j < this.nCol; j++)
            {
                for (int i = this.nRow; i < this.nRow + nR; i++)
                {
                    TextBox txtBx = new TextBox();
                    txtBxs[i, j]                   = txtBx;
                    txtBx.Name                     = g.Name + "_txtBx" + i + "_" + j;
                    txtBx.Text                     = this.zapoln;
                    txtBx.LostFocus               += new RoutedEventHandler(TextBox_LostFocus);
                    txtBx.GotFocus                += new RoutedEventHandler(TextBox_GotFocus);
                    txtBx.VerticalAlignment        = VerticalAlignment.Top;
                    txtBx.HorizontalAlignment      = HorizontalAlignment.Left;
                    txtBx.TextAlignment            = TextAlignment.Center;
                    txtBx.VerticalContentAlignment = VerticalAlignment.Center;
                    txtBx.TextWrapping             = TextWrapping.Wrap;
                    txtBx.Width                    = bW;
                    txtBx.Height                   = bH;
                    txtBx.FontSize                 = txtBx.Height / FontMult;
                    Thickness myTh = new Thickness();
                    myTh.Left    = hMar + this.sp * (j + 1) + txtBx.Width * j;
                    myTh.Top     = vMar + this.sp * (i + 1) + txtBx.Height * i;
                    txtBx.Margin = myTh;
                    this.g.Children.Add(txtBx);
                }
            }
            this.nRow += nR;
        }
Example #43
0
        private void saveDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tab = new TabPage();

            foreach (Control ctrl in tabControl1.SelectedTab.Controls)
            {
                if ((ctrl as TabControl) != null)
                {
                    tab = (ctrl as TabControl).SelectedTab;
                }
            }

            int q = ed_tboxes.GetLength(0);

            double[,] matrix = new double[q, q];
            for (int j = 0; j < q; j++)
            {
                matrix[j, j] = 1;
            }
            int tIndex = 0;

            for (int i = 0; i < q - 1; i++)
            {
                for (int j = i + 1; j < q; j++)
                {
                    double value = ParseValue(ed_tboxes[i, j].Text);

                    /*if (ed_tboxes[i, j].Text.Length == 1)
                     *  value = Convert.ToDouble(ed_tboxes[i, j].Text);
                     * else
                     *  value = 1.0 / Convert.ToDouble(ed_tboxes[i, j].Text[2].ToString());*/
                    matrix[i, j] = value;
                    matrix[j, i] = 1.0 / value;
                    tIndex++;
                }
            }
            for (int i = 0; i < matrixes.Count; i++)
            {
                if (tab.Name == matrixes[i].mainCriteria)
                {
                    matrixes[i] = PairedMatrix.EditPairedMatrix(matrixes[i], matrix);
                }
            }

            for (int i = 0; i < AHP.criteriasComparison.Count; i++)
            {
                for (int j = 0; j < AHP.criteriasComparison[i].Count; j++)
                {
                    if (tab.Name == AHP.criteriasComparison[i][j].mainCriteria)
                    {
                        AHP.criteriasComparison[i][j] = PairedMatrix.EditPairedMatrix(AHP.criteriasComparison[i][j], matrix);
                    }
                }
            }

            if (AHP.results != null)
            {
                AHP.Calculate();
                TabResultsShow();
                t      = null;
                tboxes = null;
            }
            TabHandle.MakeReadOnly(tabControl1.SelectedTab);
            editing = false;
            editDataToolStripMenuItem.Enabled = true;
            saveDataToolStripMenuItem.Enabled = false;
            ed_tboxes = null;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            // Button1 is the Checkout Button //

            // Collect Information from Data TextBoxes =
            //
            //      Name     = textBox1
            //      Address  = textBox2
            //      Phone    = textBox3
            //
            // Product Information Boxes =
            //
            //     textBox4, textBox5, textBox6, textBox7
            //     textBox8, textBox9, textBox10, textBox11
            //     textBox12, textBox13, textBox14, textBox15
            //     textBox16, textBox17, textBox18, textBox19
            //     textBox20, textBox21, textBox22, textBox23
            //

            string Name;

            Name = textBox1.ToString();

            // Exception handling if the user does not input any information
            // Opens message box urging user to input contact information
            if (textBox1.Text.Length > 0 && textBox2.Text.Length > 0 && textBox3.Text.Length > 0)
            {
                // Creates our "person" using information provided
                Person person = new Person(textBox1.Text, textBox2.Text, Convert.ToInt64(textBox3.Text));

                // Determines bool event if customer checked mailing list or not
                Customer customer = new Customer(checkBox1.Checked, person);

                // Creates 'Total' and assigns it a begin value of 0
                double Total = 0.00;

                // Array of the shopping list
                TextBox[,] order =
                {                     { textBox4,  textBox5,  textBox6,  textBox7  },
                                      { textBox8,  textBox9,  textBox10, textBox11 },
                                      { textBox12, textBox13, textBox14, textBox15 },
                                      { textBox16, textBox17, textBox18, textBox19 },
                                      { textBox20, textBox21, textBox22, textBox23 } };

                // For loop designed to read the order and calculate Total
                for (int ROWS = 0; ROWS < 5; ROWS++)
                {
                    if (order[ROWS, 0].Text.Length > 0)
                    {
                        Total += (Convert.ToDouble(order[ROWS, 2].Text) * Convert.ToDouble(order[ROWS, 3].Text));
                    }
                }

                // Reads the total and assigns the new class
                Preferred preferred = new Preferred(0, customer);

                // Determines the discount level
                if (Total > 500 && Total < 1001)
                {
                    preferred.DiscountLevel = 0.05;
                }
                else if (Total >= 1001)
                {
                    preferred.DiscountLevel = 0.10;
                }

                // Creates our pretotal value for output
                // Then determines new total based on discount level
                double PreTotal = Total;
                Total = Total - (Total * preferred.DiscountLevel);


                // Opens Order Processing Form
                this.Hide();

                // Sends all information to the final form for output
                OrdProForm Form4 = new OrdProForm(Total, preferred, PreTotal);
                Form4.ShowDialog();
            }
            else
            {
                // Exception handling
                MessageBox.Show("Please fill in all of the information");
            }
        }
 public override bool podeCalcular(TextBox[,] matriz1, TextBox[,] matriz2)
 {
     return(true);
 }
 public abstract bool podeCalcular(TextBox[,] matriz1, TextBox[,] matriz2);
 private int getNumberComponent(string name, object sender)
 {
     switch (name.Substring(0, 3))
     {
         case "dat":
             {
                 DateTimePicker date1 = new DateTimePicker();
                 date1 = sender as DateTimePicker;
                 return Convert.ToInt32(date1.Name.Replace(name, ""));
             }
         case "btn":
             {
                 Button btn1 = new Button();
                 btn1 = sender as Button;
                 return Convert.ToInt32(btn1.Name.Replace(name, ""));
             }
         case "chk":
             {
                 CheckBox chk1 = new CheckBox();
                 chk1 = sender as CheckBox;
                 return Convert.ToInt32(chk1.Name.Replace(name, ""));
             }
         case "txb":
             {
                 TextBox tb1 = new TextBox();
                 tb1 = sender as TextBox;
                 return Convert.ToInt32(tb1.Name.Replace(name, ""));
             }
         case "cmb":
             {
                 ComboBox cb1 = new ComboBox();
                 cb1 = sender as ComboBox;
                 return Convert.ToInt32(cb1.Name.Replace(name, ""));
             }
     }
     return -1;
 }
 public void GuardarColoresIngresados(string pathArchivo, TextBox[,] cajaTexto)
 {
     if (pathArchivo != null && pathArchivo != "")
     {
         string[] partes        = pathArchivo.Split('\\');
         string   nombreArchivo = partes[partes.Length - 1];
         string   vLinea        = string.Empty;
         using (System.IO.StreamWriter file = new System.IO.StreamWriter(pathArchivo, true))
         {
             string color = string.Empty;
             for (int f = 0; f <= 8; f++)
             {
                 for (int c = 0; c <= 8; c++)
                 {
                     if (cajaTexto[f, c].BackColor == Color.SkyBlue)
                     {
                         color = "1";
                     }
                     else if (cajaTexto[f, c].BackColor == Color.CornflowerBlue)
                     {
                         color = "2";
                     }
                     else if (cajaTexto[f, c].BackColor == Color.LightCoral)
                     {
                         color = "3";
                     }
                     else if (cajaTexto[f, c].BackColor == Color.Crimson)
                     {
                         color = "4";
                     }
                     else if (cajaTexto[f, c].BackColor == Color.PaleGreen)
                     {
                         color = "5";
                     }
                     else if (cajaTexto[f, c].BackColor == Color.YellowGreen)
                     {
                         color = "6";
                     }
                     else if (cajaTexto[f, c].BackColor == Color.LightSalmon)
                     {
                         color = "7";
                     }
                     else if (cajaTexto[f, c].BackColor == Color.Orange)
                     {
                         color = "8";
                     }
                     else
                     {
                         color = "0";
                     }
                     if (c == 0)
                     {
                         vLinea = color + "-";
                     }
                     else if (c > 0 && c < 8)
                     {
                         vLinea = vLinea + color + "-";
                     }
                     else if (c == 8)
                     {
                         vLinea = vLinea + color;
                     }
                 }
                 file.WriteLine(vLinea);
                 vLinea = string.Empty;
             }
         }
     }
 }
Example #49
0
 public TileMovement(int[,] tileControlMask, TextBox[,] tiles)
 {
     this.tileControlMask = tileControlMask;
     this.tiles           = tiles;
     length = Convert.ToInt32(Math.Sqrt(Convert.ToDouble(tileControlMask.Length)));
 }
Example #50
0
        public NonogramWindow()
        {
            // In 2d arrays representing elements onscreen, first index of array is X value, second
            // index is Y value. Example: ar[3, 6] refers to the fourth element from the left and
            // the seventh element from the top.

            InitializeComponent();

            int numColumns     = Program.mainPuzzle.numColumns; // width of the puzzle
            int numRows        = Program.mainPuzzle.numRows;    // height of the puzzle
            int numColumnClues = numColumns / 2 + 1;
            int numRowClues    = numRows / 2 + 1;

            this.Size = new System.Drawing.Size((numRowClues + numColumns) * cellSize + 25, (numRows + numColumnClues) * cellSize + 50);

            mainPuzzlePanel.Width    = numColumns * cellSize + 5;
            mainPuzzlePanel.Height   = numRows * cellSize + 5;
            mainPuzzlePanel.Location = new Point(numRowClues * cellSize + 5, numColumnClues * cellSize + 5);

            topRightPanel.Width    = numColumns * cellSize + 5;
            topRightPanel.Height   = numColumnClues * cellSize;
            topRightPanel.Location = new Point(numRowClues * cellSize + 3, 2);

            bottomLeftPanel.Width    = numRowClues * cellSize;
            bottomLeftPanel.Height   = numRows * cellSize + 5;
            bottomLeftPanel.Location = new Point(2, numColumnClues * cellSize + 3);

            topLeftPanel.Width  = numRowClues * cellSize;
            topLeftPanel.Height = numColumnClues * cellSize;

            // Add text boxes for column clues
            columnClues = new TextBox[numColumns, numColumnClues];
            for (int i = 0; i < numColumns; ++i)
            {
                for (int j = 0; j < numColumnClues; ++j)
                {
                    columnClues[i, j] = new TextBox();
                    topRightPanel.Controls.Add(columnClues[i, j]);
                    columnClues[i, j].Width       = cellSize - 1;
                    columnClues[i, j].BorderStyle = BorderStyle.Fixed3D;
                    columnClues[i, j].Location    = new Point(i * cellSize, j * cellSize);
                    columnClues[i, j].Text        = "0";
                    columnClues[i, j].TextAlign   = HorizontalAlignment.Center;
                }
            }

            // Add text boxes for row clues
            rowClues = new TextBox[numRowClues, numRows];
            for (int i = 0; i < numRowClues; ++i)
            {
                for (int j = 0; j < numRows; ++j)
                {
                    rowClues[i, j] = new TextBox();
                    bottomLeftPanel.Controls.Add(rowClues[i, j]);
                    rowClues[i, j].Width       = cellSize - 1;
                    rowClues[i, j].BorderStyle = BorderStyle.Fixed3D;
                    rowClues[i, j].Location    = new Point(i * cellSize, j * cellSize);
                    rowClues[i, j].Text        = "0";
                    rowClues[i, j].TextAlign   = HorizontalAlignment.Center;
                }
            }

            // Add cells to main puzzle panel
            cells = new PictureBox[numColumns, numRows];
            for (int i = 0; i < numColumns; ++i)
            {
                for (int j = 0; j < numRows; ++j)
                {
                    cells[i, j] = new PictureBox();
                    mainPuzzlePanel.Controls.Add(cells[i, j]);
                    cells[i, j].Width       = cellSize - 1;
                    cells[i, j].Height      = cellSize - 1;
                    cells[i, j].BackColor   = Color.AntiqueWhite;
                    cells[i, j].BorderStyle = BorderStyle.Fixed3D;
                    cells[i, j].Location    = new Point(i * cellSize, j * cellSize);
                }
            }
        }
        private void btnSomar_Click(object sender, EventArgs e)
        {
            if (Matriz1 == null || Matriz2 == null)
            {
                MessageBox.Show("Matriz nula !", "Error - Matriz");
                return;
            }
            float[,] tempMatriz1 = new float[Matriz1.GetLength(0), Matriz1.GetLength(1)];
            float[,] tempMatriz2 = new float[Matriz2.GetLength(0), Matriz2.GetLength(1)];
            if (tempMatriz1.GetLength(0) != tempMatriz2.GetLength(0) || tempMatriz1.GetLength(1) != tempMatriz2.GetLength(1))
            {
                MessageBox.Show("So e possivel a soma de matrizes de mesma ordem !", "Erro - Soma Matrizes");
                return;
            }

            for (int x = 0; x < Matriz1.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz1.GetLength(1); y++)
                {
                    float n = 0;
                    float.TryParse(Matriz1[x, y].Text, out n);
                    tempMatriz1[x, y] = n;
                    //tempMatriz1[x, y] = Convert.ToInt32(Matriz1[x, y].Text);
                }
            }
            for (int x = 0; x < Matriz2.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz2.GetLength(1); y++)
                {
                    float n = 0;
                    float.TryParse(Matriz2[x, y].Text, out n);
                    tempMatriz2[x, y] = n;
                    //tempMatriz2[x, y] = Convert.ToInt32(Matriz2[x, y].Text);
                }
            }

            float[,] tempMatrizResultante = CalculosMatrizes.SomarMatrizes(tempMatriz1, tempMatriz2);
            MatrizResultante = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
            int TamanhoText = groupBoxMatrizResultante.Width / MatrizResultante.GetLength(1);
            groupBoxMatrizResultante.Controls.Clear();
            for (int x = 0; x < MatrizResultante.GetLength(0); x++)
            {
                for (int y = 0; y < MatrizResultante.GetLength(1); y++)
                {
                    MatrizResultante[x, y] = new TextBox();
                    MatrizResultante[x, y].Text = tempMatrizResultante[x, y].ToString();
                    MatrizResultante[x, y].Top = (x * MatrizResultante[x, y].Height) + 20;
                    MatrizResultante[x, y].Left = y * TamanhoText + 6;
                    MatrizResultante[x, y].Width = TamanhoText;
                    groupBoxMatrizResultante.Controls.Add(MatrizResultante[x, y]);
                }
            }
        }
Example #52
0
 private void initialize()
 {
     textboxes = new TextBox[, ] {
         { box00, box01 }, { box10, box11 }
     };
 }
Example #53
0
        private void KutuOlustur()
        {
            str      = Convert.ToInt32(textBox1.Text);
            stn      = Convert.ToInt32(textBox2.Text);
            strdeger = Convert.ToString(textBox3.Text);
            stndeger = Convert.ToString(textBox4.Text);
            //Dizileri oluşturuyor
            TextKutu     = new TextBox[str, stn];
            TextKutuBos  = new TextBox[str + stn];
            TextKutuBos2 = new TextBox[str + stn];
            TextKutu2    = new TextBox[str, stn];
            LabelKutu    = new Label[str, stn];
            LabelArz     = new Label[stn + 1];
            LabelTalep   = new Label[str + 1];

            U = new int[str];
            V = new int[stn];
            O = new int[str * stn];

            dizi  = new int[str, stn];
            dizi2 = new int[str, stn];


            //Formdaki Textboxlar oluşturuluyor
            int left  = 100;
            int top   = 120;
            int left2 = 155;

            for (int i = 0; i < str; i++)
            {
                for (int k = 0; k < stn; k++)
                {
                    TextKutu[i, k]       = new TextBox();
                    TextKutu[i, k].Left  = left;
                    TextKutu[i, k].Top   = top;
                    TextKutu[i, k].Width = 50;
                    TextKutu[i, k].Text  = "";
                    this.Controls.Add(TextKutu[i, k]);

                    TextKutu2[i, k]       = new TextBox();
                    TextKutu2[i, k].Left  = left2;
                    TextKutu2[i, k].Top   = top;
                    TextKutu2[i, k].Width = 20;
                    TextKutu2[i, k].Text  = "";
                    this.Controls.Add(TextKutu2[i, k]);


                    left  += 90;
                    left2 += 90;
                }
                //arz sütunu
                TextKutuBos[i]       = new TextBox();
                TextKutuBos[i].Left  = left;
                TextKutuBos[i].Top   = top;
                TextKutuBos[i].Width = 50;
                TextKutuBos[i].Text  = "";
                this.Controls.Add(TextKutuBos[i]);


                top   = top + 60;
                left  = 100;
                left2 = 155;
            }

            //talep satırı
            for (int i = 0; i < stn + 1; i++)
            {
                TextKutuBos2[i]       = new TextBox();
                TextKutuBos2[i].Left  = left;
                TextKutuBos2[i].Top   = top;
                TextKutuBos2[i].Width = 50;
                TextKutuBos2[i].Text  = "";
                this.Controls.Add(TextKutuBos2[i]);

                left += 90;

                //label6.Text = Convert.ToString();
            }


            //Formdaki labellar oluşturuluyor
            int labeltop  = 120;
            int labelleft = 20;

            for (int i = 0; i < str; i++)
            {
                int k = 0;
                LabelKutu[i, k]       = new Label();
                LabelKutu[i, k].Left  = labelleft;
                LabelKutu[i, k].Top   = labeltop;
                LabelKutu[i, k].Width = 60;
                LabelKutu[i, k].Text  = strdeger + (i + 1);
                this.Controls.Add(LabelKutu[i, k]);

                labeltop += 60;
            }
            //talep satırı
            int tlp = 0;

            LabelTalep[tlp]       = new Label();
            LabelTalep[tlp].Left  = labelleft;
            LabelTalep[tlp].Top   = labeltop;
            LabelTalep[tlp].Width = 60;
            LabelTalep[tlp].Text  = "Talep";
            this.Controls.Add(LabelTalep[tlp]);
            tlp++;

            labelleft = 100;
            for (int k = 0; k < stn; k++)
            {
                int i = 0;
                LabelKutu[i, k]       = new Label();
                LabelKutu[i, k].Left  = labelleft;
                LabelKutu[i, k].Top   = 90;
                LabelKutu[i, k].Width = 60;
                LabelKutu[i, k].Text  = stndeger + (k + 1);
                this.Controls.Add(LabelKutu[i, k]);

                labelleft += 90;
            }
            int arzf = 0;

            LabelArz[arzf]       = new Label();
            LabelArz[arzf].Left  = labelleft;
            LabelArz[arzf].Top   = 90;
            LabelArz[arzf].Width = 60;
            LabelArz[arzf].Text  = "Arz";
            this.Controls.Add(LabelArz[arzf]);
            arzf++;

            DiziDoldur(str, stn);
        }
Example #54
0
        public void FillTableOnGUI()
        {
            Dictionary<Cell, int> cageCornersAndSums = new Dictionary<Cell, int>();
            if (se.IsExerciseKiller)
                cageCornersAndSums = se.Killer.Ctrl.GetSumOfNumbersAndIndicatorCages();
            guiTable = new TextBox[9, 9];

            for (int row = 0; row < 9; row++)
            {
                for (int col = 0; col < 9; col++)
                {
                    if (se.IsExerciseKiller)
                    {
                        foreach (KeyValuePair<Cell, int> cage in cageCornersAndSums)
                        {
                            if (se.Killer.Ctrl.IsCellAtTopLeftOfCage(cage.Key, row, col))
                            {
                                guiTable[row, col] = IsCellSpecial(row, col)
                                    ? new KillerTextBox(cage.Value.ToString(), true)
                                    : new KillerTextBox(cage.Value.ToString(), false);

                                //Removing the used cage key, so in the next round 
                                //the foreach won't iterate through the already processed cages
                                cageCornersAndSums.Remove(cage.Key);
                                break;
                            }
                        }
                    }

                    //If there is no TextBox placed
                    if (guiTable[row, col] == null)
                    {
                        guiTable[row, col] = se.IsExerciseKiller && IsCellSpecial(row, col) ? new KillerTextBox("", true) : new TextBox();
                        guiTable[row, col].TextAlign = HorizontalAlignment.Center;
                    }
                    guiTable[row, col].Font = new Font(guiTable[row, col].Font.FontFamily, 19.5f);

                    //No border
                    guiTable[row, col].BorderStyle = BorderStyle.None;

                    //No margin
                    guiTable[row, col].Margin = new Padding(0);

                    //Setting the height of the cell
                    guiTable[row, col].Top = exerciseTable.Height / exerciseTable.RowCount;

                    //Anchoring the cell horizontally to the center
                    guiTable[row, col].Anchor = AnchorStyles.Left | AnchorStyles.Right;

                    //Maximum 1 character allowed as value
                    guiTable[row, col].MaxLength = 1;

                    //Setting a new cell with its indeces in the Tag property for later usage
                    guiTable[row, col].Tag = new Cell(row, col);

                    if (!se.IsExerciseKiller)
                    {
                        if (se.Exercise[0][row, col] > 0)
                        {
                            guiTable[row, col].Text = se.Exercise[0][row, col].ToString();
                            //It is not allowed to edit the cells that contain the predefined values
                            guiTable[row, col].Enabled = false;
                        }
                    }
                    SetOriginalCellBackgroundColor(guiTable[row, col]);

                    guiTable[row, col].TextChanged += new EventHandler(TextBox_TextChanged);
                    guiTable[row, col].GotFocus += (sender, e) =>
                    {
                        Cell cellInFocus = new Cell(AsCell(sender).Row, AsCell(sender).Col);
                        Int32.TryParse(guiTable[cellInFocus.Row, cellInFocus.Col].Text, out previousCellValue);
                    };

                    guiTable[row, col].KeyDown += new KeyEventHandler(TextBox_KeyDown);

                    exerciseTable.Controls.Add(guiTable[row, col], col, row);
                }
            }
            cellFinder = new NearestEditableGUICellFinder(guiTable);
        }
        private void MultEscal()
        {
            if (MatrixR != null)
            {
                for (int i = 0; i < MatrixR.GetLength(0); i++)
                {
                    for (int j = 0; j < MatrixR.GetLength(1); j++)
                    {
                        if (MatrixR[i, j] != null)
                            groupBox3.Controls.Remove(MatrixR[i, j]);
                    }
                }
            }
            if (matrizReferente == "Matriz1") {
                MatrixR = new TextBox[linha1, coluna1];
                multEscalar = Convert.ToInt16(QuoeficienteME.Text);
            }
            else if (matrizReferente == "Matriz2") {
                MatrixR = new TextBox[linha2, coluna2];
                multEscalar = Convert.ToInt16(textBox2.Text);
            }

            for (int i = 0; i < MatrixR.GetLength(0); i++)
            {
                for (int j = 0; j < MatrixR.GetLength(1); j++)
                {
                    MatrixR[i, j] = new TextBox();
                    if(matrizReferente == "Matriz1")MatrixR[i, j].Text = Convert.ToString(Convert.ToInt32(Matrix1[i, j].Text) * multEscalar);
                    else if (matrizReferente == "Matriz2") MatrixR[i, j].Text = Convert.ToString(Convert.ToInt32(Matrix2[i, j].Text) * multEscalar);
                    MatrixR[i, j].Top = (i * MatrixR[i, j].Height) + 10;
                    MatrixR[i, j].Left = (j * 35) + 10;
                    MatrixR[i, j].Width = 30;
                    groupBox3.Controls.Add(MatrixR[i, j]);
                }
            }
        }
Example #56
0
        public void CreateMatriz(int quantidade, int posicaoMatriz1, bool transposta, bool determinante)
        {
            this.quantidade = quantidade;

            if (determinante == false)
            {
                linhas     = Convert.ToInt32(primeiro.Text);
                colunas    = Convert.ToInt32(segundo.Text);
                textBoxes  = new TextBox[linhas, colunas];
                textBoxes2 = new TextBox[linhas, colunas];
                if (transposta == false)
                {
                    textboxesResults = new TextBox[linhas, colunas];
                }
                else
                {
                    textboxesResults = new TextBox[colunas, linhas];
                    Console.WriteLine("criou uma transposta");
                }

                for (int i = 0; i <= quantidade; i++)
                {
                    Console.WriteLine("foii");
                    if (i == 1 && transposta == false)
                    {
                        for (int n = 0; n < linhas; n++)
                        {
                            for (int m = 0; m < colunas; m++)
                            {
                                if (contadorDeColunas == colunas)
                                {
                                    espacoIntervaloY += textBoxSize;
                                    espacoIntervaloX  = 0;
                                    contadorDeColunas = 0;
                                }

                                textBoxes[n, m] = new TextBox();
                                textBoxes[n, m].SetBounds(posicaoMatriz1 + espacoIntervaloX, 200 + espacoIntervaloY, textBoxSize, textBoxSize);
                                textboxesResults[n, m] = new TextBox();
                                textboxesResults[n, m].SetBounds(363 + espacoIntervaloX, 313 + espacoIntervaloY, textBoxSize, textBoxSize);

                                textBoxes[n, m].TextChanged += new EventHandler(primeiro_TextChanged);
                                Controls.Add(textBoxes[n, m]);
                                textboxesResults[n, m].TextChanged += new EventHandler(primeiro_TextChanged);
                                Controls.Add(textboxesResults[n, m]);

                                textboxesResults[n, m].Visible = false;
                                textboxesResults[n, m].Enabled = false;

                                espacoIntervaloX += textBoxSize;
                                contadorDeColunas++;
                            }
                        }
                        //mais.Left = posicaoMatriz1;
                        espacoIntervaloY = -30;
                    }
                    if (i == 1 && transposta == true)
                    {
                        for (int k = 0; k < linhas; k++)
                        {
                            for (int l = 0; l < colunas; l++)
                            {
                                if (contadorDeColunas == colunas)
                                {
                                    espacoIntervaloY += textBoxSize;
                                    espacoIntervaloX  = 0;
                                    contadorDeColunas = 0;
                                }


                                textBoxes[k, l] = new TextBox();
                                textBoxes[k, l].SetBounds(posicaoMatriz1 + espacoIntervaloX, 200 + espacoIntervaloY, textBoxSize, textBoxSize);

                                textboxesResults[l, k] = new TextBox();
                                textboxesResults[l, k].SetBounds(363 + textBoxSize * k, 313 + textBoxSize * l, textBoxSize, textBoxSize);

                                textBoxes[k, l].TextChanged += new EventHandler(primeiro_TextChanged);
                                Controls.Add(textBoxes[k, l]);

                                //textboxesResults[k, l].TextChanged += new EventHandler(primeiro_TextChanged);
                                Controls.Add(textboxesResults[l, k]);

                                textboxesResults[l, k].Visible = true;
                                textboxesResults[l, k].Enabled = true;

                                espacoIntervaloX += textBoxSize;
                                contadorDeColunas++;
                            }
                        }
                        espacoIntervaloY = -30;
                    }
                    if (i == 2)
                    {
                        for (int j = 0; j < linhas; j++)
                        {
                            for (int o = 0; o < colunas; o++)
                            {
                                if (contadorDeColunas == colunas)
                                {
                                    espacoIntervaloY += textBoxSize;
                                    espacoIntervaloX  = 0;
                                    contadorDeColunas = 0;
                                }

                                textBoxes2[j, o] = new TextBox();
                                textBoxes2[j, o].SetBounds(posicaoMatriz1 + 200 + espacoIntervaloX, 200 + espacoIntervaloY, textBoxSize, textBoxSize);

                                textBoxes2[j, o].TextChanged += new EventHandler(primeiro_TextChanged);
                                Controls.Add(textBoxes2[j, o]);
                                textboxesResults[j, o].TextChanged += new EventHandler(primeiro_TextChanged);
                                Controls.Add(textboxesResults[j, o]);

                                textboxesResults[j, o].Visible = false;
                                textboxesResults[j, o].Enabled = false;

                                espacoIntervaloX += textBoxSize;
                                contadorDeColunas++;
                            }
                        }
                        //else
                        //{
                        //    if(checkboxMudou)
                        //    textBoxes = new TextBox[0,0];
                        //    linhas = 0;
                        //    colunas = 0;
                        //}
                    }
                }
            }
            else
            {
            }

            Console.WriteLine("passou pelo criar matriz");
        }
        //soma -- ok
        private void SumButton_Click(object sender, EventArgs e)
        {
            linhaResposta = linha1;
            colunaResposta = coluna1;

            if (MatrixR != null)
            {
                for (int i = 0; i < MatrixR.GetLength(0); i++)
                {
                    for (int j = 0; j < MatrixR.GetLength(1); j++)
                    {
                        if (MatrixR[i, j] != null)
                            groupBox3.Controls.Remove(MatrixR[i, j]);
                    }
                }
            }

            MatrixR = new TextBox[linhaResposta, colunaResposta];

            if(linha1 == linha2 && coluna2 == coluna1){
                for (int i = 0; i < MatrixR.GetLength(0); i++)
                {
                    for (int j = 0; j < MatrixR.GetLength(1); j++)
                    {
                        MatrixR[i, j] = new TextBox();
                        MatrixR[i, j].Text = Convert.ToString(Convert.ToInt32(Matrix1[i, j].Text) + Convert.ToInt32(Matrix2[i,j].Text));
                        MatrixR[i, j].Top = 10 + (i * 30); ;
                        MatrixR[i, j].Left = (j * 35) + 10;
                        MatrixR[i, j].Width = 30;
                        groupBox3.Controls.Add(MatrixR[i,j]);
                    }

                }

            }
            else { MessageBox.Show("É necessario que as matrizes tenham o mesmo tamanho"); }
        }
Example #58
0
 // função para gerar os TextBox da matriz C
 /*diferenças entre as outras
 não recebe valores anteriores
 remove as textbox dos resultados anteriores*/
 void ReloadC()
 {
     foreach (TextBox text in MC)
     {
         tabPage1.Controls.Remove(text);
     }
     MC = new TextBox[int.Parse(M3C.Text), int.Parse(M3L.Text)];
     for (int i = 0; i < int.Parse(M3C.Text); i++)
     {
         for (int j = 0; j < int.Parse(M3L.Text); j++)
         {
             MC[i, j] = new TextBox();
             MC[i, j].Location = new Point(M3L.Location.X + i * 40, 100 + j * 30);
             MC[i, j].Width = 30;
             tabPage1.Controls.Add(MC[i, j]);
         }
     }
 }
        public virtual void Calcular(TextBox[,] matriz1, TextBox[,] matriz2)
        {
            string matriz1_text, matriz2_text;

            for (int i = 0; i < matriz1.GetLength(0); i++)
            {
                for (int j = 0; j < matriz1.GetLength(1); j++)
                {
                    if (matriz1[i, j].Text == string.Empty)
                    {
                        matriz1[i, j].Text = "0";
                    }
                }
            }
            for (int i = 0; i < matriz2.GetLength(0); i++)
            {
                for (int j = 0; j < matriz2.GetLength(1); j++)
                {
                    if (matriz2[i, j].Text == string.Empty)
                    {
                        matriz2[i, j].Text = "0";
                    }
                }
            }

            for (int i = 0; i < matriz1.GetLength(0); i++)
            {
                for (int j = 0; j < matriz1.GetLength(1); j++)
                {
                    for (int z = 0; z < matriz1[i, j].Text.Length; z++)
                    {
                        matriz1_text = matriz1[i, j].Text;


                        if (matriz1_text[z] != '0' && matriz1_text[z] != '1' && matriz1_text[z] != '2' && matriz1_text[z] != '3' &&
                            matriz1_text[z] != '4' && matriz1_text[z] != '5' && matriz1_text[z] != '6' && matriz1_text[z] != '7' &&
                            matriz1_text[z] != '8' && matriz1_text[z] != '9' && matriz1_text[z] != ',' && matriz1_text[z] != '-')
                        {
                            matriz1[i, j].Text = "0";
                        }
                    }
                }
            }
            for (int i = 0; i < matriz2.GetLength(0); i++)
            {
                for (int j = 0; j < matriz2.GetLength(1); j++)
                {
                    for (int z = 0; z < matriz2[i, j].Text.Length; z++)
                    {
                        matriz2_text = matriz2[i, j].Text;

                        if (matriz2_text[z] != '0' && matriz2_text[z] != '1' && matriz2_text[z] != '2' && matriz2_text[z] != '3' &&
                            matriz2_text[z] != '4' && matriz2_text[z] != '5' && matriz2_text[z] != '6' && matriz2_text[z] != '7' &&
                            matriz2_text[z] != '8' && matriz2_text[z] != '9' && matriz2_text[z] != ',' && matriz2_text[z] != '-')
                        {
                            matriz2[i, j].Text = "0";
                        }
                    }
                }
            }

            podeCalcularBool = podeCalcular(matriz1, matriz2);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     txtSudoku = AsociarTxtMatriz(txtSudoku);
 }