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

@@ -1,23 +1,29 @@
using System.ComponentModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Artemis.Core.Models.Profile;
using Artemis.UI.Shared.Services.Dialog;
using Artemis.UI.Shared.Utilities;
using SkiaSharp;
using Stylet;
namespace Artemis.UI.Shared.Screens.GradientEditor
{
public class GradientEditorViewModel : Screen
public class GradientEditorViewModel : DialogViewModelBase
{
private ColorStopViewModel _selectedColorStopViewModel;
private readonly List<ColorGradientStop> _originalStops;
public GradientEditorViewModel(ColorGradient colorGradient)
{
ColorGradient = colorGradient;
ColorStopViewModels = new BindableCollection<ColorStopViewModel>();
_originalStops = ColorGradient.Stops.Select(s => new ColorGradientStop(s.Color, s.Position)).ToList();
foreach (var colorStop in ColorGradient.Stops.OrderBy(s => s.Position))
ColorStopViewModels.Add(new ColorStopViewModel(this, colorStop));
}
@@ -37,7 +43,8 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
public bool HasSelectedColorStopViewModel => SelectedColorStopViewModel != null;
public ColorGradient ColorGradient { get; }
public double PreviewWidth => 437.5;
// TODO: Find the width out from view
public double PreviewWidth => 408;
public void AddColorStop(object sender, MouseEventArgs e)
{
@@ -75,5 +82,22 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
foreach (var stopViewModel in ColorStopViewModels)
stopViewModel.IsSelected = stopViewModel == SelectedColorStopViewModel;
}
public void Confirm()
{
if (!Session.IsEnded)
Session.Close(true);
}
public void Cancel()
{
// Restore the saved state
ColorGradient.Stops.Clear();
ColorGradient.Stops.AddRange(_originalStops);
ColorGradient.OnColorValuesUpdated();
if (!Session.IsEnded)
Session.Close(false);
}
}
}