mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Added a centralised ProfileEditorSurface for communication between VMs Prefixed Surface, Device and Led with Artemis to differentiate them better
64 lines
1.5 KiB
C#
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
|
|
}
|
|
} |