Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/View/ChangeDateTimeCommandView.cs @ 6133

Last change on this file since 6133 was 6133, checked in by gkronber, 13 years ago

#1471: imported generic parts of DataImporter from private code base

File size: 2.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8using HeuristicLab.DataImporter.Data;
9
10namespace HeuristicLab.DataImporter.Command.View {
11  public partial class ChangeDateTimeCommandView : HeuristicLab.DataImporter.Data.CommandBase.CommandViewBase {
12    private ChangeDateTimeCommandView() {
13      InitializeComponent();
14      cmbUnit.SelectedIndex = 0;
15      startTime = new DateTime(1900, 1, 1);
16      txtStartTime.Text = startTime.ToString();
17      UpdateCommand();
18    }
19
20    public ChangeDateTimeCommandView(ChangeDateTimeColumnToDoubleColumn command)
21      : this() {
22      this.Command = command;
23    }
24
25    public new ChangeDateTimeColumnToDoubleColumn Command {
26      get { return (ChangeDateTimeColumnToDoubleColumn)base.Command; }
27      set { base.Command = value; this.UpdateCommand(); }
28    }
29
30    private DateTimeSpan frequency;
31    public DateTimeSpan Frequency {
32      get { return this.frequency; }
33    }
34
35    private DateTime startTime;
36    public DateTime StartTime {
37      get { return this.startTime; }
38    }
39
40    private void UpdateCommand() {
41      if(this.Command != null) {
42        this.Command.StartTime = this.startTime;
43        this.Command.Frequency = this.Frequency;
44      }
45    }
46
47    private void txtStartTime_Validating(object sender, CancelEventArgs e) {
48      if (!DateTime.TryParse(txtStartTime.Text, out startTime)) {
49        e.Cancel = true;
50        MessageBox.Show("A date value must be entered (e.g. " + DateTime.Now.ToString() + ").");
51      } else
52        this.UpdateCommand();
53    }
54
55    private void cmbUnit_SelectedIndexChanged(object sender, EventArgs e) {
56      CalculateNewFrequency();
57    }
58
59    private void CalculateNewFrequency() {
60      frequency = new DateTimeSpan();
61      switch (cmbUnit.SelectedIndex) {
62        case 0:
63          frequency.Seconds = 1;
64          break;
65        case 1:
66          frequency.Minutes = 1;
67          break;
68        case 2:
69          frequency.Hours = 1;
70          break;
71        case 3:
72          frequency.Days = 1;
73          break;
74      }
75      this.UpdateCommand();
76    }
77   
78  }
79}
Note: See TracBrowser for help on using the repository browser.