Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
MaxNum.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 
4 using System;
5 using System.Globalization;
6 
7 namespace SiliconStudio.Presentation.ValueConverters
8 {
9  /// <summary>
10  /// This converter will return the maximal result between the converter value and the converter parameter.
11  /// </summary>
12  public class MaxNum : OneWayValueConverter<MaxNum>
13  {
14  /// <inheritdoc/>
15  public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16  {
17  var doubleValue = (double)System.Convert.ChangeType(value ?? 0, typeof(double));
18  var doubleParameter = (double)System.Convert.ChangeType(parameter ?? 0, typeof(double));
19  return System.Convert.ChangeType(Math.Max(doubleValue, doubleParameter), value != null ? value.GetType() : targetType);
20  }
21  }
22 }
This converter will return the maximal result between the converter value and the converter parameter...
Definition: MaxNum.cs:12
override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
Definition: MaxNum.cs:15