4 using System.Globalization;
6 using System.Windows.Data;
8 using SiliconStudio.Presentation.MarkupExtensions;
10 namespace SiliconStudio.Presentation.ValueConverters
16 [ValueConversion(typeof(Size), typeof(Size))]
17 public class SumSize : ValueConverterBase<SumSize>
20 public override object Convert(
object value, Type targetType,
object parameter, CultureInfo culture)
24 throw new ArgumentException(
"The value of the ConvertBack method of this converter must be a an instance of the Size structure.");
26 if (!(parameter is Size))
28 throw new ArgumentException(
"The parameter of the ConvertBack method of this converter must be a an instance of the Size structure.");
31 var sizeValue = (Size)value;
32 var sizeParameter = (Size)parameter;
33 var result =
new Size(sizeValue.Width + sizeParameter.Width, sizeValue.Height + sizeParameter.Height);
38 public override object ConvertBack(
object value, Type targetType,
object parameter, CultureInfo culture)
42 throw new ArgumentException(
"The value of the ConvertBack method of this converter must be a an instance of the Size structure.");
44 if (!(parameter is Size))
46 throw new ArgumentException(
"The parameter of the ConvertBack method of this converter must be a an instance of the Size structure.");
48 var sizeValue = (Size)value;
49 var sizeParameter = (Size)parameter;
51 var result =
new Size(sizeValue.Width - sizeParameter.Width, sizeValue.Height - sizeParameter.Height);
override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
This converter will sum a given Size with a Size passed as parameter. You can use the SizeExtension m...