Exemplo n.º 1
0
        private void premiseButton_Click(object sender, EventArgs e)
        {
            TextBox txtPremise = new TextBox();

            txtPremise.Name      = "premise";
            txtPremise.Size      = new System.Drawing.Size(80, 25);
            txtPremise.GotFocus += textBox_Enter;
            txtPremise.KeyPress += textBox_KeyPress;
            txtPremise.Tag       = "P";
            TTNode premise = new TTNode(txtPremise);

            if (!clicked)
            {
                parent              = premise;
                parent.x            = 370;
                parent.y            = 10;
                clicked             = true;
                txtPremise.Location = new System.Drawing.Point(parent.x, parent.y);
            }
            else if (focusedTextbox != null)
            {
                TTNode p = parent.find(focusedTextbox);
                premise.parent = p;
                p.addChild(premise);
                parent.reposition();
                txtPremise.Location = new System.Drawing.Point(premise.x, premise.y);
                parent.lineRef      = 0;
                parent.level        = 1;
            }
            panel1.Controls.Add(txtPremise);

            //create corresponding checkbox
            CheckBox chkPremise = new CheckBox();

            chkPremise.Location = new System.Drawing.Point(premise.x + 87, premise.y + 3);
            chkPremise.Tag      = premise;
            chkPremise.Size     = new System.Drawing.Size(15, 15);
            panel1.Controls.Add(chkPremise);
            premise.cb = chkPremise;
            checkboxes.Add(chkPremise);
            focusedTextbox = txtPremise;
            premise.state  = "Premise";
            if (premise.parent != null)
            {
                premise.level = premise.parent.level + 1;
            }
        }
Exemplo n.º 2
0
        private void branchButton_Click(object sender, EventArgs e)
        {
            if (focusedTextbox == null)
            {
                return;
            }
            TextBox txtRight = new TextBox();
            TextBox txtLeft  = new TextBox();

            txtLeft.Name       = "txtLeft";
            txtRight.Name      = "txtRight";
            txtRight.Size      = new System.Drawing.Size(80, 25);
            txtLeft.Size       = new System.Drawing.Size(80, 25);
            txtRight.GotFocus += textBox_Enter;
            txtRight.KeyPress += textBox_KeyPress;
            txtLeft.GotFocus  += textBox_Enter;
            txtLeft.KeyPress  += textBox_KeyPress;
            txtRight.Tag       = "R";
            txtLeft.Tag        = "L";
            panel1.Controls.Add(txtRight);
            panel1.Controls.Add(txtLeft);

            TTNode left  = new TTNode(txtLeft);
            TTNode right = new TTNode(txtRight);

            left.sibling  = right;
            right.sibling = left;
            if (focusedTextbox != null)
            {
                TTNode p = parent.find(focusedTextbox);
                left.parent  = p;
                right.parent = p;
                p.addChild(left);
                p.addChild(right);
                p.reposition();
                txtRight.Location = new System.Drawing.Point(right.x, right.y);
                txtLeft.Location  = new System.Drawing.Point(left.x, left.y);
                parent.drawLines();
                drawLines(p);
            }

            //create corresponding checkboxes
            CheckBox chkRight = new CheckBox();
            CheckBox chkLeft  = new CheckBox();

            chkRight.Location = new System.Drawing.Point(right.x + 87, right.y + 3);
            chkLeft.Location  = new System.Drawing.Point(left.x + 87, left.y + 3);
            chkLeft.Size      = new System.Drawing.Size(10, 10);
            chkRight.Tag      = right;
            chkLeft.Tag       = left;
            chkRight.Size     = new System.Drawing.Size(15, 15);
            chkLeft.Size      = new System.Drawing.Size(15, 15);
            panel1.Controls.Add(chkRight);
            panel1.Controls.Add(chkLeft);

            right.cb = chkRight;
            left.cb  = chkLeft;
            checkboxes.Add(chkRight);
            checkboxes.Add(chkLeft);
            focusedTextbox = txtRight;
            right.state    = "Branch";
            left.state     = "Branch";
            right.level    = right.parent.level + 1;
            left.level     = left.parent.level + 1;
        }