1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.ComponentModel;
|
---|
4 | using System.Data;
|
---|
5 | using System.Drawing;
|
---|
6 | using System.Globalization;
|
---|
7 | using System.Linq;
|
---|
8 | using System.Text;
|
---|
9 | using System.Text.RegularExpressions;
|
---|
10 | using System.Windows.Forms;
|
---|
11 | using System.Windows.Forms.VisualStyles;
|
---|
12 |
|
---|
13 | namespace HeuristicLab.BioBoost.Views {
|
---|
14 | public partial class FilterDialog : Form {
|
---|
15 |
|
---|
16 | public Regex Regex { get; private set; }
|
---|
17 | public bool Keep { get; private set; }
|
---|
18 |
|
---|
19 | public FilterDialog() {
|
---|
20 | InitializeComponent();
|
---|
21 | Keep = true;
|
---|
22 | }
|
---|
23 |
|
---|
24 | protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
|
---|
25 | if (keyData == Keys.Enter) {
|
---|
26 | DialogResult = DialogResult.OK;
|
---|
27 | Close();
|
---|
28 | return true;
|
---|
29 | } else if (keyData == Keys.Escape) {
|
---|
30 | DialogResult = DialogResult.Cancel;
|
---|
31 | Close();
|
---|
32 | return true;
|
---|
33 | }
|
---|
34 | return base.ProcessCmdKey(ref msg, keyData);
|
---|
35 | }
|
---|
36 |
|
---|
37 | private void textBox1_Validating(object sender, CancelEventArgs e) {
|
---|
38 | try {
|
---|
39 | Regex = new Regex(textBox1.Text, RegexOptions.IgnoreCase|RegexOptions.IgnorePatternWhitespace);
|
---|
40 | } catch (ArgumentException x) {
|
---|
41 | textBox1.Select(0, textBox1.Text.Length);
|
---|
42 | e.Cancel = true;
|
---|
43 | errorProvider1.SetError(textBox1, "not a valid regular expression.");
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | private void textBox1_Validated(object sender, EventArgs e) {
|
---|
48 | errorProvider1.SetError(textBox1, "");
|
---|
49 | }
|
---|
50 |
|
---|
51 | private void cancelButton_Click(object sender, EventArgs e) {
|
---|
52 | DialogResult = DialogResult.Cancel;
|
---|
53 | Close();
|
---|
54 | }
|
---|
55 |
|
---|
56 | private void okButton_Click(object sender, EventArgs e) {
|
---|
57 | DialogResult = DialogResult.OK;
|
---|
58 | Close();
|
---|
59 | }
|
---|
60 |
|
---|
61 | private void keepOption_CheckedChanged(object sender, EventArgs e) {
|
---|
62 | Keep = keepOption.Checked;
|
---|
63 | }
|
---|
64 |
|
---|
65 |
|
---|
66 | }
|
---|
67 | }
|
---|