mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 09:43:46 +00:00
Profiles - Added toggle to enable/disable folders, layers and effects
Profiles - Fixed folders not saving they children properly UI - Show version and frame time in window title
This commit is contained in:
parent
7921a4f932
commit
0903865c7d
@ -62,7 +62,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
if (Parent is EffectProfileElement effectParent)
|
if (Parent is EffectProfileElement effectParent)
|
||||||
shapeClip = shapeClip.Op(effectParent.CreateShapeClip(), SKPathOp.Union);
|
shapeClip = shapeClip.Op(effectParent.CreateShapeClip(), SKPathOp.Union);
|
||||||
|
|
||||||
foreach (var baseLayerEffect in LayerEffects)
|
foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled))
|
||||||
{
|
{
|
||||||
var effectClip = baseLayerEffect.InternalCreateShapeClip(Path);
|
var effectClip = baseLayerEffect.InternalCreateShapeClip(Path);
|
||||||
shapeClip = shapeClip.Op(effectClip, SKPathOp.Difference);
|
shapeClip = shapeClip.Op(effectClip, SKPathOp.Difference);
|
||||||
@ -82,6 +82,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
PluginGuid = layerEffect.PluginInfo.Guid,
|
PluginGuid = layerEffect.PluginInfo.Guid,
|
||||||
EffectType = layerEffect.GetType().Name,
|
EffectType = layerEffect.GetType().Name,
|
||||||
Name = layerEffect.Name,
|
Name = layerEffect.Name,
|
||||||
|
Enabled = layerEffect.Enabled,
|
||||||
HasBeenRenamed = layerEffect.HasBeenRenamed,
|
HasBeenRenamed = layerEffect.HasBeenRenamed,
|
||||||
Order = layerEffect.Order
|
Order = layerEffect.Order
|
||||||
};
|
};
|
||||||
|
|||||||
@ -17,6 +17,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
Profile = profile;
|
Profile = profile;
|
||||||
Parent = parent;
|
Parent = parent;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
Enabled = true;
|
||||||
|
|
||||||
_layerEffects = new List<BaseLayerEffect>();
|
_layerEffects = new List<BaseLayerEffect>();
|
||||||
_expandedPropertyGroups = new List<string>();
|
_expandedPropertyGroups = new List<string>();
|
||||||
@ -31,6 +32,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
Profile = profile;
|
Profile = profile;
|
||||||
Parent = parent;
|
Parent = parent;
|
||||||
Name = folderEntity.Name;
|
Name = folderEntity.Name;
|
||||||
|
Enabled = folderEntity.Enabled;
|
||||||
Order = folderEntity.Order;
|
Order = folderEntity.Order;
|
||||||
|
|
||||||
_layerEffects = new List<BaseLayerEffect>();
|
_layerEffects = new List<BaseLayerEffect>();
|
||||||
@ -58,7 +60,10 @@ namespace Artemis.Core.Models.Profile
|
|||||||
|
|
||||||
public override void Update(double deltaTime)
|
public override void Update(double deltaTime)
|
||||||
{
|
{
|
||||||
foreach (var baseLayerEffect in LayerEffects)
|
if (!Enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled))
|
||||||
baseLayerEffect.Update(deltaTime);
|
baseLayerEffect.Update(deltaTime);
|
||||||
|
|
||||||
// Iterate the children in reverse because that's how they must be rendered too
|
// Iterate the children in reverse because that's how they must be rendered too
|
||||||
@ -71,6 +76,12 @@ namespace Artemis.Core.Models.Profile
|
|||||||
|
|
||||||
public override void Render(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint)
|
public override void Render(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint)
|
||||||
{
|
{
|
||||||
|
if (!Enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Path == null)
|
||||||
|
return;
|
||||||
|
|
||||||
canvas.Save();
|
canvas.Save();
|
||||||
canvas.ClipPath(Path);
|
canvas.ClipPath(Path);
|
||||||
|
|
||||||
@ -79,7 +90,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
|
|
||||||
// Pre-processing only affects other pre-processors and the brushes
|
// Pre-processing only affects other pre-processors and the brushes
|
||||||
canvas.Save();
|
canvas.Save();
|
||||||
foreach (var baseLayerEffect in LayerEffects)
|
foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled))
|
||||||
baseLayerEffect.InternalPreProcess(canvas, canvasInfo, new SKPath(Path), groupPaint);
|
baseLayerEffect.InternalPreProcess(canvas, canvasInfo, new SKPath(Path), groupPaint);
|
||||||
|
|
||||||
// Iterate the children in reverse because the first layer must be rendered last to end up on top
|
// Iterate the children in reverse because the first layer must be rendered last to end up on top
|
||||||
@ -91,12 +102,17 @@ namespace Artemis.Core.Models.Profile
|
|||||||
|
|
||||||
// Restore the canvas as to not be affected by pre-processors
|
// Restore the canvas as to not be affected by pre-processors
|
||||||
canvas.Restore();
|
canvas.Restore();
|
||||||
foreach (var baseLayerEffect in LayerEffects)
|
foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled))
|
||||||
baseLayerEffect.InternalPostProcess(canvas, canvasInfo, new SKPath(Path), groupPaint);
|
baseLayerEffect.InternalPostProcess(canvas, canvasInfo, new SKPath(Path), groupPaint);
|
||||||
|
|
||||||
canvas.Restore();
|
canvas.Restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new folder to the bottom of this folder
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public Folder AddFolder(string name)
|
public Folder AddFolder(string name)
|
||||||
{
|
{
|
||||||
var folder = new Folder(Profile, this, name) {Order = Children.LastOrDefault()?.Order ?? 1};
|
var folder = new Folder(Profile, this, name) {Order = Children.LastOrDefault()?.Order ?? 1};
|
||||||
@ -104,6 +120,20 @@ namespace Artemis.Core.Models.Profile
|
|||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void AddChild(ProfileElement child, int? order = null)
|
||||||
|
{
|
||||||
|
base.AddChild(child, order);
|
||||||
|
CalculateRenderProperties();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void RemoveChild(ProfileElement child)
|
||||||
|
{
|
||||||
|
base.RemoveChild(child);
|
||||||
|
CalculateRenderProperties();
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"[Folder] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
|
return $"[Folder] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
|
||||||
@ -134,6 +164,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
|
|
||||||
FolderEntity.Order = Order;
|
FolderEntity.Order = Order;
|
||||||
FolderEntity.Name = Name;
|
FolderEntity.Name = Name;
|
||||||
|
FolderEntity.Enabled = Enabled;
|
||||||
|
|
||||||
FolderEntity.ProfileId = Profile.EntityId;
|
FolderEntity.ProfileId = Profile.EntityId;
|
||||||
|
|
||||||
@ -152,5 +183,12 @@ namespace Artemis.Core.Models.Profile
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
internal void Deactivate()
|
||||||
|
{
|
||||||
|
var layerEffects = new List<BaseLayerEffect>(LayerEffects);
|
||||||
|
foreach (var baseLayerEffect in layerEffects)
|
||||||
|
DeactivateLayerEffect(baseLayerEffect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,6 +34,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
Profile = profile;
|
Profile = profile;
|
||||||
Parent = parent;
|
Parent = parent;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
Enabled = true;
|
||||||
General = new LayerGeneralProperties {IsCorePropertyGroup = true};
|
General = new LayerGeneralProperties {IsCorePropertyGroup = true};
|
||||||
Transform = new LayerTransformProperties {IsCorePropertyGroup = true};
|
Transform = new LayerTransformProperties {IsCorePropertyGroup = true};
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
Profile = profile;
|
Profile = profile;
|
||||||
Parent = parent;
|
Parent = parent;
|
||||||
Name = layerEntity.Name;
|
Name = layerEntity.Name;
|
||||||
|
Enabled = layerEntity.Enabled;
|
||||||
Order = layerEntity.Order;
|
Order = layerEntity.Order;
|
||||||
General = new LayerGeneralProperties {IsCorePropertyGroup = true};
|
General = new LayerGeneralProperties {IsCorePropertyGroup = true};
|
||||||
Transform = new LayerTransformProperties {IsCorePropertyGroup = true};
|
Transform = new LayerTransformProperties {IsCorePropertyGroup = true};
|
||||||
@ -111,6 +113,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
LayerEntity.Id = EntityId;
|
LayerEntity.Id = EntityId;
|
||||||
LayerEntity.ParentId = Parent?.EntityId ?? new Guid();
|
LayerEntity.ParentId = Parent?.EntityId ?? new Guid();
|
||||||
LayerEntity.Order = Order;
|
LayerEntity.Order = Order;
|
||||||
|
LayerEntity.Enabled = Enabled;
|
||||||
LayerEntity.Name = Name;
|
LayerEntity.Name = Name;
|
||||||
LayerEntity.ProfileId = Profile.EntityId;
|
LayerEntity.ProfileId = Profile.EntityId;
|
||||||
LayerEntity.ExpandedPropertyGroups.Clear();
|
LayerEntity.ExpandedPropertyGroups.Clear();
|
||||||
@ -177,6 +180,9 @@ namespace Artemis.Core.Models.Profile
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Update(double deltaTime)
|
public override void Update(double deltaTime)
|
||||||
{
|
{
|
||||||
|
if (!Enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
if (LayerBrush?.BaseProperties == null || !LayerBrush.BaseProperties.PropertiesInitialized)
|
if (LayerBrush?.BaseProperties == null || !LayerBrush.BaseProperties.PropertiesInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -192,7 +198,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
General.Override(TimeSpan.Zero);
|
General.Override(TimeSpan.Zero);
|
||||||
Transform.Override(TimeSpan.Zero);
|
Transform.Override(TimeSpan.Zero);
|
||||||
LayerBrush.BaseProperties.Override(TimeSpan.Zero);
|
LayerBrush.BaseProperties.Override(TimeSpan.Zero);
|
||||||
foreach (var baseLayerEffect in LayerEffects)
|
foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled))
|
||||||
baseLayerEffect.BaseProperties?.Override(TimeSpan.Zero);
|
baseLayerEffect.BaseProperties?.Override(TimeSpan.Zero);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -200,12 +206,12 @@ namespace Artemis.Core.Models.Profile
|
|||||||
General.Update(deltaTime);
|
General.Update(deltaTime);
|
||||||
Transform.Update(deltaTime);
|
Transform.Update(deltaTime);
|
||||||
LayerBrush.BaseProperties.Update(deltaTime);
|
LayerBrush.BaseProperties.Update(deltaTime);
|
||||||
foreach (var baseLayerEffect in LayerEffects)
|
foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled))
|
||||||
baseLayerEffect.BaseProperties?.Update(deltaTime);
|
baseLayerEffect.BaseProperties?.Update(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerBrush.Update(deltaTime);
|
LayerBrush.Update(deltaTime);
|
||||||
foreach (var baseLayerEffect in LayerEffects)
|
foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled))
|
||||||
baseLayerEffect.Update(deltaTime);
|
baseLayerEffect.Update(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,6 +227,9 @@ namespace Artemis.Core.Models.Profile
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Render(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint)
|
public override void Render(double deltaTime, SKCanvas canvas, SKImageInfo canvasInfo, SKPaint paint)
|
||||||
{
|
{
|
||||||
|
if (!Enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
// Ensure the layer is ready
|
// Ensure the layer is ready
|
||||||
if (Path == null || LayerShape?.Path == null || !General.PropertiesInitialized || !Transform.PropertiesInitialized)
|
if (Path == null || LayerShape?.Path == null || !General.PropertiesInitialized || !Transform.PropertiesInitialized)
|
||||||
return;
|
return;
|
||||||
@ -230,13 +239,13 @@ namespace Artemis.Core.Models.Profile
|
|||||||
|
|
||||||
canvas.Save();
|
canvas.Save();
|
||||||
canvas.ClipPath(Path);
|
canvas.ClipPath(Path);
|
||||||
|
|
||||||
paint.BlendMode = General.BlendMode.CurrentValue;
|
paint.BlendMode = General.BlendMode.CurrentValue;
|
||||||
paint.Color = new SKColor(0, 0, 0, (byte) (Transform.Opacity.CurrentValue * 2.55f));
|
paint.Color = new SKColor(0, 0, 0, (byte) (Transform.Opacity.CurrentValue * 2.55f));
|
||||||
|
|
||||||
// Pre-processing only affects other pre-processors and the brushes
|
// Pre-processing only affects other pre-processors and the brushes
|
||||||
canvas.Save();
|
canvas.Save();
|
||||||
foreach (var baseLayerEffect in LayerEffects)
|
foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled))
|
||||||
baseLayerEffect.InternalPreProcess(canvas, canvasInfo, new SKPath(Path), paint);
|
baseLayerEffect.InternalPreProcess(canvas, canvasInfo, new SKPath(Path), paint);
|
||||||
|
|
||||||
// Shape clip must be determined before commiting to any rendering
|
// Shape clip must be determined before commiting to any rendering
|
||||||
@ -253,9 +262,9 @@ namespace Artemis.Core.Models.Profile
|
|||||||
|
|
||||||
// Restore the canvas as to not be affected by pre-processors
|
// Restore the canvas as to not be affected by pre-processors
|
||||||
canvas.Restore();
|
canvas.Restore();
|
||||||
foreach (var baseLayerEffect in LayerEffects)
|
foreach (var baseLayerEffect in LayerEffects.Where(e => e.Enabled))
|
||||||
baseLayerEffect.InternalPostProcess(canvas, canvasInfo, new SKPath(Path), paint);
|
baseLayerEffect.InternalPostProcess(canvas, canvasInfo, new SKPath(Path), paint);
|
||||||
|
|
||||||
canvas.Restore();
|
canvas.Restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
UndoStack = new Stack<string>();
|
UndoStack = new Stack<string>();
|
||||||
RedoStack = new Stack<string>();
|
RedoStack = new Stack<string>();
|
||||||
|
|
||||||
AddChild(new Folder(this, null, "Root folder"));
|
AddChild(new Folder(this, this, "Root folder"));
|
||||||
ApplyToEntity();
|
ApplyToEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,13 +80,18 @@ namespace Artemis.Core.Models.Profile
|
|||||||
|
|
||||||
lock (_children)
|
lock (_children)
|
||||||
{
|
{
|
||||||
|
foreach (var folder in GetAllFolders())
|
||||||
|
folder.Deactivate();
|
||||||
|
foreach (var layer in GetAllLayers())
|
||||||
|
layer.Deactivate();
|
||||||
|
|
||||||
_children.Clear();
|
_children.Clear();
|
||||||
// Populate the profile starting at the root, the rest is populated recursively
|
// Populate the profile starting at the root, the rest is populated recursively
|
||||||
var rootFolder = ProfileEntity.Folders.FirstOrDefault(f => f.ParentId == new Guid());
|
var rootFolder = ProfileEntity.Folders.FirstOrDefault(f => f.ParentId == EntityId);
|
||||||
if (rootFolder == null)
|
if (rootFolder == null)
|
||||||
AddChild(new Folder(this, null, "Root folder"));
|
AddChild(new Folder(this, this, "Root folder"));
|
||||||
else
|
else
|
||||||
AddChild(new Folder(this, null, rootFolder));
|
AddChild(new Folder(this, this, rootFolder));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +137,8 @@ namespace Artemis.Core.Models.Profile
|
|||||||
if (!IsActivated)
|
if (!IsActivated)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
foreach (var folder in GetAllFolders())
|
||||||
|
folder.Deactivate();
|
||||||
foreach (var layer in GetAllLayers())
|
foreach (var layer in GetAllLayers())
|
||||||
layer.Deactivate();
|
layer.Deactivate();
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,11 @@ namespace Artemis.Core.Models.Profile
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the enabled state, if not enabled the element is skipped in render and update
|
||||||
|
/// </summary>
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the element
|
/// Updates the element
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -79,7 +84,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="child">The profile element to add</param>
|
/// <param name="child">The profile element to add</param>
|
||||||
/// <param name="order">The order where to place the child (1-based), defaults to the end of the collection</param>
|
/// <param name="order">The order where to place the child (1-based), defaults to the end of the collection</param>
|
||||||
public void AddChild(ProfileElement child, int? order = null)
|
public virtual void AddChild(ProfileElement child, int? order = null)
|
||||||
{
|
{
|
||||||
lock (_children)
|
lock (_children)
|
||||||
{
|
{
|
||||||
@ -88,23 +93,25 @@ namespace Artemis.Core.Models.Profile
|
|||||||
{
|
{
|
||||||
_children.Add(child);
|
_children.Add(child);
|
||||||
child.Order = _children.Count;
|
child.Order = _children.Count;
|
||||||
return;
|
}
|
||||||
|
// Shift everything after the given order
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var profileElement in _children.Where(c => c.Order >= order).ToList())
|
||||||
|
profileElement.Order++;
|
||||||
|
|
||||||
|
int targetIndex;
|
||||||
|
if (order == 0)
|
||||||
|
targetIndex = 0;
|
||||||
|
else if (order > _children.Count)
|
||||||
|
targetIndex = _children.Count;
|
||||||
|
else
|
||||||
|
targetIndex = _children.FindIndex(c => c.Order == order + 1);
|
||||||
|
|
||||||
|
_children.Insert(targetIndex, child);
|
||||||
|
child.Order = order.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shift everything after the given order
|
|
||||||
foreach (var profileElement in _children.Where(c => c.Order >= order).ToList())
|
|
||||||
profileElement.Order++;
|
|
||||||
|
|
||||||
int targetIndex;
|
|
||||||
if (order == 0)
|
|
||||||
targetIndex = 0;
|
|
||||||
else if (order > _children.Count)
|
|
||||||
targetIndex = _children.Count;
|
|
||||||
else
|
|
||||||
targetIndex = _children.FindIndex(c => c.Order == order + 1);
|
|
||||||
|
|
||||||
_children.Insert(targetIndex, child);
|
|
||||||
child.Order = order.Value;
|
|
||||||
child.Parent = this;
|
child.Parent = this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,7 +120,7 @@ namespace Artemis.Core.Models.Profile
|
|||||||
/// Removes a profile element from the <see cref="Children" /> collection
|
/// Removes a profile element from the <see cref="Children" /> collection
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="child">The profile element to remove</param>
|
/// <param name="child">The profile element to remove</param>
|
||||||
public void RemoveChild(ProfileElement child)
|
public virtual void RemoveChild(ProfileElement child)
|
||||||
{
|
{
|
||||||
lock (_children)
|
lock (_children)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -27,6 +27,11 @@ namespace Artemis.Core.Plugins.LayerEffect.Abstract
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the enabled state, if not enabled the effect is skipped in render and update
|
||||||
|
/// </summary>
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets whether the effect has been renamed by the user, if true consider refraining from changing the name
|
/// Gets or sets whether the effect has been renamed by the user, if true consider refraining from changing the name
|
||||||
/// programatically
|
/// programatically
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using Artemis.Core.Events;
|
using Artemis.Core.Events;
|
||||||
using Artemis.Core.Exceptions;
|
using Artemis.Core.Exceptions;
|
||||||
using Artemis.Core.JsonConverters;
|
using Artemis.Core.JsonConverters;
|
||||||
@ -23,11 +24,12 @@ namespace Artemis.Core.Services
|
|||||||
public class CoreService : ICoreService
|
public class CoreService : ICoreService
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
private readonly PluginSetting<LogEventLevel> _loggingLevel;
|
||||||
private readonly IPluginService _pluginService;
|
private readonly IPluginService _pluginService;
|
||||||
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 readonly Stopwatch _frameStopWatch;
|
||||||
private List<Module> _modules;
|
private List<Module> _modules;
|
||||||
|
|
||||||
// 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
|
||||||
@ -48,10 +50,13 @@ namespace Artemis.Core.Services
|
|||||||
_modules = _pluginService.GetPluginsOfType<Module>();
|
_modules = _pluginService.GetPluginsOfType<Module>();
|
||||||
_pluginService.PluginEnabled += (sender, args) => _modules = _pluginService.GetPluginsOfType<Module>();
|
_pluginService.PluginEnabled += (sender, args) => _modules = _pluginService.GetPluginsOfType<Module>();
|
||||||
_pluginService.PluginDisabled += (sender, args) => _modules = _pluginService.GetPluginsOfType<Module>();
|
_pluginService.PluginDisabled += (sender, args) => _modules = _pluginService.GetPluginsOfType<Module>();
|
||||||
|
|
||||||
|
_frameStopWatch = new Stopwatch();
|
||||||
|
|
||||||
ConfigureJsonConvert();
|
ConfigureJsonConvert();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TimeSpan FrameTime { get; private set; }
|
||||||
public bool ModuleUpdatingDisabled { get; set; }
|
public bool ModuleUpdatingDisabled { get; set; }
|
||||||
public bool ModuleRenderingDisabled { get; set; }
|
public bool ModuleRenderingDisabled { get; set; }
|
||||||
|
|
||||||
@ -117,6 +122,7 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
_frameStopWatch.Restart();
|
||||||
if (!ModuleUpdatingDisabled && _modules != null)
|
if (!ModuleUpdatingDisabled && _modules != null)
|
||||||
{
|
{
|
||||||
lock (_modules)
|
lock (_modules)
|
||||||
@ -157,6 +163,11 @@ namespace Artemis.Core.Services
|
|||||||
{
|
{
|
||||||
throw new ArtemisCoreException("Exception during update", e);
|
throw new ArtemisCoreException("Exception during update", e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_frameStopWatch.Stop();
|
||||||
|
FrameTime = _frameStopWatch.Elapsed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SurfaceOnUpdated(UpdatedEventArgs args)
|
private void SurfaceOnUpdated(UpdatedEventArgs args)
|
||||||
|
|||||||
@ -10,6 +10,11 @@ namespace Artemis.Core.Services.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsInitialized { get; }
|
bool IsInitialized { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The time the last frame took to render
|
||||||
|
/// </summary>
|
||||||
|
TimeSpan FrameTime { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets whether modules are updated each frame by calling their Update method
|
/// Gets or sets whether modules are updated each frame by calling their Update method
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -86,6 +86,7 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
effect.ProfileElement = effectElement;
|
effect.ProfileElement = effectElement;
|
||||||
effect.EntityId = Guid.NewGuid();
|
effect.EntityId = Guid.NewGuid();
|
||||||
|
effect.Enabled = true;
|
||||||
effect.Order = effectElement.LayerEffects.Count + 1;
|
effect.Order = effectElement.LayerEffects.Count + 1;
|
||||||
effect.Descriptor = layerEffectDescriptor;
|
effect.Descriptor = layerEffectDescriptor;
|
||||||
|
|
||||||
@ -109,15 +110,8 @@ namespace Artemis.Core.Services
|
|||||||
|
|
||||||
var layerEffectProviders = _pluginService.GetPluginsOfType<LayerEffectProvider>();
|
var layerEffectProviders = _pluginService.GetPluginsOfType<LayerEffectProvider>();
|
||||||
var descriptors = layerEffectProviders.SelectMany(l => l.LayerEffectDescriptors).ToList();
|
var descriptors = layerEffectProviders.SelectMany(l => l.LayerEffectDescriptors).ToList();
|
||||||
|
var entities = effectElement.EffectsEntity.LayerEffects.OrderByDescending(e => e.Order).ToList();
|
||||||
List<LayerEffectEntity> entities;
|
|
||||||
if (effectElement is Layer layer)
|
|
||||||
entities = layer.LayerEntity.LayerEffects.OrderByDescending(e => e.Order).ToList();
|
|
||||||
else if (effectElement is Folder folder)
|
|
||||||
entities = folder.FolderEntity.LayerEffects.OrderByDescending(e => e.Order).ToList();
|
|
||||||
else
|
|
||||||
throw new ArtemisCoreException("Provided effect element is of an unsupported type, must be Layer of Folder");
|
|
||||||
|
|
||||||
foreach (var layerEffectEntity in entities)
|
foreach (var layerEffectEntity in entities)
|
||||||
{
|
{
|
||||||
// Get a matching descriptor
|
// Get a matching descriptor
|
||||||
@ -133,6 +127,7 @@ namespace Artemis.Core.Services
|
|||||||
effect.EntityId = layerEffectEntity.Id;
|
effect.EntityId = layerEffectEntity.Id;
|
||||||
effect.Order = layerEffectEntity.Order;
|
effect.Order = layerEffectEntity.Order;
|
||||||
effect.Name = layerEffectEntity.Name;
|
effect.Name = layerEffectEntity.Name;
|
||||||
|
effect.Enabled = layerEffectEntity.Enabled;
|
||||||
effect.Descriptor = descriptor;
|
effect.Descriptor = descriptor;
|
||||||
|
|
||||||
effect.Initialize(this);
|
effect.Initialize(this);
|
||||||
|
|||||||
@ -19,6 +19,7 @@ namespace Artemis.Storage.Entities.Profile
|
|||||||
|
|
||||||
public int Order { get; set; }
|
public int Order { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
[BsonRef("ProfileEntity")]
|
[BsonRef("ProfileEntity")]
|
||||||
public ProfileEntity Profile { get; set; }
|
public ProfileEntity Profile { get; set; }
|
||||||
|
|||||||
@ -8,6 +8,7 @@ namespace Artemis.Storage.Entities.Profile
|
|||||||
public Guid PluginGuid { get; set; }
|
public Guid PluginGuid { get; set; }
|
||||||
public string EffectType { get; set; }
|
public string EffectType { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public bool Enabled { get; set; }
|
||||||
public bool HasBeenRenamed { get; set; }
|
public bool HasBeenRenamed { get; set; }
|
||||||
public int Order { get; set; }
|
public int Order { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ namespace Artemis.Storage.Entities.Profile
|
|||||||
|
|
||||||
public int Order { get; set; }
|
public int Order { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
public List<LedEntity> Leds { get; set; }
|
public List<LedEntity> Leds { get; set; }
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,34 @@
|
|||||||
|
using Artemis.Storage.Entities.Profile;
|
||||||
|
using Artemis.Storage.Migrations.Interfaces;
|
||||||
|
using LiteDB;
|
||||||
|
|
||||||
|
namespace Artemis.Storage.Migrations
|
||||||
|
{
|
||||||
|
public class ProfileEntitiesEnabledMigration : IStorageMigration
|
||||||
|
{
|
||||||
|
public int UserVersion => 2;
|
||||||
|
|
||||||
|
public void Apply(LiteRepository repository)
|
||||||
|
{
|
||||||
|
var profiles = repository.Query<ProfileEntity>().ToList();
|
||||||
|
foreach (var profileEntity in profiles)
|
||||||
|
{
|
||||||
|
foreach (var profileEntityFolder in profileEntity.Folders)
|
||||||
|
{
|
||||||
|
profileEntityFolder.Enabled = true;
|
||||||
|
foreach (var layerEffectEntity in profileEntityFolder.LayerEffects)
|
||||||
|
layerEffectEntity.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var profileEntityLayer in profileEntity.Layers)
|
||||||
|
{
|
||||||
|
profileEntityLayer.Enabled = true;
|
||||||
|
foreach (var layerEffectEntity in profileEntityLayer.LayerEffects)
|
||||||
|
layerEffectEntity.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
repository.Upsert(profileEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,7 +19,7 @@ namespace Artemis.UI.Shared.Services.Interfaces
|
|||||||
IKernel Kernel { get; }
|
IKernel Kernel { get; }
|
||||||
|
|
||||||
void ChangeSelectedProfile(Profile profile);
|
void ChangeSelectedProfile(Profile profile);
|
||||||
void UpdateSelectedProfile(bool includeChildren);
|
void UpdateSelectedProfile();
|
||||||
void ChangeSelectedProfileElement(ProfileElement profileElement);
|
void ChangeSelectedProfileElement(ProfileElement profileElement);
|
||||||
void UpdateSelectedProfileElement();
|
void UpdateSelectedProfileElement();
|
||||||
void UpdateProfilePreview();
|
void UpdateProfilePreview();
|
||||||
|
|||||||
@ -71,9 +71,9 @@ namespace Artemis.UI.Shared.Services
|
|||||||
OnSelectedProfileChanged(profileElementEvent);
|
OnSelectedProfileChanged(profileElementEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateSelectedProfile(bool includeChildren)
|
public void UpdateSelectedProfile()
|
||||||
{
|
{
|
||||||
_profileService.UpdateProfile(SelectedProfile, includeChildren);
|
_profileService.UpdateProfile(SelectedProfile, true);
|
||||||
UpdateProfilePreview();
|
UpdateProfilePreview();
|
||||||
OnSelectedProfileElementUpdated(new ProfileElementEventArgs(SelectedProfile));
|
OnSelectedProfileElementUpdated(new ProfileElementEventArgs(SelectedProfile));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,6 @@
|
|||||||
<NeutralLanguage>en-US</NeutralLanguage>
|
<NeutralLanguage>en-US</NeutralLanguage>
|
||||||
<Description>Adds third-party support for RGB keyboards to games.</Description>
|
<Description>Adds third-party support for RGB keyboards to games.</Description>
|
||||||
<Copyright>Copyright © Robert Beekman - 2020</Copyright>
|
<Copyright>Copyright © Robert Beekman - 2020</Copyright>
|
||||||
<AssemblyVersion>1.0.0.0</AssemblyVersion>
|
|
||||||
<FileVersion>2.0.0.0</FileVersion>
|
<FileVersion>2.0.0.0</FileVersion>
|
||||||
<Prefer32Bit>true</Prefer32Bit>
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
@ -27,6 +26,18 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent />
|
<PostBuildEvent />
|
||||||
|
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||||
|
<Version>2.0.0</Version>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<NrtRevisionFormat>2.0-{chash:6}</NrtRevisionFormat>
|
||||||
|
<NrtResolveSimpleAttributes>true</NrtResolveSimpleAttributes>
|
||||||
|
<NrtResolveInformationalAttribute>true</NrtResolveInformationalAttribute>
|
||||||
|
<NrtResolveCopyright>true</NrtResolveCopyright>
|
||||||
|
<NrtTagMatch>v[0-9]*</NrtTagMatch>
|
||||||
|
<NrtRemoveTagV>true</NrtRemoveTagV>
|
||||||
|
<NrtRequiredVcs>git</NrtRequiredVcs>
|
||||||
|
<NrtShowRevision>true</NrtShowRevision>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Target Name="SkiaCleanUpAfterBuild" AfterTargets="AfterBuild">
|
<Target Name="SkiaCleanUpAfterBuild" AfterTargets="AfterBuild">
|
||||||
<Delete Files="$(OutputPath)\libSkiaSharp.dylib" />
|
<Delete Files="$(OutputPath)\libSkiaSharp.dylib" />
|
||||||
@ -141,6 +152,10 @@
|
|||||||
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
|
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
|
||||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.0" />
|
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.0" />
|
||||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||||
|
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.3.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="obj\x64\Debug\App.g.cs" />
|
<Compile Remove="obj\x64\Debug\App.g.cs" />
|
||||||
|
|||||||
@ -5,6 +5,7 @@ using Artemis.Core.Models.Profile;
|
|||||||
using Artemis.Core.Plugins.Abstract;
|
using Artemis.Core.Plugins.Abstract;
|
||||||
using Artemis.Core.Plugins.LayerEffect;
|
using Artemis.Core.Plugins.LayerEffect;
|
||||||
using Artemis.Core.Services.Interfaces;
|
using Artemis.Core.Services.Interfaces;
|
||||||
|
using Artemis.UI.Shared.Services.Interfaces;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects
|
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects
|
||||||
@ -12,12 +13,14 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects
|
|||||||
public class EffectsViewModel : PropertyChangedBase
|
public class EffectsViewModel : PropertyChangedBase
|
||||||
{
|
{
|
||||||
private readonly ILayerService _layerService;
|
private readonly ILayerService _layerService;
|
||||||
|
private readonly IProfileEditorService _profileEditorService;
|
||||||
private readonly IPluginService _pluginService;
|
private readonly IPluginService _pluginService;
|
||||||
|
|
||||||
public EffectsViewModel(LayerPropertiesViewModel layerPropertiesViewModel, IPluginService pluginService, ILayerService layerService)
|
public EffectsViewModel(LayerPropertiesViewModel layerPropertiesViewModel, IPluginService pluginService, ILayerService layerService, IProfileEditorService profileEditorService)
|
||||||
{
|
{
|
||||||
_pluginService = pluginService;
|
_pluginService = pluginService;
|
||||||
_layerService = layerService;
|
_layerService = layerService;
|
||||||
|
_profileEditorService = profileEditorService;
|
||||||
LayerPropertiesViewModel = layerPropertiesViewModel;
|
LayerPropertiesViewModel = layerPropertiesViewModel;
|
||||||
LayerEffectDescriptors = new BindableCollection<LayerEffectDescriptor>();
|
LayerEffectDescriptors = new BindableCollection<LayerEffectDescriptor>();
|
||||||
PropertyChanged += HandleSelectedLayerEffectChanged;
|
PropertyChanged += HandleSelectedLayerEffectChanged;
|
||||||
@ -58,6 +61,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerEffects
|
|||||||
{
|
{
|
||||||
await Task.Delay(500);
|
await Task.Delay(500);
|
||||||
_layerService.AddLayerEffect(effectElement, SelectedLayerEffectDescriptor);
|
_layerService.AddLayerEffect(effectElement, SelectedLayerEffectDescriptor);
|
||||||
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -310,7 +310,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
|||||||
MoveAfter(source, target);
|
MoveAfter(source, target);
|
||||||
|
|
||||||
ApplyCurrentEffectsOrder();
|
ApplyCurrentEffectsOrder();
|
||||||
ProfileEditorService.UpdateSelectedProfile(true);
|
ProfileEditorService.UpdateSelectedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveBefore(LayerPropertyGroupViewModel source, LayerPropertyGroupViewModel target)
|
private void MoveBefore(LayerPropertyGroupViewModel source, LayerPropertyGroupViewModel target)
|
||||||
|
|||||||
@ -93,7 +93,6 @@
|
|||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="Auto" />
|
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.Style>
|
<Grid.Style>
|
||||||
<Style TargetType="{x:Type Grid}">
|
<Style TargetType="{x:Type Grid}">
|
||||||
@ -105,12 +104,12 @@
|
|||||||
</Style.Triggers>
|
</Style.Triggers>
|
||||||
</Style>
|
</Style>
|
||||||
</Grid.Style>
|
</Grid.Style>
|
||||||
<materialDesign:PackIcon
|
<materialDesign:PackIcon
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Cursor="SizeNS"
|
Cursor="SizeNS"
|
||||||
Kind="{Binding LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.Descriptor.Icon}"
|
Kind="{Binding LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.Descriptor.Icon}"
|
||||||
Margin="0 5 5 0"
|
Margin="0 5 5 0"
|
||||||
Background="Transparent"/>
|
Background="Transparent" />
|
||||||
<TextBlock Grid.Column="1" ToolTip="{Binding LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.Descriptor.Description}" Margin="0 5 0 0">
|
<TextBlock Grid.Column="1" ToolTip="{Binding LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.Descriptor.Description}" Margin="0 5 0 0">
|
||||||
Effect
|
Effect
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
@ -132,25 +131,36 @@
|
|||||||
Margin="0 5"
|
Margin="0 5"
|
||||||
Visibility="{Binding LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.Name, Converter={StaticResource NullToVisibilityConverter}}" />
|
Visibility="{Binding LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.Name, Converter={StaticResource NullToVisibilityConverter}}" />
|
||||||
|
|
||||||
<Button Grid.Column="5"
|
<StackPanel Grid.Column="5" Orientation="Horizontal">
|
||||||
Style="{StaticResource MaterialDesignIconButton}"
|
<ToggleButton
|
||||||
ToolTip="Rename"
|
Style="{StaticResource MaterialDesignFlatToggleButton}"
|
||||||
Width="24"
|
ToolTip="Toggle enabled state"
|
||||||
Height="24"
|
Width="18"
|
||||||
VerticalAlignment="Center"
|
Height="18"
|
||||||
Command="{s:Action RenameEffect}">
|
IsChecked="{Binding LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.Enabled}"
|
||||||
<materialDesign:PackIcon Kind="RenameBox" Height="16" Width="16" />
|
VerticalAlignment="Center" Padding="-25"
|
||||||
</Button>
|
Margin="5 0"
|
||||||
|
Command="{s:Action EnableToggled}">
|
||||||
|
<materialDesign:PackIcon Kind="Eye" Height="13" Width="13" />
|
||||||
|
</ToggleButton>
|
||||||
|
<Button Style="{StaticResource MaterialDesignIconButton}"
|
||||||
|
ToolTip="Rename"
|
||||||
|
Width="24"
|
||||||
|
Height="24"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Command="{s:Action RenameEffect}">
|
||||||
|
<materialDesign:PackIcon Kind="RenameBox" Height="16" Width="16" />
|
||||||
|
</Button>
|
||||||
|
<Button Style="{StaticResource MaterialDesignIconButton}"
|
||||||
|
ToolTip="Remove"
|
||||||
|
Width="24"
|
||||||
|
Height="24"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Command="{s:Action DeleteEffect}">
|
||||||
|
<materialDesign:PackIcon Kind="TrashCan" Height="16" Width="16" />
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
<Button Grid.Column="6"
|
|
||||||
Style="{StaticResource MaterialDesignIconButton}"
|
|
||||||
ToolTip="Remove"
|
|
||||||
Width="24"
|
|
||||||
Height="24"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Command="{s:Action DeleteEffect}">
|
|
||||||
<materialDesign:PackIcon Kind="TrashCan" Height="16" Width="16" />
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using Artemis.Core.Services.Interfaces;
|
using Artemis.Core.Services.Interfaces;
|
||||||
using Artemis.UI.Screens.Module.ProfileEditor.Dialogs;
|
using Artemis.UI.Screens.Module.ProfileEditor.Dialogs;
|
||||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
|
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
|
||||||
@ -37,14 +38,19 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree
|
|||||||
{
|
{
|
||||||
LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.Name = newName;
|
LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.Name = newName;
|
||||||
LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.HasBeenRenamed = true;
|
LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect.HasBeenRenamed = true;
|
||||||
_profileEditorService.UpdateSelectedProfile(true);
|
_profileEditorService.UpdateSelectedProfile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteEffect()
|
public void DeleteEffect()
|
||||||
{
|
{
|
||||||
_layerService.RemoveLayerEffect(LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect);
|
_layerService.RemoveLayerEffect(LayerPropertyGroupViewModel.LayerPropertyGroup.LayerEffect);
|
||||||
_profileEditorService.UpdateSelectedProfile(true);
|
_profileEditorService.UpdateSelectedProfile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EnableToggled()
|
||||||
|
{
|
||||||
|
_profileEditorService.UpdateSelectedProfile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_profileEditorService.UpdateSelectedProfile(true);
|
_profileEditorService.UpdateSelectedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReSharper disable once UnusedMember.Global - Called from view
|
// ReSharper disable once UnusedMember.Global - Called from view
|
||||||
|
|||||||
@ -36,13 +36,28 @@
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</StackPanel.ContextMenu>
|
</StackPanel.ContextMenu>
|
||||||
<StackPanel Orientation="Horizontal" Margin="10">
|
<Grid Margin="10">
|
||||||
<materialDesign:PackIcon Kind="Folder"
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<materialDesign:PackIcon Grid.Column="0"
|
||||||
|
Kind="Folder"
|
||||||
Visibility="{Binding IsExpanded, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}" />
|
Visibility="{Binding IsExpanded, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}" />
|
||||||
<materialDesign:PackIcon Kind="FolderOpen"
|
<materialDesign:PackIcon Grid.Column="0"
|
||||||
|
Kind="FolderOpen"
|
||||||
Visibility="{Binding IsExpanded, Converter={x:Static s:BoolToVisibilityConverter.Instance}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}" />
|
Visibility="{Binding IsExpanded, Converter={x:Static s:BoolToVisibilityConverter.Instance}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}" />
|
||||||
|
<TextBlock Grid.Column="1" Text="{Binding ProfileElement.Name}" Margin="10 0 0 0" VerticalAlignment="Center" />
|
||||||
<TextBlock Text="{Binding ProfileElement.Name}" Margin="10 0 0 0" />
|
<ToggleButton Grid.Column="2"
|
||||||
</StackPanel>
|
Style="{StaticResource MaterialDesignFlatToggleButton}"
|
||||||
|
ToolTip="Toggle enabled state"
|
||||||
|
Width="18"
|
||||||
|
Height="18"
|
||||||
|
IsChecked="{Binding ProfileElement.Enabled}"
|
||||||
|
VerticalAlignment="Center" Padding="-25">
|
||||||
|
<materialDesign:PackIcon Kind="Eye" Height="13" Width="13" />
|
||||||
|
</ToggleButton>
|
||||||
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -25,15 +25,32 @@
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</StackPanel.ContextMenu>
|
</StackPanel.ContextMenu>
|
||||||
<StackPanel Orientation="Horizontal" Margin="10">
|
<Grid Margin="10">
|
||||||
<materialDesign:PackIcon Kind="Layers" Width="16" />
|
<Grid.ColumnDefinitions>
|
||||||
<materialDesign:PackIcon Kind="{Binding Layer.LayerBrush.Descriptor.Icon}"
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<materialDesign:PackIcon Grid.Column="0" Kind="Layers" Width="16" VerticalAlignment="Center"/>
|
||||||
|
<materialDesign:PackIcon Grid.Column="1"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Kind="{Binding Layer.LayerBrush.Descriptor.Icon}"
|
||||||
Width="16"
|
Width="16"
|
||||||
Margin="5 0 0 0"
|
Margin="5 0 0 0"
|
||||||
ToolTip="{Binding Layer.LayerBrush.Descriptor.DisplayName, Mode=OneWay}"
|
ToolTip="{Binding Layer.LayerBrush.Descriptor.DisplayName, Mode=OneWay}"
|
||||||
Visibility="{Binding ShowIcons, Converter={x:Static s:BoolToVisibilityConverter.Instance}, 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" />
|
<TextBlock Grid.Column="2" Text="{Binding Layer.Name}" VerticalAlignment="Center" Margin="5 0 0 0" />
|
||||||
</StackPanel>
|
<ToggleButton Grid.Column="3"
|
||||||
|
Style="{StaticResource MaterialDesignFlatToggleButton}"
|
||||||
|
ToolTip="Toggle enabled state"
|
||||||
|
Width="18"
|
||||||
|
Height="18"
|
||||||
|
IsChecked="{Binding ProfileElement.Enabled}"
|
||||||
|
VerticalAlignment="Center" Padding="-25">
|
||||||
|
<materialDesign:PackIcon Kind="Eye" Height="13" Width="13" />
|
||||||
|
</ToggleButton>
|
||||||
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Artemis.Core.Models.Profile;
|
using Artemis.Core.Models.Profile;
|
||||||
@ -37,9 +38,16 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
|
|||||||
ProfileElement = profileElement;
|
ProfileElement = profileElement;
|
||||||
|
|
||||||
Children = new BindableCollection<TreeItemViewModel>();
|
Children = new BindableCollection<TreeItemViewModel>();
|
||||||
|
ProfileElement.PropertyChanged += HandleProfileElementEnabledChanged;
|
||||||
UpdateProfileElements();
|
UpdateProfileElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleProfileElementEnabledChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.PropertyName == nameof(ProfileElement.Enabled))
|
||||||
|
_profileEditorService.UpdateSelectedProfile();
|
||||||
|
}
|
||||||
|
|
||||||
public TreeItemViewModel Parent { get; set; }
|
public TreeItemViewModel Parent { get; set; }
|
||||||
public ProfileElement ProfileElement { get; set; }
|
public ProfileElement ProfileElement { get; set; }
|
||||||
|
|
||||||
@ -113,7 +121,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
|
|||||||
|
|
||||||
ProfileElement.AddChild(new Folder(ProfileElement.Profile, ProfileElement, "New folder"));
|
ProfileElement.AddChild(new Folder(ProfileElement.Profile, ProfileElement, "New folder"));
|
||||||
UpdateProfileElements();
|
UpdateProfileElements();
|
||||||
_profileEditorService.UpdateSelectedProfile(true);
|
_profileEditorService.UpdateSelectedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddLayer()
|
public void AddLayer()
|
||||||
@ -123,7 +131,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
|
|||||||
|
|
||||||
_layerService.CreateLayer(ProfileElement.Profile, ProfileElement, "New layer");
|
_layerService.CreateLayer(ProfileElement.Profile, ProfileElement, "New layer");
|
||||||
UpdateProfileElements();
|
UpdateProfileElements();
|
||||||
_profileEditorService.UpdateSelectedProfile(true);
|
_profileEditorService.UpdateSelectedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReSharper disable once UnusedMember.Global - Called from view
|
// ReSharper disable once UnusedMember.Global - Called from view
|
||||||
@ -139,7 +147,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
|
|||||||
if (result is string newName)
|
if (result is string newName)
|
||||||
{
|
{
|
||||||
ProfileElement.Name = newName;
|
ProfileElement.Name = newName;
|
||||||
_profileEditorService.UpdateSelectedProfile(true);
|
_profileEditorService.UpdateSelectedProfile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +168,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
|
|||||||
parent.RemoveExistingElement(this);
|
parent.RemoveExistingElement(this);
|
||||||
parent.UpdateProfileElements();
|
parent.UpdateProfileElements();
|
||||||
|
|
||||||
_profileEditorService.UpdateSelectedProfile(true);
|
_profileEditorService.UpdateSelectedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateProfileElements()
|
public void UpdateProfileElements()
|
||||||
|
|||||||
@ -56,7 +56,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
newLayer.AddLeds(selectedLeds);
|
newLayer.AddLeds(selectedLeds);
|
||||||
ProfileEditorService.ChangeSelectedProfileElement(newLayer);
|
ProfileEditorService.ChangeSelectedProfileElement(newLayer);
|
||||||
ProfileEditorService.UpdateSelectedProfileElement();
|
ProfileEditorService.UpdateSelectedProfileElement();
|
||||||
ProfileEditorService.UpdateSelectedProfile(false);
|
|
||||||
}
|
}
|
||||||
// If no folder selected, apply it to a new layer in the root folder
|
// If no folder selected, apply it to a new layer in the root folder
|
||||||
else
|
else
|
||||||
@ -66,7 +65,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
|||||||
newLayer.AddLeds(selectedLeds);
|
newLayer.AddLeds(selectedLeds);
|
||||||
ProfileEditorService.ChangeSelectedProfileElement(newLayer);
|
ProfileEditorService.ChangeSelectedProfileElement(newLayer);
|
||||||
ProfileEditorService.UpdateSelectedProfileElement();
|
ProfileEditorService.UpdateSelectedProfileElement();
|
||||||
ProfileEditorService.UpdateSelectedProfile(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
FadeContentIfInactive="False"
|
FadeContentIfInactive="False"
|
||||||
Icon="/Resources/Images/Logo/logo-512.png"
|
Icon="/Resources/Images/Logo/logo-512.png"
|
||||||
Title="Artemis"
|
Title="{Binding WindowTitle}"
|
||||||
TitleBarIcon="{StaticResource BowIcon}"
|
TitleBarIcon="{StaticResource BowIcon}"
|
||||||
Foreground="{DynamicResource MaterialDesignBody}"
|
Foreground="{DynamicResource MaterialDesignBody}"
|
||||||
Background="{DynamicResource MaterialDesignPaper}"
|
Background="{DynamicResource MaterialDesignPaper}"
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Timers;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
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.UI.Events;
|
using Artemis.UI.Events;
|
||||||
using Artemis.UI.Screens.Settings;
|
using Artemis.UI.Screens.Settings;
|
||||||
using Artemis.UI.Screens.Sidebar;
|
using Artemis.UI.Screens.Sidebar;
|
||||||
@ -15,16 +18,21 @@ namespace Artemis.UI.Screens
|
|||||||
{
|
{
|
||||||
public class RootViewModel : Conductor<IScreen>
|
public class RootViewModel : Conductor<IScreen>
|
||||||
{
|
{
|
||||||
private readonly IEventAggregator _eventAggregator;
|
|
||||||
private readonly PluginSetting<ApplicationColorScheme> _colorScheme;
|
private readonly PluginSetting<ApplicationColorScheme> _colorScheme;
|
||||||
private bool _lostFocus;
|
private readonly ICoreService _coreService;
|
||||||
|
private readonly IEventAggregator _eventAggregator;
|
||||||
private readonly ThemeWatcher _themeWatcher;
|
private readonly ThemeWatcher _themeWatcher;
|
||||||
|
private bool _lostFocus;
|
||||||
|
private readonly Timer _titleUpdateTimer;
|
||||||
|
|
||||||
public RootViewModel(IEventAggregator eventAggregator, SidebarViewModel sidebarViewModel, ISettingsService settingsService)
|
public RootViewModel(IEventAggregator eventAggregator, SidebarViewModel sidebarViewModel, ISettingsService settingsService, ICoreService coreService)
|
||||||
{
|
{
|
||||||
SidebarViewModel = sidebarViewModel;
|
SidebarViewModel = sidebarViewModel;
|
||||||
_eventAggregator = eventAggregator;
|
_eventAggregator = eventAggregator;
|
||||||
|
_coreService = coreService;
|
||||||
|
|
||||||
|
_titleUpdateTimer = new Timer(500);
|
||||||
|
_titleUpdateTimer.Elapsed += (sender, args) => UpdateWindowTitle();
|
||||||
_colorScheme = settingsService.GetSetting("UI.ColorScheme", ApplicationColorScheme.Automatic);
|
_colorScheme = settingsService.GetSetting("UI.ColorScheme", ApplicationColorScheme.Automatic);
|
||||||
_colorScheme.SettingChanged += (sender, args) => ApplyColorSchemeSetting();
|
_colorScheme.SettingChanged += (sender, args) => ApplyColorSchemeSetting();
|
||||||
_themeWatcher = new ThemeWatcher();
|
_themeWatcher = new ThemeWatcher();
|
||||||
@ -40,6 +48,8 @@ namespace Artemis.UI.Screens
|
|||||||
public bool IsSidebarVisible { get; set; }
|
public bool IsSidebarVisible { get; set; }
|
||||||
public bool ActiveItemReady { get; set; }
|
public bool ActiveItemReady { get; set; }
|
||||||
|
|
||||||
|
public string WindowTitle { get; set; }
|
||||||
|
|
||||||
public void WindowDeactivated()
|
public void WindowDeactivated()
|
||||||
{
|
{
|
||||||
var windowState = ((Window) View).WindowState;
|
var windowState = ((Window) View).WindowState;
|
||||||
@ -69,6 +79,26 @@ namespace Artemis.UI.Screens
|
|||||||
_eventAggregator.Publish(new MainWindowKeyEvent(false, e));
|
_eventAggregator.Publish(new MainWindowKeyEvent(false, e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnActivate()
|
||||||
|
{
|
||||||
|
UpdateWindowTitle();
|
||||||
|
_titleUpdateTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDeactivate()
|
||||||
|
{
|
||||||
|
_titleUpdateTimer.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateWindowTitle()
|
||||||
|
{
|
||||||
|
var versionAttribute = typeof(RootViewModel).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
|
||||||
|
if (versionAttribute != null)
|
||||||
|
WindowTitle = $"Artemis {versionAttribute.InformationalVersion} - Frame time: {_coreService.FrameTime.TotalMilliseconds:F2} ms";
|
||||||
|
else
|
||||||
|
WindowTitle = $"Artemis - Frame time: {_coreService.FrameTime.TotalMilliseconds:F2} ms";
|
||||||
|
}
|
||||||
|
|
||||||
private void SidebarViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
private void SidebarViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.PropertyName == nameof(SidebarViewModel.SelectedItem))
|
if (e.PropertyName == nameof(SidebarViewModel.SelectedItem))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user