Beispiel #1
0
        public void SetValue(IntervalValue value)
        {
            if (value.Unit == IntervalUnit.Milliseconds && !this.ShowMilliseconds)
            {
                throw new InvalidOperationException("In order to display a value with the Milliseconds unit, ShowMilliseconds must be set to true.");
            }

            cbIntervalUnit.SelectedItem = value.Unit;
            switch (value.Unit)
            {
            case IntervalUnit.Milliseconds:
                nudInterval.Value = (int)value.Value.TotalMilliseconds;
                break;

            case IntervalUnit.Seconds:
                nudInterval.Value = (int)value.Value.TotalSeconds;
                break;

            case IntervalUnit.Minutes:
                nudInterval.Value = (int)value.Value.TotalMinutes;
                break;

            case IntervalUnit.Hours:
                nudInterval.Value = (int)value.Value.TotalHours;
                break;
            }
            m_Value = value;
        }
Beispiel #2
0
        public static IntervalValue FromTimeSpan(TimeSpan intervalTS)
        {
            IntervalValue intervalValue = new IntervalValue();

            intervalValue.Value = intervalTS;

            if (intervalTS.TotalHours % 1 == 0)
            {
                intervalValue.Unit = IntervalUnit.Hours;
            }
            else if (intervalTS.TotalMinutes % 1 == 0)
            {
                intervalValue.Unit = IntervalUnit.Minutes;
            }
            else if (intervalTS.TotalSeconds % 1 == 0)
            {
                intervalValue.Unit = IntervalUnit.Seconds;
            }
            else
            {
                intervalValue.Unit = IntervalUnit.Milliseconds;
            }

            return(intervalValue);
        }
Beispiel #3
0
 public void SetValue(TimeSpan value)
 {
     SetValue(IntervalValue.FromTimeSpan(value));
 }