Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
TimeSpanToDouble.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Globalization;
5 
6 namespace SiliconStudio.Presentation.ValueConverters
7 {
8  /// <summary>
9  /// This value converter will convert a TimeSpan to double by using the <see cref="TimeSpan.TotalSeconds"/> property.
10  /// </summary>
11  public class TimeSpanToDouble : ValueConverterBase<TimeSpanToDouble>
12  {
13  /// <inheritdoc/>
14  public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15  {
16  var timeSpan = (TimeSpan)value;
17  return timeSpan.TotalSeconds;
18  }
19 
20  /// <inheritdoc/>
21  public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
22  {
23  double seconds = System.Convert.ToDouble(value);
24  return TimeSpan.FromSeconds(seconds);
25  }
26  }
27 }
override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
This value converter will convert a TimeSpan to double by using the TimeSpan.TotalSeconds property...
override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)