@@ -10,25 +10,35 @@ internal class FloatingHintOffsetCalculationConverter : IMultiValueConverter
10
10
{
11
11
public object Convert ( object [ ] values , Type targetType , object ? parameter , CultureInfo culture )
12
12
{
13
- var hintHeight = ( ( FontFamily ) values [ 0 ] ) . LineSpacing
14
- * ( double ) values [ 1 ] ; // fontSize
15
- var floatingHintHeight = hintHeight
16
- * ( double ) values [ 2 ] ; // floatingScale
13
+ var fontFamily = ( FontFamily ) values [ 0 ] ;
14
+ double fontSize = ( double ) values [ 1 ] ;
15
+ double floatingScale = ( double ) values [ 2 ] ;
17
16
18
- var offset = ( values . Length > 3 ? values [ 3 ] : null ) switch
17
+ double hintHeight = fontFamily . LineSpacing * fontSize ;
18
+ double floatingHintHeight = hintHeight * floatingScale ;
19
+
20
+ double offset = ( values . Length > 3 ? values [ 3 ] : null ) switch
19
21
{
20
22
Thickness padding => floatingHintHeight / 2 + padding . Top ,
21
23
double parentHeight => ( parentHeight - hintHeight + floatingHintHeight ) / 2 ,
22
24
_ => floatingHintHeight
23
25
} ;
24
26
25
- if ( targetType == typeof ( Point ) ) // offset
27
+ if ( IsType < Point > ( targetType ) )
28
+ {
26
29
return new Point ( 0 , - offset ) ;
27
- if ( targetType == typeof ( Thickness ) ) // margin
30
+ }
31
+
32
+ if ( IsType < Thickness > ( targetType ) )
33
+ {
28
34
return new Thickness ( 0 , offset , 0 , 0 ) ;
35
+ }
36
+
29
37
throw new NotSupportedException ( targetType . FullName ) ;
30
38
}
31
39
32
40
public object [ ] ConvertBack ( object value , Type [ ] targetTypes , object parameter , CultureInfo culture ) => throw new NotSupportedException ( ) ;
41
+
42
+ private bool IsType < T > ( Type type ) => type == typeof ( T ) ;
33
43
}
34
44
}
0 commit comments