|
7 | 7 | using System.Windows.Data; |
8 | 8 | using System.Windows.Media; |
9 | 9 |
|
10 | | -namespace MaterialDesignThemes.Wpf.Converters |
| 10 | +namespace MaterialDesignThemes.Wpf.Converters; |
| 11 | + |
| 12 | +public class EllipseClipConverter : IMultiValueConverter |
11 | 13 | { |
12 | | - public class EllipseClipConverter : IMultiValueConverter |
13 | | - { |
14 | | - public static readonly EllipseClipConverter Instance = new(); |
| 14 | + public static readonly EllipseClipConverter Instance = new(); |
15 | 15 |
|
16 | | - public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) |
| 16 | + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) |
| 17 | + { |
| 18 | + if (values is [double width, double height, ..]) |
17 | 19 | { |
18 | | - if (values is [double width, double height, ..]) |
| 20 | + if (width < 1.0 || height < 1.0) |
19 | 21 | { |
20 | | - if (width < 1.0 || height < 1.0) |
21 | | - { |
22 | | - return Geometry.Empty; |
23 | | - } |
24 | | - |
25 | | - Point center = new Point(width / 2.0, height / 2.0); |
26 | | - double radiusX = width / 2.0; |
27 | | - double radiusY = height / 2.0; |
| 22 | + return Geometry.Empty; |
| 23 | + } |
28 | 24 |
|
29 | | - EllipseGeometry geometry = new EllipseGeometry(center, radiusX, radiusY); |
30 | | - geometry.Freeze(); |
| 25 | + Point center = new Point(width / 2.0, height / 2.0); |
| 26 | + double radiusX = width / 2.0; |
| 27 | + double radiusY = height / 2.0; |
31 | 28 |
|
32 | | - return geometry; |
33 | | - } |
| 29 | + EllipseGeometry geometry = new EllipseGeometry(center, radiusX, radiusY); |
| 30 | + geometry.Freeze(); |
34 | 31 |
|
35 | | - return DependencyProperty.UnsetValue; |
| 32 | + return geometry; |
36 | 33 | } |
37 | 34 |
|
38 | | - public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) |
39 | | - => throw new NotImplementedException(); |
| 35 | + return DependencyProperty.UnsetValue; |
40 | 36 | } |
| 37 | + |
| 38 | + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) |
| 39 | + => throw new NotImplementedException(); |
41 | 40 | } |
0 commit comments