|
7 | 7 |
|
8 | 8 | // For Clipping inside listbox item |
9 | 9 |
|
10 | | -namespace Flow.Launcher.Converters |
| 10 | +namespace Flow.Launcher.Converters; |
| 11 | + |
| 12 | +public class BorderClipConverter : IMultiValueConverter |
11 | 13 | { |
12 | | - public class BorderClipConverter : IMultiValueConverter |
| 14 | + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) |
13 | 15 | { |
14 | | - public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) |
| 16 | + if (values is not [double width, double height, CornerRadius radius]) |
15 | 17 | { |
16 | | - if (values is not [double width, double height, CornerRadius radius]) |
17 | | - { |
18 | | - return DependencyProperty.UnsetValue; |
19 | | - } |
20 | | - |
21 | | - Path myPath = new Path(); |
22 | | - if (width < Double.Epsilon || height < Double.Epsilon) |
23 | | - { |
24 | | - return Geometry.Empty; |
25 | | - } |
26 | | - var radiusHeight = radius.TopLeft; |
27 | | - |
28 | | - // Drawing Round box for bottom round, and rect for top area of listbox. |
29 | | - var corner = new RectangleGeometry(new Rect(0, 0, width, height), radius.TopLeft, radius.TopLeft); |
30 | | - var box = new RectangleGeometry(new Rect(0, 0, width, radiusHeight), 0, 0); |
31 | | - |
32 | | - GeometryGroup myGeometryGroup = new GeometryGroup(); |
33 | | - myGeometryGroup.Children.Add(corner); |
34 | | - myGeometryGroup.Children.Add(box); |
35 | | - |
36 | | - CombinedGeometry c1 = new CombinedGeometry(GeometryCombineMode.Union, corner, box); |
37 | | - myPath.Data = c1; |
38 | | - |
39 | | - myPath.Data.Freeze(); |
40 | | - return myPath.Data; |
| 18 | + return DependencyProperty.UnsetValue; |
41 | 19 | } |
42 | 20 |
|
43 | | - public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) |
| 21 | + Path myPath = new Path(); |
| 22 | + if (width < Double.Epsilon || height < Double.Epsilon) |
44 | 23 | { |
45 | | - throw new NotSupportedException(); |
| 24 | + return Geometry.Empty; |
46 | 25 | } |
| 26 | + var radiusHeight = radius.TopLeft; |
| 27 | + |
| 28 | + // Drawing Round box for bottom round, and rect for top area of listbox. |
| 29 | + var corner = new RectangleGeometry(new Rect(0, 0, width, height), radius.TopLeft, radius.TopLeft); |
| 30 | + var box = new RectangleGeometry(new Rect(0, 0, width, radiusHeight), 0, 0); |
| 31 | + |
| 32 | + GeometryGroup myGeometryGroup = new GeometryGroup(); |
| 33 | + myGeometryGroup.Children.Add(corner); |
| 34 | + myGeometryGroup.Children.Add(box); |
| 35 | + |
| 36 | + CombinedGeometry c1 = new CombinedGeometry(GeometryCombineMode.Union, corner, box); |
| 37 | + myPath.Data = c1; |
| 38 | + |
| 39 | + myPath.Data.Freeze(); |
| 40 | + return myPath.Data; |
47 | 41 | } |
48 | 42 |
|
| 43 | + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) |
| 44 | + { |
| 45 | + throw new NotSupportedException(); |
| 46 | + } |
49 | 47 | } |
0 commit comments