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

Implemented layer elements

Added a brush layer element
Corsair - Added ST100 RGB layout
This commit is contained in:
SpoinkyNL 2019-12-01 18:55:49 +01:00
parent 482cbe79ed
commit 9148323ad5
81 changed files with 1610 additions and 365 deletions

View File

@ -172,11 +172,14 @@
<Compile Include="Plugins\Abstract\ProfileModule.cs" /> <Compile Include="Plugins\Abstract\ProfileModule.cs" />
<Compile Include="Plugins\Exceptions\ArtemisPluginException.cs" /> <Compile Include="Plugins\Exceptions\ArtemisPluginException.cs" />
<Compile Include="Plugins\Abstract\DataModelExpansion.cs" /> <Compile Include="Plugins\Abstract\DataModelExpansion.cs" />
<Compile Include="Plugins\Abstract\Device.cs" /> <Compile Include="Plugins\Abstract\DeviceProvider.cs" />
<Compile Include="Plugins\Abstract\LayerType.cs" />
<Compile Include="Plugins\Interfaces\ILayerTypeConfiguration.cs" />
<Compile Include="Plugins\Abstract\Module.cs" /> <Compile Include="Plugins\Abstract\Module.cs" />
<Compile Include="Plugins\Abstract\Plugin.cs" /> <Compile Include="Plugins\Abstract\Plugin.cs" />
<Compile Include="Plugins\LayerElement\LayerElement.cs" />
<Compile Include="Plugins\LayerElement\LayerElementDescriptor.cs" />
<Compile Include="Plugins\LayerElement\LayerElementProvider.cs" />
<Compile Include="Plugins\LayerElement\LayerElementSettings.cs" />
<Compile Include="Plugins\LayerElement\LayerElementViewModel.cs" />
<Compile Include="Plugins\Models\PluginInfo.cs" /> <Compile Include="Plugins\Models\PluginInfo.cs" />
<Compile Include="Plugins\Models\PluginSetting.cs" /> <Compile Include="Plugins\Models\PluginSetting.cs" />
<Compile Include="Plugins\Models\PluginSettings.cs" /> <Compile Include="Plugins\Models\PluginSettings.cs" />
@ -189,9 +192,11 @@
<Compile Include="RGB.NET\DirectBitmap.cs" /> <Compile Include="RGB.NET\DirectBitmap.cs" />
<Compile Include="RGB.NET\GraphicsDecorator.cs" /> <Compile Include="RGB.NET\GraphicsDecorator.cs" />
<Compile Include="Services\DeviceService.cs" /> <Compile Include="Services\DeviceService.cs" />
<Compile Include="Services\Interfaces\ILayerService.cs" />
<Compile Include="Services\Interfaces\IProtectedArtemisService.cs" /> <Compile Include="Services\Interfaces\IProtectedArtemisService.cs" />
<Compile Include="Services\Interfaces\IMainDataModelService.cs" /> <Compile Include="Services\Interfaces\IMainDataModelService.cs" />
<Compile Include="Services\CoreService.cs" /> <Compile Include="Services\CoreService.cs" />
<Compile Include="Services\LayerService.cs" />
<Compile Include="Services\MainDataModelService.cs" /> <Compile Include="Services\MainDataModelService.cs" />
<Compile Include="Services\RgbService.cs" /> <Compile Include="Services\RgbService.cs" />
<Compile Include="Services\Interfaces\IRgbService.cs" /> <Compile Include="Services\Interfaces\IRgbService.cs" />

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using Artemis.Core.Models.Surface;
using Stylet; using Stylet;
namespace Artemis.Core.Models.Profile.Abstract namespace Artemis.Core.Models.Profile.Abstract
@ -44,7 +45,7 @@ namespace Artemis.Core.Models.Profile.Abstract
/// <summary> /// <summary>
/// Renders the element /// Renders the element
/// </summary> /// </summary>
public abstract void Render(double deltaTime, Surface.ArtemisSurface surface, Graphics graphics); public abstract void Render(double deltaTime, ArtemisSurface surface, Graphics graphics);
/// <summary> /// <summary>
/// Applies the profile element's properties to the underlying storage entity /// Applies the profile element's properties to the underlying storage entity

View File

@ -2,7 +2,7 @@ using System;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using Artemis.Core.Models.Profile.Abstract; using Artemis.Core.Models.Profile.Abstract;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Models.Surface;
using Artemis.Storage.Entities.Profile; using Artemis.Storage.Entities.Profile;
namespace Artemis.Core.Models.Profile namespace Artemis.Core.Models.Profile
@ -19,7 +19,7 @@ namespace Artemis.Core.Models.Profile
Name = name; Name = name;
} }
public Folder(Profile profile, ProfileElement parent, FolderEntity folderEntity, IPluginService pluginService) internal Folder(Profile profile, ProfileElement parent, FolderEntity folderEntity)
{ {
FolderEntity = folderEntity; FolderEntity = folderEntity;
EntityId = folderEntity.Id; EntityId = folderEntity.Id;
@ -33,10 +33,10 @@ namespace Artemis.Core.Models.Profile
// Load child folders // Load child folders
foreach (var childFolder in Profile.ProfileEntity.Folders.Where(f => f.ParentId == EntityId)) foreach (var childFolder in Profile.ProfileEntity.Folders.Where(f => f.ParentId == EntityId))
_children.Add(new Folder(profile, this, childFolder, pluginService)); _children.Add(new Folder(profile, this, childFolder));
// Load child layers // Load child layers
foreach (var childLayer in Profile.ProfileEntity.Layers.Where(f => f.ParentId == EntityId)) foreach (var childLayer in Profile.ProfileEntity.Layers.Where(f => f.ParentId == EntityId))
_children.Add(new Layer(profile, this, childLayer, pluginService)); _children.Add(new Layer(profile, this, childLayer));
// Ensure order integrity, should be unnecessary but no one is perfect specially me // Ensure order integrity, should be unnecessary but no one is perfect specially me
_children = _children.OrderBy(c => c.Order).ToList(); _children = _children.OrderBy(c => c.Order).ToList();
@ -56,7 +56,7 @@ namespace Artemis.Core.Models.Profile
profileElement.Update(deltaTime); profileElement.Update(deltaTime);
} }
public override void Render(double deltaTime, Surface.ArtemisSurface surface, Graphics graphics) public override void Render(double deltaTime, ArtemisSurface surface, Graphics graphics)
{ {
// Folders don't render but their children do // Folders don't render but their children do
foreach (var profileElement in Children) foreach (var profileElement in Children)

View File

@ -7,15 +7,15 @@ using System.Linq;
using Artemis.Core.Extensions; using Artemis.Core.Extensions;
using Artemis.Core.Models.Profile.Abstract; using Artemis.Core.Models.Profile.Abstract;
using Artemis.Core.Models.Surface; using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.LayerElement;
using Artemis.Core.Plugins.Interfaces;
using Artemis.Core.Services.Interfaces;
using Artemis.Storage.Entities.Profile; using Artemis.Storage.Entities.Profile;
using Newtonsoft.Json;
namespace Artemis.Core.Models.Profile namespace Artemis.Core.Models.Profile
{ {
public sealed class Layer : ProfileElement public sealed class Layer : ProfileElement
{ {
private readonly List<LayerElement> _layerElements;
private List<ArtemisLed> _leds; private List<ArtemisLed> _leds;
public Layer(Profile profile, ProfileElement parent, string name) public Layer(Profile profile, ProfileElement parent, string name)
@ -26,10 +26,12 @@ namespace Artemis.Core.Models.Profile
Profile = profile; Profile = profile;
Parent = parent; Parent = parent;
Name = name; Name = name;
_leds = new List<ArtemisLed>(); _leds = new List<ArtemisLed>();
_layerElements = new List<LayerElement>();
} }
internal Layer(Profile profile, ProfileElement parent, LayerEntity layerEntity, IPluginService pluginService) internal Layer(Profile profile, ProfileElement parent, LayerEntity layerEntity)
{ {
LayerEntity = layerEntity; LayerEntity = layerEntity;
EntityId = layerEntity.Id; EntityId = layerEntity.Id;
@ -39,46 +41,44 @@ namespace Artemis.Core.Models.Profile
Name = layerEntity.Name; Name = layerEntity.Name;
Order = layerEntity.Order; Order = layerEntity.Order;
LayerType = pluginService.GetLayerTypeByGuid(layerEntity.LayerTypeGuid);
_leds = new List<ArtemisLed>(); _leds = new List<ArtemisLed>();
_layerElements = new List<LayerElement>();
} }
internal LayerEntity LayerEntity { get; set; } internal LayerEntity LayerEntity { get; set; }
public ReadOnlyCollection<ArtemisLed> Leds => _leds.AsReadOnly(); public ReadOnlyCollection<ArtemisLed> Leds => _leds.AsReadOnly();
public LayerType LayerType { get; private set; } public ReadOnlyCollection<LayerElement> LayerElements => _layerElements.AsReadOnly();
public ILayerTypeConfiguration LayerTypeConfiguration { get; set; }
public Rectangle RenderRectangle { get; set; } public Rectangle RenderRectangle { get; set; }
public GraphicsPath RenderPath { get; set; } public GraphicsPath RenderPath { get; set; }
public override void Update(double deltaTime) public override void Update(double deltaTime)
{ {
if (LayerType == null) foreach (var layerElement in LayerElements)
return; layerElement.Update(deltaTime);
lock (LayerType)
{
LayerType.Update(this);
}
} }
public override void Render(double deltaTime, ArtemisSurface surface, Graphics graphics) public override void Render(double deltaTime, ArtemisSurface surface, Graphics graphics)
{ {
if (LayerType == null) graphics.SetClip(RenderPath);
return;
lock (LayerType) foreach (var layerElement in LayerElements)
{ layerElement.RenderPreProcess(surface, graphics);
LayerType.Render(this, surface, graphics);
} foreach (var layerElement in LayerElements)
layerElement.Render(surface, graphics);
foreach (var layerElement in LayerElements)
layerElement.RenderPostProcess(surface, graphics);
graphics.ResetClip();
} }
internal override void ApplyToEntity() internal override void ApplyToEntity()
{ {
LayerEntity.Id = EntityId; LayerEntity.Id = EntityId;
LayerEntity.ParentId = Parent?.EntityId ?? new Guid(); LayerEntity.ParentId = Parent?.EntityId ?? new Guid();
LayerEntity.LayerTypeGuid = LayerType?.PluginInfo.Guid ?? new Guid();
LayerEntity.Order = Order; LayerEntity.Order = Order;
LayerEntity.Name = Name; LayerEntity.Name = Name;
@ -99,24 +99,16 @@ namespace Artemis.Core.Models.Profile
LayerEntity.Condition.Clear(); LayerEntity.Condition.Clear();
LayerEntity.Elements.Clear(); LayerEntity.Elements.Clear();
} foreach (var layerElement in LayerElements)
public void ApplySurface(ArtemisSurface surface)
{
var leds = new List<ArtemisLed>();
// Get the surface LEDs for this layer
var availableLeds = surface.Devices.SelectMany(d => d.Leds).ToList();
foreach (var ledEntity in LayerEntity.Leds)
{ {
var match = availableLeds.FirstOrDefault(a => a.Device.RgbDevice.GetDeviceHashCode() == ledEntity.DeviceHash && var layerElementEntity = new LayerElementEntity
a.RgbLed.Id.ToString() == ledEntity.LedName); {
if (match != null) PluginGuid = layerElement.Descriptor.LayerElementProvider.PluginInfo.Guid,
leds.Add(match); LayerElementType = layerElement.GetType().Name,
Configuration = JsonConvert.SerializeObject(layerElement.Settings)
};
LayerEntity.Elements.Add(layerElementEntity);
} }
_leds = leds;
CalculateRenderProperties();
} }
public void AddLed(ArtemisLed led) public void AddLed(ArtemisLed led)
@ -143,17 +135,27 @@ namespace Artemis.Core.Models.Profile
CalculateRenderProperties(); CalculateRenderProperties();
} }
public void UpdateLayerType(LayerType layerType) internal void AddLayerElement(LayerElement layerElement)
{ {
if (LayerType != null) _layerElements.Add(layerElement);
}
public void ApplySurface(ArtemisSurface surface)
{
var leds = new List<ArtemisLed>();
// Get the surface LEDs for this layer
var availableLeds = surface.Devices.SelectMany(d => d.Leds).ToList();
foreach (var ledEntity in LayerEntity.Leds)
{ {
lock (LayerType) var match = availableLeds.FirstOrDefault(a => a.Device.RgbDevice.GetDeviceHashCode() == ledEntity.DeviceHash &&
{ a.RgbLed.Id.ToString() == ledEntity.LedName);
LayerType.Dispose(); if (match != null)
} leds.Add(match);
} }
LayerType = layerType; _leds = leds;
CalculateRenderProperties();
} }
internal void CalculateRenderProperties() internal void CalculateRenderProperties()
@ -167,8 +169,8 @@ namespace Artemis.Core.Models.Profile
// Determine to top-left and bottom-right // Determine to top-left and bottom-right
var minX = Leds.Min(l => l.AbsoluteRenderRectangle.X); var minX = Leds.Min(l => l.AbsoluteRenderRectangle.X);
var minY = Leds.Min(l => l.AbsoluteRenderRectangle.Y); var minY = Leds.Min(l => l.AbsoluteRenderRectangle.Y);
var maxX = Leds.Max(l => l.AbsoluteRenderRectangle.X); var maxX = Leds.Max(l => l.AbsoluteRenderRectangle.X + l.AbsoluteRenderRectangle.Width);
var maxY = Leds.Max(l => l.AbsoluteRenderRectangle.Y); var maxY = Leds.Max(l => l.AbsoluteRenderRectangle.Y + l.AbsoluteRenderRectangle.Height);
RenderRectangle = new Rectangle(minX, minY, maxX - minX, maxY - minY); RenderRectangle = new Rectangle(minX, minY, maxX - minX, maxY - minY);

View File

@ -3,8 +3,8 @@ using System.Drawing;
using System.Linq; using System.Linq;
using Artemis.Core.Exceptions; using Artemis.Core.Exceptions;
using Artemis.Core.Models.Profile.Abstract; using Artemis.Core.Models.Profile.Abstract;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Models; using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces;
using Artemis.Storage.Entities.Profile; using Artemis.Storage.Entities.Profile;
namespace Artemis.Core.Models.Profile namespace Artemis.Core.Models.Profile
@ -23,7 +23,7 @@ namespace Artemis.Core.Models.Profile
ApplyToEntity(); ApplyToEntity();
} }
internal Profile(PluginInfo pluginInfo, ProfileEntity profileEntity, IPluginService pluginService) internal Profile(PluginInfo pluginInfo, ProfileEntity profileEntity)
{ {
ProfileEntity = profileEntity; ProfileEntity = profileEntity;
EntityId = profileEntity.Id; EntityId = profileEntity.Id;
@ -36,7 +36,7 @@ namespace Artemis.Core.Models.Profile
if (rootFolder == null) if (rootFolder == null)
AddChild(new Folder(this, null, "Root folder")); AddChild(new Folder(this, null, "Root folder"));
else else
AddChild(new Folder(this, null, rootFolder, pluginService)); AddChild(new Folder(this, null, rootFolder));
} }
public PluginInfo PluginInfo { get; } public PluginInfo PluginInfo { get; }
@ -56,7 +56,7 @@ namespace Artemis.Core.Models.Profile
} }
} }
public override void Render(double deltaTime, Surface.ArtemisSurface surface, Graphics graphics) public override void Render(double deltaTime, ArtemisSurface surface, Graphics graphics)
{ {
lock (this) lock (this)
{ {
@ -86,12 +86,14 @@ namespace Artemis.Core.Models.Profile
} }
internal void Activate() internal void Activate(ArtemisSurface surface)
{ {
lock (this) lock (this)
{ {
if (IsActivated) return; if (IsActivated)
return;
ApplySurface(surface);
OnActivated(); OnActivated();
IsActivated = true; IsActivated = true;
} }
@ -113,7 +115,7 @@ namespace Artemis.Core.Models.Profile
return $"{nameof(Order)}: {Order}, {nameof(Name)}: {Name}, {nameof(PluginInfo)}: {PluginInfo}"; return $"{nameof(Order)}: {Order}, {nameof(Name)}: {Name}, {nameof(PluginInfo)}: {PluginInfo}";
} }
public void ApplySurface(Surface.ArtemisSurface surface) public void ApplySurface(ArtemisSurface surface)
{ {
foreach (var layer in GetAllLayers()) foreach (var layer in GetAllLayers())
layer.ApplySurface(surface); layer.ApplySurface(surface);

View File

@ -1,4 +1,5 @@
using System; using System;
using System.Diagnostics;
using System.IO; using System.IO;
using Artemis.Core.Extensions; using Artemis.Core.Extensions;
using Artemis.Core.Plugins.Models; using Artemis.Core.Plugins.Models;
@ -8,22 +9,24 @@ namespace Artemis.Core.Plugins.Abstract
{ {
/// <inheritdoc /> /// <inheritdoc />
/// <summary> /// <summary>
/// Allows you to implement your own RGB device /// Allows you to implement and register your own device provider
/// </summary> /// </summary>
public abstract class Device : Plugin public abstract class DeviceProvider : Plugin
{ {
protected Device(PluginInfo pluginInfo, IRGBDeviceProvider deviceProvider) : base(pluginInfo) protected DeviceProvider(PluginInfo pluginInfo, IRGBDeviceProvider rgbDeviceProvider) : base(pluginInfo)
{ {
DeviceProvider = deviceProvider ?? throw new ArgumentNullException(nameof(deviceProvider)); RgbDeviceProvider = rgbDeviceProvider ?? throw new ArgumentNullException(nameof(rgbDeviceProvider));
} }
public IRGBDeviceProvider DeviceProvider { get; } public IRGBDeviceProvider RgbDeviceProvider { get; }
protected void ResolveAbsolutePath(Type type, object sender, ResolvePathEventArgs e) protected void ResolveAbsolutePath(Type type, object sender, ResolvePathEventArgs e)
{ {
if (sender.GetType().IsGenericType(type)) if (sender.GetType().IsGenericType(type))
{ {
Debug.WriteLine(e.RelativePart);
Debug.WriteLine(e.FileName);
// Start from the plugin directory // Start from the plugin directory
if (e.RelativePart != null && e.FileName != null) if (e.RelativePart != null && e.FileName != null)
e.FinalPath = Path.Combine(PluginInfo.Directory.FullName, e.RelativePart, e.FileName); e.FinalPath = Path.Combine(PluginInfo.Directory.FullName, e.RelativePart, e.FileName);

View File

@ -1,29 +0,0 @@
using System.Drawing;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Models;
namespace Artemis.Core.Plugins.Abstract
{
/// <inheritdoc />
/// <summary>
/// Allows you to create your own layer type
/// </summary>
public abstract class LayerType : Plugin
{
protected LayerType(PluginInfo pluginInfo) : base(pluginInfo)
{
}
/// <summary>
/// Updates the layer type
/// </summary>
/// <param name="layer"></param>
public abstract void Update(Layer layer);
/// <summary>
/// Renders the layer type
/// </summary>
public abstract void Render(Layer device, ArtemisSurface surface, Graphics graphics);
}
}

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Drawing; using System.Drawing;
using Artemis.Core.Exceptions;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface; using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Models; using Artemis.Core.Plugins.Models;
@ -34,8 +35,10 @@ namespace Artemis.Core.Plugins.Abstract
} }
} }
public void ChangeActiveProfile(Profile profile) internal void ChangeActiveProfile(Profile profile, ArtemisSurface surface)
{ {
if (profile != null && profile.PluginInfo != PluginInfo)
throw new ArtemisCoreException($"Cannot activate a profile of plugin {profile.PluginInfo} on a module of plugin {PluginInfo}.");
lock (this) lock (this)
{ {
if (profile == ActiveProfile) if (profile == ActiveProfile)
@ -44,7 +47,7 @@ namespace Artemis.Core.Plugins.Abstract
ActiveProfile?.Deactivate(); ActiveProfile?.Deactivate();
ActiveProfile = profile; ActiveProfile = profile;
ActiveProfile?.Activate(); ActiveProfile?.Activate(surface);
} }
OnActiveProfileChanged(); OnActiveProfileChanged();

View File

@ -1,6 +0,0 @@
namespace Artemis.Core.Plugins.Interfaces
{
public interface ILayerTypeConfiguration
{
}
}

View File

@ -0,0 +1,47 @@
using System.Drawing;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface;
namespace Artemis.Core.Plugins.LayerElement
{
public abstract class LayerElement
{
protected LayerElement(Layer layer, LayerElementSettings settings, LayerElementDescriptor descriptor)
{
Layer = layer;
Settings = settings;
Descriptor = descriptor;
}
public Layer Layer { get; }
public LayerElementSettings Settings { get; }
public LayerElementDescriptor Descriptor { get; }
/// <summary>
/// Called by the profile editor to populate the layer element properties panel
/// </summary>
/// <returns></returns>
public abstract LayerElementViewModel GetViewModel();
/// <summary>
/// Called before rendering every frame, write your update logic here
/// </summary>
/// <param name="deltaTime"></param>
public abstract void Update(double deltaTime);
/// <summary>
/// Called before rendering, in the order configured on the layer
/// </summary>
public abstract void RenderPreProcess(ArtemisSurface surface, Graphics graphics);
/// <summary>
/// Called during rendering, in the order configured on the layer
/// </summary>
public abstract void Render(ArtemisSurface surface, Graphics graphics);
/// <summary>
/// Called after rendering, in the order configured on the layer
/// </summary>
public abstract void RenderPostProcess(ArtemisSurface surface, Graphics graphics);
}
}

View File

@ -0,0 +1,22 @@
using System;
namespace Artemis.Core.Plugins.LayerElement
{
public class LayerElementDescriptor
{
internal LayerElementDescriptor(string displayName, string description, string icon, Type layerElementType, LayerElementProvider layerElementProvider)
{
DisplayName = displayName;
Description = description;
Icon = icon;
LayerElementType = layerElementType;
LayerElementProvider = layerElementProvider;
}
public string DisplayName { get; }
public string Description { get; }
public string Icon { get; }
public Type LayerElementType { get; }
public LayerElementProvider LayerElementProvider { get; }
}
}

View File

@ -0,0 +1,28 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
namespace Artemis.Core.Plugins.LayerElement
{
/// <inheritdoc />
/// <summary>
/// Allows you to create one or more <see cref="LayerElement" />s usable by profile layers.
/// </summary>
public abstract class LayerElementProvider : Plugin
{
private readonly List<LayerElementDescriptor> _layerElementDescriptors;
protected LayerElementProvider(PluginInfo pluginInfo) : base(pluginInfo)
{
_layerElementDescriptors = new List<LayerElementDescriptor>();
}
public ReadOnlyCollection<LayerElementDescriptor> LayerElementDescriptors => _layerElementDescriptors.AsReadOnly();
protected void AddLayerElementDescriptor<T>(string displayName, string description, string icon) where T : LayerElement
{
_layerElementDescriptors.Add(new LayerElementDescriptor(displayName, description, icon, typeof(T), this));
}
}
}

View File

@ -0,0 +1,8 @@
using Stylet;
namespace Artemis.Core.Plugins.LayerElement
{
public abstract class LayerElementSettings : PropertyChangedBase
{
}
}

View File

@ -0,0 +1,14 @@
using Stylet;
namespace Artemis.Core.Plugins.LayerElement
{
public abstract class LayerElementViewModel : PropertyChangedBase
{
protected LayerElementViewModel(LayerElement layerElement)
{
LayerElement = layerElement;
}
public LayerElement LayerElement { get; }
}
}

View File

@ -54,7 +54,16 @@ namespace Artemis.Core.RGB.NET
public Graphics GetGraphics() public Graphics GetGraphics()
{ {
return _bitmap == null ? null : Graphics.FromImage(_bitmap.Bitmap); try
{
return _bitmap == null ? null : Graphics.FromImage(_bitmap.Bitmap);
}
catch (AccessViolationException)
{
// ignored
}
return null;
} }
public Bitmap GetBitmap() public Bitmap GetBitmap()

View File

@ -5,7 +5,6 @@ using Artemis.Core.Events;
using Artemis.Core.Exceptions; using Artemis.Core.Exceptions;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Storage;
using Artemis.Core.Services.Storage.Interfaces; using Artemis.Core.Services.Storage.Interfaces;
using RGB.NET.Core; using RGB.NET.Core;
using Serilog; using Serilog;

View File

@ -1,8 +1,4 @@
using System; using System.Drawing;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core.Events; using Artemis.Core.Events;
using Artemis.Core.Models.Surface; using Artemis.Core.Models.Surface;
@ -56,7 +52,7 @@ namespace Artemis.Core.Services
public interface IDeviceService : IArtemisService public interface IDeviceService : IArtemisService
{ {
/// <summary> /// <summary>
/// Identifies the device by making it blink white 5 times /// Identifies the device by making it blink white 5 times
/// </summary> /// </summary>
/// <param name="device"></param> /// <param name="device"></param>
void IdentifyDevice(ArtemisDevice device); void IdentifyDevice(ArtemisDevice device);

View File

@ -0,0 +1,18 @@
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.LayerElement;
namespace Artemis.Core.Services.Interfaces
{
public interface ILayerService : IArtemisService
{
/// <summary>
/// Instantiates and adds the <see cref="LayerElement" /> described by the provided
/// <see cref="LayerElementDescriptor" /> to the provided <see cref="Layer" />.
/// </summary>
/// <param name="layer">The layer to add the new layer element to</param>
/// <param name="layerElementDescriptor">The descriptor of the new layer element</param>
/// <param name="settings">JSON settings to be deserialized and injected into the layer element</param>
/// <returns></returns>
LayerElement InstantiateLayerElement(Layer layer, LayerElementDescriptor layerElementDescriptor, string settings = null);
}
}

View File

@ -55,13 +55,6 @@ namespace Artemis.Core.Services.Interfaces
/// <returns>A list containing all the plugin info</returns> /// <returns>A list containing all the plugin info</returns>
List<PluginInfo> GetAllPluginInfo(); List<PluginInfo> GetAllPluginInfo();
/// <summary>
/// Finds an instance of the layer type matching the given GUID
/// </summary>
/// <param name="layerTypeGuid">The GUID of the layer type to find</param>
/// <returns>An instance of the layer type</returns>
LayerType GetLayerTypeByGuid(Guid layerTypeGuid);
/// <summary> /// <summary>
/// Finds all enabled <see cref="Plugin" /> instances of type <see cref="T" /> /// Finds all enabled <see cref="Plugin" /> instances of type <see cref="T" />
/// </summary> /// </summary>

View File

@ -0,0 +1,50 @@
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Exceptions;
using Artemis.Core.Plugins.LayerElement;
using Artemis.Core.Services.Interfaces;
using Newtonsoft.Json;
using Ninject;
using Ninject.Parameters;
namespace Artemis.Core.Services
{
public class LayerService : ILayerService
{
private readonly IKernel _kernel;
public LayerService(IKernel kernel)
{
_kernel = kernel;
}
public LayerElement InstantiateLayerElement(Layer layer, LayerElementDescriptor layerElementDescriptor, string settings)
{
// Deserialize the settings, if provided
object deserializedSettings = null;
if (settings != null)
{
var settingsType = layerElementDescriptor.LayerElementType.GetProperty(nameof(LayerElement.Settings))?.PropertyType;
if (settingsType == null)
{
throw new ArtemisPluginException(
layerElementDescriptor.LayerElementProvider.PluginInfo,
$"Layer element of type {layerElementDescriptor.LayerElementType} has no Settings property."
);
}
deserializedSettings = JsonConvert.DeserializeObject(settings, settingsType);
}
var arguments = new IParameter[]
{
new ConstructorArgument("layer", layer),
new ConstructorArgument("settings", deserializedSettings),
new ConstructorArgument("descriptor", layerElementDescriptor)
};
var layerElement = (LayerElement) _kernel.Get(layerElementDescriptor.LayerElementType, arguments);
layer.AddLayerElement(layerElement);
return layerElement;
}
}
}

View File

@ -285,19 +285,6 @@ namespace Artemis.Core.Services
return new List<PluginInfo>(_plugins); return new List<PluginInfo>(_plugins);
} }
/// <inheritdoc />
public LayerType GetLayerTypeByGuid(Guid layerTypeGuid)
{
var pluginInfo = _plugins.FirstOrDefault(p => p.Guid == layerTypeGuid);
if (pluginInfo == null)
return null;
if (!(pluginInfo.Instance is LayerType layerType))
throw new ArtemisPluginException(pluginInfo, "Plugin is expected to implement exactly one LayerType");
return layerType;
}
/// <inheritdoc /> /// <inheritdoc />
public List<T> GetPluginsOfType<T>() where T : Plugin public List<T> GetPluginsOfType<T>() where T : Plugin
{ {
@ -309,7 +296,7 @@ namespace Artemis.Core.Services
public Plugin GetDevicePlugin(IRGBDevice rgbDevice) public Plugin GetDevicePlugin(IRGBDevice rgbDevice)
{ {
return GetPluginsOfType<Device>().First(d => d.DeviceProvider.Devices.Contains(rgbDevice)); return GetPluginsOfType<DeviceProvider>().First(d => d.RgbDeviceProvider.Devices.Contains(rgbDevice));
} }
public void Dispose() public void Dispose()

View File

@ -12,5 +12,12 @@ namespace Artemis.Core.Services.Storage.Interfaces
Profile GetActiveProfile(ProfileModule module); Profile GetActiveProfile(ProfileModule module);
void UpdateProfile(Profile profile, bool includeChildren); void UpdateProfile(Profile profile, bool includeChildren);
void DeleteProfile(Profile profile); void DeleteProfile(Profile profile);
/// <summary>
/// Activates the profile for the given <see cref="ProfileModule" /> with the currently active surface
/// </summary>
/// <param name="module">The module to activate the profile for</param>
/// <param name="profile">The profile to activate</param>
void ActivateProfile(ProfileModule module, Profile profile);
} }
} }

View File

@ -16,8 +16,8 @@ namespace Artemis.Core.Services.Storage
public class ProfileService : IProfileService public class ProfileService : IProfileService
{ {
private readonly IPluginService _pluginService; private readonly IPluginService _pluginService;
private readonly ISurfaceService _surfaceService;
private readonly IProfileRepository _profileRepository; private readonly IProfileRepository _profileRepository;
private readonly ISurfaceService _surfaceService;
internal ProfileService(IPluginService pluginService, ISurfaceService surfaceService, IProfileRepository profileRepository) internal ProfileService(IPluginService pluginService, ISurfaceService surfaceService, IProfileRepository profileRepository)
{ {
@ -29,25 +29,6 @@ namespace Artemis.Core.Services.Storage
_surfaceService.SurfaceConfigurationUpdated += SurfaceServiceOnSurfaceConfigurationUpdated; _surfaceService.SurfaceConfigurationUpdated += SurfaceServiceOnSurfaceConfigurationUpdated;
} }
private void SurfaceServiceOnActiveSurfaceConfigurationChanged(object sender, SurfaceConfigurationEventArgs e)
{
ApplySurfaceToProfiles(e.Surface);
}
private void SurfaceServiceOnSurfaceConfigurationUpdated(object sender, SurfaceConfigurationEventArgs e)
{
if (!e.Surface.IsActive)
return;
ApplySurfaceToProfiles(e.Surface);
}
private void ApplySurfaceToProfiles(ArtemisSurface surface)
{
var profileModules = _pluginService.GetPluginsOfType<ProfileModule>();
foreach (var profileModule in profileModules.Where(p => p.ActiveProfile != null).ToList())
profileModule.ActiveProfile.ApplySurface(surface);
}
public List<Profile> GetProfiles(ProfileModule module) public List<Profile> GetProfiles(ProfileModule module)
{ {
var profileEntities = _profileRepository.GetByPluginGuid(module.PluginInfo.Guid); var profileEntities = _profileRepository.GetByPluginGuid(module.PluginInfo.Guid);
@ -58,7 +39,7 @@ namespace Artemis.Core.Services.Storage
if (module.ActiveProfile != null && module.ActiveProfile.EntityId == profileEntity.Id) if (module.ActiveProfile != null && module.ActiveProfile.EntityId == profileEntity.Id)
profiles.Add(module.ActiveProfile); profiles.Add(module.ActiveProfile);
else else
profiles.Add(new Profile(module.PluginInfo, profileEntity, _pluginService)); profiles.Add(new Profile(module.PluginInfo, profileEntity));
} }
return profiles; return profiles;
@ -74,7 +55,7 @@ namespace Artemis.Core.Services.Storage
if (profileEntity == null) if (profileEntity == null)
return null; return null;
return new Profile(module.PluginInfo, profileEntity, _pluginService); return new Profile(module.PluginInfo, profileEntity);
} }
public Profile CreateProfile(ProfileModule module, string name) public Profile CreateProfile(ProfileModule module, string name)
@ -87,6 +68,12 @@ namespace Artemis.Core.Services.Storage
return profile; return profile;
} }
public void ActivateProfile(ProfileModule module, Profile profile)
{
module.ChangeActiveProfile(profile, _surfaceService.ActiveSurface);
}
public void DeleteProfile(Profile profile) public void DeleteProfile(Profile profile)
{ {
_profileRepository.Remove(profile.ProfileEntity); _profileRepository.Remove(profile.ProfileEntity);
@ -108,5 +95,24 @@ namespace Artemis.Core.Services.Storage
_profileRepository.Save(profile.ProfileEntity); _profileRepository.Save(profile.ProfileEntity);
} }
private void SurfaceServiceOnActiveSurfaceConfigurationChanged(object sender, SurfaceConfigurationEventArgs e)
{
ApplySurfaceToProfiles(e.Surface);
}
private void SurfaceServiceOnSurfaceConfigurationUpdated(object sender, SurfaceConfigurationEventArgs e)
{
if (!e.Surface.IsActive)
return;
ApplySurfaceToProfiles(e.Surface);
}
private void ApplySurfaceToProfiles(ArtemisSurface surface)
{
var profileModules = _pluginService.GetPluginsOfType<ProfileModule>();
foreach (var profileModule in profileModules.Where(p => p.ActiveProfile != null).ToList())
profileModule.ActiveProfile.ApplySurface(surface);
}
} }
} }

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="AppDomainToolkit" version="1.0.4.3" targetFramework="net461" /> <package id="AppDomainToolkit" version="1.0.4.3" targetFramework="net461" />
<package id="Ben.Demystifier" version="0.1.4" targetFramework="net472" /> <package id="Ben.Demystifier" version="0.1.4" targetFramework="net472" />

View File

@ -54,7 +54,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CorsairDevice.cs" /> <Compile Include="CorsairDeviceProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -8,11 +8,11 @@ using RGB.NET.Devices.Corsair;
namespace Artemis.Plugins.Devices.Corsair namespace Artemis.Plugins.Devices.Corsair
{ {
// ReSharper disable once UnusedMember.Global // ReSharper disable once UnusedMember.Global
public class CorsairDevice : Device public class CorsairDeviceProvider : DeviceProvider
{ {
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public CorsairDevice(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, CorsairDeviceProvider.Instance) public CorsairDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.Corsair.CorsairDeviceProvider.Instance)
{ {
_rgbService = rgbService; _rgbService = rgbService;
} }
@ -20,9 +20,9 @@ namespace Artemis.Plugins.Devices.Corsair
public override void EnablePlugin() public override void EnablePlugin()
{ {
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(CorsairRGBDevice<>), sender, args); PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(CorsairRGBDevice<>), sender, args);
CorsairDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "CUESDK.x64_2017.dll")); RGB.NET.Devices.Corsair.CorsairDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "CUESDK.x64_2017.dll"));
CorsairDeviceProvider.PossibleX86NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x86", "CUESDK_2017.dll")); RGB.NET.Devices.Corsair.CorsairDeviceProvider.PossibleX86NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x86", "CUESDK_2017.dll"));
_rgbService.AddDeviceProvider(DeviceProvider); _rgbService.AddDeviceProvider(RgbDeviceProvider);
} }
public override void DisablePlugin() public override void DisablePlugin()

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 KiB

View File

@ -0,0 +1,138 @@
<?xml version="1.0"?>
<Device xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>Corsair MM800 RGB</Name>
<Description>Physical layout of Corsairs ST100 RGB</Description>
<Type>HeadsetStand</Type>
<Lighting>Key</Lighting>
<Vendor>Corsair</Vendor>
<Model>ST100RGB</Model>
<Width>145</Width>
<Height>148</Height>
<LedUnitWidth>42</LedUnitWidth>
<LedUnitHeight>44</LedUnitHeight>
<ImageBasePath>Images\Corsair\HeadsetStands</ImageBasePath>
<DeviceImage>ST100RGB.png</DeviceImage>
<Leds>
<Led Id="HeadsetStand9">
<X>5</X>
<Y>10</Y>
</Led>
<Led Id="HeadsetStand8">
<X>=</X>
<Y>+</Y>
</Led>
<Led Id="HeadsetStand7">
<X>=</X>
<Y>+</Y>
</Led>
<Led Id="HeadsetStand6">
<Y>~</Y>
<Width>1.2</Width>
<Height>1</Height>
</Led>
<Led Id="HeadsetStand5">
<Width>1</Width>
<Height>1</Height>
</Led>
<Led Id="HeadsetStand4">
<X>~</X>
<Y>-</Y>
</Led>
<Led Id="HeadsetStand3">
<X>~</X>
<Y>-</Y>
</Led>
<Led Id="HeadsetStand1">
<Shape>M0.442,0.467 L0.456,0.518 L0.456,0.567 L0.446,0.62 L0.438,0.645 L0.469,0.613 L0.52,0.579 L0.564,0.569 L0.583,0.596 L0.593,0.564 L0.59,0.528 L0.566,0.474 L0.545,0.43 L0.516,0.384 L0.523,0.445 L0.521,0.491 L0.516,0.55 L0.518,0.496 L0.519,0.469 L0.501,0.447 L0.486,0.425 L0.489,0.469 L0.492,0.528 L0.484,0.564 L0.484,0.499z M0.451,0.411 L0.463,0.443 L0.464,0.467 L0.484,0.479 L0.478,0.435z M0.488,0.379 L0.497,0.43 L0.516,0.447 L0.513,0.406z M0.52,0.318 L0.528,0.37 L0.532,0.394 L0.557,0.418 L0.568,0.457 L0.572,0.425 L0.559,0.377 L0.543,0.343z</Shape>
<X>-3.75</X>
<Y>0</Y>
<Height>0.45</Height>
</Led>
<Led Id="HeadsetStand2">
<X>=</X>
<Y>+</Y>
</Led>
</Leds>
<LedImageLayouts>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand9" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand8" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand7" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand6" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand5" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand4" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand3" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand2" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand9" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand2" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand8" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand3" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand7" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand4" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand6" />
</LedImages>
</LedImageLayout>
<LedImageLayout>
<LedImages>
<LedImage Id="HeadsetStand1" />
</LedImages>
</LedImageLayout>
</LedImageLayouts>
</Device>

View File

@ -0,0 +1,496 @@
<?xml version="1.0" encoding="utf-8"?>
<Device xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>Corsair K70 RGB - Physical UK</Name>
<Description>Physical UK-Layout of Corsairs K70 RGB (Logical: BE, CH, DE, ES, EU, FR, IT, ND, MEX, RU, UK, US_Int)</Description>
<Author>Darth Affe</Author>
<Type>Keyboard</Type>
<Lighting>Key</Lighting>
<Vendor>Corsair</Vendor>
<Model>K70 RGB</Model>
<Width>436</Width>
<Height>165</Height>
<ImageBasePath>Images\Corsair\Keyboards</ImageBasePath>
<DeviceImage>K70RGB.png</DeviceImage>
<Leds>
<!-- Extra-Keys: Brightness -> Mute -->
<Led Id="Keyboard_Brightness">
<Shape>Circle</Shape>
<X>298</X>
<Y>6</Y>
<Width>10mm</Width>
<Height>10mm</Height>
</Led>
<Led Id="Keyboard_WinLock">
<Shape>Circle</Shape>
<X>+9</X>
<Width>10mm</Width>
<Height>10mm</Height>
</Led>
<Led Id="Keyboard_MediaMute">
<X>375</X>
<Y>6</Y>
<Height>12mm</Height>
</Led>
<!-- Esc -> NextTrack -->
<Led Id="Keyboard_Escape">
<X>4</X>
<Y>28</Y>
</Led>
<Led Id="Keyboard_F1">
<X>+12.667</X>
</Led>
<Led Id="Keyboard_F2" />
<Led Id="Keyboard_F3" />
<Led Id="Keyboard_F4" />
<Led Id="Keyboard_F5">
<X>+12.667</X>
</Led>
<Led Id="Keyboard_F6" />
<Led Id="Keyboard_F7" />
<Led Id="Keyboard_F8" />
<Led Id="Keyboard_F9">
<X>+12.667</X>
</Led>
<Led Id="Keyboard_F10" />
<Led Id="Keyboard_F11" />
<Led Id="Keyboard_F12" />
<Led Id="Keyboard_PrintScreen">
<X>+5</X>
</Led>
<Led Id="Keyboard_ScrollLock" />
<Led Id="Keyboard_PauseBreak" />
<Led Id="Keyboard_MediaStop">
<X>+5</X>
<Height>12mm</Height>
</Led>
<Led Id="Keyboard_MediaPreviousTrack">
<Height>12mm</Height>
</Led>
<Led Id="Keyboard_MediaPlay">
<Height>12mm</Height>
</Led>
<Led Id="Keyboard_MediaNextTrack">
<Height>12mm</Height>
</Led>
<!-- ^ -> Num- -->
<Led Id="Keyboard_GraveAccentAndTilde">
<X>4</X>
<Y>49</Y>
</Led>
<Led Id="Keyboard_1" />
<Led Id="Keyboard_2" />
<Led Id="Keyboard_3" />
<Led Id="Keyboard_4" />
<Led Id="Keyboard_5" />
<Led Id="Keyboard_6" />
<Led Id="Keyboard_7" />
<Led Id="Keyboard_8" />
<Led Id="Keyboard_9" />
<Led Id="Keyboard_0" />
<Led Id="Keyboard_MinusAndUnderscore" />
<Led Id="Keyboard_EqualsAndPlus" />
<Led Id="Keyboard_Backspace">
<Width>2</Width>
</Led>
<Led Id="Keyboard_Insert">
<X>+5</X>
</Led>
<Led Id="Keyboard_Home" />
<Led Id="Keyboard_PageUp" />
<Led Id="Keyboard_NumLock">
<X>+5</X>
</Led>
<Led Id="Keyboard_NumSlash" />
<Led Id="Keyboard_NumAsterisk" />
<Led Id="Keyboard_NumMinus" />
<!-- Tab -> Num+ -->
<Led Id="Keyboard_Tab">
<X>4</X>
<Y>+</Y>
<Width>1.5</Width>
</Led>
<Led Id="Keyboard_Q" />
<Led Id="Keyboard_W" />
<Led Id="Keyboard_E" />
<Led Id="Keyboard_R" />
<Led Id="Keyboard_T" />
<Led Id="Keyboard_Y" />
<Led Id="Keyboard_U" />
<Led Id="Keyboard_I" />
<Led Id="Keyboard_O" />
<Led Id="Keyboard_P" />
<Led Id="Keyboard_BracketLeft" />
<Led Id="Keyboard_BracketRight" />
<Led Id="Keyboard_Enter">
<Shape>M0,0 L0,0.5 L0.16666666666,0.5 L0.16666666666,1 L1,1 L1,0 Z</Shape>
<Width>1.5</Width>
<Height>2</Height>
</Led>
<Led Id="Keyboard_Delete">
<X>+5</X>
</Led>
<Led Id="Keyboard_End" />
<Led Id="Keyboard_PageDown" />
<Led Id="Keyboard_Num7">
<X>+5</X>
</Led>
<Led Id="Keyboard_Num8" />
<Led Id="Keyboard_Num9" />
<Led Id="Keyboard_NumPlus">
<Height>2</Height>
</Led>
<!-- CapsLock -> Num6 -->
<Led Id="Keyboard_CapsLock">
<X>4</X>
<Y>~</Y>
<Width>1.75</Width>
</Led>
<Led Id="Keyboard_A" />
<Led Id="Keyboard_S" />
<Led Id="Keyboard_D" />
<Led Id="Keyboard_F" />
<Led Id="Keyboard_G" />
<Led Id="Keyboard_H" />
<Led Id="Keyboard_J" />
<Led Id="Keyboard_K" />
<Led Id="Keyboard_L" />
<Led Id="Keyboard_SemicolonAndColon" />
<Led Id="Keyboard_ApostropheAndDoubleQuote" />
<Led Id="Keyboard_NonUsTilde" />
<Led Id="Keyboard_Num4">
<X>+90.75</X>
</Led>
<Led Id="Keyboard_Num5" />
<Led Id="Keyboard_Num6" />
<!-- LShift -> NumEnter -->
<Led Id="Keyboard_LeftShift">
<X>4</X>
<Y>+</Y>
<Width>1.25</Width>
</Led>
<Led Id="Keyboard_NonUsBackslash" />
<Led Id="Keyboard_Z" />
<Led Id="Keyboard_X" />
<Led Id="Keyboard_C" />
<Led Id="Keyboard_V" />
<Led Id="Keyboard_B" />
<Led Id="Keyboard_N" />
<Led Id="Keyboard_M" />
<Led Id="Keyboard_CommaAndLessThan" />
<Led Id="Keyboard_PeriodAndBiggerThan" />
<Led Id="Keyboard_SlashAndQuestionMark" />
<Led Id="Keyboard_RightShift">
<Width>2.75</Width>
</Led>
<Led Id="Keyboard_ArrowUp">
<X>+24</X>
</Led>
<Led Id="Keyboard_Num1">
<X>+24</X>
</Led>
<Led Id="Keyboard_Num2" />
<Led Id="Keyboard_Num3" />
<Led Id="Keyboard_NumEnter">
<Height>2</Height>
</Led>
<!-- LCtrl -> NumPeriod -->
<Led Id="Keyboard_LeftCtrl">
<X>4</X>
<Y>~</Y>
<Width>1.5</Width>
</Led>
<Led Id="Keyboard_LeftGui" />
<Led Id="Keyboard_LeftAlt">
<Width>1.25</Width>
</Led>
<Led Id="Keyboard_Space">
<Width>6.5</Width>
</Led>
<Led Id="Keyboard_RightAlt">
<Width>1.25</Width>
</Led>
<Led Id="Keyboard_RightGui" />
<Led Id="Keyboard_Application" />
<Led Id="Keyboard_RightCtrl">
<Width>1.5</Width>
</Led>
<Led Id="Keyboard_ArrowLeft">
<X>+5</X>
</Led>
<Led Id="Keyboard_ArrowDown" />
<Led Id="Keyboard_ArrowRight" />
<Led Id="Keyboard_Num0">
<X>+5</X>
<Width>2</Width>
</Led>
<Led Id="Keyboard_NumPeriodAndDelete" />
</Leds>
<LedImageLayouts>
<LedImageLayout Layout="DE">
<LedImages>
<LedImage Id="Keyboard_Brightness" Image="K_Keys\Brightness.png" />
<LedImage Id="Keyboard_WinLock" Image="K_Keys\WinLock.png" />
<LedImage Id="Keyboard_MediaMute" Image="K_Keys\Mute.png" />
<LedImage Id="Keyboard_Escape" Image="K_Keys\Escape.png" />
<LedImage Id="Keyboard_F1" Image="K_Keys\F1.png" />
<LedImage Id="Keyboard_F2" Image="K_Keys\F2.png" />
<LedImage Id="Keyboard_F3" Image="K_Keys\F3.png" />
<LedImage Id="Keyboard_F4" Image="K_Keys\F4.png" />
<LedImage Id="Keyboard_F5" Image="K_Keys\F5.png" />
<LedImage Id="Keyboard_F6" Image="K_Keys\F6.png" />
<LedImage Id="Keyboard_F7" Image="K_Keys\F7.png" />
<LedImage Id="Keyboard_F8" Image="K_Keys\F8.png" />
<LedImage Id="Keyboard_F9" Image="K_Keys\F9.png" />
<LedImage Id="Keyboard_F10" Image="K_Keys\F10.png" />
<LedImage Id="Keyboard_F11" Image="K_Keys\F11.png" />
<LedImage Id="Keyboard_F12" Image="K_Keys\F12.png" />
<LedImage Id="Keyboard_PrintScreen" Image="K_Keys\Drucken.png" />
<LedImage Id="Keyboard_ScrollLock" Image="K_Keys\Rollen.png" />
<LedImage Id="Keyboard_PauseBreak" Image="K_Keys\PauseUntbr.png" />
<LedImage Id="Keyboard_MediaStop" Image="K_Keys\Stop.png" />
<LedImage Id="Keyboard_MediaPreviousTrack" Image="K_Keys\PreviousTrack.png" />
<LedImage Id="Keyboard_MediaPlay" Image="K_Keys\PlayPause.png" />
<LedImage Id="Keyboard_MediaNextTrack" Image="K_Keys\NextTrack.png" />
<LedImage Id="Keyboard_GraveAccentAndTilde" Image="K_Keys\Circumflex_Degree.png" />
<LedImage Id="Keyboard_1" Image="K_Keys\1_ExclamationMark.png" />
<LedImage Id="Keyboard_2" Image="K_Keys\2_QuotationMark_Exponent2.png" />
<LedImage Id="Keyboard_3" Image="K_Keys\3_SectionSign_Exponent3.png" />
<LedImage Id="Keyboard_4" Image="K_Keys\4_Dollar.png" />
<LedImage Id="Keyboard_5" Image="K_Keys\5_Percent.png" />
<LedImage Id="Keyboard_6" Image="K_Keys\6_Ampersand.png" />
<LedImage Id="Keyboard_7" Image="K_Keys\7_Slash_CurlyBracketLeft.png" />
<LedImage Id="Keyboard_8" Image="K_Keys\8_BracketLeft_SquareBracketLeft.png" />
<LedImage Id="Keyboard_9" Image="K_Keys\9_BracketRight_SquareBracketRight.png" />
<LedImage Id="Keyboard_0" Image="K_Keys\0_Equals_CurlyBracketRight.png" />
<LedImage Id="Keyboard_MinusAndUnderscore" Image="K_Keys\QuestionMark_SharpS_Backslash.png" />
<LedImage Id="Keyboard_EqualsAndPlus" Image="K_Keys\AccentGrave_AccentAcute.png" />
<LedImage Id="Keyboard_Backspace" Image="K_Keys\Backspace.png" />
<LedImage Id="Keyboard_Insert" Image="K_Keys\Einfg.png" />
<LedImage Id="Keyboard_Home" Image="K_Keys\Pos1.png" />
<LedImage Id="Keyboard_PageUp" Image="K_Keys\BildUp.png" />
<LedImage Id="Keyboard_NumLock" Image="K_Keys\Num.png" />
<LedImage Id="Keyboard_NumSlash" Image="K_Keys\Slash.png" />
<LedImage Id="Keyboard_NumAsterisk" Image="K_Keys\Asterisk.png" />
<LedImage Id="Keyboard_NumMinus" Image="K_Keys\Minus.png" />
<LedImage Id="Keyboard_Tab" Image="K_Keys\Tab.png" />
<LedImage Id="Keyboard_Q" Image="K_Keys\Q_At.png" />
<LedImage Id="Keyboard_W" Image="K_Keys\W.png" />
<LedImage Id="Keyboard_E" Image="K_Keys\E_Euro.png" />
<LedImage Id="Keyboard_R" Image="K_Keys\R.png" />
<LedImage Id="Keyboard_T" Image="K_Keys\T.png" />
<LedImage Id="Keyboard_Y" Image="K_Keys\Z.png" />
<LedImage Id="Keyboard_U" Image="K_Keys\U.png" />
<LedImage Id="Keyboard_I" Image="K_Keys\I.png" />
<LedImage Id="Keyboard_O" Image="K_Keys\O.png" />
<LedImage Id="Keyboard_P" Image="K_Keys\P.png" />
<LedImage Id="Keyboard_BracketLeft" Image="K_Keys\UE.png" />
<LedImage Id="Keyboard_BracketRight" Image="K_Keys\Plus_Asterisk_Tilde.png" />
<LedImage Id="Keyboard_Enter" Image="K_Keys\Enter.png" />
<LedImage Id="Keyboard_Delete" Image="K_Keys\Entf.png" />
<LedImage Id="Keyboard_End" Image="K_Keys\Ende.png" />
<LedImage Id="Keyboard_PageDown" Image="K_Keys\BildDown.png" />
<LedImage Id="Keyboard_Num7" Image="K_Keys\Num7_Pos1.png" />
<LedImage Id="Keyboard_Num8" Image="K_Keys\Num8_ArrowUp.png" />
<LedImage Id="Keyboard_Num9" Image="K_Keys\Num9_BildUp.png" />
<LedImage Id="Keyboard_NumPlus" Image="K_Keys\NumPlus.png" />
<LedImage Id="Keyboard_CapsLock" Image="K_Keys\CapsLock.png" />
<LedImage Id="Keyboard_A" Image="K_Keys\A.png" />
<LedImage Id="Keyboard_S" Image="K_Keys\S.png" />
<LedImage Id="Keyboard_D" Image="K_Keys\D.png" />
<LedImage Id="Keyboard_F" Image="K_Keys\F.png" />
<LedImage Id="Keyboard_G" Image="K_Keys\G.png" />
<LedImage Id="Keyboard_H" Image="K_Keys\H.png" />
<LedImage Id="Keyboard_J" Image="K_Keys\J.png" />
<LedImage Id="Keyboard_K" Image="K_Keys\K.png" />
<LedImage Id="Keyboard_L" Image="K_Keys\L.png" />
<LedImage Id="Keyboard_SemicolonAndColon" Image="K_Keys\OE.png" />
<LedImage Id="Keyboard_ApostropheAndDoubleQuote" Image="K_Keys\AE.png" />
<LedImage Id="Keyboard_NonUsTilde" Image="K_Keys\Hash_Apostrophe.png" />
<LedImage Id="Keyboard_Num4" Image="K_Keys\Num4_ArrowLeft.png" />
<LedImage Id="Keyboard_Num5" Image="K_Keys\Num5.png" />
<LedImage Id="Keyboard_Num6" Image="K_Keys\Num6_ArrowRight.png" />
<LedImage Id="Keyboard_LeftShift" Image="K_Keys\Shift.png" />
<LedImage Id="Keyboard_NonUsBackslash" Image="K_Keys\LessThan_GreaterThan_Pipe.png" />
<LedImage Id="Keyboard_Z" Image="K_Keys\Y.png" />
<LedImage Id="Keyboard_X" Image="K_Keys\X.png" />
<LedImage Id="Keyboard_C" Image="K_Keys\C.png" />
<LedImage Id="Keyboard_V" Image="K_Keys\V.png" />
<LedImage Id="Keyboard_B" Image="K_Keys\B.png" />
<LedImage Id="Keyboard_N" Image="K_Keys\N.png" />
<LedImage Id="Keyboard_M" Image="K_Keys\M_Mu.png" />
<LedImage Id="Keyboard_CommaAndLessThan" Image="K_Keys\Comma_Semicolon.png" />
<LedImage Id="Keyboard_PeriodAndBiggerThan" Image="K_Keys\Dot_Colon.png" />
<LedImage Id="Keyboard_SlashAndQuestionMark" Image="K_Keys\Hyphen_Underscore.png" />
<LedImage Id="Keyboard_RightShift" Image="K_Keys\ShiftBig.png" />
<LedImage Id="Keyboard_ArrowUp" Image="K_Keys\CaretUp.png" />
<LedImage Id="Keyboard_Num1" Image="K_Keys\Num1_Ende.png" />
<LedImage Id="Keyboard_Num2" Image="K_Keys\Num2_ArrowDown.png" />
<LedImage Id="Keyboard_Num3" Image="K_Keys\Num3_BildDown.png" />
<LedImage Id="Keyboard_NumEnter" Image="K_Keys\NumEnter.png" />
<LedImage Id="Keyboard_LeftCtrl" Image="K_Keys\Strg.png" />
<LedImage Id="Keyboard_LeftGui" Image="K_Keys\Windows.png" />
<LedImage Id="Keyboard_LeftAlt" Image="K_Keys\Alt.png" />
<LedImage Id="Keyboard_Space" Image="K_Keys\Space.png" />
<LedImage Id="Keyboard_RightAlt" Image="K_Keys\AltGr.png" />
<LedImage Id="Keyboard_RightGui" Image="K_Keys\Windows.png" />
<LedImage Id="Keyboard_Application" Image="K_Keys\Menu.png" />
<LedImage Id="Keyboard_RightCtrl" Image="K_Keys\Strg.png" />
<LedImage Id="Keyboard_ArrowLeft" Image="K_Keys\CaretLeft.png" />
<LedImage Id="Keyboard_ArrowDown" Image="K_Keys\CaretDown.png" />
<LedImage Id="Keyboard_ArrowRight" Image="K_Keys\CaretRight.png" />
<LedImage Id="Keyboard_Num0" Image="K_Keys\Num0_Einfg.png" />
<LedImage Id="Keyboard_NumPeriodAndDelete" Image="K_Keys\Comma_Entf.png" />
</LedImages>
</LedImageLayout>
<LedImageLayout Layout="EU">
<LedImages>
<LedImage Id="Keyboard_Brightness" Image="K_Keys\Brightness.png" />
<LedImage Id="Keyboard_WinLock" Image="K_Keys\WinLock.png" />
<LedImage Id="Keyboard_MediaMute" Image="K_Keys\Mute.png" />
<LedImage Id="Keyboard_Escape" Image="K_Keys\Escape.png" />
<LedImage Id="Keyboard_F1" Image="K_Keys\F1.png" />
<LedImage Id="Keyboard_F2" Image="K_Keys\F2.png" />
<LedImage Id="Keyboard_F3" Image="K_Keys\F3.png" />
<LedImage Id="Keyboard_F4" Image="K_Keys\F4.png" />
<LedImage Id="Keyboard_F5" Image="K_Keys\F5.png" />
<LedImage Id="Keyboard_F6" Image="K_Keys\F6.png" />
<LedImage Id="Keyboard_F7" Image="K_Keys\F7.png" />
<LedImage Id="Keyboard_F8" Image="K_Keys\F8.png" />
<LedImage Id="Keyboard_F9" Image="K_Keys\F9.png" />
<LedImage Id="Keyboard_F10" Image="K_Keys\F10.png" />
<LedImage Id="Keyboard_F11" Image="K_Keys\F11.png" />
<LedImage Id="Keyboard_F12" Image="K_Keys\F12.png" />
<LedImage Id="Keyboard_PrintScreen" Image="K_Keys\PrtScnSysRq.png" />
<LedImage Id="Keyboard_ScrollLock" Image="K_Keys\ScrollLock.png" />
<LedImage Id="Keyboard_PauseBreak" Image="K_Keys\PauseBreak.png" />
<LedImage Id="Keyboard_MediaStop" Image="K_Keys\Stop.png" />
<LedImage Id="Keyboard_MediaPreviousTrack" Image="K_Keys\PreviousTrack.png" />
<LedImage Id="Keyboard_MediaPlay" Image="K_Keys\PlayPause.png" />
<LedImage Id="Keyboard_MediaNextTrack" Image="K_Keys\NextTrack.png" />
<LedImage Id="Keyboard_GraveAccentAndTilde" Image="K_Keys\AccentGrave_Tilde.png" />
<LedImage Id="Keyboard_1" Image="K_Keys\1_ExclamationMark.png" />
<LedImage Id="Keyboard_2" Image="K_Keys\2_At.png" />
<LedImage Id="Keyboard_3" Image="K_Keys\3_Hash.png" />
<LedImage Id="Keyboard_4" Image="K_Keys\4_Dollar.png" />
<LedImage Id="Keyboard_5" Image="K_Keys\5_Percent_Euro.png" />
<LedImage Id="Keyboard_6" Image="K_Keys\6_Circumflex.png" />
<LedImage Id="Keyboard_7" Image="K_Keys\7_Ampersand.png" />
<LedImage Id="Keyboard_8" Image="K_Keys\8_Asterisk.png" />
<LedImage Id="Keyboard_9" Image="K_Keys\9_BracketRight.png" />
<LedImage Id="Keyboard_0" Image="K_Keys\0_BracketRight.png" />
<LedImage Id="Keyboard_MinusAndUnderscore" Image="K_Keys\Hyphen_Underscore.png" />
<LedImage Id="Keyboard_EqualsAndPlus" Image="K_Keys\Equals_Plus.png" />
<LedImage Id="Keyboard_Backspace" Image="K_Keys\Backspace.png" />
<LedImage Id="Keyboard_Insert" Image="K_Keys\Insert.png" />
<LedImage Id="Keyboard_Home" Image="K_Keys\Home.png" />
<LedImage Id="Keyboard_PageUp" Image="K_Keys\PageUp.png" />
<LedImage Id="Keyboard_NumLock" Image="K_Keys\NumLock.png" />
<LedImage Id="Keyboard_NumSlash" Image="K_Keys\Slash.png" />
<LedImage Id="Keyboard_NumAsterisk" Image="K_Keys\Asterisk.png" />
<LedImage Id="Keyboard_NumMinus" Image="K_Keys\Minus.png" />
<LedImage Id="Keyboard_Tab" Image="K_Keys\TabWText.png" />
<LedImage Id="Keyboard_Q" Image="K_Keys\Q.png" />
<LedImage Id="Keyboard_W" Image="K_Keys\W.png" />
<LedImage Id="Keyboard_E" Image="K_Keys\E.png" />
<LedImage Id="Keyboard_R" Image="K_Keys\R.png" />
<LedImage Id="Keyboard_T" Image="K_Keys\T.png" />
<LedImage Id="Keyboard_Y" Image="K_Keys\Y.png" />
<LedImage Id="Keyboard_U" Image="K_Keys\U.png" />
<LedImage Id="Keyboard_I" Image="K_Keys\I.png" />
<LedImage Id="Keyboard_O" Image="K_Keys\O.png" />
<LedImage Id="Keyboard_P" Image="K_Keys\P.png" />
<LedImage Id="Keyboard_BracketLeft" Image="K_Keys\SquareBracketLeft_CurlyBracketLeft.png" />
<LedImage Id="Keyboard_BracketRight" Image="K_Keys\SquareBracketRight_CurlyBracketRight.png" />
<LedImage Id="Keyboard_Enter" Image="K_Keys\EnterWText.png" />
<LedImage Id="Keyboard_Delete" Image="K_Keys\Delete.png" />
<LedImage Id="Keyboard_End" Image="K_Keys\End.png" />
<LedImage Id="Keyboard_PageDown" Image="K_Keys\PageDown.png" />
<LedImage Id="Keyboard_Num7" Image="K_Keys\Num7_Home.png" />
<LedImage Id="Keyboard_Num8" Image="K_Keys\Num8_ArrowUp.png" />
<LedImage Id="Keyboard_Num9" Image="K_Keys\Num9_PgUp.png" />
<LedImage Id="Keyboard_NumPlus" Image="K_Keys\NumPlus.png" />
<LedImage Id="Keyboard_CapsLock" Image="K_Keys\CapsLockText.png" />
<LedImage Id="Keyboard_A" Image="K_Keys\A.png" />
<LedImage Id="Keyboard_S" Image="K_Keys\S.png" />
<LedImage Id="Keyboard_D" Image="K_Keys\D.png" />
<LedImage Id="Keyboard_F" Image="K_Keys\F.png" />
<LedImage Id="Keyboard_G" Image="K_Keys\G.png" />
<LedImage Id="Keyboard_H" Image="K_Keys\H.png" />
<LedImage Id="Keyboard_J" Image="K_Keys\J.png" />
<LedImage Id="Keyboard_K" Image="K_Keys\K.png" />
<LedImage Id="Keyboard_L" Image="K_Keys\L.png" />
<LedImage Id="Keyboard_SemicolonAndColon" Image="K_Keys\Semicolon_Colon.png" />
<LedImage Id="Keyboard_ApostropheAndDoubleQuote" Image="K_Keys\Apostrophe_QuotationMark.png" />
<LedImage Id="Keyboard_NonUsTilde" Image="K_Keys\Blackslash_Pipe.png" />
<LedImage Id="Keyboard_Num4" Image="K_Keys\Num4_ArrowLeft.png" />
<LedImage Id="Keyboard_Num5" Image="K_Keys\Num5.png" />
<LedImage Id="Keyboard_Num6" Image="K_Keys\Num6_ArrowRight.png" />
<LedImage Id="Keyboard_LeftShift" Image="K_Keys\ShiftWText.png" />
<LedImage Id="Keyboard_NonUsBackslash" Image="K_Keys\Blackslash_Pipe.png" />
<LedImage Id="Keyboard_Z" Image="K_Keys\Z.png" />
<LedImage Id="Keyboard_X" Image="K_Keys\X.png" />
<LedImage Id="Keyboard_C" Image="K_Keys\C.png" />
<LedImage Id="Keyboard_V" Image="K_Keys\V.png" />
<LedImage Id="Keyboard_B" Image="K_Keys\B.png" />
<LedImage Id="Keyboard_N" Image="K_Keys\N.png" />
<LedImage Id="Keyboard_M" Image="K_Keys\M.png" />
<LedImage Id="Keyboard_CommaAndLessThan" Image="K_Keys\LessThan_Comma.png" />
<LedImage Id="Keyboard_PeriodAndBiggerThan" Image="K_Keys\GreaterThan_Dot.png" />
<LedImage Id="Keyboard_SlashAndQuestionMark" Image="K_Keys\QuestionMark_Slash.png" />
<LedImage Id="Keyboard_RightShift" Image="K_Keys\ShiftWTextBig.png" />
<LedImage Id="Keyboard_ArrowUp" Image="K_Keys\CaretUp.png" />
<LedImage Id="Keyboard_Num1" Image="K_Keys\Num1_End.png" />
<LedImage Id="Keyboard_Num2" Image="K_Keys\Num2_ArrowDown.png" />
<LedImage Id="Keyboard_Num3" Image="K_Keys\Num3_PgDn.png" />
<LedImage Id="Keyboard_NumEnter" Image="K_Keys\NumEnter.png" />
<LedImage Id="Keyboard_LeftCtrl" Image="K_Keys\Ctrl.png" />
<LedImage Id="Keyboard_LeftGui" Image="K_Keys\Windows.png" />
<LedImage Id="Keyboard_LeftAlt" Image="K_Keys\Alt.png" />
<LedImage Id="Keyboard_Space" Image="K_Keys\Space.png" />
<LedImage Id="Keyboard_RightAlt" Image="K_Keys\AltGr.png" />
<LedImage Id="Keyboard_RightGui" Image="K_Keys\Windows.png" />
<LedImage Id="Keyboard_Application" Image="K_Keys\Menu.png" />
<LedImage Id="Keyboard_RightCtrl" Image="K_Keys\Ctrl.png" />
<LedImage Id="Keyboard_ArrowLeft" Image="K_Keys\CaretLeft.png" />
<LedImage Id="Keyboard_ArrowDown" Image="K_Keys\CaretDown.png" />
<LedImage Id="Keyboard_ArrowRight" Image="K_Keys\CaretRight.png" />
<LedImage Id="Keyboard_Num0" Image="K_Keys\Num0_Ins.png" />
<LedImage Id="Keyboard_NumPeriodAndDelete" Image="K_Keys\Comma_Del.png" />
</LedImages>
</LedImageLayout>
</LedImageLayouts>
</Device>

View File

@ -47,7 +47,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="LogitechDevice.cs" /> <Compile Include="LogitechDeviceProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -7,11 +7,11 @@ using RGB.NET.Devices.Logitech;
namespace Artemis.Plugins.Devices.Logitech namespace Artemis.Plugins.Devices.Logitech
{ {
public class LogitechDevice : Device public class LogitechDeviceProvider : DeviceProvider
{ {
private readonly IRgbService _rgbService; private readonly IRgbService _rgbService;
public LogitechDevice(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, LogitechDeviceProvider.Instance) public LogitechDeviceProvider(PluginInfo pluginInfo, IRgbService rgbService) : base(pluginInfo, RGB.NET.Devices.Logitech.LogitechDeviceProvider.Instance)
{ {
_rgbService = rgbService; _rgbService = rgbService;
} }
@ -19,9 +19,9 @@ namespace Artemis.Plugins.Devices.Logitech
public override void EnablePlugin() public override void EnablePlugin()
{ {
PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(LogitechRGBDevice<>), sender, args); PathHelper.ResolvingAbsolutePath += (sender, args) => ResolveAbsolutePath(typeof(LogitechRGBDevice<>), sender, args);
LogitechDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "LogitechLedEnginesWrapper.dll")); RGB.NET.Devices.Logitech.LogitechDeviceProvider.PossibleX64NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x64", "LogitechLedEnginesWrapper.dll"));
LogitechDeviceProvider.PossibleX86NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x86", "LogitechLedEnginesWrapper.dll")); RGB.NET.Devices.Logitech.LogitechDeviceProvider.PossibleX86NativePaths.Add(Path.Combine(PluginInfo.Directory.FullName, "x86", "LogitechLedEnginesWrapper.dll"));
_rgbService.AddDeviceProvider(DeviceProvider); _rgbService.AddDeviceProvider(RgbDeviceProvider);
} }
public override void DisablePlugin() public override void DisablePlugin()

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<runtime> <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

View File

@ -7,8 +7,8 @@
<ProjectGuid>{0F288A66-6EB0-4589-8595-E33A3A3EAEA2}</ProjectGuid> <ProjectGuid>{0F288A66-6EB0-4589-8595-E33A3A3EAEA2}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Artemis.Plugins.LayerTypes.Brush</RootNamespace> <RootNamespace>Artemis.Plugins.LayerElements.Brush</RootNamespace>
<AssemblyName>Artemis.Plugins.LayerTypes.Brush</AssemblyName> <AssemblyName>Artemis.Plugins.LayerElements.Brush</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
@ -33,14 +33,20 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="MaterialDesignColors, Version=1.2.0.325, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignColors.1.2.0\lib\net45\MaterialDesignColors.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="MaterialDesignThemes.Wpf">
<HintPath>..\packages\MaterialDesignThemes.2.6.0\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="PresentationCore" /> <Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" /> <Reference Include="PresentationFramework" />
<Reference Include="QRCoder, Version=1.2.5.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QRCoder.1.2.5\lib\net40\QRCoder.dll</HintPath>
</Reference>
<Reference Include="RGB.NET.Core, Version=0.1.25.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="RGB.NET.Core, Version=0.1.25.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\RGB.NET\bin\net45\RGB.NET.Core.dll</HintPath> <HintPath>..\..\..\RGB.NET\bin\net45\RGB.NET.Core.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="Stylet, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Stylet, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Stylet.1.2.0\lib\net45\Stylet.dll</HintPath> <HintPath>..\packages\Stylet.1.2.0\lib\net45\Stylet.dll</HintPath>
@ -52,6 +58,7 @@
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath> <HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" /> <Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
@ -59,14 +66,13 @@
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Net.Http" /> <Reference Include="System.Net.Http" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\QRCoder.1.2.5\lib\net40\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BrushConfiguration.cs" /> <Compile Include="BrushLayerElementSettings.cs" />
<Compile Include="BrushLayerType.cs" /> <Compile Include="BrushLayerElementViewModel.cs" />
<Compile Include="BrushLayerElement.cs" />
<Compile Include="BrushLayerElementProvider.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -83,6 +89,12 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Page Include="BrushLayerElementView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <PropertyGroup>
<PostBuildEvent>echo Copying plugin to Artemis.UI output directory <PostBuildEvent>echo Copying plugin to Artemis.UI output directory

View File

@ -1,9 +0,0 @@
using Artemis.Core.Plugins.Interfaces;
namespace Artemis.Plugins.LayerTypes.Brush
{
public class BrushConfiguration : ILayerTypeConfiguration
{
public System.Windows.Media.Brush Brush { get; set; }
}
}

View File

@ -0,0 +1,40 @@
using System.Drawing;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.LayerElement;
namespace Artemis.Plugins.LayerElements.Brush
{
public class BrushLayerElement : LayerElement
{
public BrushLayerElement(Layer layer, BrushLayerElementSettings settings, LayerElementDescriptor descriptor) : base(layer, settings, descriptor)
{
Settings = settings ?? new BrushLayerElementSettings {Brush = new SolidBrush(Color.Red)};
}
public new BrushLayerElementSettings Settings { get; }
public override LayerElementViewModel GetViewModel()
{
return new BrushLayerElementViewModel(this);
}
public override void Update(double deltaTime)
{
}
public override void RenderPreProcess(ArtemisSurface surface, Graphics graphics)
{
}
public override void Render(ArtemisSurface surface, Graphics graphics)
{
if (Settings?.Brush != null)
graphics.FillRectangle(Settings.Brush, Layer.RenderRectangle);
}
public override void RenderPostProcess(ArtemisSurface surface, Graphics graphics)
{
}
}
}

View File

@ -0,0 +1,25 @@
using Artemis.Core.Plugins.LayerElement;
using Artemis.Core.Plugins.Models;
namespace Artemis.Plugins.LayerElements.Brush
{
public class BrushLayerElementProvider : LayerElementProvider
{
public BrushLayerElementProvider(PluginInfo pluginInfo) : base(pluginInfo)
{
AddLayerElementDescriptor<BrushLayerElement>("Brush", "A brush of a specific type and colors", "Brush");
}
public override void EnablePlugin()
{
}
public override void DisablePlugin()
{
}
public override void Dispose()
{
}
}
}

View File

@ -0,0 +1,9 @@
using Artemis.Core.Plugins.LayerElement;
namespace Artemis.Plugins.LayerElements.Brush
{
public class BrushLayerElementSettings : LayerElementSettings
{
public System.Drawing.Brush Brush { get; set; }
}
}

View File

@ -0,0 +1,54 @@
<UserControl x:Class="Artemis.Plugins.LayerElements.Brush.BrushLayerElementView"
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:brushLayer="clr-namespace:Artemis.Plugins.LayerElements.Brush"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type brushLayer:BrushLayerElementViewModel}}">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Teal.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Teal.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid Margin="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Setting 1 -->
<StackPanel Grid.Row="0" Grid.Column="0">
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Setting title</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}">Setting subtitle</TextBlock>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" ToolTip="Default ToggleButton Style" />
</StackPanel>
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
<!-- Setting 2 -->
<StackPanel Grid.Row="2" Grid.Column="0">
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Setting title</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}">Setting subtitle</TextBlock>
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="1" VerticalAlignment="Center">
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" ToolTip="Default ToggleButton Style" />
</StackPanel>
<Separator Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignLightSeparator}" />
</Grid>
</UserControl>

View File

@ -0,0 +1,14 @@
using Artemis.Core.Plugins.LayerElement;
namespace Artemis.Plugins.LayerElements.Brush
{
public class BrushLayerElementViewModel : LayerElementViewModel
{
public BrushLayerElementViewModel(BrushLayerElement layerElement) : base(layerElement)
{
LayerElement = layerElement;
}
public new BrushLayerElement LayerElement { get; }
}
}

View File

@ -1,42 +0,0 @@
using System.Drawing;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
using QRCoder;
namespace Artemis.Plugins.LayerTypes.Brush
{
public class BrushLayerType : LayerType
{
public BrushLayerType(PluginInfo pluginInfo) : base(pluginInfo)
{
}
public override void EnablePlugin()
{
var qrGenerator = new QRCodeGenerator();
}
public override void DisablePlugin()
{
}
public override void Update(Layer layer)
{
var config = layer.LayerTypeConfiguration as BrushConfiguration;
if (config == null)
return;
// Update the brush
}
public override void Render(Layer device, ArtemisSurface surface, Graphics graphics)
{
}
public override void Dispose()
{
}
}
}

View File

@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information // set of attributes. Change these attribute values to modify the information
// associated with an assembly. // associated with an assembly.
[assembly: AssemblyTitle("Artemis.Plugins.LayerTypes.Brush")] [assembly: AssemblyTitle("Artemis.Plugins.LayerElements.Brush")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="QRCoder" version="1.2.5" targetFramework="net461" /> <package id="MaterialDesignColors" version="1.2.0" targetFramework="net472" />
<package id="Stylet" version="1.2.0" targetFramework="net472" /> <package id="Stylet" version="1.2.0" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" /> <package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages> </packages>

View File

@ -1,10 +1,10 @@
{ {
"Guid": "92a9d6ba-6f7a-4937-94d5-c1d715b4141a", "Guid": "92a9d6ba-6f7a-4937-94d5-c1d715b4141a",
"Name": "Brush layer", "Name": "Brush layer elements",
"Version": { "Version": {
"Major": 1, "Major": 1,
"Minor": 0, "Minor": 0,
"Build": 0 "Build": 0
}, },
"Main": "Artemis.Plugins.LayerTypes.Brush.dll" "Main": "Artemis.Plugins.LayerElements.Brush.dll"
} }

View File

@ -8,6 +8,8 @@ using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models; using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Storage.Interfaces; using Artemis.Core.Services.Storage.Interfaces;
using Artemis.Plugins.Modules.General.ViewModels; using Artemis.Plugins.Modules.General.ViewModels;
using RGB.NET.Core;
using Color = System.Drawing.Color;
namespace Artemis.Plugins.Modules.General namespace Artemis.Plugins.Modules.General
{ {
@ -45,6 +47,8 @@ namespace Artemis.Plugins.Modules.General
public int[] Hues { get; set; } public int[] Hues { get; set; }
public int MovePercentage { get; set; } public int MovePercentage { get; set; }
public Dictionary<ArtemisDevice, TextureBrush> DeviceBrushes { get; set; }
public override void EnablePlugin() public override void EnablePlugin()
{ {
} }
@ -65,16 +69,20 @@ namespace Artemis.Plugins.Modules.General
MovePercentage++; MovePercentage++;
if (MovePercentage > 100) if (MovePercentage > 100)
MovePercentage = 0; MovePercentage = 0;
base.Update(deltaTime);
} }
public override void Render(double deltaTime, ArtemisSurface surface, Graphics graphics) public override void Render(double deltaTime, ArtemisSurface surface, Graphics graphics)
{ {
// Per-device coloring, slower // Per-device coloring, slower
RenderPerDevice(surface, graphics); // RenderPerDevice(surface, graphics);
// Per-LED coloring, slowest // Per-LED coloring, slowest
// RenderPerLed(surface, graphics); // RenderPerLed(surface, graphics);
base.Render(deltaTime, surface, graphics);
} }
public void RenderFullSurface(ArtemisSurface surface, Graphics graphics) public void RenderFullSurface(ArtemisSurface surface, Graphics graphics)
@ -97,8 +105,6 @@ namespace Artemis.Plugins.Modules.General
} }
} }
public Dictionary<ArtemisDevice, TextureBrush> DeviceBrushes { get; set; }
private Image RenderGradientForDevice(ArtemisDevice device) private Image RenderGradientForDevice(ArtemisDevice device)
{ {
var brush = new LinearGradientBrush(device.RenderRectangle, Color.Black, Color.Black, 0, false) var brush = new LinearGradientBrush(device.RenderRectangle, Color.Black, Color.Black, 0, false)
@ -119,7 +125,10 @@ namespace Artemis.Plugins.Modules.General
var index = 0; var index = 0;
foreach (var led in surface.Devices.SelectMany(d => d.Leds)) foreach (var led in surface.Devices.SelectMany(d => d.Leds))
{ {
graphics.FillRectangle(new SolidBrush(ColorHelpers.ColorFromHSV(Hues[index], 1, 1)), led.AbsoluteRenderRectangle); if (led.RgbLed.Id == LedId.HeadsetStand1)
graphics.FillRectangle(new SolidBrush(Color.Red), led.AbsoluteRenderRectangle);
else
graphics.FillRectangle(new SolidBrush(ColorHelpers.ColorFromHSV(Hues[index], 1, 1)), led.AbsoluteRenderRectangle);
index++; index++;
} }
} }

View File

@ -4,6 +4,8 @@ namespace Artemis.Storage.Entities.Profile
{ {
public class LayerElementEntity public class LayerElementEntity
{ {
public Guid Id { get; set; } public Guid PluginGuid { get; set; }
public string LayerElementType { get; set; }
public string Configuration { get; set; }
} }
} }

View File

@ -15,7 +15,6 @@ namespace Artemis.Storage.Entities.Profile
public Guid Id { get; set; } public Guid Id { get; set; }
public Guid ParentId { get; set; } public Guid ParentId { get; set; }
public Guid LayerTypeGuid { get; set; }
public int Order { get; set; } public int Order { get; set; }
public string Name { get; set; } public string Name { get; set; }

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Artemis.Storage.Entities;
using Artemis.Storage.Entities.Profile; using Artemis.Storage.Entities.Profile;
namespace Artemis.Storage.Repositories.Interfaces namespace Artemis.Storage.Repositories.Interfaces

View File

@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using Artemis.Storage.Entities;
using Artemis.Storage.Entities.Surface; using Artemis.Storage.Entities.Surface;
namespace Artemis.Storage.Repositories.Interfaces namespace Artemis.Storage.Repositories.Interfaces

View File

@ -31,7 +31,7 @@
<!-- Include the Dragablz Material Design style --> <!-- Include the Dragablz Material Design style -->
<ResourceDictionary Source="pack://application:,,,/Dragablz;component/Themes/materialdesign.xaml" /> <ResourceDictionary Source="pack://application:,,,/Dragablz;component/Themes/materialdesign.xaml" />
<ResourceDictionary Source="ResourceDictionaries/Scrollbar.xaml"/> <ResourceDictionary Source="ResourceDictionaries/Scrollbar.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<!-- MahApps Brushes --> <!-- MahApps Brushes -->

View File

@ -148,11 +148,14 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Bootstrapper.cs" /> <Compile Include="Bootstrapper.cs" />
<Compile Include="Converters\ColorToDrawingColorConverter.cs" />
<Compile Include="Converters\ColorToSolidColorBrushConverter.cs" /> <Compile Include="Converters\ColorToSolidColorBrushConverter.cs" />
<Compile Include="Converters\InverseBooleanConverter.cs" /> <Compile Include="Converters\InverseBooleanConverter.cs" />
<Compile Include="Converters\NullToImageConverter.cs" /> <Compile Include="Converters\NullToImageConverter.cs" />
<Compile Include="Converters\NullToVisibilityConverter.cs" /> <Compile Include="Converters\NullToVisibilityConverter.cs" />
<Compile Include="Events\MainWindowFocusChangedEvent.cs" /> <Compile Include="Events\MainWindowFocusChangedEvent.cs" />
<Compile Include="Screens\GradientEditor\GradientEditorViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerElements\Dialogs\AddLayerElementViewModel.cs" />
<Compile Include="Services\Interfaces\IProfileEditorService.cs" /> <Compile Include="Services\Interfaces\IProfileEditorService.cs" />
<Compile Include="Services\ProfileEditorService.cs" /> <Compile Include="Services\ProfileEditorService.cs" />
<Compile Include="Utilities\BindableSelectedItemBehavior.cs" /> <Compile Include="Utilities\BindableSelectedItemBehavior.cs" />
@ -179,7 +182,6 @@
<Compile Include="Screens\Module\ProfileEditor\DisplayConditions\DisplayConditionsViewModel.cs" /> <Compile Include="Screens\Module\ProfileEditor\DisplayConditions\DisplayConditionsViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\DisplayConditions\DisplayConditionViewModel.cs" /> <Compile Include="Screens\Module\ProfileEditor\DisplayConditions\DisplayConditionViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\ElementProperties\ElementPropertiesViewModel.cs" /> <Compile Include="Screens\Module\ProfileEditor\ElementProperties\ElementPropertiesViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\ElementProperties\ElementPropertyViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerElements\LayerElementsViewModel.cs" /> <Compile Include="Screens\Module\ProfileEditor\LayerElements\LayerElementsViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\LayerElements\LayerElementViewModel.cs" /> <Compile Include="Screens\Module\ProfileEditor\LayerElements\LayerElementViewModel.cs" />
<Compile Include="Screens\Module\ProfileEditor\ProfileTree\TreeItem\FolderViewModel.cs" /> <Compile Include="Screens\Module\ProfileEditor\ProfileTree\TreeItem\FolderViewModel.cs" />
@ -226,6 +228,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Screens\GradientEditor\GradientEditorView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Module\ProfileEditor\Dialogs\ProfileCreateView.xaml"> <Page Include="Screens\Module\ProfileEditor\Dialogs\ProfileCreateView.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
@ -246,7 +252,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Screens\Module\ProfileEditor\ElementProperties\ElementPropertyView.xaml"> <Page Include="Screens\Module\ProfileEditor\LayerElements\Dialogs\AddLayerElementView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
@ -254,10 +260,6 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Screens\Module\ProfileEditor\LayerElements\LayerElementView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Screens\Module\ProfileEditor\ProfileTree\TreeItem\FolderView.xaml"> <Page Include="Screens\Module\ProfileEditor\ProfileTree\TreeItem\FolderView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>

View File

@ -0,0 +1,33 @@
using System;
using System.Drawing;
using System.Globalization;
using System.Windows.Data;
namespace Artemis.UI.Converters
{
/// <inheritdoc />
/// <summary>
/// Converts <see cref="T:System.Drawing.Color" /> into <see cref="T:System.Windows.Media.Color" />.
/// </summary>
[ValueConversion(typeof(Color), typeof(System.Windows.Media.Color))]
public class ColorToDrawingColorConverter : IValueConverter
{
/// <inheritdoc />
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is Color drawingColor)
return System.Windows.Media.Color.FromArgb(drawingColor.A, drawingColor.R, drawingColor.G, drawingColor.B);
return default(System.Windows.Media.Color);
}
/// <inheritdoc />
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is System.Windows.Media.Color mediaColor)
return Color.FromArgb(mediaColor.A, mediaColor.R, mediaColor.G, mediaColor.B);
return default(Color);
}
}
}

View File

@ -0,0 +1,16 @@
<mah:MetroWindow x:Class="Artemis.UI.Screens.GradientEditor.GradientEditorView"
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"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:gradientEditor="clr-namespace:Artemis.UI.Screens.GradientEditor"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
Title="Gradient Editor"
Height="450" Width="800"
d:DataContext="{d:DesignInstance {x:Type gradientEditor:GradientEditorViewModel}}">
<Grid>
<materialDesign:ColorPicker Color="{Binding CurrentColor}" />
</Grid>
</mah:MetroWindow>

View File

@ -0,0 +1,10 @@
using System.Windows.Media;
using Stylet;
namespace Artemis.UI.Screens.GradientEditor
{
public class GradientEditorViewModel : Screen
{
public Color CurrentColor { get; set; }
}
}

View File

@ -16,7 +16,7 @@
Margin="0 8 0 16" Margin="0 8 0 16"
Style="{StaticResource MaterialDesignFloatingHintTextBox}" Style="{StaticResource MaterialDesignFloatingHintTextBox}"
Text="{Binding ElementName, UpdateSourceTrigger=PropertyChanged}" Text="{Binding ElementName, UpdateSourceTrigger=PropertyChanged}"
Loaded="FrameworkElement_OnLoaded"/> Loaded="FrameworkElement_OnLoaded" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" Margin="0 8 8 0" Command="{s:Action Cancel}"> <Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" Margin="0 8 8 0" Command="{s:Action Cancel}">

View File

@ -3,15 +3,23 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.ElementProperties" xmlns:elementProperties="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.ElementProperties"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type elementProperties:ElementPropertiesViewModel}}">
<Grid> <Grid>
<StackPanel> <Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<TextBlock Style="{StaticResource MaterialDesignSubheadingTextBlock}" Margin="10 5 0 -4"> <TextBlock Style="{StaticResource MaterialDesignSubheadingTextBlock}" Margin="10 5 0 -4">
Layer element properties Layer element properties
</TextBlock> </TextBlock>
<Separator Style="{StaticResource MaterialDesignDarkSeparator}" Margin="8 0" /> <Separator Style="{StaticResource MaterialDesignDarkSeparator}" Margin="8 0" />
</StackPanel> </StackPanel>
<ContentControl Grid.Row="1" s:View.Model="{Binding LayerElementViewModel}" />
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -1,6 +1,25 @@
namespace Artemis.UI.Screens.Module.ProfileEditor.ElementProperties using System;
using Artemis.Core.Plugins.LayerElement;
using Artemis.UI.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.ElementProperties
{ {
public class ElementPropertiesViewModel : ProfileEditorPanelViewModel public class ElementPropertiesViewModel : ProfileEditorPanelViewModel
{ {
private readonly IProfileEditorService _profileEditorService;
public ElementPropertiesViewModel(IProfileEditorService profileEditorService)
{
_profileEditorService = profileEditorService;
_profileEditorService.SelectedLayerElementChanged += OnSelectedLayerElementChanged;
}
public LayerElementViewModel LayerElementViewModel { get; set; }
private void OnSelectedLayerElementChanged(object sender, EventArgs e)
{
LayerElementViewModel = _profileEditorService.SelectedLayerElement?.GetViewModel();
}
} }
} }

View File

@ -1,10 +0,0 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.ElementProperties.ElementPropertyView"
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.Module.ProfileEditor.ElementProperties"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid />
</UserControl>

View File

@ -1,6 +0,0 @@
namespace Artemis.UI.Screens.Module.ProfileEditor.ElementProperties
{
public class ElementPropertyViewModel
{
}
}

View File

@ -0,0 +1,45 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerElements.Dialogs.AddLayerElementView"
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:layerElement="clr-namespace:Artemis.Core.Plugins.LayerElement;assembly=Artemis.Core"
xmlns:layerElements="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerElements.Dialogs"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance {x:Type layerElements:AddLayerElementViewModel}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Margin="15">Select a new layer element below</TextBlock>
<ListBox Grid.Row="1" ItemsSource="{Binding LayerElementDescriptors}" SelectedItem="{Binding SelectedLayerElementDescriptor}" HorizontalContentAlignment="Stretch">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type layerElement:LayerElementDescriptor}">
<Border Padding="8" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MaterialDesignDivider}" VerticalAlignment="Stretch" MouseDown="{s:Action ListBoxItemMouseClick}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<materialDesign:PackIcon Kind="{Binding Icon}" Width="20" Height="20" VerticalAlignment="Center" />
<StackPanel Margin="8 0 0 0" Grid.Column="1" VerticalAlignment="Stretch">
<TextBlock FontWeight="Bold" Text="{Binding DisplayName}" />
<TextBlock Text="{Binding Description}" />
</StackPanel>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="10 15">
<Button Style="{StaticResource MaterialDesignFlatButton}" IsCancel="True" Margin="0 8 8 0" Command="{s:Action Cancel}">CANCEL</Button>
<Button Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 8 0" Command="{s:Action Accept}">ACCEPT</Button>
</StackPanel>
</Grid>
</UserControl>

View File

@ -0,0 +1,53 @@
using System.Windows.Input;
using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.LayerElement;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.ViewModels.Dialogs;
using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerElements.Dialogs
{
public class AddLayerElementViewModel : DialogViewModelBase
{
private readonly ILayerService _layerService;
public AddLayerElementViewModel(IPluginService pluginService, ILayerService layerService, Layer layer)
{
_layerService = layerService;
Layer = layer;
LayerElementDescriptors = new BindableCollection<LayerElementDescriptor>();
var layerElementProviders = pluginService.GetPluginsOfType<LayerElementProvider>();
foreach (var layerElementProvider in layerElementProviders)
LayerElementDescriptors.AddRange(layerElementProvider.LayerElementDescriptors);
}
public Layer Layer { get; }
public LayerElementDescriptor SelectedLayerElementDescriptor { get; set; }
public BindableCollection<LayerElementDescriptor> LayerElementDescriptors { get; set; }
public bool CanAccept => SelectedLayerElementDescriptor != null;
public void Accept()
{
var layerElement = _layerService.InstantiateLayerElement(Layer, SelectedLayerElementDescriptor);
Session.Close(layerElement);
}
public void Cancel()
{
Session.Close();
}
#region View event handlers
public void ListBoxItemMouseClick(object sender, MouseButtonEventArgs args)
{
if (args.ClickCount > 1 && SelectedLayerElementDescriptor != null)
Accept();
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerElements.LayerElementView"
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.Module.ProfileEditor.LayerElements"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid />
</UserControl>

View File

@ -1,6 +1,19 @@
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerElements using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.LayerElement;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerElements
{ {
public class LayerElementViewModel public class LayerElementViewModel
{ {
public LayerElementViewModel(LayerElement layerElement)
{
Layer = layerElement.Layer;
LayerElement = layerElement;
LayerElementDescriptor = layerElement.Descriptor;
}
public Layer Layer { get; set; }
public LayerElement LayerElement { get; set; }
public LayerElementDescriptor LayerElementDescriptor { get; set; }
} }
} }

View File

@ -3,15 +3,69 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerElements" xmlns:layerElements="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.LayerElements"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800"
<Grid> d:DataContext="{d:DesignInstance {x:Type layerElements:LayerElementsViewModel}}">
<StackPanel>
<TextBlock Style="{StaticResource MaterialDesignSubheadingTextBlock}" Margin="10 5 0 -4"> <materialDesign:DialogHost Identifier="LayerElementsDialogHost" CloseOnClickAway="True">
Layer elements <Grid>
</TextBlock> <Grid.RowDefinitions>
<Separator Style="{StaticResource MaterialDesignDarkSeparator}" Margin="8 0" /> <RowDefinition Height="Auto" />
</StackPanel> <RowDefinition Height="*" />
</Grid> </Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<TextBlock Style="{StaticResource MaterialDesignSubheadingTextBlock}" Margin="10 5 0 -4">
Layer elements
</TextBlock>
<Separator Style="{StaticResource MaterialDesignDarkSeparator}" Margin="8 0" />
</StackPanel>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ListBox ItemsSource="{Binding LayerElements}" SelectedItem="{Binding SelectedLayerElement}" HorizontalContentAlignment="Stretch">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type layerElements:LayerElementViewModel}">
<Border Padding="8" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MaterialDesignDivider}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<materialDesign:PackIcon Kind="{Binding LayerElementDescriptor.Icon}" Width="20" Height="20" VerticalAlignment="Center" />
<StackPanel Margin="8 0 0 0" Grid.Column="1">
<TextBlock FontWeight="Bold" Text="{Binding LayerElementDescriptor.DisplayName}" />
<TextBlock Text="{Binding LayerElementDescriptor.Description}" />
</StackPanel>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel VerticalAlignment="Bottom" Grid.Column="1" Orientation="Vertical" Margin="8">
<Button Style="{StaticResource MaterialDesignToolButton}"
Width="30"
Padding="2 0 2 0"
materialDesign:RippleAssist.IsCentered="True"
ToolTip="Add a new layer element"
Command="{s:Action AddLayerElement}">
<materialDesign:PackIcon Kind="LibraryAdd" />
</Button>
<Button Style="{StaticResource MaterialDesignToolButton}"
Width="30"
Padding="2 0 2 0"
materialDesign:RippleAssist.IsCentered="True"
ToolTip="Delete selected layer element"
Command="{s:Action DeleteSelectedLayerElement}">
<materialDesign:PackIcon Kind="Delete" />
</Button>
</StackPanel>
</Grid>
</Grid>
</materialDesign:DialogHost>
</UserControl> </UserControl>

View File

@ -1,6 +1,95 @@
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerElements using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Abstract;
using Artemis.Core.Plugins.LayerElement;
using Artemis.UI.Screens.Module.ProfileEditor.LayerElements.Dialogs;
using Artemis.UI.Services.Interfaces;
using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerElements
{ {
public class LayerElementsViewModel : ProfileEditorPanelViewModel public class LayerElementsViewModel : ProfileEditorPanelViewModel
{ {
private readonly IDialogService _dialogService;
private readonly IProfileEditorService _profileEditorService;
private LayerElementViewModel _selectedLayerElement;
public LayerElementsViewModel(IProfileEditorService profileEditorService, IDialogService dialogService)
{
_profileEditorService = profileEditorService;
_dialogService = dialogService;
LayerElements = new BindableCollection<LayerElementViewModel>();
SelectedProfileElement = _profileEditorService.SelectedProfileElement;
PopulateLayerElements();
_profileEditorService.SelectedProfileElementChanged += OnSelectedProfileElementChanged;
_profileEditorService.SelectedLayerElementChanged += OnSelectedLayerElementChanged;
}
public ProfileElement SelectedProfileElement { get; private set; }
public BindableCollection<LayerElementViewModel> LayerElements { get; set; }
public LayerElementViewModel SelectedLayerElement
{
get => _selectedLayerElement;
set
{
_selectedLayerElement = value;
_profileEditorService.ChangeSelectedLayerElement(value?.LayerElement);
}
}
public bool CanAddLayerElement => SelectedProfileElement is Layer;
public bool CanDeleteSelectedLayerElement => SelectedLayerElement != null;
private void OnSelectedLayerElementChanged(object sender, EventArgs e)
{
_selectedLayerElement = LayerElements.FirstOrDefault(l => l.LayerElement == _profileEditorService.SelectedLayerElement);
NotifyOfPropertyChange(() => SelectedLayerElement);
}
private void OnSelectedProfileElementChanged(object sender, EventArgs e)
{
SelectedProfileElement = _profileEditorService.SelectedProfileElement;
PopulateLayerElements();
}
private void PopulateLayerElements()
{
LayerElements.Clear();
if (SelectedProfileElement is Layer layer)
{
foreach (var layerElement in layer.LayerElements)
LayerElements.Add(new LayerElementViewModel(layerElement));
}
}
public async void AddLayerElement()
{
var result = await _dialogService.ShowDialogAt<AddLayerElementViewModel>(
"LayerElementsDialogHost",
new Dictionary<string, object> {{"layer", (Layer) SelectedProfileElement}}
);
if (result is LayerElement layerElement)
LayerElements.Add(new LayerElementViewModel(layerElement));
}
public async void DeleteSelectedLayerElement()
{
if (SelectedLayerElement == null)
return;
var result = await _dialogService.ShowConfirmDialogAt(
"LayerElementsDialogHost",
"Delete layer element",
"Are you sure you want to delete the selected layer element?"
);
if (!result)
return;
}
} }
} }

View File

@ -8,7 +8,6 @@ using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models; using Artemis.Core.Plugins.Models;
using Artemis.Core.Services; using Artemis.Core.Services;
using Artemis.Core.Services.Storage.Interfaces; using Artemis.Core.Services.Storage.Interfaces;
using Artemis.UI.Events;
using Artemis.UI.Screens.Module.ProfileEditor.Dialogs; using Artemis.UI.Screens.Module.ProfileEditor.Dialogs;
using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions; using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions;
using Artemis.UI.Screens.Module.ProfileEditor.ElementProperties; using Artemis.UI.Screens.Module.ProfileEditor.ElementProperties;
@ -81,7 +80,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
return; return;
var oldProfile = Module.ActiveProfile; var oldProfile = Module.ActiveProfile;
Module.ChangeActiveProfile(profile); _profileService.ActivateProfile(Module, profile);
if (oldProfile != null) if (oldProfile != null)
_profileService.UpdateProfile(oldProfile, false); _profileService.UpdateProfile(oldProfile, false);
@ -186,7 +185,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
_profileEditorService.ChangeSelectedProfile(SelectedProfile); _profileEditorService.ChangeSelectedProfile(SelectedProfile);
if (!activeProfile.IsActivated) if (!activeProfile.IsActivated)
Module.ChangeActiveProfile(activeProfile); _profileService.ActivateProfile(Module, activeProfile);
} }
} }
} }

View File

@ -132,10 +132,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree
private void OnSelectedElementChanged(object sender, EventArgs e) private void OnSelectedElementChanged(object sender, EventArgs e)
{ {
var vms = RootFolder.GetAllChildren(); var vms = RootFolder?.GetAllChildren();
// Don't set it using the setter or that will trigger the event again // Don't set it using the setter or that will trigger the event again
_selectedTreeItem = vms.FirstOrDefault(vm => vm.ProfileElement == _profileEditorService.SelectedProfileElement); _selectedTreeItem = vms?.FirstOrDefault(vm => vm.ProfileElement == _profileEditorService.SelectedProfileElement);
NotifyOfPropertyChange(() => SelectedTreeItem); NotifyOfPropertyChange(() => SelectedTreeItem);
} }

View File

@ -37,8 +37,10 @@
</ContextMenu> </ContextMenu>
</StackPanel.ContextMenu> </StackPanel.ContextMenu>
<StackPanel Orientation="Horizontal" Margin="10"> <StackPanel Orientation="Horizontal" Margin="10">
<materialDesign:PackIcon Kind="Folder" Visibility="{Binding IsExpanded, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}"/> <materialDesign:PackIcon Kind="Folder"
<materialDesign:PackIcon Kind="FolderOpen" Visibility="{Binding IsExpanded, Converter={x:Static s:BoolToVisibilityConverter.Instance}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}"/> Visibility="{Binding IsExpanded, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}" />
<materialDesign:PackIcon Kind="FolderOpen"
Visibility="{Binding IsExpanded, Converter={x:Static s:BoolToVisibilityConverter.Instance}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}" />
<TextBlock Text="{Binding ProfileElement.Name}" Margin="10 0 0 0" /> <TextBlock Text="{Binding ProfileElement.Name}" Margin="10 0 0 0" />
</StackPanel> </StackPanel>

View File

@ -38,7 +38,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
public Geometry StrokeGeometry { get; private set; } public Geometry StrokeGeometry { get; private set; }
public Color DisplayColor { get; private set; } public Color DisplayColor { get; private set; }
private void CreateLedGeometry() private void CreateLedGeometry()
{ {
switch (Led.RgbLed.Shape) switch (Led.RgbLed.Shape)

View File

@ -1,7 +1,5 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
@ -15,7 +13,6 @@ using Artemis.UI.Screens.News;
using Artemis.UI.Screens.Settings; using Artemis.UI.Screens.Settings;
using Artemis.UI.Screens.SurfaceEditor; using Artemis.UI.Screens.SurfaceEditor;
using Artemis.UI.Screens.Workshop; using Artemis.UI.Screens.Workshop;
using MahApps.Metro.Controls;
using Stylet; using Stylet;
namespace Artemis.UI.Screens namespace Artemis.UI.Screens
@ -23,8 +20,8 @@ namespace Artemis.UI.Screens
public class RootViewModel : Conductor<IScreen> public class RootViewModel : Conductor<IScreen>
{ {
private readonly ICollection<IScreenViewModel> _artemisViewModels; private readonly ICollection<IScreenViewModel> _artemisViewModels;
private readonly IModuleViewModelFactory _moduleViewModelFactory;
private readonly IEventAggregator _eventAggregator; private readonly IEventAggregator _eventAggregator;
private readonly IModuleViewModelFactory _moduleViewModelFactory;
private readonly IPluginService _pluginService; private readonly IPluginService _pluginService;
private bool _lostFocus; private bool _lostFocus;

View File

@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Workshop" xmlns:local="clr-namespace:Artemis.UI.Screens.Workshop"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<Grid> <Grid>

View File

@ -29,8 +29,8 @@ namespace Artemis.UI.Services.Dialog
{ {
new ConstructorArgument("header", header), new ConstructorArgument("header", header),
new ConstructorArgument("text", text), new ConstructorArgument("text", text),
new ConstructorArgument("confirmText", confirmText), new ConstructorArgument("confirmText", confirmText.ToUpper()),
new ConstructorArgument("cancelText", cancelText) new ConstructorArgument("cancelText", cancelText.ToUpper())
}; };
var result = await ShowDialog<ConfirmDialogViewModel>(arguments); var result = await ShowDialog<ConfirmDialogViewModel>(arguments);
return (bool) result; return (bool) result;
@ -42,8 +42,8 @@ namespace Artemis.UI.Services.Dialog
{ {
new ConstructorArgument("header", header), new ConstructorArgument("header", header),
new ConstructorArgument("text", text), new ConstructorArgument("text", text),
new ConstructorArgument("confirmText", confirmText), new ConstructorArgument("confirmText", confirmText.ToUpper()),
new ConstructorArgument("cancelText", cancelText) new ConstructorArgument("cancelText", cancelText.ToUpper())
}; };
var result = await ShowDialogAt<ConfirmDialogViewModel>(identifier, arguments); var result = await ShowDialogAt<ConfirmDialogViewModel>(identifier, arguments);
return (bool) result; return (bool) result;

View File

@ -1,6 +1,7 @@
using System; using System;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Abstract; using Artemis.Core.Models.Profile.Abstract;
using Artemis.Core.Plugins.LayerElement;
namespace Artemis.UI.Services.Interfaces namespace Artemis.UI.Services.Interfaces
{ {
@ -8,15 +9,18 @@ namespace Artemis.UI.Services.Interfaces
{ {
Profile SelectedProfile { get; } Profile SelectedProfile { get; }
ProfileElement SelectedProfileElement { get; } ProfileElement SelectedProfileElement { get; }
LayerElement SelectedLayerElement { get; }
void ChangeSelectedProfile(Profile profile); void ChangeSelectedProfile(Profile profile);
void UpdateSelectedProfile(); void UpdateSelectedProfile();
void ChangeSelectedProfileElement(ProfileElement profileElement); void ChangeSelectedProfileElement(ProfileElement profileElement);
void UpdateSelectedProfileElement(); void UpdateSelectedProfileElement();
void ChangeSelectedLayerElement(LayerElement layerElement);
event EventHandler SelectedProfileChanged; event EventHandler SelectedProfileChanged;
event EventHandler SelectedProfileUpdated; event EventHandler SelectedProfileUpdated;
event EventHandler SelectedProfileElementChanged; event EventHandler SelectedProfileElementChanged;
event EventHandler SelectedProfileElementUpdated; event EventHandler SelectedProfileElementUpdated;
event EventHandler SelectedLayerElementChanged;
} }
} }

View File

@ -1,6 +1,7 @@
using System; using System;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.Abstract; using Artemis.Core.Models.Profile.Abstract;
using Artemis.Core.Plugins.LayerElement;
using Artemis.Core.Services.Storage.Interfaces; using Artemis.Core.Services.Storage.Interfaces;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
@ -17,6 +18,7 @@ namespace Artemis.UI.Services
public Profile SelectedProfile { get; private set; } public Profile SelectedProfile { get; private set; }
public ProfileElement SelectedProfileElement { get; private set; } public ProfileElement SelectedProfileElement { get; private set; }
public LayerElement SelectedLayerElement { get; private set; }
public void ChangeSelectedProfile(Profile profile) public void ChangeSelectedProfile(Profile profile)
{ {
@ -42,10 +44,17 @@ namespace Artemis.UI.Services
OnSelectedProfileElementUpdated(); OnSelectedProfileElementUpdated();
} }
public void ChangeSelectedLayerElement(LayerElement layerElement)
{
SelectedLayerElement = layerElement;
OnSelectedLayerElementChanged();
}
public event EventHandler SelectedProfileChanged; public event EventHandler SelectedProfileChanged;
public event EventHandler SelectedProfileUpdated; public event EventHandler SelectedProfileUpdated;
public event EventHandler SelectedProfileElementChanged; public event EventHandler SelectedProfileElementChanged;
public event EventHandler SelectedProfileElementUpdated; public event EventHandler SelectedProfileElementUpdated;
public event EventHandler SelectedLayerElementChanged;
protected virtual void OnSelectedProfileElementUpdated() protected virtual void OnSelectedProfileElementUpdated()
{ {
@ -66,5 +75,10 @@ namespace Artemis.UI.Services
{ {
SelectedProfileChanged?.Invoke(this, EventArgs.Empty); SelectedProfileChanged?.Invoke(this, EventArgs.Empty);
} }
protected virtual void OnSelectedLayerElementChanged()
{
SelectedLayerElementChanged?.Invoke(this, EventArgs.Empty);
}
} }
} }

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Castle.Core" version="4.4.0" targetFramework="net461" /> <package id="Castle.Core" version="4.4.0" targetFramework="net461" />
<package id="ControlzEx" version="3.0.2.4" targetFramework="net472" /> <package id="ControlzEx" version="3.0.2.4" targetFramework="net472" />

View File

@ -19,7 +19,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{E830
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis.Plugins.Modules.General", "Artemis.Plugins.Modules.General\Artemis.Plugins.Modules.General.csproj", "{E592F239-FAA0-4840-9C85-46E5867D06D5}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis.Plugins.Modules.General", "Artemis.Plugins.Modules.General\Artemis.Plugins.Modules.General.csproj", "{E592F239-FAA0-4840-9C85-46E5867D06D5}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis.Plugins.LayerTypes.Brush", "Artemis.Plugins.LayerTypes.Brush\Artemis.Plugins.LayerTypes.Brush.csproj", "{0F288A66-6EB0-4589-8595-E33A3A3EAEA2}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis.Plugins.LayerElements.Brush", "Artemis.Plugins.LayerTypes.Brush\Artemis.Plugins.LayerElements.Brush.csproj", "{0F288A66-6EB0-4589-8595-E33A3A3EAEA2}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis.Plugins.Devices.Corsair", "Artemis.Plugins.Devices.Corsair\Artemis.Plugins.Devices.Corsair.csproj", "{A779B2F8-C253-4C4B-8634-6EB8F594E96D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis.Plugins.Devices.Corsair", "Artemis.Plugins.Devices.Corsair\Artemis.Plugins.Devices.Corsair.csproj", "{A779B2F8-C253-4C4B-8634-6EB8F594E96D}"
EndProject EndProject