private void loadCountriesMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog loadCountries = new OpenFileDialog();

            loadCountries.Filter = "CSV Files|*.csv";
            loadCountries.Title  = "Select a CSV File";

            if (loadCountries.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    string[]  headers        = new string[6];
                    const int MAX_LINES_FILE = 50000;
                    string[]  AllLines       = new string[MAX_LINES_FILE];
                    AllLines = File.ReadAllLines(loadCountries.FileName);
                    foreach (string line in AllLines)
                    {
                        if (line.StartsWith("Country"))
                        {
                            headers = line.Split(',');
                        }
                        else
                        {
                            string[]            columns  = line.Split(',');
                            LinkedList <String> tempList = new LinkedList <string>();
                            string[]            partners = columns[5].Split(';', '[', ']');
                            foreach (string tradePartner in partners)
                            {
                                if (tradePartner != "")
                                {
                                    tempList.AddLast(tradePartner.Replace('_', ' '));
                                }
                            }

                            Country temp = new Country
                            {
                                Name              = columns[0].Replace('_', ' '),
                                GdpGrowth         = Convert.ToDouble(columns[1]),
                                Inflation         = Convert.ToDouble(columns[2]),
                                TradeBalance      = Convert.ToDouble(columns[3]),
                                HdiRanking        = Convert.ToUInt32(columns[4]),
                                MainTradePartners = tempList
                            };
                            mainTree.InsertItem(temp);
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Please make sure that selected file is not already in use.\n\nIf file is not in use, please check for errors.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            refreshMainForm();
        }
        private void bigTradePotentiaMenuItem_Click(object sender, EventArgs e)
        {
            searchTextBox.Clear();
            clearSearchResults();
            Country biggestTradePotential = mainTree.GetBiggestTradePotential();

            resultsTree.InsertItem(biggestTradePotential);
            searchBoxLabel.Text       = "Displaying Country with Biggest Trade Potential";
            countryList.DataSource    = resultsTree.GetCountries();
            countryList.DisplayMember = "name";
            backButton.Enabled        = true;
        }
        public CountryTree FindTradePartners(Country searchTerm)
        {
            CountryTree tradePartners = new CountryTree();

            foreach (string partner in searchTerm.MainTradePartners)
            {
                foreach (Country country in GetCountries())
                {
                    if (country.Name.Equals(partner))
                    {
                        tradePartners.InsertItem(country);
                    }
                    else if (country.MainTradePartners.Contains(searchTerm.Name) && !tradePartners.Contains(country))
                    {
                        tradePartners.InsertItem(country);
                    }
                }
            }
            return(tradePartners);
        }