1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Plugins - Moved test data model to a seperate plugin

Core - Moved built-in types to a separate folder and namespace
This commit is contained in:
Robert 2020-09-16 19:22:37 +02:00
parent d788183f25
commit d9017c67b4
59 changed files with 350 additions and 131 deletions

View File

@ -1,4 +1,12 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=defaulttypes_005Cconditions/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=defaulttypes_005Cconditions_005Coperators/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=defaulttypes_005Cdatabindings/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=defaulttypes_005Cdatabindings_005Cconditions/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=defaulttypes_005Cdatabindings_005Cconditions_005Coperators/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=defaulttypes_005Cdatabindings_005Cconverters/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=defaulttypes_005Cdatabindings_005Cmodifiers/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=defaulttypes_005Cproperties/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=events/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=events/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=events_005Cplugins/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=events_005Cplugins/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=events_005Cprofiles/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=events_005Cprofiles/@EntryIndexedValue">True</s:Boolean>

View File

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class EqualsConditionOperator : ConditionOperator internal class EqualsConditionOperator : ConditionOperator
{ {

View File

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class GreaterThanConditionOperator : ConditionOperator internal class GreaterThanConditionOperator : ConditionOperator
{ {

View File

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class GreaterThanOrEqualConditionOperator : ConditionOperator internal class GreaterThanOrEqualConditionOperator : ConditionOperator
{ {

View File

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class LessThanConditionOperator : ConditionOperator internal class LessThanConditionOperator : ConditionOperator
{ {

View File

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class LessThanOrEqualConditionOperator : ConditionOperator internal class LessThanOrEqualConditionOperator : ConditionOperator
{ {

View File

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class NotEqualConditionOperator : ConditionOperator internal class NotEqualConditionOperator : ConditionOperator
{ {

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class StringContainsConditionOperator : ConditionOperator internal class StringContainsConditionOperator : ConditionOperator
{ {

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class StringEndsWithConditionOperator : ConditionOperator internal class StringEndsWithConditionOperator : ConditionOperator
{ {

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class StringEqualsConditionOperator : ConditionOperator internal class StringEqualsConditionOperator : ConditionOperator
{ {

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class StringNotContainsConditionOperator : ConditionOperator internal class StringNotContainsConditionOperator : ConditionOperator
{ {

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class StringNotEqualConditionOperator : ConditionOperator internal class StringNotEqualConditionOperator : ConditionOperator
{ {

View File

@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class StringNullConditionOperator : ConditionOperator internal class StringNullConditionOperator : ConditionOperator
{ {

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class StringStartsWithConditionOperator : ConditionOperator internal class StringStartsWithConditionOperator : ConditionOperator
{ {

View File

@ -1,7 +1,6 @@
using System; using System;
using SkiaSharp;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
/// <inheritdoc /> /// <inheritdoc />
public class FloatDataBindingConverter : FloatDataBindingConverter<float> public class FloatDataBindingConverter : FloatDataBindingConverter<float>

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
/// <inheritdoc /> /// <inheritdoc />
public class GeneralDataBindingConverter<T> : DataBindingConverter<T, object> where T : ILayerProperty public class GeneralDataBindingConverter<T> : DataBindingConverter<T, object> where T : ILayerProperty

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
/// <inheritdoc /> /// <inheritdoc />
public class IntDataBindingConverter : IntDataBindingConverter<int> public class IntDataBindingConverter : IntDataBindingConverter<int>

View File

@ -1,10 +1,16 @@
using SkiaSharp; using SkiaSharp;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
/// <inheritdoc /> /// <inheritdoc />
public class SKColorDataBindingConverter : DataBindingConverter<SKColor, SKColor> public class SKColorDataBindingConverter : DataBindingConverter<SKColor, SKColor>
{ {
public SKColorDataBindingConverter()
{
SupportsInterpolate = true;
SupportsSum = true;
}
/// <inheritdoc /> /// <inheritdoc />
public override SKColor Sum(SKColor a, SKColor b) public override SKColor Sum(SKColor a, SKColor b)
{ {
@ -14,7 +20,7 @@ namespace Artemis.Core
/// <inheritdoc /> /// <inheritdoc />
public override SKColor Interpolate(SKColor a, SKColor b, double progress) public override SKColor Interpolate(SKColor a, SKColor b, double progress)
{ {
return a.Interpolate(b, (float)progress); return a.Interpolate(b, (float) progress);
} }
} }
} }

View File

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class DivideModifierType : DataBindingModifierType internal class DivideModifierType : DataBindingModifierType
{ {

View File

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class FloorModifierType : DataBindingModifierType internal class FloorModifierType : DataBindingModifierType
{ {

View File

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class MultiplicationModifierType : DataBindingModifierType internal class MultiplicationModifierType : DataBindingModifierType
{ {

View File

@ -1,7 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
internal class PercentageOfModifierType : DataBindingModifierType internal class PercentageOfModifierType : DataBindingModifierType
{ {

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using SkiaSharp;
namespace Artemis.Core.DefaultTypes
{
internal class SKColorSumModifierType : DataBindingModifierType
{
public override IReadOnlyCollection<Type> CompatibleTypes => new List<Type> {typeof(SKColor)};
public override string Description => "Combine with";
public override string Icon => "FormatColorFill";
public override object Apply(object currentValue, object parameterValue)
{
return ((SKColor) currentValue).Sum((SKColor) parameterValue);
}
}
}

View File

@ -1,4 +1,4 @@
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
/// <inheritdoc /> /// <inheritdoc />
public class ColorGradientLayerProperty : LayerProperty<ColorGradient> public class ColorGradientLayerProperty : LayerProperty<ColorGradient>

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
/// <inheritdoc /> /// <inheritdoc />
public class EnumLayerProperty<T> : LayerProperty<T> where T : Enum public class EnumLayerProperty<T> : LayerProperty<T> where T : Enum

View File

@ -1,4 +1,4 @@
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
/// <inheritdoc /> /// <inheritdoc />
public class FloatLayerProperty : LayerProperty<float> public class FloatLayerProperty : LayerProperty<float>

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
/// <inheritdoc /> /// <inheritdoc />
public class IntLayerProperty : LayerProperty<int> public class IntLayerProperty : LayerProperty<int>

View File

@ -1,4 +1,4 @@
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
/// <summary> /// <summary>
/// A special layer property used to configure the selected layer brush /// A special layer property used to configure the selected layer brush

View File

@ -1,6 +1,6 @@
using SkiaSharp; using SkiaSharp;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
/// <inheritdoc /> /// <inheritdoc />
public class SKColorLayerProperty : LayerProperty<SKColor> public class SKColorLayerProperty : LayerProperty<SKColor>

View File

@ -1,6 +1,6 @@
using SkiaSharp; using SkiaSharp;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
/// <inheritdoc /> /// <inheritdoc />
public class SKPointLayerProperty : LayerProperty<SKPoint> public class SKPointLayerProperty : LayerProperty<SKPoint>

View File

@ -1,6 +1,6 @@
using SkiaSharp; using SkiaSharp;
namespace Artemis.Core namespace Artemis.Core.DefaultTypes
{ {
/// <inheritdoc /> /// <inheritdoc />
public class SKSizeLayerProperty : LayerProperty<SKSize> public class SKSizeLayerProperty : LayerProperty<SKSize>

View File

@ -1,70 +0,0 @@
using System;
using SkiaSharp;
namespace Artemis.Core
{
// This is internal because it's mainly a proof-of-concept
internal class SKColorArgbDataBindingConverter : DataBindingConverter<SKColor, byte>
{
private readonly Channel _channel;
public SKColorArgbDataBindingConverter(Channel channel)
{
_channel = channel;
SupportsSum = true;
SupportsInterpolate = true;
}
public override byte Sum(byte a, byte b)
{
return ClampToByte(a + b);
}
public override byte Interpolate(byte a, byte b, double progress)
{
var diff = b - a;
return ClampToByte(a + diff * progress);
}
public override void ApplyValue(byte value)
{
switch (_channel)
{
case Channel.Alpha:
DataBinding.LayerProperty.CurrentValue = DataBinding.LayerProperty.CurrentValue.WithAlpha(value);
break;
case Channel.Red:
DataBinding.LayerProperty.CurrentValue = DataBinding.LayerProperty.CurrentValue.WithRed(value);
break;
case Channel.Green:
DataBinding.LayerProperty.CurrentValue = DataBinding.LayerProperty.CurrentValue.WithGreen(value);
break;
case Channel.Blue:
DataBinding.LayerProperty.CurrentValue = DataBinding.LayerProperty.CurrentValue.WithBlue(value);
break;
default:
throw new ArgumentOutOfRangeException();
}
}
public override byte ConvertFromObject(object source)
{
var saveValue = Convert.ToDouble(source);
return ClampToByte(saveValue);
}
private static byte ClampToByte(double value)
{
return (byte) Math.Clamp(value, 0, 255);
}
public enum Channel
{
Alpha,
Red,
Green,
Blue
}
}
}

View File

@ -1,4 +1,5 @@
using SkiaSharp; using Artemis.Core.DefaultTypes;
using SkiaSharp;
namespace Artemis.Core namespace Artemis.Core
{ {

View File

@ -1,4 +1,5 @@
using SkiaSharp; using Artemis.Core.DefaultTypes;
using SkiaSharp;
namespace Artemis.Core namespace Artemis.Core
{ {

View File

@ -165,16 +165,6 @@ namespace Artemis.Core.Modules
/// </param> /// </param>
public abstract void ModuleDeactivated(bool isOverride); public abstract void ModuleDeactivated(bool isOverride);
internal virtual void InternalUpdate(double deltaTime)
{
Update(deltaTime);
}
internal virtual void InternalRender(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo)
{
Render(deltaTime, surface, canvas, canvasInfo);
}
/// <summary> /// <summary>
/// Evaluates the activation requirements following the <see cref="ActivationRequirementMode" /> and returns the result /// Evaluates the activation requirements following the <see cref="ActivationRequirementMode" /> and returns the result
/// </summary> /// </summary>
@ -191,6 +181,16 @@ namespace Artemis.Core.Modules
return false; return false;
} }
internal virtual void InternalUpdate(double deltaTime)
{
Update(deltaTime);
}
internal virtual void InternalRender(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo)
{
Render(deltaTime, surface, canvas, canvasInfo);
}
internal virtual void Activate(bool isOverride) internal virtual void Activate(bool isOverride)
{ {
if (IsActivated) if (IsActivated)

View File

@ -39,6 +39,20 @@ namespace Artemis.Core
/// </summary> /// </summary>
public abstract void DisablePlugin(); public abstract void DisablePlugin();
/// <summary>
/// Registers a timed update that whenever the plugin is enabled calls the provided <paramref name="action" /> at the provided
/// <paramref name="interval" />
/// </summary>
/// <param name="interval">The interval at which the update should occur</param>
/// <param name="action">The action to call every time the interval has passed. The delta time parameter represents the time passed since the last update in seconds</param>
/// <returns>The resulting plugin update registration</returns>
public PluginUpdateRegistration AddTimedUpdate(TimeSpan interval, Action<double> action)
{
if (action == null)
throw new ArgumentNullException(nameof(action));
return new PluginUpdateRegistration(PluginInfo, interval, action);
}
internal void SetEnabled(bool enable, bool isAutoEnable = false) internal void SetEnabled(bool enable, bool isAutoEnable = false)
{ {
if (enable && !Enabled) if (enable && !Enabled)

View File

@ -0,0 +1,102 @@
using System;
using System.Timers;
namespace Artemis.Core
{
/// <summary>
/// Represents a registration for a timed plugin update
/// </summary>
public class PluginUpdateRegistration
{
private DateTime _lastEvent;
private Timer _timer;
internal PluginUpdateRegistration(PluginInfo pluginInfo, TimeSpan interval, Action<double> action)
{
PluginInfo = pluginInfo;
Interval = interval;
Action = action;
PluginInfo.Instance.PluginEnabled += InstanceOnPluginEnabled;
PluginInfo.Instance.PluginDisabled += InstanceOnPluginDisabled;
if (PluginInfo.Instance.Enabled)
Start();
}
/// <summary>
/// Gets the plugin info of the plugin this registration is associated with
/// </summary>
public PluginInfo PluginInfo { get; }
/// <summary>
/// Gets the interval at which the update should occur
/// </summary>
public TimeSpan Interval { get; }
/// <summary>
/// Gets the action that gets called each time the update event fires
/// </summary>
public Action<double> Action { get; }
/// <summary>
/// Starts calling the <see cref="Action" /> at the configured <see cref="Interval" />
/// <para>Note: Called automatically when the plugin enables</para>
/// </summary>
public void Start()
{
lock (this)
{
if (!PluginInfo.Instance.Enabled)
throw new ArtemisPluginException("Cannot start a timed update for a disabled plugin");
if (_timer != null)
return;
_lastEvent = DateTime.Now;
_timer = new Timer(Interval.TotalMilliseconds);
_timer.Elapsed += TimerOnElapsed;
_timer.Start();
}
}
/// <summary>
/// Stops calling the <see cref="Action" /> at the configured <see cref="Interval" />
/// <para>Note: Called automatically when the plugin disables</para>
/// </summary>
public void Stop()
{
lock (this)
{
if (_timer == null)
return;
_timer.Elapsed -= TimerOnElapsed;
_timer.Stop();
_timer.Dispose();
_timer = null;
}
}
private void TimerOnElapsed(object sender, ElapsedEventArgs e)
{
if (!PluginInfo.Instance.Enabled)
return;
var interval = DateTime.Now - _lastEvent;
_lastEvent = DateTime.Now;
Action(interval.TotalSeconds);
}
private void InstanceOnPluginEnabled(object? sender, EventArgs e)
{
Start();
}
private void InstanceOnPluginDisabled(object? sender, EventArgs e)
{
Stop();
}
}
}

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Artemis.Core.DefaultTypes;
namespace Artemis.Core.Services namespace Artemis.Core.Services
{ {

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Artemis.Core.DefaultTypes;
namespace Artemis.Core.Services namespace Artemis.Core.Services
{ {
@ -45,6 +46,7 @@ namespace Artemis.Core.Services
RegisterModifierType(Constants.CorePluginInfo, new PercentageOfModifierType()); RegisterModifierType(Constants.CorePluginInfo, new PercentageOfModifierType());
RegisterModifierType(Constants.CorePluginInfo, new DivideModifierType()); RegisterModifierType(Constants.CorePluginInfo, new DivideModifierType());
RegisterModifierType(Constants.CorePluginInfo, new FloorModifierType()); RegisterModifierType(Constants.CorePluginInfo, new FloorModifierType());
RegisterModifierType(Constants.CorePluginInfo, new SKColorSumModifierType());
} }
} }
} }

View File

@ -53,7 +53,7 @@ namespace Artemis.Core
if (type == null) if (type == null)
return new List<DataBindingModifierTypeRegistration>(Registrations); return new List<DataBindingModifierTypeRegistration>(Registrations);
var candidates = Registrations.Where(r => r.DataBindingModifierType.CompatibleTypes.Any(t => t.IsCastableFrom(type))).ToList(); var candidates = Registrations.Where(r => r.DataBindingModifierType.CompatibleTypes.Any(t => t == type)).ToList();
// If there are multiple operators with the same description, use the closest match // If there are multiple operators with the same description, use the closest match
foreach (var displayDataBindingModifiers in candidates.GroupBy(r => r.DataBindingModifierType.Description).Where(g => g.Count() > 1).ToList()) foreach (var displayDataBindingModifiers in candidates.GroupBy(r => r.DataBindingModifierType.Description).Where(g => g.Count() > 1).ToList())

View File

@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ShouldIncludeNativeSkiaSharp>false</ShouldIncludeNativeSkiaSharp>
<AssemblyName>Artemis.Plugins.DataModelExpansions.TestData</AssemblyName>
<RootNamespace>Artemis.Plugins.DataModelExpansions.TestData</RootNamespace>
<Platforms>x64</Platforms>
<GenerateDependencyFile>False</GenerateDependencyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SkiaSharp" Version="1.68.3">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Stylet" Version="1.3.4">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Artemis.Core\Artemis.Core.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(BuildingInsideVisualStudio)' == 'true'">
<Exec Command="echo Copying plugin to Artemis.UI output directory&#xD;&#xA;XCOPY &quot;$(TargetDir.TrimEnd('\'))&quot; &quot;$(SolutionDir)\Artemis.UI\$(OutDir)Plugins\$(ProjectName)&quot; /s /q /i /y" />
</Target>
</Project>

View File

@ -0,0 +1,43 @@
using System.Collections.Generic;
using Artemis.Core.DataModelExpansions;
using SkiaSharp;
namespace Artemis.Plugins.DataModelExpansions.TestData.DataModels
{
public class PluginDataModel : DataModel
{
public PluginDataModel()
{
PluginSubDataModel = new PluginSubDataModel();
}
// Your datamodel can have regular properties and you can annotate them if you'd like
[DataModelProperty(Name = "A test string", Description = "It doesn't do much, but it's there.")]
public string TemplateDataModelString { get; set; }
public SKColor TestColorA { get; set; }
public SKColor TestColorB { get; set; }
// You can even have classes in your datamodel, just don't forget to instantiate them ;)
[DataModelProperty(Name = "A class within the datamodel")]
public PluginSubDataModel PluginSubDataModel { get; set; }
}
public class PluginSubDataModel
{
public PluginSubDataModel()
{
ListOfInts = new List<int> { 1, 2, 3, 4, 5 };
}
// You don't need to annotate properties, they will still show up
public float FloatyFloat { get; set; }
// You can even have a list!
public List<int> ListOfInts { get; set; }
// If you don't want a property to show up in the datamodel, annotate it with DataModelIgnore
[DataModelIgnore]
public string MyDarkestSecret { get; set; }
}
}

View File

@ -0,0 +1,34 @@
using System;
using Artemis.Core.DataModelExpansions;
using Artemis.Plugins.DataModelExpansions.TestData.DataModels;
using SkiaSharp;
namespace Artemis.Plugins.DataModelExpansions.TestData
{
public class PluginDataModelExpansion : DataModelExpansion<PluginDataModel>
{
private Random _rand;
public override void EnablePlugin()
{
_rand = new Random();
AddTimedUpdate(TimeSpan.FromSeconds(1), TimedUpdate);
}
private void TimedUpdate(double deltaTime)
{
DataModel.TestColorA = SKColor.FromHsv(_rand.Next(0, 360), 100, 100);
DataModel.TestColorB = SKColor.FromHsv(_rand.Next(0, 360), 100, 100);
}
public override void DisablePlugin()
{
}
public override void Update(double deltaTime)
{
// You can access your data model here and update it however you like
DataModel.TemplateDataModelString = $"The last delta time was {deltaTime} seconds";
}
}
}

View File

@ -0,0 +1,9 @@
{
"profiles": {
"ModuleProject": {
"commandName": "Executable",
"executablePath": "C:\\Repos\\Artemis\\src\\Artemis.UI\\bin\\x64\\Debug\\netcoreapp3.1\\Artemis.UI.exe",
"workingDirectory": "C:\\Repos\\Artemis\\src\\Artemis.UI\\bin\\x64\\Debug\\netcoreapp3.1"
}
}
}

View File

@ -0,0 +1,7 @@
{
"Guid": "ab41d601-35e0-4a73-bf0b-94509b006ab0",
"Name": "Test data model expansion",
"Description": "A data model expansion providing test data",
"Version": "1.0.0.0",
"Main": "Artemis.Plugins.DataModelExpansions.TestData.dll"
}

View File

@ -17,6 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Artemis.UI", "Artemis.UI\Ar
{0F288A66-6EB0-4589-8595-E33A3A3EAEA2} = {0F288A66-6EB0-4589-8595-E33A3A3EAEA2} {0F288A66-6EB0-4589-8595-E33A3A3EAEA2} = {0F288A66-6EB0-4589-8595-E33A3A3EAEA2}
{A46F278A-FC2C-4342-8455-994D957DDA03} = {A46F278A-FC2C-4342-8455-994D957DDA03} {A46F278A-FC2C-4342-8455-994D957DDA03} = {A46F278A-FC2C-4342-8455-994D957DDA03}
{26902C94-3EBC-4132-B7F0-FFCAB8E150DA} = {26902C94-3EBC-4132-B7F0-FFCAB8E150DA} {26902C94-3EBC-4132-B7F0-FFCAB8E150DA} = {26902C94-3EBC-4132-B7F0-FFCAB8E150DA}
{5353C9A2-2D9A-4051-8599-AFE56D54B882} = {5353C9A2-2D9A-4051-8599-AFE56D54B882}
{7F4C7AB0-4C9B-452D-AFED-34544C903DEF} = {7F4C7AB0-4C9B-452D-AFED-34544C903DEF} {7F4C7AB0-4C9B-452D-AFED-34544C903DEF} = {7F4C7AB0-4C9B-452D-AFED-34544C903DEF}
{235A45C7-24AD-4F47-B9D4-CD67E610A04D} = {235A45C7-24AD-4F47-B9D4-CD67E610A04D} {235A45C7-24AD-4F47-B9D4-CD67E610A04D} = {235A45C7-24AD-4F47-B9D4-CD67E610A04D}
{D004FEC9-0CF8-4828-B620-95DBA73201A3} = {D004FEC9-0CF8-4828-B620-95DBA73201A3} {D004FEC9-0CF8-4828-B620-95DBA73201A3} = {D004FEC9-0CF8-4828-B620-95DBA73201A3}
@ -79,6 +80,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Artemis.Plugins.Devices.Deb
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Artemis.Plugins.Modules.Overlay", "Plugins\Artemis.Plugins.Modules.Overlay\Artemis.Plugins.Modules.Overlay.csproj", "{00318027-7FDB-4C86-AB86-9005A481E330}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Artemis.Plugins.Modules.Overlay", "Plugins\Artemis.Plugins.Modules.Overlay\Artemis.Plugins.Modules.Overlay.csproj", "{00318027-7FDB-4C86-AB86-9005A481E330}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DataModelExpansions", "DataModelExpansions", "{5A5B55D7-F631-467A-A16F-B880DE4E8909}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis.Plugins.DataModelExpansions.TestData", "Artemis.Plugins.DataModelExpansions.TestData\Artemis.Plugins.DataModelExpansions.TestData.csproj", "{5353C9A2-2D9A-4051-8599-AFE56D54B882}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
@ -177,6 +182,10 @@ Global
{00318027-7FDB-4C86-AB86-9005A481E330}.Debug|x64.Build.0 = Debug|x64 {00318027-7FDB-4C86-AB86-9005A481E330}.Debug|x64.Build.0 = Debug|x64
{00318027-7FDB-4C86-AB86-9005A481E330}.Release|x64.ActiveCfg = Release|x64 {00318027-7FDB-4C86-AB86-9005A481E330}.Release|x64.ActiveCfg = Release|x64
{00318027-7FDB-4C86-AB86-9005A481E330}.Release|x64.Build.0 = Release|x64 {00318027-7FDB-4C86-AB86-9005A481E330}.Release|x64.Build.0 = Release|x64
{5353C9A2-2D9A-4051-8599-AFE56D54B882}.Debug|x64.ActiveCfg = Debug|x64
{5353C9A2-2D9A-4051-8599-AFE56D54B882}.Debug|x64.Build.0 = Debug|x64
{5353C9A2-2D9A-4051-8599-AFE56D54B882}.Release|x64.ActiveCfg = Release|x64
{5353C9A2-2D9A-4051-8599-AFE56D54B882}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -205,6 +214,8 @@ Global
{62214042-667E-4B29-B64E-1A68CE6FE209} = {2C1477DC-7A5C-4B65-85DB-1F16A18FB2EC} {62214042-667E-4B29-B64E-1A68CE6FE209} = {2C1477DC-7A5C-4B65-85DB-1F16A18FB2EC}
{3D83760B-0A36-4C8F-978D-7949C3FC862B} = {88792A7E-F037-4280-81D3-B131508EF1D8} {3D83760B-0A36-4C8F-978D-7949C3FC862B} = {88792A7E-F037-4280-81D3-B131508EF1D8}
{00318027-7FDB-4C86-AB86-9005A481E330} = {B258A061-FA19-4835-8DC4-E9C3AE3664A0} {00318027-7FDB-4C86-AB86-9005A481E330} = {B258A061-FA19-4835-8DC4-E9C3AE3664A0}
{5A5B55D7-F631-467A-A16F-B880DE4E8909} = {E830A02B-A7E5-4A6B-943F-76B0A542630C}
{5353C9A2-2D9A-4051-8599-AFE56D54B882} = {5A5B55D7-F631-467A-A16F-B880DE4E8909}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C203080A-4473-4CC2-844B-F552EA43D66A} SolutionGuid = {C203080A-4473-4CC2-844B-F552EA43D66A}

View File

@ -1,5 +1,6 @@
using System.ComponentModel; using System.ComponentModel;
using Artemis.Core; using Artemis.Core;
using Artemis.Core.DefaultTypes;
using SkiaSharp; using SkiaSharp;
namespace Artemis.Plugins.LayerBrushes.Color.PropertyGroups namespace Artemis.Plugins.LayerBrushes.Color.PropertyGroups

View File

@ -1,5 +1,6 @@
using System.ComponentModel; using System.ComponentModel;
using Artemis.Core; using Artemis.Core;
using Artemis.Core.DefaultTypes;
namespace Artemis.Plugins.LayerBrushes.Color.PropertyGroups namespace Artemis.Plugins.LayerBrushes.Color.PropertyGroups
{ {

View File

@ -1,4 +1,5 @@
using Artemis.Core; using Artemis.Core;
using Artemis.Core.DefaultTypes;
using SkiaSharp; using SkiaSharp;
namespace Artemis.Plugins.LayerBrushes.ColorRgbNet namespace Artemis.Plugins.LayerBrushes.ColorRgbNet

View File

@ -1,4 +1,5 @@
using Artemis.Core; using Artemis.Core;
using Artemis.Core.DefaultTypes;
using SkiaSharp; using SkiaSharp;
namespace Artemis.Plugins.LayerBrushes.Noise namespace Artemis.Plugins.LayerBrushes.Noise

View File

@ -1,4 +1,5 @@
using Artemis.Core; using Artemis.Core;
using Artemis.Core.DefaultTypes;
namespace Artemis.Plugins.LayerEffects.Filter namespace Artemis.Plugins.LayerEffects.Filter
{ {

View File

@ -1,4 +1,5 @@
using Artemis.Core; using Artemis.Core;
using Artemis.Core.DefaultTypes;
namespace Artemis.Plugins.LayerEffects.Filter namespace Artemis.Plugins.LayerEffects.Filter
{ {

View File

@ -1,4 +1,5 @@
using Artemis.Core; using Artemis.Core;
using Artemis.Core.DefaultTypes;
namespace Artemis.Plugins.LayerEffects.Filter namespace Artemis.Plugins.LayerEffects.Filter
{ {

View File

@ -1,4 +1,5 @@
using Artemis.Core; using Artemis.Core;
using Artemis.Core.DefaultTypes;
using SkiaSharp; using SkiaSharp;
namespace Artemis.Plugins.LayerEffects.Filter namespace Artemis.Plugins.LayerEffects.Filter

View File

@ -1,4 +1,5 @@
using Artemis.Core; using Artemis.Core;
using Artemis.Core.DefaultTypes;
namespace Artemis.Plugins.LayerEffects.Filter namespace Artemis.Plugins.LayerEffects.Filter
{ {

View File

@ -1,4 +1,5 @@
using Artemis.Core; using Artemis.Core;
using Artemis.Core.DefaultTypes;
using Artemis.Core.LayerEffects; using Artemis.Core.LayerEffects;
using SkiaSharp; using SkiaSharp;

View File

@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.DataModelExpansions; using Artemis.Core.DataModelExpansions;
using Artemis.Plugins.Modules.General.DataModels.Windows; using Artemis.Plugins.Modules.General.DataModels.Windows;
@ -11,19 +9,10 @@ namespace Artemis.Plugins.Modules.General.DataModels
public GeneralDataModel() public GeneralDataModel()
{ {
TimeDataModel = new TimeDataModel(); TimeDataModel = new TimeDataModel();
TestTimeList = new List<TimeDataModel>();
var testExpression = new Func<object, object, bool>((leftItem, rightDataModel) =>
((TimeDataModel) leftItem).CurrentTime.Month == ((GeneralDataModel) rightDataModel).TimeDataModel.CurrentTime.Day);
var test = TestTimeList.Any(model => testExpression(model, this));
} }
public WindowDataModel ActiveWindow { get; set; } public WindowDataModel ActiveWindow { get; set; }
public TimeDataModel TimeDataModel { get; set; } public TimeDataModel TimeDataModel { get; set; }
public List<TimeDataModel> TestTimeList { get; set; }
} }
public class TimeDataModel : DataModel public class TimeDataModel : DataModel

View File

@ -19,11 +19,6 @@ namespace Artemis.Plugins.Modules.General
DisplayIcon = "AllInclusive"; DisplayIcon = "AllInclusive";
ExpandsDataModel = true; ExpandsDataModel = true;
ModuleTabs = new List<ModuleTab> {new ModuleTab<GeneralViewModel>("General")}; ModuleTabs = new List<ModuleTab> {new ModuleTab<GeneralViewModel>("General")};
DataModel.TestTimeList.Add(new TimeDataModel {CurrentTime = DateTimeOffset.Now.AddDays(1)});
DataModel.TestTimeList.Add(new TimeDataModel {CurrentTime = DateTimeOffset.Now.AddDays(2)});
DataModel.TestTimeList.Add(new TimeDataModel {CurrentTime = DateTimeOffset.Now.AddDays(3)});
DataModel.TestTimeList.Add(new TimeDataModel {CurrentTime = DateTimeOffset.Now.AddDays(4)});
} }
public override void DisablePlugin() public override void DisablePlugin()