示例#1
0
        private void BtnSemanticTableaux_Click(object sender, EventArgs e)
        {
            try
            {
                string userInput = TbFormulaInput.Text.Trim();
                if (userInput.Length < 4)
                {
                    throw new Exception("Format of input is not correct");
                }
                else
                {
                    _graphImages.Clear();
                    userInput = $"~({userInput})";
                    var binaryTree = ParsingModule.Parse(userInput);
                    _tableauxRoot = new TableauxNode(binaryTree.Root as CompositeComponent);
                    _tableauxRoot.IsClosed();

                    _graphImages.Add(0, GenerateGraphVizBinaryGraph(binaryTree.Root.GraphVizFormula, "Normal"));
                    _graphImages.Add(1, GenerateGraphVizBinaryGraph(_tableauxRoot.GraphVizFormula(), "Tableaux"));
                    BtnSemanticTableaux.BackColor = _tableauxRoot.LeafIsClosed == true ? Color.ForestGreen : Color.Tomato;
                    _imageIndex                    = 0;
                    BtnImageNext.Enabled           = true;
                    Btn_Image_Open.Enabled         = true;
                    Tb_InfixFormula_Normal.Enabled = true;
                    PbBinaryGraph.ImageLocation    = _graphImages[0];
                    _formulaGenerator.Calculate(binaryTree.Root);
                    Tb_InfixFormula_Normal.Text = binaryTree.Root.InFixFormula;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($@"{ex.Message}");
            }
        }
示例#2
0
        //Form Event Handlers
        private void BtnParse_Click(object sender, EventArgs e)
        {
            string userInput = TbFormulaInput.Text.Trim();

            try
            {
                if (userInput.Length < 4)
                {
                    throw new Exception("Format of input is not correct");
                }
                else
                {
                    _graphImages.Clear();
                    _binaryTreeNormal = ParsingModule.Parse(userInput);
                    var rootOfNormalBinaryTree = _binaryTreeNormal.Root as CompositeComponent;
                    _nandify.Calculate(rootOfNormalBinaryTree);

                    _truthTable     = new TruthTable(_binaryTreeNormal);
                    _truthTableNand = new TruthTable(Nandify.BinaryTree);
                    _truthTable.ProcessDnf();

                    PopulateTextBoxesWithValues(rootOfNormalBinaryTree);
                    PopulateListBoxesWithValues();
                    PopulatePictureBoxWithImages(rootOfNormalBinaryTree);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($@"{ex.Message}");
            }
        }