mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Scripting - Core implementation (#629)
Scripting - Added plugin classes Layers - Fix certain blend modes not working as intended UI - Add customizable header per page Profile editor - Hide the regular header Profile editor - Added a new toolbar
This commit is contained in:
parent
d749ab5bbd
commit
048864fe78
@ -61,6 +61,7 @@
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=plugins_005Cprerequisites/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=plugins_005Cprerequisites_005Cprerequisiteaction/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=plugins_005Cprofiling/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=plugins_005Cscriptingproviders_005Cscripts/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=plugins_005Csettings/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=rgb_002Enet/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=services_005Ccolorquantizer/@EntryIndexedValue">True</s:Boolean>
|
||||
|
||||
@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Artemis.Core.LayerBrushes;
|
||||
using Artemis.Core.LayerEffects;
|
||||
using Artemis.Core.ScriptingProviders;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.Storage.Entities.Profile.Abstract;
|
||||
using RGB.NET.Core;
|
||||
@ -37,6 +38,9 @@ namespace Artemis.Core
|
||||
Profile = Parent.Profile;
|
||||
Name = name;
|
||||
Suspended = false;
|
||||
Scripts = new List<LayerScript>();
|
||||
ScriptConfigurations = new List<ScriptConfiguration>();
|
||||
|
||||
_general = new LayerGeneralProperties();
|
||||
_transform = new LayerTransformProperties();
|
||||
|
||||
@ -60,6 +64,9 @@ namespace Artemis.Core
|
||||
|
||||
Profile = profile;
|
||||
Parent = parent;
|
||||
Scripts = new List<LayerScript>();
|
||||
ScriptConfigurations = new List<ScriptConfiguration>();
|
||||
|
||||
_general = new LayerGeneralProperties();
|
||||
_transform = new LayerTransformProperties();
|
||||
|
||||
@ -75,6 +82,16 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<ArtemisLed> Leds => _leds.AsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of all active scripts assigned to this layer
|
||||
/// </summary>
|
||||
public List<LayerScript> Scripts { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of all script configurations assigned to this layer
|
||||
/// </summary>
|
||||
public List<ScriptConfiguration> ScriptConfigurations { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines the shape that is rendered by the <see cref="LayerBrush" />.
|
||||
/// </summary>
|
||||
@ -142,8 +159,10 @@ namespace Artemis.Core
|
||||
if (LayerBrush?.BaseProperties != null)
|
||||
result.AddRange(LayerBrush.BaseProperties.GetAllLayerProperties());
|
||||
foreach (BaseLayerEffect layerEffect in LayerEffects)
|
||||
{
|
||||
if (layerEffect.BaseProperties != null)
|
||||
result.AddRange(layerEffect.BaseProperties.GetAllLayerProperties());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -171,6 +190,9 @@ namespace Artemis.Core
|
||||
|
||||
Disposed = true;
|
||||
|
||||
while (Scripts.Count > 1)
|
||||
Scripts[0].Dispose();
|
||||
|
||||
LayerBrushStore.LayerBrushAdded -= LayerBrushStoreOnLayerBrushAdded;
|
||||
LayerBrushStore.LayerBrushRemoved -= LayerBrushStoreOnLayerBrushRemoved;
|
||||
|
||||
@ -247,6 +269,11 @@ namespace Artemis.Core
|
||||
ExpandedPropertyGroups.AddRange(LayerEntity.ExpandedPropertyGroups);
|
||||
LoadRenderElement();
|
||||
Adapter.Load();
|
||||
|
||||
foreach (ScriptConfiguration scriptConfiguration in ScriptConfigurations)
|
||||
scriptConfiguration.Script?.Dispose();
|
||||
ScriptConfigurations.Clear();
|
||||
ScriptConfigurations.AddRange(LayerEntity.ScriptConfigurations.Select(e => new ScriptConfiguration(e)));
|
||||
}
|
||||
|
||||
internal override void Save()
|
||||
@ -284,6 +311,13 @@ namespace Artemis.Core
|
||||
// Adaption hints
|
||||
Adapter.Save();
|
||||
|
||||
LayerEntity.ScriptConfigurations.Clear();
|
||||
foreach (ScriptConfiguration scriptConfiguration in ScriptConfigurations)
|
||||
{
|
||||
scriptConfiguration.Save();
|
||||
LayerEntity.ScriptConfigurations.Add(scriptConfiguration.Entity);
|
||||
}
|
||||
|
||||
SaveRenderElement();
|
||||
}
|
||||
|
||||
@ -316,6 +350,9 @@ namespace Artemis.Core
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException("Layer");
|
||||
|
||||
foreach (LayerScript layerScript in Scripts)
|
||||
layerScript.OnLayerUpdating(deltaTime);
|
||||
|
||||
UpdateDisplayCondition();
|
||||
UpdateTimeline(deltaTime);
|
||||
|
||||
@ -323,6 +360,9 @@ namespace Artemis.Core
|
||||
Enable();
|
||||
else if (Timeline.IsFinished)
|
||||
Disable();
|
||||
|
||||
foreach (LayerScript layerScript in Scripts)
|
||||
layerScript.OnLayerUpdated(deltaTime);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -473,19 +513,27 @@ namespace Artemis.Core
|
||||
if (LayerBrush == null)
|
||||
throw new ArtemisCoreException("The layer is not yet ready for rendering");
|
||||
|
||||
foreach (LayerScript layerScript in Scripts)
|
||||
layerScript.OnLayerRendering(canvas, bounds, layerPaint);
|
||||
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => !e.Suspended))
|
||||
baseLayerEffect.PreProcess(canvas, bounds, layerPaint);
|
||||
|
||||
try
|
||||
{
|
||||
canvas.SaveLayer(layerPaint);
|
||||
|
||||
// If a brush is a bad boy and tries to color outside the lines, ensure that its clipped off
|
||||
canvas.ClipPath(renderPath);
|
||||
|
||||
// Restore the blend mode before doing the actual render
|
||||
layerPaint.BlendMode = SKBlendMode.SrcOver;
|
||||
|
||||
LayerBrush.InternalRender(canvas, bounds, layerPaint);
|
||||
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => !e.Suspended))
|
||||
baseLayerEffect.PostProcess(canvas, bounds, layerPaint);
|
||||
|
||||
foreach (LayerScript layerScript in Scripts)
|
||||
layerScript.OnLayerRendered(canvas, bounds, layerPaint);
|
||||
}
|
||||
|
||||
finally
|
||||
@ -500,9 +548,7 @@ namespace Artemis.Core
|
||||
throw new ObjectDisposedException("Layer");
|
||||
|
||||
if (!Leds.Any())
|
||||
{
|
||||
Path = new SKPath();
|
||||
}
|
||||
else
|
||||
{
|
||||
SKPath path = new() {FillType = SKPathFillType.Winding};
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.ScriptingProviders;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
|
||||
namespace Artemis.Core
|
||||
@ -23,6 +24,16 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
LayerPropertyGroup LayerPropertyGroup { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of all active scripts assigned to this layer property
|
||||
/// </summary>
|
||||
List<PropertyScript> Scripts { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of all script configurations assigned to this layer property
|
||||
/// </summary>
|
||||
public List<ScriptConfiguration> ScriptConfigurations { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique path of the property on the layer
|
||||
/// </summary>
|
||||
|
||||
@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Artemis.Core.ScriptingProviders;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@ -30,6 +31,8 @@ namespace Artemis.Core
|
||||
Path = null!;
|
||||
Entity = null!;
|
||||
PropertyDescription = null!;
|
||||
Scripts = new List<PropertyScript>();
|
||||
ScriptConfigurations = new List<ScriptConfiguration>();
|
||||
|
||||
CurrentValue = default!;
|
||||
DefaultValue = default!;
|
||||
@ -55,15 +58,15 @@ namespace Artemis.Core
|
||||
/// </param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_disposed = true;
|
||||
_disposed = true;
|
||||
|
||||
foreach (IDataBinding dataBinding in _dataBindings)
|
||||
dataBinding.Dispose();
|
||||
while (Scripts.Count > 1)
|
||||
Scripts[0].Dispose();
|
||||
|
||||
Disposed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
foreach (IDataBinding dataBinding in _dataBindings)
|
||||
dataBinding.Dispose();
|
||||
|
||||
Disposed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -150,6 +153,12 @@ namespace Artemis.Core
|
||||
/// <inheritdoc />
|
||||
public PropertyDescriptionAttribute PropertyDescription { get; internal set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<PropertyScript> Scripts { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<ScriptConfiguration> ScriptConfigurations { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Path { get; private set; }
|
||||
|
||||
@ -162,12 +171,18 @@ namespace Artemis.Core
|
||||
if (_disposed)
|
||||
throw new ObjectDisposedException("LayerProperty");
|
||||
|
||||
foreach (PropertyScript propertyScript in Scripts)
|
||||
propertyScript.OnPropertyUpdating(timeline.Delta.TotalSeconds);
|
||||
|
||||
CurrentValue = BaseValue;
|
||||
|
||||
UpdateKeyframes(timeline);
|
||||
UpdateDataBindings(timeline);
|
||||
|
||||
OnUpdated();
|
||||
|
||||
foreach (PropertyScript propertyScript in Scripts)
|
||||
propertyScript.OnPropertyUpdated(timeline.Delta.TotalSeconds);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -747,6 +762,11 @@ namespace Artemis.Core
|
||||
if (dataBinding != null)
|
||||
_dataBindings.Add(dataBinding);
|
||||
}
|
||||
|
||||
foreach (ScriptConfiguration scriptConfiguration in ScriptConfigurations)
|
||||
scriptConfiguration.Script?.Dispose();
|
||||
ScriptConfigurations.Clear();
|
||||
ScriptConfigurations.AddRange(Entity.ScriptConfigurations.Select(e => new ScriptConfiguration(e)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -768,6 +788,13 @@ namespace Artemis.Core
|
||||
Entity.DataBindingEntities.Clear();
|
||||
foreach (IDataBinding dataBinding in _dataBindings)
|
||||
dataBinding.Save();
|
||||
|
||||
Entity.ScriptConfigurations.Clear();
|
||||
foreach (ScriptConfiguration scriptConfiguration in ScriptConfigurations)
|
||||
{
|
||||
scriptConfiguration.Save();
|
||||
Entity.ScriptConfigurations.Add(scriptConfiguration.Entity);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.ScriptingProviders;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using SkiaSharp;
|
||||
|
||||
@ -13,13 +14,15 @@ namespace Artemis.Core
|
||||
{
|
||||
private readonly object _lock = new();
|
||||
private bool _isFreshImport;
|
||||
|
||||
|
||||
internal Profile(ProfileConfiguration configuration, ProfileEntity profileEntity) : base(null!)
|
||||
{
|
||||
Configuration = configuration;
|
||||
Profile = this;
|
||||
ProfileEntity = profileEntity;
|
||||
EntityId = profileEntity.Id;
|
||||
Scripts = new List<ProfileScript>();
|
||||
ScriptConfigurations = new List<ScriptConfiguration>();
|
||||
|
||||
UndoStack = new Stack<string>();
|
||||
RedoStack = new Stack<string>();
|
||||
@ -32,6 +35,17 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public ProfileConfiguration Configuration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of all active scripts assigned to this profile
|
||||
/// </summary>
|
||||
public List<ProfileScript> Scripts { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of all script configurations assigned to this profile
|
||||
/// </summary>
|
||||
public List<ScriptConfiguration> ScriptConfigurations { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether this profile is freshly imported i.e. no changes have been made to it
|
||||
/// since import
|
||||
@ -62,8 +76,14 @@ namespace Artemis.Core
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException("Profile");
|
||||
|
||||
foreach (ProfileScript profileScript in Scripts)
|
||||
profileScript.OnProfileUpdating(deltaTime);
|
||||
|
||||
foreach (ProfileElement profileElement in Children)
|
||||
profileElement.Update(deltaTime);
|
||||
|
||||
foreach (ProfileScript profileScript in Scripts)
|
||||
profileScript.OnProfileUpdated(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,8 +95,14 @@ namespace Artemis.Core
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException("Profile");
|
||||
|
||||
foreach (ProfileScript profileScript in Scripts)
|
||||
profileScript.OnProfileRendering(canvas, canvas.LocalClipBounds);
|
||||
|
||||
foreach (ProfileElement profileElement in Children)
|
||||
profileElement.Render(canvas, basePosition);
|
||||
|
||||
foreach (ProfileScript profileScript in Scripts)
|
||||
profileScript.OnProfileRendered(canvas, canvas.LocalClipBounds);
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,6 +151,9 @@ namespace Artemis.Core
|
||||
if (!disposing)
|
||||
return;
|
||||
|
||||
while (Scripts.Count > 1)
|
||||
Scripts[0].Dispose();
|
||||
|
||||
foreach (ProfileElement profileElement in Children)
|
||||
profileElement.Dispose();
|
||||
ChildrenList.Clear();
|
||||
@ -157,6 +186,11 @@ namespace Artemis.Core
|
||||
AddChild(new Folder(this, this, rootFolder));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ScriptConfiguration scriptConfiguration in ScriptConfigurations)
|
||||
scriptConfiguration.Script?.Dispose();
|
||||
ScriptConfigurations.Clear();
|
||||
ScriptConfigurations.AddRange(ProfileEntity.ScriptConfigurations.Select(e => new ScriptConfiguration(e)));
|
||||
}
|
||||
|
||||
internal override void Save()
|
||||
@ -176,6 +210,13 @@ namespace Artemis.Core
|
||||
|
||||
ProfileEntity.Layers.Clear();
|
||||
ProfileEntity.Layers.AddRange(GetAllLayers().Select(f => f.LayerEntity));
|
||||
|
||||
ProfileEntity.ScriptConfigurations.Clear();
|
||||
foreach (ScriptConfiguration scriptConfiguration in ScriptConfigurations)
|
||||
{
|
||||
scriptConfiguration.Save();
|
||||
ProfileEntity.ScriptConfigurations.Add(scriptConfiguration.Entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
using Artemis.Storage.Entities.General;
|
||||
|
||||
namespace Artemis.Core.ScriptingProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the configuration of a script
|
||||
/// </summary>
|
||||
public class ScriptConfiguration : CorePropertyChanged, IStorageModel
|
||||
{
|
||||
private string _scriptingProviderId;
|
||||
private string _name;
|
||||
private string? _scriptContent;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="ScriptConfiguration" /> class
|
||||
/// </summary>
|
||||
public ScriptConfiguration(ScriptingProvider provider, string name)
|
||||
{
|
||||
ScriptingProviderId = provider.Id;
|
||||
Name = name;
|
||||
Entity = new ScriptConfigurationEntity();
|
||||
}
|
||||
|
||||
internal ScriptConfiguration(ScriptConfigurationEntity entity)
|
||||
{
|
||||
ScriptingProviderId = null!;
|
||||
Name = null!;
|
||||
Entity = entity;
|
||||
|
||||
Load();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ID of the scripting provider
|
||||
/// </summary>
|
||||
public string ScriptingProviderId
|
||||
{
|
||||
get => _scriptingProviderId;
|
||||
set => SetAndNotify(ref _scriptingProviderId, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the script
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => SetAndNotify(ref _name, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the script's content
|
||||
/// </summary>
|
||||
public string? ScriptContent
|
||||
{
|
||||
get => _scriptContent;
|
||||
set => SetAndNotify(ref _scriptContent, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If active, gets the script
|
||||
/// </summary>
|
||||
public Script? Script { get; internal set; }
|
||||
|
||||
internal ScriptConfigurationEntity Entity { get; }
|
||||
|
||||
#region Implementation of IStorageModel
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Load()
|
||||
{
|
||||
ScriptingProviderId = Entity.ScriptingProviderId;
|
||||
ScriptContent = Entity.ScriptContent;
|
||||
Name = Entity.Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Save()
|
||||
{
|
||||
Entity.ScriptingProviderId = ScriptingProviderId;
|
||||
Entity.ScriptContent = ScriptContent;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
177
src/Artemis.Core/Plugins/ScriptingProviders/ScriptingProvider.cs
Normal file
177
src/Artemis.Core/Plugins/ScriptingProviders/ScriptingProvider.cs
Normal file
@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace Artemis.Core.ScriptingProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows you to implement and register your own scripting provider.
|
||||
/// </summary>
|
||||
public abstract class ScriptingProvider<TGlobalScript, TProfileScript, TLayerScript, TPropertyScript> : ScriptingProvider
|
||||
where TGlobalScript : GlobalScript
|
||||
where TProfileScript : ProfileScript
|
||||
where TLayerScript : LayerScript
|
||||
where TPropertyScript : PropertyScript
|
||||
{
|
||||
/// <summary>
|
||||
/// Called when the UI needs a script editor for a <see cref="GlobalScript" />
|
||||
/// </summary>
|
||||
/// <param name="script">The script the editor must edit</param>
|
||||
public abstract IScriptEditorViewModel CreateGlobalScriptEditor(TGlobalScript script);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the UI needs a script editor for a <see cref="ProfileScript" />
|
||||
/// </summary>
|
||||
/// <param name="script">The script the editor must edit</param>
|
||||
public abstract IScriptEditorViewModel CreateProfileScriptEditor(TProfileScript script);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the UI needs a script editor for a <see cref="LayerScript" />
|
||||
/// </summary>
|
||||
/// <param name="script">The script the editor must edit</param>
|
||||
public abstract IScriptEditorViewModel CreateLayerScriptScriptEditor(TLayerScript script);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the UI needs a script editor for a <see cref="PropertyScript" />
|
||||
/// </summary>
|
||||
/// <param name="script">The script the editor must edit</param>
|
||||
public abstract IScriptEditorViewModel CreatePropertyScriptEditor(TPropertyScript script);
|
||||
|
||||
#region Overrides of ScriptingProvider
|
||||
|
||||
/// <inheritdoc />
|
||||
internal override Type GlobalScriptType => typeof(TGlobalScript);
|
||||
|
||||
/// <inheritdoc />
|
||||
internal override Type ProfileScriptType => typeof(TProfileScript);
|
||||
|
||||
/// <inheritdoc />
|
||||
internal override Type LayerScriptType => typeof(TLayerScript);
|
||||
|
||||
/// <inheritdoc />
|
||||
internal override Type PropertyScriptType => typeof(TPropertyScript);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the UI needs a script editor for a <see cref="GlobalScript" />
|
||||
/// </summary>
|
||||
/// <param name="script">The script the editor must edit</param>
|
||||
public override IScriptEditorViewModel CreateGlobalScriptEditor(GlobalScript script)
|
||||
{
|
||||
if (script == null) throw new ArgumentNullException(nameof(script));
|
||||
if (script.GetType() != GlobalScriptType)
|
||||
throw new ArtemisCoreException($"This scripting provider only supports global scripts of type {GlobalScriptType.Name}");
|
||||
|
||||
return CreateGlobalScriptEditor((TGlobalScript) script);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the UI needs a script editor for a <see cref="ProfileScript" />
|
||||
/// </summary>
|
||||
/// <param name="script">The script the editor must edit</param>
|
||||
public override IScriptEditorViewModel CreateProfileScriptEditor(ProfileScript script)
|
||||
{
|
||||
if (script == null) throw new ArgumentNullException(nameof(script));
|
||||
if (script.GetType() != ProfileScriptType)
|
||||
throw new ArtemisCoreException($"This scripting provider only supports profile scripts of type {ProfileScriptType.Name}");
|
||||
|
||||
return CreateProfileScriptEditor((TProfileScript) script);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the UI needs a script editor for a <see cref="LayerScript" />
|
||||
/// </summary>
|
||||
/// <param name="script">The script the editor must edit</param>
|
||||
public override IScriptEditorViewModel CreateLayerScriptScriptEditor(LayerScript script)
|
||||
{
|
||||
if (script == null) throw new ArgumentNullException(nameof(script));
|
||||
if (script.GetType() != LayerScriptType)
|
||||
throw new ArtemisCoreException($"This scripting provider only supports layer scripts of type {LayerScriptType.Name}");
|
||||
|
||||
return CreateLayerScriptScriptEditor((TLayerScript) script);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the UI needs a script editor for a <see cref="PropertyScript" />
|
||||
/// </summary>
|
||||
/// <param name="script">The script the editor must edit</param>
|
||||
public override IScriptEditorViewModel CreatePropertyScriptEditor(PropertyScript script)
|
||||
{
|
||||
if (script == null) throw new ArgumentNullException(nameof(script));
|
||||
if (script.GetType() != PropertyScriptType)
|
||||
throw new ArtemisCoreException($"This scripting provider only supports property scripts of type {PropertyScriptType.Name}");
|
||||
|
||||
return CreatePropertyScriptEditor((TPropertyScript) script);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overrides of PluginFeature
|
||||
|
||||
/// <inheritdoc />
|
||||
internal override void InternalDisable()
|
||||
{
|
||||
base.InternalDisable();
|
||||
|
||||
while (Scripts.Count > 0)
|
||||
Scripts[0].Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows you to implement and register your own scripting provider.
|
||||
/// <para>
|
||||
/// Note: You can't implement this, implement
|
||||
/// <see cref="ScriptingProvider{TProfileScript,TLayerScript,TPropertyScript,TGlobalScript}" /> instead.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public abstract class ScriptingProvider : PluginFeature
|
||||
{
|
||||
internal abstract Type GlobalScriptType { get; }
|
||||
internal abstract Type PropertyScriptType { get; }
|
||||
internal abstract Type LayerScriptType { get; }
|
||||
internal abstract Type ProfileScriptType { get; }
|
||||
internal List<Script> InternalScripts { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all active scripts belonging to this scripting provider
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<Script> Scripts => InternalScripts.AsReadOnly();
|
||||
|
||||
/// <summary>
|
||||
/// Called when the UI needs a script editor for a <see cref="GlobalScript" />
|
||||
/// </summary>
|
||||
/// <param name="script">The script the editor must edit</param>
|
||||
public abstract IScriptEditorViewModel CreateGlobalScriptEditor(GlobalScript script);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the UI needs a script editor for a <see cref="ProfileScript" />
|
||||
/// </summary>
|
||||
/// <param name="script">The script the editor must edit</param>
|
||||
public abstract IScriptEditorViewModel CreateProfileScriptEditor(ProfileScript script);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the UI needs a script editor for a <see cref="LayerScript" />
|
||||
/// </summary>
|
||||
/// <param name="script">The script the editor must edit</param>
|
||||
public abstract IScriptEditorViewModel CreateLayerScriptScriptEditor(LayerScript script);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the UI needs a script editor for a <see cref="PropertyScript" />
|
||||
/// </summary>
|
||||
/// <param name="script">The script the editor must edit</param>
|
||||
public abstract IScriptEditorViewModel CreatePropertyScriptEditor(PropertyScript script);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a view model containing a script editor
|
||||
/// </summary>
|
||||
public interface IScriptEditorViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the script this editor is editing
|
||||
/// </summary>
|
||||
Script Script { get; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
using Artemis.Core.Services;
|
||||
|
||||
namespace Artemis.Core.ScriptingProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a script running globally
|
||||
/// </summary>
|
||||
public abstract class GlobalScript : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected GlobalScript(ScriptConfiguration configuration) : base(configuration)
|
||||
{
|
||||
}
|
||||
|
||||
internal ScriptingService ScriptingService { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever the Artemis Core is about to update
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Seconds passed since last update</param>
|
||||
public virtual void OnCoreUpdating(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever the Artemis Core has been updated
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Seconds passed since last update</param>
|
||||
public virtual void OnCoreUpdated(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
#region Overrides of Script
|
||||
|
||||
/// <inheritdoc />
|
||||
internal override void InternalCleanup()
|
||||
{
|
||||
ScriptingService.InternalGlobalScripts.Remove(this);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.ScriptingProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a script bound to a specific <see cref="Layer" /> processed by a <see cref="ScriptingProvider" />.
|
||||
/// </summary>
|
||||
public abstract class LayerScript : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected LayerScript(Layer layer, ScriptConfiguration configuration) : base(configuration)
|
||||
{
|
||||
Layer = layer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the layer this script is bound to
|
||||
/// </summary>
|
||||
public Layer Layer { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever the layer is about to update
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Seconds passed since last update</param>
|
||||
public virtual void OnLayerUpdating(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever the layer has been updated
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Seconds passed since last update</param>
|
||||
public virtual void OnLayerUpdated(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever the layer is about to render
|
||||
/// </summary>
|
||||
/// <param name="canvas">The layer canvas</param>
|
||||
/// <param name="bounds">The area to be filled, covers the shape</param>
|
||||
/// <param name="paint">The paint to be used to fill the shape</param>
|
||||
public virtual void OnLayerRendering(SKCanvas canvas, SKRect bounds, SKPaint paint)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever the layer has been rendered
|
||||
/// </summary>
|
||||
/// <param name="canvas">The layer canvas</param>
|
||||
/// <param name="bounds">The area to be filled, covers the shape</param>
|
||||
/// <param name="paint">The paint to be used to fill the shape</param>
|
||||
public virtual void OnLayerRendered(SKCanvas canvas, SKRect bounds, SKPaint paint)
|
||||
{
|
||||
}
|
||||
|
||||
#region Overrides of Script
|
||||
|
||||
/// <inheritdoc />
|
||||
internal override void InternalCleanup()
|
||||
{
|
||||
lock (Layer.Scripts)
|
||||
{
|
||||
Layer.Scripts.Remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.ScriptingProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a script bound to a specific <see cref="Profile" /> processed by a <see cref="ScriptingProvider" />.
|
||||
/// </summary>
|
||||
public abstract class ProfileScript : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected ProfileScript(Profile profile, ScriptConfiguration configuration) : base(configuration)
|
||||
{
|
||||
Profile = profile;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the profile this script is bound to
|
||||
/// </summary>
|
||||
public Profile Profile { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever the profile is about to update
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Seconds passed since last update</param>
|
||||
public virtual void OnProfileUpdating(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever the profile has been updated
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Seconds passed since last update</param>
|
||||
public virtual void OnProfileUpdated(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever the profile is about to render
|
||||
/// </summary>
|
||||
/// <param name="canvas">The profile canvas</param>
|
||||
/// <param name="bounds">The area to be filled, covers the entire canvas</param>
|
||||
public virtual void OnProfileRendering(SKCanvas canvas, SKRect bounds)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever the profile has been rendered
|
||||
/// </summary>
|
||||
/// <param name="canvas">The profile canvas</param>
|
||||
/// <param name="bounds">The area to be filled, covers the entire canvas</param>
|
||||
public virtual void OnProfileRendered(SKCanvas canvas, SKRect bounds)
|
||||
{
|
||||
}
|
||||
|
||||
#region Overrides of Script
|
||||
|
||||
/// <inheritdoc />
|
||||
internal override void InternalCleanup()
|
||||
{
|
||||
lock (Profile.Scripts)
|
||||
{
|
||||
Profile.Scripts.Remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
namespace Artemis.Core.ScriptingProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a script bound to a specific <see cref="LayerProperty{T}" /> processed by a
|
||||
/// <see cref="ScriptingProvider" />.
|
||||
/// </summary>
|
||||
public abstract class PropertyScript : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected PropertyScript(ILayerProperty layerProperty, ScriptConfiguration configuration) : base(configuration)
|
||||
{
|
||||
LayerProperty = layerProperty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the layer property this script is bound to
|
||||
/// </summary>
|
||||
public ILayerProperty LayerProperty { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever the property is about to update
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Seconds passed since last update</param>
|
||||
public virtual void OnPropertyUpdating(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called whenever the property has been updated
|
||||
/// </summary>
|
||||
/// <param name="deltaTime">Seconds passed since last update</param>
|
||||
public virtual void OnPropertyUpdated(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
#region Overrides of Script
|
||||
|
||||
/// <inheritdoc />
|
||||
internal override void InternalCleanup()
|
||||
{
|
||||
lock (LayerProperty.Scripts)
|
||||
{
|
||||
LayerProperty.Scripts.Remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
103
src/Artemis.Core/Plugins/ScriptingProviders/Scripts/Script.cs
Normal file
103
src/Artemis.Core/Plugins/ScriptingProviders/Scripts/Script.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Artemis.Core.ScriptingProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a script processed by a <see cref="ScriptingProviders.ScriptingProvider" />.
|
||||
/// </summary>
|
||||
public abstract class Script : CorePropertyChanged, IDisposable
|
||||
{
|
||||
private ScriptingProvider _scriptingProvider = null!;
|
||||
|
||||
/// <summary>
|
||||
/// The base constructor of any script
|
||||
/// </summary>
|
||||
/// <param name="configuration">The script configuration this script belongs to</param>
|
||||
protected Script(ScriptConfiguration configuration)
|
||||
{
|
||||
if (configuration.Script != null)
|
||||
throw new ArtemisCoreException("The provided script configuration already has an active script");
|
||||
|
||||
ScriptConfiguration = configuration;
|
||||
ScriptConfiguration.Script = this;
|
||||
|
||||
ScriptConfiguration.PropertyChanged += ScriptConfigurationOnPropertyChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scripting provider this script belongs to
|
||||
/// </summary>
|
||||
public ScriptingProvider ScriptingProvider
|
||||
{
|
||||
get => _scriptingProvider;
|
||||
internal set => SetAndNotify(ref _scriptingProvider, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the script configuration this script belongs to
|
||||
/// </summary>
|
||||
public ScriptConfiguration ScriptConfiguration { get; }
|
||||
|
||||
#region Event handlers
|
||||
|
||||
private void ScriptConfigurationOnPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(ScriptConfiguration.ScriptContent))
|
||||
OnScriptContentChanged();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Releases the unmanaged resources used by the object and optionally releases the managed resources.
|
||||
/// </summary>
|
||||
/// <param name="disposing">
|
||||
/// <see langword="true" /> to release both managed and unmanaged resources;
|
||||
/// <see langword="false" /> to release only unmanaged resources.
|
||||
/// </param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
ScriptConfiguration.PropertyChanged -= ScriptConfigurationOnPropertyChanged;
|
||||
ScriptConfiguration.Script = null;
|
||||
ScriptingProvider.InternalScripts.Remove(this);
|
||||
|
||||
// Can't trust those pesky plugin devs!
|
||||
InternalCleanup();
|
||||
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
internal abstract void InternalCleanup();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the contents of the script have changed
|
||||
/// </summary>
|
||||
public event EventHandler? ScriptContentChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the <see cref="ScriptContentChanged" /> event
|
||||
/// </summary>
|
||||
protected virtual void OnScriptContentChanged()
|
||||
{
|
||||
ScriptContentChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Ninject;
|
||||
using Artemis.Core.ScriptingProviders;
|
||||
using Artemis.Storage;
|
||||
using HidSharp;
|
||||
using Ninject;
|
||||
@ -29,6 +30,7 @@ namespace Artemis.Core.Services
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IModuleService _moduleService;
|
||||
private readonly IScriptingService _scriptingService;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly List<Exception> _updateExceptions = new();
|
||||
private DateTime _lastExceptionLog;
|
||||
@ -41,7 +43,8 @@ namespace Artemis.Core.Services
|
||||
IPluginManagementService pluginManagementService,
|
||||
IRgbService rgbService,
|
||||
IProfileService profileService,
|
||||
IModuleService moduleService)
|
||||
IModuleService moduleService,
|
||||
IScriptingService scriptingService)
|
||||
{
|
||||
Kernel = kernel;
|
||||
Constants.CorePlugin.Kernel = kernel;
|
||||
@ -51,10 +54,11 @@ namespace Artemis.Core.Services
|
||||
_rgbService = rgbService;
|
||||
_profileService = profileService;
|
||||
_moduleService = moduleService;
|
||||
_scriptingService = scriptingService;
|
||||
_loggingLevel = settingsService.GetSetting("Core.LoggingLevel", LogEventLevel.Debug);
|
||||
_frameStopWatch = new Stopwatch();
|
||||
StartupArguments = new List<string>();
|
||||
|
||||
|
||||
_rgbService.IsRenderPaused = true;
|
||||
_rgbService.Surface.Updating += SurfaceOnUpdating;
|
||||
_loggingLevel.SettingChanged += (sender, args) => ApplyLoggingLevel();
|
||||
@ -107,6 +111,9 @@ namespace Artemis.Core.Services
|
||||
{
|
||||
_frameStopWatch.Restart();
|
||||
|
||||
foreach (GlobalScript script in _scriptingService.GlobalScripts)
|
||||
script.OnCoreUpdating(args.DeltaTime);
|
||||
|
||||
_moduleService.UpdateActiveModules(args.DeltaTime);
|
||||
SKTexture texture = _rgbService.OpenRender();
|
||||
SKCanvas canvas = texture.Surface.Canvas;
|
||||
@ -126,6 +133,9 @@ namespace Artemis.Core.Services
|
||||
canvas.Flush();
|
||||
|
||||
OnFrameRendered(new FrameRenderedEventArgs(texture, _rgbService.Surface));
|
||||
|
||||
foreach (GlobalScript script in _scriptingService.GlobalScripts)
|
||||
script.OnCoreUpdated(args.DeltaTime);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
219
src/Artemis.Core/Services/ScriptingService.cs
Normal file
219
src/Artemis.Core/Services/ScriptingService.cs
Normal file
@ -0,0 +1,219 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.ScriptingProviders;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
{
|
||||
internal class ScriptingService : IScriptingService
|
||||
{
|
||||
private readonly IPluginManagementService _pluginManagementService;
|
||||
private List<ScriptingProvider> _scriptingProviders;
|
||||
|
||||
public ScriptingService(IPluginManagementService pluginManagementService, IProfileService profileService)
|
||||
{
|
||||
_pluginManagementService = pluginManagementService;
|
||||
|
||||
InternalGlobalScripts = new List<GlobalScript>();
|
||||
|
||||
_pluginManagementService.PluginFeatureEnabled += PluginManagementServiceOnPluginFeatureToggled;
|
||||
_pluginManagementService.PluginFeatureDisabled += PluginManagementServiceOnPluginFeatureToggled;
|
||||
_scriptingProviders = _pluginManagementService.GetFeaturesOfType<ScriptingProvider>();
|
||||
|
||||
// No need to sub to Deactivated, scripts will deactivate themselves
|
||||
profileService.ProfileActivated += ProfileServiceOnProfileActivated;
|
||||
|
||||
foreach (ProfileConfiguration profileConfiguration in profileService.ProfileConfigurations)
|
||||
{
|
||||
if (profileConfiguration.Profile != null)
|
||||
InitializeProfileScripts(profileConfiguration.Profile);
|
||||
}
|
||||
}
|
||||
|
||||
internal List<GlobalScript> InternalGlobalScripts { get; }
|
||||
|
||||
private ConstructorArgument CreateScriptConstructorArgument(Type scriptType, object value)
|
||||
{
|
||||
// Limit to one constructor, there's no need to have more and it complicates things anyway
|
||||
ConstructorInfo[] constructors = scriptType.GetConstructors();
|
||||
if (constructors.Length != 1)
|
||||
throw new ArtemisCoreException("Scripts must have exactly one constructor");
|
||||
|
||||
// Find the ScriptConfiguration parameter, it is required by the base constructor so its there for sure
|
||||
ParameterInfo configurationParameter = constructors.First().GetParameters().First(p => value.GetType().IsAssignableFrom(p.ParameterType));
|
||||
|
||||
if (configurationParameter.Name == null)
|
||||
throw new ArtemisCoreException($"Couldn't find a valid constructor argument on {scriptType.Name} with type {value.GetType().Name}");
|
||||
return new ConstructorArgument(configurationParameter.Name, value);
|
||||
}
|
||||
|
||||
private void PluginManagementServiceOnPluginFeatureToggled(object? sender, PluginFeatureEventArgs e)
|
||||
{
|
||||
_scriptingProviders = _pluginManagementService.GetFeaturesOfType<ScriptingProvider>();
|
||||
}
|
||||
|
||||
private void ProfileServiceOnProfileActivated(object? sender, ProfileConfigurationEventArgs e)
|
||||
{
|
||||
if (e.ProfileConfiguration.Profile != null)
|
||||
InitializeProfileScripts(e.ProfileConfiguration.Profile);
|
||||
}
|
||||
|
||||
private void InitializeProfileScripts(Profile profile)
|
||||
{
|
||||
// Initialize the scripts on the profile
|
||||
foreach (ScriptConfiguration scriptConfiguration in profile.ScriptConfigurations.Where(c => c.Script == null))
|
||||
CreateScriptInstance(profile, scriptConfiguration);
|
||||
|
||||
foreach (Layer layer in profile.GetAllLayers())
|
||||
{
|
||||
// Initialize the scripts on the layers
|
||||
foreach (ScriptConfiguration scriptConfiguration in layer.ScriptConfigurations.Where(c => c.Script == null))
|
||||
CreateScriptInstance(layer, scriptConfiguration);
|
||||
|
||||
// Initialize the scripts on the layer properties of layers
|
||||
foreach (ILayerProperty layerProperty in layer.GetAllLayerProperties())
|
||||
{
|
||||
foreach (ScriptConfiguration scriptConfiguration in layerProperty.ScriptConfigurations.Where(c => c.Script == null))
|
||||
CreateScriptInstance(layerProperty, scriptConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Folder folder in profile.GetAllFolders())
|
||||
{
|
||||
// Initialize the scripts on the layer properties of folders
|
||||
foreach (ILayerProperty layerProperty in folder.GetAllLayerProperties())
|
||||
{
|
||||
foreach (ScriptConfiguration scriptConfiguration in layerProperty.ScriptConfigurations.Where(c => c.Script == null))
|
||||
CreateScriptInstance(layerProperty, scriptConfiguration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<GlobalScript> GlobalScripts => InternalGlobalScripts.AsReadOnly();
|
||||
|
||||
public GlobalScript? CreateScriptInstance(ScriptConfiguration scriptConfiguration)
|
||||
{
|
||||
if (scriptConfiguration.Script != null)
|
||||
throw new ArtemisCoreException("The provided script configuration already has an active script");
|
||||
|
||||
ScriptingProvider? provider = _scriptingProviders.FirstOrDefault(p => p.Id == scriptConfiguration.ScriptingProviderId);
|
||||
if (provider == null)
|
||||
return null;
|
||||
|
||||
GlobalScript script = (GlobalScript) provider.Plugin.Kernel!.Get(
|
||||
provider.GlobalScriptType,
|
||||
CreateScriptConstructorArgument(provider.GlobalScriptType, scriptConfiguration)
|
||||
);
|
||||
|
||||
script.ScriptingProvider = provider;
|
||||
script.ScriptingService = this;
|
||||
provider.InternalScripts.Add(script);
|
||||
InternalGlobalScripts.Add(script);
|
||||
return script;
|
||||
}
|
||||
|
||||
public ProfileScript? CreateScriptInstance(Profile profile, ScriptConfiguration scriptConfiguration)
|
||||
{
|
||||
if (scriptConfiguration.Script != null)
|
||||
throw new ArtemisCoreException("The provided script configuration already has an active script");
|
||||
|
||||
ScriptingProvider? provider = _scriptingProviders.FirstOrDefault(p => p.Id == scriptConfiguration.ScriptingProviderId);
|
||||
if (provider == null)
|
||||
return null;
|
||||
|
||||
ProfileScript script = (ProfileScript) provider.Plugin.Kernel!.Get(
|
||||
provider.ProfileScriptType,
|
||||
CreateScriptConstructorArgument(provider.ProfileScriptType, profile),
|
||||
CreateScriptConstructorArgument(provider.ProfileScriptType, scriptConfiguration)
|
||||
);
|
||||
|
||||
script.ScriptingProvider = provider;
|
||||
provider.InternalScripts.Add(script);
|
||||
return script;
|
||||
}
|
||||
|
||||
public LayerScript? CreateScriptInstance(Layer layer, ScriptConfiguration scriptConfiguration)
|
||||
{
|
||||
if (scriptConfiguration.Script != null)
|
||||
throw new ArtemisCoreException("The provided script configuration already has an active script");
|
||||
|
||||
ScriptingProvider? provider = _scriptingProviders.FirstOrDefault(p => p.Id == scriptConfiguration.ScriptingProviderId);
|
||||
if (provider == null)
|
||||
return null;
|
||||
|
||||
LayerScript script = (LayerScript) provider.Plugin.Kernel!.Get(
|
||||
provider.LayerScriptType,
|
||||
CreateScriptConstructorArgument(provider.LayerScriptType, layer),
|
||||
CreateScriptConstructorArgument(provider.LayerScriptType, scriptConfiguration)
|
||||
);
|
||||
|
||||
script.ScriptingProvider = provider;
|
||||
provider.InternalScripts.Add(script);
|
||||
return script;
|
||||
}
|
||||
|
||||
public PropertyScript? CreateScriptInstance(ILayerProperty layerProperty, ScriptConfiguration scriptConfiguration)
|
||||
{
|
||||
if (scriptConfiguration.Script != null)
|
||||
throw new ArtemisCoreException("The provided script configuration already has an active script");
|
||||
|
||||
ScriptingProvider? provider = _scriptingProviders.FirstOrDefault(p => p.Id == scriptConfiguration.ScriptingProviderId);
|
||||
if (provider == null)
|
||||
return null;
|
||||
|
||||
PropertyScript script = (PropertyScript) provider.Plugin.Kernel!.Get(
|
||||
provider.PropertyScriptType,
|
||||
CreateScriptConstructorArgument(provider.PropertyScriptType, layerProperty),
|
||||
CreateScriptConstructorArgument(provider.PropertyScriptType, scriptConfiguration)
|
||||
);
|
||||
|
||||
script.ScriptingProvider = provider;
|
||||
provider.InternalScripts.Add(script);
|
||||
return script;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IScriptingService : IArtemisService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a read only collection of all active global scripts
|
||||
/// </summary>
|
||||
ReadOnlyCollection<GlobalScript> GlobalScripts { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to create an instance of a global script configured in the provided <see cref="ScriptConfiguration" />
|
||||
/// </summary>
|
||||
/// <param name="scriptConfiguration">The script configuration of the script to instantiate</param>
|
||||
/// <returns>An instance of the script if the script provider was found; otherwise <see langword="null" /></returns>
|
||||
GlobalScript? CreateScriptInstance(ScriptConfiguration scriptConfiguration);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to create an instance of a profile script configured in the provided <see cref="ScriptConfiguration" />
|
||||
/// </summary>
|
||||
/// <param name="profile">The profile the script is bound to</param>
|
||||
/// <param name="scriptConfiguration">The script configuration of the script to instantiate</param>
|
||||
/// <returns>An instance of the script if the script provider was found; otherwise <see langword="null" /></returns>
|
||||
ProfileScript? CreateScriptInstance(Profile profile, ScriptConfiguration scriptConfiguration);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to create an instance of a layer script configured in the provided <see cref="ScriptConfiguration" />
|
||||
/// </summary>
|
||||
/// <param name="layer">The layer the script is bound to</param>
|
||||
/// <param name="scriptConfiguration">The script configuration of the script to instantiate</param>
|
||||
/// <returns>An instance of the script if the script provider was found; otherwise <see langword="null" /></returns>
|
||||
LayerScript? CreateScriptInstance(Layer layer, ScriptConfiguration scriptConfiguration);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to create an instance of a layer property script configured in the provided
|
||||
/// <see cref="ScriptConfiguration" />
|
||||
/// </summary>
|
||||
/// <param name="layerProperty">The layer property the script is bound to</param>
|
||||
/// <param name="scriptConfiguration">The script configuration of the script to instantiate</param>
|
||||
/// <returns>An instance of the script if the script provider was found; otherwise <see langword="null" /></returns>
|
||||
PropertyScript? CreateScriptInstance(ILayerProperty layerProperty, ScriptConfiguration scriptConfiguration);
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using Newtonsoft.Json;
|
||||
using SkiaSharp;
|
||||
|
||||
@ -158,5 +159,15 @@ namespace Artemis.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="canvas"></param>
|
||||
void RenderProfiles(SKCanvas canvas);
|
||||
|
||||
/// <summary>
|
||||
/// Occurs whenever a profile has been activated
|
||||
/// </summary>
|
||||
public event EventHandler<ProfileConfigurationEventArgs>? ProfileActivated;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs whenever a profile has been deactivated
|
||||
/// </summary>
|
||||
public event EventHandler<ProfileConfigurationEventArgs>? ProfileDeactivated;
|
||||
}
|
||||
}
|
||||
@ -317,6 +317,8 @@ namespace Artemis.Core.Services
|
||||
}
|
||||
|
||||
profileConfiguration.Profile = profile;
|
||||
|
||||
OnProfileActivated(new ProfileConfigurationEventArgs(profileConfiguration));
|
||||
return profile;
|
||||
}
|
||||
|
||||
@ -330,6 +332,8 @@ namespace Artemis.Core.Services
|
||||
Profile profile = profileConfiguration.Profile;
|
||||
profileConfiguration.Profile = null;
|
||||
profile.Dispose();
|
||||
|
||||
OnProfileDeactivated(new ProfileConfigurationEventArgs(profileConfiguration));
|
||||
}
|
||||
|
||||
public void DeleteProfile(ProfileConfiguration profileConfiguration)
|
||||
@ -582,5 +586,22 @@ namespace Artemis.Core.Services
|
||||
|
||||
_profileRepository.Save(profile.ProfileEntity);
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
public event EventHandler<ProfileConfigurationEventArgs>? ProfileActivated;
|
||||
public event EventHandler<ProfileConfigurationEventArgs>? ProfileDeactivated;
|
||||
|
||||
protected virtual void OnProfileActivated(ProfileConfigurationEventArgs e)
|
||||
{
|
||||
ProfileActivated?.Invoke(this, e);
|
||||
}
|
||||
|
||||
protected virtual void OnProfileDeactivated(ProfileConfigurationEventArgs e)
|
||||
{
|
||||
ProfileDeactivated?.Invoke(this, e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Storage.Entities.General
|
||||
{
|
||||
public class ScriptConfigurationEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string ScriptingProviderId { get; set; }
|
||||
public string ScriptContent { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.General;
|
||||
using Artemis.Storage.Entities.Profile.Abstract;
|
||||
using Artemis.Storage.Entities.Profile.AdaptionHints;
|
||||
using LiteDB;
|
||||
@ -12,6 +13,7 @@ namespace Artemis.Storage.Entities.Profile
|
||||
{
|
||||
Leds = new List<LedEntity>();
|
||||
AdaptionHints = new List<IAdaptionHintEntity>();
|
||||
ScriptConfigurations = new List<ScriptConfigurationEntity>();
|
||||
PropertyEntities = new List<PropertyEntity>();
|
||||
LayerEffects = new List<LayerEffectEntity>();
|
||||
ExpandedPropertyGroups = new List<string>();
|
||||
@ -23,6 +25,7 @@ namespace Artemis.Storage.Entities.Profile
|
||||
|
||||
public List<LedEntity> Leds { get; set; }
|
||||
public List<IAdaptionHintEntity> AdaptionHints { get; set; }
|
||||
public List<ScriptConfigurationEntity> ScriptConfigurations { get; set; }
|
||||
|
||||
[BsonRef("ProfileEntity")]
|
||||
public ProfileEntity Profile { get; set; }
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Storage.Entities.General;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
{
|
||||
@ -10,15 +11,17 @@ namespace Artemis.Storage.Entities.Profile
|
||||
{
|
||||
Folders = new List<FolderEntity>();
|
||||
Layers = new List<LayerEntity>();
|
||||
ScriptConfigurations = new List<ScriptConfigurationEntity>();
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
|
||||
|
||||
public string Name { get; set; }
|
||||
public bool IsFreshImport { get; set; }
|
||||
|
||||
public List<FolderEntity> Folders { get; set; }
|
||||
public List<LayerEntity> Layers { get; set; }
|
||||
public List<ScriptConfigurationEntity> ScriptConfigurations { get; set; }
|
||||
|
||||
public void UpdateGuid(Guid guid)
|
||||
{
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities.General;
|
||||
using Artemis.Storage.Entities.Profile.DataBindings;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
@ -9,6 +10,7 @@ namespace Artemis.Storage.Entities.Profile
|
||||
{
|
||||
KeyframeEntities = new List<KeyframeEntity>();
|
||||
DataBindingEntities = new List<DataBindingEntity>();
|
||||
ScriptConfigurations = new List<ScriptConfigurationEntity>();
|
||||
}
|
||||
|
||||
public string FeatureId { get; set; }
|
||||
@ -19,5 +21,6 @@ namespace Artemis.Storage.Entities.Profile
|
||||
|
||||
public List<KeyframeEntity> KeyframeEntities { get; set; }
|
||||
public List<DataBindingEntity> DataBindingEntities { get; set; }
|
||||
public List<ScriptConfigurationEntity> ScriptConfigurations { get; set; }
|
||||
}
|
||||
}
|
||||
@ -36,7 +36,7 @@
|
||||
<PackageReference Include="Ben.Demystifier" Version="0.3.0" />
|
||||
<PackageReference Include="Humanizer.Core" Version="2.8.26" />
|
||||
<PackageReference Include="MaterialDesignExtensions" Version="3.3.0" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="4.0.0" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="4.1.0" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
|
||||
<PackageReference Include="Ninject" Version="3.3.4" />
|
||||
<PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" />
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
using Artemis.Core.ScriptingProviders;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared.ScriptingProviders
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a Stylet view model containing a script editor
|
||||
/// </summary>
|
||||
public class ScriptEditorViewModelViewModel : Screen, IScriptEditorViewModel
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public ScriptEditorViewModelViewModel(Script script)
|
||||
{
|
||||
Script = script;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Script Script { get; }
|
||||
}
|
||||
}
|
||||
@ -29,11 +29,11 @@
|
||||
},
|
||||
"MaterialDesignThemes": {
|
||||
"type": "Direct",
|
||||
"requested": "[4.0.0, )",
|
||||
"resolved": "4.0.0",
|
||||
"contentHash": "+n5oWHuRiYL/gUw2XfQHCRZqHtU8KbrdurgU0IcO98Zsyhw4BvggodfXY8veRtbjjmM9EJ/sG2yKBrgPOGX4JQ==",
|
||||
"requested": "[4.1.0, )",
|
||||
"resolved": "4.1.0",
|
||||
"contentHash": "WqrO9AbtdE4pLPtDk/C5BZRnkgWFwVGyUHWj7tRJrgnKl089DEobVXBCLeqp2mkgBeFHj4Xe3AfWyhmlnO6AZA==",
|
||||
"dependencies": {
|
||||
"MaterialDesignColors": "2.0.0"
|
||||
"MaterialDesignColors": "2.0.1"
|
||||
}
|
||||
},
|
||||
"Microsoft.Xaml.Behaviors.Wpf": {
|
||||
@ -150,8 +150,8 @@
|
||||
},
|
||||
"MaterialDesignColors": {
|
||||
"type": "Transitive",
|
||||
"resolved": "2.0.0",
|
||||
"contentHash": "+JoghC3QRK0u9Wul1To1ORjcfTbFTVzFPjJ02H7VREOdNzIIn427e8G9gP9hXu9pm1r2OneLnoCG/lTma5cG2w=="
|
||||
"resolved": "2.0.1",
|
||||
"contentHash": "Azl8nN23SD6QPE0PdsfpKiIqWTvH7rzXwgXPiFSEt91NFOrwB5cx3iq/sbINWMZunhXJ32+jVUHiV03B8eJbZw=="
|
||||
},
|
||||
"McMaster.NETCore.Plugins": {
|
||||
"type": "Transitive",
|
||||
|
||||
@ -143,7 +143,7 @@
|
||||
<PackageReference Include="Hardcodet.NotifyIcon.Wpf.NetCore" Version="1.0.18" />
|
||||
<PackageReference Include="Humanizer.Core" Version="2.8.26" />
|
||||
<PackageReference Include="MaterialDesignExtensions" Version="3.3.0" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="4.0.0" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="4.1.0" />
|
||||
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.0.2" />
|
||||
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Modules;
|
||||
using Artemis.UI.Screens.Header;
|
||||
using Artemis.UI.Screens.Plugins;
|
||||
using Artemis.UI.Screens.ProfileEditor.Conditions;
|
||||
using Artemis.UI.Screens.ProfileEditor.LayerProperties;
|
||||
@ -60,6 +61,11 @@ namespace Artemis.UI.Ninject.Factories
|
||||
KeyboardSectionAdaptionHintViewModel KeyboardSectionAdaptionHintViewModel(KeyboardSectionAdaptionHint adaptionHint);
|
||||
}
|
||||
|
||||
public interface IHeaderVmFactory : IVmFactory
|
||||
{
|
||||
SimpleHeaderViewModel SimpleHeaderViewModel(string displayName);
|
||||
}
|
||||
|
||||
public interface IProfileLayerVmFactory : IVmFactory
|
||||
{
|
||||
ProfileLayerViewModel Create(Layer layer, PanZoomViewModel panZoomViewModel);
|
||||
|
||||
@ -33,7 +33,7 @@ namespace Artemis.UI.Ninject
|
||||
{
|
||||
x.FromThisAssembly()
|
||||
.SelectAllClasses()
|
||||
.InheritedFrom<IMainScreenViewModel>()
|
||||
.InheritedFrom<MainScreenViewModel>()
|
||||
.BindAllBaseClasses()
|
||||
.Configure(c => c.InSingletonScope());
|
||||
});
|
||||
|
||||
35
src/Artemis.UI/Screens/Header/SimpleHeaderView.xaml
Normal file
35
src/Artemis.UI/Screens/Header/SimpleHeaderView.xaml
Normal file
@ -0,0 +1,35 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Header.SimpleHeaderView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Header"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:SimpleHeaderViewModel}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0"
|
||||
Text="{Binding DisplayName}"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"
|
||||
Margin="15 0" />
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding FrameTime}" VerticalAlignment="Center" FontSize="14" Margin="10 0" ToolTip="The time the last frame took to render" />
|
||||
|
||||
<!-- Bug: materialDesign:RippleAssist.RippleOnTop doesn't look as nice but otherwise it doesn't work at all, not sure why -->
|
||||
<Button Style="{StaticResource MaterialDesignIconForegroundButton}"
|
||||
VerticalAlignment="Center"
|
||||
ToolTip="Open debugger"
|
||||
Command="{s:Action ShowDebugger}"
|
||||
materialDesign:RippleAssist.RippleOnTop="True">
|
||||
<materialDesign:PackIcon Kind="Matrix" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
69
src/Artemis.UI/Screens/Header/SimpleHeaderViewModel.cs
Normal file
69
src/Artemis.UI/Screens/Header/SimpleHeaderViewModel.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using System.Timers;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Services;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Header
|
||||
{
|
||||
public class SimpleHeaderViewModel : Screen
|
||||
{
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly IDebugService _debugService;
|
||||
private string _frameTime;
|
||||
private Timer _frameTimeUpdateTimer;
|
||||
|
||||
public SimpleHeaderViewModel(string displayName, ICoreService coreService, IDebugService debugService)
|
||||
{
|
||||
DisplayName = displayName;
|
||||
|
||||
_coreService = coreService;
|
||||
_debugService = debugService;
|
||||
}
|
||||
|
||||
public string FrameTime
|
||||
{
|
||||
get => _frameTime;
|
||||
set => SetAndNotify(ref _frameTime, value);
|
||||
}
|
||||
|
||||
public void ShowDebugger()
|
||||
{
|
||||
_debugService.ShowDebugger();
|
||||
}
|
||||
|
||||
private void UpdateFrameTime()
|
||||
{
|
||||
FrameTime = $"Frame time: {_coreService.FrameTime.TotalMilliseconds:F2} ms";
|
||||
}
|
||||
|
||||
private void OnFrameTimeUpdateTimerOnElapsed(object sender, ElapsedEventArgs args)
|
||||
{
|
||||
UpdateFrameTime();
|
||||
}
|
||||
|
||||
#region Overrides of Screen
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
_frameTimeUpdateTimer = new Timer(500);
|
||||
_frameTimeUpdateTimer.Elapsed += OnFrameTimeUpdateTimerOnElapsed;
|
||||
_frameTimeUpdateTimer.Start();
|
||||
|
||||
UpdateFrameTime();
|
||||
base.OnInitialActivate();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnClose()
|
||||
{
|
||||
_frameTimeUpdateTimer.Elapsed -= OnFrameTimeUpdateTimerOnElapsed;
|
||||
_frameTimeUpdateTimer?.Dispose();
|
||||
_frameTimeUpdateTimer = null;
|
||||
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,13 @@
|
||||
using Stylet;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
|
||||
namespace Artemis.UI.Screens.Home
|
||||
{
|
||||
public class HomeViewModel : Screen, IMainScreenViewModel
|
||||
public class HomeViewModel : MainScreenViewModel
|
||||
{
|
||||
public HomeViewModel()
|
||||
public HomeViewModel(IHeaderVmFactory headerVmFactory)
|
||||
{
|
||||
DisplayName = "Home";
|
||||
HeaderViewModel = headerVmFactory.SimpleHeaderViewModel(DisplayName);
|
||||
}
|
||||
|
||||
public void OpenUrl(string url)
|
||||
|
||||
@ -1,6 +1,19 @@
|
||||
namespace Artemis.UI.Screens
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens
|
||||
{
|
||||
public interface IMainScreenViewModel
|
||||
public abstract class MainScreenViewModel : Screen
|
||||
{
|
||||
private Screen _headerViewModel;
|
||||
|
||||
public Screen HeaderViewModel
|
||||
{
|
||||
get => _headerViewModel;
|
||||
set
|
||||
{
|
||||
if (!SetAndNotify(ref _headerViewModel, value)) return;
|
||||
_headerViewModel.ConductWith(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7,8 +7,7 @@
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:profileEditor="clr-namespace:Artemis.UI.Screens.ProfileEditor"
|
||||
xmlns:behaviors="clr-namespace:Artemis.UI.Behaviors"
|
||||
xmlns:dataTemplateSelectors="clr-namespace:Artemis.UI.DataTemplateSelectors"
|
||||
xmlns:profile="clr-namespace:Artemis.Core;assembly=Artemis.Core"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
mc:Ignorable="d"
|
||||
behaviors:InputBindingBehavior.PropagateInputBindingsToWindow="True"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
@ -29,70 +28,202 @@
|
||||
<KeyBinding Command="{s:Action Redo}" Modifiers="Control" Key="Y" />
|
||||
</UserControl.InputBindings>
|
||||
|
||||
<Grid Margin="10">
|
||||
<Grid ClipToBounds="True">
|
||||
<Grid.ColumnDefinitions>
|
||||
<!-- Left side -->
|
||||
<ColumnDefinition Width="*" MinWidth="100" />
|
||||
<!-- Side panels resize -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<!-- Side panels -->
|
||||
<ColumnDefinition Width="{Binding SidePanelsWidth.Value, Mode=TwoWay}" MinWidth="100" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<shared:ProfileConfigurationIcon Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Width="25"
|
||||
Height="25"
|
||||
Margin="25 -5 25 0"
|
||||
ToolTip="{Binding ProfileConfiguration.Name}"
|
||||
ConfigurationIcon="{Binding ProfileConfiguration.Icon}" />
|
||||
|
||||
<Menu Grid.Row="0" Grid.Column="1" IsMainMenu="True" Margin="0 -4 0 0">
|
||||
<MenuItem Header="_File">
|
||||
<MenuItem Header="New" Icon="{materialDesign:PackIcon Kind=Plus}">
|
||||
<MenuItem Header="Folder"
|
||||
Icon="{materialDesign:PackIcon Kind=Folder}"
|
||||
Command="{s:Action AddFolder}"
|
||||
s:View.ActionTarget="{Binding ProfileTreeViewModel}" />
|
||||
<MenuItem Header="Layer"
|
||||
Icon="{materialDesign:PackIcon Kind=Layers}"
|
||||
Command="{s:Action AddLayer}"
|
||||
s:View.ActionTarget="{Binding ProfileTreeViewModel}" />
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="View properties"
|
||||
Icon="{materialDesign:PackIcon Kind=Settings}"
|
||||
Command="{s:Action ViewProperties}"/>
|
||||
<MenuItem Header="Suspend profile"
|
||||
IsCheckable="True"
|
||||
IsChecked="{Binding ProfileConfiguration.IsSuspended}" />
|
||||
<Separator />
|
||||
<MenuItem Header="Export profile"
|
||||
Icon="{materialDesign:PackIcon Kind=Export}"
|
||||
Command="{s:Action ExportProfile}" />
|
||||
<MenuItem Header="Duplicate profile"
|
||||
Icon="{materialDesign:PackIcon Kind=ContentDuplicate}"
|
||||
Command="{s:Action DuplicateProfile}" />
|
||||
<Separator />
|
||||
<MenuItem Header="Delete profile"
|
||||
Icon="{materialDesign:PackIcon Kind=Trash}"
|
||||
Command="{s:Action DeleteProfile}" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Edit" SubmenuOpened="{s:Action EditMenuOpened}">
|
||||
<MenuItem Header="_Duplicate"
|
||||
Icon="{materialDesign:PackIcon Kind=ContentDuplicate}"
|
||||
Command="{s:Action Duplicate}"
|
||||
InputGestureText="Ctrl+D"
|
||||
IsEnabled="{Binding HasSelectedElement}"/>
|
||||
<MenuItem Header="_Copy"
|
||||
Icon="{materialDesign:PackIcon Kind=ContentCopy}"
|
||||
Command="{s:Action Copy}"
|
||||
InputGestureText="Ctrl+C"
|
||||
IsEnabled="{Binding HasSelectedElement}"/>
|
||||
<MenuItem Header="_Paste"
|
||||
Icon="{materialDesign:PackIcon Kind=ContentPaste}"
|
||||
Command="{s:Action Paste}"
|
||||
InputGestureText="Ctrl+V" />
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Scripting" IsEnabled="False">
|
||||
<MenuItem Header="_Profile scripts"
|
||||
Icon="{materialDesign:PackIcon Kind=BookEdit}" />
|
||||
<MenuItem Header="_Layer scripts"
|
||||
Icon="{materialDesign:PackIcon Kind=Layers}"
|
||||
IsEnabled="{Binding HasSelectedElement}"/>
|
||||
<MenuItem Header="_Property scripts"
|
||||
Icon="{materialDesign:PackIcon Kind=FormTextbox}"
|
||||
IsEnabled="{Binding HasSelectedElement}"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="_Help">
|
||||
<MenuItem Header="Artemis wiki"
|
||||
Icon="{materialDesign:PackIcon Kind=BookEdit}"
|
||||
Command="{s:Action OpenUrl}"
|
||||
CommandParameter="https://wiki.artemis-rgb.com/" />
|
||||
<Separator />
|
||||
<MenuItem Header="Editor"
|
||||
Icon="{materialDesign:PackIcon Kind=Edit}"
|
||||
Command="{s:Action OpenUrl}"
|
||||
CommandParameter="https://wiki.artemis-rgb.com/en/guides/user/profiles" />
|
||||
<MenuItem Header="Layers"
|
||||
Icon="{materialDesign:PackIcon Kind=Layers}"
|
||||
Command="{s:Action OpenUrl}"
|
||||
CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/layers" />
|
||||
<MenuItem Header="Display conditions"
|
||||
Icon="{materialDesign:PackIcon Kind=NotEqual}"
|
||||
Command="{s:Action OpenUrl}"
|
||||
CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/conditions" />
|
||||
<MenuItem Header="Timeline"
|
||||
Icon="{materialDesign:PackIcon Kind=Stopwatch}"
|
||||
Command="{s:Action OpenUrl}"
|
||||
CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/timeline" />
|
||||
<MenuItem Header="Data bindings"
|
||||
Icon="{materialDesign:PackIcon Kind=VectorLink}"
|
||||
Command="{s:Action OpenUrl}"
|
||||
CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/data-bindings" />
|
||||
<MenuItem Header="Scripting"
|
||||
Icon="{materialDesign:PackIcon Kind=CodeJson}"
|
||||
Command="{s:Action OpenUrl}"
|
||||
CommandParameter="https://wiki.artemis-rgb.com/guides/user/profiles/scripting" />
|
||||
<Separator />
|
||||
<MenuItem Header="Report a bug"
|
||||
Icon="{materialDesign:PackIcon Kind=Github}"
|
||||
Command="{s:Action OpenUrl}"
|
||||
CommandParameter="https://github.com/Artemis-RGB/Artemis/issues" />
|
||||
<MenuItem Header="Get help on Discord"
|
||||
Icon="{materialDesign:PackIcon Kind=Discord}"
|
||||
Command="{s:Action OpenUrl}"
|
||||
CommandParameter="https://discord.gg/S3MVaC9" />
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
|
||||
<Button Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Style="{StaticResource MaterialDesignIconForegroundButton}"
|
||||
ToolTip="Open debugger"
|
||||
Margin="10 -4 10 0"
|
||||
Width="34"
|
||||
Height="34"
|
||||
Command="{s:Action OpenDebugger}">
|
||||
<materialDesign:PackIcon Kind="Matrix" Width="20" Height="20" />
|
||||
</Button>
|
||||
|
||||
<Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Margin="10 -5 10 10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<!-- Left side -->
|
||||
<ColumnDefinition Width="*" MinWidth="100" />
|
||||
<!-- Side panels resize -->
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<!-- Side panels -->
|
||||
<ColumnDefinition Width="{Binding SidePanelsWidth.Value, Mode=TwoWay}" MinWidth="100" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Left side -->
|
||||
<Grid Grid.Row="0" Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
<!-- Design area -->
|
||||
<RowDefinition Height="*" MinHeight="200" />
|
||||
<!-- Bottom panels resize -->
|
||||
<RowDefinition Height="Auto" />
|
||||
<!-- Bottom panels -->
|
||||
<RowDefinition Height="{Binding BottomPanelsHeight.Value, Mode=TwoWay}" MinHeight="108" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Left side -->
|
||||
<Grid Grid.Row="0" Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
<!-- Design area -->
|
||||
<RowDefinition Height="*" MinHeight="200" />
|
||||
<materialDesign:Card Grid.Row="0" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
|
||||
<ContentControl s:View.Model="{Binding ProfileViewModel, IsAsync=True}" />
|
||||
</materialDesign:Card>
|
||||
|
||||
<!-- Bottom panels resize -->
|
||||
<RowDefinition Height="Auto" />
|
||||
<GridSplitter Grid.Row="1" Grid.Column="0" Height="5" HorizontalAlignment="Stretch" Cursor="SizeNS" Margin="0 5" />
|
||||
|
||||
<!-- Bottom panels -->
|
||||
<RowDefinition Height="{Binding BottomPanelsHeight.Value, Mode=TwoWay}" MinHeight="108" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Design area -->
|
||||
<materialDesign:Card Grid.Row="0" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
|
||||
<ContentControl s:View.Model="{Binding ProfileViewModel, IsAsync=True}" />
|
||||
</materialDesign:Card>
|
||||
<Grid Grid.Row="2">
|
||||
<!-- Layer elements -->
|
||||
<materialDesign:Card Grid.Column="0" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
|
||||
<ContentControl s:View.Model="{Binding LayerPropertiesViewModel, IsAsync=True}" />
|
||||
</materialDesign:Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<!-- Bottom panels resize -->
|
||||
<GridSplitter Grid.Row="1" Grid.Column="0" Height="5" HorizontalAlignment="Stretch" Cursor="SizeNS" Margin="0 5" />
|
||||
<!-- Side panels resize -->
|
||||
<GridSplitter Grid.Row="0" Grid.Column="1" Width="5" HorizontalAlignment="Stretch" Cursor="SizeWE" Margin="5 0" />
|
||||
|
||||
<!-- Bottom panels -->
|
||||
<Grid Grid.Row="2">
|
||||
<!-- Layer elements -->
|
||||
<materialDesign:Card Grid.Column="0" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
|
||||
<ContentControl s:View.Model="{Binding LayerPropertiesViewModel, IsAsync=True}" />
|
||||
<!-- Side panels -->
|
||||
<Grid Grid.Row="0" Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<!-- Profile elements -->
|
||||
<RowDefinition Height="*" MinHeight="100" />
|
||||
<!-- Conditions resize -->
|
||||
<RowDefinition Height="Auto" />
|
||||
<!-- Display conditions -->
|
||||
<RowDefinition Height="{Binding DataModelConditionsHeight.Value, Mode=TwoWay}" MinHeight="100" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Profile elements -->
|
||||
<materialDesign:Card Grid.Row="0" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
|
||||
<ContentControl s:View.Model="{Binding ProfileTreeViewModel, IsAsync=True}" Margin="0,-1,-0.2,1" />
|
||||
</materialDesign:Card>
|
||||
|
||||
<!-- Conditions resize -->
|
||||
<GridSplitter Grid.Row="1" Height="5" HorizontalAlignment="Stretch" Cursor="SizeNS" Margin="0 5" />
|
||||
|
||||
<!-- Display conditions -->
|
||||
<materialDesign:Card Grid.Row="2" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
|
||||
<ContentControl s:View.Model="{Binding DisplayConditionsViewModel, IsAsync=True}" />
|
||||
</materialDesign:Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<!-- Side panels resize -->
|
||||
<GridSplitter Grid.Row="0" Grid.Column="1" Width="5" HorizontalAlignment="Stretch" Cursor="SizeWE" Margin="5 0" />
|
||||
|
||||
<!-- Side panels -->
|
||||
<Grid Grid.Row="0" Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<!-- Profile elements -->
|
||||
<RowDefinition Height="*" MinHeight="100" />
|
||||
<!-- Conditions resize -->
|
||||
<RowDefinition Height="Auto" />
|
||||
<!-- Display conditions -->
|
||||
<RowDefinition Height="{Binding DataModelConditionsHeight.Value, Mode=TwoWay}" MinHeight="100" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Profile elements -->
|
||||
<materialDesign:Card Grid.Row="0" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
|
||||
<ContentControl s:View.Model="{Binding ProfileTreeViewModel, IsAsync=True}" Margin="0,-1,-0.2,1" />
|
||||
</materialDesign:Card>
|
||||
|
||||
<!-- Conditions resize -->
|
||||
<GridSplitter Grid.Row="1" Height="5" HorizontalAlignment="Stretch" Cursor="SizeNS" Margin="0 5" />
|
||||
|
||||
<!-- Display conditions -->
|
||||
<materialDesign:Card Grid.Row="2" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
|
||||
<ContentControl s:View.Model="{Binding DisplayConditionsViewModel, IsAsync=True}" />
|
||||
</materialDesign:Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
</UserControl>
|
||||
@ -5,18 +5,25 @@ using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.ProfileEditor.DisplayConditions;
|
||||
using Artemis.UI.Screens.ProfileEditor.LayerProperties;
|
||||
using Artemis.UI.Screens.ProfileEditor.ProfileTree;
|
||||
using Artemis.UI.Screens.ProfileEditor.Visualization;
|
||||
using Artemis.UI.Screens.Sidebar.Dialogs;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Stylet;
|
||||
using ProfileConfigurationEventArgs = Artemis.UI.Shared.ProfileConfigurationEventArgs;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor
|
||||
{
|
||||
public class ProfileEditorViewModel : Screen, IMainScreenViewModel
|
||||
public class ProfileEditorViewModel : MainScreenViewModel
|
||||
{
|
||||
private readonly IMessageService _messageService;
|
||||
private readonly ISidebarVmFactory _sidebarVmFactory;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
@ -37,12 +44,14 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
IProfileService profileService,
|
||||
IDialogService dialogService,
|
||||
ISettingsService settingsService,
|
||||
IMessageService messageService)
|
||||
IMessageService messageService,
|
||||
ISidebarVmFactory sidebarVmFactory)
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
_profileService = profileService;
|
||||
_settingsService = settingsService;
|
||||
_messageService = messageService;
|
||||
_sidebarVmFactory = sidebarVmFactory;
|
||||
|
||||
DisplayName = "Profile Editor";
|
||||
DialogService = dialogService;
|
||||
@ -60,6 +69,8 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
|
||||
public IDialogService DialogService { get; }
|
||||
|
||||
public ProfileConfiguration ProfileConfiguration => _profileEditorService.SelectedProfileConfiguration;
|
||||
|
||||
public DisplayConditionsViewModel DisplayConditionsViewModel
|
||||
{
|
||||
get => _displayConditionsViewModel;
|
||||
@ -176,20 +187,96 @@ namespace Artemis.UI.Screens.ProfileEditor
|
||||
_messageService.ShowMessage("Redid profile update", "UNDO", Undo);
|
||||
}
|
||||
|
||||
#region Menu
|
||||
|
||||
public bool HasSelectedElement => _profileEditorService.SelectedProfileElement != null;
|
||||
public bool CanPaste => _profileEditorService.GetCanPasteProfileElement();
|
||||
|
||||
public async Task ViewProperties()
|
||||
{
|
||||
await _sidebarVmFactory.SidebarProfileConfigurationViewModel(_profileEditorService.SelectedProfileConfiguration).ViewProperties();
|
||||
}
|
||||
|
||||
public void DuplicateProfile()
|
||||
{
|
||||
ProfileConfigurationExportModel export = _profileService.ExportProfile(ProfileConfiguration);
|
||||
_profileService.ImportProfile(ProfileConfiguration.Category, export, true, false, "copy");
|
||||
}
|
||||
|
||||
public async Task DeleteProfile()
|
||||
{
|
||||
await _sidebarVmFactory.SidebarProfileConfigurationViewModel(_profileEditorService.SelectedProfileConfiguration).Delete();
|
||||
}
|
||||
|
||||
public async Task ExportProfile()
|
||||
{
|
||||
await _sidebarVmFactory.SidebarProfileConfigurationViewModel(_profileEditorService.SelectedProfileConfiguration).Export();
|
||||
}
|
||||
|
||||
public void Copy()
|
||||
{
|
||||
if (_profileEditorService.SelectedProfileElement != null)
|
||||
_profileEditorService.CopyProfileElement(_profileEditorService.SelectedProfileElement);
|
||||
}
|
||||
|
||||
public void Duplicate()
|
||||
{
|
||||
if (_profileEditorService.SelectedProfileElement != null)
|
||||
_profileEditorService.DuplicateProfileElement(_profileEditorService.SelectedProfileElement);
|
||||
}
|
||||
|
||||
public void Paste()
|
||||
{
|
||||
if (_profileEditorService.SelectedProfileElement != null && _profileEditorService.SelectedProfileElement.Parent is Folder parent)
|
||||
_profileEditorService.PasteProfileElement(parent, _profileEditorService.SelectedProfileElement.Order - 1);
|
||||
else
|
||||
{
|
||||
Folder rootFolder = _profileEditorService.SelectedProfile?.GetRootFolder();
|
||||
if (rootFolder != null)
|
||||
_profileEditorService.PasteProfileElement(rootFolder, rootFolder.Children.Count);
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenUrl(string url)
|
||||
{
|
||||
Core.Utilities.OpenUrl(url);
|
||||
}
|
||||
|
||||
public void EditMenuOpened()
|
||||
{
|
||||
NotifyOfPropertyChange(nameof(CanPaste));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
_profileEditorService.SelectedProfileChanged += ProfileEditorServiceOnSelectedProfileChanged;
|
||||
_profileEditorService.SelectedProfileElementChanged += ProfileEditorServiceOnSelectedProfileElementChanged;
|
||||
LoadWorkspaceSettings();
|
||||
base.OnInitialActivate();
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
_profileEditorService.SelectedProfileChanged -= ProfileEditorServiceOnSelectedProfileChanged;
|
||||
_profileEditorService.SelectedProfileElementChanged -= ProfileEditorServiceOnSelectedProfileElementChanged;
|
||||
SaveWorkspaceSettings();
|
||||
_profileEditorService.ChangeSelectedProfileConfiguration(null);
|
||||
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnSelectedProfileChanged(object sender, ProfileConfigurationEventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(nameof(ProfileConfiguration));
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnSelectedProfileElementChanged(object sender, RenderProfileElementEventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(nameof(HasSelectedElement));
|
||||
}
|
||||
private void LoadWorkspaceSettings()
|
||||
{
|
||||
SidePanelsWidth = _settingsService.GetSetting("ProfileEditor.SidePanelsWidth", new GridLength(385));
|
||||
|
||||
@ -100,7 +100,7 @@
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
|
||||
<Grid Name="EditorDisplayGrid"
|
||||
<Grid Name="EditorDisplayGrid"
|
||||
shared:SizeObserver.Observe="True"
|
||||
shared:SizeObserver.ObservedHeight="{Binding PanZoomViewModel.CanvasHeight}"
|
||||
shared:SizeObserver.ObservedWidth="{Binding PanZoomViewModel.CanvasWidth}">
|
||||
@ -133,13 +133,13 @@
|
||||
<StackPanel ZIndex="1" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="10" Cursor="Arrow">
|
||||
<materialDesign:Card Padding="8">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
||||
IsChecked="{Binding FocusSelectedLayer.Value}"
|
||||
ToolTip="If selected, dims all LEDs that are not part of the selected layer">
|
||||
Focus selected layer
|
||||
</CheckBox>
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
||||
Margin="10 0 0 0"
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
||||
Margin="10 0 0 0"
|
||||
IsChecked="{Binding AlwaysApplyDataBindings.Value}"
|
||||
ToolTip="If selected, updates all data bindings instead of only the one you are editing">
|
||||
Apply all data bindings in editor
|
||||
@ -150,14 +150,13 @@
|
||||
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom" HorizontalAlignment="Right"
|
||||
Margin="10" ZIndex="1">
|
||||
<Slider Margin="0,0,14,0"
|
||||
Orientation="Vertical"
|
||||
<Slider Orientation="Vertical"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0 10"
|
||||
Height="120"
|
||||
Minimum="10"
|
||||
Maximum="250"
|
||||
Height="100"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
Value="{Binding PanZoomViewModel.ZoomPercentage}"
|
||||
Style="{StaticResource MaterialDesignDiscreteSlider}" />
|
||||
Value="{Binding PanZoomViewModel.ZoomPercentage}" />
|
||||
<Button Command="{s:Action ResetZoomAndPan}"
|
||||
Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
|
||||
HorizontalAlignment="Right"
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<mde:MaterialWindow x:Class="Artemis.UI.Screens.RootView"
|
||||
<mde:MaterialWindow
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
@ -8,6 +8,7 @@
|
||||
xmlns:screens="clr-namespace:Artemis.UI.Screens"
|
||||
xmlns:mde="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
|
||||
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
|
||||
xmlns:Shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared" x:Class="Artemis.UI.Screens.RootView"
|
||||
mc:Ignorable="d"
|
||||
FadeContentIfInactive="False"
|
||||
Icon="/Resources/Images/Logo/bow.ico"
|
||||
@ -24,7 +25,10 @@
|
||||
MouseDown="{s:Action WindowMouseDown}"
|
||||
MouseUp="{s:Action WindowMouseUp}"
|
||||
d:DesignHeight="640" d:DesignWidth="1200"
|
||||
d:DataContext="{d:DesignInstance screens:RootViewModel}">
|
||||
d:DataContext="{d:DesignInstance {x:Type screens:RootViewModel}}">
|
||||
<mde:MaterialWindow.Resources>
|
||||
<Shared:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/>
|
||||
</mde:MaterialWindow.Resources>
|
||||
<materialDesign:DialogHost IsTabStop="False" Focusable="False" Identifier="RootDialog" DialogTheme="Inherit" SnackbarMessageQueue="{Binding MainMessageQueue}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
@ -42,30 +46,13 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<materialDesign:ColorZone Grid.Row="0" Mode="PrimaryMid" DockPanel.Dock="Top" DockPanel.ZIndex="1" Height="42">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0"
|
||||
Text="{Binding SidebarViewModel.SelectedScreen.DisplayName}"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="20"
|
||||
Margin="15 0" />
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding FrameTime}" VerticalAlignment="Center" FontSize="14" Margin="10 0" ToolTip="The time the last frame took to render" />
|
||||
|
||||
<!-- Bug: materialDesign:RippleAssist.RippleOnTop doesn't look as nice but otherwise it doesn't work at all, not sure why -->
|
||||
<Button Style="{StaticResource MaterialDesignIconForegroundButton}"
|
||||
VerticalAlignment="Center"
|
||||
ToolTip="Open debugger"
|
||||
Command="{s:Action ShowDebugger}"
|
||||
materialDesign:RippleAssist.RippleOnTop="True">
|
||||
<materialDesign:PackIcon Kind="Matrix" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<materialDesign:ColorZone Grid.Row="0"
|
||||
Mode="PrimaryMid"
|
||||
DockPanel.Dock="Top"
|
||||
Panel.ZIndex="1"
|
||||
Height="48"
|
||||
Visibility="{Binding SidebarViewModel.SelectedScreen.HeaderViewModel, Converter={StaticResource NullToVisibilityConverter}}" >
|
||||
<ContentControl s:View.Model="{Binding SidebarViewModel.SelectedScreen.HeaderViewModel}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" />
|
||||
</materialDesign:ColorZone>
|
||||
|
||||
<ContentControl Grid.Row="1"
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core;
|
||||
@ -21,19 +19,17 @@ using Constants = Artemis.Core.Constants;
|
||||
|
||||
namespace Artemis.UI.Screens
|
||||
{
|
||||
public sealed class RootViewModel : Conductor<Screen>, IDisposable
|
||||
public sealed class RootViewModel : Conductor<Screen>
|
||||
{
|
||||
private readonly IRegistrationService _builtInRegistrationService;
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly IDebugService _debugService;
|
||||
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly Timer _frameTimeUpdateTimer;
|
||||
private readonly IKernel _kernel;
|
||||
private readonly IMessageService _messageService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IWindowManager _windowManager;
|
||||
private readonly PluginSetting<WindowSize> _windowSize;
|
||||
private string _frameTime;
|
||||
|
||||
private bool _lostFocus;
|
||||
private ISnackbarMessageQueue _mainMessageQueue;
|
||||
private MaterialWindow _window;
|
||||
@ -43,9 +39,7 @@ namespace Artemis.UI.Screens
|
||||
IKernel kernel,
|
||||
IEventAggregator eventAggregator,
|
||||
ISettingsService settingsService,
|
||||
ICoreService coreService,
|
||||
IWindowManager windowManager,
|
||||
IDebugService debugService,
|
||||
IRegistrationService builtInRegistrationService,
|
||||
IMessageService messageService,
|
||||
SidebarViewModel sidebarViewModel)
|
||||
@ -53,12 +47,9 @@ namespace Artemis.UI.Screens
|
||||
_kernel = kernel;
|
||||
_eventAggregator = eventAggregator;
|
||||
_settingsService = settingsService;
|
||||
_coreService = coreService;
|
||||
_windowManager = windowManager;
|
||||
_debugService = debugService;
|
||||
_builtInRegistrationService = builtInRegistrationService;
|
||||
_messageService = messageService;
|
||||
_frameTimeUpdateTimer = new Timer(500);
|
||||
_windowSize = _settingsService.GetSetting<WindowSize>("UI.RootWindowSize");
|
||||
|
||||
SidebarWidth = _settingsService.GetSetting("UI.SidebarWidth", new GridLength(240));
|
||||
@ -84,11 +75,6 @@ namespace Artemis.UI.Screens
|
||||
set => SetAndNotify(ref _windowTitle, value);
|
||||
}
|
||||
|
||||
public string FrameTime
|
||||
{
|
||||
get => _frameTime;
|
||||
set => SetAndNotify(ref _frameTime, value);
|
||||
}
|
||||
|
||||
public void WindowDeactivated()
|
||||
{
|
||||
@ -109,11 +95,6 @@ namespace Artemis.UI.Screens
|
||||
_eventAggregator.Publish(new MainWindowFocusChangedEvent(true));
|
||||
}
|
||||
|
||||
public void ShowDebugger()
|
||||
{
|
||||
_debugService.ShowDebugger();
|
||||
}
|
||||
|
||||
public void WindowKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
_eventAggregator.Publish(new MainWindowKeyEvent(sender, true, e));
|
||||
@ -134,22 +115,6 @@ namespace Artemis.UI.Screens
|
||||
_eventAggregator.Publish(new MainWindowMouseEvent(sender, false, e));
|
||||
}
|
||||
|
||||
private void UpdateFrameTime()
|
||||
{
|
||||
FrameTime = $"Frame time: {_coreService.FrameTime.TotalMilliseconds:F2} ms";
|
||||
}
|
||||
|
||||
private void OnFrameTimeUpdateTimerOnElapsed(object sender, ElapsedEventArgs args)
|
||||
{
|
||||
UpdateFrameTime();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
_frameTimeUpdateTimer?.Dispose();
|
||||
}
|
||||
|
||||
private void SidebarViewModelOnSelectedScreenChanged(object? sender, EventArgs e)
|
||||
{
|
||||
ActiveItem = SidebarViewModel.SelectedScreen;
|
||||
@ -181,8 +146,6 @@ namespace Artemis.UI.Screens
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
MainMessageQueue = _messageService.MainMessageQueue;
|
||||
UpdateFrameTime();
|
||||
|
||||
SidebarViewModel.SelectedScreenChanged += SidebarViewModelOnSelectedScreenChanged;
|
||||
ActiveItem = SidebarViewModel.SelectedScreen;
|
||||
|
||||
@ -190,9 +153,6 @@ namespace Artemis.UI.Screens
|
||||
_builtInRegistrationService.RegisterBuiltInDataModelInputs();
|
||||
_builtInRegistrationService.RegisterBuiltInPropertyEditors();
|
||||
|
||||
_frameTimeUpdateTimer.Elapsed += OnFrameTimeUpdateTimerOnElapsed;
|
||||
_frameTimeUpdateTimer.Start();
|
||||
|
||||
_window = (MaterialWindow) View;
|
||||
|
||||
PluginSetting<bool> setupWizardCompleted = _settingsService.GetSetting("UI.SetupWizardCompleted", false);
|
||||
@ -209,7 +169,6 @@ namespace Artemis.UI.Screens
|
||||
Keyboard.ClearFocus();
|
||||
|
||||
MainMessageQueue = null;
|
||||
_frameTimeUpdateTimer.Stop();
|
||||
|
||||
SidebarViewModel.SelectedScreenChanged -= SidebarViewModelOnSelectedScreenChanged;
|
||||
SidebarWidth.Save();
|
||||
@ -217,8 +176,6 @@ namespace Artemis.UI.Screens
|
||||
_windowSize.Value.ApplyFromWindow(_window);
|
||||
_windowSize.Save();
|
||||
|
||||
_frameTimeUpdateTimer.Elapsed -= OnFrameTimeUpdateTimerOnElapsed;
|
||||
|
||||
// Lets force the GC to run after closing the window so it is obvious to users watching task manager
|
||||
// that closing the UI will decrease the memory footprint of the application.
|
||||
Task.Run(async () =>
|
||||
|
||||
24
src/Artemis.UI/Screens/Scripting/ScriptsDialogViewModel.cs
Normal file
24
src/Artemis.UI/Screens/Scripting/ScriptsDialogViewModel.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using Artemis.Core;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Scripting
|
||||
{
|
||||
public class ScriptsDialogViewModel : Conductor<ScriptConfigurationViewModel>.Collection.OneActive
|
||||
{
|
||||
public ScriptsDialogViewModel(Profile profile)
|
||||
{
|
||||
}
|
||||
|
||||
public ScriptsDialogViewModel(Layer layer)
|
||||
{
|
||||
}
|
||||
|
||||
public ScriptsDialogViewModel(ILayerProperty layerProperty)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class ScriptConfigurationViewModel : Screen
|
||||
{
|
||||
}
|
||||
}
|
||||
33
src/Artemis.UI/Screens/Settings/SettingsTabsView.xaml
Normal file
33
src/Artemis.UI/Screens/Settings/SettingsTabsView.xaml
Normal file
@ -0,0 +1,33 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Settings.SettingsTabsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Settings"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:SettingsTabsViewModel}">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary
|
||||
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBlock.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<TabControl Style="{StaticResource MaterialDesignAppBarTabControl}"
|
||||
ItemsSource="{Binding Items}"
|
||||
SelectedItem="{Binding ActiveItem}"
|
||||
DisplayMemberPath="DisplayName">
|
||||
<TabControl.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding IsAsync=True}"
|
||||
VerticalContentAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
IsTabStop="False"
|
||||
TextElement.Foreground="{DynamicResource MaterialDesignBody}" />
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
</TabControl>
|
||||
</UserControl>
|
||||
27
src/Artemis.UI/Screens/Settings/SettingsTabsViewModel.cs
Normal file
27
src/Artemis.UI/Screens/Settings/SettingsTabsViewModel.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using Artemis.UI.Screens.Settings.Tabs.About;
|
||||
using Artemis.UI.Screens.Settings.Tabs.Devices;
|
||||
using Artemis.UI.Screens.Settings.Tabs.General;
|
||||
using Artemis.UI.Screens.Settings.Tabs.Plugins;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings
|
||||
{
|
||||
public class SettingsTabsViewModel : Conductor<Screen>.Collection.OneActive
|
||||
{
|
||||
public SettingsTabsViewModel(
|
||||
GeneralSettingsTabViewModel generalSettingsTabViewModel,
|
||||
PluginSettingsTabViewModel pluginSettingsTabViewModel,
|
||||
DeviceSettingsTabViewModel deviceSettingsTabViewModel,
|
||||
AboutTabViewModel aboutTabViewModel)
|
||||
{
|
||||
DisplayName = "Settings";
|
||||
|
||||
Items.Add(generalSettingsTabViewModel);
|
||||
Items.Add(pluginSettingsTabViewModel);
|
||||
Items.Add(deviceSettingsTabViewModel);
|
||||
Items.Add(aboutTabViewModel);
|
||||
|
||||
ActiveItem = generalSettingsTabViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,26 +8,5 @@
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance settings:SettingsViewModel}"
|
||||
d:DesignHeight="600" d:DesignWidth="600">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary
|
||||
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBlock.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<TabControl Style="{StaticResource MaterialDesignTabControl}"
|
||||
ItemsSource="{Binding Items}"
|
||||
SelectedItem="{Binding ActiveItem}"
|
||||
DisplayMemberPath="DisplayName">
|
||||
<TabControl.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding IsAsync=True}"
|
||||
VerticalContentAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
IsTabStop="False"
|
||||
TextElement.Foreground="{DynamicResource MaterialDesignBody}" />
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
</TabControl>
|
||||
<ContentControl s:View.Model="{Binding ActiveItem}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" />
|
||||
</UserControl>
|
||||
@ -1,27 +1,17 @@
|
||||
using Artemis.UI.Screens.Settings.Tabs.About;
|
||||
using Artemis.UI.Screens.Settings.Tabs.Devices;
|
||||
using Artemis.UI.Screens.Settings.Tabs.General;
|
||||
using Artemis.UI.Screens.Settings.Tabs.Plugins;
|
||||
using Stylet;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings
|
||||
{
|
||||
public class SettingsViewModel : Conductor<Screen>.Collection.OneActive, IMainScreenViewModel
|
||||
public class SettingsViewModel : MainScreenViewModel
|
||||
{
|
||||
public SettingsViewModel(
|
||||
GeneralSettingsTabViewModel generalSettingsTabViewModel,
|
||||
PluginSettingsTabViewModel pluginSettingsTabViewModel,
|
||||
DeviceSettingsTabViewModel deviceSettingsTabViewModel,
|
||||
AboutTabViewModel aboutTabViewModel)
|
||||
public SettingsViewModel(SettingsTabsViewModel settingsTabsViewModel)
|
||||
{
|
||||
DisplayName = "Settings";
|
||||
|
||||
Items.Add(generalSettingsTabViewModel);
|
||||
Items.Add(pluginSettingsTabViewModel);
|
||||
Items.Add(deviceSettingsTabViewModel);
|
||||
Items.Add(aboutTabViewModel);
|
||||
|
||||
ActiveItem = generalSettingsTabViewModel;
|
||||
settingsTabsViewModel.ConductWith(this);
|
||||
ActiveItem = settingsTabsViewModel;
|
||||
}
|
||||
|
||||
public SettingsTabsViewModel ActiveItem { get; }
|
||||
}
|
||||
}
|
||||
@ -70,7 +70,7 @@
|
||||
<Separator />
|
||||
<MenuItem Header="Delete" Command="{s:Action Delete}" InputGestureText="Del">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="TrashCan" />
|
||||
<materialDesign:PackIcon Kind="Trash" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Ninject;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Sidebar
|
||||
{
|
||||
public class SidebarScreenViewModel<T> : SidebarScreenViewModel where T : Screen
|
||||
public class SidebarScreenViewModel<T> : SidebarScreenViewModel where T : MainScreenViewModel
|
||||
{
|
||||
public SidebarScreenViewModel(PackIconKind icon, string displayName) : base(icon, displayName)
|
||||
{
|
||||
}
|
||||
|
||||
public override Screen CreateInstance(IKernel kernel)
|
||||
public override MainScreenViewModel CreateInstance(IKernel kernel)
|
||||
{
|
||||
return kernel.Get<T>();
|
||||
}
|
||||
@ -24,8 +23,9 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
DisplayName = displayName;
|
||||
}
|
||||
|
||||
public abstract Screen CreateInstance(IKernel kernel);
|
||||
public PackIconKind Icon { get; }
|
||||
public string DisplayName { get; }
|
||||
|
||||
public abstract MainScreenViewModel CreateInstance(IKernel kernel);
|
||||
}
|
||||
}
|
||||
@ -30,9 +30,9 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly IDialogService _dialogService;
|
||||
private SidebarScreenViewModel _selectedSidebarScreen;
|
||||
private ArtemisDevice _headerDevice;
|
||||
private Screen _selectedScreen;
|
||||
private SidebarScreenViewModel _selectedSidebarScreen;
|
||||
private MainScreenViewModel _selectedScreen;
|
||||
private readonly SidebarScreenViewModel<ProfileEditorViewModel> _profileEditor;
|
||||
private readonly DefaultDropHandler _defaultDropHandler;
|
||||
|
||||
@ -80,7 +80,7 @@ namespace Artemis.UI.Screens.Sidebar
|
||||
|
||||
public BindableCollection<SidebarScreenViewModel> SidebarScreens { get; }
|
||||
|
||||
public Screen SelectedScreen
|
||||
public MainScreenViewModel SelectedScreen
|
||||
{
|
||||
get => _selectedScreen;
|
||||
private set => SetAndNotify(ref _selectedScreen, value);
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid Margin="16">
|
||||
<Grid Margin="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MinWidth="100" />
|
||||
<ColumnDefinition Width="5" />
|
||||
@ -204,12 +204,12 @@
|
||||
<StackPanel ZIndex="1" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="10" Cursor="Arrow">
|
||||
<materialDesign:Card Padding="8">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
||||
IsChecked="{Binding ColorDevices}"
|
||||
ToolTip="If selected, each device is completely lid up with a random color">
|
||||
Show random device colors
|
||||
</CheckBox>
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}"
|
||||
IsChecked="{Binding ColorFirstLedOnly}"
|
||||
IsEnabled="{Binding ColorDevices}"
|
||||
ToolTip="If selected, only the first LED of each device is lid up, aiding with rotation settings"
|
||||
@ -220,7 +220,7 @@
|
||||
</materialDesign:Card>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0, 0, 15, 15">
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0 0 15 15">
|
||||
<Button Command="{s:Action AutoArrange}"
|
||||
Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
|
||||
HorizontalAlignment="Right"
|
||||
@ -228,15 +228,14 @@
|
||||
VerticalAlignment="Bottom">
|
||||
<materialDesign:PackIcon Kind="Wand" Height="24" Width="24" />
|
||||
</Button>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Slider Margin="0,0,14,0"
|
||||
Orientation="Vertical"
|
||||
<StackPanel Orientation="Vertical" Margin="10 0 0 0">
|
||||
<Slider Orientation="Vertical"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0 10"
|
||||
Height="120"
|
||||
Minimum="10"
|
||||
Maximum="400"
|
||||
Height="100"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
Value="{Binding PanZoomViewModel.ZoomPercentage}"
|
||||
Style="{StaticResource MaterialDesignDiscreteSlider}" />
|
||||
Value="{Binding PanZoomViewModel.ZoomPercentage}" />
|
||||
<Button Command="{s:Action ResetZoomAndPan}"
|
||||
Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
|
||||
HorizontalAlignment="Right"
|
||||
@ -317,7 +316,7 @@
|
||||
</materialDesign:DialogHost>
|
||||
</materialDesign:Card>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignCaptionTextBlock}" Margin="0,5,0,0">
|
||||
<TextBlock Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignCaptionTextBlock}" Margin="0 5 0 -5">
|
||||
<InlineUIContainer>
|
||||
<materialDesign:PackIcon Kind="Keyboard" Margin="0 0 0 -3" />
|
||||
</InlineUIContainer>
|
||||
|
||||
@ -22,7 +22,7 @@ using MouseButton = System.Windows.Input.MouseButton;
|
||||
|
||||
namespace Artemis.UI.Screens.SurfaceEditor
|
||||
{
|
||||
public class SurfaceEditorViewModel : Screen, IMainScreenViewModel
|
||||
public class SurfaceEditorViewModel : MainScreenViewModel
|
||||
{
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly IDeviceService _deviceService;
|
||||
|
||||
@ -3,7 +3,7 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Workshop
|
||||
{
|
||||
public class WorkshopViewModel : Screen, IMainScreenViewModel
|
||||
public class WorkshopViewModel : MainScreenViewModel
|
||||
{
|
||||
private Color _testColor;
|
||||
private bool _testPopupOpen;
|
||||
|
||||
@ -53,11 +53,11 @@
|
||||
},
|
||||
"MaterialDesignThemes": {
|
||||
"type": "Direct",
|
||||
"requested": "[4.0.0, )",
|
||||
"resolved": "4.0.0",
|
||||
"contentHash": "+n5oWHuRiYL/gUw2XfQHCRZqHtU8KbrdurgU0IcO98Zsyhw4BvggodfXY8veRtbjjmM9EJ/sG2yKBrgPOGX4JQ==",
|
||||
"requested": "[4.1.0, )",
|
||||
"resolved": "4.1.0",
|
||||
"contentHash": "WqrO9AbtdE4pLPtDk/C5BZRnkgWFwVGyUHWj7tRJrgnKl089DEobVXBCLeqp2mkgBeFHj4Xe3AfWyhmlnO6AZA==",
|
||||
"dependencies": {
|
||||
"MaterialDesignColors": "2.0.0"
|
||||
"MaterialDesignColors": "2.0.1"
|
||||
}
|
||||
},
|
||||
"Microsoft.Toolkit.Uwp.Notifications": {
|
||||
@ -262,8 +262,8 @@
|
||||
},
|
||||
"MaterialDesignColors": {
|
||||
"type": "Transitive",
|
||||
"resolved": "2.0.0",
|
||||
"contentHash": "+JoghC3QRK0u9Wul1To1ORjcfTbFTVzFPjJ02H7VREOdNzIIn427e8G9gP9hXu9pm1r2OneLnoCG/lTma5cG2w=="
|
||||
"resolved": "2.0.1",
|
||||
"contentHash": "Azl8nN23SD6QPE0PdsfpKiIqWTvH7rzXwgXPiFSEt91NFOrwB5cx3iq/sbINWMZunhXJ32+jVUHiV03B8eJbZw=="
|
||||
},
|
||||
"McMaster.NETCore.Plugins": {
|
||||
"type": "Transitive",
|
||||
@ -1489,7 +1489,7 @@
|
||||
"Ben.Demystifier": "0.3.0",
|
||||
"Humanizer.Core": "2.8.26",
|
||||
"MaterialDesignExtensions": "3.3.0",
|
||||
"MaterialDesignThemes": "4.0.0",
|
||||
"MaterialDesignThemes": "4.1.0",
|
||||
"Microsoft.Xaml.Behaviors.Wpf": "1.1.31",
|
||||
"Ninject": "3.3.4",
|
||||
"Ninject.Extensions.Conventions": "3.3.0",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user