[8055] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[15973] | 3 | * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[8055] | 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.Windows.Forms;
|
---|
| 23 | using HeuristicLab.MainForm;
|
---|
| 24 | using HeuristicLab.MainForm.WindowsForms;
|
---|
| 25 |
|
---|
| 26 | namespace HeuristicLab.Clients.OKB.Query {
|
---|
| 27 | [View("StringComparisonAvailableValuesFilter View")]
|
---|
| 28 | [Content(typeof(StringComparisonAvailableValuesFilter), true)]
|
---|
| 29 | public partial class StringComparisonAvailableValuesFilterView : FilterView {
|
---|
| 30 | public new StringComparisonAvailableValuesFilter Content {
|
---|
| 31 | get { return (StringComparisonAvailableValuesFilter)base.Content; }
|
---|
| 32 | set { base.Content = value; }
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | public StringComparisonAvailableValuesFilterView() {
|
---|
| 36 | InitializeComponent();
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | protected override void OnContentChanged() {
|
---|
| 40 | base.OnContentChanged();
|
---|
| 41 | comparisonComboBox.SelectedIndex = -1;
|
---|
| 42 | if (Content != null) {
|
---|
| 43 | if (Content.Comparison == StringComparison.Equal)
|
---|
| 44 | comparisonComboBox.SelectedItem = "=";
|
---|
| 45 | else if (Content.Comparison == StringComparison.NotEqual)
|
---|
| 46 | comparisonComboBox.SelectedItem = "<>";
|
---|
| 47 | else if (Content.Comparison == StringComparison.Contains)
|
---|
| 48 | comparisonComboBox.SelectedItem = "contains";
|
---|
| 49 | else if (Content.Comparison == StringComparison.NotContains)
|
---|
| 50 | comparisonComboBox.SelectedItem = "not contains";
|
---|
| 51 | else if (Content.Comparison == StringComparison.Like)
|
---|
| 52 | comparisonComboBox.SelectedItem = "like";
|
---|
| 53 | else if (Content.Comparison == StringComparison.NotLike)
|
---|
| 54 | comparisonComboBox.SelectedItem = "not like";
|
---|
| 55 | }
|
---|
| 56 | valueComboBox.DataSource = Content == null ? null : Content.AvailableValues;
|
---|
| 57 | valueComboBox.Text = Content == null ? string.Empty : Content.Value;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | protected override void SetEnabledStateOfControls() {
|
---|
| 61 | base.SetEnabledStateOfControls();
|
---|
| 62 | comparisonComboBox.Enabled = Content != null && !ReadOnly;
|
---|
| 63 | valueComboBox.Enabled = Content != null && !ReadOnly;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | private void comparisonComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
|
---|
| 67 | if (Content != null) {
|
---|
[8138] | 68 | if (comparisonComboBox.SelectedItem.ToString() == "=")
|
---|
[8055] | 69 | Content.Comparison = StringComparison.Equal;
|
---|
[8138] | 70 | else if (comparisonComboBox.SelectedItem.ToString() == "<>")
|
---|
[8055] | 71 | Content.Comparison = StringComparison.NotEqual;
|
---|
[8138] | 72 | else if (comparisonComboBox.SelectedItem.ToString() == "contains")
|
---|
[8055] | 73 | Content.Comparison = StringComparison.Contains;
|
---|
[8138] | 74 | else if (comparisonComboBox.SelectedItem.ToString() == "not contains")
|
---|
[8055] | 75 | Content.Comparison = StringComparison.NotContains;
|
---|
[8138] | 76 | else if (comparisonComboBox.SelectedItem.ToString() == "like")
|
---|
[8055] | 77 | Content.Comparison = StringComparison.Like;
|
---|
[8138] | 78 | else if (comparisonComboBox.SelectedItem.ToString() == "not like")
|
---|
[8055] | 79 | Content.Comparison = StringComparison.NotLike;
|
---|
| 80 | }
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | private void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
|
---|
| 84 | if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
|
---|
| 85 | label.Focus(); // set focus on label to validate data
|
---|
| 86 | if (e.KeyCode == Keys.Escape) {
|
---|
| 87 | valueComboBox.Text = Content.Value;
|
---|
| 88 | label.Focus(); // set focus on label to validate data
|
---|
| 89 | }
|
---|
| 90 | }
|
---|
| 91 | private void valueComboBox_Validated(object sender, System.EventArgs e) {
|
---|
| 92 | if (Content != null) {
|
---|
| 93 | Content.Value = valueComboBox.Text;
|
---|
| 94 | }
|
---|
| 95 | }
|
---|
| 96 | }
|
---|
| 97 | }
|
---|