1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +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();
foreach (var layerEffect in LayerEffects)
{
var layerEffectEntity = new LayerEffectEntity()
var layerEffectEntity = new LayerEffectEntity
{
PluginGuid = layerEffect.PluginInfo.Guid,
EffectType = layerEffect.GetType().Name,

View File

@ -10,8 +10,8 @@ namespace Artemis.Core.Models.Profile.LayerProperties
/// </summary>
public abstract class BaseLayerProperty
{
private bool _keyframesEnabled;
private bool _isHidden;
private bool _keyframesEnabled;
internal BaseLayerProperty()
{
@ -85,6 +85,8 @@ namespace Artemis.Core.Models.Profile.LayerProperties
internal PropertyEntity PropertyEntity { get; set; }
internal LayerPropertyGroup LayerPropertyGroup { get; set; }
public abstract void ApplyDefaultValue();
/// <summary>
/// Applies the provided property entity to the layer property by deserializing the JSON base value and keyframe values
@ -113,7 +115,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties
public event EventHandler BaseValueChanged;
/// <summary>
/// Occurs when the <see cref="IsHidden"/> value of the layer property was updated
/// Occurs when the <see cref="IsHidden" /> value of the layer property was updated
/// </summary>
public event EventHandler VisibilityChanged;
@ -163,9 +165,5 @@ namespace Artemis.Core.Models.Profile.LayerProperties
}
#endregion
public abstract void ApplyDefaultValue();
}
}

View File

@ -56,7 +56,8 @@ namespace Artemis.Core.Models.Profile.LayerProperties
}
/// <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
/// </summary>
public T DefaultValue { get; set; }
@ -166,6 +167,12 @@ namespace Artemis.Core.Models.Profile.LayerProperties
RemoveKeyframe(layerPropertyKeyframe);
}
public override void ApplyDefaultValue()
{
BaseValue = DefaultValue;
CurrentValue = DefaultValue;
}
/// <summary>
/// Called every update (if keyframes are both supported and enabled) to determine the new <see cref="CurrentValue" />
/// based on the provided progress
@ -284,11 +291,5 @@ namespace Artemis.Core.Models.Profile.LayerProperties
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;
}
public static implicit operator ColorGradient(ColorGradientLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
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
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;
}
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)
{
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

@ -1,19 +1,26 @@
namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
/// <inheritdoc/>
/// <inheritdoc />
public class FloatLayerProperty : LayerProperty<float>
{
internal FloatLayerProperty()
{
}
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)
{
var diff = NextKeyframe.Value - CurrentKeyframe.Value;
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

@ -2,21 +2,32 @@
namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
/// <inheritdoc/>
/// <inheritdoc />
public class IntLayerProperty : LayerProperty<int>
{
internal IntLayerProperty()
{
}
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)
{
var diff = NextKeyframe.Value - CurrentKeyframe.Value;
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;
}
public static implicit operator LayerBrushReference(LayerBrushReferenceLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
throw new ArtemisCoreException("Layer brush references do not support keyframes.");
}
public static implicit operator LayerBrushReference(LayerBrushReferenceLayerProperty p) => p.CurrentValue;
}
}

View File

@ -3,13 +3,18 @@ using SkiaSharp;
namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
/// <inheritdoc/>
/// <inheritdoc />
public class SKColorLayerProperty : LayerProperty<SKColor>
{
internal SKColorLayerProperty()
{
}
public static implicit operator SKColor(SKColorLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
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));
}
public static implicit operator SKColor(SKColorLayerProperty p) => p.CurrentValue;
}
}

View File

@ -2,20 +2,23 @@
namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
/// <inheritdoc/>
/// <inheritdoc />
public class SKPointLayerProperty : LayerProperty<SKPoint>
{
internal SKPointLayerProperty()
{
}
public static implicit operator SKPoint(SKPointLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
var xDiff = NextKeyframe.Value.X - CurrentKeyframe.Value.X;
var yDiff = NextKeyframe.Value.Y - CurrentKeyframe.Value.Y;
CurrentValue = new SKPoint(CurrentKeyframe.Value.X + xDiff * keyframeProgressEased, CurrentKeyframe.Value.Y + yDiff * keyframeProgressEased);
}
public static implicit operator SKPoint(SKPointLayerProperty p) => p.CurrentValue;
}
}

View File

@ -2,20 +2,23 @@
namespace Artemis.Core.Models.Profile.LayerProperties.Types
{
/// <inheritdoc/>
/// <inheritdoc />
public class SKSizeLayerProperty : LayerProperty<SKSize>
{
internal SKSizeLayerProperty()
{
}
public static implicit operator SKSize(SKSizeLayerProperty p)
{
return p.CurrentValue;
}
protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased)
{
var widthDiff = NextKeyframe.Value.Width - CurrentKeyframe.Value.Width;
var heightDiff = NextKeyframe.Value.Height - CurrentKeyframe.Value.Height;
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;
}
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>
/// Called before properties are fully initialized to allow you to populate
/// <see cref="LayerProperty{T}.DefaultValue" /> on the properties you want
@ -280,20 +295,5 @@ namespace Artemis.Core.Models.Profile
}
#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()
{
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>
public bool HasConfigurationViewModel { get; protected set; }
public void Dispose()
{
DisablePlugin();
}
/// <summary>
/// Called when the plugin is activated
/// </summary>
@ -59,11 +64,6 @@ namespace Artemis.Core.Plugins.Abstract
}
}
public void Dispose()
{
DisablePlugin();
}
#region Events
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
// to COM components. If you need to access a type in this assembly from

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Artemis.Core.Events;
using Artemis.Core.Exceptions;
using Artemis.Core.JsonConverters;
@ -10,7 +9,6 @@ using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Storage.Interfaces;
using Artemis.Storage;
using Artemis.Storage.Migrations.Interfaces;
using Newtonsoft.Json;
using RGB.NET.Core;
using Serilog;
@ -29,8 +27,8 @@ namespace Artemis.Core.Services
private readonly IProfileService _profileService;
private readonly IRgbService _rgbService;
private readonly ISurfaceService _surfaceService;
private readonly PluginSetting<LogEventLevel> _loggingLevel;
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
internal CoreService(ILogger logger, StorageMigrationService _, ISettingsService settingsService, IPluginService pluginService,
@ -66,24 +64,6 @@ namespace Artemis.Core.Services
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()
{
if (IsInitialized)
@ -107,6 +87,24 @@ namespace Artemis.Core.Services
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()
{
_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.LayerEffect;
using Artemis.Core.Plugins.LayerEffect.Abstract;
using Artemis.Storage.Entities.Profile;
namespace Artemis.Core.Services.Interfaces
{

View File

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

View File

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

View File

@ -4,7 +4,6 @@ using Artemis.Core.Events;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Storage.Interfaces;
using Artemis.Storage.Entities.Profile;
@ -214,9 +213,7 @@ namespace Artemis.Core.Services.Storage
private void OnPluginLoaded(object sender, PluginEventArgs e)
{
if (e.PluginInfo.Instance is LayerBrushProvider)
{
ActiveProfilesInstantiateProfileLayerBrushes();
}
else if (e.PluginInfo.Instance is ProfileModule 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
_rgbService.UpdateSurfaceLedGroup();
OnActiveSurfaceConfigurationChanged(new SurfaceConfigurationEventArgs(ActiveSurface));
}
public void UpdateSurfaceConfiguration(ArtemisSurface surface, bool includeDevices)

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using LiteDB;
namespace Artemis.Storage.Entities.Profile
@ -33,6 +32,4 @@ namespace Artemis.Storage.Entities.Profile
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
{

View File

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

View File

@ -9,8 +9,8 @@ namespace Artemis.Storage
public class StorageMigrationService
{
private readonly ILogger _logger;
private readonly LiteRepository _repository;
private readonly List<IStorageMigration> _migrations;
private readonly LiteRepository _repository;
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 Artemis.Core.Models.Surface;
using RGB.NET.Core;
using Stylet;
namespace Artemis.UI.Shared.Controls
{
@ -37,19 +36,6 @@ namespace Artemis.UI.Shared.Controls
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
{
get => (ArtemisDevice) GetValue(DeviceProperty);
@ -99,6 +85,19 @@ namespace Artemis.UI.Shared.Controls
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)
{
var deviceVisualizer = (DeviceVisualizer) d;

View File

@ -34,6 +34,41 @@ namespace Artemis.UI.Shared.Controls
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()
{
// The minimum required size for geometry to be created
@ -105,40 +140,5 @@ namespace Artemis.UI.Shared.Controls
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(DraggableFloat));
public event EventHandler DragStarted;
public event EventHandler DragEnded;
private bool _calledDragStarted;
private bool _inCallback;
private Point _mouseDragStartPoint;
private float _startValue;
private bool _calledDragStarted;
public DraggableFloat()
{
@ -51,11 +49,24 @@ namespace Artemis.UI.Shared.Controls
public event PropertyChangedEventHandler PropertyChanged;
public event EventHandler DragStarted;
public event EventHandler DragEnded;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
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)
{
var draggableFloat = (DraggableFloat) d;
@ -149,15 +160,5 @@ namespace Artemis.UI.Shared.Controls
{
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,9 +37,10 @@
Background="{StaticResource Checkerboard}">
<Rectangle Stroke="{DynamicResource NormalBorderBrush}" Cursor="Hand" MouseUp="UIElement_OnMouseUp">
<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"
StartPoint="0,0"/>
StartPoint="0,0" />
</Rectangle.Fill>
</Rectangle>
</Border>

View File

@ -1,11 +1,9 @@
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Colors;
using Artemis.UI.Shared.Annotations;
using Artemis.UI.Shared.Services.Interfaces;
@ -21,9 +19,6 @@ namespace Artemis.UI.Shared.Controls
private static IGradientPickerService _gradientPickerService;
private bool _inCallback;
public event EventHandler DialogOpened;
public event EventHandler DialogClosed;
public GradientPicker()
{
InitializeComponent();
@ -63,12 +58,25 @@ namespace Artemis.UI.Shared.Controls
public event PropertyChangedEventHandler PropertyChanged;
public event EventHandler DialogOpened;
public event EventHandler DialogClosed;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
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)
{
var gradientPicker = (GradientPicker) d;
@ -102,15 +110,5 @@ namespace Artemis.UI.Shared.Controls
EventManager.RegisterRoutedEvent(nameof(ColorGradient), RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler<ColorGradient>), typeof(GradientPicker));
#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.Windows.Data;
using System.Windows.Media;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Colors;
using SkiaSharp;
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;
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;
// Setting ComVisible to false makes the types in this assembly not visible

View File

@ -21,7 +21,7 @@
<DataTemplate>
<StackPanel>
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Text="Stack trace"
TextWrapping="Wrap" FontWeight="Bold"/>
TextWrapping="Wrap" FontWeight="Bold" />
<avalonedit:TextEditor SyntaxHighlighting="C#"
FontFamily="pack://application:,,,/Resources/Fonts/#Roboto Mono"
@ -32,7 +32,7 @@
VerticalScrollBarVisibility="Auto"
MaxWidth="1000"
Margin="0 10 10 0"
Padding="10"/>
Padding="10" />
<Separator Margin="0 15" />
</StackPanel>

View File

@ -32,13 +32,13 @@ namespace Artemis.UI.Shared.Screens.Dialogs
public class DialogException
{
public Exception Exception { get; }
public IDocument Document { get; set; }
public DialogException(Exception exception)
{
Exception = exception;
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.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Colors;
using Artemis.UI.Shared.Utilities;
using Stylet;
@ -25,11 +23,6 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
ColorStop.PropertyChanged += ColorStopOnPropertyChanged;
}
private void ColorStopOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
_gradientEditorViewModel.ColorGradient.OnColorValuesUpdated();
}
public ColorGradientStop ColorStop { get; }
public double Offset
@ -66,6 +59,11 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
set => SetAndNotify(ref _willRemoveColorStop, value);
}
private void ColorStopOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
_gradientEditorViewModel.ColorGradient.OnColorValuesUpdated();
}
#region Movement
public void StopMouseDown(object sender, MouseButtonEventArgs e)

View File

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

View File

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

View File

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

View File

@ -7,7 +7,8 @@ namespace Artemis.UI.Shared.Utilities
public static class HitTestUtilities
{
/// <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>
/// <typeparam name="T"></typeparam>
/// <param name="container"></param>

View File

@ -1,44 +1,17 @@
using System;
using System.Reflection;
using System.Runtime.InteropServices;
namespace Artemis.UI.Shared.Utilities
{
public class ShortcutUtilities
{
private static Type m_type = Type.GetTypeFromProgID("WScript.Shell");
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();
}
private static readonly Type m_type = Type.GetTypeFromProgID("WScript.Shell");
private static readonly object m_shell = Activator.CreateInstance(m_type);
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.Hotkey = hotkey;
shortcut.TargetPath = targetPath;
@ -48,5 +21,117 @@ namespace Artemis.UI.Shared.Utilities
shortcut.IconLocation = iconPath;
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 string Label { get; }
public RequestSelectSidebarItemEvent(string 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.Module.ProfileEditor;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.PropertyInput;
using Artemis.UI.Shared.Services.Dialog;
using Artemis.UI.Stylet;
using FluentValidation;

View File

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

View File

@ -26,8 +26,8 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<materialDesign:PackIcon Grid.Row="0" Grid.RowSpan="2" Kind="{Binding Icon}" Height="20" Width="20" Margin="-5 -2 10 0" VerticalAlignment="Center"/>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding DisplayName}" TextWrapping="Wrap" MaxWidth="350"/>
<materialDesign:PackIcon Grid.Row="0" Grid.RowSpan="2" Kind="{Binding Icon}" Height="20" Width="20" Margin="-5 -2 10 0" VerticalAlignment="Center" />
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding DisplayName}" TextWrapping="Wrap" MaxWidth="350" />
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Description}" TextWrapping="Wrap" MaxWidth="350" Foreground="{DynamicResource MaterialDesignNavigationItemSubheader}" />
</Grid>
</ControlTemplate>

View File

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

View File

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

View File

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

View File

@ -20,7 +20,7 @@
Conditions are not yet implemented
</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}" TextWrapping="Wrap" HorizontalAlignment="Center">
Conditions will allow you to easily configure when a layer should be shown.<LineBreak/><LineBreak/>
Conditions will allow you to easily configure when a layer should be shown.<LineBreak /><LineBreak />
You'll also use this to set up how a layer reacts to its conditions being matched, like play the timeline once or keep repeating the timeline until the conditions are no longer matched.
</TextBlock>
</StackPanel>

View File

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

View File

@ -136,7 +136,7 @@
</Border>
</ScrollViewer>
<materialDesign:TransitionerSlide >
<materialDesign:TransitionerSlide>
<materialDesign:TransitionerSlide.BackwardWipe>
<materialDesign:CircleWipe />
</materialDesign:TransitionerSlide.BackwardWipe>

View File

@ -8,7 +8,6 @@ using Artemis.Core.Events;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject.Factories;
@ -62,6 +61,21 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
public EffectsViewModel EffectsViewModel { 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()
{
PopulateProperties(ProfileEditorService.SelectedProfileElement);
@ -115,10 +129,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
private void PopulateProperties(ProfileElement profileElement)
{
if (SelectedFolder != null)
{
SelectedFolder = null;
}
if (SelectedFolder != null) SelectedFolder = null;
if (SelectedLayer != null)
{
@ -133,9 +144,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
_brushPropertyGroup = null;
if (profileElement is Folder folder)
{
SelectedFolder = folder;
}
else if (profileElement is Layer layer)
{
SelectedLayer = layer;
@ -389,20 +398,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
}
#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 Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Exceptions;
using Artemis.UI.PropertyInput;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree;
using Artemis.UI.PropertyInput;
using Artemis.UI.Shared.PropertyInput;
using Artemis.UI.Shared.Services.Interfaces;
using Humanizer;

View File

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

View File

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

View File

@ -2,7 +2,6 @@
using System.Linq;
using Artemis.UI.Exceptions;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
using Stylet;
@ -23,17 +22,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
_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 override void UpdateKeyframes()
@ -53,9 +41,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
);
}
else
{
TimelineKeyframeViewModels.Clear();
}
foreach (var timelineKeyframeViewModel in TimelineKeyframeViewModels)
timelineKeyframeViewModel.Update(_profileEditorService.PixelsPerSecond);
@ -68,6 +54,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
LayerPropertyViewModel.LayerProperty.KeyframeRemoved -= 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
@ -82,8 +79,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
public TimelineViewModel TimelineViewModel { get; set; }
public BindableCollection<TimelineKeyframeViewModel> TimelineKeyframeViewModels { get; set; }
public abstract void UpdateKeyframes();
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
{
private readonly IProfileEditorService _profileEditorService;
private readonly ILayerService _layerService;
private readonly IDialogService _dialogService;
private readonly ILayerService _layerService;
private readonly IProfileEditorService _profileEditorService;
public TreePropertyGroupViewModel(LayerPropertyBaseViewModel layerPropertyBaseViewModel,
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.DisplayConditions;
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.Visualization;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
using Stylet;

View File

@ -54,7 +54,7 @@
materialDesign:RippleAssist.IsCentered="True"
ToolTip="Add new folder to root"
Command="{s:Action AddFolder}">
<materialDesign:PackIcon Kind="CreateNewFolder" Width="15"/>
<materialDesign:PackIcon Kind="CreateNewFolder" Width="15" />
</Button>
<Button Style="{StaticResource MaterialDesignIconForegroundButton}"
Width="30"
@ -63,7 +63,7 @@
materialDesign:RippleAssist.IsCentered="True"
ToolTip="Add new layer to root"
Command="{s:Action AddLayer}">
<materialDesign:PackIcon Kind="LayersPlus" Width="15"/>
<materialDesign:PackIcon Kind="LayersPlus" Width="15" />
</Button>
</StackPanel>
</Grid>

View File

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

View File

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

View File

@ -32,7 +32,7 @@
Margin="5 0 0 0"
ToolTip="{Binding Layer.LayerBrush.Descriptor.DisplayName, Mode=OneWay}"
Visibility="{Binding ShowIcons, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"
Background="Transparent"/>
Background="Transparent" />
<TextBlock Text="{Binding Layer.Name}" Margin="5 0 0 0" />
</StackPanel>
</StackPanel>

View File

@ -1,7 +1,6 @@
using Artemis.Core.Models.Profile;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
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 bool ShowIcons => Layer?.LayerBrush != null;
public override bool SupportsChildren => false;
}
}

View File

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

View File

@ -16,7 +16,7 @@
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="Gray" Duration="0:0:0.5"/>
<ColorAnimation Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="Gray" Duration="0:0:0.5" />
<DoubleAnimation Storyboard.TargetProperty="(Path.StrokeThickness)" To="0.5" Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
@ -24,7 +24,7 @@
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="{StaticResource Accent700}" Duration="0:0:0.5"/>
<ColorAnimation Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="{StaticResource Accent700}" Duration="0:0:0.5" />
<DoubleAnimation Storyboard.TargetProperty="(Path.StrokeThickness)" To="1" Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
@ -69,7 +69,6 @@
StrokeThickness="1"
StrokeLineJoin="Round"
x:Name="LayerPath"
Style="{StaticResource SelectedLayerStyle}">
</Path>
Style="{StaticResource SelectedLayerStyle}" />
</Canvas>
</UserControl>

View File

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

View File

@ -124,7 +124,7 @@
<DataTemplate>
<controls:DeviceVisualizer Device="{Binding}"
ShowColors="True"
HighlightedLeds="{Binding DataContext.HighlightedLeds, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Mode=OneWay}"/>
HighlightedLeds="{Binding DataContext.HighlightedLeds, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Mode=OneWay}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,6 @@
using System;
using System.Windows;
using System.Windows.Input;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
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.Windows;
using System.Windows.Input;
@ -17,9 +16,9 @@ namespace Artemis.UI.Screens
public class RootViewModel : Conductor<IScreen>
{
private readonly IEventAggregator _eventAggregator;
private readonly PluginSetting<ApplicationColorScheme> _colorScheme;
private bool _lostFocus;
private PluginSetting<ApplicationColorScheme> _colorScheme;
private ThemeWatcher _themeWatcher;
private readonly ThemeWatcher _themeWatcher;
public RootViewModel(IEventAggregator eventAggregator, SidebarViewModel sidebarViewModel, ISettingsService settingsService)
{

View File

@ -3,10 +3,8 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Artemis.Core;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Services;
using Artemis.Core.Services.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.Shared.Services.Interfaces;
using Artemis.UI.Shared.Utilities;
using Artemis.UI.Utilities;
using Microsoft.Win32;
using Ninject;
using Serilog.Events;
using Stylet;

View File

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

View File

@ -1,15 +1,4 @@
using System;
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;
using System.Windows.Controls;
namespace Artemis.UI.Screens.Settings.Tabs.Plugins
{

View File

@ -1,7 +1,6 @@
using System;
using System.Threading.Tasks;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
@ -33,6 +32,29 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
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()
{
if (PluginInfo.Icon != null)
@ -61,29 +83,6 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
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)
{
if (PluginInfo.Enabled == enable)

View File

@ -18,6 +18,6 @@
d:DataContext="{d:DesignInstance local:PluginSettingsWindowViewModel}"
Icon="/Resources/Images/Logo/logo-512.png">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
<ContentControl s:View.Model="{Binding ActiveItem}"/>
<ContentControl s:View.Model="{Binding ActiveItem}" />
</ScrollViewer>
</controls:MaterialWindow>

View File

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

View File

@ -26,7 +26,7 @@
<RotateTransform Angle="{Binding Device.Rotation}" />
</Grid.RenderTransform>
<controls:DeviceVisualizer Device="{Binding Device}"/>
<controls:DeviceVisualizer Device="{Binding Device}" />
<Rectangle Fill="{DynamicResource MaterialDesignCardBackground}"
Stroke="{DynamicResource MaterialDesignTextBoxBorder}"

View File

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

View File

@ -3,11 +3,10 @@ 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.Controls;
using Artemis.UI.Shared.Services.Interfaces;
using Ninject;
using Stylet;
using GradientPicker = Artemis.UI.Shared.Controls.GradientPicker;
namespace Artemis.UI.Screens
{

View File

@ -3,10 +3,8 @@ using System.Windows;
using System.Windows.Media;
using Artemis.Core;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Colors;
using Artemis.Core.Services;
using Artemis.UI.PropertyInput;
using Artemis.UI.PropertyInput;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
using SkiaSharp;
@ -16,8 +14,8 @@ namespace Artemis.UI.Services
{
public class LayerEditorService : ILayerEditorService
{
private readonly ISettingsService _settingsService;
private readonly IProfileEditorService _profileEditorService;
private readonly ISettingsService _settingsService;
public LayerEditorService(ISettingsService settingsService, IProfileEditorService profileEditorService)
{
@ -26,17 +24,6 @@ namespace Artemis.UI.Services
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 />
public Rect GetLayerBounds(Layer layer)
{
@ -151,5 +138,16 @@ namespace Artemis.UI.Services
// The difference between the two is the offset
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 System.Collections.Generic;
using System.Reflection;
using Stylet;
using Stylet;
namespace Artemis.UI.Stylet
{