Skip to content

Commit bb1b741

Browse files
committed
fixes in brush editor
1 parent d08f616 commit bb1b741

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

Src/Xceed.Wpf.Toolkit/BrushPicker/Implementation/ColorBox.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -477,17 +477,17 @@ static void BrushChanged(DependencyObject property, DependencyPropertyChangedEve
477477
}
478478
else if (brush is SolidColorBrush)
479479
{
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)
482483
{
483484
c.BrushType = BrushTypes.Predefined;
484-
//c.Color = (brush as SolidColorBrush).Color;
485485
}
486486
else
487487
{
488488
c.BrushType = BrushTypes.Solid;
489-
c.Color = (brush as SolidColorBrush).Color;
490489
}
490+
c.Color = (brush as SolidColorBrush).Color;
491491
}
492492
else if (brush is LinearGradientBrush)
493493
{
@@ -523,7 +523,7 @@ static void BrushChanged(DependencyObject property, DependencyPropertyChangedEve
523523

524524
c._BrushTypeSetInternally = false;
525525
}
526-
}
526+
}
527527

528528
public Color Color
529529
{
@@ -572,7 +572,7 @@ public static void OnColorChanged(DependencyObject o, DependencyPropertyChangedE
572572

573573
c._RGBSetInternally = false;
574574
}
575-
575+
576576
c.RaiseColorChangedEvent((Color)e.NewValue);
577577
}
578578
}
@@ -781,8 +781,10 @@ internal void SetBrush()
781781

782782
switch (BrushType)
783783
{
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;
786788

787789
case BrushTypes.Solid:
788790
Brush = new SolidColorBrush(this.Color);
@@ -800,7 +802,7 @@ internal void SetBrush()
800802
brush.MappingMode = this.MappingMode;
801803
brush.SpreadMethod = this.SpreadMethod;
802804
Brush = brush;
803-
805+
804806
break;
805807

806808
case BrushTypes.Radial:
@@ -821,7 +823,7 @@ internal void SetBrush()
821823
break;
822824
}
823825

824-
if (this.BrushType != BrushTypes.None)
826+
if (this.BrushType != BrushTypes.None && this.BrushType != BrushTypes.Predefined)
825827
{
826828
this.Brush.Opacity = opacity; // retain old opacity
827829
if (tempTG != null)

Src/Xceed.Wpf.Toolkit/BrushPicker/Themes/Generic.xaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,17 @@
210210
</ControlTemplate>
211211
</Setter.Value>
212212
</Setter>
213-
</Style>
213+
<Setter Property="IsHitTestVisible" Value="True"/>
214+
<Style.Triggers>
215+
<DataTrigger Binding="{Binding ElementName=Popup, Path=IsOpen}" Value="True">
216+
<Setter Property="IsHitTestVisible" Value="False"/>
217+
</DataTrigger>
218+
</Style.Triggers>
219+
</Style>
214220
</ToggleButton.Style>
215221
</ToggleButton>
216222

217-
<Popup IsOpen="{Binding ElementName=PART_OpenPopup,Path=IsChecked}" StaysOpen="False" AllowsTransparency="True"
223+
<Popup Name="Popup" IsOpen="{Binding ElementName=PART_OpenPopup, Path=IsChecked, Mode=TwoWay}" StaysOpen="False" AllowsTransparency="True"
218224
Width="{Binding ActualWidth, ElementName=PART_Root}"
219225
MinWidth="250"
220226
HorizontalOffset="-1">

0 commit comments

Comments
 (0)