diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj
index cc39b8ccf..f2ba363af 100644
--- a/Artemis/Artemis/Artemis.csproj
+++ b/Artemis/Artemis/Artemis.csproj
@@ -330,6 +330,11 @@
+
+
+ KeyPressPropertiesView.xaml
+
+
@@ -740,6 +745,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
diff --git a/Artemis/Artemis/ArtemisBootstrapper.cs b/Artemis/Artemis/ArtemisBootstrapper.cs
index 8f412eaf1..d0aec9007 100644
--- a/Artemis/Artemis/ArtemisBootstrapper.cs
+++ b/Artemis/Artemis/ArtemisBootstrapper.cs
@@ -5,8 +5,6 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using Artemis.InjectionModules;
-using Artemis.Profiles.Layers.Interfaces;
-using Artemis.Profiles.Layers.Types.KeyPress;
using Artemis.Settings;
using Artemis.Utilities;
using Artemis.Utilities.Converters;
diff --git a/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressPropertiesModel.cs b/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressPropertiesModel.cs
new file mode 100644
index 000000000..4b2358fa7
--- /dev/null
+++ b/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressPropertiesModel.cs
@@ -0,0 +1,14 @@
+using Artemis.Profiles.Layers.Models;
+
+namespace Artemis.Profiles.Layers.Types.KeyPress
+{
+ public class KeyPressPropertiesModel : LayerPropertiesModel
+ {
+ public KeyPressPropertiesModel(LayerPropertiesModel properties) : base(properties)
+ {
+ }
+
+ public int Scale { get; set; }
+ public bool RandomColor { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressPropertiesView.xaml b/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressPropertiesView.xaml
new file mode 100644
index 000000000..68b8d3787
--- /dev/null
+++ b/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressPropertiesView.xaml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressPropertiesView.xaml.cs b/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressPropertiesView.xaml.cs
new file mode 100644
index 000000000..7b2f0b055
--- /dev/null
+++ b/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressPropertiesView.xaml.cs
@@ -0,0 +1,15 @@
+using System.Windows.Controls;
+
+namespace Artemis.Profiles.Layers.Types.KeyPress
+{
+ ///
+ /// Interaction logic for KeyPressPropertiesView.xaml
+ ///
+ public partial class KeyPressPropertiesView : UserControl
+ {
+ public KeyPressPropertiesView()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressPropertiesViewModel.cs b/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressPropertiesViewModel.cs
new file mode 100644
index 000000000..6ea9c2e6c
--- /dev/null
+++ b/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressPropertiesViewModel.cs
@@ -0,0 +1,18 @@
+using Artemis.Models.Interfaces;
+using Artemis.Profiles.Layers.Abstract;
+using Artemis.Profiles.Layers.Models;
+
+namespace Artemis.Profiles.Layers.Types.KeyPress
+{
+ public class KeyPressPropertiesViewModel : LayerPropertiesViewModel
+ {
+ public KeyPressPropertiesViewModel(LayerModel layerModel, IDataModel dataModel) : base(layerModel, dataModel)
+ {
+ }
+
+ public override void ApplyProperties()
+ {
+ LayerModel.Properties.Brush = Brush;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressType.cs b/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressType.cs
index 249f4140e..de4c1e3b4 100644
--- a/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressType.cs
+++ b/Artemis/Artemis/Profiles/Layers/Types/KeyPress/KeyPressType.cs
@@ -9,7 +9,6 @@ using Artemis.Profiles.Layers.Abstract;
using Artemis.Profiles.Layers.Animations;
using Artemis.Profiles.Layers.Interfaces;
using Artemis.Profiles.Layers.Models;
-using Artemis.Profiles.Layers.Types.Generic;
using Artemis.Properties;
using Artemis.Utilities;
using Artemis.Utilities.Keyboard;
@@ -20,7 +19,7 @@ namespace Artemis.Profiles.Layers.Types.KeyPress
{
private readonly MainManager _mainManager;
private List _keyPressLayers = new List();
- private LayerPropertiesModel _properties;
+ private KeyPressPropertiesModel _properties;
public KeyPressType(MainManager mainManager)
{
@@ -64,7 +63,7 @@ namespace Artemis.Profiles.Layers.Types.KeyPress
layerModel.Properties.Y = 0;
layerModel.Properties.Contain = true;
- _properties = layerModel.Properties;
+ _properties = (KeyPressPropertiesModel) layerModel.Properties;
lock (_keyPressLayers)
{
@@ -78,18 +77,18 @@ namespace Artemis.Profiles.Layers.Types.KeyPress
public void SetupProperties(LayerModel layerModel)
{
- if (layerModel.Properties is SimplePropertiesModel)
+ if (layerModel.Properties is KeyPressPropertiesModel)
return;
- layerModel.Properties = new SimplePropertiesModel(layerModel.Properties);
+ layerModel.Properties = new KeyPressPropertiesModel(layerModel.Properties);
}
public LayerPropertiesViewModel SetupViewModel(LayerPropertiesViewModel layerPropertiesViewModel,
List layerAnimations, IDataModel dataModel, LayerModel proposedLayer)
{
- if (layerPropertiesViewModel is GenericPropertiesViewModel)
+ if (layerPropertiesViewModel is KeyPressPropertiesViewModel)
return layerPropertiesViewModel;
- return new GenericPropertiesViewModel(proposedLayer, dataModel, layerAnimations);
+ return new KeyPressPropertiesViewModel(proposedLayer, dataModel);
}
private void KeyboardHookOnKeyDownCallback(KeyEventArgs e)
@@ -104,15 +103,18 @@ namespace Artemis.Profiles.Layers.Types.KeyPress
lock (_keyPressLayers)
{
var layer = LayerModel.CreateLayer();
- layer.Properties.Brush = _properties.Brush.CloneCurrentValue();
- layer.Properties.X = keyMatch.Value.X - 3;
- layer.Properties.Y = keyMatch.Value.Y - 3;
- layer.Properties.Width = 6;
- layer.Properties.Height = 6;
-
- layer.Properties.AnimationSpeed = 1;
+ layer.Properties.X = keyMatch.Value.X - _properties.Scale/2;
+ layer.Properties.Y = keyMatch.Value.Y - _properties.Scale/2;
+ layer.Properties.Width = _properties.Scale;
+ layer.Properties.Height = _properties.Scale;
+ layer.Properties.AnimationSpeed = _properties.AnimationSpeed;
layer.LayerAnimation = new GrowAnimation();
+ // Setup the brush according to settings
+ layer.Properties.Brush = _properties.RandomColor
+ ? ColorHelpers.RandomizeBrush(_properties.Brush)
+ : _properties.Brush.CloneCurrentValue();
+
_keyPressLayers.Add(layer);
}
}
diff --git a/Artemis/Artemis/Utilities/ColorHelpers.cs b/Artemis/Artemis/Utilities/ColorHelpers.cs
index 0a28d5a77..a4d21dc72 100644
--- a/Artemis/Artemis/Utilities/ColorHelpers.cs
+++ b/Artemis/Artemis/Utilities/ColorHelpers.cs
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
-using System.Drawing;
using System.Linq;
+using System.Windows.Media;
+using Brush = System.Windows.Media.Brush;
+using Color = System.Drawing.Color;
namespace Artemis.Utilities
{
@@ -96,5 +98,35 @@ namespace Artemis.Utilities
{
return System.Windows.Media.Color.FromArgb(dColor.A, dColor.R, dColor.G, dColor.B);
}
+
+ public static Brush RandomizeBrush(Brush brush)
+ {
+ if (brush is SolidColorBrush)
+ {
+ return new SolidColorBrush(GetRandomRainbowMediaColor());
+ }
+
+ if (brush is LinearGradientBrush)
+ {
+ var randomBrush = (LinearGradientBrush) brush.CloneCurrentValue();
+ var rand = GetRandomRainbowMediaColor();
+ foreach (var stop in randomBrush.GradientStops)
+ stop.Color = System.Windows.Media.Color.FromArgb(stop.Color.A, rand.R, rand.G, rand.B);
+
+ return randomBrush;
+ }
+
+ if (brush is RadialGradientBrush)
+ {
+ var randomBrush = (RadialGradientBrush)brush.CloneCurrentValue();
+ var rand = GetRandomRainbowMediaColor();
+ foreach (var stop in randomBrush.GradientStops)
+ stop.Color = System.Windows.Media.Color.FromArgb(stop.Color.A, rand.R, rand.G, rand.B);
+
+ return randomBrush;
+ }
+
+ return brush;
+ }
}
}
\ No newline at end of file