Exemplo n.º 1
0
        private void AddToTreeView(Class.RBTreeNode <int, string> node, TreeNode tvNode)
        {
            if (node == null)
            {
                return;
            }

            TreeNode newtvNode;

            if (node.IsBlack)
            {
                newtvNode = new TreeNode("Key=" + node.Key.ToString() + " Color= Black");
                tvNode.Nodes.Add(newtvNode);
                AddToTreeView(node.Left, newtvNode);
                AddToTreeView(node.Right, newtvNode);
            }
            else
            {
                newtvNode = new TreeNode("Key=" + node.Key.ToString() + " Color= Red");
                tvNode.Nodes.Add(newtvNode);
                AddToTreeView(node.Left, newtvNode);
                AddToTreeView(node.Right, newtvNode);
            }
            //    i = (node.IsBlack ? 0 : 1);
            //newtvNode = new TreeNode("Key=" + node.Key.ToString() + "; Data=" + node.Data.ToString() + "; Count=" + node.Count, i, i);
            //tvNode.Nodes.Add(newtvNode);
            //AddToTreeView(node.Left, newtvNode);
            //AddToTreeView(node.Right, newtvNode);
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (rb5 == false && rb6 == false)
                {
                    MessageBox.Show("Не выбранно количество деревьев для показа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    int emountOfVertex = Convert.ToInt32(textBoxNumber.Text);
                    Class.RBTreeNode <int, string> node;
                    int    i, k;
                    Random rnd = new Random();

                    for (i = 1; i <= emountOfVertex; i++)
                    {
                        k    = rnd.Next(100);
                        node = new Class.RBTreeNode <int, string>(k, k.ToString());
                        tree.InsertNode(node);
                    }

                    //bmpTemp = bmp;
                    //ShowRBTree();
                    //bmp = getControlScreenshot(tvRB);
                    bmpTemp2 = bmpTemp1;
                    bmpTemp1 = bmpTemp;
                    bmpTemp  = bmp;


                    ShowRBTree();
                    bmp = getControlScreenshot(tvRB);
                    pictureBox1.Image = bmpTemp;
                    pictureBox3.Image = bmpTemp2;
                    pictureBox2.Image = bmpTemp1;

                    pictureBox1.Image = bmpTemp;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Неверно введенные данные!", "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            Class.RBTreeNode <int, string> node;
            int    key;
            string data;

            //for view picture
            try
            {
                if (rb5 == false && rb6 == false)
                {
                    MessageBox.Show("Не выбранно количество деревьев для показа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    key  = Convert.ToInt32(textBoxKey1.Text);
                    data = textBoxData1.Text.ToString();
                    node = new Class.RBTreeNode <int, string>(key, data);
                    tree.InsertNode(node);


                    //bmpTemp = bmp;

                    //ShowRBTree();
                    //bmp = getControlScreenshot(tvRB);
                    //pictureBox1.Image = bmpTemp;
                    bmpTemp2 = bmpTemp1;
                    bmpTemp1 = bmpTemp;
                    bmpTemp  = bmp;


                    ShowRBTree();
                    bmp = getControlScreenshot(tvRB);
                    pictureBox1.Image = bmpTemp;
                    pictureBox3.Image = bmpTemp2;
                    pictureBox2.Image = bmpTemp1;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Неверно введенные данные!", "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
        private void add_5_node_Click(object sender, EventArgs e)
        {
            Class.RBTreeNode <int, string> node;
            int    i, k;
            Random rnd = new Random();

            for (i = 1; i <= 5; i++)
            {
                k    = rnd.Next(100);
                node = new Class.RBTreeNode <int, string>(k, k.ToString());
                tree.InsertNode(node);
            }

            bmpTemp = bmp;
            ShowRBTree();
            bmp = getControlScreenshot(tvRB);

            pictureBox1.Image = bmpTemp;
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            Class.RBTreeNode <int, string> node;
            int    key;
            string data;

            //for view picture

            try
            {
                key  = Convert.ToInt32(nodeKey_txtBx.Text);
                data = nodeData_txtBx.Text.ToString();
                node = new Class.RBTreeNode <int, string>(key, data);
                tree.InsertNode(node);
                bmpTemp  = bmp;
                bmpTemp1 = bmpTemp;
                bmpTemp2 = bmpTemp1;
                ShowRBTree();
                bmp = getControlScreenshot(tvRB);

                pictureBox1.Image = bmpTemp;
                pictureBox2.Image = bmpTemp;
                pictureBox3.Image = bmpTemp;
                //if (bmpTemp != null)
                //    counter++;
                //if (counter %2 != 0)
                //{
                //    bmpTemp1 = bmp1;

                //    ShowRBTree();
                //    bmp1 = getControlScreenshot(treeView1);

                //    pictureBox1.Image = bmpTemp1;
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show("Неверно введенные данные!", "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }