From 0b216d6cc201069abc4fbcbd3e5a0d6df35916d0 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Mon, 1 Aug 2016 23:30:49 +0200 Subject: [PATCH] Basic audio layer type --- Artemis/Artemis/Artemis.csproj | 29 +-- .../InjectionModules/ArtemisModules.cs | 5 +- .../Effects/TypeWave/TypeWave.Designer.cs | 98 --------- .../Effects/TypeWave/TypeWave.settings | 26 --- .../Modules/Effects/TypeWave/TypeWaveModel.cs | 138 ------------ .../Effects/TypeWave/TypeWaveSettings.cs | 52 ----- .../Effects/TypeWave/TypeWaveView.xaml | 121 ----------- .../Effects/TypeWave/TypeWaveView.xaml.cs | 15 -- .../Effects/TypeWave/TypeWaveViewModel.cs | 25 --- .../Types/Audio/AudioPropertiesModel.cs | 14 ++ .../Types/Audio/AudioPropertiesView.xaml | 59 ++++++ .../Types/Audio/AudioPropertiesView.xaml.cs | 15 ++ .../Types/Audio/AudioPropertiesViewModel.cs | 18 ++ .../Profiles/Layers/Types/Audio/AudioType.cs | 200 ++++++++++++++++++ .../Layers/Types/KeyPress/KeyPressType.cs | 3 + 15 files changed, 322 insertions(+), 496 deletions(-) delete mode 100644 Artemis/Artemis/Modules/Effects/TypeWave/TypeWave.Designer.cs delete mode 100644 Artemis/Artemis/Modules/Effects/TypeWave/TypeWave.settings delete mode 100644 Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveModel.cs delete mode 100644 Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveSettings.cs delete mode 100644 Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveView.xaml delete mode 100644 Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveView.xaml.cs delete mode 100644 Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveViewModel.cs create mode 100644 Artemis/Artemis/Profiles/Layers/Types/Audio/AudioPropertiesModel.cs create mode 100644 Artemis/Artemis/Profiles/Layers/Types/Audio/AudioPropertiesView.xaml create mode 100644 Artemis/Artemis/Profiles/Layers/Types/Audio/AudioPropertiesView.xaml.cs create mode 100644 Artemis/Artemis/Profiles/Layers/Types/Audio/AudioPropertiesViewModel.cs create mode 100644 Artemis/Artemis/Profiles/Layers/Types/Audio/AudioType.cs diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index f2ba363af..0016043d5 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -325,6 +325,12 @@ + + + AudioPropertiesView.xaml + + + GenericPropertiesView.xaml @@ -372,12 +378,6 @@ - - TypeWave.settings - True - True - - CounterStrike.settings @@ -445,7 +445,6 @@ - @@ -521,7 +520,6 @@ - @@ -557,9 +555,6 @@ AudioVisualizerView.xaml - - TypeWaveView.xaml - GamesView.xaml @@ -641,10 +636,6 @@ SettingsSingleFileGenerator Bubbles.Designer.cs - - SettingsSingleFileGenerator - TypeWave.Designer.cs - SettingsSingleFileGenerator WindowsProfile.Designer.cs @@ -741,6 +732,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -777,10 +772,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - MSBuild:Compile Designer diff --git a/Artemis/Artemis/InjectionModules/ArtemisModules.cs b/Artemis/Artemis/InjectionModules/ArtemisModules.cs index 7347d9e09..68f35bd1a 100644 --- a/Artemis/Artemis/InjectionModules/ArtemisModules.cs +++ b/Artemis/Artemis/InjectionModules/ArtemisModules.cs @@ -4,7 +4,6 @@ using Artemis.DeviceProviders.Logitech; using Artemis.DeviceProviders.Razer; using Artemis.Modules.Effects.AudioVisualizer; using Artemis.Modules.Effects.Bubbles; -using Artemis.Modules.Effects.TypeWave; using Artemis.Modules.Effects.WindowsProfile; using Artemis.Modules.Games.CounterStrike; using Artemis.Modules.Games.Dota2; @@ -16,6 +15,7 @@ using Artemis.Modules.Overlays.VolumeDisplay; using Artemis.Profiles.Layers.Animations; using Artemis.Profiles.Layers.Conditions; using Artemis.Profiles.Layers.Interfaces; +using Artemis.Profiles.Layers.Types.Audio; using Artemis.Profiles.Layers.Types.Folder; using Artemis.Profiles.Layers.Types.Generic; using Artemis.Profiles.Layers.Types.Headset; @@ -36,7 +36,6 @@ namespace Artemis.InjectionModules // Effects Bind().To().InSingletonScope(); - Bind().To().InSingletonScope(); Bind().To().InSingletonScope(); Bind().To().InSingletonScope(); @@ -92,9 +91,11 @@ namespace Artemis.InjectionModules Bind().To(); Bind().To(); Bind().To(); + Bind().To(); // Bind some Layer Types to self as well in order to allow JSON.NET injection Bind().ToSelf(); + Bind().ToSelf(); #endregion } diff --git a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWave.Designer.cs b/Artemis/Artemis/Modules/Effects/TypeWave/TypeWave.Designer.cs deleted file mode 100644 index 6fda6a5f0..000000000 --- a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWave.Designer.cs +++ /dev/null @@ -1,98 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Artemis.Modules.Effects.TypeWave { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] - internal sealed partial class TypeWave : global::System.Configuration.ApplicationSettingsBase { - - private static TypeWave defaultInstance = ((TypeWave)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new TypeWave()))); - - public static TypeWave Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool IsRandomColors { - get { - return ((bool)(this["IsRandomColors"])); - } - set { - this["IsRandomColors"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("#FFFF0000")] - public global::System.Windows.Media.Color WaveColor { - get { - return ((global::System.Windows.Media.Color)(this["WaveColor"])); - } - set { - this["WaveColor"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("True")] - public bool IsShiftColors { - get { - return ((bool)(this["IsShiftColors"])); - } - set { - this["IsShiftColors"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("20")] - public int ShiftColorSpeed { - get { - return ((int)(this["ShiftColorSpeed"])); - } - set { - this["ShiftColorSpeed"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("500")] - public int TimeToLive { - get { - return ((int)(this["TimeToLive"])); - } - set { - this["TimeToLive"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("4")] - public int SpreadSpeed { - get { - return ((int)(this["SpreadSpeed"])); - } - set { - this["SpreadSpeed"] = value; - } - } - } -} diff --git a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWave.settings b/Artemis/Artemis/Modules/Effects/TypeWave/TypeWave.settings deleted file mode 100644 index b28238d15..000000000 --- a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWave.settings +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - True - - - #FFFF0000 - - - True - - - 20 - - - 500 - - - 4 - - - \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveModel.cs b/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveModel.cs deleted file mode 100644 index 2326f1dcc..000000000 --- a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveModel.cs +++ /dev/null @@ -1,138 +0,0 @@ -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Windows.Forms; -using Artemis.Managers; -using Artemis.Models; -using Artemis.Profiles.Layers.Models; -using Artemis.Utilities; -using Artemis.Utilities.Keyboard; - -namespace Artemis.Modules.Effects.TypeWave -{ - public class TypeWaveModel : EffectModel - { - private readonly List _waves; - private Color _randomColor; - - public TypeWaveModel(MainManager mainManager, TypeWaveSettings settings) : base(mainManager, null) - { - Name = "TypeWave"; - _waves = new List(); - _randomColor = Color.Red; - Settings = settings; - Initialized = false; - } - - public TypeWaveSettings Settings { get; set; } - - public override void Dispose() - { - Initialized = false; - KeyboardHook.KeyDownCallback -= KeyboardHookOnKeyDownCallback; - } - - private void KeyboardHookOnKeyDownCallback(KeyEventArgs e) - { - // More than 25 waves is pointless - if (_waves.Count >= 25) - return; - - var keyMatch = MainManager.DeviceManager.ActiveKeyboard.GetKeyPosition(e.KeyCode); - if (keyMatch == null) - return; - - _waves.Add(Settings.IsRandomColors - ? new Wave(new Point(keyMatch.Value.X*KeyboardScale, keyMatch.Value.Y*KeyboardScale), 0, _randomColor) - : new Wave(new Point(keyMatch.Value.X*KeyboardScale, keyMatch.Value.Y*KeyboardScale), 0, - ColorHelpers.ToDrawingColor(Settings.WaveColor))); - } - - public override void Enable() - { - KeyboardHook.KeyDownCallback += KeyboardHookOnKeyDownCallback; - Initialized = true; - } - - public override void Update() - { - if (Settings.IsRandomColors) - _randomColor = ColorHelpers.ShiftColor(_randomColor, 25); - - for (var i = 0; i < _waves.Count; i++) - { - // TODO: Get from settings - var fps = 25; - - _waves[i].Size += Settings.SpreadSpeed*KeyboardScale; - - if (Settings.IsShiftColors) - _waves[i].Color = ColorHelpers.ShiftColor(_waves[i].Color, Settings.ShiftColorSpeed); - - var decreaseAmount = 255/(Settings.TimeToLive/fps); - _waves[i].Color = Color.FromArgb( - _waves[i].Color.A - decreaseAmount, _waves[i].Color.R, - _waves[i].Color.G, - _waves[i].Color.B); - - if (_waves[i].Color.A >= decreaseAmount) - continue; - - _waves.RemoveAt(i); - i--; - } - } - - public override List GetRenderLayers(bool keyboardOnly) - { - return null; - } - - public override void Render(RenderFrame frame, bool keyboardOnly) - { - if (_waves.Count == 0) - return; - - // Don't want a for-each, collection is changed in different thread - // ReSharper disable once ForCanBeConvertedToForeach - for (var i = 0; i < _waves.Count; i++) - { - if (_waves[i].Size == 0) - continue; - var path = new GraphicsPath(); - path.AddEllipse(_waves[i].Point.X - _waves[i].Size/2, _waves[i].Point.Y - _waves[i].Size/2, - _waves[i].Size, _waves[i].Size); - - var pthGrBrush = new PathGradientBrush(path) - { - SurroundColors = new[] {_waves[i].Color}, - CenterColor = Color.Transparent - }; - - using (var g = Graphics.FromImage(frame.KeyboardBitmap)) - { - g.FillPath(pthGrBrush, path); - pthGrBrush.FocusScales = new PointF(0.3f, 0.8f); - - g.FillPath(pthGrBrush, path); - g.DrawEllipse(new Pen(pthGrBrush, 1), _waves[i].Point.X - _waves[i].Size/2, - _waves[i].Point.Y - _waves[i].Size/2, _waves[i].Size, _waves[i].Size); - } - } - } - } - - public class Wave - { - public Wave(Point point, int size, Color color) - { - Point = point; - Size = size; - Color = color; - } - - public Point Point { get; set; } - public int Size { get; set; } - public Color Color { get; set; } - } -} \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveSettings.cs b/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveSettings.cs deleted file mode 100644 index 66f3820bc..000000000 --- a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveSettings.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System.Windows.Media; -using Artemis.Models; - -namespace Artemis.Modules.Effects.TypeWave -{ - public class TypeWaveSettings : EffectSettings - { - public TypeWaveSettings() - { - Load(); - } - - public bool IsRandomColors { get; set; } - public Color WaveColor { get; set; } - public bool IsShiftColors { get; set; } - public int ShiftColorSpeed { get; set; } - public int TimeToLive { get; set; } - public int SpreadSpeed { get; set; } - - public sealed override void Load() - { - IsRandomColors = TypeWave.Default.IsRandomColors; - WaveColor = TypeWave.Default.WaveColor; - IsShiftColors = TypeWave.Default.IsShiftColors; - ShiftColorSpeed = TypeWave.Default.ShiftColorSpeed; - TimeToLive = TypeWave.Default.TimeToLive; - SpreadSpeed = TypeWave.Default.SpreadSpeed; - } - - public sealed override void Save() - { - TypeWave.Default.IsRandomColors = IsRandomColors; - TypeWave.Default.WaveColor = WaveColor; - TypeWave.Default.IsShiftColors = IsShiftColors; - TypeWave.Default.ShiftColorSpeed = ShiftColorSpeed; - TypeWave.Default.TimeToLive = TimeToLive; - TypeWave.Default.SpreadSpeed = SpreadSpeed; - - TypeWave.Default.Save(); - } - - public sealed override void ToDefault() - { - IsRandomColors = true; - WaveColor = Color.FromArgb(255, 255, 0, 0); - IsShiftColors = true; - ShiftColorSpeed = 20; - TimeToLive = 500; - SpreadSpeed = 4; - } - } -} \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveView.xaml b/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveView.xaml deleted file mode 100644 index 89527794a..000000000 --- a/Artemis/Artemis/Modules/Effects/TypeWave/TypeWaveView.xaml +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - Wave color - - - - - - Use random colors - - - - - - Shift through colors as the wave grows - - - - - - Speed to shift colors at - - - - - - Wave time to live - - - - - - Wave growth speed - - - - - -