@@ -42,7 +42,7 @@ protected IndicatorAdornerBase(FrameworkElement adornedElement, AdornerPosition
4242
4343 protected enum AdornerPosition
4444 {
45- UpperLeft = 0 ,
45+ UpperLeft ,
4646 UpperRight ,
4747 LowerLeft ,
4848 LowerRight ,
@@ -58,8 +58,8 @@ public virtual void Dispose()
5858
5959 public override GeneralTransform GetDesiredTransform ( GeneralTransform transform )
6060 {
61- Rect bounds = this . GetAdornedElementBounds ( ) ;
62- if ( bounds . IsEmpty )
61+ Size size = this . AdornedElement . RenderSize ;
62+ if ( size . IsEmpty )
6363 {
6464 return base . GetDesiredTransform ( transform ) ;
6565 }
@@ -68,7 +68,7 @@ public override GeneralTransform GetDesiredTransform(GeneralTransform transform)
6868 Children =
6969 {
7070 base . GetDesiredTransform ( transform ) ,
71- new ScaleTransform ( 0.5 , 0.5 , bounds . Width * this . _widthMultiple , bounds . Height * this . _heightMultiple ) ,
71+ new ScaleTransform ( 0.5 , 0.5 , size . Width * this . _widthMultiple , size . Height * this . _heightMultiple ) ,
7272 }
7373 } ;
7474 }
@@ -114,29 +114,21 @@ protected override Size MeasureOverride(Size constraint)
114114
115115 protected override void OnRender ( DrawingContext drawingContext )
116116 {
117- Rect bounds = this . GetAdornedElementBounds ( ) ;
118- if ( bounds . IsEmpty )
117+ Size size = this . AdornedElement . RenderSize ;
118+ if ( size . IsEmpty )
119119 {
120120 return ;
121121 }
122- RenderTargetBitmap bitmap = new ( ( int ) bounds . Width , ( int ) bounds . Height , 96 , 96 , PixelFormats . Pbgra32 ) ;
122+ RenderTargetBitmap bitmap = new ( ( int ) size . Width , ( int ) size . Height , 96 , 96 , PixelFormats . Pbgra32 ) ;
123123 DrawingVisual visual = new ( ) ;
124124 using ( DrawingContext context = visual . RenderOpen ( ) )
125125 {
126126 VisualBrush brush = new ( this . _contentPresenter ) ;
127- context . DrawRectangle ( brush , null , new ( default , bounds . Size ) ) ;
127+ context . DrawRectangle ( brush , null , new ( size ) ) ;
128128 }
129129 bitmap . Render ( visual ) ;
130130 bitmap . Freeze ( ) ;
131- drawingContext . DrawImage ( bitmap , new ( default , bounds . Size ) ) ;
132- }
133-
134- private Rect GetAdornedElementBounds ( )
135- {
136- Rect bounds = VisualTreeHelper . GetDescendantBounds ( this . AdornedElement ) ;
137- return bounds . IsEmpty && ( this . AdornedElement . ActualHeight > 0d || this . AdornedElement . ActualWidth > 0d )
138- ? new ( new ( this . AdornedElement . ActualWidth , this . AdornedElement . ActualHeight ) )
139- : bounds ;
131+ drawingContext . DrawImage ( bitmap , new ( size ) ) ;
140132 }
141133
142134 private static class AdornerAttacher < TAdorner >
0 commit comments