Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2521_ProblemRefactoring/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/StringComparisonFilterView.cs @ 16692

Last change on this file since 16692 was 16692, checked in by abeham, 5 years ago

#2521: merged trunk changes up to r15681 into branch (removal of trunk/sources)

File size: 4.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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
22using System.Windows.Forms;
23using HeuristicLab.MainForm;
24using HeuristicLab.MainForm.WindowsForms;
25
26namespace HeuristicLab.Clients.OKB.Query {
27  [View("StringComparisonFilter View")]
28  [Content(typeof(StringComparisonFilter), true)]
29  public partial class StringComparisonFilterView : FilterView {
30    public new StringComparisonFilter Content {
31      get { return (StringComparisonFilter)base.Content; }
32      set { base.Content = value; }
33    }
34
35    public StringComparisonFilterView() {
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      valueTextBox.Text = Content == null ? string.Empty : Content.Value;
57    }
58
59    protected override void SetEnabledStateOfControls() {
60      base.SetEnabledStateOfControls();
61      comparisonComboBox.Enabled = Content != null && !ReadOnly;
62      valueTextBox.Enabled = Content != null;
63      valueTextBox.ReadOnly = ReadOnly;
64    }
65
66    private void comparisonComboBox_SelectedIndexChanged(object sender, System.EventArgs e) {
67      if (Content != null) {
68        if (comparisonComboBox.SelectedItem.ToString() == "=")
69          Content.Comparison = StringComparison.Equal;
70        else if (comparisonComboBox.SelectedItem.ToString() == "<>")
71          Content.Comparison = StringComparison.NotEqual;
72        else if (comparisonComboBox.SelectedItem.ToString() == "contains")
73          Content.Comparison = StringComparison.Contains;
74        else if (comparisonComboBox.SelectedItem.ToString() == "not contains")
75          Content.Comparison = StringComparison.NotContains;
76        else if (comparisonComboBox.SelectedItem.ToString() == "like")
77          Content.Comparison = StringComparison.Like;
78        else if (comparisonComboBox.SelectedItem.ToString() == "not like")
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        valueTextBox.Text = Content.Value;
88        label.Focus();  // set focus on label to validate data
89      }
90    }
91    private void valueTextBox_Validated(object sender, System.EventArgs e) {
92      if (Content != null) {
93        Content.Value = valueTextBox.Text;
94      }
95    }
96  }
97}
Note: See TracBrowser for help on using the repository browser.