Files
Artemis/src/Artemis.Core/Plugins/Abstract/ProfileModule.cs
T
Robert 16decaae42 Implemented layer LED assignment
Added a centralised ProfileEditorSurface for communication between VMs
Prefixed Surface, Device and Led with Artemis to differentiate them better
2019-11-29 17:37:22 +01:00

64 lines
1.5 KiB
C#

using System;
using System.Drawing;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Models;
namespace Artemis.Core.Plugins.Abstract
{
public abstract class ProfileModule : Module
{
protected ProfileModule(PluginInfo pluginInfo) : base(pluginInfo)
{
}
public Profile ActiveProfile { get; private set; }
/// <inheritdoc />
public override void Update(double deltaTime)
{
lock (this)
{
// Update the profile
ActiveProfile?.Update(deltaTime);
}
}
/// <inheritdoc />
public override void Render(double deltaTime, ArtemisSurface surface, Graphics graphics)
{
lock (this)
{
// Render the profile
ActiveProfile?.Render(deltaTime, surface, graphics);
}
}
public void ChangeActiveProfile(Profile profile)
{
lock (this)
{
if (profile == ActiveProfile)
return;
ActiveProfile?.Deactivate();
ActiveProfile = profile;
ActiveProfile?.Activate();
}
OnActiveProfileChanged();
}
#region Events
public event EventHandler ActiveProfileChanged;
protected virtual void OnActiveProfileChanged()
{
ActiveProfileChanged?.Invoke(this, EventArgs.Empty);
}
#endregion
}
}