Beispiel #1
0
        private void buttonClearRibbon_Click(object sender, EventArgs e)
        {
            string oldAlphabet = alphabet;

            alphabet = "";
            for (int i = 1; i < dgvStates.Rows.Count; i++)
            {
                alphabet += dgvStates.Rows[i].Cells[0].Value.ToString();
            }
            if (Analyzer.alphabetAnalysis(dgvStates, alphabet))
            {
                dgvRibbon = DGV.RibbonClear(dgvRibbon, alphabet);

                dgvStates = DGV.toWhite(dgvStates, 0);
                dgvStates.Rows[0].Cells[0].Style.BackColor = Color.Gray;
                dgvRibbon = DGV.toWhite(dgvRibbon, 1);
            }
            else
            {
                alphabet = oldAlphabet;
            }
        }
Beispiel #2
0
        //Кнопка старта
        private void buttonStart_Click(object sender, EventArgs e)
        {
            if (buttonStart.Text == "Старт")
            {
                //Шаманство с алфавитом
                string oldAlphabet = alphabet;
                alphabet = "";
                for (int i = 1; i < dgvStates.Rows.Count; i++)
                {
                    try { alphabet += dgvStates.Rows[i].Cells[0].Value.ToString(); }
                    catch { dgvStates.Rows[i].Cells[0].Value = ""; }
                }

                //Белим

                dgvStates = DGV.toWhite(dgvStates, 0);
                dgvStates.Rows[0].Cells[0].Style.BackColor = Color.Gray;
                dgvRibbon = DGV.toWhite(dgvRibbon, 1);

                dgvStates.ClearSelection();

                shift = 1;
                if (operandsModeForm)
                {
                    if (operandA + operandB + 1 + shift > dgvRibbon.ColumnCount)
                    {
                        dgvRibbon.ColumnCount += (operandA + operandB + 1 + 1) - dgvRibbon.ColumnCount;
                    }
                    for (int i = 0; i < shift; i++)
                    {
                        dgvRibbon.Rows[1].Cells[i].Value = alphabet[0];
                    }
                    for (int i = shift; i < operandA + shift; i++)
                    {
                        dgvRibbon.Rows[1].Cells[i].Value = alphabet[2];
                    }
                    dgvRibbon.Rows[1].Cells[operandA + shift].Value = alphabet[1];
                    for (int i = operandA + 1 + shift; i < operandA + operandB + 1 + shift; i++)
                    {
                        dgvRibbon.Rows[1].Cells[i].Value = alphabet[2];
                    }
                    for (int i = operandA + operandB + 1 + shift; i < dgvRibbon.ColumnCount; i++)
                    {
                        dgvRibbon.Rows[1].Cells[i].Value = alphabet[0];
                    }

                    //dgvRibbonFormat();
                    dgvRibbon = DGV.RibbonFormat(dgvRibbon);
                }

                if (Analyzer.alphabetAnalysis(dgvStates, alphabet) && Analyzer.syntacticAnalysis(dgvStates, alphabet, states) && Analyzer.semanticAnalysis(dgvStates, dgvRibbon, alphabet, states) && Analyzer.ribbonAnalysis(dgvRibbon, alphabet))
                {
                    blockOnStart();

                    colorIndexRibon   = 0;
                    colorIndexStates1 = 0;
                    colorIndexStates2 = 0;

                    start();
                }
                else
                {
                    alphabet = oldAlphabet;
                }
            }
            else
            if (buttonStart.Text == "Пауза")
            {
                trackBarSpeed.Enabled = true;
                timerAuto.Enabled     = false;
                buttonStart.Text      = "Продолжить";
            }
            else
            if (buttonStart.Text == "Продолжить")
            {
                trackBarSpeed.Enabled = false;
                timerAuto.Interval    = speed;
                timerAuto.Enabled     = true;
                buttonStart.Text      = "Пауза";
            }
            else
            if (buttonStart.Text == "Стоп")
            {
                step(true);
            }
        }