#region License Information /* HeuristicLab * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using HeuristicLab.DataImporter.Data; namespace HeuristicLab.DataImporter.Command.View { public partial class ChangeDateTimeCommandView : HeuristicLab.DataImporter.Data.CommandBase.CommandViewBase { private ChangeDateTimeCommandView() { InitializeComponent(); cmbUnit.SelectedIndex = 0; startTime = new DateTime(1900, 1, 1); txtStartTime.Text = startTime.ToString(); UpdateCommand(); } public ChangeDateTimeCommandView(ChangeDateTimeColumnToDoubleColumn command) : this() { this.Command = command; } public new ChangeDateTimeColumnToDoubleColumn Command { get { return (ChangeDateTimeColumnToDoubleColumn)base.Command; } set { base.Command = value; this.UpdateCommand(); } } private DateTimeSpan frequency; public DateTimeSpan Frequency { get { return this.frequency; } } private DateTime startTime; public DateTime StartTime { get { return this.startTime; } } private void UpdateCommand() { if(this.Command != null) { this.Command.StartTime = this.startTime; this.Command.Frequency = this.Frequency; } } private void txtStartTime_Validating(object sender, CancelEventArgs e) { if (!DateTime.TryParse(txtStartTime.Text, out startTime)) { e.Cancel = true; MessageBox.Show("A date value must be entered (e.g. " + DateTime.Now.ToString() + ")."); } else this.UpdateCommand(); } private void cmbUnit_SelectedIndexChanged(object sender, EventArgs e) { CalculateNewFrequency(); } private void CalculateNewFrequency() { frequency = new DateTimeSpan(); switch (cmbUnit.SelectedIndex) { case 0: frequency.Seconds = 1; break; case 1: frequency.Minutes = 1; break; case 2: frequency.Hours = 1; break; case 3: frequency.Days = 1; break; } this.UpdateCommand(); } } }