Ejemplo n.º 1
0
        private void bNextStep_Click(object sender, EventArgs e)
        {
            if (countOfStep <= final.ListBddInProcess.Count)
            {
                if (final.ListBddInProcess.ContainsKey(countOfStep))
                {
                    Bitmap     bmpLeft = final.DrawBDD(final.ListBddInProcess[countOfStep].Item1);
                    PictureBox pbLeft  = new PictureBox();
                    pbLeft.Image              = bmpLeft;
                    pbLeft.Width              = bmpLeft.Width;
                    pbLeft.Height             = bmpLeft.Height;
                    pbLeft.Parent             = pForDrawingBDD;
                    pbLeft.Location           = LocationLastPictureBox;
                    LocationLastPictureBox.X += (pbLeft.Width + 15);
                    LocationLastPictureBox.Y += 50;

                    Point pointForStep = new Point(LocationLastPictureBox.X + pbLeft.Width, LocationLastPictureBox.Y);

                    Label op = new Label();
                    op.Text     = GetSymbolByOperation(final.ListBddInProcess[countOfStep].Item4);
                    op.Font     = new Font("Times New Roman", 36, System.Drawing.FontStyle.Bold);
                    op.Parent   = pForDrawingBDD;
                    op.Location = LocationLastPictureBox;
                    op.AutoSize = true;
                    LocationLastPictureBox.X += 25;
                    LocationLastPictureBox.Y -= 50;
                    if (final.ListBddInProcess[countOfStep].Item2 != null)
                    {
                        Bitmap     bmpRight = final.DrawBDD(final.ListBddInProcess[countOfStep].Item2);
                        PictureBox pbRight  = new PictureBox();
                        pbRight.Image             = bmpRight;
                        pbRight.Width             = bmpRight.Width;
                        pbRight.Height            = bmpRight.Height;
                        pbRight.Parent            = pForDrawingBDD;
                        pbRight.Location          = LocationLastPictureBox;
                        LocationLastPictureBox.Y += Math.Max(pbLeft.Height, pbRight.Height);
                        pointForStep.X           += (pbRight.Width + 50);
                    }
                    else
                    {
                        LocationLastPictureBox.Y += pbLeft.Height;
                    }
                    Label eq = new Label();
                    eq.Text     = "=";
                    eq.Font     = new Font("Times New Roman", 36, System.Drawing.FontStyle.Bold);
                    eq.Parent   = pForDrawingBDD;
                    eq.Location = new Point(200, LocationLastPictureBox.Y);
                    eq.AutoSize = true;
                    LocationLastPictureBox.X -= (pbLeft.Width + 40);
                    LocationLastPictureBox.Y += 50;

                    Label step = new Label();
                    step.Text     = "Шаг №" + countOfStep;
                    step.Font     = new Font("Times New Roman", 28, System.Drawing.FontStyle.Bold);
                    step.Parent   = pForDrawingBDD;
                    step.Location = pointForStep;
                    step.AutoSize = true;

                    Bitmap     bmpAnswer = final.DrawBDD(final.ListBddInProcess[countOfStep].Item3);
                    PictureBox pbAnswer  = new PictureBox();
                    pbAnswer.Image  = bmpAnswer;
                    pbAnswer.Width  = bmpAnswer.Width;
                    pbAnswer.Height = bmpAnswer.Height;
                    pbAnswer.Parent = pForDrawingBDD;
                    //pbAnswer.BorderStyle = BorderStyle.FixedSingle;
                    pbAnswer.Location         = LocationLastPictureBox;
                    LocationLastPictureBox.Y += pbAnswer.Height;
                    countOfStep++;
                    finallyBitmap = bmpAnswer;
                    if (countOfStep == final.ListBddInProcess.Count)
                    {
                        bSaveBmpByFormula.Visible = true;
                        MessageBox.Show("Построение BDD окончено");
                    }
                }
            }
            else
            {
                MessageBox.Show("Построение BDD окончено");
            }
        }
Ejemplo n.º 2
0
        //построние по формуле
        private void bBuildBDDOnTheFormula_Click(object sender, EventArgs e)
        {
            rbFirstMethod.Visible  = false;
            rbSecondMethod.Visible = false;
            string expression = ConvertUserStringToProgramString(tbForFromula.Text);

            string[] listOrder = tbSeqVarInFormula.Text.Split(',');
            bNextStep.Visible = false;
            bool flag = false;

            if (listOrder[0] == "")
            {
                if (rbFirstMethod.Checked)
                {
                    listOrder = Bdd.GetOptimalOrderByCount(expression);
                    flag      = true;
                }
                else if (rbSecondMethod.Checked)
                {
                    listOrder = Bdd.GetOptimalOrderByDistance(expression);
                    flag      = true;
                }
                else
                {
                    MessageBox.Show("Введите порядок переменных или выберите автоматический подбор");
                }
            }
            else
            {
                if (CheckCoincidenceOfVariablesAndFormula(listOrder, expression))
                {
                    flag = true;
                }
                else
                {
                    MessageBox.Show("Некорректно введен порядок переменных");
                }
            }
            if (flag)
            {
                pForDrawingBDD.Controls.Clear();
                LocationLastPictureBox = new Point(10, 50);
                final = new Bdd();
                final = final.BuildBddOnFormula(expression, listOrder);

                Label formula = new Label();
                formula.Text     = "f(" + GetStringByStringBuf(listOrder) + ") = " + tbForFromula.Text;
                formula.Font     = new Font("Times New Roman", 28, System.Drawing.FontStyle.Bold);
                formula.Parent   = pForDrawingBDD;
                formula.Location = new Point(20, 20);
                formula.AutoSize = true;

                for (int i = 1; i <= final.ListBddInProcess.Count; i++)
                {
                    if (final.ListBddInProcess.ContainsKey(i))
                    {
                        Bitmap     bmpLeft = final.DrawBDD(final.ListBddInProcess[i].Item1);
                        PictureBox pbLeft  = new PictureBox();
                        pbLeft.Image              = bmpLeft;
                        pbLeft.Width              = bmpLeft.Width;
                        pbLeft.Height             = bmpLeft.Height;
                        pbLeft.Parent             = pForDrawingBDD;
                        pbLeft.Location           = LocationLastPictureBox;
                        LocationLastPictureBox.X += (pbLeft.Width + 15);
                        LocationLastPictureBox.Y += 50;

                        Point pointForStep = new Point(LocationLastPictureBox.X + pbLeft.Width, LocationLastPictureBox.Y);

                        Label op = new Label();
                        op.Text     = GetSymbolByOperation(final.ListBddInProcess[i].Item4);
                        op.Font     = new Font("Times New Roman", 36, System.Drawing.FontStyle.Bold);
                        op.Parent   = pForDrawingBDD;
                        op.Location = LocationLastPictureBox;
                        op.AutoSize = true;
                        LocationLastPictureBox.X += 25;
                        LocationLastPictureBox.Y -= 50;
                        if (final.ListBddInProcess[i].Item2 != null)
                        {
                            Bitmap     bmpRight = final.DrawBDD(final.ListBddInProcess[i].Item2);
                            PictureBox pbRight  = new PictureBox();
                            pbRight.Image             = bmpRight;
                            pbRight.Width             = bmpRight.Width;
                            pbRight.Height            = bmpRight.Height;
                            pbRight.Parent            = pForDrawingBDD;
                            pbRight.Location          = LocationLastPictureBox;
                            LocationLastPictureBox.Y += Math.Max(pbLeft.Height, pbRight.Height);
                            pointForStep.X           += (pbRight.Width);
                        }
                        else
                        {
                            LocationLastPictureBox.Y += pbLeft.Height;
                        }

                        Label eq = new Label();
                        eq.Text     = "=";
                        eq.Font     = new Font("Times New Roman", 36, System.Drawing.FontStyle.Bold);
                        eq.Parent   = pForDrawingBDD;
                        eq.Location = new Point(200, LocationLastPictureBox.Y);
                        eq.AutoSize = true;
                        LocationLastPictureBox.X -= (pbLeft.Width + 40);
                        LocationLastPictureBox.Y += 50;

                        Label step = new Label();
                        step.Text     = "Шаг №" + i;
                        step.Font     = new Font("Times New Roman", 28, System.Drawing.FontStyle.Bold);
                        step.Parent   = pForDrawingBDD;
                        step.Location = pointForStep;
                        step.AutoSize = true;

                        Bitmap     bmpAnswer = final.DrawBDD(final.ListBddInProcess[i].Item3);
                        PictureBox pbAnswer  = new PictureBox();
                        pbAnswer.Image  = bmpAnswer;
                        pbAnswer.Width  = bmpAnswer.Width;
                        pbAnswer.Height = bmpAnswer.Height;
                        pbAnswer.Parent = pForDrawingBDD;
                        //pbAnswer.BorderStyle = BorderStyle.FixedSingle;
                        pbAnswer.Location         = LocationLastPictureBox;
                        LocationLastPictureBox.Y += pbAnswer.Height;

                        finallyBitmap = bmpAnswer;
                    }
                }
                bSaveBmpByFormula.Visible = true;
            }
        }