private void openFileButton_Click(object sender, EventArgs e) { const int MAX_FILE_LINES = 50000; string[] AllLines = new string[MAX_FILE_LINES]; openFile.ShowDialog(); Regex rx = new Regex(@"([a-zA-Z0-9s_\\.\-\\(\):])+(.txt)$"); if (rx.IsMatch(openFile.FileName)) { _tree = new AVLWordTree <Word>(); _tree.filename = openFile.FileName; AllLines = File.ReadAllLines(_tree.filename); fileNameLabel.Text = _tree.filename; fileOutputDisplay.Text = ""; for (int i = 0; i < AllLines.Length; i++) { //split words using space , . ? and ; string line = AllLines[i]; fileOutputDisplay.Text += line + "\n"; string[] words = line.Split(' ', ',', '.', '?', ';'); for (int j = 0; j < words.Length; j++) { if (words[j] != "") { Word newWord = new Word(words[j].ToLower(), new Location(i, j)); if (_tree.contains(newWord)) { _tree.addNewLocation(newWord); } else { _tree.insertItem(newWord); } } } } fileInfoButton.Visible = true; } }
public EditForm(Word word, AVLWordTree <Word> tree) { InitializeComponent(); _word = word; _tree = tree; }
public SearchForm(AVLWordTree <Word> tree) { InitializeComponent(); _tree = tree; }