@@ -477,17 +477,17 @@ static void BrushChanged(DependencyObject property, DependencyPropertyChangedEve
477
477
}
478
478
else if ( brush is SolidColorBrush )
479
479
{
480
- var fbrush = _wpfBrushTypes . First ( x => x . Brush == brush ) ;
481
- if ( fbrush == null )
480
+ var sbrush = ( SolidColorBrush ) brush ;
481
+ var fbrush = _wpfBrushTypes . FirstOrDefault ( x => ( ( SolidColorBrush ) x . Brush ) . Color == sbrush . Color ) ;
482
+ if ( fbrush != null )
482
483
{
483
484
c . BrushType = BrushTypes . Predefined ;
484
- //c.Color = (brush as SolidColorBrush).Color;
485
485
}
486
486
else
487
487
{
488
488
c . BrushType = BrushTypes . Solid ;
489
- c . Color = ( brush as SolidColorBrush ) . Color ;
490
489
}
490
+ c . Color = ( brush as SolidColorBrush ) . Color ;
491
491
}
492
492
else if ( brush is LinearGradientBrush )
493
493
{
@@ -523,7 +523,7 @@ static void BrushChanged(DependencyObject property, DependencyPropertyChangedEve
523
523
524
524
c . _BrushTypeSetInternally = false ;
525
525
}
526
- }
526
+ }
527
527
528
528
public Color Color
529
529
{
@@ -572,7 +572,7 @@ public static void OnColorChanged(DependencyObject o, DependencyPropertyChangedE
572
572
573
573
c . _RGBSetInternally = false ;
574
574
}
575
-
575
+
576
576
c . RaiseColorChangedEvent ( ( Color ) e . NewValue ) ;
577
577
}
578
578
}
@@ -781,8 +781,10 @@ internal void SetBrush()
781
781
782
782
switch ( BrushType )
783
783
{
784
- case BrushTypes . Predefined : return ;
785
- case BrushTypes . None : Brush = null ; break ;
784
+ case BrushTypes . Predefined :
785
+ break ;
786
+ case BrushTypes . None : Brush = null ;
787
+ break ;
786
788
787
789
case BrushTypes . Solid :
788
790
Brush = new SolidColorBrush ( this . Color ) ;
@@ -800,7 +802,7 @@ internal void SetBrush()
800
802
brush . MappingMode = this . MappingMode ;
801
803
brush . SpreadMethod = this . SpreadMethod ;
802
804
Brush = brush ;
803
-
805
+
804
806
break ;
805
807
806
808
case BrushTypes . Radial :
@@ -821,7 +823,7 @@ internal void SetBrush()
821
823
break ;
822
824
}
823
825
824
- if ( this . BrushType != BrushTypes . None )
826
+ if ( this . BrushType != BrushTypes . None && this . BrushType != BrushTypes . Predefined )
825
827
{
826
828
this . Brush . Opacity = opacity ; // retain old opacity
827
829
if ( tempTG != null )
0 commit comments