Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2817-BinPackingSpeedup/HeuristicLab.Clients.OKB.Views/3.3/Query/Views/OrdinalComparisonDateTimeFilterView.cs @ 16140

Last change on this file since 16140 was 16140, checked in by abeham, 6 years ago

#2817: updated to trunk r15680

File size: 2.9 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;
23using System.Windows.Forms;
24using HeuristicLab.MainForm;
25using HeuristicLab.MainForm.WindowsForms;
26
27namespace HeuristicLab.Clients.OKB.Query {
28  [View("OrdinalComparisonDateTimeFilter View")]
29  [Content(typeof(OrdinalComparisonDateTimeFilter), true)]
30  public partial class OrdinalComparisonDateTimeFilterView : OrdinalComparisonFilterView {
31    public new OrdinalComparisonDateTimeFilter Content {
32      get { return (OrdinalComparisonDateTimeFilter)base.Content; }
33      set { base.Content = value; }
34    }
35
36    public OrdinalComparisonDateTimeFilterView() {
37      InitializeComponent();
38      errorProvider.SetIconAlignment(valueTextBox, ErrorIconAlignment.MiddleLeft);
39      errorProvider.SetIconPadding(valueTextBox, 2);
40    }
41
42    protected override void OnContentChanged() {
43      base.OnContentChanged();
44      valueTextBox.Text = Content == null ? string.Empty : Content.Value.ToString();
45    }
46
47    protected override void SetEnabledStateOfControls() {
48      base.SetEnabledStateOfControls();
49      valueTextBox.Enabled = Content != null;
50      valueTextBox.ReadOnly = ReadOnly;
51    }
52
53    private void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
54      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
55        label.Focus();  // set focus on label to validate data
56      if (e.KeyCode == Keys.Escape) {
57        valueTextBox.Text = Content.Value.ToString();
58        label.Focus();  // set focus on label to validate data
59      }
60    }
61    private void valueTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
62      DateTime val;
63      if (!DateTime.TryParse(valueTextBox.Text, out val)) {
64        e.Cancel = true;
65        errorProvider.SetError(valueTextBox, "Invalid DateTime Value");
66        valueTextBox.SelectAll();
67      }
68    }
69    private void valueTextBox_Validated(object sender, System.EventArgs e) {
70      if (Content != null) {
71        Content.Value = DateTime.Parse(valueTextBox.Text);
72        errorProvider.SetError(valueTextBox, string.Empty);
73      }
74    }
75  }
76}
Note: See TracBrowser for help on using the repository browser.