mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
UI - Started work on the gradient picker service now that my POC works
This commit is contained in:
parent
9b47e96dc1
commit
d96c8a1879
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@ -6,6 +7,7 @@ using System.Windows.Input;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.UI.Shared.Annotations;
|
||||
using Artemis.UI.Shared.Screens.GradientEditor;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
@ -14,6 +16,20 @@ namespace Artemis.UI.Shared
|
||||
/// </summary>
|
||||
public partial class GradientPicker : UserControl, INotifyPropertyChanged
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by the gradient picker to load saved gradients, do not touch or it'll just throw an exception
|
||||
/// </summary>
|
||||
public static IGradientPickerService GradientPickerService
|
||||
{
|
||||
private get => _gradientPickerService;
|
||||
set
|
||||
{
|
||||
if (_gradientPickerService != null)
|
||||
throw new AccessViolationException("This is not for you to touch");
|
||||
_gradientPickerService = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ColorGradientProperty = DependencyProperty.Register(nameof(ColorGradient), typeof(ColorGradient), typeof(GradientPicker),
|
||||
new FrameworkPropertyMetadata(default(ColorGradient), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, ColorGradientPropertyChangedCallback));
|
||||
|
||||
@ -24,6 +40,8 @@ namespace Artemis.UI.Shared
|
||||
typeof(RoutedPropertyChangedEventHandler<ColorGradient>),
|
||||
typeof(GradientPicker));
|
||||
|
||||
private static IGradientPickerService _gradientPickerService;
|
||||
|
||||
private bool _inCallback;
|
||||
|
||||
public GradientPicker()
|
||||
|
||||
8
src/Artemis.UI.Shared/Services/GradientPickerService.cs
Normal file
8
src/Artemis.UI.Shared/Services/GradientPickerService.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
public class GradientPickerService : IGradientPickerService
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
namespace Artemis.UI.Shared.Services.Interfaces
|
||||
{
|
||||
public interface IGradientPickerService : IArtemisSharedUIService
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,10 @@
|
||||
using System.Windows;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Core.Utilities;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Screens.Splash;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Ninject;
|
||||
using Stylet;
|
||||
|
||||
@ -11,9 +12,10 @@ namespace Artemis.UI.Screens
|
||||
{
|
||||
public class TrayViewModel : Screen
|
||||
{
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly IKernel _kernel;
|
||||
private readonly IWindowManager _windowManager;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private bool _setGradientPickerService;
|
||||
private SplashViewModel _splashViewModel;
|
||||
|
||||
public TrayViewModel(IKernel kernel, IWindowManager windowManager, IEventAggregator eventAggregator, ICoreService coreService, ISettingsService settingsService)
|
||||
@ -39,6 +41,14 @@ namespace Artemis.UI.Screens
|
||||
if (!CanShowRootViewModel)
|
||||
return;
|
||||
|
||||
// The gradient picker must have a reference to this service to be able to load saved gradients.
|
||||
// To avoid wasting resources, only set the service once and not until showing the UI.
|
||||
if (!_setGradientPickerService)
|
||||
{
|
||||
GradientPicker.GradientPickerService = _kernel.Get<IGradientPickerService>();
|
||||
_setGradientPickerService = true;
|
||||
}
|
||||
|
||||
CanShowRootViewModel = false;
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user