diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj
index abe4a03ae..c5b07ade1 100644
--- a/Artemis/Artemis/Artemis.csproj
+++ b/Artemis/Artemis/Artemis.csproj
@@ -267,6 +267,7 @@
+
@@ -498,8 +499,8 @@
ResXFileCodeGenerator
- Resources.Designer.cs
Designer
+ Resources.Designer.cs
SettingsSingleFileGenerator
@@ -546,6 +547,10 @@
+
+
+
+
diff --git a/Artemis/Artemis/ArtemisBootstrapper.cs b/Artemis/Artemis/ArtemisBootstrapper.cs
index 2db81902e..d9d09728f 100644
--- a/Artemis/Artemis/ArtemisBootstrapper.cs
+++ b/Artemis/Artemis/ArtemisBootstrapper.cs
@@ -1,6 +1,7 @@
using System.Diagnostics;
using System.Linq;
using System.Windows;
+using System.Windows.Controls;
using System.Windows.Forms;
using Artemis.ViewModels;
using Autofac;
@@ -18,6 +19,47 @@ namespace Artemis
CheckDuplicateInstances();
Initialize();
+
+ MessageBinder.SpecialValues.Add("$scaledmousex", (ctx) =>
+ {
+ var img = ctx.Source as Image;
+ var input = ctx.Source as IInputElement;
+ var e = ctx.EventArgs as System.Windows.Input.MouseEventArgs;
+
+ // If there is an image control, get the scaled position
+ if (img != null && e != null)
+ {
+ Point position = e.GetPosition(img);
+ return (int)(img.Source.Width * (position.X / img.ActualWidth));
+ }
+
+ // If there is another type of of IInputControl get the non-scaled position - or do some processing to get a scaled position, whatever needs to happen
+ if (e != null && input != null)
+ return e.GetPosition(input).X;
+
+ // Return 0 if no processing could be done
+ return 0;
+ });
+ MessageBinder.SpecialValues.Add("$scaledmousey", (ctx) =>
+ {
+ var img = ctx.Source as Image;
+ var input = ctx.Source as IInputElement;
+ var e = ctx.EventArgs as System.Windows.Input.MouseEventArgs;
+
+ // If there is an image control, get the scaled position
+ if (img != null && e != null)
+ {
+ Point position = e.GetPosition(img);
+ return (int)(img.Source.Width * (position.Y / img.ActualWidth));
+ }
+
+ // If there is another type of of IInputControl get the non-scaled position - or do some processing to get a scaled position, whatever needs to happen
+ if (e != null && input != null)
+ return e.GetPosition(input).Y;
+
+ // Return 0 if no processing could be done
+ return 0;
+ });
}
protected override void ConfigureContainer(ContainerBuilder builder)
@@ -45,5 +87,6 @@ namespace Artemis
"Artemis (╯°□°)╯︵ ┻━┻", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Application.Current.Shutdown();
}
+
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Events/ActiveKeyboardChanged.cs b/Artemis/Artemis/Events/ActiveKeyboardChanged.cs
new file mode 100644
index 000000000..fb123dd86
--- /dev/null
+++ b/Artemis/Artemis/Events/ActiveKeyboardChanged.cs
@@ -0,0 +1,12 @@
+namespace Artemis.Events
+{
+ public class ActiveKeyboardChanged
+ {
+ public ActiveKeyboardChanged(string activeKeyboard)
+ {
+ ActiveKeyboard = activeKeyboard;
+ }
+
+ public string ActiveKeyboard { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs
index f064dc811..2802ebf11 100644
--- a/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs
+++ b/Artemis/Artemis/KeyboardProviders/Corsair/CorsairRGB.cs
@@ -1,20 +1,22 @@
using System.Collections.Generic;
using System.Drawing;
using System.Threading;
+using System.Windows;
+using Artemis.Properties;
using Artemis.Utilities;
using CUE.NET;
using CUE.NET.Brushes;
using CUE.NET.Devices.Generic.Enums;
-using CUE.NET.Devices.Headset;
using CUE.NET.Devices.Keyboard;
-using CUE.NET.Devices.Mouse;
using CUE.NET.Exceptions;
+using Point = System.Drawing.Point;
namespace Artemis.KeyboardProviders.Corsair
{
internal class CorsairRGB : KeyboardProvider
{
private CorsairKeyboard _keyboard;
+
public CorsairRGB()
{
Name = "Corsair RGB Keyboards";
@@ -74,6 +76,7 @@ namespace Artemis.KeyboardProviders.Corsair
case "K95 RGB":
Height = 7;
Width = 25;
+ PreviewSettings = new PreviewSettings(626, 175, new Thickness(0,-15,0,0), Resources.k95);
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 1), new Point(20, 1)));
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(21, 2), new Point(25, 7)));
KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(5, 3), new Point(8, 3)));
@@ -81,6 +84,7 @@ namespace Artemis.KeyboardProviders.Corsair
case "K70 RGB":
Height = 7;
Width = 21;
+ PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.k70);
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 1), new Point(18, 1)));
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(17, 2), new Point(21, 7)));
KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(2, 3), new Point(5, 3)));
@@ -88,16 +92,18 @@ namespace Artemis.KeyboardProviders.Corsair
case "K65 RGB":
Height = 7;
Width = 18;
+ PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.k65);
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 1), new Point(18, 1)));
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(17, 2), new Point(20, 7)));
KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(2, 3), new Point(5, 3)));
break;
case "STRAFE RGB":
Height = 6;
+ Width = 22;
+ PreviewSettings = new PreviewSettings(626, 175, new Thickness(0, -15, 0, 0), Resources.strafe);
KeyboardRegions.Add(new KeyboardRegion("TopRow", new Point(0, 1), new Point(18, 1)));
KeyboardRegions.Add(new KeyboardRegion("NumPad", new Point(18, 2), new Point(22, 7)));
KeyboardRegions.Add(new KeyboardRegion("QWER", new Point(1, 3), new Point(4, 3)));
- Width = 22;
break;
}
}
@@ -106,7 +112,7 @@ namespace Artemis.KeyboardProviders.Corsair
{
CueSDK.Reinitialize();
}
-
+
///
/// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap
/// size.
@@ -118,7 +124,7 @@ namespace Artemis.KeyboardProviders.Corsair
using (var g = Graphics.FromImage(fixedBmp))
{
g.Clear(Color.Black);
- g.DrawImage(bitmap, 0,0);
+ g.DrawImage(bitmap, 0, 0);
}
var fixedImage = ImageUtilities.ResizeImage(fixedBmp, Width, Height);
@@ -131,4 +137,4 @@ namespace Artemis.KeyboardProviders.Corsair
_keyboard.Update();
}
}
-}
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/KeyboardProviders/KeyboardProvider.cs b/Artemis/Artemis/KeyboardProviders/KeyboardProvider.cs
index 022cab79f..746163184 100644
--- a/Artemis/Artemis/KeyboardProviders/KeyboardProvider.cs
+++ b/Artemis/Artemis/KeyboardProviders/KeyboardProvider.cs
@@ -14,6 +14,8 @@ namespace Artemis.KeyboardProviders
public List KeyboardRegions { get; set; }
+ public PreviewSettings PreviewSettings { get; set; }
+
public abstract bool CanEnable();
public abstract void Enable();
public abstract void Disable();
@@ -33,4 +35,20 @@ namespace Artemis.KeyboardProviders
public Rect KeyboardRectangle(int scale) => new Rect(new Size(Width*scale, Height*scale));
}
+
+ public struct PreviewSettings
+ {
+ public int Width { get; set; }
+ public int Height { get; set; }
+ public Thickness Margin { get; set; }
+ public Bitmap Image { get; set; }
+
+ public PreviewSettings(int width, int height, Thickness margin, Bitmap image)
+ {
+ Width = width;
+ Height = height;
+ Margin = margin;
+ Image = image;
+ }
+ }
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Managers/EffectManager.cs b/Artemis/Artemis/Managers/EffectManager.cs
index 5ae38a048..f7b639406 100644
--- a/Artemis/Artemis/Managers/EffectManager.cs
+++ b/Artemis/Artemis/Managers/EffectManager.cs
@@ -14,6 +14,7 @@ namespace Artemis.Managers
private readonly MainManager _mainManager;
private bool _clearing;
private EffectModel _pauseEffect;
+ private EffectModel _activeEffect;
public EffectManager(MainManager mainManager, IEventAggregator events)
{
@@ -24,7 +25,16 @@ namespace Artemis.Managers
}
public List EffectModels { get; set; }
- public EffectModel ActiveEffect { get; private set; }
+
+ public EffectModel ActiveEffect
+ {
+ get { return _activeEffect; }
+ private set
+ {
+ _activeEffect = value;
+ _events.PublishOnUIThread(new ActiveEffectChanged(value?.Name));
+ }
+ }
public IEnumerable EnabledOverlays
{
@@ -101,7 +111,7 @@ namespace Artemis.Managers
ActiveEffect.Enable();
// Let the ViewModels know
- _events.PublishOnUIThread(new ActiveEffectChanged(ActiveEffect.Name));
+ //_events.PublishOnUIThread(new ActiveEffectChanged(ActiveEffect.Name));
_mainManager.Unpause();
_pauseEffect = null;
@@ -143,7 +153,7 @@ namespace Artemis.Managers
General.Default.LastEffect = null;
General.Default.Save();
- _events.PublishOnUIThread(new ActiveEffectChanged(""));
+ //_events.PublishOnUIThread(new ActiveEffectChanged(""));
_clearing = false;
_mainManager.Unpause();
diff --git a/Artemis/Artemis/Managers/KeyboardManager.cs b/Artemis/Artemis/Managers/KeyboardManager.cs
index f6e7c9d1f..cc0463332 100644
--- a/Artemis/Artemis/Managers/KeyboardManager.cs
+++ b/Artemis/Artemis/Managers/KeyboardManager.cs
@@ -1,23 +1,37 @@
using System.Collections.Generic;
using System.Linq;
-using System.Windows.Forms;
+using Artemis.Events;
using Artemis.KeyboardProviders;
using Artemis.Settings;
+using Caliburn.Micro;
namespace Artemis.Managers
{
public class KeyboardManager
{
+ private readonly IEventAggregator _events;
private readonly MainManager _mainManager;
+ private KeyboardProvider _activeKeyboard;
- public KeyboardManager(MainManager mainManager)
+ public KeyboardManager(MainManager mainManager, IEventAggregator events)
{
_mainManager = mainManager;
+ _events = events;
KeyboardProviders = ProviderHelper.GetKeyboardProviders();
}
public List KeyboardProviders { get; set; }
- public KeyboardProvider ActiveKeyboard { get; set; }
+
+ public KeyboardProvider ActiveKeyboard
+ {
+ get { return _activeKeyboard; }
+ set
+ {
+ _activeKeyboard = value;
+ // Let the ViewModels know
+ _events.PublishOnUIThread(new ActiveKeyboardChanged(value?.Name));
+ }
+ }
///
/// Enables the last keyboard according to the settings file
diff --git a/Artemis/Artemis/Managers/MainManager.cs b/Artemis/Artemis/Managers/MainManager.cs
index 0df082f1a..745b91b15 100644
--- a/Artemis/Artemis/Managers/MainManager.cs
+++ b/Artemis/Artemis/Managers/MainManager.cs
@@ -25,7 +25,7 @@ namespace Artemis.Managers
Events = events;
DialogService = dialogService;
- KeyboardManager = new KeyboardManager(this);
+ KeyboardManager = new KeyboardManager(this, Events);
EffectManager = new EffectManager(this, Events);
KeyboardHook = new KeyboardHook();
diff --git a/Artemis/Artemis/Models/Profiles/LayerModel.cs b/Artemis/Artemis/Models/Profiles/LayerModel.cs
index a6f3bede5..971e874b2 100644
--- a/Artemis/Artemis/Models/Profiles/LayerModel.cs
+++ b/Artemis/Artemis/Models/Profiles/LayerModel.cs
@@ -26,8 +26,9 @@ namespace Artemis.Models.Profiles
public string Name { get; set; }
public LayerType LayerType { get; set; }
+ public bool Enabled { get; set; }
public LayerPropertiesModel LayerUserProperties { get; set; }
-
+
public List Children { get; set; }
public List LayerConditions { get; set; }
public List LayerProperties { get; set; }
@@ -40,11 +41,12 @@ namespace Artemis.Models.Profiles
public bool ConditionsMet(IGameDataModel dataModel)
{
- return LayerConditions.All(cm => cm.ConditionMet(dataModel));
+ return Enabled && LayerConditions.All(cm => cm.ConditionMet(dataModel));
}
public void DrawPreview(DrawingContext c)
{
+ GeneralHelpers.CopyProperties(LayerCalculatedProperties, LayerUserProperties);
if (LayerType == LayerType.KeyboardRectangle || LayerType == LayerType.KeyboardEllipse)
_drawer.Draw(c);
else if (LayerType == LayerType.KeyboardGif)
diff --git a/Artemis/Artemis/Models/Profiles/LayerPropertiesModel.cs b/Artemis/Artemis/Models/Profiles/LayerPropertiesModel.cs
index df28efcde..4f8feadae 100644
--- a/Artemis/Artemis/Models/Profiles/LayerPropertiesModel.cs
+++ b/Artemis/Artemis/Models/Profiles/LayerPropertiesModel.cs
@@ -13,7 +13,7 @@ namespace Artemis.Models.Profiles
public int Y { get; set; }
public int Width { get; set; }
public int Height { get; set; }
- public int Opacity { get; set; }
+ public double Opacity { get; set; }
public bool ContainedBrush { get; set; }
public LayerAnimation Animation { get; set; }
public double AnimationSpeed { get; set; }
diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs
index 9c6d232de..381a7fd44 100644
--- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs
+++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeModel.cs
@@ -1,4 +1,5 @@
-using System.Drawing;
+using System.Diagnostics;
+using System.Drawing;
using System.Windows.Media;
using Artemis.Managers;
using Artemis.Models;
@@ -88,6 +89,8 @@ namespace Artemis.Modules.Games.CounterStrike
if (!jsonString.Contains("Counter-Strike: Global Offensive"))
return;
+ Debug.WriteLine("Received data");
+
// Parse the JSON
GameDataModel = JsonConvert.DeserializeObject(jsonString);
}
diff --git a/Artemis/Artemis/Properties/Resources.Designer.cs b/Artemis/Artemis/Properties/Resources.Designer.cs
index a9c2117a7..2d53d553d 100644
--- a/Artemis/Artemis/Properties/Resources.Designer.cs
+++ b/Artemis/Artemis/Properties/Resources.Designer.cs
@@ -91,10 +91,7 @@ namespace Artemis.Properties {
/// Looks up a localized string similar to "Artemis"
///{
/// "uri" "http://localhost:{{port}}/csgo_game_event"
- /// "timeout" "5.0"
- /// "buffer" "0.1"
- /// "throttle" "0.1"
- /// "heartbeat" "30.0"
+ /// "timeout" "0.1"
/// "data"
/// {
/// "provider" "1"
@@ -148,6 +145,36 @@ namespace Artemis.Properties {
}
}
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap k65 {
+ get {
+ object obj = ResourceManager.GetObject("k65", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap k70 {
+ get {
+ object obj = ResourceManager.GetObject("k70", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap k95 {
+ get {
+ object obj = ResourceManager.GetObject("k95", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Byte[].
///
@@ -201,5 +228,15 @@ namespace Artemis.Properties {
return ResourceManager.GetString("playerWitcherWs", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ internal static System.Drawing.Bitmap strafe {
+ get {
+ object obj = ResourceManager.GetObject("strafe", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
}
}
diff --git a/Artemis/Artemis/Properties/Resources.resx b/Artemis/Artemis/Properties/Resources.resx
index bf8569e4d..2033fd6c4 100644
--- a/Artemis/Artemis/Properties/Resources.resx
+++ b/Artemis/Artemis/Properties/Resources.resx
@@ -145,4 +145,16 @@
..\Resources\folder.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ ..\resources\keyboards\k65.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\resources\keyboards\k70.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\resources\keyboards\k95.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\resources\keyboards\strafe.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/Artemis/Artemis/Resources/CounterStrike/csgoGamestateConfiguration.txt b/Artemis/Artemis/Resources/CounterStrike/csgoGamestateConfiguration.txt
index c73502f4b..6263805ee 100644
--- a/Artemis/Artemis/Resources/CounterStrike/csgoGamestateConfiguration.txt
+++ b/Artemis/Artemis/Resources/CounterStrike/csgoGamestateConfiguration.txt
@@ -1,10 +1,7 @@
"Artemis"
{
"uri" "http://localhost:{{port}}/csgo_game_event"
- "timeout" "5.0"
- "buffer" "0.1"
- "throttle" "0.1"
- "heartbeat" "30.0"
+ "timeout" "0.1"
"data"
{
"provider" "1"
diff --git a/Artemis/Artemis/Resources/Keyboards/k65.png b/Artemis/Artemis/Resources/Keyboards/k65.png
new file mode 100644
index 000000000..da6d7659a
Binary files /dev/null and b/Artemis/Artemis/Resources/Keyboards/k65.png differ
diff --git a/Artemis/Artemis/Resources/Keyboards/k70.png b/Artemis/Artemis/Resources/Keyboards/k70.png
new file mode 100644
index 000000000..098d55922
Binary files /dev/null and b/Artemis/Artemis/Resources/Keyboards/k70.png differ
diff --git a/Artemis/Artemis/Resources/Keyboards/k95.png b/Artemis/Artemis/Resources/Keyboards/k95.png
new file mode 100644
index 000000000..03bd7e384
Binary files /dev/null and b/Artemis/Artemis/Resources/Keyboards/k95.png differ
diff --git a/Artemis/Artemis/Resources/Keyboards/strafe.png b/Artemis/Artemis/Resources/Keyboards/strafe.png
new file mode 100644
index 000000000..3aa5d000c
Binary files /dev/null and b/Artemis/Artemis/Resources/Keyboards/strafe.png differ
diff --git a/Artemis/Artemis/Styles/ColorBox.xaml b/Artemis/Artemis/Styles/ColorBox.xaml
index 00e268802..672237b09 100644
--- a/Artemis/Artemis/Styles/ColorBox.xaml
+++ b/Artemis/Artemis/Styles/ColorBox.xaml
@@ -189,7 +189,7 @@
+ MinWidth="250" HorizontalOffset="-1" Placement="Top" PopupAnimation="Fade">
@@ -492,8 +492,7 @@
SelectedGradient="{Binding}"
Margin="0,0,0,2">
-
+
diff --git a/Artemis/Artemis/Utilities/GameState/GameStateWebServer.cs b/Artemis/Artemis/Utilities/GameState/GameStateWebServer.cs
index bfddd675b..dc1d062f3 100644
--- a/Artemis/Artemis/Utilities/GameState/GameStateWebServer.cs
+++ b/Artemis/Artemis/Utilities/GameState/GameStateWebServer.cs
@@ -57,8 +57,8 @@ namespace Artemis.Utilities.GameState
return;
try
{
- var rstr = HandleRequest(ctx.Request);
- var buf = Encoding.UTF8.GetBytes(rstr);
+ HandleRequest(ctx.Request);
+ var buf = Encoding.UTF8.GetBytes("ok");
ctx.Response.ContentLength64 = buf.Length;
ctx.Response.OutputStream.Write(buf, 0, buf.Length);
}
diff --git a/Artemis/Artemis/Utilities/LayerDrawer.cs b/Artemis/Artemis/Utilities/LayerDrawer.cs
index 8f5fd6858..ca49b2350 100644
--- a/Artemis/Artemis/Utilities/LayerDrawer.cs
+++ b/Artemis/Artemis/Utilities/LayerDrawer.cs
@@ -1,4 +1,5 @@
-using System.Windows;
+using System;
+using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Artemis.Models.Profiles;
@@ -27,6 +28,8 @@ namespace Artemis.Utilities
if (_layerModel.LayerCalculatedProperties.Brush == null)
return;
+ UpdateAnimation();
+
// Set up variables for this frame
_rectangle = new Rect(_layerModel.LayerCalculatedProperties.X*Scale,
_layerModel.LayerCalculatedProperties.Y*Scale, _layerModel.LayerCalculatedProperties.Width*Scale,
@@ -36,12 +39,14 @@ namespace Artemis.Utilities
_layerModel.LayerCalculatedProperties.Brush.Dispatcher.Invoke(() => DrawRectangle(c));
else if (_layerModel.LayerType == LayerType.KeyboardEllipse)
_layerModel.LayerCalculatedProperties.Brush.Dispatcher.Invoke(() => DrawEllipse(c));
-
- UpdateAnimation();
}
private void UpdateAnimation()
{
+ if (!_layerModel.Enabled)
+ return;
+
+ // Slide right animation
if (_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideRight)
{
_firstRect = new Rect(new Point(_rectangle.X + _animationProgress, _rectangle.Y),
@@ -52,16 +57,20 @@ namespace Artemis.Utilities
if (_animationProgress > _layerModel.LayerCalculatedProperties.Width*4)
_animationProgress = 0;
}
+
+ // Slide left animation
if (_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideLeft)
{
_firstRect = new Rect(new Point(_rectangle.X - _animationProgress, _rectangle.Y),
new Size(_rectangle.Width + 1, _rectangle.Height));
_secondRect = new Rect(new Point(_firstRect.X + _rectangle.Width, _rectangle.Y),
- new Size(_rectangle.Width , _rectangle.Height));
+ new Size(_rectangle.Width, _rectangle.Height));
if (_animationProgress > _layerModel.LayerCalculatedProperties.Width*4)
_animationProgress = 0;
}
+
+ // Slide down animation
if (_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideDown)
{
_firstRect = new Rect(new Point(_rectangle.X, _rectangle.Y + _animationProgress),
@@ -69,9 +78,11 @@ namespace Artemis.Utilities
_secondRect = new Rect(new Point(_firstRect.X, _firstRect.Y - _rectangle.Height),
new Size(_rectangle.Width, _rectangle.Height));
- if (_animationProgress > _layerModel.LayerCalculatedProperties.Height * 4)
+ if (_animationProgress > _layerModel.LayerCalculatedProperties.Height*4)
_animationProgress = 0;
}
+
+ // Slide up animation
if (_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideUp)
{
_firstRect = new Rect(new Point(_rectangle.X, _rectangle.Y - _animationProgress),
@@ -79,12 +90,25 @@ namespace Artemis.Utilities
_secondRect = new Rect(new Point(_firstRect.X, _firstRect.Y + _rectangle.Height),
new Size(_rectangle.Width, _rectangle.Height));
- if (_animationProgress > _layerModel.LayerCalculatedProperties.Height * 4)
+ if (_animationProgress > _layerModel.LayerCalculatedProperties.Height*4)
_animationProgress = 0;
}
- // Update the rotation progress
- _animationProgress = _animationProgress + _layerModel.LayerCalculatedProperties.AnimationSpeed;
+ // Pulse animation
+ if (_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.Pulse)
+ {
+ var opac = (Math.Sin(_animationProgress*Math.PI) + 1)*(_layerModel.LayerUserProperties.Opacity/2);
+ _layerModel.LayerCalculatedProperties.Opacity = opac;
+ if (_animationProgress > 2)
+ _animationProgress = 0;
+
+ _animationProgress = _animationProgress + _layerModel.LayerCalculatedProperties.AnimationSpeed/2;
+ }
+ else
+ {
+ // Update the animation progress
+ _animationProgress = _animationProgress + _layerModel.LayerCalculatedProperties.AnimationSpeed;
+ }
}
public BitmapImage GetThumbnail()
@@ -131,7 +155,9 @@ namespace Artemis.Utilities
public void DrawRectangle(DrawingContext c)
{
- _layerModel.LayerCalculatedProperties.Brush.Opacity = _layerModel.LayerCalculatedProperties.Opacity;
+ //_layerModel.LayerCalculatedProperties.Brush.Opacity = _layerModel.LayerCalculatedProperties.Opacity;
+ var brush = _layerModel.LayerCalculatedProperties.Brush.CloneCurrentValue();
+ brush.Opacity = _layerModel.LayerCalculatedProperties.Opacity;
if (_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideDown ||
_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideLeft ||
@@ -139,13 +165,13 @@ namespace Artemis.Utilities
_layerModel.LayerCalculatedProperties.Animation == LayerAnimation.SlideUp)
{
c.PushClip(new RectangleGeometry(_rectangle));
- c.DrawRectangle(_layerModel.LayerCalculatedProperties.Brush, null, _firstRect);
- c.DrawRectangle(_layerModel.LayerCalculatedProperties.Brush, null, _secondRect);
+ c.DrawRectangle(brush, null, _firstRect);
+ c.DrawRectangle(brush, null, _secondRect);
c.Pop();
}
else
{
- c.DrawRectangle(_layerModel.LayerCalculatedProperties.Brush, null, _rectangle);
+ c.DrawRectangle(brush, null, _rectangle);
}
}
diff --git a/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs b/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs
index 169477783..aedf2c01c 100644
--- a/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs
@@ -90,7 +90,7 @@ namespace Artemis.ViewModels.Flyouts
public void Handle(ActiveEffectChanged message)
{
- var effectDisplay = message.ActiveEffect.Length > 0 ? message.ActiveEffect : "none";
+ var effectDisplay = string.IsNullOrEmpty(message.ActiveEffect) ? message.ActiveEffect : "none";
ActiveEffectName = $"Active effect: {effectDisplay}";
}
diff --git a/Artemis/Artemis/ViewModels/LayerEditorViewModel.cs b/Artemis/Artemis/ViewModels/LayerEditorViewModel.cs
index 0bfe25831..cd5a2377f 100644
--- a/Artemis/Artemis/ViewModels/LayerEditorViewModel.cs
+++ b/Artemis/Artemis/ViewModels/LayerEditorViewModel.cs
@@ -1,9 +1,7 @@
using System;
using System.ComponentModel;
-using System.Diagnostics;
using System.Linq;
using System.Threading;
-using System.Windows;
using System.Windows.Media;
using Artemis.DAL;
using Artemis.KeyboardProviders;
@@ -19,6 +17,7 @@ namespace Artemis.ViewModels
private readonly KeyboardProvider _activeKeyboard;
private readonly BackgroundWorker _previewWorker;
private readonly ProfileModel _profile;
+ private readonly bool _wasEnabled;
private LayerModel _layer;
private LayerPropertiesModel _proposedProperties;
@@ -26,8 +25,11 @@ namespace Artemis.ViewModels
{
_activeKeyboard = activeKeyboard;
_profile = profile;
+ _wasEnabled = layer.Enabled;
Layer = layer;
+ Layer.Enabled = false;
+
DataModelProps = new BindableCollection();
ProposedProperties = new LayerPropertiesModel();
DataModelProps.AddRange(GeneralHelpers.GenerateTypeMap());
@@ -39,7 +41,8 @@ namespace Artemis.ViewModels
_previewWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
_previewWorker.DoWork += PreviewWorkerOnDoWork;
_previewWorker.RunWorkerAsync();
-
+
+ PropertyChanged += AnimationUiHandler;
PreSelect();
}
@@ -101,7 +104,7 @@ namespace Artemis.ViewModels
while (!_previewWorker.CancellationPending)
{
NotifyOfPropertyChange(() => LayerImage);
- Thread.Sleep(1000 / 25);
+ Thread.Sleep(1000/25);
}
}
@@ -110,6 +113,12 @@ namespace Artemis.ViewModels
GeneralHelpers.CopyProperties(ProposedProperties, Layer.LayerUserProperties);
}
+ private void AnimationUiHandler(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName != "_proposedProperties")
+ return;
+ }
+
public void AddCondition()
{
var condition = new LayerConditionModel();
@@ -133,6 +142,7 @@ namespace Artemis.ViewModels
public override void CanClose(Action callback)
{
_previewWorker.CancelAsync();
+ _layer.Enabled = _wasEnabled;
base.CanClose(callback);
}
}
diff --git a/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs b/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs
index 46ed9870e..a3f0ffa56 100644
--- a/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs
+++ b/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs
@@ -1,7 +1,16 @@
-using System.Dynamic;
+using System;
+using System.Drawing.Imaging;
+using System.Dynamic;
+using System.IO;
using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
using System.Windows.Media;
+using System.Windows.Media.Imaging;
using Artemis.DAL;
+using Artemis.Events;
+using Artemis.KeyboardProviders;
using Artemis.Managers;
using Artemis.Models;
using Artemis.Models.Profiles;
@@ -9,7 +18,7 @@ using Caliburn.Micro;
namespace Artemis.ViewModels
{
- public class ProfileEditorViewModel : Screen
+ public class ProfileEditorViewModel : Screen, IHandle
{
private readonly GameModel _gameModel;
private readonly MainManager _mainManager;
@@ -23,6 +32,7 @@ namespace Artemis.ViewModels
_gameModel = gameModel;
ProfileModels = new BindableCollection();
+ _mainManager.Events.Subscribe(this);
LoadProfiles();
}
@@ -44,12 +54,78 @@ namespace Artemis.ViewModels
{
if (Equals(value, _selectedProfileModel)) return;
_selectedProfileModel = value;
- NotifyOfPropertyChange();
+ NotifyOfPropertyChange(() => SelectedProfileModel);
}
}
public LayerModel SelectedLayer { get; set; }
+ public ImageSource KeyboardPreview
+ {
+ get
+ {
+ if (_selectedProfileModel == null)
+ return null;
+
+ var keyboardRect = _mainManager.KeyboardManager.ActiveKeyboard.KeyboardRectangle(4);
+ var visual = new DrawingVisual();
+ using (var drawingContext = visual.RenderOpen())
+ {
+ // Setup the DrawingVisual's size
+ drawingContext.PushClip(new RectangleGeometry(keyboardRect));
+ drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), null, keyboardRect);
+
+ // Draw the layer
+ foreach (var layerModel in _selectedProfileModel.Layers)
+ {
+ // if (layerModel.Selected)
+ drawingContext.DrawRectangle(null, new Pen(new SolidColorBrush(Colors.White), 0.5),new Rect(layerModel.LayerUserProperties.X*4,layerModel.LayerUserProperties.Y*4, layerModel.LayerUserProperties.Width*4,layerModel.LayerUserProperties.Height*4));
+ layerModel.DrawPreview(drawingContext);
+ }
+
+ // Remove the clip
+ drawingContext.Pop();
+ }
+ var image = new DrawingImage(visual.Drawing);
+
+ return image;
+ }
+ }
+
+ public ImageSource KeyboardImage
+ {
+ get
+ {
+ using (var memory = new MemoryStream())
+ {
+ if (_mainManager.KeyboardManager.ActiveKeyboard?.PreviewSettings == null)
+ return null;
+
+ _mainManager.KeyboardManager.ActiveKeyboard.PreviewSettings.Image.Save(memory, ImageFormat.Png);
+ memory.Position = 0;
+
+ var bitmapImage = new BitmapImage();
+ bitmapImage.BeginInit();
+ bitmapImage.StreamSource = memory;
+ bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
+ bitmapImage.EndInit();
+
+ return bitmapImage;
+ }
+ }
+ }
+
+ public PreviewSettings? PreviewSettings
+ {
+ get { return _mainManager.KeyboardManager.ActiveKeyboard?.PreviewSettings; }
+ }
+
+ public void Handle(ActiveKeyboardChanged message)
+ {
+ NotifyOfPropertyChange(() => KeyboardImage);
+ NotifyOfPropertyChange(() => PreviewSettings);
+ }
+
private void LoadProfiles()
{
ProfileModels.Clear();
@@ -94,7 +170,8 @@ namespace Artemis.ViewModels
public void LayerEditor(LayerModel layer)
{
IWindowManager manager = new WindowManager();
- _editorVm = new LayerEditorViewModel(_mainManager.KeyboardManager.ActiveKeyboard, SelectedProfileModel, layer);
+ _editorVm = new LayerEditorViewModel(_mainManager.KeyboardManager.ActiveKeyboard, SelectedProfileModel,
+ layer);
dynamic settings = new ExpandoObject();
settings.Title = "Artemis | Edit " + layer.Name;
@@ -104,6 +181,7 @@ namespace Artemis.ViewModels
public void SetSelectedLayer(LayerModel layer)
{
SelectedLayer = layer;
+ NotifyOfPropertyChange(() => KeyboardPreview);
}
public void AddLayer()
@@ -113,12 +191,22 @@ namespace Artemis.ViewModels
Name = "Layer " + (_selectedProfileModel.Layers.Count + 1),
LayerType = LayerType.KeyboardRectangle
});
- NotifyOfPropertyChange();
+ NotifyOfPropertyChange(() => SelectedProfileModel);
}
- private ImageSource GenerateKeyboardImage()
+ public void MouseMoveKeyboardPreview(MouseEventArgs e)
{
- return null;
+ var pos = e.GetPosition((Image) e.OriginalSource);
+ var realX =
+ (int)
+ Math.Round(pos.X/
+ (_mainManager.KeyboardManager.ActiveKeyboard.PreviewSettings.Width/
+ _mainManager.KeyboardManager.ActiveKeyboard.Width));
+ var realY =
+ (int)
+ Math.Round(pos.Y/
+ (_mainManager.KeyboardManager.ActiveKeyboard.PreviewSettings.Height/
+ _mainManager.KeyboardManager.ActiveKeyboard.Height));
}
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Views/LayerEditorView.xaml b/Artemis/Artemis/Views/LayerEditorView.xaml
index c760b9c52..89b023a2f 100644
--- a/Artemis/Artemis/Views/LayerEditorView.xaml
+++ b/Artemis/Artemis/Views/LayerEditorView.xaml
@@ -120,17 +120,17 @@
+ TickPlacement="None" TickFrequency="0.05"
+ Value="{Binding Path=ProposedProperties.AnimationSpeed, Mode=TwoWay}" Minimum="0.05" Maximum="3"
+ SmallChange="1" IsSnapToTickEnabled="True" Margin="10,12,10,2" Height="24" />
+ TickPlacement="BottomRight" TickFrequency="0.05"
+ Value="{Binding Path=ProposedProperties.Opacity, Mode=TwoWay}" Minimum="0.0" Maximum="1.0"
+ SmallChange="0.05" Margin="10,7" Height="24" />
-
+
+
+
+
+
+
@@ -59,15 +69,17 @@
-
+
-
+
-
+
-
+