mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added layer shapes, editor is still WIP
This commit is contained in:
parent
8ba43ecec1
commit
580db3185e
@ -166,6 +166,11 @@
|
||||
<Compile Include="Extensions\TypeExtensions.cs" />
|
||||
<Compile Include="JsonConverters\SKColorConverter.cs" />
|
||||
<Compile Include="Models\DataModelDescription.cs" />
|
||||
<Compile Include="Models\Profile\LayerShapes\Ellipse.cs" />
|
||||
<Compile Include="Models\Profile\LayerShapes\Fill.cs" />
|
||||
<Compile Include="Models\Profile\LayerShapes\Polygon.cs" />
|
||||
<Compile Include="Models\Profile\LayerShapes\Rectangle.cs" />
|
||||
<Compile Include="Models\Profile\LayerShapes\LayerShape.cs" />
|
||||
<Compile Include="Models\Surface\ArtemisLed.cs" />
|
||||
<Compile Include="Models\Surface\ArtemisSurface.cs" />
|
||||
<Compile Include="Models\Surface\ArtemisDevice.cs" />
|
||||
@ -180,16 +185,16 @@
|
||||
<Compile Include="Plugins\Abstract\DeviceProvider.cs" />
|
||||
<Compile Include="Plugins\Abstract\Module.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\LayerBrush\LayerBrush.cs" />
|
||||
<Compile Include="Plugins\LayerBrush\LayerBrushDescriptor.cs" />
|
||||
<Compile Include="Plugins\LayerBrush\LayerBrushProvider.cs" />
|
||||
<Compile Include="Plugins\LayerBrush\LayerBrushSettings.cs" />
|
||||
<Compile Include="Plugins\LayerBrush\LayerBrushViewModel.cs" />
|
||||
<Compile Include="Plugins\Models\PluginInfo.cs" />
|
||||
<Compile Include="Plugins\Models\PluginSetting.cs" />
|
||||
<Compile Include="Plugins\Models\PluginSettings.cs" />
|
||||
<Compile Include="Models\Profile\Folder.cs" />
|
||||
<Compile Include="Models\Profile\Abstract\ProfileElement.cs" />
|
||||
<Compile Include="Models\Profile\ProfileElement.cs" />
|
||||
<Compile Include="Models\Profile\Layer.cs" />
|
||||
<Compile Include="Models\Profile\Profile.cs" />
|
||||
<Compile Include="Ninject\CoreModule.cs" />
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Models.Profile.Abstract;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using SkiaSharp;
|
||||
@ -92,7 +91,7 @@ namespace Artemis.Core.Models.Profile
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Folder - {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
|
||||
return $"[Folder] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,9 +3,9 @@ using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Extensions;
|
||||
using Artemis.Core.Models.Profile.Abstract;
|
||||
using Artemis.Core.Models.Profile.LayerShapes;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Newtonsoft.Json;
|
||||
using SkiaSharp;
|
||||
@ -14,7 +14,7 @@ namespace Artemis.Core.Models.Profile
|
||||
{
|
||||
public sealed class Layer : ProfileElement
|
||||
{
|
||||
private readonly List<LayerElement> _layerElements;
|
||||
private LayerShape _layerShape;
|
||||
private List<ArtemisLed> _leds;
|
||||
|
||||
public Layer(Profile profile, ProfileElement parent, string name)
|
||||
@ -27,7 +27,6 @@ namespace Artemis.Core.Models.Profile
|
||||
Name = name;
|
||||
|
||||
_leds = new List<ArtemisLed>();
|
||||
_layerElements = new List<LayerElement>();
|
||||
}
|
||||
|
||||
internal Layer(Profile profile, ProfileElement parent, LayerEntity layerEntity)
|
||||
@ -40,61 +39,98 @@ namespace Artemis.Core.Models.Profile
|
||||
Name = layerEntity.Name;
|
||||
Order = layerEntity.Order;
|
||||
|
||||
switch (layerEntity.ShapeEntity?.Type)
|
||||
{
|
||||
case ShapeEntityType.Ellipse:
|
||||
LayerShape = new Ellipse(this, layerEntity.ShapeEntity);
|
||||
break;
|
||||
case ShapeEntityType.Fill:
|
||||
LayerShape = new Fill(this, layerEntity.ShapeEntity);
|
||||
break;
|
||||
case ShapeEntityType.Polygon:
|
||||
LayerShape = new Polygon(this, layerEntity.ShapeEntity);
|
||||
break;
|
||||
case ShapeEntityType.Rectangle:
|
||||
LayerShape = new Rectangle(this, layerEntity.ShapeEntity);
|
||||
break;
|
||||
case null:
|
||||
LayerShape = null;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
_leds = new List<ArtemisLed>();
|
||||
_layerElements = new List<LayerElement>();
|
||||
}
|
||||
|
||||
internal LayerEntity LayerEntity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A collection of all the LEDs this layer is assigned to.
|
||||
/// </summary>
|
||||
public ReadOnlyCollection<ArtemisLed> Leds => _leds.AsReadOnly();
|
||||
public ReadOnlyCollection<LayerElement> LayerElements => _layerElements.AsReadOnly();
|
||||
|
||||
public SKRect RenderRectangle { get; set; }
|
||||
public SKRect AbsoluteRenderRectangle { get; set; }
|
||||
public SKPath RenderPath { get; set; }
|
||||
/// <summary>
|
||||
/// A rectangle relative to the surface that contains all the LEDs in this layer.
|
||||
/// <para>For rendering, use the RenderRectangle on <see cref="LayerShape" />.</para>
|
||||
/// </summary>
|
||||
public SKRect Rectangle { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// A zero-based absolute rectangle that contains all the LEDs in this layer.
|
||||
/// <para>For rendering, use the RenderRectangle on <see cref="LayerShape" />.</para>
|
||||
/// </summary>
|
||||
public SKRect AbsoluteRectangle { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// A path containing all the LEDs this layer is applied to.
|
||||
/// <para>For rendering, use the RenderPath on <see cref="LayerShape" />.</para>
|
||||
/// </summary>
|
||||
public SKPath Path { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Defines the shape that is rendered by the <see cref="LayerBrush"/>.
|
||||
/// </summary>
|
||||
public LayerShape LayerShape
|
||||
{
|
||||
get => _layerShape;
|
||||
set
|
||||
{
|
||||
_layerShape = value;
|
||||
_layerShape.CalculateRenderProperties();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The brush that will fill the <see cref="LayerShape"/>.
|
||||
/// </summary>
|
||||
public LayerBrush LayerBrush { get; internal set; }
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
lock (_layerElements)
|
||||
{
|
||||
foreach (var layerElement in LayerElements)
|
||||
layerElement.Update(deltaTime);
|
||||
}
|
||||
LayerBrush?.Update(deltaTime);
|
||||
}
|
||||
|
||||
public override void Render(double deltaTime, SKCanvas canvas)
|
||||
{
|
||||
if (RenderPath == null)
|
||||
if (Path == null)
|
||||
return;
|
||||
|
||||
lock (_layerElements)
|
||||
{
|
||||
canvas.Save();
|
||||
using (var framePath = new SKPath(RenderPath))
|
||||
{
|
||||
canvas.ClipPath(framePath);
|
||||
|
||||
foreach (var layerElement in LayerElements)
|
||||
layerElement.RenderPreProcess(framePath, canvas);
|
||||
foreach (var layerElement in LayerElements)
|
||||
layerElement.Render(framePath, canvas);
|
||||
foreach (var layerElement in LayerElements)
|
||||
layerElement.RenderPostProcess(framePath, canvas);
|
||||
}
|
||||
canvas.Restore();
|
||||
}
|
||||
canvas.Save();
|
||||
LayerBrush?.Render(canvas);
|
||||
canvas.Restore();
|
||||
}
|
||||
|
||||
internal override void ApplyToEntity()
|
||||
{
|
||||
// Properties
|
||||
LayerEntity.Id = EntityId;
|
||||
LayerEntity.ParentId = Parent?.EntityId ?? new Guid();
|
||||
|
||||
LayerEntity.Order = Order;
|
||||
LayerEntity.Name = Name;
|
||||
|
||||
LayerEntity.ProfileId = Profile.EntityId;
|
||||
|
||||
// LEDs
|
||||
LayerEntity.Leds.Clear();
|
||||
foreach (var artemisLed in Leds)
|
||||
{
|
||||
@ -106,62 +142,60 @@ namespace Artemis.Core.Models.Profile
|
||||
LayerEntity.Leds.Add(ledEntity);
|
||||
}
|
||||
|
||||
// Conditions TODO
|
||||
LayerEntity.Condition.Clear();
|
||||
|
||||
LayerEntity.Elements.Clear();
|
||||
foreach (var layerElement in LayerElements)
|
||||
// Brush
|
||||
LayerEntity.BrushEntity = new BrushEntity
|
||||
{
|
||||
var layerElementEntity = new LayerElementEntity
|
||||
{
|
||||
Id = layerElement.Guid,
|
||||
PluginGuid = layerElement.Descriptor.LayerElementProvider.PluginInfo.Guid,
|
||||
LayerElementType = layerElement.GetType().Name,
|
||||
Configuration = JsonConvert.SerializeObject(layerElement.Settings)
|
||||
};
|
||||
LayerEntity.Elements.Add(layerElementEntity);
|
||||
}
|
||||
BrushPluginGuid = LayerBrush.Descriptor.LayerBrushProvider.PluginInfo.Guid,
|
||||
BrushType = LayerBrush.GetType().Name,
|
||||
Configuration = JsonConvert.SerializeObject(LayerBrush.Settings)
|
||||
};
|
||||
|
||||
// Shape
|
||||
LayerShape.ApplyToEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new <see cref="ArtemisLed" /> to the layer and updates the render properties.
|
||||
/// </summary>
|
||||
/// <param name="led">The LED to add</param>
|
||||
public void AddLed(ArtemisLed led)
|
||||
{
|
||||
_leds.Add(led);
|
||||
CalculateRenderProperties();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a collection of new <see cref="ArtemisLed" />s to the layer and updates the render properties.
|
||||
/// </summary>
|
||||
/// <param name="leds">The LEDs to add</param>
|
||||
public void AddLeds(IEnumerable<ArtemisLed> leds)
|
||||
{
|
||||
_leds.AddRange(leds);
|
||||
CalculateRenderProperties();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a <see cref="ArtemisLed" /> from the layer and updates the render properties.
|
||||
/// </summary>
|
||||
/// <param name="led">The LED to remove</param>
|
||||
public void RemoveLed(ArtemisLed led)
|
||||
{
|
||||
_leds.Remove(led);
|
||||
CalculateRenderProperties();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes all <see cref="ArtemisLed" />s from the layer and updates the render properties.
|
||||
/// </summary>
|
||||
public void ClearLeds()
|
||||
{
|
||||
_leds.Clear();
|
||||
CalculateRenderProperties();
|
||||
}
|
||||
|
||||
internal void AddLayerElement(LayerElement layerElement)
|
||||
{
|
||||
lock (_layerElements)
|
||||
{
|
||||
_layerElements.Add(layerElement);
|
||||
}
|
||||
}
|
||||
|
||||
internal void RemoveLayerElement(LayerElement layerElement)
|
||||
{
|
||||
lock (_layerElements)
|
||||
{
|
||||
_layerElements.Remove(layerElement);
|
||||
}
|
||||
}
|
||||
|
||||
internal void PopulateLeds(ArtemisSurface surface)
|
||||
{
|
||||
var leds = new List<ArtemisLed>();
|
||||
@ -191,20 +225,20 @@ namespace Artemis.Core.Models.Profile
|
||||
var maxX = Leds.Max(l => l.AbsoluteRenderRectangle.Right);
|
||||
var maxY = Leds.Max(l => l.AbsoluteRenderRectangle.Bottom);
|
||||
|
||||
RenderRectangle = SKRect.Create(minX, minY, maxX - minX, maxY - minY);
|
||||
AbsoluteRenderRectangle = SKRect.Create(0, 0, maxX - minX, maxY - minY);
|
||||
Rectangle = SKRect.Create(minX, minY, maxX - minX, maxY - minY);
|
||||
AbsoluteRectangle = SKRect.Create(0, 0, maxX - minX, maxY - minY);
|
||||
|
||||
var path = new SKPath {FillType = SKPathFillType.Winding};
|
||||
foreach (var artemisLed in Leds)
|
||||
path.AddRect(artemisLed.AbsoluteRenderRectangle);
|
||||
|
||||
RenderPath = path;
|
||||
Path = path;
|
||||
OnRenderPropertiesUpdated();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Layer - {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
|
||||
return $"[Layer] {nameof(Name)}: {Name}, {nameof(Order)}: {Order}";
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
35
src/Artemis.Core/Models/Profile/LayerShapes/Ellipse.cs
Normal file
35
src/Artemis.Core/Models/Profile/LayerShapes/Ellipse.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
{
|
||||
public class Ellipse : LayerShape
|
||||
{
|
||||
public Ellipse(Layer layer) : base(layer)
|
||||
{
|
||||
}
|
||||
|
||||
internal Ellipse(Layer layer, ShapeEntity shapeEntity) : base(layer, shapeEntity)
|
||||
{
|
||||
}
|
||||
|
||||
public override void CalculateRenderProperties()
|
||||
{
|
||||
var width = Layer.AbsoluteRectangle.Width;
|
||||
var height = Layer.AbsoluteRectangle.Height;
|
||||
var rect = SKRect.Create(Position.X * width, Position.Y * height, Size.Width * width, Size.Height * height);
|
||||
|
||||
var path = new SKPath();
|
||||
path.AddOval(rect);
|
||||
|
||||
RenderPath = path;
|
||||
RenderRectangle = path.GetRect();
|
||||
}
|
||||
|
||||
public override void ApplyToEntity()
|
||||
{
|
||||
base.ApplyToEntity();
|
||||
Layer.LayerEntity.ShapeEntity.Type = ShapeEntityType.Ellipse;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
src/Artemis.Core/Models/Profile/LayerShapes/Fill.cs
Normal file
26
src/Artemis.Core/Models/Profile/LayerShapes/Fill.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
|
||||
namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
{
|
||||
public class Fill : LayerShape
|
||||
{
|
||||
public Fill(Layer layer) : base(layer)
|
||||
{
|
||||
}
|
||||
internal Fill(Layer layer, ShapeEntity shapeEntity) : base(layer, shapeEntity)
|
||||
{
|
||||
}
|
||||
|
||||
public override void CalculateRenderProperties()
|
||||
{
|
||||
RenderPath = Layer.Path;
|
||||
RenderRectangle = Layer.Path.GetRect();
|
||||
}
|
||||
|
||||
public override void ApplyToEntity()
|
||||
{
|
||||
base.ApplyToEntity();
|
||||
Layer.LayerEntity.ShapeEntity.Type = ShapeEntityType.Fill;
|
||||
}
|
||||
}
|
||||
}
|
||||
74
src/Artemis.Core/Models/Profile/LayerShapes/LayerShape.cs
Normal file
74
src/Artemis.Core/Models/Profile/LayerShapes/LayerShape.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
{
|
||||
public abstract class LayerShape
|
||||
{
|
||||
protected LayerShape(Layer layer)
|
||||
{
|
||||
Layer = layer;
|
||||
|
||||
Layer.RenderPropertiesUpdated += LayerOnRenderPropertiesUpdated;
|
||||
}
|
||||
|
||||
protected LayerShape(Layer layer, ShapeEntity shapeEntity)
|
||||
{
|
||||
Layer = layer;
|
||||
Anchor = new SKPoint(shapeEntity.Anchor?.X ?? 0, shapeEntity.Anchor?.Y ?? 0);
|
||||
Position = new SKPoint(shapeEntity.Position?.X ?? 0, shapeEntity.Position?.Y ?? 0);
|
||||
Size = new SKSize(shapeEntity.Width, shapeEntity.Height);
|
||||
|
||||
Layer.RenderPropertiesUpdated += LayerOnRenderPropertiesUpdated;
|
||||
}
|
||||
|
||||
private void LayerOnRenderPropertiesUpdated(object sender, EventArgs e)
|
||||
{
|
||||
CalculateRenderProperties();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The layer this shape is attached to
|
||||
/// </summary>
|
||||
public Layer Layer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// At which position the shape is attached to the layer
|
||||
/// </summary>
|
||||
public SKPoint Anchor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The position of the shape
|
||||
/// </summary>
|
||||
public SKPoint Position { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The size of the shape
|
||||
/// </summary>
|
||||
public SKSize Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A render rectangle relative to the layer
|
||||
/// </summary>
|
||||
public SKRect RenderRectangle { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// A path relative to the layer
|
||||
/// </summary>
|
||||
public SKPath RenderPath { get; protected set; }
|
||||
|
||||
public abstract void CalculateRenderProperties();
|
||||
|
||||
public virtual void ApplyToEntity()
|
||||
{
|
||||
Layer.LayerEntity.ShapeEntity = new ShapeEntity
|
||||
{
|
||||
Anchor = new ShapePointEntity { X = Anchor.X, Y = Anchor.Y },
|
||||
Position = new ShapePointEntity { X = Position.X, Y = Position.Y },
|
||||
Width = Size.Width,
|
||||
Height = Size.Height
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
45
src/Artemis.Core/Models/Profile/LayerShapes/Polygon.cs
Normal file
45
src/Artemis.Core/Models/Profile/LayerShapes/Polygon.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
{
|
||||
public class Polygon : LayerShape
|
||||
{
|
||||
|
||||
public Polygon(Layer layer) : base(layer)
|
||||
{
|
||||
}
|
||||
|
||||
internal Polygon(Layer layer, ShapeEntity shapeEntity) : base(layer, shapeEntity)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The points of this polygon
|
||||
/// </summary>
|
||||
public List<SKPoint> Points { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The points of this polygon where they need to be rendered inside the layer
|
||||
/// </summary>
|
||||
public List<SKPoint> RenderPoints => Points.Select(p => new SKPoint(p.X * Layer.AbsoluteRectangle.Width, p.Y * Layer.AbsoluteRectangle.Height)).ToList();
|
||||
|
||||
public override void CalculateRenderProperties()
|
||||
{
|
||||
var path = new SKPath();
|
||||
path.AddPoly(RenderPoints.ToArray());
|
||||
|
||||
RenderPath = path;
|
||||
RenderRectangle = path.GetRect();
|
||||
}
|
||||
|
||||
public override void ApplyToEntity()
|
||||
{
|
||||
base.ApplyToEntity();
|
||||
Layer.LayerEntity.ShapeEntity.Type = ShapeEntityType.Polygon;
|
||||
Layer.LayerEntity.ShapeEntity.Points = Points.Select(p => new ShapePointEntity { X = p.X, Y = p.Y }).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
34
src/Artemis.Core/Models/Profile/LayerShapes/Rectangle.cs
Normal file
34
src/Artemis.Core/Models/Profile/LayerShapes/Rectangle.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Models.Profile.LayerShapes
|
||||
{
|
||||
public class Rectangle : LayerShape
|
||||
{
|
||||
public Rectangle(Layer layer) : base(layer)
|
||||
{
|
||||
}
|
||||
|
||||
internal Rectangle(Layer layer, ShapeEntity shapeEntity) : base(layer, shapeEntity)
|
||||
{
|
||||
}
|
||||
|
||||
public override void CalculateRenderProperties()
|
||||
{
|
||||
var width = Layer.AbsoluteRectangle.Width;
|
||||
var height = Layer.AbsoluteRectangle.Height;
|
||||
var rect = SKRect.Create(Position.X * width, Position.Y * height, Size.Width * width, Size.Height * height);
|
||||
var path = new SKPath();
|
||||
path.AddRect(rect);
|
||||
|
||||
RenderPath = path;
|
||||
RenderRectangle = path.GetRect();
|
||||
}
|
||||
|
||||
public override void ApplyToEntity()
|
||||
{
|
||||
base.ApplyToEntity();
|
||||
Layer.LayerEntity.ShapeEntity.Type = ShapeEntityType.Rectangle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Exceptions;
|
||||
using Artemis.Core.Models.Profile.Abstract;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
@ -109,17 +108,17 @@ namespace Artemis.Core.Models.Profile
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{nameof(Order)}: {Order}, {nameof(Name)}: {Name}, {nameof(PluginInfo)}: {PluginInfo}";
|
||||
}
|
||||
|
||||
internal void PopulateLeds(ArtemisSurface surface)
|
||||
{
|
||||
foreach (var layer in GetAllLayers())
|
||||
layer.PopulateLeds(surface);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[Profile] {nameof(Name)}: {Name}, {nameof(IsActivated)}: {IsActivated}, {nameof(PluginInfo)}: {PluginInfo}";
|
||||
}
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -2,11 +2,10 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using SkiaSharp;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.Core.Models.Profile.Abstract
|
||||
namespace Artemis.Core.Models.Profile
|
||||
{
|
||||
public abstract class ProfileElement : PropertyChangedBase
|
||||
{
|
||||
@ -132,5 +131,7 @@ namespace Artemis.Core.Models.Profile.Abstract
|
||||
child.Parent = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
48
src/Artemis.Core/Plugins/LayerBrush/LayerBrush.cs
Normal file
48
src/Artemis.Core/Plugins/LayerBrush/LayerBrush.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
public abstract class LayerBrush : IDisposable
|
||||
{
|
||||
protected LayerBrush(Layer layer, LayerBrushSettings settings, LayerBrushDescriptor descriptor)
|
||||
{
|
||||
Layer = layer;
|
||||
Settings = settings;
|
||||
Descriptor = descriptor;
|
||||
}
|
||||
|
||||
public Layer Layer { get; }
|
||||
public LayerBrushSettings Settings { get; }
|
||||
public LayerBrushDescriptor Descriptor { get; }
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called by the profile editor to populate the brush properties panel
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract LayerBrushViewModel GetViewModel();
|
||||
|
||||
/// <summary>
|
||||
/// Called before rendering every frame, write your update logic here
|
||||
/// </summary>
|
||||
/// <param name="deltaTime"></param>
|
||||
public virtual void Update(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The main method of rendering anything to the layer. The provided <see cref="SKCanvas" /> is specific to the layer
|
||||
/// and matches it's width and height.
|
||||
/// <para>Called during rendering, in the order configured on the layer</para>
|
||||
/// </summary>
|
||||
/// <param name="canvas">The layer canvas</param>
|
||||
public virtual void Render(SKCanvas canvas)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
22
src/Artemis.Core/Plugins/LayerBrush/LayerBrushDescriptor.cs
Normal file
22
src/Artemis.Core/Plugins/LayerBrush/LayerBrushDescriptor.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
public class LayerBrushDescriptor
|
||||
{
|
||||
internal LayerBrushDescriptor(string displayName, string description, string icon, Type layerBrushType, LayerBrushProvider layerBrushProvider)
|
||||
{
|
||||
DisplayName = displayName;
|
||||
Description = description;
|
||||
Icon = icon;
|
||||
LayerBrushType = layerBrushType;
|
||||
LayerBrushProvider = layerBrushProvider;
|
||||
}
|
||||
|
||||
public string DisplayName { get; }
|
||||
public string Description { get; }
|
||||
public string Icon { get; }
|
||||
public Type LayerBrushType { get; }
|
||||
public LayerBrushProvider LayerBrushProvider { get; }
|
||||
}
|
||||
}
|
||||
28
src/Artemis.Core/Plugins/LayerBrush/LayerBrushProvider.cs
Normal file
28
src/Artemis.Core/Plugins/LayerBrush/LayerBrushProvider.cs
Normal 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.LayerBrush
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Allows you to create one or more <see cref="LayerBrush" />s usable by profile layers.
|
||||
/// </summary>
|
||||
public abstract class LayerBrushProvider : Plugin
|
||||
{
|
||||
private readonly List<LayerBrushDescriptor> _layerBrushDescriptors;
|
||||
|
||||
protected LayerBrushProvider(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
{
|
||||
_layerBrushDescriptors = new List<LayerBrushDescriptor>();
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<LayerBrushDescriptor> LayerBrushDescriptors => _layerBrushDescriptors.AsReadOnly();
|
||||
|
||||
protected void AddLayerBrushDescriptor<T>(string displayName, string description, string icon) where T : LayerBrush
|
||||
{
|
||||
_layerBrushDescriptors.Add(new LayerBrushDescriptor(displayName, description, icon, typeof(T), this));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerElement
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
public abstract class LayerElementSettings : PropertyChangedBase
|
||||
public abstract class LayerBrushSettings : PropertyChangedBase
|
||||
{
|
||||
private Action<Action> _propertyChangedDispatcher = Execute.DefaultPropertyChangedDispatcher;
|
||||
|
||||
14
src/Artemis.Core/Plugins/LayerBrush/LayerBrushViewModel.cs
Normal file
14
src/Artemis.Core/Plugins/LayerBrush/LayerBrushViewModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerBrush
|
||||
{
|
||||
public abstract class LayerBrushViewModel : PropertyChangedBase
|
||||
{
|
||||
protected LayerBrushViewModel(LayerBrush brush)
|
||||
{
|
||||
Brush = brush;
|
||||
}
|
||||
|
||||
public LayerBrush Brush { get; }
|
||||
}
|
||||
}
|
||||
@ -1,75 +0,0 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerElement
|
||||
{
|
||||
public abstract class LayerElement : IDisposable
|
||||
{
|
||||
protected LayerElement(Layer layer, Guid guid, LayerElementSettings settings, LayerElementDescriptor descriptor)
|
||||
{
|
||||
Layer = layer;
|
||||
Guid = guid;
|
||||
Settings = settings;
|
||||
Descriptor = descriptor;
|
||||
}
|
||||
|
||||
public Layer Layer { get; }
|
||||
public Guid Guid { get; }
|
||||
public LayerElementSettings Settings { get; }
|
||||
public LayerElementDescriptor Descriptor { get; }
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
/// <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 virtual void Update(double deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows you to perform rendering on the surface <see cref="SKCanvas" /> before any layer-clipping is applied
|
||||
/// <para>Called before rendering, in the order configured on the layer</para>
|
||||
/// </summary>
|
||||
/// <param name="framePath"></param>
|
||||
/// <param name="canvas">The entire surface canvas</param>
|
||||
public virtual void RenderPreProcess(SKPath framePath, SKCanvas canvas)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The main method of rendering anything to the layer. The provided <see cref="SKCanvas" /> is specific to the layer
|
||||
/// and matches it's width and height.
|
||||
/// <para>Called during rendering, in the order configured on the layer</para>
|
||||
/// </summary>
|
||||
/// <param name="framePath"></param>
|
||||
/// <param name="canvas">The layer canvas</param>
|
||||
public virtual void Render(SKPath framePath, SKCanvas canvas)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows you to modify the <see cref="SKShader" /> used to draw the layer's <see cref="SKBitmap" /> on the
|
||||
/// <see cref="SKCanvas" />.
|
||||
/// <para>Called after rendering, in the order configured on the layer.</para>
|
||||
/// </summary>
|
||||
/// <param name="framePath"></param>
|
||||
/// <param name="canvas"></param>
|
||||
/// <param name="bitmap">The bitmap created from the layer canvas</param>
|
||||
/// <param name="shader">The current shader used to draw the bitmap on the surface canvas</param>
|
||||
/// <returns>The resulting shader used to draw the bitmap on the surface canvas</returns>
|
||||
public virtual void RenderPostProcess(SKPath framePath, SKCanvas canvas)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,22 +0,0 @@
|
||||
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; }
|
||||
}
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.Core.Plugins.LayerElement
|
||||
{
|
||||
public abstract class LayerElementViewModel : PropertyChangedBase
|
||||
{
|
||||
protected LayerElementViewModel(LayerElement layerElement)
|
||||
{
|
||||
LayerElement = layerElement;
|
||||
}
|
||||
|
||||
public LayerElement LayerElement { get; }
|
||||
}
|
||||
}
|
||||
@ -1,21 +1,18 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
|
||||
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" />.
|
||||
/// Instantiates and adds the <see cref="LayerBrush" /> described by the provided
|
||||
/// <see cref="LayerBrushDescriptor" /> 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>
|
||||
/// <param name="brushDescriptor">The descriptor of the new layer brush</param>
|
||||
/// <param name="settings">JSON settings to be deserialized and injected into the layer brush</param>
|
||||
/// <returns></returns>
|
||||
LayerElement InstantiateLayerElement(Layer layer, LayerElementDescriptor layerElementDescriptor, string settings = null, Guid? guid = null);
|
||||
|
||||
void RemoveLayerElement(Layer layer, LayerElement layerElement);
|
||||
LayerBrush InstantiateLayerBrush(Layer layer, LayerBrushDescriptor brushDescriptor, string settings = null);
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.Exceptions;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
using Ninject;
|
||||
@ -23,16 +23,13 @@ namespace Artemis.Core.Services
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public LayerElement InstantiateLayerElement(Layer layer, LayerElementDescriptor layerElementDescriptor, string settings, Guid? guid)
|
||||
public LayerBrush InstantiateLayerBrush(Layer layer, LayerBrushDescriptor brushDescriptor, string settings)
|
||||
{
|
||||
if (guid == null)
|
||||
guid = Guid.NewGuid();
|
||||
|
||||
// Determine the settings type declared by the layer element
|
||||
object settingsInstance = null;
|
||||
var properties = layerElementDescriptor.LayerElementType.GetProperties();
|
||||
var properties = brushDescriptor.LayerBrushType.GetProperties();
|
||||
var settingsType = properties.FirstOrDefault(p => p.Name == "Settings" &&
|
||||
p.DeclaringType == layerElementDescriptor.LayerElementType)?.PropertyType;
|
||||
p.DeclaringType == brushDescriptor.LayerBrushType)?.PropertyType;
|
||||
|
||||
// Deserialize the settings if provided, check for null in JSON as well
|
||||
if (settings != null && settings != "null")
|
||||
@ -41,8 +38,8 @@ namespace Artemis.Core.Services
|
||||
if (settingsType == null)
|
||||
{
|
||||
throw new ArtemisPluginException(
|
||||
layerElementDescriptor.LayerElementProvider.PluginInfo,
|
||||
$"Settings where provided but layer element of type {layerElementDescriptor.LayerElementType.Name} has no Settings property."
|
||||
brushDescriptor.LayerBrushProvider.PluginInfo,
|
||||
$"Settings where provided but layer element of type {brushDescriptor.LayerBrushType.Name} has no Settings property."
|
||||
);
|
||||
}
|
||||
|
||||
@ -53,8 +50,8 @@ namespace Artemis.Core.Services
|
||||
catch (JsonSerializationException e)
|
||||
{
|
||||
_logger.Warning(e, "Failed to deserialize settings for layer type {type}, resetting element settings - Plugin info: {pluginInfo}",
|
||||
layerElementDescriptor.LayerElementType.Name,
|
||||
layerElementDescriptor.LayerElementProvider.PluginInfo);
|
||||
brushDescriptor.LayerBrushType.Name,
|
||||
brushDescriptor.LayerBrushProvider.PluginInfo);
|
||||
|
||||
settingsInstance = Activator.CreateInstance(settingsType);
|
||||
}
|
||||
@ -68,20 +65,20 @@ namespace Artemis.Core.Services
|
||||
var arguments = new IParameter[]
|
||||
{
|
||||
new ConstructorArgument("layer", layer),
|
||||
new ConstructorArgument("guid", guid.Value),
|
||||
new ConstructorArgument("settings", settingsInstance),
|
||||
new ConstructorArgument("descriptor", layerElementDescriptor)
|
||||
new ConstructorArgument("descriptor", brushDescriptor)
|
||||
};
|
||||
var layerElement = (LayerElement) _kernel.Get(layerElementDescriptor.LayerElementType, arguments);
|
||||
layer.AddLayerElement(layerElement);
|
||||
var layerElement = (LayerBrush) _kernel.Get(brushDescriptor.LayerBrushType, arguments);
|
||||
layer.LayerBrush = (layerElement);
|
||||
|
||||
return layerElement;
|
||||
}
|
||||
|
||||
public void RemoveLayerElement(Layer layer, LayerElement layerElement)
|
||||
public void RemoveLayerBrush(Layer layer, LayerBrush layerElement)
|
||||
{
|
||||
layer.RemoveLayerElement(layerElement);
|
||||
layerElement.Dispose();
|
||||
var brush = layer.LayerBrush;
|
||||
layer.LayerBrush = null;
|
||||
brush.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@ using Artemis.Core.Events;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
@ -16,10 +16,10 @@ namespace Artemis.Core.Services.Storage
|
||||
/// </summary>
|
||||
public class ProfileService : IProfileService
|
||||
{
|
||||
private readonly ILayerService _layerService;
|
||||
private readonly IPluginService _pluginService;
|
||||
private readonly IProfileRepository _profileRepository;
|
||||
private readonly ISurfaceService _surfaceService;
|
||||
private readonly ILayerService _layerService;
|
||||
|
||||
internal ProfileService(IPluginService pluginService, ISurfaceService surfaceService, ILayerService layerService, IProfileRepository profileRepository)
|
||||
{
|
||||
@ -78,7 +78,7 @@ namespace Artemis.Core.Services.Storage
|
||||
{
|
||||
module.ChangeActiveProfile(profile, _surfaceService.ActiveSurface);
|
||||
if (profile != null)
|
||||
InstantiateProfileLayerElements(profile);
|
||||
InstantiateProfileLayerBrushes(profile);
|
||||
}
|
||||
|
||||
public void DeleteProfile(Profile profile)
|
||||
@ -102,27 +102,22 @@ namespace Artemis.Core.Services.Storage
|
||||
|
||||
_profileRepository.Save(profile.ProfileEntity);
|
||||
}
|
||||
private void InstantiateProfileLayerElements(Profile profile)
|
||||
|
||||
private void InstantiateProfileLayerBrushes(Profile profile)
|
||||
{
|
||||
var layerElementProviders = _pluginService.GetPluginsOfType<LayerElementProvider>();
|
||||
var descriptors = layerElementProviders.SelectMany(l => l.LayerElementDescriptors).ToList();
|
||||
var layerBrushProviders = _pluginService.GetPluginsOfType<LayerBrushProvider>();
|
||||
var descriptors = layerBrushProviders.SelectMany(l => l.LayerBrushDescriptors).ToList();
|
||||
|
||||
foreach (var layer in profile.GetAllLayers())
|
||||
// Only instantiate brushes for layers without an existing brush instance
|
||||
foreach (var layer in profile.GetAllLayers().Where(l => l.LayerBrush == null && l.LayerEntity.BrushEntity != null))
|
||||
{
|
||||
foreach (var elementEntity in layer.LayerEntity.Elements)
|
||||
{
|
||||
// Skip already instantiated layer elements
|
||||
if (layer.LayerElements.Any(e => e.Guid == elementEntity.Id))
|
||||
continue;
|
||||
// Get a matching descriptor
|
||||
var descriptor = descriptors.FirstOrDefault(d => d.LayerBrushProvider.PluginInfo.Guid == layer.LayerEntity.BrushEntity.BrushPluginGuid &&
|
||||
d.LayerBrushType.Name == layer.LayerEntity.BrushEntity.BrushType);
|
||||
|
||||
// Get a matching descriptor
|
||||
var descriptor = descriptors.FirstOrDefault(d => d.LayerElementProvider.PluginInfo.Guid == elementEntity.PluginGuid &&
|
||||
d.LayerElementType.Name == elementEntity.LayerElementType);
|
||||
|
||||
// If a descriptor that matches if found, instantiate it with the GUID of the element entity
|
||||
if (descriptor != null)
|
||||
_layerService.InstantiateLayerElement(layer, descriptor, elementEntity.Configuration, elementEntity.Id);
|
||||
}
|
||||
// If a descriptor that matches if found, instantiate it with the GUID of the element entity
|
||||
if (descriptor != null)
|
||||
_layerService.InstantiateLayerBrush(layer, descriptor, layer.LayerEntity.BrushEntity.Configuration);
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,11 +128,11 @@ namespace Artemis.Core.Services.Storage
|
||||
profileModule.ActiveProfile.PopulateLeds(surface);
|
||||
}
|
||||
|
||||
private void ActiveProfilesInstantiateProfileLayerElements()
|
||||
private void ActiveProfilesInstantiateProfileLayerBrushes()
|
||||
{
|
||||
var profileModules = _pluginService.GetPluginsOfType<ProfileModule>();
|
||||
foreach (var profileModule in profileModules.Where(p => p.ActiveProfile != null).ToList())
|
||||
InstantiateProfileLayerElements(profileModule.ActiveProfile);
|
||||
InstantiateProfileLayerBrushes(profileModule.ActiveProfile);
|
||||
}
|
||||
|
||||
#region Event handlers
|
||||
@ -155,8 +150,8 @@ namespace Artemis.Core.Services.Storage
|
||||
|
||||
private void OnPluginLoaded(object sender, PluginEventArgs e)
|
||||
{
|
||||
if (e.PluginInfo.Instance is LayerElementProvider)
|
||||
ActiveProfilesInstantiateProfileLayerElements();
|
||||
if (e.PluginInfo.Instance is LayerBrushProvider)
|
||||
ActiveProfilesInstantiateProfileLayerBrushes();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -3,9 +3,9 @@ using Artemis.Core.Plugins.Models;
|
||||
|
||||
namespace Artemis.Plugins.LayerElements.Animations
|
||||
{
|
||||
public class AnimationLayerElementProvider : LayerElementProvider
|
||||
public class AnimationBrushProvider : BrushProvider
|
||||
{
|
||||
public AnimationLayerElementProvider(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
public AnimationBrushProvider(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
{
|
||||
AddLayerElementDescriptor<SlideLayerElement>("Slide animation", "A sliding animation", "ArrowAll");
|
||||
AddLayerElementDescriptor<RotationLayerElement>("Rotation animation", "A rotation animation", "CropRotate");
|
||||
@ -59,7 +59,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AnimationLayerElementProvider.cs" />
|
||||
<Compile Include="AnimationBrushProvider.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RotationLayerElement.cs" />
|
||||
<Compile Include="SlideLayerElement.cs" />
|
||||
|
||||
@ -7,13 +7,13 @@ namespace Artemis.Plugins.LayerElements.Animations
|
||||
{
|
||||
public class RotationLayerElement : LayerElement
|
||||
{
|
||||
public RotationLayerElement(Layer layer, Guid guid, LayerElementSettings settings, LayerElementDescriptor descriptor) : base(layer, guid, settings, descriptor)
|
||||
public RotationLayerElement(Layer layer, Guid guid, BrushSettings settings, BrushDescriptor descriptor) : base(layer, guid, settings, descriptor)
|
||||
{
|
||||
}
|
||||
|
||||
public float Rotation { get; set; }
|
||||
|
||||
public override LayerElementViewModel GetViewModel()
|
||||
public override BrushViewModel GetViewModel()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -7,13 +7,13 @@ namespace Artemis.Plugins.LayerElements.Animations
|
||||
{
|
||||
public class SlideLayerElement : LayerElement
|
||||
{
|
||||
public SlideLayerElement(Layer layer, Guid guid, LayerElementSettings settings, LayerElementDescriptor descriptor) : base(layer, guid, settings, descriptor)
|
||||
public SlideLayerElement(Layer layer, Guid guid, BrushSettings settings, BrushDescriptor descriptor) : base(layer, guid, settings, descriptor)
|
||||
{
|
||||
}
|
||||
|
||||
public int MovePercentage { get; set; }
|
||||
|
||||
public override LayerElementViewModel GetViewModel()
|
||||
public override BrushViewModel GetViewModel()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
<ProjectGuid>{7F4C7AB0-4C9B-452D-AFED-34544C903DEF}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Artemis.Plugins.LayerElements.Noise</RootNamespace>
|
||||
<AssemblyName>Artemis.Plugins.LayerElements.Noise</AssemblyName>
|
||||
<RootNamespace>Artemis.Plugins.LayerBrushes.Noise</RootNamespace>
|
||||
<AssemblyName>Artemis.Plugins.LayerBrushes.Noise</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
@ -87,11 +87,11 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="NoiseLayerElementSettings.cs" />
|
||||
<Compile Include="NoiseLayerElementViewModel.cs" />
|
||||
<Compile Include="NoiseLayerElement.cs" />
|
||||
<Compile Include="NoiseLayerElementProvider.cs" />
|
||||
<Compile Include="OpenSimplexNoise.cs" />
|
||||
<Compile Include="NoiseBrushSettings.cs" />
|
||||
<Compile Include="NoiseBrushViewModel.cs" />
|
||||
<Compile Include="NoiseBrush.cs" />
|
||||
<Compile Include="NoiseBrushProvider.cs" />
|
||||
<Compile Include="Utilities\OpenSimplexNoise.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -113,7 +113,7 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="NoiseLayerElementView.xaml">
|
||||
<Page Include="NoiseBrushView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
@ -1,26 +1,27 @@
|
||||
using System;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Plugins.LayerBrushes.Noise.Utilities;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.LayerElements.Noise
|
||||
namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
{
|
||||
public class NoiseLayerElement : LayerElement
|
||||
public class NoiseBrush : LayerBrush
|
||||
{
|
||||
private const int Scale = 6;
|
||||
private static readonly Random Rand = new Random();
|
||||
private readonly OpenSimplexNoise _noise;
|
||||
private float _z;
|
||||
|
||||
public NoiseLayerElement(Layer layer, Guid guid, NoiseLayerElementSettings settings, LayerElementDescriptor descriptor) : base(layer, guid, settings, descriptor)
|
||||
public NoiseBrush(Layer layer, NoiseBrushSettings settings, LayerBrushDescriptor descriptor) : base(layer, settings, descriptor)
|
||||
{
|
||||
Settings = settings;
|
||||
|
||||
_z = Rand.Next(0, 4096);
|
||||
_noise = new OpenSimplexNoise(Guid.GetHashCode());
|
||||
_noise = new OpenSimplexNoise(Rand.Next(0, 4096));
|
||||
}
|
||||
|
||||
public new NoiseLayerElementSettings Settings { get; }
|
||||
public new NoiseBrushSettings Settings { get; }
|
||||
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
@ -34,16 +35,16 @@ namespace Artemis.Plugins.LayerElements.Noise
|
||||
base.Update(deltaTime);
|
||||
}
|
||||
|
||||
public override LayerElementViewModel GetViewModel()
|
||||
public override LayerBrushViewModel GetViewModel()
|
||||
{
|
||||
return new NoiseLayerElementViewModel(this);
|
||||
return new NoiseBrushViewModel(this);
|
||||
}
|
||||
|
||||
public override void Render(SKPath framePath, SKCanvas canvas)
|
||||
public override void Render(SKCanvas canvas)
|
||||
{
|
||||
// Scale down the render path to avoid computing a value for every pixel
|
||||
var width = (int) (Math.Max(Layer.RenderRectangle.Width, Layer.RenderRectangle.Height) / Scale);
|
||||
var height = (int) (Math.Max(Layer.RenderRectangle.Width, Layer.RenderRectangle.Height) / Scale);
|
||||
var width = (int) (Math.Max(Layer.Rectangle.Width, Layer.Rectangle.Height) / Scale);
|
||||
var height = (int) (Math.Max(Layer.Rectangle.Width, Layer.Rectangle.Height) / Scale);
|
||||
var opacity = (float) Math.Round(Settings.Color.Alpha / 255.0, 2, MidpointRounding.AwayFromZero);
|
||||
using (var bitmap = new SKBitmap(new SKImageInfo(width, height)))
|
||||
{
|
||||
@ -76,7 +77,7 @@ namespace Artemis.Plugins.LayerElements.Noise
|
||||
using (var sh = SKShader.CreateBitmap(bitmap, SKShaderTileMode.Mirror, SKShaderTileMode.Mirror, SKMatrix.MakeScale(Scale, Scale)))
|
||||
using (var paint = new SKPaint {Shader = sh, BlendMode = Settings.BlendMode})
|
||||
{
|
||||
canvas.DrawPath(framePath, paint);
|
||||
canvas.DrawPath(Layer.LayerShape.RenderPath, paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
|
||||
namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
{
|
||||
public class NoiseBrushProvider : LayerBrushProvider
|
||||
{
|
||||
public NoiseBrushProvider(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
{
|
||||
AddLayerBrushDescriptor<NoiseBrush>("Noise", "A brush of that shows an animated random noise", "ScatterPlot");
|
||||
}
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.LayerElements.Noise
|
||||
namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
{
|
||||
public class NoiseLayerElementSettings : LayerElementSettings
|
||||
public class NoiseBrushSettings : LayerBrushSettings
|
||||
{
|
||||
private float _animationSpeed;
|
||||
private SKBlendMode _blendMode;
|
||||
@ -11,7 +11,7 @@ namespace Artemis.Plugins.LayerElements.Noise
|
||||
private float _xScale;
|
||||
private float _yScale;
|
||||
|
||||
public NoiseLayerElementSettings()
|
||||
public NoiseBrushSettings()
|
||||
{
|
||||
// Color = new SKColor(0, 0, 0);
|
||||
// BlendMode = SKBlendMode.Color;
|
||||
@ -1,14 +1,14 @@
|
||||
<UserControl x:Class="Artemis.Plugins.LayerElements.Noise.NoiseLayerElementView"
|
||||
<UserControl x:Class="Artemis.Plugins.LayerBrushes.Noise.NoiseBrushView"
|
||||
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:noiseLayer="clr-namespace:Artemis.Plugins.LayerElements.Noise"
|
||||
xmlns:artemis="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
|
||||
xmlns:noiseBrush="clr-namespace:Artemis.Plugins.LayerBrushes.Noise"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance {x:Type noiseLayer:NoiseLayerElementViewModel}}">
|
||||
d:DataContext="{d:DesignInstance {x:Type noiseBrush:NoiseBrushViewModel}}">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
@ -41,7 +41,7 @@
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Text="Noise color" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<artemis:ColorPicker Color="{Binding LayerElement.Settings.Color, Converter={StaticResource SKColorToColorConverter}}" Width="100" />
|
||||
<artemis:ColorPicker Color="{Binding Brush.Settings.Color, Converter={StaticResource SKColorToColorConverter}}" Width="100" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
@ -69,7 +69,7 @@
|
||||
SelectedValuePath="Value"
|
||||
DisplayMemberPath="Description"
|
||||
Width="100"
|
||||
SelectedValue="{Binding LayerElement.Settings.BlendMode}" />
|
||||
SelectedValue="{Binding Brush.Settings.BlendMode}" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
@ -89,7 +89,7 @@
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<Slider Orientation="Horizontal" TickFrequency="0.5" Minimum="0.5" Maximum="40" Value="{Binding LayerElement.Settings.XScale}" Width="100" />
|
||||
<Slider Orientation="Horizontal" TickFrequency="0.5" Minimum="0.5" Maximum="40" Value="{Binding Brush.Settings.XScale}" Width="100" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
@ -110,7 +110,7 @@
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<Slider Orientation="Horizontal" TickFrequency="0.5" Minimum="0.5" Maximum="40" Value="{Binding LayerElement.Settings.YScale}" Width="100" />
|
||||
<Slider Orientation="Horizontal" TickFrequency="0.5" Minimum="0.5" Maximum="40" Value="{Binding Brush.Settings.YScale}" Width="100" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
@ -132,7 +132,7 @@
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
|
||||
<Slider Orientation="Horizontal" TickFrequency="1" Minimum="1" Maximum="100" Value="{Binding LayerElement.Settings.AnimationSpeed}" Width="100" />
|
||||
<Slider Orientation="Horizontal" TickFrequency="1" Minimum="1" Maximum="100" Value="{Binding Brush.Settings.AnimationSpeed}" Width="100" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
@ -0,0 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Utilities;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.LayerBrushes.Noise
|
||||
{
|
||||
public class NoiseBrushViewModel : LayerBrushViewModel
|
||||
{
|
||||
public NoiseBrushViewModel(NoiseBrush brush) : base(brush)
|
||||
{
|
||||
Brush = brush;
|
||||
}
|
||||
|
||||
public new NoiseBrush Brush { get; }
|
||||
public IEnumerable<ValueDescription> BlendModes => EnumUtilities.GetAllValuesAndDescriptions(typeof(SKBlendMode));
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
|
||||
namespace Artemis.Plugins.LayerElements.Noise
|
||||
{
|
||||
public class NoiseLayerElementProvider : LayerElementProvider
|
||||
{
|
||||
public NoiseLayerElementProvider(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
{
|
||||
AddLayerElementDescriptor<NoiseLayerElement>("Noise", "A brush of that shows an animated random noise", "ScatterPlot");
|
||||
}
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using Artemis.Core.Utilities;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.LayerElements.Noise
|
||||
{
|
||||
public class NoiseLayerElementViewModel : LayerElementViewModel
|
||||
{
|
||||
public NoiseLayerElementViewModel(NoiseLayerElement layerElement) : base(layerElement)
|
||||
{
|
||||
LayerElement = layerElement;
|
||||
}
|
||||
|
||||
public new NoiseLayerElement LayerElement { get; }
|
||||
public IEnumerable<ValueDescription> BlendModes => EnumUtilities.GetAllValuesAndDescriptions(typeof(SKBlendMode));
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Artemis.Plugins.LayerElements.Noise")]
|
||||
[assembly: AssemblyTitle("Artemis.Plugins.LayerBrushes.Noise")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Artemis.Plugins.LayerElements.Noise
|
||||
namespace Artemis.Plugins.LayerBrushes.Noise.Utilities
|
||||
{
|
||||
public class OpenSimplexNoise
|
||||
{
|
||||
@ -1,10 +1,10 @@
|
||||
{
|
||||
"Guid": "61cbbf01-8d69-4ede-a972-f3f269da66d9",
|
||||
"Name": "Noise layer elements",
|
||||
"Name": "Noise layer brush",
|
||||
"Version": {
|
||||
"Major": 1,
|
||||
"Minor": 0,
|
||||
"Build": 0
|
||||
},
|
||||
"Main": "Artemis.Plugins.LayerElements.Noise.dll"
|
||||
"Main": "Artemis.Plugins.LayerBrushes.Noise.dll"
|
||||
}
|
||||
@ -7,8 +7,8 @@
|
||||
<ProjectGuid>{0F288A66-6EB0-4589-8595-E33A3A3EAEA2}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Artemis.Plugins.LayerElements.Brush</RootNamespace>
|
||||
<AssemblyName>Artemis.Plugins.LayerElements.Brush</AssemblyName>
|
||||
<RootNamespace>Artemis.Plugins.LayerBrushes.Color</RootNamespace>
|
||||
<AssemblyName>Artemis.Plugins.LayerBrushes.Color</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
@ -87,10 +87,10 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BrushLayerElementSettings.cs" />
|
||||
<Compile Include="BrushLayerElementViewModel.cs" />
|
||||
<Compile Include="BrushLayerElement.cs" />
|
||||
<Compile Include="BrushLayerElementProvider.cs" />
|
||||
<Compile Include="ColorBrushSettings.cs" />
|
||||
<Compile Include="ColorBrushViewModel.cs" />
|
||||
<Compile Include="ColorBrush.cs" />
|
||||
<Compile Include="ColorBrushProvider.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -108,7 +108,7 @@
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="BrushLayerElementView.xaml">
|
||||
<Page Include="ColorBrushView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
@ -1,25 +0,0 @@
|
||||
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()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using Artemis.Core.Utilities;
|
||||
|
||||
namespace Artemis.Plugins.LayerElements.Brush
|
||||
{
|
||||
public class BrushLayerElementViewModel : LayerElementViewModel
|
||||
{
|
||||
public BrushLayerElementViewModel(BrushLayerElement layerElement) : base(layerElement)
|
||||
{
|
||||
LayerElement = layerElement;
|
||||
}
|
||||
|
||||
public new BrushLayerElement LayerElement { get; }
|
||||
public IEnumerable<ValueDescription> BrushTypes => EnumUtilities.GetAllValuesAndDescriptions(typeof(BrushType));
|
||||
}
|
||||
}
|
||||
@ -2,19 +2,18 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.LayerElements.Brush
|
||||
namespace Artemis.Plugins.LayerBrushes.Color
|
||||
{
|
||||
public class BrushLayerElement : LayerElement
|
||||
public class ColorBrush : LayerBrush
|
||||
{
|
||||
private SKShader _shader;
|
||||
private List<SKColor> _testColors;
|
||||
private SKPaint _paint;
|
||||
|
||||
public BrushLayerElement(Layer layer, Guid guid, BrushLayerElementSettings settings, LayerElementDescriptor descriptor) : base(layer, guid, settings, descriptor)
|
||||
public ColorBrush(Layer layer, ColorBrushSettings settings, LayerBrushDescriptor descriptor) : base(layer, settings, descriptor)
|
||||
{
|
||||
Settings = settings;
|
||||
|
||||
@ -34,20 +33,20 @@ namespace Artemis.Plugins.LayerElements.Brush
|
||||
|
||||
private void CreateShader()
|
||||
{
|
||||
var center = new SKPoint(Layer.RenderRectangle.MidX, Layer.RenderRectangle.MidY);
|
||||
var center = new SKPoint(Layer.Rectangle.MidX, Layer.Rectangle.MidY);
|
||||
SKShader shader;
|
||||
switch (Settings.BrushType)
|
||||
switch (Settings.GradientType)
|
||||
{
|
||||
case BrushType.Solid:
|
||||
case GradientType.Solid:
|
||||
shader = SKShader.CreateColor(_testColors.First());
|
||||
break;
|
||||
case BrushType.LinearGradient:
|
||||
shader = SKShader.CreateLinearGradient(new SKPoint(0, 0), new SKPoint(Layer.RenderRectangle.Width, 0), _testColors.ToArray(), SKShaderTileMode.Repeat);
|
||||
case GradientType.LinearGradient:
|
||||
shader = SKShader.CreateLinearGradient(new SKPoint(0, 0), new SKPoint(Layer.Rectangle.Width, 0), _testColors.ToArray(), SKShaderTileMode.Repeat);
|
||||
break;
|
||||
case BrushType.RadialGradient:
|
||||
shader = SKShader.CreateRadialGradient(center, Math.Min(Layer.RenderRectangle.Width, Layer.RenderRectangle.Height), _testColors.ToArray(), SKShaderTileMode.Repeat);
|
||||
case GradientType.RadialGradient:
|
||||
shader = SKShader.CreateRadialGradient(center, Math.Min(Layer.Rectangle.Width, Layer.Rectangle.Height), _testColors.ToArray(), SKShaderTileMode.Repeat);
|
||||
break;
|
||||
case BrushType.SweepGradient:
|
||||
case GradientType.SweepGradient:
|
||||
shader = SKShader.CreateSweepGradient(center, _testColors.ToArray(), null, SKShaderTileMode.Clamp, 0, 360);
|
||||
break;
|
||||
default:
|
||||
@ -62,16 +61,16 @@ namespace Artemis.Plugins.LayerElements.Brush
|
||||
oldPaint?.Dispose();
|
||||
}
|
||||
|
||||
public new BrushLayerElementSettings Settings { get; }
|
||||
public new ColorBrushSettings Settings { get; }
|
||||
|
||||
public override LayerElementViewModel GetViewModel()
|
||||
public override LayerBrushViewModel GetViewModel()
|
||||
{
|
||||
return new BrushLayerElementViewModel(this);
|
||||
return new ColorBrushViewModel(this);
|
||||
}
|
||||
|
||||
public override void Render(SKPath framePath, SKCanvas canvas)
|
||||
public override void Render(SKCanvas canvas)
|
||||
{
|
||||
canvas.DrawPath(framePath, _paint);
|
||||
canvas.DrawPath(Layer.LayerShape.RenderPath, _paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
25
src/Artemis.Plugins.LayerTypes.Brush/ColorBrushProvider.cs
Normal file
25
src/Artemis.Plugins.LayerTypes.Brush/ColorBrushProvider.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
|
||||
namespace Artemis.Plugins.LayerBrushes.Color
|
||||
{
|
||||
public class ColorBrushProvider : LayerBrushProvider
|
||||
{
|
||||
public ColorBrushProvider(PluginInfo pluginInfo) : base(pluginInfo)
|
||||
{
|
||||
AddLayerBrushDescriptor<ColorBrush>("Color", "A color with an (optional) gradient", "Brush");
|
||||
}
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
public override void DisablePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,25 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Plugins.LayerElements.Brush
|
||||
namespace Artemis.Plugins.LayerBrushes.Color
|
||||
{
|
||||
public class BrushLayerElementSettings : LayerElementSettings
|
||||
public class ColorBrushSettings : LayerBrushSettings
|
||||
{
|
||||
private BrushType _brushType;
|
||||
private List<SKColor> _colors;
|
||||
private GradientType _gradientType;
|
||||
|
||||
public BrushLayerElementSettings()
|
||||
public ColorBrushSettings()
|
||||
{
|
||||
BrushType = BrushType.Solid;
|
||||
GradientType = GradientType.Solid;
|
||||
Colors = new List<SKColor>();
|
||||
}
|
||||
|
||||
public BrushType BrushType
|
||||
public GradientType GradientType
|
||||
{
|
||||
get => _brushType;
|
||||
set => SetAndNotify(ref _brushType, value);
|
||||
get => _gradientType;
|
||||
set => SetAndNotify(ref _gradientType, value);
|
||||
}
|
||||
|
||||
public List<SKColor> Colors
|
||||
@ -29,7 +29,7 @@ namespace Artemis.Plugins.LayerElements.Brush
|
||||
}
|
||||
}
|
||||
|
||||
public enum BrushType
|
||||
public enum GradientType
|
||||
{
|
||||
[Description("Solid")]
|
||||
Solid,
|
||||
@ -1,13 +1,12 @@
|
||||
<UserControl x:Class="Artemis.Plugins.LayerElements.Brush.BrushLayerElementView"
|
||||
<UserControl x:Class="Artemis.Plugins.LayerBrushes.Color.ColorBrushView"
|
||||
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"
|
||||
xmlns:colorBrush="clr-namespace:Artemis.Plugins.LayerBrushes.Color"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance {x:Type brushLayer:BrushLayerElementViewModel}}">
|
||||
d:DataContext="{d:DesignInstance {x:Type colorBrush:ColorBrushViewModel}}">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
@ -47,7 +46,7 @@
|
||||
ItemsSource="{Binding Path=BrushTypes}"
|
||||
SelectedValuePath="Value"
|
||||
DisplayMemberPath="Description"
|
||||
SelectedValue="{Binding Path=LayerElement.Settings.BrushType}" />
|
||||
SelectedValue="{Binding Path=ColorBrush.Settings.GradientType}" />
|
||||
</StackPanel>
|
||||
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignSeparator}" />
|
||||
</Grid>
|
||||
17
src/Artemis.Plugins.LayerTypes.Brush/ColorBrushViewModel.cs
Normal file
17
src/Artemis.Plugins.LayerTypes.Brush/ColorBrushViewModel.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core.Plugins.LayerBrush;
|
||||
using Artemis.Core.Utilities;
|
||||
|
||||
namespace Artemis.Plugins.LayerBrushes.Color
|
||||
{
|
||||
public class ColorBrushViewModel : LayerBrushViewModel
|
||||
{
|
||||
public ColorBrushViewModel(ColorBrush element) : base(element)
|
||||
{
|
||||
ColorBrush = element;
|
||||
}
|
||||
|
||||
public new ColorBrush ColorBrush { get; }
|
||||
public IEnumerable<ValueDescription> BrushTypes => EnumUtilities.GetAllValuesAndDescriptions(typeof(GradientType));
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Artemis.Plugins.LayerElements.Brush")]
|
||||
[assembly: AssemblyTitle("Artemis.Plugins.LayerBrushes.Color")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
{
|
||||
"Guid": "92a9d6ba-6f7a-4937-94d5-c1d715b4141a",
|
||||
"Name": "Brush layer elements",
|
||||
"Name": "Color layer brush",
|
||||
"Version": {
|
||||
"Major": 1,
|
||||
"Minor": 0,
|
||||
"Build": 0
|
||||
},
|
||||
"Main": "Artemis.Plugins.LayerElements.Brush.dll"
|
||||
"Main": "Artemis.Plugins.LayerBrushes.Color.dll"
|
||||
}
|
||||
11
src/Artemis.Storage/Entities/Profile/BrushEntity.cs
Normal file
11
src/Artemis.Storage/Entities/Profile/BrushEntity.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
{
|
||||
public class BrushEntity
|
||||
{
|
||||
public Guid BrushPluginGuid { get; set; }
|
||||
public string BrushType { get; set; }
|
||||
public string Configuration { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
{
|
||||
public class LayerElementEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid PluginGuid { get; set; }
|
||||
public string LayerElementType { get; set; }
|
||||
public string Configuration { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using LiteDB;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
@ -10,7 +11,6 @@ namespace Artemis.Storage.Entities.Profile
|
||||
{
|
||||
Leds = new List<LedEntity>();
|
||||
Condition = new List<ProfileConditionEntity>();
|
||||
Elements = new List<LayerElementEntity>();
|
||||
}
|
||||
|
||||
public Guid Id { get; set; }
|
||||
@ -21,11 +21,12 @@ namespace Artemis.Storage.Entities.Profile
|
||||
|
||||
public List<LedEntity> Leds { get; set; }
|
||||
public List<ProfileConditionEntity> Condition { get; set; }
|
||||
public List<LayerElementEntity> Elements { get; set; }
|
||||
|
||||
public ShapeEntity ShapeEntity { get; set; }
|
||||
public BrushEntity BrushEntity { get; set; }
|
||||
|
||||
[BsonRef("ProfileEntity")]
|
||||
public ProfileEntity Profile { get; set; }
|
||||
|
||||
public Guid ProfileId { get; set; }
|
||||
}
|
||||
}
|
||||
29
src/Artemis.Storage/Entities/Profile/ShapeEntity.cs
Normal file
29
src/Artemis.Storage/Entities/Profile/ShapeEntity.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile
|
||||
{
|
||||
public class ShapeEntity
|
||||
{
|
||||
public ShapeEntityType Type { get; set; }
|
||||
public ShapePointEntity Anchor { get; set; }
|
||||
public float Width { get; set; }
|
||||
public float Height { get; set; }
|
||||
public ShapePointEntity Position { get; set; }
|
||||
|
||||
public List<ShapePointEntity> Points { get; set; }
|
||||
}
|
||||
|
||||
public class ShapePointEntity
|
||||
{
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
}
|
||||
|
||||
public enum ShapeEntityType
|
||||
{
|
||||
Ellipse,
|
||||
Fill,
|
||||
Polygon,
|
||||
Rectangle
|
||||
}
|
||||
}
|
||||
@ -174,7 +174,48 @@
|
||||
<Compile Include="Events\MainWindowFocusChangedEvent.cs" />
|
||||
<Compile Include="Events\WindowsThemeEventArgs.cs" />
|
||||
<Compile Include="Screens\GradientEditor\GradientEditorViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\LayerElements\Dialogs\AddLayerElementViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\LayerPropertiesView.xaml.cs">
|
||||
<DependentUpon>LayerPropertiesView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\LayerPropertiesViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\Timeline\LayerPropertiesTimelineView.xaml.cs">
|
||||
<DependentUpon>LayerPropertiesTimelineView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Screens\Module\ProfileEditor\LayerProperties\Timeline\LayerPropertiesTimelineViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\CanvasViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\EllipseToolView.xaml.cs">
|
||||
<DependentUpon>EllipseToolView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\EllipseToolViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\FillToolView.xaml.cs">
|
||||
<DependentUpon>FillToolView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\FillToolViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\PolygonToolView.xaml.cs">
|
||||
<DependentUpon>PolygonToolView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\PolygonToolViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\RectangleToolView.xaml.cs">
|
||||
<DependentUpon>RectangleToolView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\RectangleToolViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\SelectionAddToolView.xaml.cs">
|
||||
<DependentUpon>SelectionAddToolView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\SelectionAddToolViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\SelectionRemoveToolView.xaml.cs">
|
||||
<DependentUpon>SelectionRemoveToolView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\SelectionRemoveToolViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\SelectionToolView.xaml.cs">
|
||||
<DependentUpon>SelectionToolView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\SelectionToolViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\ViewpointMoveToolView.xaml.cs">
|
||||
<DependentUpon>ViewpointMoveToolView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\ViewpointMoveToolViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\VisualizationToolViewModel.cs" />
|
||||
<Compile Include="Screens\Sidebar\SidebarView.xaml.cs">
|
||||
<DependentUpon>SidebarView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -202,9 +243,6 @@
|
||||
<Compile Include="Screens\Module\ProfileEditor\Dialogs\ProfileElementRenameViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\DisplayConditions\DisplayConditionsViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\DisplayConditions\DisplayConditionViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\ElementProperties\ElementPropertiesViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\LayerElements\LayerElementsViewModel.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\LayerViewModel.cs" />
|
||||
<Compile Include="Screens\Module\ProfileEditor\ProfileTree\ProfileTreeViewModel.cs" />
|
||||
@ -269,15 +307,11 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\ElementProperties\ElementPropertiesView.xaml">
|
||||
<Page Include="Screens\Module\ProfileEditor\LayerProperties\LayerPropertiesView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\LayerElements\Dialogs\AddLayerElementView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\LayerElements\LayerElementsView.xaml">
|
||||
<Page Include="Screens\Module\ProfileEditor\LayerProperties\Timeline\LayerPropertiesTimelineView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
@ -301,6 +335,38 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\Visualization\Tools\EllipseToolView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\Visualization\Tools\FillToolView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\Visualization\Tools\PolygonToolView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\Visualization\Tools\RectangleToolView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\Visualization\Tools\SelectionAddToolView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\Visualization\Tools\SelectionRemoveToolView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\Visualization\Tools\SelectionToolView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\Module\ProfileEditor\Visualization\Tools\ViewpointMoveToolView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Screens\News\NewsView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@ -436,7 +502,24 @@
|
||||
<ItemGroup>
|
||||
<None Include="Resources\aero_rotate_br.cur" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<None Include="Resources\aero_crosshair.cur" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\aero_crosshair_minus.cur" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\aero_crosshair_plus.cur" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\aero_pen_min.cur" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\aero_pen_plus.cur" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\aero_fill.cur" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Artemis.Core.Models.Profile.Abstract;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.UI.Screens.Module;
|
||||
|
||||
60
src/Artemis.UI/Properties/Resources.Designer.cs
generated
60
src/Artemis.UI/Properties/Resources.Designer.cs
generated
@ -60,6 +60,66 @@ namespace Artemis.UI.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] aero_crosshair {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("aero_crosshair", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] aero_crosshair_minus {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("aero_crosshair_minus", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] aero_crosshair_plus {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("aero_crosshair_plus", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] aero_fill {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("aero_fill", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] aero_pen_min {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("aero_pen_min", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] aero_pen_plus {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("aero_pen_plus", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
|
||||
@ -118,6 +118,24 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="aero_crosshair" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\aero_crosshair.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="aero_crosshair_minus" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\aero_crosshair_minus.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="aero_crosshair_plus" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\aero_crosshair_plus.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="aero_fill" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\aero_fill.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="aero_pen_min" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\aero_pen_min.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="aero_pen_plus" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\aero_pen_plus.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="aero_rotate_bl" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\aero_rotate_bl.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
|
||||
BIN
src/Artemis.UI/Resources/aero_crosshair.cur
Normal file
BIN
src/Artemis.UI/Resources/aero_crosshair.cur
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
BIN
src/Artemis.UI/Resources/aero_crosshair_minus.cur
Normal file
BIN
src/Artemis.UI/Resources/aero_crosshair_minus.cur
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
BIN
src/Artemis.UI/Resources/aero_crosshair_plus.cur
Normal file
BIN
src/Artemis.UI/Resources/aero_crosshair_plus.cur
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
BIN
src/Artemis.UI/Resources/aero_fill.cur
Normal file
BIN
src/Artemis.UI/Resources/aero_fill.cur
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
src/Artemis.UI/Resources/aero_pen_min.cur
Normal file
BIN
src/Artemis.UI/Resources/aero_pen_min.cur
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
BIN
src/Artemis.UI/Resources/aero_pen_plus.cur
Normal file
BIN
src/Artemis.UI/Resources/aero_pen_plus.cur
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@ -1,5 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Models.Profile.Abstract;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.UI.ViewModels.Dialogs;
|
||||
using FluentValidation;
|
||||
using Stylet;
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.ElementProperties.ElementPropertiesView"
|
||||
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:elementProperties="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.ElementProperties"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance {x:Type elementProperties:ElementPropertiesViewModel}}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0">
|
||||
<TextBlock Style="{StaticResource MaterialDesignSubheadingTextBlock}" Margin="10 5 0 -4">
|
||||
Layer element properties
|
||||
</TextBlock>
|
||||
<Separator Style="{StaticResource MaterialDesignDarkSeparator}" Margin="8 0" />
|
||||
</StackPanel>
|
||||
<ScrollViewer Grid.Row="1">
|
||||
<ContentControl s:View.Model="{Binding LayerElementViewModel}" Margin="0 0 10 0"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@ -1,37 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.ElementProperties
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (LayerElementViewModel?.LayerElement?.Settings != null)
|
||||
LayerElementViewModel.LayerElement.Settings.PropertyChanged -= SettingsOnPropertyChanged;
|
||||
|
||||
LayerElementViewModel = _profileEditorService.SelectedLayerElement?.GetViewModel();
|
||||
|
||||
if (LayerElementViewModel?.LayerElement?.Settings != null)
|
||||
LayerElementViewModel.LayerElement.Settings.PropertyChanged += SettingsOnPropertyChanged;
|
||||
}
|
||||
|
||||
private void SettingsOnPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
<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>
|
||||
@ -1,57 +0,0 @@
|
||||
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()
|
||||
{
|
||||
if (Session.IsEnded)
|
||||
return;
|
||||
var layerElement = _layerService.InstantiateLayerElement(Layer, SelectedLayerElementDescriptor);
|
||||
Session.Close(layerElement);
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
if (Session.IsEnded)
|
||||
return;
|
||||
Session.Close();
|
||||
}
|
||||
|
||||
#region View event handlers
|
||||
|
||||
public void ListBoxItemMouseClick(object sender, MouseButtonEventArgs args)
|
||||
{
|
||||
if (args.ClickCount > 1 && SelectedLayerElementDescriptor != null)
|
||||
Accept();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Plugins.LayerElement;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerElements
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
@ -1,71 +0,0 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerElements.LayerElementsView"
|
||||
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: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"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance {x:Type layerElements:LayerElementsViewModel}}">
|
||||
|
||||
<materialDesign:DialogHost Identifier="LayerElementsDialogHost" CloseOnClickAway="True">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</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>
|
||||
@ -1,111 +0,0 @@
|
||||
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.Core.Services.Interfaces;
|
||||
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
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly ILayerService _layerService;
|
||||
private LayerElementViewModel _selectedLayerElement;
|
||||
|
||||
public LayerElementsViewModel(IProfileEditorService profileEditorService, ILayerService layerService, IDialogService dialogService)
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
_layerService = layerService;
|
||||
_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))
|
||||
return;
|
||||
|
||||
LayerElements.Add(new LayerElementViewModel(layerElement));
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
var layerElement = SelectedLayerElement.LayerElement;
|
||||
var layer = (Layer) SelectedProfileElement;
|
||||
|
||||
LayerElements.Remove(SelectedLayerElement);
|
||||
SelectedLayerElement = null;
|
||||
|
||||
_layerService.RemoveLayerElement(layer, layerElement);
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.LayerPropertiesView"
|
||||
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.LayerProperties"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for LayerPropertiesView.xaml
|
||||
/// </summary>
|
||||
public partial class LayerPropertiesView : UserControl
|
||||
{
|
||||
public LayerPropertiesView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
|
||||
{
|
||||
public class LayerPropertiesViewModel : ProfileEditorPanelViewModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline.LayerPropertiesTimelineView"
|
||||
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.LayerProperties.Timeline"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for LayerPropertiesTimelineView.xaml
|
||||
/// </summary>
|
||||
public partial class LayerPropertiesTimelineView : UserControl
|
||||
{
|
||||
public LayerPropertiesTimelineView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
class LayerPropertiesTimelineViewModel
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -80,7 +80,7 @@
|
||||
|
||||
<!-- Element properties -->
|
||||
<materialDesign:Card Grid.Column="2" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
|
||||
<ContentControl s:View.Model="{Binding ElementPropertiesViewModel}" />
|
||||
<ContentControl s:View.Model="{Binding LayerPropertiesViewModel}" />
|
||||
</materialDesign:Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@ -10,8 +10,7 @@ using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.Dialogs;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.ElementProperties;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerElements;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.Visualization;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
@ -41,8 +40,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
||||
DialogService = dialogService;
|
||||
|
||||
DisplayConditionsViewModel = (DisplayConditionsViewModel) viewModels.First(vm => vm is DisplayConditionsViewModel);
|
||||
ElementPropertiesViewModel = (ElementPropertiesViewModel) viewModels.First(vm => vm is ElementPropertiesViewModel);
|
||||
LayerElementsViewModel = (LayerElementsViewModel) viewModels.First(vm => vm is LayerElementsViewModel);
|
||||
LayerPropertiesViewModel = (LayerPropertiesViewModel) viewModels.First(vm => vm is LayerPropertiesViewModel);
|
||||
ProfileTreeViewModel = (ProfileTreeViewModel) viewModels.First(vm => vm is ProfileTreeViewModel);
|
||||
ProfileViewModel = (ProfileViewModel) viewModels.First(vm => vm is ProfileViewModel);
|
||||
Profiles = new BindableCollection<Profile>();
|
||||
@ -55,8 +53,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
||||
public ProfileModule Module { get; }
|
||||
public IDialogService DialogService { get; }
|
||||
public DisplayConditionsViewModel DisplayConditionsViewModel { get; }
|
||||
public ElementPropertiesViewModel ElementPropertiesViewModel { get; }
|
||||
public LayerElementsViewModel LayerElementsViewModel { get; }
|
||||
public LayerPropertiesViewModel LayerPropertiesViewModel { get; }
|
||||
public ProfileTreeViewModel ProfileTreeViewModel { get; }
|
||||
public ProfileViewModel ProfileViewModel { get; }
|
||||
public BindableCollection<Profile> Profiles { get; set; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Artemis.Core.Models.Profile.Abstract;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using Artemis.Core.Models.Profile.Abstract;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.Core.Models.Profile.Abstract;
|
||||
using Artemis.UI.Exceptions;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.Dialogs;
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
{
|
||||
public class CanvasViewModel : PropertyChangedBase
|
||||
{
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
}
|
||||
}
|
||||
@ -21,8 +21,8 @@
|
||||
</Grid.LayoutTransform>
|
||||
|
||||
<!-- Device image with fallback -->
|
||||
<Image VerticalAlignment="Top"
|
||||
HorizontalAlignment="Left"
|
||||
<Image VerticalAlignment="Stretch"
|
||||
HorizontalAlignment="Stretch"
|
||||
Source="{Binding Device.RgbDevice.DeviceInfo.Image, Converter={StaticResource NullToImageConverter}}" />
|
||||
|
||||
<Rectangle Fill="{DynamicResource MaterialDesignCardBackground}"
|
||||
|
||||
@ -7,7 +7,7 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
{
|
||||
public class ProfileDeviceViewModel : PropertyChangedBase
|
||||
public class ProfileDeviceViewModel : CanvasViewModel
|
||||
{
|
||||
public ProfileDeviceViewModel(ArtemisDevice device)
|
||||
{
|
||||
@ -21,13 +21,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
public ArtemisDevice Device { get; set; }
|
||||
public bool AddedLeds { get; private set; }
|
||||
|
||||
public double X
|
||||
public new double X
|
||||
{
|
||||
get => Device.X;
|
||||
set => Device.X = value;
|
||||
}
|
||||
|
||||
public double Y
|
||||
public new double Y
|
||||
{
|
||||
get => Device.Y;
|
||||
set => Device.Y = value;
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
</DoubleAnimation.EasingFunction>
|
||||
</DoubleAnimation>
|
||||
<ObjectAnimationUsingKeyFrames BeginTime="0:0:0.5" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Hidden}"/>
|
||||
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Hidden}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
@ -39,164 +39,151 @@
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
<Grid ClipToBounds="True"
|
||||
KeyUp="{s:Action EditorGridKeyUp}"
|
||||
KeyDown="{s:Action EditorGridKeyDown}"
|
||||
MouseWheel="{s:Action EditorGridMouseWheel}"
|
||||
MouseUp="{s:Action EditorGridMouseClick}"
|
||||
MouseDown="{s:Action EditorGridMouseClick}"
|
||||
MouseMove="{s:Action EditorGridMouseMove}"
|
||||
Cursor="{Binding Cursor}"
|
||||
utilities:SizeObserver.Observe="True"
|
||||
utilities:SizeObserver.ObservedWidth="{Binding PanZoomViewModel.CanvasWidth, Mode=OneWayToSource}"
|
||||
utilities:SizeObserver.ObservedHeight="{Binding PanZoomViewModel.CanvasHeight, Mode=OneWayToSource}">
|
||||
|
||||
<Grid.Background>
|
||||
<VisualBrush TileMode="Tile" Stretch="Uniform" Viewport="{Binding PanZoomViewModel.BackgroundViewport}" ViewportUnits="Absolute">
|
||||
<VisualBrush.Visual>
|
||||
<Grid Width="25" Height="25">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Grid.Row="0" Grid.Column="0" Fill="{DynamicResource MaterialDesignPaper}" />
|
||||
<Rectangle Grid.Row="0" Grid.Column="1" />
|
||||
<Rectangle Grid.Row="1" Grid.Column="0" />
|
||||
<Rectangle Grid.Row="1" Grid.Column="1" Fill="{DynamicResource MaterialDesignPaper}" />
|
||||
</Grid>
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
</Grid.Background>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ToolBarTray Orientation="Vertical" Width="58">
|
||||
<ToolBar Style="{DynamicResource MaterialDesignToolBar}" ClipToBounds="False" ToolBarTray.IsLocked="True" >
|
||||
<ListBox SelectedIndex="{Binding ActiveToolIndex}" ToolBar.OverflowMode="Never">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Vertical"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBoxItem ToolTip="Pan over different parts of the surface" >
|
||||
<materialDesign:PackIcon Kind="HandLeft" />
|
||||
</ListBoxItem>
|
||||
<ListBoxItem ToolTip="Change layer selection" >
|
||||
<materialDesign:PackIcon Kind="SelectionDrag" />
|
||||
</ListBoxItem>
|
||||
<ListBoxItem ToolTip="Add to layer selection">
|
||||
<materialDesign:PackIcon Kind="PencilPlusOutline" />
|
||||
</ListBoxItem>
|
||||
<ListBoxItem ToolTip="Remove from layer selection">
|
||||
<materialDesign:PackIcon Kind="PencilMinusOutline" />
|
||||
</ListBoxItem>
|
||||
<Separator />
|
||||
<ListBoxItem ToolTip="Create round shape in layer">
|
||||
<materialDesign:PackIcon Kind="ShapeCirclePlus" />
|
||||
</ListBoxItem>
|
||||
<ListBoxItem ToolTip="Create rectangular shape in layer">
|
||||
<materialDesign:PackIcon Kind="ShapeRectanglePlus" />
|
||||
</ListBoxItem>
|
||||
<ListBoxItem ToolTip="Create polygonal shape in layer">
|
||||
<materialDesign:PackIcon Kind="ShapePolygonPlus" />
|
||||
</ListBoxItem>
|
||||
<ListBoxItem ToolTip="Fill entire layer">
|
||||
<materialDesign:PackIcon Kind="FormatColourFill" />
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
|
||||
</ToolBar>
|
||||
</ToolBarTray>
|
||||
<Grid Grid.Column="1"
|
||||
ClipToBounds="True"
|
||||
KeyUp="{s:Action CanvasKeyUp}"
|
||||
KeyDown="{s:Action CanvasKeyDown}"
|
||||
MouseWheel="{s:Action CanvasMouseWheel}"
|
||||
MouseUp="{s:Action CanvasMouseDown}"
|
||||
MouseDown="{s:Action CanvasMouseUp}"
|
||||
MouseMove="{s:Action CanvasMouseMove}"
|
||||
Cursor="{Binding ActiveToolViewModel.Cursor}"
|
||||
utilities:SizeObserver.Observe="True"
|
||||
utilities:SizeObserver.ObservedWidth="{Binding PanZoomViewModel.CanvasWidth, Mode=OneWayToSource}"
|
||||
utilities:SizeObserver.ObservedHeight="{Binding PanZoomViewModel.CanvasHeight, Mode=OneWayToSource}">
|
||||
|
||||
<Grid.Triggers>
|
||||
<EventTrigger RoutedEvent="Grid.MouseLeftButtonDown">
|
||||
<BeginStoryboard>
|
||||
<Storyboard TargetName="MultiSelectionPath" TargetProperty="Opacity">
|
||||
<DoubleAnimation From="0" To="1" Duration="0:0:0.1" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
<EventTrigger RoutedEvent="Grid.MouseLeftButtonUp">
|
||||
<BeginStoryboard>
|
||||
<Storyboard TargetName="MultiSelectionPath" TargetProperty="Opacity">
|
||||
<DoubleAnimation From="1" To="0" Duration="0:0:0.2" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</Grid.Triggers>
|
||||
|
||||
<Grid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Create new layer for selection" Command="{s:Action CreateLayer}" CommandParameter="{Binding}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="LayersPlus" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Apply selection to layer" Command="{s:Action ApplyToLayer}" CommandParameter="{Binding}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="Selection" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="Select all" Command="{s:Action SelectAll}" CommandParameter="{Binding}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="SelectAll" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Inverse selection" Command="{s:Action InverseSelection}" CommandParameter="{Binding}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="SelectInverse" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Clear selection" Command="{s:Action ClearSelection}" CommandParameter="{Binding}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="SelectOff" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</Grid.ContextMenu>
|
||||
|
||||
<Grid Name="EditorDisplayGrid">
|
||||
<Grid.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="{Binding PanZoomViewModel.Zoom}" ScaleY="{Binding PanZoomViewModel.Zoom}" />
|
||||
<TranslateTransform X="{Binding PanZoomViewModel.PanX}" Y="{Binding PanZoomViewModel.PanY}" />
|
||||
</TransformGroup>
|
||||
</Grid.RenderTransform>
|
||||
<ItemsControl ItemsSource="{Binding Devices}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Canvas />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemContainerStyle>
|
||||
<Style TargetType="ContentPresenter">
|
||||
<Setter Property="Canvas.Left" Value="{Binding X}" />
|
||||
<Setter Property="Canvas.Top" Value="{Binding Y}" />
|
||||
</Style>
|
||||
</ItemsControl.ItemContainerStyle>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding}" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
|
||||
<!-- Multi-selection rectangle -->
|
||||
<Path Data="{Binding SelectionRectangle}" Opacity="0"
|
||||
Stroke="{DynamicResource PrimaryHueLightBrush}"
|
||||
StrokeThickness="1"
|
||||
Name="MultiSelectionPath"
|
||||
IsHitTestVisible="False">
|
||||
<Path.Fill>
|
||||
<SolidColorBrush Color="{DynamicResource Primary400}" Opacity="0.25" />
|
||||
</Path.Fill>
|
||||
</Path>
|
||||
|
||||
<StackPanel ZIndex="1" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="10">
|
||||
<materialDesign:Card Padding="8">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}" IsChecked="{Binding HighlightSelectedLayer.Value}">
|
||||
Highlight selected layer
|
||||
</CheckBox>
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}" Margin="10 0 0 0" IsChecked="{Binding PauseRenderingOnFocusLoss.Value}">
|
||||
Pause visualization on focus loss
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom" HorizontalAlignment="Right"
|
||||
Margin="10" ZIndex="1">
|
||||
<Slider Margin="0,0,14,0"
|
||||
Orientation="Vertical"
|
||||
Minimum="10"
|
||||
Maximum="400"
|
||||
Height="100"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
Value="{Binding PanZoomViewModel.ZoomPercentage}"
|
||||
Style="{StaticResource MaterialDesignDiscreteSlider}" />
|
||||
<Button Command="{s:Action ResetZoomAndPan}"
|
||||
Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
|
||||
HorizontalAlignment="Right"
|
||||
ToolTip="Reset zoom & position">
|
||||
<materialDesign:PackIcon Kind="ImageFilterCenterFocus" Height="24" Width="24" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Loading indicator -->
|
||||
<Grid Background="{StaticResource MaterialDesignPaper}" Style="{StaticResource InitializingFade}">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
Initializing LED visualization...
|
||||
</TextBlock>
|
||||
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}" Value="0" IsIndeterminate="True" />
|
||||
<Grid.Background>
|
||||
<VisualBrush TileMode="Tile" Stretch="Uniform" Viewport="{Binding PanZoomViewModel.BackgroundViewport}" ViewportUnits="Absolute">
|
||||
<VisualBrush.Visual>
|
||||
<Grid Width="25" Height="25">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Grid.Row="0" Grid.Column="0" Fill="{DynamicResource MaterialDesignPaper}" />
|
||||
<Rectangle Grid.Row="0" Grid.Column="1" />
|
||||
<Rectangle Grid.Row="1" Grid.Column="0" />
|
||||
<Rectangle Grid.Row="1" Grid.Column="1" Fill="{DynamicResource MaterialDesignPaper}" />
|
||||
</Grid>
|
||||
</VisualBrush.Visual>
|
||||
</VisualBrush>
|
||||
</Grid.Background>
|
||||
|
||||
<Grid Name="EditorDisplayGrid">
|
||||
<Grid.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="{Binding PanZoomViewModel.Zoom}" ScaleY="{Binding PanZoomViewModel.Zoom}" />
|
||||
<TranslateTransform X="{Binding PanZoomViewModel.PanX}" Y="{Binding PanZoomViewModel.PanY}" />
|
||||
</TransformGroup>
|
||||
</Grid.RenderTransform>
|
||||
<ItemsControl ItemsSource="{Binding Devices}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Canvas />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemContainerStyle>
|
||||
<Style TargetType="ContentPresenter">
|
||||
<Setter Property="Canvas.Left" Value="{Binding X}" />
|
||||
<Setter Property="Canvas.Top" Value="{Binding Y}" />
|
||||
</Style>
|
||||
</ItemsControl.ItemContainerStyle>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding}" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
|
||||
<StackPanel ZIndex="1" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="10">
|
||||
<materialDesign:Card Padding="8">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}" IsChecked="{Binding HighlightSelectedLayer.Value}">
|
||||
Highlight selected layer
|
||||
</CheckBox>
|
||||
<CheckBox Style="{StaticResource MaterialDesignCheckBox}" Margin="10 0 0 0" IsChecked="{Binding PauseRenderingOnFocusLoss.Value}">
|
||||
Pause visualization on focus loss
|
||||
</CheckBox>
|
||||
</StackPanel>
|
||||
</materialDesign:Card>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom" HorizontalAlignment="Right"
|
||||
Margin="10" ZIndex="1">
|
||||
<Slider Margin="0,0,14,0"
|
||||
Orientation="Vertical"
|
||||
Minimum="10"
|
||||
Maximum="400"
|
||||
Height="100"
|
||||
FocusVisualStyle="{x:Null}"
|
||||
Value="{Binding PanZoomViewModel.ZoomPercentage}"
|
||||
Style="{StaticResource MaterialDesignDiscreteSlider}" />
|
||||
<Button Command="{s:Action ResetZoomAndPan}"
|
||||
Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
|
||||
HorizontalAlignment="Right"
|
||||
ToolTip="Reset zoom & position">
|
||||
<materialDesign:PackIcon Kind="ImageFilterCenterFocus" Height="24" Width="24" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Loading indicator -->
|
||||
<Grid Background="{StaticResource MaterialDesignPaper}" Style="{StaticResource InitializingFade}" d:IsHidden="True">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
Initializing LED visualization...
|
||||
</TextBlock>
|
||||
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}" Value="0" IsIndeterminate="True" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Core.Events;
|
||||
@ -12,13 +11,11 @@ using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Extensions;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools;
|
||||
using Artemis.UI.Screens.Shared;
|
||||
using Artemis.UI.Screens.SurfaceEditor;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using RGB.NET.Core;
|
||||
using Stylet;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
{
|
||||
@ -29,25 +26,21 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
private readonly ISurfaceService _surfaceService;
|
||||
private TimerUpdateTrigger _updateTrigger;
|
||||
|
||||
public ProfileViewModel(IProfileEditorService profileEditorService,
|
||||
ISurfaceService surfaceService,
|
||||
ISettingsService settingsService,
|
||||
IEventAggregator eventAggregator)
|
||||
public ProfileViewModel(IProfileEditorService profileEditorService, ISurfaceService surfaceService, ISettingsService settingsService, IEventAggregator eventAggregator)
|
||||
{
|
||||
_profileEditorService = profileEditorService;
|
||||
_surfaceService = surfaceService;
|
||||
_settingsService = settingsService;
|
||||
Devices = new ObservableCollection<ProfileDeviceViewModel>();
|
||||
Cursor = null;
|
||||
|
||||
Execute.PostToUIThread(() =>
|
||||
Execute.OnUIThreadSync(() =>
|
||||
{
|
||||
SelectionRectangle = new RectangleGeometry();
|
||||
CanvasViewModels = new ObservableCollection<CanvasViewModel>();
|
||||
PanZoomViewModel = new PanZoomViewModel();
|
||||
});
|
||||
|
||||
ApplySurfaceConfiguration(surfaceService.ActiveSurface);
|
||||
CreateUpdateTrigger();
|
||||
ActivateToolByIndex(0);
|
||||
|
||||
_profileEditorService.SelectedProfileElementChanged += OnSelectedProfileElementChanged;
|
||||
_profileEditorService.SelectedProfileElementUpdated += OnSelectedProfileElementChanged;
|
||||
@ -55,13 +48,42 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
}
|
||||
|
||||
public bool IsInitializing { get; private set; }
|
||||
public ObservableCollection<ProfileDeviceViewModel> Devices { get; set; }
|
||||
public RectangleGeometry SelectionRectangle { get; set; }
|
||||
public ObservableCollection<CanvasViewModel> CanvasViewModels { get; set; }
|
||||
public PanZoomViewModel PanZoomViewModel { get; set; }
|
||||
public PluginSetting<bool> HighlightSelectedLayer { get; set; }
|
||||
public PluginSetting<bool> PauseRenderingOnFocusLoss { get; set; }
|
||||
|
||||
public Cursor Cursor { get; set; }
|
||||
public ReadOnlyCollection<ProfileDeviceViewModel> Devices => CanvasViewModels
|
||||
.Where(vm => vm is ProfileDeviceViewModel)
|
||||
.Cast<ProfileDeviceViewModel>()
|
||||
.ToList()
|
||||
.AsReadOnly();
|
||||
|
||||
public VisualizationToolViewModel ActiveToolViewModel
|
||||
{
|
||||
get => _activeToolViewModel;
|
||||
set
|
||||
{
|
||||
// Remove the tool from the canvas
|
||||
if (_activeToolViewModel != null)
|
||||
CanvasViewModels.Remove(_activeToolViewModel);
|
||||
// Set the new tool
|
||||
_activeToolViewModel = value;
|
||||
// Add the new tool to the canvas
|
||||
if (_activeToolViewModel != null)
|
||||
CanvasViewModels.Add(_activeToolViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
public int ActiveToolIndex
|
||||
{
|
||||
get => _activeToolIndex;
|
||||
set
|
||||
{
|
||||
_activeToolIndex = value;
|
||||
ActivateToolByIndex(value);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateUpdateTrigger()
|
||||
{
|
||||
@ -82,12 +104,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
|
||||
private void ApplySurfaceConfiguration(ArtemisSurface surface)
|
||||
{
|
||||
List<ArtemisDevice> devices;
|
||||
lock (Devices)
|
||||
{
|
||||
devices = new List<ArtemisDevice>();
|
||||
devices.AddRange(surface.Devices);
|
||||
}
|
||||
var devices = new List<ArtemisDevice>();
|
||||
devices.AddRange(surface.Devices);
|
||||
|
||||
// Make sure all devices have an up-to-date VM
|
||||
foreach (var surfaceDeviceConfiguration in devices)
|
||||
@ -102,9 +120,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
{
|
||||
// Gotta call IsInitializing on the UI thread or its never gets picked up
|
||||
IsInitializing = true;
|
||||
lock (Devices)
|
||||
lock (CanvasViewModels)
|
||||
{
|
||||
Devices.Add(profileDeviceViewModel);
|
||||
CanvasViewModels.Add(profileDeviceViewModel);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -112,21 +130,22 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
else
|
||||
viewModel.Device = surfaceDeviceConfiguration;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Sort the devices by ZIndex
|
||||
Execute.PostToUIThread(() =>
|
||||
{
|
||||
lock (Devices)
|
||||
lock (CanvasViewModels)
|
||||
{
|
||||
foreach (var device in Devices.OrderBy(d => d.ZIndex).ToList())
|
||||
Devices.Move(Devices.IndexOf(device), device.ZIndex - 1);
|
||||
CanvasViewModels.Move(CanvasViewModels.IndexOf(device), device.ZIndex - 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateLeds(object sender, CustomUpdateData customUpdateData)
|
||||
{
|
||||
lock (Devices)
|
||||
lock (CanvasViewModels)
|
||||
{
|
||||
if (IsInitializing)
|
||||
IsInitializing = Devices.Any(d => !d.AddedLeds);
|
||||
@ -165,11 +184,83 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
{
|
||||
HighlightSelectedLayer.Save();
|
||||
PauseRenderingOnFocusLoss.Save();
|
||||
|
||||
_updateTrigger.Stop();
|
||||
|
||||
try
|
||||
{
|
||||
_updateTrigger.Stop();
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
// TODO: Remove when fixed in RGB.NET, or avoid double stopping
|
||||
}
|
||||
|
||||
base.OnDeactivate();
|
||||
}
|
||||
|
||||
#region Buttons
|
||||
|
||||
private void ActivateToolByIndex(int value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 0:
|
||||
ActiveToolViewModel = new ViewpointMoveToolViewModel(this, _profileEditorService);
|
||||
break;
|
||||
case 1:
|
||||
ActiveToolViewModel = new SelectionToolViewModel(this, _profileEditorService);
|
||||
break;
|
||||
case 2:
|
||||
ActiveToolViewModel = new SelectionAddToolViewModel(this, _profileEditorService);
|
||||
break;
|
||||
case 3:
|
||||
ActiveToolViewModel = new SelectionRemoveToolViewModel(this, _profileEditorService);
|
||||
break;
|
||||
case 4:
|
||||
ActiveToolViewModel = new EllipseToolViewModel(this, _profileEditorService);
|
||||
break;
|
||||
case 5:
|
||||
ActiveToolViewModel = new RectangleToolViewModel(this, _profileEditorService);
|
||||
break;
|
||||
case 6:
|
||||
ActiveToolViewModel = new PolygonToolViewModel(this, _profileEditorService);
|
||||
break;
|
||||
case 7:
|
||||
ActiveToolViewModel = new FillToolViewModel(this, _profileEditorService);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetZoomAndPan()
|
||||
{
|
||||
PanZoomViewModel.Reset();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mouse
|
||||
|
||||
public void CanvasMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ActiveToolViewModel?.MouseDown(sender, e);
|
||||
}
|
||||
|
||||
public void CanvasMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
ActiveToolViewModel?.MouseUp(sender, e);
|
||||
}
|
||||
|
||||
public void CanvasMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
ActiveToolViewModel?.MouseMove(sender, e);
|
||||
}
|
||||
|
||||
public void CanvasMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
ActiveToolViewModel?.MouseWheel(sender, e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Context menu actions
|
||||
|
||||
public bool CanApplyToLayer { get; set; }
|
||||
@ -209,123 +300,23 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
|
||||
#endregion
|
||||
|
||||
#region Selection
|
||||
#region Keys
|
||||
|
||||
private MouseDragStatus _mouseDragStatus;
|
||||
private Point _mouseDragStartPoint;
|
||||
private int _previousTool;
|
||||
private int _activeToolIndex;
|
||||
private VisualizationToolViewModel _activeToolViewModel;
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void EditorGridMouseClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (IsPanKeyDown() || e.ChangedButton == MouseButton.Right)
|
||||
return;
|
||||
|
||||
var position = e.GetPosition((IInputElement) sender);
|
||||
var relative = PanZoomViewModel.GetRelativeMousePosition(sender, e);
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
StartMouseDrag(position, relative);
|
||||
else
|
||||
StopMouseDrag(position);
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void EditorGridMouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
// If holding down Ctrl, pan instead of move/select
|
||||
if (IsPanKeyDown())
|
||||
{
|
||||
Pan(sender, e);
|
||||
return;
|
||||
}
|
||||
|
||||
var position = e.GetPosition((IInputElement) sender);
|
||||
if (_mouseDragStatus == MouseDragStatus.Selecting)
|
||||
UpdateSelection(position);
|
||||
}
|
||||
|
||||
private void StartMouseDrag(Point position, Point relative)
|
||||
{
|
||||
_mouseDragStatus = MouseDragStatus.Selecting;
|
||||
_mouseDragStartPoint = position;
|
||||
|
||||
// Any time dragging starts, start with a new rect
|
||||
SelectionRectangle.Rect = new Rect();
|
||||
}
|
||||
|
||||
private void StopMouseDrag(Point position)
|
||||
{
|
||||
var selectedRect = new Rect(_mouseDragStartPoint, position);
|
||||
foreach (var device in Devices)
|
||||
{
|
||||
foreach (var profileLedViewModel in device.Leds)
|
||||
{
|
||||
if (PanZoomViewModel.TransformContainingRect(profileLedViewModel.Led.RgbLed.AbsoluteLedRectangle.ToWindowsRect(1)).IntersectsWith(selectedRect))
|
||||
profileLedViewModel.IsSelected = true;
|
||||
else if (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift))
|
||||
profileLedViewModel.IsSelected = false;
|
||||
}
|
||||
}
|
||||
|
||||
_mouseDragStatus = MouseDragStatus.None;
|
||||
}
|
||||
|
||||
private void UpdateSelection(Point position)
|
||||
{
|
||||
if (IsPanKeyDown())
|
||||
return;
|
||||
|
||||
var selectedRect = new Rect(_mouseDragStartPoint, position);
|
||||
SelectionRectangle.Rect = selectedRect;
|
||||
|
||||
foreach (var device in Devices)
|
||||
{
|
||||
foreach (var profileLedViewModel in device.Leds)
|
||||
{
|
||||
if (PanZoomViewModel.TransformContainingRect(profileLedViewModel.Led.RgbLed.AbsoluteLedRectangle.ToWindowsRect(1)).IntersectsWith(selectedRect))
|
||||
profileLedViewModel.IsSelected = true;
|
||||
else if (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift))
|
||||
profileLedViewModel.IsSelected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Panning and zooming
|
||||
|
||||
public void EditorGridMouseWheel(object sender, MouseWheelEventArgs e)
|
||||
{
|
||||
PanZoomViewModel.ProcessMouseScroll(sender, e);
|
||||
}
|
||||
|
||||
public void EditorGridKeyDown(object sender, KeyEventArgs e)
|
||||
public void CanvasKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
_previousTool = ActiveToolIndex;
|
||||
if ((e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl) && e.IsDown)
|
||||
Cursor = Cursors.ScrollAll;
|
||||
ActiveToolViewModel = new ViewpointMoveToolViewModel(this, _profileEditorService);
|
||||
}
|
||||
|
||||
public void EditorGridKeyUp(object sender, KeyEventArgs e)
|
||||
public void CanvasKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if ((e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl) && e.IsUp)
|
||||
Cursor = null;
|
||||
}
|
||||
|
||||
public void Pan(object sender, MouseEventArgs e)
|
||||
{
|
||||
PanZoomViewModel.ProcessMouseMove(sender, e);
|
||||
|
||||
// Empty the selection rect since it's shown while mouse is down
|
||||
SelectionRectangle.Rect = Rect.Empty;
|
||||
}
|
||||
|
||||
public void ResetZoomAndPan()
|
||||
{
|
||||
PanZoomViewModel.Reset();
|
||||
}
|
||||
|
||||
private bool IsPanKeyDown()
|
||||
{
|
||||
return Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl);
|
||||
ActivateToolByIndex(_previousTool);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -348,10 +339,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
||||
if (PauseRenderingOnFocusLoss == null || ScreenState != ScreenState.Active)
|
||||
return;
|
||||
|
||||
if (PauseRenderingOnFocusLoss.Value && !message.IsFocused)
|
||||
_updateTrigger.Stop();
|
||||
else if (PauseRenderingOnFocusLoss.Value && message.IsFocused)
|
||||
_updateTrigger.Start();
|
||||
try
|
||||
{
|
||||
if (PauseRenderingOnFocusLoss.Value && !message.IsFocused)
|
||||
_updateTrigger.Stop();
|
||||
else if (PauseRenderingOnFocusLoss.Value && message.IsFocused)
|
||||
_updateTrigger.Start();
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
// TODO: Remove when fixed in RGB.NET, or avoid double stopping
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools.EllipseToolView"
|
||||
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.Visualization.Tools"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Canvas>
|
||||
<Canvas.Triggers>
|
||||
<EventTrigger RoutedEvent="Canvas.MouseLeftButtonDown">
|
||||
<BeginStoryboard>
|
||||
<Storyboard TargetName="Preview" TargetProperty="Opacity">
|
||||
<DoubleAnimation From="0" To="1" Duration="0:0:0.1" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
<EventTrigger RoutedEvent="Canvas.MouseLeftButtonUp">
|
||||
<BeginStoryboard>
|
||||
<Storyboard TargetName="Preview" TargetProperty="Opacity">
|
||||
<DoubleAnimation From="1" To="0" Duration="0:0:0.2" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger>
|
||||
</Canvas.Triggers>
|
||||
<Canvas.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Ellipse action 1" Command="{s:Action CreateLayer}" CommandParameter="{Binding}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="LayersPlus" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Ellipse action 2" Command="{s:Action ApplyToLayer}" CommandParameter="{Binding}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="Selection" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</Canvas.ContextMenu>
|
||||
<Ellipse Stroke="{DynamicResource PrimaryHueLightBrush}" StrokeThickness="1" IsHitTestVisible="False" x:Name="Preview" Opacity="1" Width="100" Height="100">
|
||||
<Ellipse.Fill>
|
||||
<SolidColorBrush Color="{DynamicResource Primary400}" Opacity="0.25" />
|
||||
</Ellipse.Fill>
|
||||
</Ellipse>
|
||||
</Canvas>
|
||||
</UserControl>
|
||||
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for EllipseToolView.xaml
|
||||
/// </summary>
|
||||
public partial class EllipseToolView : UserControl
|
||||
{
|
||||
public EllipseToolView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
using System.IO;
|
||||
using System.Windows.Input;
|
||||
using Artemis.UI.Properties;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
public class EllipseToolViewModel : VisualizationToolViewModel
|
||||
{
|
||||
public EllipseToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
|
||||
{
|
||||
using (var stream = new MemoryStream(Resources.aero_crosshair))
|
||||
{
|
||||
Cursor = new Cursor(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools.FillToolView"
|
||||
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.Visualization.Tools"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
</UserControl>
|
||||
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for FillToolView.xaml
|
||||
/// </summary>
|
||||
public partial class FillToolView : UserControl
|
||||
{
|
||||
public FillToolView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core.Models.Profile.LayerShapes;
|
||||
using Artemis.UI.Properties;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
public class FillToolViewModel : VisualizationToolViewModel
|
||||
{
|
||||
public FillToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
|
||||
{
|
||||
using (var stream = new MemoryStream(Resources.aero_fill))
|
||||
{
|
||||
Cursor = new Cursor(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public override void MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
base.MouseUp(sender, e);
|
||||
|
||||
// Find out if the click is inside a layer and if so, fill it
|
||||
var position = e.GetPosition((IInputElement) sender);
|
||||
var panZoomVm = ProfileViewModel.PanZoomViewModel;
|
||||
|
||||
var layer = ProfileEditorService.SelectedProfile
|
||||
.GetAllLayers()
|
||||
.FirstOrDefault(l => l.Leds.Any(
|
||||
led => panZoomVm.TransformContainingRect(led.RgbLed.AbsoluteLedRectangle).Contains(position))
|
||||
);
|
||||
|
||||
if (layer != null)
|
||||
layer.LayerShape = new Fill(layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools.PolygonToolView"
|
||||
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.Visualization.Tools"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for PolygonToolView.xaml
|
||||
/// </summary>
|
||||
public partial class PolygonToolView : UserControl
|
||||
{
|
||||
public PolygonToolView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
using System.IO;
|
||||
using System.Windows.Input;
|
||||
using Artemis.UI.Properties;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
public class PolygonToolViewModel : VisualizationToolViewModel
|
||||
{
|
||||
public PolygonToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
|
||||
{
|
||||
using (var stream = new MemoryStream(Resources.aero_crosshair))
|
||||
{
|
||||
Cursor = new Cursor(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools.RectangleToolView"
|
||||
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.Visualization.Tools"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for RectangleToolView.xaml
|
||||
/// </summary>
|
||||
public partial class RectangleToolView : UserControl
|
||||
{
|
||||
public RectangleToolView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
using System.IO;
|
||||
using System.Windows.Input;
|
||||
using Artemis.UI.Properties;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
public class RectangleToolViewModel : VisualizationToolViewModel
|
||||
{
|
||||
public RectangleToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
|
||||
{
|
||||
using (var stream = new MemoryStream(Resources.aero_crosshair))
|
||||
{
|
||||
Cursor = new Cursor(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools.SelectionAddToolView"
|
||||
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.Visualization.Tools"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SelectionAddToolView.xaml
|
||||
/// </summary>
|
||||
public partial class SelectionAddToolView : UserControl
|
||||
{
|
||||
public SelectionAddToolView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Artemis.UI.Properties;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
|
||||
{
|
||||
public class SelectionAddToolViewModel : VisualizationToolViewModel
|
||||
{
|
||||
public SelectionAddToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
|
||||
{
|
||||
using (var stream = new MemoryStream(Resources.aero_pen_plus))
|
||||
{
|
||||
Cursor = new Cursor(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public override void MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
base.MouseUp(sender, e);
|
||||
|
||||
var position = e.GetPosition((IInputElement) sender);
|
||||
var selectedRect = new Rect(MouseDownStartPosition, position);
|
||||
|
||||
foreach (var device in ProfileViewModel.Devices)
|
||||
{
|
||||
foreach (var ledViewModel in device.Leds)
|
||||
{
|
||||
if (ProfileViewModel.PanZoomViewModel.TransformContainingRect(ledViewModel.Led.RgbLed.AbsoluteLedRectangle).IntersectsWith(selectedRect))
|
||||
ledViewModel.IsSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user