1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.ComponentModel;
|
---|
24 | using System.Text.RegularExpressions;
|
---|
25 | using System.Windows.Forms;
|
---|
26 |
|
---|
27 | namespace HeuristicLab.BioBoost.Views {
|
---|
28 | public partial class FilterDialog : Form {
|
---|
29 |
|
---|
30 | public Regex Regex { get; private set; }
|
---|
31 | public bool Keep { get; private set; }
|
---|
32 |
|
---|
33 | public FilterDialog() {
|
---|
34 | InitializeComponent();
|
---|
35 | Keep = true;
|
---|
36 | }
|
---|
37 |
|
---|
38 | protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
|
---|
39 | if (keyData == Keys.Enter) {
|
---|
40 | DialogResult = DialogResult.OK;
|
---|
41 | Close();
|
---|
42 | return true;
|
---|
43 | } else if (keyData == Keys.Escape) {
|
---|
44 | DialogResult = DialogResult.Cancel;
|
---|
45 | Close();
|
---|
46 | return true;
|
---|
47 | }
|
---|
48 | return base.ProcessCmdKey(ref msg, keyData);
|
---|
49 | }
|
---|
50 |
|
---|
51 | private void textBox1_Validating(object sender, CancelEventArgs e) {
|
---|
52 | try {
|
---|
53 | Regex = new Regex(textBox1.Text, RegexOptions.IgnoreCase|RegexOptions.IgnorePatternWhitespace);
|
---|
54 | } catch (ArgumentException x) {
|
---|
55 | textBox1.Select(0, textBox1.Text.Length);
|
---|
56 | e.Cancel = true;
|
---|
57 | errorProvider1.SetError(textBox1, "not a valid regular expression.");
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | private void textBox1_Validated(object sender, EventArgs e) {
|
---|
62 | errorProvider1.SetError(textBox1, "");
|
---|
63 | }
|
---|
64 |
|
---|
65 | private void cancelButton_Click(object sender, EventArgs e) {
|
---|
66 | DialogResult = DialogResult.Cancel;
|
---|
67 | Close();
|
---|
68 | }
|
---|
69 |
|
---|
70 | private void okButton_Click(object sender, EventArgs e) {
|
---|
71 | DialogResult = DialogResult.OK;
|
---|
72 | Close();
|
---|
73 | }
|
---|
74 |
|
---|
75 | private void keepOption_CheckedChanged(object sender, EventArgs e) {
|
---|
76 | Keep = keepOption.Checked;
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 | }
|
---|
81 | }
|
---|