diff --git a/src/Artemis.UI.Shared/Controls/ColorPicker.xaml b/src/Artemis.UI.Shared/Controls/ColorPicker.xaml
index 740f659f0..c28b32576 100644
--- a/src/Artemis.UI.Shared/Controls/ColorPicker.xaml
+++ b/src/Artemis.UI.Shared/Controls/ColorPicker.xaml
@@ -73,7 +73,9 @@
MinWidth="95"
MaxLength="9"
Margin="0"
- HorizontalAlignment="Stretch">
+ HorizontalAlignment="Stretch"
+ FontFamily="Consolas"
+ CharacterCasing="Upper">
@@ -82,7 +84,7 @@
diff --git a/src/Artemis.UI.Shared/Screens/GradientEditor/ColorStopViewModel.cs b/src/Artemis.UI.Shared/Screens/GradientEditor/ColorStopViewModel.cs
index 7629a9899..60080f009 100644
--- a/src/Artemis.UI.Shared/Screens/GradientEditor/ColorStopViewModel.cs
+++ b/src/Artemis.UI.Shared/Screens/GradientEditor/ColorStopViewModel.cs
@@ -32,6 +32,7 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
ColorStop.Position = (float) Math.Round(value / _gradientEditorViewModel.PreviewWidth, 3, MidpointRounding.AwayFromZero);
NotifyOfPropertyChange(nameof(Offset));
NotifyOfPropertyChange(nameof(OffsetPercent));
+ NotifyOfPropertyChange(nameof(OffsetFloat));
}
}
@@ -43,6 +44,20 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
ColorStop.Position = Math.Min(100, Math.Max(0, value)) / 100f;
NotifyOfPropertyChange(nameof(Offset));
NotifyOfPropertyChange(nameof(OffsetPercent));
+ NotifyOfPropertyChange(nameof(OffsetFloat));
+ }
+ }
+
+ // Functionally similar to Offset Percent, but doesn't round on get in order to prevent inconsistencies (and is 0 to 1)
+ public float OffsetFloat
+ {
+ get => ColorStop.Position;
+ set
+ {
+ ColorStop.Position = Math.Min(1, Math.Max(0, value));
+ NotifyOfPropertyChange(nameof(Offset));
+ NotifyOfPropertyChange(nameof(OffsetPercent));
+ NotifyOfPropertyChange(nameof(OffsetFloat));
}
}
diff --git a/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorView.xaml b/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorView.xaml
index 64e084204..ee74e5784 100644
--- a/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorView.xaml
+++ b/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorView.xaml
@@ -12,9 +12,9 @@
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto"
Width="400"
- Height="400"
+ Height="450"
d:DesignHeight="450"
- d:DesignWidth="800"
+ d:DesignWidth="400"
d:DataContext="{d:DesignInstance local:GradientEditorViewModel}">
@@ -40,7 +40,7 @@
-
+
@@ -60,8 +60,83 @@
- Gradient
-
+
+ Gradient
+
+
+
+
+
+
+
+
+
+ Clear Gradient?
+
+
+
+
+
+
+
+
+
@@ -90,8 +165,7 @@
-
- Selected stop
+ Selected stop:
@@ -100,7 +174,7 @@
-
+
-
@@ -122,8 +196,15 @@
Margin="8,0,0,0"
IsEnabled="{Binding HasSelectedColorStopViewModel}"
Command="{s:Action RemoveColorStop}"
- CommandParameter="{Binding SelectedColorStopViewModel}">
- DELETE
+ CommandParameter="{Binding SelectedColorStopViewModel}"
+ ToolTip="Delete Selected Stop">
+
+
+
+
+
+ Delete
+
diff --git a/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorViewModel.cs b/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorViewModel.cs
index 497d81963..cf94d437f 100644
--- a/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorViewModel.cs
+++ b/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorViewModel.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
@@ -27,19 +28,9 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
PropertyChanged += UpdateColorStopViewModels;
ColorGradient.CollectionChanged += ColorGradientOnCollectionChanged;
+ ColorStopViewModels.CollectionChanged += ColorStopViewModelsOnCollectionChanged;
}
- #region Overrides of DialogViewModelBase
-
- ///
- public override void OnDialogClosed(object sender, DialogClosingEventArgs e)
- {
- ColorGradient.CollectionChanged -= ColorGradientOnCollectionChanged;
- base.OnDialogClosed(sender, e);
- }
-
- #endregion
-
public BindableCollection ColorStopViewModels { get; }
public ColorStopViewModel? SelectedColorStopViewModel
@@ -53,6 +44,9 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
}
public bool HasSelectedColorStopViewModel => SelectedColorStopViewModel != null;
+ public bool HasMoreThanOneStop => ColorStopViewModels.Count > 1;
+ private bool popupOpen = false;
+ public bool ClearGradientPopupOpen => popupOpen;
public ColorGradient ColorGradient { get; }
@@ -62,11 +56,20 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
set => SetAndNotify(ref _previewWidth, value);
}
- public ColorGradient Stops
+ public ColorGradient Stops => ColorGradient;
+
+ #region Overrides of DialogViewModelBase
+
+ ///
+ public override void OnDialogClosed(object sender, DialogClosingEventArgs e)
{
- get => ColorGradient;
+ ColorGradient.CollectionChanged -= ColorGradientOnCollectionChanged;
+ ColorStopViewModels.CollectionChanged -= ColorStopViewModelsOnCollectionChanged;
+ base.OnDialogClosed(sender, e);
}
+ #endregion
+
public void AddColorStop(object sender, MouseEventArgs e)
{
Canvas? child = VisualTreeUtilities.FindChild