示例#1
0
        }        //End MenuForm ( )

        #endregion

        #region Click Event
        /// <summary>
        /// Handles the Click event of the TreeButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void TreeButton_Click(object sender, EventArgs e)
        {
            bool valid = true;

            try
            {
                numNodes = Int32.Parse(StartTextBox.Text);
                NodeSize = Int32.Parse(NodeTextBox.Text);
            }            //End try statement
            catch (ArgumentNullException)
            {
                MessageBox.Show("There is no data in field",
                                "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                valid = false;
            }            //End else statement
            catch (FormatException)
            {
                MessageBox.Show("There is Invalid data in field",
                                "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                valid = false;
            }            //End else statement
            if (valid)
            {
                b = new BTree(NodeSize);
                int    next;
                int [] values = new int [numNodes];
                if (RandomCheckBox.Checked)
                {
                    for (int i = 0; i < numNodes; i++)
                    {
                        next       = random.Next(0, 10000);
                        values [i] = next;
                    }            //end for loop
                }                //End if statement
                else
                {
                    for (int i = 0; i < numNodes; i++)
                    {
                        values [i] = i;
                    }            //end for loop
                }                //End else statement
                for (int i = 0; i < values.Length; i++)
                {
                    b.AddValue(values [i]);
                }                //end for loop
                Tree tree = new Tree(b);
                tree.ShowDialog( );
            }    //End if statement
        }        //End TreeButton_Click (object, EventArgs)