Free cookie consent management tool by TermsFeed Policy Generator

source: addons/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/View/ChangeDateTimeCommandView.cs @ 17153

Last change on this file since 17153 was 16994, checked in by gkronber, 6 years ago

#2520 Update plugin dependencies and references for HL.DataImporter for new persistence

File size: 3.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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.ComponentModel;
24using System.Windows.Forms;
25using HeuristicLab.DataImporter.Data;
26
27namespace HeuristicLab.DataImporter.Command.View {
28  public partial class ChangeDateTimeCommandView : HeuristicLab.DataImporter.Data.CommandBase.CommandViewBase {
29    private ChangeDateTimeCommandView() {
30      InitializeComponent();
31      cmbUnit.SelectedIndex = 0;
32      startTime = new DateTime(1900, 1, 1);
33      txtStartTime.Text = startTime.ToString();
34      UpdateCommand();
35    }
36
37    public ChangeDateTimeCommandView(ChangeDateTimeColumnToDoubleColumn command)
38      : this() {
39      this.Command = command;
40    }
41
42    public new ChangeDateTimeColumnToDoubleColumn Command {
43      get { return (ChangeDateTimeColumnToDoubleColumn)base.Command; }
44      set { base.Command = value; this.UpdateCommand(); }
45    }
46
47    private DateTimeSpan frequency;
48    public DateTimeSpan Frequency {
49      get { return this.frequency; }
50    }
51
52    private DateTime startTime;
53    public DateTime StartTime {
54      get { return this.startTime; }
55    }
56
57    private void UpdateCommand() {
58      if(this.Command != null) {
59        this.Command.StartTime = this.startTime;
60        this.Command.Frequency = this.Frequency;
61      }
62    }
63
64    private void txtStartTime_Validating(object sender, CancelEventArgs e) {
65      if (!DateTime.TryParse(txtStartTime.Text, out startTime)) {
66        e.Cancel = true;
67        MessageBox.Show("A date value must be entered (e.g. " + DateTime.Now.ToString() + ").");
68      } else
69        this.UpdateCommand();
70    }
71
72    private void cmbUnit_SelectedIndexChanged(object sender, EventArgs e) {
73      CalculateNewFrequency();
74    }
75
76    private void CalculateNewFrequency() {
77      frequency = new DateTimeSpan();
78      switch (cmbUnit.SelectedIndex) {
79        case 0:
80          frequency.Seconds = 1;
81          break;
82        case 1:
83          frequency.Minutes = 1;
84          break;
85        case 2:
86          frequency.Hours = 1;
87          break;
88        case 3:
89          frequency.Days = 1;
90          break;
91      }
92      this.UpdateCommand();
93    }
94   
95  }
96}
Note: See TracBrowser for help on using the repository browser.