1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2026-01-01 10:13:30 +00:00

Meta - Code cleanup

This commit is contained in:
SpoinkyNL 2020-06-13 22:27:51 +02:00
parent b2ab142dbd
commit 58a964b872
105 changed files with 3097 additions and 2624 deletions

View File

@ -164,7 +164,7 @@ namespace Artemis.Core.Models.Profile
LayerEntity.LayerEffects.Clear(); LayerEntity.LayerEffects.Clear();
foreach (var layerEffect in LayerEffects) foreach (var layerEffect in LayerEffects)
{ {
var layerEffectEntity = new LayerEffectEntity() var layerEffectEntity = new LayerEffectEntity
{ {
PluginGuid = layerEffect.PluginInfo.Guid, PluginGuid = layerEffect.PluginInfo.Guid,
EffectType = layerEffect.GetType().Name, EffectType = layerEffect.GetType().Name,

View File

@ -10,8 +10,8 @@ namespace Artemis.Core.Models.Profile.LayerProperties
/// </summary> /// </summary>
public abstract class BaseLayerProperty public abstract class BaseLayerProperty
{ {
private bool _keyframesEnabled;
private bool _isHidden; private bool _isHidden;
private bool _keyframesEnabled;
internal BaseLayerProperty() internal BaseLayerProperty()
{ {
@ -85,6 +85,8 @@ namespace Artemis.Core.Models.Profile.LayerProperties
internal PropertyEntity PropertyEntity { get; set; } internal PropertyEntity PropertyEntity { get; set; }
internal LayerPropertyGroup LayerPropertyGroup { get; set; } internal LayerPropertyGroup LayerPropertyGroup { get; set; }
public abstract void ApplyDefaultValue();
/// <summary> /// <summary>
/// Applies the provided property entity to the layer property by deserializing the JSON base value and keyframe values /// Applies the provided property entity to the layer property by deserializing the JSON base value and keyframe values
@ -163,9 +165,5 @@ namespace Artemis.Core.Models.Profile.LayerProperties
} }
#endregion #endregion
public abstract void ApplyDefaultValue();
} }
} }

View File

@ -56,7 +56,8 @@ namespace Artemis.Core.Models.Profile.LayerProperties
} }
/// <summary> /// <summary>
/// Gets or sets the default value of this layer property. If set, this value is automatically applied if the property has no /// Gets or sets the default value of this layer property. If set, this value is automatically applied if the property
/// has no
/// value in storage /// value in storage
/// </summary> /// </summary>
public T DefaultValue { get; set; } public T DefaultValue { get; set; }
@ -166,6 +167,12 @@ namespace Artemis.Core.Models.Profile.LayerProperties
RemoveKeyframe(layerPropertyKeyframe); RemoveKeyframe(layerPropertyKeyframe);
} }
public override void ApplyDefaultValue()
{
BaseValue = DefaultValue;
CurrentValue = DefaultValue;
}
/// <summary> /// <summary>
/// Called every update (if keyframes are both supported and enabled) to determine the new <see cref="CurrentValue" /> /// Called every update (if keyframes are both supported and enabled) to determine the new <see cref="CurrentValue" />
/// based on the provided progress /// based on the provided progress
@ -284,11 +291,5 @@ namespace Artemis.Core.Models.Profile.LayerProperties
EasingFunction = (int) k.EasingFunction EasingFunction = (int) k.EasingFunction
})); }));
} }
public override void ApplyDefaultValue()
{
BaseValue = DefaultValue;
CurrentValue = DefaultValue;
}
} }
} }

View File

@ -12,6 +12,11 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
KeyframesSupported = false; KeyframesSupported = false;
} }
public static implicit operator ColorGradient(ColorGradientLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased) protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{ {
throw new ArtemisCoreException("Color Gradients do not support keyframes."); throw new ArtemisCoreException("Color Gradients do not support keyframes.");
@ -24,7 +29,5 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
// Don't allow color gradients to be null // Don't allow color gradients to be null
BaseValue ??= DefaultValue ?? new ColorGradient(); BaseValue ??= DefaultValue ?? new ColorGradient();
} }
public static implicit operator ColorGradient(ColorGradientLayerProperty p) => p.CurrentValue;
} }
} }

View File

@ -11,12 +11,19 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
KeyframesSupported = false; KeyframesSupported = false;
} }
public static implicit operator T(EnumLayerProperty<T> p)
{
return p.CurrentValue;
}
public static implicit operator int(EnumLayerProperty<T> p)
{
return Convert.ToInt32(p.CurrentValue);
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased) protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{ {
throw new ArtemisCoreException("Enum properties do not support keyframes."); throw new ArtemisCoreException("Enum properties do not support keyframes.");
} }
public static implicit operator T(EnumLayerProperty<T> p) => p.CurrentValue;
public static implicit operator int(EnumLayerProperty<T> p) => Convert.ToInt32(p.CurrentValue);
} }
} }

View File

@ -7,13 +7,20 @@
{ {
} }
public static implicit operator float(FloatLayerProperty p)
{
return p.CurrentValue;
}
public static implicit operator double(FloatLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased) protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{ {
var diff = NextKeyframe.Value - CurrentKeyframe.Value; var diff = NextKeyframe.Value - CurrentKeyframe.Value;
CurrentValue = CurrentKeyframe.Value + diff * keyframeProgressEased; CurrentValue = CurrentKeyframe.Value + diff * keyframeProgressEased;
} }
public static implicit operator float(FloatLayerProperty p) => p.CurrentValue;
public static implicit operator double(FloatLayerProperty p) => p.CurrentValue;
} }
} }

View File

@ -9,14 +9,25 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
{ {
} }
public static implicit operator int(IntLayerProperty p)
{
return p.CurrentValue;
}
public static implicit operator float(IntLayerProperty p)
{
return p.CurrentValue;
}
public static implicit operator double(IntLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased) protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{ {
var diff = NextKeyframe.Value - CurrentKeyframe.Value; var diff = NextKeyframe.Value - CurrentKeyframe.Value;
CurrentValue = (int) Math.Round(CurrentKeyframe.Value + diff * keyframeProgressEased, MidpointRounding.AwayFromZero); CurrentValue = (int) Math.Round(CurrentKeyframe.Value + diff * keyframeProgressEased, MidpointRounding.AwayFromZero);
} }
public static implicit operator int(IntLayerProperty p) => p.CurrentValue;
public static implicit operator float(IntLayerProperty p) => p.CurrentValue;
public static implicit operator double(IntLayerProperty p) => p.CurrentValue;
} }
} }

View File

@ -12,11 +12,14 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
KeyframesSupported = false; KeyframesSupported = false;
} }
public static implicit operator LayerBrushReference(LayerBrushReferenceLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased) protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{ {
throw new ArtemisCoreException("Layer brush references do not support keyframes."); throw new ArtemisCoreException("Layer brush references do not support keyframes.");
} }
public static implicit operator LayerBrushReference(LayerBrushReferenceLayerProperty p) => p.CurrentValue;
} }
} }

View File

@ -10,6 +10,11 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
{ {
} }
public static implicit operator SKColor(SKColorLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased) protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{ {
var redDiff = NextKeyframe.Value.Red - CurrentKeyframe.Value.Red; var redDiff = NextKeyframe.Value.Red - CurrentKeyframe.Value.Red;
@ -29,7 +34,5 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
{ {
return (byte) Math.Max(0, Math.Min(255, value)); return (byte) Math.Max(0, Math.Min(255, value));
} }
public static implicit operator SKColor(SKColorLayerProperty p) => p.CurrentValue;
} }
} }

View File

@ -9,13 +9,16 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
{ {
} }
public static implicit operator SKPoint(SKPointLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased) protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{ {
var xDiff = NextKeyframe.Value.X - CurrentKeyframe.Value.X; var xDiff = NextKeyframe.Value.X - CurrentKeyframe.Value.X;
var yDiff = NextKeyframe.Value.Y - CurrentKeyframe.Value.Y; var yDiff = NextKeyframe.Value.Y - CurrentKeyframe.Value.Y;
CurrentValue = new SKPoint(CurrentKeyframe.Value.X + xDiff * keyframeProgressEased, CurrentKeyframe.Value.Y + yDiff * keyframeProgressEased); CurrentValue = new SKPoint(CurrentKeyframe.Value.X + xDiff * keyframeProgressEased, CurrentKeyframe.Value.Y + yDiff * keyframeProgressEased);
} }
public static implicit operator SKPoint(SKPointLayerProperty p) => p.CurrentValue;
} }
} }

View File

@ -9,13 +9,16 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types
{ {
} }
public static implicit operator SKSize(SKSizeLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased) protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{ {
var widthDiff = NextKeyframe.Value.Width - CurrentKeyframe.Value.Width; var widthDiff = NextKeyframe.Value.Width - CurrentKeyframe.Value.Width;
var heightDiff = NextKeyframe.Value.Height - CurrentKeyframe.Value.Height; var heightDiff = NextKeyframe.Value.Height - CurrentKeyframe.Value.Height;
CurrentValue = new SKSize(CurrentKeyframe.Value.Width + widthDiff * keyframeProgressEased, CurrentKeyframe.Value.Height + heightDiff * keyframeProgressEased); CurrentValue = new SKSize(CurrentKeyframe.Value.Width + widthDiff * keyframeProgressEased, CurrentKeyframe.Value.Height + heightDiff * keyframeProgressEased);
} }
public static implicit operator SKSize(SKSizeLayerProperty p) => p.CurrentValue;
} }
} }

View File

@ -107,6 +107,21 @@ namespace Artemis.Core.Models.Profile
return _allLayerProperties; return _allLayerProperties;
} }
public void UpdateOrder(int oldOrder)
{
// Expanded state is tied to the path so save it before changing the path
var expanded = Layer.IsPropertyGroupExpanded(this);
Layer.SetPropertyGroupExpanded(this, false);
Path = Path.Replace($"LayerEffect.{oldOrder}.", $"LayerEffect.{LayerEffect.Order}.");
// Restore the expanded state with the new path
Layer.SetPropertyGroupExpanded(this, expanded);
// Update children
foreach (var layerPropertyGroup in LayerPropertyGroups)
layerPropertyGroup.UpdateOrder(oldOrder);
}
/// <summary> /// <summary>
/// Called before properties are fully initialized to allow you to populate /// Called before properties are fully initialized to allow you to populate
/// <see cref="LayerProperty{T}.DefaultValue" /> on the properties you want /// <see cref="LayerProperty{T}.DefaultValue" /> on the properties you want
@ -280,20 +295,5 @@ namespace Artemis.Core.Models.Profile
} }
#endregion #endregion
public void UpdateOrder(int oldOrder)
{
// Expanded state is tied to the path so save it before changing the path
var expanded = Layer.IsPropertyGroupExpanded(this);
Layer.SetPropertyGroupExpanded(this, false);
Path = Path.Replace($"LayerEffect.{oldOrder}.", $"LayerEffect.{LayerEffect.Order}.");
// Restore the expanded state with the new path
Layer.SetPropertyGroupExpanded(this, expanded);
// Update children
foreach (var layerPropertyGroup in LayerPropertyGroups)
layerPropertyGroup.UpdateOrder(oldOrder);
}
} }
} }

View File

@ -127,14 +127,14 @@ namespace Artemis.Core.Models.Profile
} }
} }
/// <summary>
/// Applies the profile element's properties to the underlying storage entity
/// </summary>
internal abstract void ApplyToEntity();
public override string ToString() public override string ToString()
{ {
return $"{nameof(EntityId)}: {EntityId}, {nameof(Order)}: {Order}, {nameof(Name)}: {Name}"; return $"{nameof(EntityId)}: {EntityId}, {nameof(Order)}: {Order}, {nameof(Name)}: {Name}";
} }
/// <summary>
/// Applies the profile element's properties to the underlying storage entity
/// </summary>
internal abstract void ApplyToEntity();
} }
} }

View File

@ -23,6 +23,11 @@ namespace Artemis.Core.Plugins.Abstract
/// </summary> /// </summary>
public bool HasConfigurationViewModel { get; protected set; } public bool HasConfigurationViewModel { get; protected set; }
public void Dispose()
{
DisablePlugin();
}
/// <summary> /// <summary>
/// Called when the plugin is activated /// Called when the plugin is activated
/// </summary> /// </summary>
@ -59,11 +64,6 @@ namespace Artemis.Core.Plugins.Abstract
} }
} }
public void Dispose()
{
DisablePlugin();
}
#region Events #region Events
public event EventHandler PluginEnabled; public event EventHandler PluginEnabled;

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,4 @@
using System.Reflection; using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from // to COM components. If you need to access a type in this assembly from

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
using Artemis.Core.Events; using Artemis.Core.Events;
using Artemis.Core.Exceptions; using Artemis.Core.Exceptions;
using Artemis.Core.JsonConverters; using Artemis.Core.JsonConverters;
@ -10,7 +9,6 @@ using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Storage.Interfaces; using Artemis.Core.Services.Storage.Interfaces;
using Artemis.Storage; using Artemis.Storage;
using Artemis.Storage.Migrations.Interfaces;
using Newtonsoft.Json; using Newtonsoft.Json;
using RGB.NET.Core; using RGB.NET.Core;
using Serilog; using Serilog;
@ -29,8 +27,8 @@ namespace Artemis.Core.Services
private readonly IProfileService _profileService; private readonly IProfileService _profileService;
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
private readonly ISurfaceService _surfaceService; private readonly ISurfaceService _surfaceService;
private readonly PluginSetting<LogEventLevel> _loggingLevel;
private List<Module> _modules; private List<Module> _modules;
private PluginSetting<LogEventLevel> _loggingLevel;
// ReSharper disable once UnusedParameter.Local - Storage migration service is injected early to ensure it runs before anything else // ReSharper disable once UnusedParameter.Local - Storage migration service is injected early to ensure it runs before anything else
internal CoreService(ILogger logger, StorageMigrationService _, ISettingsService settingsService, IPluginService pluginService, internal CoreService(ILogger logger, StorageMigrationService _, ISettingsService settingsService, IPluginService pluginService,
@ -66,24 +64,6 @@ namespace Artemis.Core.Services
public bool IsInitialized { get; set; } public bool IsInitialized { get; set; }
protected virtual void OnFrameRendering(FrameRenderingEventArgs e)
{
FrameRendering?.Invoke(this, e);
}
protected virtual void OnFrameRendered(FrameRenderedEventArgs e)
{
FrameRendered?.Invoke(this, e);
}
private void ConfigureJsonConvert()
{
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
Converters = new List<JsonConverter> {new SKColorConverter()}
};
}
public void Initialize() public void Initialize()
{ {
if (IsInitialized) if (IsInitialized)
@ -107,6 +87,24 @@ namespace Artemis.Core.Services
OnInitialized(); OnInitialized();
} }
protected virtual void OnFrameRendering(FrameRenderingEventArgs e)
{
FrameRendering?.Invoke(this, e);
}
protected virtual void OnFrameRendered(FrameRenderedEventArgs e)
{
FrameRendered?.Invoke(this, e);
}
private void ConfigureJsonConvert()
{
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
Converters = new List<JsonConverter> {new SKColorConverter()}
};
}
private void ApplyLoggingLevel() private void ApplyLoggingLevel()
{ {
_logger.Information("Setting logging level to {loggingLevel}", _loggingLevel.Value); _logger.Information("Setting logging level to {loggingLevel}", _loggingLevel.Value);

View File

@ -3,7 +3,6 @@ using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.LayerBrush.Abstract; using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Plugins.LayerEffect; using Artemis.Core.Plugins.LayerEffect;
using Artemis.Core.Plugins.LayerEffect.Abstract; using Artemis.Core.Plugins.LayerEffect.Abstract;
using Artemis.Storage.Entities.Profile;
namespace Artemis.Core.Services.Interfaces namespace Artemis.Core.Services.Interfaces
{ {

View File

@ -1,18 +1,12 @@
using System.Collections.Generic; using System.Linq;
using System.Linq;
using System.Windows.Documents;
using Artemis.Core.Exceptions; using Artemis.Core.Exceptions;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.LayerBrush.Abstract; using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Plugins.LayerEffect; using Artemis.Core.Plugins.LayerEffect;
using Artemis.Core.Plugins.LayerEffect.Abstract; using Artemis.Core.Plugins.LayerEffect.Abstract;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.Storage.Entities.Profile;
using Ninject; using Ninject;
using Ninject.Injection;
using Ninject.Parameters;
using Serilog; using Serilog;
namespace Artemis.Core.Services namespace Artemis.Core.Services

View File

@ -1,10 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Windows;
using Artemis.Core.Events; using Artemis.Core.Events;
using Artemis.Core.Exceptions; using Artemis.Core.Exceptions;
using Artemis.Core.Extensions; using Artemis.Core.Extensions;

View File

@ -4,7 +4,6 @@ using Artemis.Core.Events;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface; using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Storage.Interfaces; using Artemis.Core.Services.Storage.Interfaces;
using Artemis.Storage.Entities.Profile; using Artemis.Storage.Entities.Profile;
@ -214,9 +213,7 @@ namespace Artemis.Core.Services.Storage
private void OnPluginLoaded(object sender, PluginEventArgs e) private void OnPluginLoaded(object sender, PluginEventArgs e)
{ {
if (e.PluginInfo.Instance is LayerBrushProvider) if (e.PluginInfo.Instance is LayerBrushProvider)
{
ActiveProfilesInstantiateProfileLayerBrushes(); ActiveProfilesInstantiateProfileLayerBrushes();
}
else if (e.PluginInfo.Instance is ProfileModule profileModule) else if (e.PluginInfo.Instance is ProfileModule profileModule)
{ {
var activeProfile = GetActiveProfile(profileModule); var activeProfile = GetActiveProfile(profileModule);

View File

@ -95,7 +95,6 @@ namespace Artemis.Core.Services.Storage
// Update the RGB service's graphics decorator to work with the new surface entity // Update the RGB service's graphics decorator to work with the new surface entity
_rgbService.UpdateSurfaceLedGroup(); _rgbService.UpdateSurfaceLedGroup();
OnActiveSurfaceConfigurationChanged(new SurfaceConfigurationEventArgs(ActiveSurface)); OnActiveSurfaceConfigurationChanged(new SurfaceConfigurationEventArgs(ActiveSurface));
} }
public void UpdateSurfaceConfiguration(ArtemisSurface surface, bool includeDevices) public void UpdateSurfaceConfiguration(ArtemisSurface surface, bool includeDevices)

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text.Json.Serialization;
using LiteDB; using LiteDB;
namespace Artemis.Storage.Entities.Profile namespace Artemis.Storage.Entities.Profile
@ -33,6 +32,4 @@ namespace Artemis.Storage.Entities.Profile
public Guid ProfileId { get; set; } public Guid ProfileId { get; set; }
} }
} }

View File

@ -1,6 +1,4 @@
using System; namespace Artemis.Storage.Entities.Surface
namespace Artemis.Storage.Entities.Surface
{ {
public class DeviceEntity public class DeviceEntity
{ {

View File

@ -1,8 +1,4 @@
using System; using Artemis.Storage.Migrations.Interfaces;
using System.Collections.Generic;
using System.Text;
using Artemis.Storage.Entities.Profile;
using Artemis.Storage.Migrations.Interfaces;
using LiteDB; using LiteDB;
namespace Artemis.Storage.Migrations namespace Artemis.Storage.Migrations
@ -10,6 +6,7 @@ namespace Artemis.Storage.Migrations
public class AttributeBasedPropertiesMigration : IStorageMigration public class AttributeBasedPropertiesMigration : IStorageMigration
{ {
public int UserVersion => 1; public int UserVersion => 1;
public void Apply(LiteRepository repository) public void Apply(LiteRepository repository)
{ {
if (repository.Database.CollectionExists("ProfileEntity")) if (repository.Database.CollectionExists("ProfileEntity"))

View File

@ -9,8 +9,8 @@ namespace Artemis.Storage
public class StorageMigrationService public class StorageMigrationService
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly LiteRepository _repository;
private readonly List<IStorageMigration> _migrations; private readonly List<IStorageMigration> _migrations;
private readonly LiteRepository _repository;
public StorageMigrationService(ILogger logger, LiteRepository repository, List<IStorageMigration> migrations) public StorageMigrationService(ILogger logger, LiteRepository repository, List<IStorageMigration> migrations)
{ {

View File

@ -8,7 +8,6 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using Artemis.Core.Models.Surface; using Artemis.Core.Models.Surface;
using RGB.NET.Core; using RGB.NET.Core;
using Stylet;
namespace Artemis.UI.Shared.Controls namespace Artemis.UI.Shared.Controls
{ {
@ -37,19 +36,6 @@ namespace Artemis.UI.Shared.Controls
Unloaded += (sender, args) => SubscribeToUpdate(false); 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 public ArtemisDevice Device
{ {
get => (ArtemisDevice) GetValue(DeviceProperty); get => (ArtemisDevice) GetValue(DeviceProperty);
@ -99,6 +85,19 @@ namespace Artemis.UI.Shared.Controls
drawingContext.DrawDrawing(_backingStore); drawingContext.DrawDrawing(_backingStore);
} }
private void SubscribeToUpdate(bool subscribe)
{
if (_subscribed == subscribe)
return;
if (subscribe)
RGBSurface.Instance.Updated += RgbSurfaceOnUpdated;
else
RGBSurface.Instance.Updated -= RgbSurfaceOnUpdated;
_subscribed = subscribe;
}
private static void DevicePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void DevicePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
var deviceVisualizer = (DeviceVisualizer) d; var deviceVisualizer = (DeviceVisualizer) d;

View File

@ -34,6 +34,41 @@ namespace Artemis.UI.Shared.Controls
public Geometry DisplayGeometry { get; private set; } public Geometry DisplayGeometry { get; private set; }
public void RenderColor(DrawingContext drawingContext, bool isDimmed)
{
if (DisplayGeometry == null)
return;
var r = Led.RgbLed.Color.GetR();
var g = Led.RgbLed.Color.GetG();
var b = Led.RgbLed.Color.GetB();
drawingContext.DrawRectangle(isDimmed
? new SolidColorBrush(Color.FromArgb(100, r, g, b))
: new SolidColorBrush(Color.FromRgb(r, g, b)), null, LedRect);
}
public void RenderImage(DrawingContext drawingContext)
{
if (LedImage == null)
return;
drawingContext.DrawImage(LedImage, LedRect);
}
public void RenderOpacityMask(DrawingContext drawingContext)
{
if (DisplayGeometry == null)
return;
var fillBrush = new SolidColorBrush(Color.FromArgb(100, 255, 255, 255));
fillBrush.Freeze();
var penBrush = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
penBrush.Freeze();
drawingContext.DrawGeometry(fillBrush, new Pen(penBrush, 1), DisplayGeometry);
}
private void CreateLedGeometry() private void CreateLedGeometry()
{ {
// The minimum required size for geometry to be created // The minimum required size for geometry to be created
@ -105,40 +140,5 @@ namespace Artemis.UI.Shared.Controls
CreateRectangleGeometry(); CreateRectangleGeometry();
} }
} }
public void RenderColor(DrawingContext drawingContext, bool isDimmed)
{
if (DisplayGeometry == null)
return;
var r = Led.RgbLed.Color.GetR();
var g = Led.RgbLed.Color.GetG();
var b = Led.RgbLed.Color.GetB();
drawingContext.DrawRectangle(isDimmed
? new SolidColorBrush(Color.FromArgb(100, r, g, b))
: new SolidColorBrush(Color.FromRgb(r, g, b)), null, LedRect);
}
public void RenderImage(DrawingContext drawingContext)
{
if (LedImage == null)
return;
drawingContext.DrawImage(LedImage, LedRect);
}
public void RenderOpacityMask(DrawingContext drawingContext)
{
if (DisplayGeometry == null)
return;
var fillBrush = new SolidColorBrush(Color.FromArgb(100, 255, 255, 255));
fillBrush.Freeze();
var penBrush = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
penBrush.Freeze();
drawingContext.DrawGeometry(fillBrush, new Pen(penBrush, 1), DisplayGeometry);
}
} }
} }

View File

@ -24,13 +24,11 @@ namespace Artemis.UI.Shared.Controls
typeof(RoutedPropertyChangedEventHandler<float>), typeof(RoutedPropertyChangedEventHandler<float>),
typeof(DraggableFloat)); typeof(DraggableFloat));
public event EventHandler DragStarted; private bool _calledDragStarted;
public event EventHandler DragEnded;
private bool _inCallback; private bool _inCallback;
private Point _mouseDragStartPoint; private Point _mouseDragStartPoint;
private float _startValue; private float _startValue;
private bool _calledDragStarted;
public DraggableFloat() public DraggableFloat()
{ {
@ -51,11 +49,24 @@ namespace Artemis.UI.Shared.Controls
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
public event EventHandler DragStarted;
public event EventHandler DragEnded;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{ {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
} }
protected virtual void OnDragStarted()
{
DragStarted?.Invoke(this, EventArgs.Empty);
}
protected virtual void OnDragEnded()
{
DragEnded?.Invoke(this, EventArgs.Empty);
}
private static void FloatPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void FloatPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
var draggableFloat = (DraggableFloat) d; var draggableFloat = (DraggableFloat) d;
@ -149,15 +160,5 @@ namespace Artemis.UI.Shared.Controls
{ {
return Math.Floor(amountToRound / nearstOf + fairness) * nearstOf; return Math.Floor(amountToRound / nearstOf + fairness) * nearstOf;
} }
protected virtual void OnDragStarted()
{
DragStarted?.Invoke(this, EventArgs.Empty);
}
protected virtual void OnDragEnded()
{
DragEnded?.Invoke(this, EventArgs.Empty);
}
} }
} }

View File

@ -37,7 +37,8 @@
Background="{StaticResource Checkerboard}"> Background="{StaticResource Checkerboard}">
<Rectangle Stroke="{DynamicResource NormalBorderBrush}" Cursor="Hand" MouseUp="UIElement_OnMouseUp"> <Rectangle Stroke="{DynamicResource NormalBorderBrush}" Cursor="Hand" MouseUp="UIElement_OnMouseUp">
<Rectangle.Fill> <Rectangle.Fill>
<LinearGradientBrush GradientStops="{Binding ColorGradient.Stops, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource ColorGradientToGradientStopsConverter}}" <LinearGradientBrush
GradientStops="{Binding ColorGradient.Stops, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource ColorGradientToGradientStopsConverter}}"
EndPoint="1,0" EndPoint="1,0"
StartPoint="0,0" /> StartPoint="0,0" />
</Rectangle.Fill> </Rectangle.Fill>

View File

@ -1,11 +1,9 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Colors; using Artemis.Core.Models.Profile.Colors;
using Artemis.UI.Shared.Annotations; using Artemis.UI.Shared.Annotations;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
@ -21,9 +19,6 @@ namespace Artemis.UI.Shared.Controls
private static IGradientPickerService _gradientPickerService; private static IGradientPickerService _gradientPickerService;
private bool _inCallback; private bool _inCallback;
public event EventHandler DialogOpened;
public event EventHandler DialogClosed;
public GradientPicker() public GradientPicker()
{ {
InitializeComponent(); InitializeComponent();
@ -63,12 +58,25 @@ namespace Artemis.UI.Shared.Controls
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
public event EventHandler DialogOpened;
public event EventHandler DialogClosed;
[NotifyPropertyChangedInvocator] [NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{ {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
} }
protected virtual void OnDialogOpened()
{
DialogOpened?.Invoke(this, EventArgs.Empty);
}
protected virtual void OnDialogClosed()
{
DialogClosed?.Invoke(this, EventArgs.Empty);
}
private static void ColorGradientPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) private static void ColorGradientPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{ {
var gradientPicker = (GradientPicker) d; var gradientPicker = (GradientPicker) d;
@ -102,15 +110,5 @@ namespace Artemis.UI.Shared.Controls
EventManager.RegisterRoutedEvent(nameof(ColorGradient), RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler<ColorGradient>), typeof(GradientPicker)); EventManager.RegisterRoutedEvent(nameof(ColorGradient), RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler<ColorGradient>), typeof(GradientPicker));
#endregion #endregion
protected virtual void OnDialogOpened()
{
DialogOpened?.Invoke(this, EventArgs.Empty);
}
protected virtual void OnDialogClosed()
{
DialogClosed?.Invoke(this, EventArgs.Empty);
}
} }
} }

View File

@ -3,7 +3,6 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Media; using System.Windows.Media;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Colors; using Artemis.Core.Models.Profile.Colors;
using SkiaSharp; using SkiaSharp;
using Stylet; using Stylet;

View File

@ -1,5 +1,4 @@
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile.Colors;
using Artemis.Core.Models.Profile.Colors;
using Artemis.UI.Shared.Screens.GradientEditor; using Artemis.UI.Shared.Screens.GradientEditor;
namespace Artemis.UI.Shared.Ninject.Factories namespace Artemis.UI.Shared.Ninject.Factories

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,4 @@
using System.Reflection; using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible

View File

@ -32,13 +32,13 @@ namespace Artemis.UI.Shared.Screens.Dialogs
public class DialogException public class DialogException
{ {
public Exception Exception { get; }
public IDocument Document { get; set; }
public DialogException(Exception exception) public DialogException(Exception exception)
{ {
Exception = exception; Exception = exception;
Document = new TextDocument(new StringTextSource($"{exception.Message}\r\n\r\n{exception.StackTrace}")); Document = new TextDocument(new StringTextSource($"{exception.Message}\r\n\r\n{exception.StackTrace}"));
} }
public Exception Exception { get; }
public IDocument Document { get; set; }
} }
} }

View File

@ -1,11 +1,9 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Colors; using Artemis.Core.Models.Profile.Colors;
using Artemis.UI.Shared.Utilities; using Artemis.UI.Shared.Utilities;
using Stylet; using Stylet;
@ -25,11 +23,6 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
ColorStop.PropertyChanged += ColorStopOnPropertyChanged; ColorStop.PropertyChanged += ColorStopOnPropertyChanged;
} }
private void ColorStopOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
_gradientEditorViewModel.ColorGradient.OnColorValuesUpdated();
}
public ColorGradientStop ColorStop { get; } public ColorGradientStop ColorStop { get; }
public double Offset public double Offset
@ -66,6 +59,11 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
set => SetAndNotify(ref _willRemoveColorStop, value); set => SetAndNotify(ref _willRemoveColorStop, value);
} }
private void ColorStopOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
_gradientEditorViewModel.ColorGradient.OnColorValuesUpdated();
}
#region Movement #region Movement
public void StopMouseDown(object sender, MouseButtonEventArgs e) public void StopMouseDown(object sender, MouseButtonEventArgs e)

View File

@ -4,7 +4,6 @@ using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Colors; using Artemis.Core.Models.Profile.Colors;
using Artemis.UI.Shared.Services.Dialog; using Artemis.UI.Shared.Services.Dialog;
using Artemis.UI.Shared.Utilities; using Artemis.UI.Shared.Utilities;

View File

@ -1,6 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Colors; using Artemis.Core.Models.Profile.Colors;
using Artemis.UI.Shared.Screens.GradientEditor; using Artemis.UI.Shared.Screens.GradientEditor;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;

View File

@ -1,5 +1,4 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Colors; using Artemis.Core.Models.Profile.Colors;
namespace Artemis.UI.Shared.Services.Interfaces namespace Artemis.UI.Shared.Services.Interfaces

View File

@ -7,7 +7,8 @@ namespace Artemis.UI.Shared.Utilities
public static class HitTestUtilities public static class HitTestUtilities
{ {
/// <summary> /// <summary>
/// Runs a hit test on children of the container within the rectangle matching all elements that have a data context of <see cref="T"/>. /// Runs a hit test on children of the container within the rectangle matching all elements that have a data context of
/// <see cref="T" />.
/// </summary> /// </summary>
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
/// <param name="container"></param> /// <param name="container"></param>

View File

@ -1,44 +1,17 @@
using System; using System;
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Artemis.UI.Shared.Utilities namespace Artemis.UI.Shared.Utilities
{ {
public class ShortcutUtilities public class ShortcutUtilities
{ {
private static readonly Type m_type = Type.GetTypeFromProgID("WScript.Shell");
private static Type m_type = Type.GetTypeFromProgID("WScript.Shell"); private static readonly object m_shell = Activator.CreateInstance(m_type);
private static object m_shell = Activator.CreateInstance(m_type);
[ComImport, TypeLibType((short)0x1040), Guid("F935DC23-1CF0-11D0-ADB9-00C04FD58A0B")]
private interface IWshShortcut
{
[DispId(0)]
string FullName { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0)] get; }
[DispId(0x3e8)]
string Arguments { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3e8)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3e8)] set; }
[DispId(0x3e9)]
string Description { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3e9)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3e9)] set; }
[DispId(0x3ea)]
string Hotkey { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3ea)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3ea)] set; }
[DispId(0x3eb)]
string IconLocation { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3eb)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3eb)] set; }
[DispId(0x3ec)]
string RelativePath { [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3ec)] set; }
[DispId(0x3ed)]
string TargetPath { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3ed)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3ed)] set; }
[DispId(0x3ee)]
int WindowStyle { [DispId(0x3ee)] get; [param: In] [DispId(0x3ee)] set; }
[DispId(0x3ef)]
string WorkingDirectory { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3ef)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3ef)] set; }
[TypeLibFunc((short)0x40), DispId(0x7d0)]
void Load([In, MarshalAs(UnmanagedType.BStr)] string PathLink);
[DispId(0x7d1)]
void Save();
}
public static void Create(string fileName, string targetPath, string arguments, string workingDirectory, string description, string hotkey, string iconPath) public static void Create(string fileName, string targetPath, string arguments, string workingDirectory, string description, string hotkey, string iconPath)
{ {
IWshShortcut shortcut = (IWshShortcut)m_type.InvokeMember("CreateShortcut", System.Reflection.BindingFlags.InvokeMethod, null, m_shell, new object[] { fileName }); var shortcut = (IWshShortcut) m_type.InvokeMember("CreateShortcut", BindingFlags.InvokeMethod, null, m_shell, new object[] {fileName});
shortcut.Description = description; shortcut.Description = description;
shortcut.Hotkey = hotkey; shortcut.Hotkey = hotkey;
shortcut.TargetPath = targetPath; shortcut.TargetPath = targetPath;
@ -48,5 +21,117 @@ namespace Artemis.UI.Shared.Utilities
shortcut.IconLocation = iconPath; shortcut.IconLocation = iconPath;
shortcut.Save(); shortcut.Save();
} }
[ComImport]
[TypeLibType(0x1040)]
[Guid("F935DC23-1CF0-11D0-ADB9-00C04FD58A0B")]
private interface IWshShortcut
{
[DispId(0)]
string FullName
{
[return: MarshalAs(UnmanagedType.BStr)]
[DispId(0)]
get;
}
[DispId(0x3e8)]
string Arguments
{
[return: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3e8)]
get;
[param: In]
[param: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3e8)]
set;
}
[DispId(0x3e9)]
string Description
{
[return: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3e9)]
get;
[param: In]
[param: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3e9)]
set;
}
[DispId(0x3ea)]
string Hotkey
{
[return: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3ea)]
get;
[param: In]
[param: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3ea)]
set;
}
[DispId(0x3eb)]
string IconLocation
{
[return: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3eb)]
get;
[param: In]
[param: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3eb)]
set;
}
[DispId(0x3ec)]
string RelativePath
{
[param: In]
[param: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3ec)]
set;
}
[DispId(0x3ed)]
string TargetPath
{
[return: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3ed)]
get;
[param: In]
[param: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3ed)]
set;
}
[DispId(0x3ee)]
int WindowStyle
{
[DispId(0x3ee)]
get;
[param: In]
[DispId(0x3ee)]
set;
}
[DispId(0x3ef)]
string WorkingDirectory
{
[return: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3ef)]
get;
[param: In]
[param: MarshalAs(UnmanagedType.BStr)]
[DispId(0x3ef)]
set;
}
[TypeLibFunc(0x40)]
[DispId(0x7d0)]
void Load([In] [MarshalAs(UnmanagedType.BStr)] string PathLink);
[DispId(0x7d1)]
void Save();
}
} }
} }

View File

@ -2,11 +2,11 @@
{ {
public class RequestSelectSidebarItemEvent public class RequestSelectSidebarItemEvent
{ {
public string Label { get; }
public RequestSelectSidebarItemEvent(string label) public RequestSelectSidebarItemEvent(string label)
{ {
Label = label; Label = label;
} }
public string Label { get; }
} }
} }

View File

@ -3,7 +3,6 @@ using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens; using Artemis.UI.Screens;
using Artemis.UI.Screens.Module.ProfileEditor; using Artemis.UI.Screens.Module.ProfileEditor;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.PropertyInput;
using Artemis.UI.Shared.Services.Dialog; using Artemis.UI.Shared.Services.Dialog;
using Artemis.UI.Stylet; using Artemis.UI.Stylet;
using FluentValidation; using FluentValidation;

View File

@ -1,6 +1,4 @@
using System.Reflection; using System.Runtime.InteropServices;
using System.Resources;
using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
// Setting ComVisible to false makes the types in this assembly not visible // Setting ComVisible to false makes the types in this assembly not visible

View File

@ -1,5 +1,4 @@
using System; using System.Linq;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;

View File

@ -9,8 +9,8 @@
d:DesignHeight="213.053" d:DesignWidth="254.425"> d:DesignHeight="213.053" d:DesignWidth="254.425">
<StackPanel Margin="16"> <StackPanel Margin="16">
<TextBlock Style="{StaticResource MaterialDesignHeadline6TextBlock}"> <TextBlock Style="{StaticResource MaterialDesignHeadline6TextBlock}">
<Run Text="Rename"></Run> <Run Text="Rename" />
<Run Text="{Binding Subject, Mode=OneWay}"></Run> <Run Text="{Binding Subject, Mode=OneWay}" />
</TextBlock> </TextBlock>
<TextBox materialDesign:HintAssist.Hint="Element name" <TextBox materialDesign:HintAssist.Hint="Element name"

View File

@ -1,5 +1,4 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core.Models.Profile;
using Artemis.UI.Shared.Services.Dialog; using Artemis.UI.Shared.Services.Dialog;
using FluentValidation; using FluentValidation;
using Stylet; using Stylet;

View File

@ -16,8 +16,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract
public abstract bool IsVisible { get; } public abstract bool IsVisible { get; }
public List<LayerPropertyBaseViewModel> Children { get; set; } public List<LayerPropertyBaseViewModel> Children { get; set; }
public abstract void Dispose();
public abstract List<BaseLayerPropertyKeyframe> GetKeyframes(bool expandedOnly); public abstract List<BaseLayerPropertyKeyframe> GetKeyframes(bool expandedOnly);
public abstract void Dispose();
} }
} }

View File

@ -8,7 +8,6 @@ using Artemis.Core.Events;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerProperties; using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Models.Profile.LayerProperties.Attributes; using Artemis.Core.Models.Profile.LayerProperties.Attributes;
using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Services; using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;
@ -62,6 +61,21 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
public EffectsViewModel EffectsViewModel { get; set; } public EffectsViewModel EffectsViewModel { get; set; }
public TimelineViewModel TimelineViewModel { get; set; } public TimelineViewModel TimelineViewModel { get; set; }
#region Effects
public void ToggleAddEffect()
{
if (DateTime.Now - _lastToggle < TimeSpan.FromMilliseconds(500))
return;
_lastToggle = DateTime.Now;
PropertyTreeIndex = PropertyTreeIndex == 0 ? 1 : 0;
if (PropertyTreeIndex == 1)
EffectsViewModel.PopulateDescriptors();
}
#endregion
protected override void OnInitialActivate() protected override void OnInitialActivate()
{ {
PopulateProperties(ProfileEditorService.SelectedProfileElement); PopulateProperties(ProfileEditorService.SelectedProfileElement);
@ -115,10 +129,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
private void PopulateProperties(ProfileElement profileElement) private void PopulateProperties(ProfileElement profileElement)
{ {
if (SelectedFolder != null) if (SelectedFolder != null) SelectedFolder = null;
{
SelectedFolder = null;
}
if (SelectedLayer != null) if (SelectedLayer != null)
{ {
@ -133,9 +144,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
_brushPropertyGroup = null; _brushPropertyGroup = null;
if (profileElement is Folder folder) if (profileElement is Folder folder)
{
SelectedFolder = folder; SelectedFolder = folder;
}
else if (profileElement is Layer layer) else if (profileElement is Layer layer)
{ {
SelectedLayer = layer; SelectedLayer = layer;
@ -389,20 +398,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
} }
#endregion #endregion
#region Effects
public void ToggleAddEffect()
{
if (DateTime.Now - _lastToggle < TimeSpan.FromMilliseconds(500))
return;
_lastToggle = DateTime.Now;
PropertyTreeIndex = PropertyTreeIndex == 0 ? 1 : 0;
if (PropertyTreeIndex == 1)
EffectsViewModel.PopulateDescriptors();
}
#endregion
} }
} }

View File

@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using Artemis.Core.Models.Profile.LayerProperties; using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Exceptions; using Artemis.UI.Exceptions;
using Artemis.UI.PropertyInput;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract; using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline; using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree; using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree;
using Artemis.UI.PropertyInput;
using Artemis.UI.Shared.PropertyInput; using Artemis.UI.Shared.PropertyInput;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
using Humanizer; using Humanizer;

View File

@ -4,7 +4,6 @@ using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using Artemis.Core.Models.Profile.LayerProperties; using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Utilities; using Artemis.Core.Utilities;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
using Stylet; using Stylet;

View File

@ -41,8 +41,7 @@
StrokeThickness="0" StrokeThickness="0"
Width="10" Width="10"
Height="10" Height="10"
Margin="-5,6,0,0"> Margin="-5,6,0,0" />
</Ellipse>
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>

View File

@ -2,7 +2,6 @@
using System.Linq; using System.Linq;
using Artemis.UI.Exceptions; using Artemis.UI.Exceptions;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract; using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
using Stylet; using Stylet;
@ -23,17 +22,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
_profileEditorService.PixelsPerSecondChanged += ProfileEditorServiceOnPixelsPerSecondChanged; _profileEditorService.PixelsPerSecondChanged += ProfileEditorServiceOnPixelsPerSecondChanged;
} }
private void LayerPropertyOnKeyframeModified(object sender, EventArgs e)
{
UpdateKeyframes();
}
private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e)
{
foreach (var timelineKeyframeViewModel in TimelineKeyframeViewModels)
timelineKeyframeViewModel.Update(_profileEditorService.PixelsPerSecond);
}
public LayerPropertyViewModel<T> LayerPropertyViewModel { get; } public LayerPropertyViewModel<T> LayerPropertyViewModel { get; }
public override void UpdateKeyframes() public override void UpdateKeyframes()
@ -53,9 +41,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
); );
} }
else else
{
TimelineKeyframeViewModels.Clear(); TimelineKeyframeViewModels.Clear();
}
foreach (var timelineKeyframeViewModel in TimelineKeyframeViewModels) foreach (var timelineKeyframeViewModel in TimelineKeyframeViewModels)
timelineKeyframeViewModel.Update(_profileEditorService.PixelsPerSecond); timelineKeyframeViewModel.Update(_profileEditorService.PixelsPerSecond);
@ -68,6 +54,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
LayerPropertyViewModel.LayerProperty.KeyframeRemoved -= LayerPropertyOnKeyframeModified; LayerPropertyViewModel.LayerProperty.KeyframeRemoved -= LayerPropertyOnKeyframeModified;
LayerPropertyViewModel.LayerProperty.KeyframesToggled -= LayerPropertyOnKeyframeModified; LayerPropertyViewModel.LayerProperty.KeyframesToggled -= LayerPropertyOnKeyframeModified;
} }
private void LayerPropertyOnKeyframeModified(object sender, EventArgs e)
{
UpdateKeyframes();
}
private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e)
{
foreach (var timelineKeyframeViewModel in TimelineKeyframeViewModels)
timelineKeyframeViewModel.Update(_profileEditorService.PixelsPerSecond);
}
} }
public abstract class TimelinePropertyViewModel : IDisposable public abstract class TimelinePropertyViewModel : IDisposable
@ -82,8 +79,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
public TimelineViewModel TimelineViewModel { get; set; } public TimelineViewModel TimelineViewModel { get; set; }
public BindableCollection<TimelineKeyframeViewModel> TimelineKeyframeViewModels { get; set; } public BindableCollection<TimelineKeyframeViewModel> TimelineKeyframeViewModels { get; set; }
public abstract void UpdateKeyframes();
public abstract void Dispose(); public abstract void Dispose();
public abstract void UpdateKeyframes();
} }
} }

View File

@ -8,9 +8,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree
{ {
public class TreePropertyGroupViewModel public class TreePropertyGroupViewModel
{ {
private readonly IProfileEditorService _profileEditorService;
private readonly ILayerService _layerService;
private readonly IDialogService _dialogService; private readonly IDialogService _dialogService;
private readonly ILayerService _layerService;
private readonly IProfileEditorService _profileEditorService;
public TreePropertyGroupViewModel(LayerPropertyBaseViewModel layerPropertyBaseViewModel, public TreePropertyGroupViewModel(LayerPropertyBaseViewModel layerPropertyBaseViewModel,
IProfileEditorService profileEditorService, ILayerService layerService, IDialogService dialogService) IProfileEditorService profileEditorService, ILayerService layerService, IDialogService dialogService)

View File

@ -11,10 +11,8 @@ using Artemis.Core.Services.Storage.Interfaces;
using Artemis.UI.Screens.Module.ProfileEditor.Dialogs; using Artemis.UI.Screens.Module.ProfileEditor.Dialogs;
using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions; using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties; using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree; using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree;
using Artemis.UI.Screens.Module.ProfileEditor.Visualization; using Artemis.UI.Screens.Module.ProfileEditor.Visualization;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
using Stylet; using Stylet;

View File

@ -4,7 +4,6 @@ using System.Windows;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem; using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
using GongSolutions.Wpf.DragDrop; using GongSolutions.Wpf.DragDrop;

View File

@ -1,7 +1,6 @@
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem

View File

@ -1,7 +1,6 @@
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
@ -22,6 +21,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
public Layer Layer => ProfileElement as Layer; public Layer Layer => ProfileElement as Layer;
public bool ShowIcons => Layer?.LayerBrush != null; public bool ShowIcons => Layer?.LayerBrush != null;
public override bool SupportsChildren => false; public override bool SupportsChildren => false;
} }
} }

View File

@ -6,7 +6,6 @@ using Artemis.Core.Services.Interfaces;
using Artemis.UI.Exceptions; using Artemis.UI.Exceptions;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.Module.ProfileEditor.Dialogs; using Artemis.UI.Screens.Module.ProfileEditor.Dialogs;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
using Stylet; using Stylet;

View File

@ -69,7 +69,6 @@
StrokeThickness="1" StrokeThickness="1"
StrokeLineJoin="Round" StrokeLineJoin="Round"
x:Name="LayerPath" x:Name="LayerPath"
Style="{StaticResource SelectedLayerStyle}"> Style="{StaticResource SelectedLayerStyle}" />
</Path>
</Canvas> </Canvas>
</UserControl> </UserControl>

View File

@ -7,7 +7,6 @@ using System.Windows.Media.Imaging;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerShapes; using Artemis.Core.Models.Profile.LayerShapes;
using Artemis.Core.Models.Surface; using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.UI.Extensions; using Artemis.UI.Extensions;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;

View File

@ -6,8 +6,6 @@ using System.Windows.Input;
using Artemis.Core.Events; using Artemis.Core.Events;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface; using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Plugins.Models; using Artemis.Core.Plugins.Models;
using Artemis.Core.Services; using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;

View File

@ -4,7 +4,6 @@ using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.UI.Properties; using Artemis.UI.Properties;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools

View File

@ -3,10 +3,8 @@ using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.UI.Properties; using Artemis.UI.Properties;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools

View File

@ -1,5 +1,4 @@
using System.Windows.Input; using System.Windows.Input;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools

View File

@ -1,5 +1,4 @@
using System; using System.ComponentModel;
using System.ComponentModel;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
@ -17,9 +16,9 @@ namespace Artemis.UI.Screens
public class RootViewModel : Conductor<IScreen> public class RootViewModel : Conductor<IScreen>
{ {
private readonly IEventAggregator _eventAggregator; private readonly IEventAggregator _eventAggregator;
private readonly PluginSetting<ApplicationColorScheme> _colorScheme;
private bool _lostFocus; private bool _lostFocus;
private PluginSetting<ApplicationColorScheme> _colorScheme; private readonly ThemeWatcher _themeWatcher;
private ThemeWatcher _themeWatcher;
public RootViewModel(IEventAggregator eventAggregator, SidebarViewModel sidebarViewModel, ISettingsService settingsService) public RootViewModel(IEventAggregator eventAggregator, SidebarViewModel sidebarViewModel, ISettingsService settingsService)
{ {

View File

@ -3,10 +3,8 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core; using Artemis.Core;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Services; using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Storage.Interfaces; using Artemis.Core.Services.Storage.Interfaces;
@ -17,8 +15,6 @@ using Artemis.UI.Screens.Settings.Tabs.Devices;
using Artemis.UI.Screens.Settings.Tabs.Plugins; using Artemis.UI.Screens.Settings.Tabs.Plugins;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
using Artemis.UI.Shared.Utilities; using Artemis.UI.Shared.Utilities;
using Artemis.UI.Utilities;
using Microsoft.Win32;
using Ninject; using Ninject;
using Serilog.Events; using Serilog.Events;
using Stylet; using Stylet;

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO;
using Artemis.Core.Models.Surface; using Artemis.Core.Models.Surface;
using Artemis.Core.Services; using Artemis.Core.Services;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;

View File

@ -1,15 +1,4 @@
using System; using System.Windows.Controls;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Artemis.UI.Screens.Settings.Tabs.Plugins namespace Artemis.UI.Screens.Settings.Tabs.Plugins
{ {

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.Models; using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
@ -33,6 +32,29 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
public PackIconKind Icon => GetIconKind(); public PackIconKind Icon => GetIconKind();
public bool IsEnabled
{
get => PluginInfo.Enabled;
set => Task.Run(() => UpdateEnabled(value));
}
public bool CanOpenSettings => IsEnabled && Plugin.HasConfigurationViewModel;
public async Task OpenSettings()
{
try
{
var configurationViewModel = Plugin.GetConfigurationViewModel();
if (configurationViewModel != null)
_windowManager.ShowDialog(new PluginSettingsWindowViewModel(configurationViewModel));
}
catch (Exception e)
{
await _dialogService.ShowExceptionDialog("An exception occured while trying to show the plugin's settings window", e);
throw;
}
}
private PackIconKind GetIconKind() private PackIconKind GetIconKind()
{ {
if (PluginInfo.Icon != null) if (PluginInfo.Icon != null)
@ -61,29 +83,6 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
return PackIconKind.Plugin; return PackIconKind.Plugin;
} }
public bool IsEnabled
{
get => PluginInfo.Enabled;
set => Task.Run(() => UpdateEnabled(value));
}
public bool CanOpenSettings => IsEnabled && Plugin.HasConfigurationViewModel;
public async Task OpenSettings()
{
try
{
var configurationViewModel = Plugin.GetConfigurationViewModel();
if (configurationViewModel != null)
_windowManager.ShowDialog(new PluginSettingsWindowViewModel(configurationViewModel));
}
catch (Exception e)
{
await _dialogService.ShowExceptionDialog("An exception occured while trying to show the plugin's settings window", e);
throw;
}
}
private async Task UpdateEnabled(bool enable) private async Task UpdateEnabled(bool enable)
{ {
if (PluginInfo.Enabled == enable) if (PluginInfo.Enabled == enable)

View File

@ -24,8 +24,8 @@ namespace Artemis.UI.Screens.SurfaceEditor
{ {
private readonly IDeviceService _deviceService; private readonly IDeviceService _deviceService;
private readonly IDialogService _dialogService; private readonly IDialogService _dialogService;
private readonly ISettingsService _settingsService;
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
private readonly ISettingsService _settingsService;
private readonly ISurfaceService _surfaceService; private readonly ISurfaceService _surfaceService;
public SurfaceEditorViewModel(IRgbService rgbService, ISurfaceService surfaceService, IDialogService dialogService, ISettingsService settingsService, public SurfaceEditorViewModel(IRgbService rgbService, ISurfaceService surfaceService, IDialogService dialogService, ISettingsService settingsService,

View File

@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using Artemis.Core.Models.Surface; using Artemis.Core.Models.Surface;

View File

@ -3,11 +3,10 @@ using Artemis.Core.Services.Interfaces;
using Artemis.Core.Utilities; using Artemis.Core.Utilities;
using Artemis.UI.Events; using Artemis.UI.Events;
using Artemis.UI.Screens.Splash; using Artemis.UI.Screens.Splash;
using Artemis.UI.Shared; using Artemis.UI.Shared.Controls;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
using Ninject; using Ninject;
using Stylet; using Stylet;
using GradientPicker = Artemis.UI.Shared.Controls.GradientPicker;
namespace Artemis.UI.Screens namespace Artemis.UI.Screens
{ {

View File

@ -3,10 +3,8 @@ using System.Windows;
using System.Windows.Media; using System.Windows.Media;
using Artemis.Core; using Artemis.Core;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Colors;
using Artemis.Core.Services; using Artemis.Core.Services;
using Artemis.UI.PropertyInput; using Artemis.UI.PropertyInput;
using Artemis.UI.PropertyInput;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
using SkiaSharp; using SkiaSharp;
@ -16,8 +14,8 @@ namespace Artemis.UI.Services
{ {
public class LayerEditorService : ILayerEditorService public class LayerEditorService : ILayerEditorService
{ {
private readonly ISettingsService _settingsService;
private readonly IProfileEditorService _profileEditorService; private readonly IProfileEditorService _profileEditorService;
private readonly ISettingsService _settingsService;
public LayerEditorService(ISettingsService settingsService, IProfileEditorService profileEditorService) public LayerEditorService(ISettingsService settingsService, IProfileEditorService profileEditorService)
{ {
@ -26,17 +24,6 @@ namespace Artemis.UI.Services
RegisterBuiltInPropertyEditors(); RegisterBuiltInPropertyEditors();
} }
private void RegisterBuiltInPropertyEditors()
{
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(BrushPropertyInputViewModel));
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(ColorGradientPropertyInputViewModel));
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(FloatPropertyInputViewModel));
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(IntPropertyInputViewModel));
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(SKColorPropertyInputViewModel));
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(SKPointPropertyInputViewModel));
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(SKSizePropertyInputViewModel));
}
/// <inheritdoc /> /// <inheritdoc />
public Rect GetLayerBounds(Layer layer) public Rect GetLayerBounds(Layer layer)
{ {
@ -151,5 +138,16 @@ namespace Artemis.UI.Services
// The difference between the two is the offset // The difference between the two is the offset
return topLeft - tempTopLeft; return topLeft - tempTopLeft;
} }
private void RegisterBuiltInPropertyEditors()
{
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(BrushPropertyInputViewModel));
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(ColorGradientPropertyInputViewModel));
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(FloatPropertyInputViewModel));
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(IntPropertyInputViewModel));
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(SKColorPropertyInputViewModel));
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(SKPointPropertyInputViewModel));
_profileEditorService.RegisterPropertyInput(Constants.CorePluginInfo, typeof(SKSizePropertyInputViewModel));
}
} }
} }

View File

@ -1,7 +1,4 @@
using System; using Stylet;
using System.Collections.Generic;
using System.Reflection;
using Stylet;
namespace Artemis.UI.Stylet namespace Artemis.UI.Stylet
{ {