private void FileEndingsComboBoxChanged(object sender, EventArgs e) { statusTextBox.Text = ""; if ((string)fileEndingsComboBox.SelectedItem == "New") { addButton.Text = "Add"; fileEndingsTextBox.Text = ""; lineDelimiterTextBox.Text = ""; startDelimiterTextBox.Text = ""; endDelimiterTextBox.Text = ""; ignoreLineDelimiterTextBox.Text = ""; ignoreStartDelimiterTextBox.Text = ""; ignoreEndDelimiterTextBox.Text = ""; specialCharacterDelimiterTextBox.Text = ""; } else { addButton.Text = "Update"; CommentScraper.DelimiterInfo delimInfo = delimInfos[fileEndingsComboBox.SelectedIndex - 1]; fileEndingsTextBox.Text = EncloseInDelims(delimInfo.fileEndings, openDelim, closeDelim); lineDelimiterTextBox.Text = EncloseInDelims(delimInfo.lineDelimiters, openDelim, closeDelim); startDelimiterTextBox.Text = EncloseInDelims(delimInfo.startDelimiters, openDelim, closeDelim); endDelimiterTextBox.Text = EncloseInDelims(delimInfo.endDelimiters, openDelim, closeDelim); ignoreLineDelimiterTextBox.Text = EncloseInDelims(delimInfo.ignoreLineDelimiters, openDelim, closeDelim); ignoreStartDelimiterTextBox.Text = EncloseInDelims(delimInfo.startIgnoreDelimiters, openDelim, closeDelim); ignoreEndDelimiterTextBox.Text = EncloseInDelims(delimInfo.endIgnoreDelimiters, openDelim, closeDelim); specialCharacterDelimiterTextBox.Text = EncloseInDelims(delimInfo.specialCharacterDelimiters, openDelim, closeDelim); } }
private void OnAddButton(object sender, MouseEventArgs e) { CommentScraper.DelimiterInfo delimInfo = new CommentScraper.DelimiterInfo(); try { delimInfo.fileEndings = ParseStringBy(fileEndingsTextBox.Text, openDelim, closeDelim); if (delimInfo.fileEndings.Length == 0) { throw new Exception("You must have at least one file ending"); } delimInfo.lineDelimiters = ParseStringBy(lineDelimiterTextBox.Text, openDelim, closeDelim); delimInfo.startDelimiters = ParseStringBy(startDelimiterTextBox.Text, openDelim, closeDelim); delimInfo.endDelimiters = ParseStringBy(endDelimiterTextBox.Text, openDelim, closeDelim); delimInfo.ignoreLineDelimiters = ParseStringBy(ignoreLineDelimiterTextBox.Text, openDelim, closeDelim); delimInfo.startIgnoreDelimiters = ParseStringBy(ignoreStartDelimiterTextBox.Text, openDelim, closeDelim); delimInfo.endIgnoreDelimiters = ParseStringBy(ignoreEndDelimiterTextBox.Text, openDelim, closeDelim); delimInfo.specialCharacterDelimiters = ParseStringBy(specialCharacterDelimiterTextBox.Text, openDelim, closeDelim); if ((string)fileEndingsComboBox.SelectedItem == "New") { fileEndingsComboBox.Items.Add(EncloseInDelims(delimInfo.fileEndings, openDelim, closeDelim)); delimInfos.Add(delimInfo); fileEndingsComboBox.SelectedIndex = fileEndingsComboBox.Items.Count - 1; statusTextBox.Text = "Added successfully"; } else { delimInfos[fileEndingsComboBox.SelectedIndex - 1] = delimInfo; statusTextBox.Text = "Updated successfully"; } } catch (Exception err) { statusTextBox.Text = err.Message; } }