mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added Key press config (commiting to master because I forgot to swap :'))
This commit is contained in:
parent
43ab4d2d24
commit
4f214b0a5f
@ -330,6 +330,11 @@
|
||||
</Compile>
|
||||
<Compile Include="Profiles\Layers\Types\Generic\GenericPropertiesViewModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\Generic\GenericType.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\KeyPress\KeyPressPropertiesModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\KeyPress\KeyPressPropertiesView.xaml.cs">
|
||||
<DependentUpon>KeyPressPropertiesView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Profiles\Layers\Types\KeyPress\KeyPressPropertiesViewModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\KeyPress\KeyPressType.cs" />
|
||||
<Compile Include="Profiles\ProfileModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Models\SimplePropertiesModel.cs" />
|
||||
@ -740,6 +745,10 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Profiles\Layers\Types\KeyPress\KeyPressPropertiesView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Resources\Icons.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
<UserControl x:Class="Artemis.Profiles.Layers.Types.KeyPress.KeyPressPropertiesView"
|
||||
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:ncore="http://schemas.ncore.com/wpf/xaml/colorbox"
|
||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="500">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<!-- Scale -->
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Scale:"
|
||||
Height="18" VerticalAlignment="Top" />
|
||||
<Slider x:Name="Scale" Grid.Row="0" Grid.Column="1" VerticalAlignment="Top"
|
||||
TickPlacement="None" TickFrequency="2"
|
||||
Value="{Binding Path=LayerModel.Properties.Scale, Mode=TwoWay}" Minimum="2" Maximum="24"
|
||||
SmallChange="2" IsSnapToTickEnabled="True" Margin="10,12,10,2" Height="24" LargeChange="2" />
|
||||
|
||||
<!-- Animation Speed -->
|
||||
<TextBlock Grid.Row="0" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Animation speed:"
|
||||
VerticalAlignment="Top" Height="18" />
|
||||
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Top"
|
||||
TickPlacement="None" TickFrequency="0.05"
|
||||
Value="{Binding Path=LayerModel.Properties.AnimationSpeed, Mode=TwoWay}" Minimum="0.05" Maximum="3"
|
||||
SmallChange="0" IsSnapToTickEnabled="True" Margin="10,12,10,2" Height="24" />
|
||||
|
||||
<!-- Colors -->
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal" x:Name="ShowBrush">
|
||||
<TextBlock Margin="10,13,10,0" FontSize="13.333" Text="Color(s):"
|
||||
VerticalAlignment="Top" Height="18" Width="130" />
|
||||
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
||||
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
||||
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" Height="24" Width="134" VerticalAlignment="Top" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Random color -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Random color:"
|
||||
VerticalAlignment="Top" Height="18" />
|
||||
<controls:ToggleSwitch Grid.Row="1" Grid.Column="3" OnLabel="Yes" OffLabel="No"
|
||||
IsChecked="{Binding Path=LayerModel.Properties.RandomColor, Mode=TwoWay}"
|
||||
VerticalAlignment="Top" Margin="10,5,10,2" />
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.KeyPress
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for KeyPressPropertiesView.xaml
|
||||
/// </summary>
|
||||
public partial class KeyPressPropertiesView : UserControl
|
||||
{
|
||||
public KeyPressPropertiesView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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<LayerModel> _keyPressLayers = new List<LayerModel>();
|
||||
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<ILayerAnimation> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user