Esempio n. 1
0
        /*
         * Formats the keyword textbox to create a list of each of the keywords it needs to seach for,
         * then finds out how often it appears in the text and adds it to the KeywordFrequencies list.
         */
        private void GetKeywordsFromTextbox()
        {
            List <String> Keywords = new List <String>();

            String[] KeywordsSplitted = Textbox_Keywords.getTextbox().Text.Split(',');

            KeywordFrequencies.Clear();
            foreach (String keyword in KeywordsSplitted)
            {
                if (keyword.Trim() != String.Empty)
                {
                    String FormattedKeyword = keyword.ToLower().Trim();
                    int    Frequency        = GetNumberOfKeywords(FormattedKeyword);

                    if (RichTextbox_MainText.getTextbox().Text.ToLower().Contains(FormattedKeyword))
                    {
                        KeywordFrequency NewKF;
                        NewKF.Keyword   = keyword.Trim();
                        NewKF.Frequency = Frequency;
                        KeywordFrequencies.Add(NewKF);
                    }

                    ChangeColourOfKeywords(FormattedKeyword);
                }
            }

            AddKeywordsToListbox();
        }
Esempio n. 2
0
 private void Button_Search_Click(object sender, EventArgs e)
 {
     // Search will only start if there is text in the textbox
     if (Textbox_Keywords.getTextbox().Text.Length > 0)
     {
         GetKeywordsFromTextbox();
     }
 }
Esempio n. 3
0
        /*
         * Loads keywords from a file, or if the file does not exist it will create a new .csv file will
         * the default keywords.
         */
        private void Button_KeywordsFile_Click(object sender, EventArgs e)
        {
            if (File.Exists("keywords.csv"))
            {
                String keywordsFileText            = File.ReadAllText("keywords.csv");
                Textbox_Keywords.getTextbox().Text = keywordsFileText;
            }
            else
            {
                MessageBox.Show("Could not find the \"keyword.search\" file." + Environment.NewLine + "Creating default file.", "File", MessageBoxButtons.OK);

                String       fileText = "fear, terror, threat, the enemy, out there, always, circling, watching, waiting";
                StreamWriter newFile  = new StreamWriter("keywords.csv");
                newFile.WriteLine(fileText);
                newFile.Close();
            }
        }
Esempio n. 4
0
 /*
  * Clears the text in the keywords textbox.
  */
 private void Button_ClearKeywords_Click(object sender, EventArgs e)
 {
     Textbox_Keywords.getTextbox().Text = String.Empty;
     Listbox_SearchCount.getListBox().Items.Clear();
     SetMainTextDefaultColour();
 }