/// <summary>
        /// Event handler for Look Up or Get Statistics button
        /// </summary>
        /// <param name="sender">general object passed in</param>
        /// <param name="e">EventArgs object passed in</param>
        private void uxGetStatistics_Click(object sender, EventArgs e)
        {
            string fileName = uxNameBox.Text.Trim().ToUpper();
            //try
            //{
            NameInformation nameInfoFile = _names.Find(fileName);

            if (nameInfoFile.Name != null)
            {
                uxFrequency.Text = nameInfoFile.Frequency.ToString();
                uxRank.Text      = nameInfoFile.Rank.ToString();
                return;
            }
            else
            {
                uxFrequency.Clear();
                uxRank.Clear();
                MessageBox.Show("Name was not found!");
            }
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.ToString());
            //    uxFrequency.Clear();
            //    uxRank.Clear();
            //}
        }
Example #2
0
        /// <summary>
        /// This is the click event handler for the Get Statistics Button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void uxLookup_Click(object sender, EventArgs e)
        {
            NameInformation name = _names.Find(uxName.Text.Trim().ToUpper());

            if (name.Name == null)
            {
                MessageBox.Show("Name not found.");
                uxFrequency.Text = "";
                uxRank.Text      = "";
            }
            else
            {
                uxFrequency.Text = name.Frequency.ToString();
                uxRank.Text      = name.Rank.ToString();
                return;
            }
        }
Example #3
0
        }         //END OF uxOpen_Click METHOD

        /// <summary>
        /// Take the text from name TextBox and search for it in the _names B-tree
        /// by calling Find method
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void uxLookup_Click(object sender, EventArgs e)
        {
            string          name     = uxName.Text.Trim().ToUpper();
            NameInformation nameInfo = _names.Find(name);

            if (nameInfo.Name == null)
            {
                MessageBox.Show("Name Not Found");
                uxFrequency.Clear();
                uxRank.Clear();
            }   //END OF IF STATEMENT
            else
            {
                uxFrequency.Text = _names.Find(name).Frequency.ToString();
                uxRank.Text      = _names.Find(name).Rank.ToString();
            } //END OF ELSE STATEMENT
        }     //END OF uxLookup_Click
        /// <summary>
        /// Event handler for the Get Statistics Button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void uxLookup_Click(object sender, EventArgs e)
        {
            String          name = uxName.Text.Trim().ToUpper();
            NameInformation temp = _names.Find(name);

            if (temp.Name != null)
            {
                uxFrequency.Text = _names.Find(name).Frequency.ToString();
                uxRank.Text      = _names.Find(name).Rank.ToString();
            }
            else
            {
                MessageBox.Show("Name Not Found.");
                uxFrequency.Text = "";
                uxRank.Text      = "";
            }
        }
Example #5
0
        /// <summary>
        /// Used to read the file and intitialize _names
        /// </summary>
        /// <param name="fn">Holds the fileName</param>
        /// <returns>A tree containing all the names</returns>
        private BTree <string, NameInformation> ReadFile(string fn)
        {
            int minDegree = Convert.ToInt32(uxMinDegree.Text);
            BTree <string, NameInformation> newTree = new BTree <string, NameInformation>(minDegree);

            using (StreamReader input = new StreamReader(fn))
            {
                while (!input.EndOfStream)
                {
                    string          name      = input.ReadLine().Trim();
                    float           frequency = Convert.ToSingle(input.ReadLine());
                    int             rank      = Convert.ToInt32(input.ReadLine());
                    NameInformation newName   = new NameInformation(name, frequency, rank);
                    newTree.Insert(name, newName);
                } //END OF WHILE-LOOP
                return(newTree);
            }     //END OF USING STATEMENT
        }         //END OF ReadFile METHOD
        /// <summary>
        /// Takes in the file name of a NameInformation file and reads it using a Streamreader
        /// </summary>
        /// <param name="fn">filename of NameInformation file</param>
        /// <returns></returns>
        private BTree <string, NameInformation> ReadFile(string fn)
        {
            int minimumDeg = Convert.ToInt32(uxMinimumDegree.Value);
            BTree <string, NameInformation> tempTree = new BTree <string, NameInformation>(minimumDeg);

            using (StreamReader sr = new StreamReader(fn))
            {
                while (!sr.EndOfStream)
                {
                    string          name     = sr.ReadLine().Trim();
                    float           freq     = Convert.ToSingle(sr.ReadLine());
                    int             rank     = Convert.ToInt32(sr.ReadLine());
                    NameInformation tempName = new NameInformation(name, freq, rank);
                    tempTree.Insert(name, tempName);
                }
            }
            return(tempTree);
        }
Example #7
0
        /// <summary>
        /// reads in a file creating a BTree
        /// </summary>
        /// <param name="fn">filename to read in</param>
        /// <returns>BTrees with string as key and NameInformation as value</returns>
        private BTree <string, NameInformation> ReadFile(string fn)
        {
            BTree <string, NameInformation> tree = new BTree <string, NameInformation>((int)uxMinDegree.Value);

            using (StreamReader input = new StreamReader(fn))
            {
                while (!input.EndOfStream)
                {
                    string          name = input.ReadLine().Trim();
                    float           freq = Convert.ToSingle(input.ReadLine());
                    int             rank = Convert.ToInt32(input.ReadLine());
                    NameInformation info = new NameInformation(name, freq, rank);

                    tree.Insert(name, info);
                }
                return(tree);
            }
        }
        /// <summary>
        /// This method takes in the file name of a name information file and reads it using a StreamReader.
        /// </summary>
        /// <param name="fn"></param>
        /// <returns></returns>
        private BTree <string, NameInformation> ReadFile(string fn)
        {
            using (StreamReader input = new StreamReader(fn))
            {
                int min = Convert.ToInt32(uxMinDegree.Text);
                BTree <string, NameInformation> tree = new BTree <string, NameInformation>(min);

                while (!input.EndOfStream)
                {
                    String          name      = input.ReadLine().Trim();
                    float           frequency = Convert.ToSingle(input.ReadLine());
                    int             rank      = Convert.ToInt32(input.ReadLine());
                    NameInformation temp      = new NameInformation(name, frequency, rank);
                    tree.Insert(name, temp);
                }
                return(tree);
            }
        }
Example #9
0
 /// <summary>
 /// looks up name from text box in names BTree
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void uxLookUp_Click(object sender, EventArgs e)
 {
     try
     {
         string          name = uxName.Text.Trim().ToUpper();
         NameInformation info = _names.Find(name);
         if (info.Name != null)
         {
             uxFrequency.Text = info.Frequency.ToString();
             uxRank.Text      = info.Rank.ToString();
             return;
         }
         else
         {
             uxFrequency.Text = "";
             uxRank.Text      = "";
             MessageBox.Show("name was not found");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Obejct reference not set to an instance of an object.");
     }
 }