Color brush - Fixed gradient picker not appearing

Gradient picker - Use dialog instead of a popup window
This commit is contained in:
SpoinkyNL committed 2020-04-17 23:01:42 +02:00
1 parent e863652b08
commit 45baa6ab85
21 files changed
+206 -101

No files matched your search

@@ -21,14 +21,28 @@ namespace Artemis.UI.Shared.Controls
private readonly DrawingGroup _backingStore;
private readonly List<DeviceVisualizerLed> _deviceVisualizerLeds;
private BitmapImage _deviceImage;
private bool _subscribed;
public DeviceVisualizer()
{
_backingStore = new DrawingGroup();
_deviceVisualizerLeds = new List<DeviceVisualizerLed>();
RGBSurface.Instance.Updated += RgbSurfaceOnUpdated;
Unloaded += (sender, args) => Dispose();
Loaded += (sender, args) => SubscribeToUpdate(true);
Unloaded += (sender, args) => SubscribeToUpdate(false);
}
private void SubscribeToUpdate(bool subscribe)
{
if (_subscribed == subscribe)
return;
if (subscribe)
RGBSurface.Instance.Updated += RgbSurfaceOnUpdated;
else
RGBSurface.Instance.Updated -= RgbSurfaceOnUpdated;
_subscribed = subscribe;
}
public ArtemisDevice Device
@@ -131,7 +145,7 @@ namespace Artemis.UI.Shared.Controls
bitmapBrush.Freeze();
_backingStore.OpacityMask = bitmapBrush;
}
private void RgbSurfaceOnUpdated(UpdatedEventArgs e)
{
Dispatcher.Invoke(() =>
@@ -46,6 +46,15 @@ namespace Artemis.UI.Shared.Controls
set => SetValue(ColorGradientProperty, value);
}
/// <summary>
/// Gets or sets the currently selected color gradient
/// </summary>
public string DialogHost
{
get => (string) GetValue(DialogHostProperty);
set => SetValue(DialogHostProperty, value);
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
@@ -67,7 +76,7 @@ namespace Artemis.UI.Shared.Controls
private void UIElement_OnMouseUp(object sender, MouseButtonEventArgs e)
{
GradientPickerService.ShowGradientPicker(ColorGradient);
GradientPickerService.ShowGradientPicker(ColorGradient, DialogHost);
}
#region Static WPF fields
@@ -75,6 +84,9 @@ namespace Artemis.UI.Shared.Controls
public static readonly DependencyProperty ColorGradientProperty = DependencyProperty.Register(nameof(ColorGradient), typeof(ColorGradient), typeof(GradientPicker),
new FrameworkPropertyMetadata(default(ColorGradient), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, ColorGradientPropertyChangedCallback));
public static readonly DependencyProperty DialogHostProperty = DependencyProperty.Register(nameof(DialogHost), typeof(string), typeof(GradientPicker),
new FrameworkPropertyMetadata(default(string)));
public static readonly RoutedEvent ColorGradientChangedEvent =
EventManager.RegisterRoutedEvent(nameof(ColorGradient), RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler<ColorGradient>), typeof(GradientPicker));