3
3
4
4
namespace Microsoft . Maui
5
5
{
6
- // TODO : Need to impl
7
6
public static class StrokeExtensions
8
7
{
9
8
public static void UpdateStrokeShape ( this EvasObject nativeView , IBorder border )
10
9
{
11
10
var borderShape = border . Shape ;
12
- //MauiDrawable? background = nativeView.Background as MauiDrawable;
13
-
14
- //if (background == null && borderShape == null)
15
- // return;
11
+ var canvas = nativeView as IWrapperViewCanvas ;
12
+ if ( canvas == null && borderShape == null )
13
+ return ;
16
14
17
15
nativeView . UpdateMauiDrawable ( border ) ;
18
16
}
19
17
20
18
public static void UpdateStroke ( this EvasObject nativeView , IBorder border )
21
19
{
22
20
var stroke = border . Stroke ;
23
- //MauiDrawable? background = nativeView.Background as MauiDrawable;
24
-
25
- //if (background == null && stroke.IsNullOrEmpty())
26
- // return;
21
+ var canvas = nativeView as IWrapperViewCanvas ;
22
+ if ( canvas == null && stroke . IsNullOrEmpty ( ) )
23
+ return ;
27
24
28
25
nativeView . UpdateMauiDrawable ( border ) ;
29
26
}
30
27
31
28
public static void UpdateStrokeThickness ( this EvasObject nativeView , IBorder border )
32
29
{
33
- //MauiDrawable? background = nativeView.Background as MauiDrawable;
34
- //bool hasBorder = border.Shape != null && border.Stroke != null;
35
-
36
- //if (background == null && !hasBorder)
37
- // return;
30
+ var canvas = nativeView as IWrapperViewCanvas ;
31
+ bool hasBorder = border . Shape != null && border . Stroke != null ;
32
+ if ( canvas == null && ! hasBorder )
33
+ return ;
38
34
39
35
nativeView . UpdateMauiDrawable ( border ) ;
40
36
}
41
37
42
38
public static void UpdateStrokeDashPattern ( this EvasObject nativeView , IBorder border )
43
39
{
44
40
var strokeDashPattern = border . StrokeDashPattern ;
45
- //MauiDrawable? background = nativeView.Background as MauiDrawable;
46
-
47
- //bool hasBorder = border.Shape != null && border.Stroke != null;
48
-
49
- //if (background == null && !hasBorder && (strokeDashPattern == null || strokeDashPattern.Length == 0))
50
- // return;
41
+ var canvas = nativeView as IWrapperViewCanvas ;
42
+ bool hasBorder = border . Shape != null && border . Stroke != null ;
43
+ if ( canvas == null && ! hasBorder && ( strokeDashPattern == null || strokeDashPattern . Length == 0 ) )
44
+ return ;
51
45
52
46
nativeView . UpdateMauiDrawable ( border ) ;
53
47
}
54
48
55
49
public static void UpdateStrokeDashOffset ( this EvasObject nativeView , IBorder border )
56
50
{
57
- //MauiDrawable? background = nativeView.Background as MauiDrawable;
58
-
59
- //bool hasBorder = border.Shape != null && border.Stroke != null;
60
-
61
- //if (background == null && !hasBorder)
62
- // return;
51
+ var canvas = nativeView as IWrapperViewCanvas ;
52
+ bool hasBorder = border . Shape != null && border . Stroke != null ;
53
+ if ( canvas == null && ! hasBorder )
54
+ return ;
63
55
64
56
nativeView . UpdateMauiDrawable ( border ) ;
65
57
}
66
58
67
59
public static void UpdateStrokeMiterLimit ( this EvasObject nativeView , IBorder border )
68
60
{
69
- //MauiDrawable? background = nativeView.Background as MauiDrawable;
70
-
71
- //bool hasBorder = border.Shape != null && border.Stroke != null;
72
-
73
- //if (background == null && !hasBorder)
74
- // return;
61
+ var canvas = nativeView as IWrapperViewCanvas ;
62
+ bool hasBorder = border . Shape != null && border . Stroke != null ;
63
+ if ( canvas == null && ! hasBorder )
64
+ return ;
75
65
76
66
nativeView . UpdateMauiDrawable ( border ) ;
77
67
}
78
68
79
69
public static void UpdateStrokeLineCap ( this EvasObject nativeView , IBorder border )
80
70
{
81
- //MauiDrawable? background = nativeView.Background as MauiDrawable;
82
- //bool hasBorder = border.Shape != null && border.Stroke != null;
83
-
84
- //if (background == null && !hasBorder)
85
- // return;
71
+ var canvas = nativeView as IWrapperViewCanvas ;
72
+ bool hasBorder = border . Shape != null && border . Stroke != null ;
73
+ if ( canvas == null && ! hasBorder )
74
+ return ;
86
75
87
76
nativeView . UpdateMauiDrawable ( border ) ;
88
77
}
89
78
90
79
public static void UpdateStrokeLineJoin ( this EvasObject nativeView , IBorder border )
91
80
{
92
- //MauiDrawable? background = nativeView.Background as MauiDrawable;
93
- //bool hasBorder = border.Shape != null && border.Stroke != null;
94
-
95
- //if (background == null && !hasBorder)
96
- // return;
81
+ var canvas = nativeView as IWrapperViewCanvas ;
82
+ bool hasBorder = border . Shape != null && border . Stroke != null ;
83
+ if ( canvas == null && ! hasBorder )
84
+ return ;
97
85
98
86
nativeView . UpdateMauiDrawable ( border ) ;
99
87
}
100
88
101
89
internal static void UpdateMauiDrawable ( this EvasObject nativeView , IBorder border )
102
90
{
103
91
bool hasBorder = border . Shape != null && border . Stroke != null ;
104
-
105
92
if ( ! hasBorder )
106
93
return ;
107
94
108
- //MauiDrawable? mauiDrawable = nativeView.Background as MauiDrawable;
109
-
110
- //if (mauiDrawable == null)
111
- //{
112
- // mauiDrawable = new MauiDrawable(nativeView.Context);
113
-
114
- // nativeView.Background = mauiDrawable;
115
- //}
116
-
117
- //mauiDrawable.SetBackground(border.Background);
118
- //mauiDrawable.SetBorderBrush(border.Stroke);
119
- //mauiDrawable.SetBorderWidth(border.StrokeThickness);
120
- //mauiDrawable.SetBorderDash(border.StrokeDashPattern, border.StrokeDashOffset);
121
- //mauiDrawable.SetBorderMiterLimit(border.StrokeMiterLimit);
122
- //mauiDrawable.SetBorderLineJoin(border.StrokeLineJoin);
123
- //mauiDrawable.SetBorderLineCap(border.StrokeLineCap);
124
- //mauiDrawable.SetBorderShape(border.Shape);
95
+ if ( nativeView is IWrapperViewCanvas canvas )
96
+ {
97
+ canvas . Drawables . BorderDrawable = border . Background ? . ToDrawable ( border ) ?? null ;
98
+ }
125
99
}
126
100
}
127
101
}
0 commit comments