1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Redid keybinds

Added mouse binds
Finalized editor resize
Realigned keyboard in editor
This commit is contained in:
SpoinkyNL 2017-03-14 21:01:08 +01:00
parent a71dc46071
commit c13b9e4dd5
34 changed files with 689 additions and 381 deletions

View File

@ -491,6 +491,7 @@
<Compile Include="Profiles\Layers\Animations\NoneAnimation.cs" />
<Compile Include="Profiles\Layers\Models\EventPropertiesModel.cs" />
<Compile Include="Profiles\Layers\Models\KeyboardEventPropertiesModel.cs" />
<Compile Include="Profiles\Layers\Models\LayerKeybindModel.cs" />
<Compile Include="Profiles\Layers\Models\TweenModel.cs" />
<Compile Include="Profiles\Layers\Types\AmbientLight\AmbienceCreator\AmbienceCreatorExtend.cs" />
<Compile Include="Profiles\Layers\Types\AmbientLight\AmbienceCreator\AmbienceCreatorMirror.cs" />
@ -685,6 +686,7 @@
<Compile Include="Modules\Games\Dota2\Dota2ViewModel.cs" />
<Compile Include="Modules\Games\RocketLeague\RocketLeagueViewModel.cs" />
<Compile Include="Modules\Games\Witcher3\Witcher3ViewModel.cs" />
<Compile Include="ViewModels\Profiles\LayerKeybindViewModel.cs" />
<Compile Include="ViewModels\Profiles\LayerTweenViewModel.cs" />
<Compile Include="ViewModels\Profiles\Events\EventPropertiesViewModel.cs" />
<Compile Include="Profiles\Layers\Types\Keyboard\KeyboardPropertiesViewModel.cs" />
@ -735,6 +737,9 @@
<Compile Include="Profiles\Layers\Types\Keyboard\KeyboardPropertiesView.xaml.cs">
<DependentUpon>KeyboardPropertiesView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Profiles\LayerKeybindView.xaml.cs">
<DependentUpon>LayerKeybindView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Profiles\LayerConditionView.xaml.cs">
<DependentUpon>LayerConditionView.xaml</DependentUpon>
</Compile>
@ -984,6 +989,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Profiles\LayerKeybindView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\Profiles\LayerConditionView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@ -14,7 +14,7 @@ namespace Artemis.DeviceProviders.Artemis
CantEnableText = "Waaaaah, this should not be happening!";
Height = 1;
Width = 1;
PreviewSettings = new PreviewSettings(new Thickness(0, 0, 0, 0), Resources.none);
PreviewSettings = new PreviewSettings(new Rect(), Resources.none);
}
public override void Disable()

View File

@ -28,7 +28,7 @@ namespace Artemis.DeviceProviders.CoolerMaster
Height = 6;
Width = 22;
PreviewSettings = new PreviewSettings(new Thickness(-2, -5, 0, 0), Resources.masterkeys_pro_l);
PreviewSettings = new PreviewSettings(new Rect(17, 13, 812, 219), Resources.masterkeys_pro_l);
_generalSettings = SettingsProvider.Load<GeneralSettings>();
}
@ -89,4 +89,4 @@ namespace Artemis.DeviceProviders.CoolerMaster
}
}
}
}
}

View File

@ -28,7 +28,7 @@ namespace Artemis.DeviceProviders.CoolerMaster
Height = 6;
Width = 18;
PreviewSettings = new PreviewSettings(new Thickness(0, 0, 0, 0), Resources.masterkeys_pro_s);
PreviewSettings = new PreviewSettings(new Rect(13, 12, 657, 219), Resources.masterkeys_pro_s);
_generalSettings = SettingsProvider.Load<GeneralSettings>();
}
@ -89,4 +89,4 @@ namespace Artemis.DeviceProviders.CoolerMaster
}
}
}
}
}

View File

@ -55,7 +55,7 @@ namespace Artemis.DeviceProviders.Corsair
Height = 7;
Width = 25;
Slug = "corsair-k95-rgb";
PreviewSettings = new PreviewSettings(new Thickness(12, -12, 12, 5), Resources.k95);
PreviewSettings = new PreviewSettings(new Rect(20, 26, 1066, 282), Resources.k95);
break;
case "K70 RGB":
case "K70 RGB RAPIDFIRE":
@ -63,7 +63,7 @@ namespace Artemis.DeviceProviders.Corsair
Height = 7;
Width = 21;
Slug = "corsair-k70-rgb";
PreviewSettings = new PreviewSettings(new Thickness(12, -12, 12, 5), Resources.k70);
PreviewSettings = new PreviewSettings(new Rect(15, 26, 929, 282), Resources.k70);
break;
case "K65 RGB":
case "CGK65 RGB":
@ -72,13 +72,13 @@ namespace Artemis.DeviceProviders.Corsair
Height = 7;
Width = 18;
Slug = "corsair-k65-rgb";
PreviewSettings = new PreviewSettings(new Thickness(12, -12, 12, 5), Resources.k65);
PreviewSettings = new PreviewSettings(new Rect(15, 30, 747, 363), Resources.k65);
break;
case "STRAFE RGB":
Height = 7;
Width = 22;
Slug = "corsair-strafe-rgb";
PreviewSettings = new PreviewSettings(new Thickness(12, -12, 12, 5), Resources.strafe);
PreviewSettings = new PreviewSettings(new Rect(23, 30, 984, 375), Resources.strafe);
break;
}
@ -154,7 +154,7 @@ namespace Artemis.DeviceProviders.Corsair
return null;
var center = cueLed.LedRectangle.GetCenter();
return new KeyMatch(keyCode, (int)(center.X * widthMultiplier), (int)(center.Y * heightMultiplier));
return new KeyMatch(keyCode, (int) (center.X * widthMultiplier), (int) (center.Y * heightMultiplier));
}
}
}
}

View File

@ -4,6 +4,8 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media.Imaging;
using Artemis.Utilities;
using MahApps.Metro.Controls.Dialogs;
using Size = System.Windows.Size;
@ -31,9 +33,9 @@ namespace Artemis.DeviceProviders
/// Returns a bitmap matching the keyboard's dimensions using the provided scale
/// </summary>
/// <returns></returns>
public Bitmap KeyboardBitmap(int scale = 4) => new Bitmap(Width*scale, Height*scale);
public Bitmap KeyboardBitmap(int scale = 4) => new Bitmap(Width * scale, Height * scale);
public Rect KeyboardRectangle(int scale = 4) => new Rect(new Size(Width*scale, Height*scale));
public Rect KeyboardRectangle(int scale = 4) => new Rect(new Size(Width * scale, Height * scale));
/// <summary>
/// Runs CanEnable asynchronously multiple times until successful, cancelled or max tries reached
@ -56,7 +58,7 @@ namespace Artemis.DeviceProviders
return false;
}
// Updated progress to indicate how much tries are left
dialog.SetProgress(0.1*tries);
dialog.SetProgress(0.1 * tries);
}
if (CanEnable())
@ -115,13 +117,16 @@ namespace Artemis.DeviceProviders
public struct PreviewSettings
{
public Thickness Margin { get; set; }
public Bitmap Image { get; set; }
public Rect OverlayRectangle { get; set; }
public Rect BackgroundRectangle { get; set; }
public BitmapImage Image { get; set; }
public PreviewSettings(Thickness margin, Bitmap image)
public PreviewSettings(Rect overlayRectangle, Bitmap bitmap)
{
Margin = margin;
Image = image;
OverlayRectangle = overlayRectangle;
BackgroundRectangle = new Rect(0, 0, bitmap.Width, bitmap.Height);
Image = ImageUtilities.BitmapToBitmapImage(bitmap);
Image.Freeze();
}
}
}
}

View File

@ -22,7 +22,7 @@ namespace Artemis.DeviceProviders.Logitech
"If needed, you can select a different keyboard in Artemis under settings.";
Height = 6;
Width = 21;
PreviewSettings = new PreviewSettings(new Thickness(0, 35, 0, 0), Resources.g810);
PreviewSettings = new PreviewSettings(new Rect(19, 70, 1010, 269), Resources.g810);
_generalSettings = SettingsProvider.Load<GeneralSettings>();
}

View File

@ -24,7 +24,7 @@ namespace Artemis.DeviceProviders.Logitech
"If needed, you can select a different keyboard in Artemis under settings.";
Height = 7;
Width = 22;
PreviewSettings = new PreviewSettings(new Thickness(20, -55, 20, 65), Resources.g910);
PreviewSettings = new PreviewSettings(new Rect(34, 18, 916, 272), Resources.g910);
_generalSettings = SettingsProvider.Load<GeneralSettings>();
}
@ -54,7 +54,7 @@ namespace Artemis.DeviceProviders.Logitech
/// <param name="bitmap"></param>
public override void DrawBitmap(Bitmap bitmap)
{
using (var croppedBitmap = new Bitmap(21*4, 6*4))
using (var croppedBitmap = new Bitmap(21 * 4, 6 * 4))
{
// Deal with non-standard DPI
croppedBitmap.SetResolution(96, 96);
@ -91,11 +91,11 @@ namespace Artemis.DeviceProviders.Logitech
private void SetLogitechColorFromCoordinates(Bitmap bitmap, KeyboardNames key, int x, int y)
{
var color = bitmap.GetPixel(x, y);
var rPer = (int) Math.Round(color.R/2.55);
var gPer = (int) Math.Round(color.G/2.55);
var bPer = (int) Math.Round(color.B/2.55);
var rPer = (int) Math.Round(color.R / 2.55);
var gPer = (int) Math.Round(color.G / 2.55);
var bPer = (int) Math.Round(color.B / 2.55);
LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(key, rPer, gPer, bPer);
}
}
}
}

View File

@ -27,7 +27,7 @@ namespace Artemis.DeviceProviders.Razer
Height = Constants.MaxRows;
Width = Constants.MaxColumns;
PreviewSettings = new PreviewSettings(new Thickness(0, -15, 0, 0), Resources.blackwidow);
PreviewSettings = new PreviewSettings(new Rect(26, 56, 906, 234), Resources.blackwidow);
_generalSettings = SettingsProvider.Load<GeneralSettings>();
}
@ -72,4 +72,4 @@ namespace Artemis.DeviceProviders.Razer
}
}
}
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Input;
@ -16,13 +17,13 @@ namespace Artemis.Managers
static KeybindManager()
{
KeyboardHook.KeyDownCallback += args => ProcessKey(args, KeyType.KeyDown);
KeyboardHook.KeyUpCallback += args => ProcessKey(args, KeyType.KeyUp);
KeyboardHook.MouseDownCallback += args => ProcessMouse(args, KeyType.MouseDown);
KeyboardHook.MouseUpCallback += args => ProcessMouse(args, KeyType.MouseUp);
KeyboardHook.KeyDownCallback += args => ProcessKey(args, PressType.Down);
KeyboardHook.KeyUpCallback += args => ProcessKey(args, PressType.Up);
KeyboardHook.MouseDownCallback += args => ProcessMouse(args, PressType.Down);
KeyboardHook.MouseUpCallback += args => ProcessMouse(args, PressType.Up);
}
private static void ProcessKey(KeyEventArgs keyEventArgs, KeyType keyType)
private static void ProcessKey(KeyEventArgs keyEventArgs, PressType pressType)
{
// Don't trigger if the key itself is a modifier
if (keyEventArgs.KeyCode == Keys.LShiftKey || keyEventArgs.KeyCode == Keys.RShiftKey ||
@ -37,17 +38,20 @@ namespace Artemis.Managers
var hotKey = new HotKey(KeyInterop.KeyFromVirtualKey(keyEventArgs.KeyValue), modifiers);
foreach (var keybindModel in KeybindModels)
keybindModel.InvokeIfMatched(hotKey, keyType);
keybindModel.InvokeIfMatched(hotKey, pressType);
}
private static void ProcessMouse(MouseEventArgs mouseEventArgs, KeyType keyType)
private static void ProcessMouse(MouseEventArgs mouseEventArgs, PressType pressType)
{
foreach (var keybindModel in KeybindModels)
keybindModel.InvokeIfMatched(mouseEventArgs.Button, keyType);
keybindModel.InvokeIfMatched(mouseEventArgs.Button, pressType);
}
public static void AddOrUpdate(KeybindModel keybindModel)
{
if (keybindModel == null)
return;
var existing = KeybindModels.FirstOrDefault(k => k.Name == keybindModel.Name);
if (existing != null)
KeybindModels.Remove(existing);

View File

@ -6,40 +6,40 @@ namespace Artemis.Models
{
public class KeybindModel
{
public KeybindModel(string name, HotKey hotKey, KeyType keyType, Action action)
public KeybindModel(string name, HotKey hotKey, PressType pressType, Action action)
{
Name = name;
HotKey = hotKey;
KeyType = keyType;
PressType = pressType;
Action = action;
}
public KeybindModel(string name, MouseButtons mouseButtons, KeyType keyType, Action action)
public KeybindModel(string name, MouseButtons mouseButtons, PressType pressType, Action action)
{
Name = name;
MouseButtons = mouseButtons;
KeyType = keyType;
PressType = pressType;
Action = action;
}
public string Name { get; set; }
public HotKey HotKey { get; set; }
public MouseButtons MouseButtons { get; }
public KeyType KeyType { get; set; }
public MouseButtons? MouseButtons { get; }
public PressType PressType { get; set; }
public Action Action { get; set; }
public void InvokeIfMatched(HotKey hotKey, KeyType keyType)
public void InvokeIfMatched(HotKey hotKey, PressType pressType)
{
if (HotKey == null || hotKey == null || KeyType != keyType)
if (HotKey == null || hotKey == null || PressType != pressType)
return;
if (hotKey.Equals(HotKey))
Action?.Invoke();
}
public void InvokeIfMatched(MouseButtons mouseButtons, KeyType keyType)
public void InvokeIfMatched(MouseButtons mouseButtons, PressType pressType)
{
if (KeyType != keyType)
if (PressType != pressType)
return;
if (mouseButtons.Equals(MouseButtons))
@ -47,11 +47,9 @@ namespace Artemis.Models
}
}
public enum KeyType
public enum PressType
{
KeyDown,
KeyUp,
MouseDown,
MouseUp
Down,
Up
}
}

View File

@ -1,5 +1,7 @@
using System.Drawing;
using System.Windows;
using System.Windows;
using System.Windows.Media;
using Artemis.Utilities;
using Color = System.Drawing.Color;
using Point = System.Windows.Point;
namespace Artemis.Modules.General.Bubbles
@ -20,7 +22,7 @@ namespace Artemis.Modules.General.Bubbles
#region Properties & Fields
private Brush _brush;
private SolidColorBrush _brush;
private Color _color;
@ -30,7 +32,7 @@ namespace Artemis.Modules.General.Bubbles
set
{
_color = value;
_brush = new SolidBrush(_color);
_brush = new SolidColorBrush(ColorHelpers.ToMediaColor(_color));
}
}
@ -45,10 +47,10 @@ namespace Artemis.Modules.General.Bubbles
public void CheckCollision(Rect border)
{
if (Position.X - Radius < border.X || Position.X + Radius > border.X + border.Width)
Direction = new Vector(Direction.X*-1, Direction.Y);
Direction = new Vector(Direction.X * -1, Direction.Y);
if (Position.Y - Radius < border.Y || Position.Y + Radius > border.Y + border.Height)
Direction = new Vector(Direction.X, Direction.Y*-1);
Direction = new Vector(Direction.X, Direction.Y * -1);
}
public void Move()
@ -56,11 +58,11 @@ namespace Artemis.Modules.General.Bubbles
Position += Direction;
}
public void Draw(Graphics g)
public void Draw(DrawingContext drawingContext)
{
g.FillEllipse(_brush, (float) Position.X - Radius, (float) Position.Y - Radius, Radius*2, Radius*2);
drawingContext.DrawEllipse(_brush, new Pen(_brush, 1), new Point((float) Position.X - Radius, (float) Position.Y - Radius), Radius * 2, Radius * 2);
}
#endregion
}
}
}

View File

@ -93,11 +93,9 @@ namespace Artemis.Modules.General.Bubbles
public override void Render(FrameModel frameModel, bool keyboardOnly)
{
using (var g = Graphics.FromImage(frameModel.KeyboardBitmap))
{
foreach (var bubble in _bubbles)
bubble.Draw(g);
}
var c = frameModel.KeyboardModel.GetDrawingContext();
foreach (var bubble in _bubbles)
bubble.Draw(c);
}
#endregion

View File

@ -0,0 +1,101 @@
using System;
using System.Windows.Forms;
using Artemis.Managers;
using Artemis.Models;
using MahApps.Metro.Controls;
namespace Artemis.Profiles.Layers.Models
{
public class LayerKeybindModel
{
private KeybindModel _downKeybind;
private KeybindModel _upKeybind;
public ToggleType ToggleType { get; set; }
public HotKey HotKey { get; set; }
public MouseButtons? MouseButtons { get; set; }
public void Unregister()
{
if (_downKeybind != null)
{
KeybindManager.Remove(_downKeybind);
_downKeybind = null;
}
if (_upKeybind != null)
{
KeybindManager.Remove(_upKeybind);
_upKeybind = null;
}
}
internal void Register(LayerModel layerModel, int index)
{
Unregister();
// Bind EnableHeldDown or DisableHeldDOwn
if (ToggleType == ToggleType.EnableHeldDown || ToggleType == ToggleType.DisableHeldDown)
{
Action downAction = null;
Action upAction = null;
switch (ToggleType)
{
case ToggleType.EnableHeldDown:
downAction = () => layerModel.RenderAllowed = true;
upAction = () => layerModel.RenderAllowed = false;
break;
case ToggleType.DisableHeldDown:
downAction = () => layerModel.RenderAllowed = false;
upAction = () => layerModel.RenderAllowed = true;
break;
}
// Either bind HotKey or mouse buttons depending on what isn't null
if (HotKey != null)
{
_downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", HotKey, PressType.Down, downAction);
_upKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-up", HotKey, PressType.Up, upAction);
}
else if (MouseButtons != null)
{
_downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", MouseButtons.Value, PressType.Down, downAction);
_upKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-up", MouseButtons.Value, PressType.Up, upAction);
}
KeybindManager.AddOrUpdate(_downKeybind);
KeybindManager.AddOrUpdate(_upKeybind);
return;
}
// Bind Enable, Disable or Toggle
Action action = null;
switch (ToggleType)
{
case ToggleType.Enable:
action = () => layerModel.RenderAllowed = true;
break;
case ToggleType.Disable:
action = () => layerModel.RenderAllowed = false;
break;
case ToggleType.Toggle:
action = () => layerModel.RenderAllowed = !layerModel.RenderAllowed;
break;
}
// Either bind HotKey or mouse buttons depending on what isn't null
if (HotKey != null)
_downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", HotKey, PressType.Down, action);
else if (MouseButtons != null)
_downKeybind = new KeybindModel($"{layerModel.GetHashCode()}-{layerModel.Name}-{index}-down", MouseButtons.Value, PressType.Down, action);
KeybindManager.AddOrUpdate(_downKeybind);
}
}
public enum ToggleType
{
Enable,
Disable,
Toggle,
EnableHeldDown,
DisableHeldDown
}
}

View File

@ -39,7 +39,7 @@ namespace Artemis.Profiles.Layers.Models
/// </summary>
/// <param name="dataModel"></param>
/// <returns></returns>
public bool ConditionsMet(ModuleDataModel dataModel)
public bool AreConditionsMet(ModuleDataModel dataModel)
{
// Conditions are not even checked if the layer isn't enabled
return Enabled && LayerCondition.ConditionsMet(this, dataModel);
@ -92,7 +92,7 @@ namespace Artemis.Profiles.Layers.Models
/// <param name="updateAnimations"></param>
public void Draw(ModuleDataModel dataModel, DrawingContext c, bool preview, bool updateAnimations)
{
if (Brush == null)
if (Brush == null || !preview && !RenderAllowed)
return;
LayerType.Draw(this, c);
@ -107,14 +107,12 @@ namespace Artemis.Profiles.Layers.Models
// If the type is an event, set it up
if (IsEvent && EventProperties == null)
{
EventProperties = new KeyboardEventPropertiesModel
{
ExpirationType = ExpirationType.Time,
Length = new TimeSpan(0, 0, 1),
TriggerDelay = new TimeSpan(0)
};
}
}
/// <summary>
@ -221,19 +219,15 @@ namespace Artemis.Profiles.Layers.Models
if (Parent != null)
{
foreach (var child in Parent.Children.OrderBy(c => c.Order))
{
if (child.Order >= source.Order)
child.Order++;
}
Parent.Children.Add(source);
}
else if (Profile != null)
{
foreach (var layer in Profile.Layers.OrderBy(l => l.Order))
{
if (layer.Order >= source.Order)
layer.Order++;
}
Profile.Layers.Add(source);
}
}
@ -247,7 +241,7 @@ namespace Artemis.Profiles.Layers.Models
if (height < 0)
height = 0;
return new Rect(X*scale, Y*scale, width*scale, height*scale);
return new Rect(X * scale, Y * scale, width * scale, height * scale);
}
/// <summary>
@ -267,10 +261,8 @@ namespace Artemis.Profiles.Layers.Models
continue;
if (!ignoreConditions)
{
if (!layerModel.ConditionsMet(dataModel))
if (!layerModel.AreConditionsMet(dataModel))
continue;
}
layers.Add(layerModel);
layers.AddRange(layerModel.GetRenderLayers(dataModel, keyboardOnly, ignoreConditions));
@ -287,6 +279,24 @@ namespace Artemis.Profiles.Layers.Models
LayerCondition = new DataModelCondition();
}
public void SetupKeybinds()
{
// Clean up old keybinds
RemoveKeybinds();
for (var index = 0; index < Properties.LayerKeybindModels.Count; index++)
{
var keybindModel = Properties.LayerKeybindModels[index];
keybindModel.Register(this, index);
}
}
public void RemoveKeybinds()
{
foreach (var keybindModel in Properties.LayerKeybindModels)
keybindModel.Unregister();
}
#region Properties
#region Layer type properties
@ -302,6 +312,7 @@ namespace Artemis.Profiles.Layers.Models
public string Name { get; set; }
public int Order { get; set; }
public bool Enabled { get; set; }
public bool RenderAllowed { get; set; }
public bool Expanded { get; set; }
public bool IsEvent { get; set; }
public LayerPropertiesModel Properties { get; set; }
@ -391,7 +402,7 @@ namespace Artemis.Profiles.Layers.Models
get { return Profile; }
set { Profile = value; }
}
#endregion
}
}
}

View File

@ -25,6 +25,7 @@ namespace Artemis.Profiles.Layers.Models
Opacity = source.Opacity;
AnimationSpeed = source.AnimationSpeed;
Conditions = source.Conditions;
LayerKeybindModels = source.LayerKeybindModels;
ConditionType = source.ConditionType;
DynamicProperties = source.DynamicProperties;
Brush = source.Brush;
@ -50,7 +51,8 @@ namespace Artemis.Profiles.Layers.Models
public string HeightEase { get; set; }
public string OpacityEase { get; set; }
public ConditionType ConditionType { get; set; }
public List<LayerConditionModel> Conditions { get; set; } = new List<LayerConditionModel>();
public List<LayerConditionModel> Conditions { get; set; } = new List<LayerConditionModel>();
public List<LayerKeybindModel> LayerKeybindModels { get; set; } = new List<LayerKeybindModel>();
public List<DynamicPropertiesModel> DynamicProperties { get; set; } = new List<DynamicPropertiesModel>();
[JsonConverter(typeof(BrushJsonConverter))]

View File

@ -10,27 +10,23 @@
<Grid>
<!-- Colors -->
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Animation -->
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10" FontSize="13.333" Text="Animation:"
VerticalAlignment="Center"
Height="18" />
<ComboBox Grid.Row="0" Grid.Column="1" Margin="10,10,10,0" x:Name="LayerAnimations" VerticalAlignment="Top"
Height="22">
<Label Grid.Row="0" Grid.Column="0" Content="Animation:" VerticalAlignment="Center" Margin="0,0,5,0" />
<ComboBox Grid.Row="0" Grid.Column="1" x:Name="LayerAnimations" VerticalAlignment="Center">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name, Mode=OneWay}" />
@ -39,42 +35,29 @@
</ComboBox>
<!-- Animation Speed -->
<TextBlock Grid.Row="0" Grid.Column="2" Margin="10" FontSize="13.333" Text="Animation speed:"
VerticalAlignment="Center" Height="18" />
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center"
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" />
<Label Grid.Row="0" Grid.Column="2" Content="Animation speed:" VerticalAlignment="Center" Margin="5,0" />
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center" TickPlacement="None" TickFrequency="0.05" Value="{Binding Path=LayerModel.Properties.AnimationSpeed, Mode=TwoWay}"
Minimum="0.05" Maximum="3" SmallChange="0" IsSnapToTickEnabled="True" />
<!-- ClippingType -->
<TextBlock Grid.Row="1" Grid.Column="0" Margin="10, 13, 10, 10" FontSize="13.333" Text="Clipping type:"
VerticalAlignment="Center" Height="23" />
<controls:ToggleSwitch IsChecked="{Binding Path=LayerModel.Properties.Contain, Mode=TwoWay}"
Grid.Row="1"
Grid.Column="1" OnLabel="Contain" OffLabel="Cut-off" Margin="10,1,5,1"
VerticalAlignment="Center"
Height="36" />
<Label Grid.Row="1" Grid.Column="0" Content="Clipping type:" VerticalAlignment="Center" Margin="0,0,5,0" />
<controls:ToggleSwitch Grid.Row="1" Grid.Column="1" IsChecked="{Binding Path=LayerModel.Properties.Contain, Mode=TwoWay}" OnLabel="Contain" OffLabel="Cut-off" VerticalAlignment="Center" Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" Margin="0,10" />
<!-- Colors -->
<StackPanel Grid.Row="1" Grid.Column="2" 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 Brush, Mode=TwoWay}" ShowNone="False" Height="24" Width="134"
VerticalAlignment="Top" ShowLinear="True" ShowRadial="False" ShowSolid="False" />
</Border>
</StackPanel>
<Label Grid.Row="1" Grid.Column="2" Content="Color(s):" VerticalAlignment="Center" Margin="5,0" />
<Border Grid.Row="1" Grid.Column="3" BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit" Height="26" Margin="0,5">
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" ShowNone="False" VerticalAlignment="Stretch" />
</Border>
<!-- Dynamic -->
<Label Grid.Row="3" Grid.Column="0" FontSize="20" HorizontalAlignment="Left"
Content="Dynamic" Width="97" VerticalAlignment="Bottom" />
<Label Grid.Row="2" Grid.Column="0" FontSize="20" Content="Dynamic" />
<!-- Dynamic property views -->
<ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" x:Name="HeightProperties" />
<ContentControl Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" x:Name="WidthProperties" />
<ContentControl Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
<ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" x:Name="HeightProperties" />
<ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" x:Name="WidthProperties" />
<ContentControl Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
<ContentControl Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="4" x:Name="LayerTweenViewModel" />
<!-- Tweening -->
<ContentControl Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="4" x:Name="LayerTweenViewModel" />
</Grid>
</UserControl>

View File

@ -4,73 +4,57 @@
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:ObjectModel="clr-namespace:System.Collections.ObjectModel;assembly=System"
x:Class="Artemis.Profiles.Layers.Types.Generic.GenericPropertiesView"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="500">
<Grid>
<!-- Colors -->
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Animation -->
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10" FontSize="13.333" Text="Animation:"
VerticalAlignment="Center"
Height="18" />
<ComboBox Grid.Row="0" Grid.Column="1" Margin="10,10,10,0" x:Name="LayerAnimations" VerticalAlignment="Top"
Height="22">
<Label Grid.Row="0" Grid.Column="0" Content="Animation:" VerticalAlignment="Center" Margin="0,0,5,0" HorizontalAlignment="Left" />
<ComboBox Grid.Row="0" Grid.Column="1" x:Name="LayerAnimations" VerticalAlignment="Center">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name, Mode=OneWay}" />
<TextBlock Text="{Binding Path=Name, Mode=OneWay}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<!-- Animation Speed -->
<TextBlock Grid.Row="0" Grid.Column="2" Margin="10" FontSize="13.333" Text="Animation speed:"
VerticalAlignment="Center" Height="18" />
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center"
TickPlacement="None" TickFrequency="0.05"
Value="{Binding LayerModel.Properties.AnimationSpeed, Mode=TwoWay}" Minimum="0.05" Maximum="3"
SmallChange="0" IsSnapToTickEnabled="True" Margin="10,12,10,2" Height="24" />
<Label Grid.Row="0" Grid.Column="2" Content="Animation speed:" VerticalAlignment="Center" Margin="5,0" />
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center" TickPlacement="None" TickFrequency="0.05" Value="{Binding Path=LayerModel.Properties.AnimationSpeed, Mode=TwoWay}"
Minimum="0.05" Maximum="3" SmallChange="0" IsSnapToTickEnabled="True" />
<!-- 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}" ShowNone="False" Height="24" Width="134"
VerticalAlignment="Top" />
</Border>
</StackPanel>
<Label Grid.Row="1" Grid.Column="0" Content="Color(s):" VerticalAlignment="Center" Margin="0,0,5,0" HorizontalAlignment="Left" />
<Border Grid.Row="1" Grid.Column="1" BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit" Height="26" Margin="0,5">
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" ShowNone="False" VerticalAlignment="Stretch" />
</Border>
<!-- Dynamic -->
<Label Grid.Row="3" Grid.Column="0" FontSize="20" HorizontalAlignment="Left"
Content="Dynamic" Width="97" VerticalAlignment="Bottom" />
<Label Grid.Row="2" Grid.Column="0" FontSize="20" Content="Dynamic" />
<!-- Dynamic property views -->
<ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
<ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
<!-- Note -->
<TextBlock Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333"
Foreground="{DynamicResource HighlightBrush}"
VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap">
<TextBlock Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333" Foreground="{DynamicResource HighlightBrush}" VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap">
<Run Text="Note: Generic devices are devices over which Artemis has limited control." /><LineBreak />
<Run /><LineBreak />
<Run Text="You can use this layer type to assign a color to all generic devices at once." /><LineBreak />
<Run
Text="Should your generic device have multiple LEDs, Artemis will try to take the colors from the Brush and spread them over the LEDs." />
<Run Text="Should your generic device have multiple LEDs, Artemis will try to take the colors from the Brush and spread them over the LEDs." />
<LineBreak /><Run /><LineBreak /><Run Text="Examples of supported generic devices:" /><LineBreak />
<Run Text="- Logitech mice and headsets" /><LineBreak /><Run Text="- Logitech G19" /><LineBreak />
<Run Text="- Logitech G510" /><LineBreak /><Run />

View File

@ -7,26 +7,23 @@
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<!-- Colors -->
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Animation -->
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10" FontSize="13.333" Text="Animation:"
VerticalAlignment="Center"
Height="18" />
<ComboBox Grid.Row="0" Grid.Column="1" Margin="10,10,10,0" x:Name="LayerAnimations" VerticalAlignment="Top"
Height="22">
<Label Grid.Row="0" Grid.Column="0" Content="Animation:" VerticalAlignment="Center" Margin="0,0,5,0" HorizontalAlignment="Left" />
<ComboBox Grid.Row="0" Grid.Column="1" x:Name="LayerAnimations" VerticalAlignment="Center">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name, Mode=OneWay}" />
@ -35,35 +32,26 @@
</ComboBox>
<!-- Animation Speed -->
<TextBlock Grid.Row="0" Grid.Column="2" Margin="10" FontSize="13.333" Text="Animation speed:"
VerticalAlignment="Center" Height="18" />
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center"
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" />
<Label Grid.Row="0" Grid.Column="2" Content="Animation speed:" VerticalAlignment="Center" Margin="5,0" />
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center" TickPlacement="None" TickFrequency="0.05" Value="{Binding Path=LayerModel.Properties.AnimationSpeed, Mode=TwoWay}"
Minimum="0.05" Maximum="3" SmallChange="0" IsSnapToTickEnabled="True" />
<!-- 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}" ShowNone="False" Height="24" Width="134"
VerticalAlignment="Top" />
</Border>
</StackPanel>
<Label Grid.Row="1" Grid.Column="0" Content="Color(s):" VerticalAlignment="Center" Margin="0,0,5,0" HorizontalAlignment="Left" />
<Border Grid.Row="1" Grid.Column="1" BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit" Height="26" Margin="0,5">
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" ShowNone="False" VerticalAlignment="Stretch" />
</Border>
<!-- Dynamic -->
<Label Grid.Row="3" Grid.Column="0" FontSize="20" HorizontalAlignment="Left"
Content="Dynamic" Width="97" VerticalAlignment="Bottom" />
<Label Grid.Row="2" Grid.Column="0" FontSize="20" Content="Dynamic" />
<!-- Dynamic property views -->
<ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
<ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
<!-- Note -->
<TextBlock Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333"
Foreground="{DynamicResource HighlightBrush}"
Text="Note: If your headset has multiple controllable LEDs you can create a gradient. Artemis will take the colors in the gradient and assign them to the LEDs"
VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap" />
<TextBlock Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333" Foreground="{DynamicResource HighlightBrush}" VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap"
Text="Note: If your headset has multiple controllable LEDs you can create a gradient. Artemis will take the colors in the gradient and assign them to the LEDs"/>
</Grid>
</UserControl>

View File

@ -46,7 +46,7 @@
<!-- Colors -->
<Label Grid.Row="1" Grid.Column="2" Content="Color(s):" VerticalAlignment="Center" Margin="5,0" />
<Border Grid.Row="1" Grid.Column="3" BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit" Height="26">
<Border Grid.Row="1" Grid.Column="3" BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit" Height="26" Margin="0,5">
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" ShowNone="False" VerticalAlignment="Stretch" />
</Border>

View File

@ -1,32 +1,29 @@
<UserControl x:Class="Artemis.Profiles.Layers.Types.Mouse.MousePropertiesView"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<!-- Colors -->
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Animation -->
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10" FontSize="13.333" Text="Animation:"
VerticalAlignment="Center"
Height="18" />
<ComboBox Grid.Row="0" Grid.Column="1" Margin="10,10,10,0" x:Name="LayerAnimations" VerticalAlignment="Top"
Height="22">
<Label Grid.Row="0" Grid.Column="0" Content="Animation:" VerticalAlignment="Center" Margin="0,0,5,0" HorizontalAlignment="Left" />
<ComboBox Grid.Row="0" Grid.Column="1" x:Name="LayerAnimations" VerticalAlignment="Center">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name, Mode=OneWay}" />
@ -35,35 +32,25 @@
</ComboBox>
<!-- Animation Speed -->
<TextBlock Grid.Row="0" Grid.Column="2" Margin="10" FontSize="13.333" Text="Animation speed:"
VerticalAlignment="Center" Height="18" />
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center"
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" />
<Label Grid.Row="0" Grid.Column="2" Content="Animation speed:" VerticalAlignment="Center" Margin="5,0" />
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center" TickPlacement="None" TickFrequency="0.05" Value="{Binding Path=LayerModel.Properties.AnimationSpeed, Mode=TwoWay}"
Minimum="0.05" Maximum="3" SmallChange="0" IsSnapToTickEnabled="True" />
<!-- 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}" ShowNone="False" Height="24" Width="134"
VerticalAlignment="Top" />
</Border>
</StackPanel>
<Label Grid.Row="1" Grid.Column="0" Content="Color(s):" VerticalAlignment="Center" Margin="0,0,5,0" HorizontalAlignment="Left" />
<Border Grid.Row="1" Grid.Column="1" BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit" Height="26" Margin="0,5">
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" ShowNone="False" VerticalAlignment="Stretch" />
</Border>
<!-- Dynamic -->
<Label Grid.Row="3" Grid.Column="0" FontSize="20" HorizontalAlignment="Left"
Content="Dynamic" Width="97" VerticalAlignment="Bottom" />
<Label Grid.Row="2" Grid.Column="0" FontSize="20" Content="Dynamic" />
<!-- Dynamic property views -->
<ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
<ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
<!-- Note -->
<TextBlock Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333"
Foreground="{DynamicResource HighlightBrush}"
Text="Note: If your mouse has multiple controllable LEDs you can create a gradient. Artemis will take the colors in the gradient and assign them to the LEDs"
VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap" />
<TextBlock Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333" Foreground="{DynamicResource HighlightBrush}" VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap"
Text="Note: If your mouse has multiple controllable LEDs you can create a gradient. Artemis will take the colors in the gradient and assign them to the LEDs" />
</Grid>
</UserControl>

View File

@ -1,32 +1,29 @@
<UserControl x:Class="Artemis.Profiles.Layers.Types.Mousemat.MousematPropertiesView"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<!-- Colors -->
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- Animation -->
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10" FontSize="13.333" Text="Animation:"
VerticalAlignment="Center"
Height="18" />
<ComboBox Grid.Row="0" Grid.Column="1" Margin="10,10,10,0" x:Name="LayerAnimations" VerticalAlignment="Top"
Height="22">
<Label Grid.Row="0" Grid.Column="0" Content="Animation:" VerticalAlignment="Center" Margin="0,0,5,0" HorizontalAlignment="Left" />
<ComboBox Grid.Row="0" Grid.Column="1" x:Name="LayerAnimations" VerticalAlignment="Center">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name, Mode=OneWay}" />
@ -35,35 +32,25 @@
</ComboBox>
<!-- Animation Speed -->
<TextBlock Grid.Row="0" Grid.Column="2" Margin="10" FontSize="13.333" Text="Animation speed:"
VerticalAlignment="Center" Height="18" />
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center"
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" />
<Label Grid.Row="0" Grid.Column="2" Content="Animation speed:" VerticalAlignment="Center" Margin="5,0" />
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Center" TickPlacement="None" TickFrequency="0.05" Value="{Binding Path=LayerModel.Properties.AnimationSpeed, Mode=TwoWay}"
Minimum="0.05" Maximum="3" SmallChange="0" IsSnapToTickEnabled="True" />
<!-- 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}" ShowNone="False" Height="24" Width="134"
VerticalAlignment="Top" />
</Border>
</StackPanel>
<Label Grid.Row="1" Grid.Column="0" Content="Color(s):" VerticalAlignment="Center" Margin="0,0,5,0" HorizontalAlignment="Left" />
<Border Grid.Row="1" Grid.Column="1" BorderBrush="{StaticResource ControlBorderBrush}" BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit" Height="26" Margin="0,5">
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" ShowNone="False" VerticalAlignment="Stretch" />
</Border>
<!-- Dynamic -->
<Label Grid.Row="3" Grid.Column="0" FontSize="20" HorizontalAlignment="Left"
Content="Dynamic" Width="97" VerticalAlignment="Bottom" />
<Label Grid.Row="2" Grid.Column="0" FontSize="20" Content="Dynamic" />
<!-- Dynamic property views -->
<ContentControl Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
<ContentControl Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" x:Name="OpacityProperties" />
<!-- Note -->
<TextBlock Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333"
Foreground="{DynamicResource HighlightBrush}"
Text="Note: If your mousemat has multiple controllable LEDs you can create a gradient. Artemis will take the colors in the gradient and assign them to the LEDs"
VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap" />
<TextBlock Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="4" Margin="10,2,10,10" FontSize="13.333" Foreground="{DynamicResource HighlightBrush}" VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap"
Text="Note: If your mousemat has multiple controllable LEDs you can create a gradient. Artemis will take the colors in the gradient and assign them to the LEDs" />
</Grid>
</UserControl>

View File

@ -33,13 +33,13 @@ namespace Artemis.Profiles.Lua.Modules
/// </summary>
/// <param name="name">Name of the keybind</param>
/// <param name="hotKey">Hotkey in string format, per example: ALT+CTRL+SHIFT+D</param>
/// <param name="keyType">The key type, either key up or key down</param>
/// <param name="pressType">The key type, either key up or key down</param>
/// <param name="function">LUA function to call</param>
/// <param name="args">Optional arguments for the passed function</param>
public void SetKeybind(string name, string hotKey, KeyType keyType, DynValue function, params DynValue[] args)
public void SetKeybind(string name, string hotKey, PressType pressType, DynValue function, params DynValue[] args)
{
if (keyType != KeyType.KeyDown && keyType != KeyType.KeyUp)
throw new ScriptRuntimeException("Key type must either be KeyDown or KeyUp.");
if (pressType != PressType.Down && pressType != PressType.Up)
throw new ScriptRuntimeException("Key type must either be Down or Up.");
var modifierKeys = ModifierKeys.None;
var key = Key.System;
@ -59,8 +59,8 @@ namespace Artemis.Profiles.Lua.Modules
var hk = new HotKey(key, modifierKeys);
var model = args != null
? new KeybindModel("LUA-" + name, hk, keyType, () => LuaManager.Call(function, args))
: new KeybindModel("LUA-" + name, hk, keyType, () => LuaManager.Call(function));
? new KeybindModel("LUA-" + name, hk, pressType, () => LuaManager.Call(function, args))
: new KeybindModel("LUA-" + name, hk, pressType, () => LuaManager.Call(function));
KeybindManager.AddOrUpdate(model);

View File

@ -92,7 +92,7 @@ namespace Artemis.Profiles
continue;
if (!ignoreConditions)
if (!layerModel.ConditionsMet(dataModel))
if (!layerModel.AreConditionsMet(dataModel))
continue;
layers.Add(layerModel);
@ -223,45 +223,14 @@ namespace Artemis.Profiles
public void ApplyKeybinds()
{
// _profileBinds.Clear();
// foreach (var layerModel in GetLayers())
// {
// for (var index = 0; index < layerModel.Properties.Conditions.Count; index++)
// {
// var condition = layerModel.Properties.Conditions[index];
// if (condition.Field == null || !condition.Field.Contains("hotkey"))
// continue;
//
// // Create an action for the layer, the layer's specific condition type handles activation
// if (condition.Operator == "held")
// {
// var downAction = new Action(() => layerModel.LayerCondition.KeyDownTask(condition));
// var downKb = new KeybindModel($"{GameName}-{Name}-{layerModel.Name}-down-{index}", condition.HotKey, KeyType.KeyDown, downAction);
// var upAction = new Action(() => layerModel.LayerCondition.KeyUpTask(condition));
// var upKb = new KeybindModel($"{GameName}-{Name}-{layerModel.Name}-up-{index}", condition.HotKey, KeyType.KeyUp, upAction);
//
// KeybindManager.AddOrUpdate(downKb);
// KeybindManager.AddOrUpdate(upKb);
// _profileBinds.Add(downKb);
// _profileBinds.Add(upKb);
// }
// else
// {
// var action = new Action(() => layerModel.LayerCondition.KeyDownTask(condition));
// var kb = new KeybindModel($"{GameName}-{Name}-{layerModel.Name}-{index}", condition.HotKey, KeyType.KeyDown, action);
//
// KeybindManager.AddOrUpdate(kb);
// _profileBinds.Add(kb);
// }
// }
// }
foreach (var layerModel in GetLayers())
layerModel.SetupKeybinds();
}
public void ClearKeybinds()
{
// foreach (var keybindModel in _profileBinds)
// KeybindManager.Remove(keybindModel);
// _profileBinds.Clear();
foreach (var layerModel in GetLayers())
layerModel.RemoveKeybinds();
}
#region Compare
@ -275,9 +244,12 @@ namespace Artemis.Profiles
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
if (ReferenceEquals(null, obj))
return false;
if (ReferenceEquals(this, obj))
return true;
if (obj.GetType() != GetType())
return false;
return Equals((ProfileModel) obj);
}

View File

@ -54,7 +54,7 @@ namespace Artemis.Utilities
bitmapImage.StreamSource = memory;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
return bitmapImage;
}
}

View File

@ -44,7 +44,9 @@ namespace Artemis.ViewModels
// Setup existing conditions
var conditions = ProposedLayer.Properties.Conditions.Select(c => new LayerConditionViewModel(this, c));
var keyBinds = ProposedLayer.Properties.LayerKeybindModels.Select(c => new LayerKeybindViewModel(this, c));
LayerConditionVms = new BindableCollection<LayerConditionViewModel>(conditions);
LayerKeybindVms = new BindableCollection<LayerKeybindViewModel>(keyBinds);
PropertyChanged += PropertiesViewModelHandler;
@ -60,6 +62,7 @@ namespace Artemis.ViewModels
public BindableCollection<ILayerType> LayerTypes { get; set; }
public BindableCollection<GeneralHelpers.PropertyCollection> DataModelProps { get; set; }
public BindableCollection<LayerConditionViewModel> LayerConditionVms { get; set; }
public BindableCollection<LayerKeybindViewModel> LayerKeybindVms { get; set; }
public bool KeyboardGridIsVisible => ProposedLayer.LayerType is KeyboardType;
public bool GifGridIsVisible => ProposedLayer.LayerType is KeyboardGifType;
@ -68,7 +71,8 @@ namespace Artemis.ViewModels
get { return _layer; }
set
{
if (Equals(value, _layer)) return;
if (Equals(value, _layer))
return;
_layer = value;
NotifyOfPropertyChange(() => Layer);
}
@ -81,7 +85,8 @@ namespace Artemis.ViewModels
get { return _proposedLayer; }
set
{
if (Equals(value, _proposedLayer)) return;
if (Equals(value, _proposedLayer))
return;
_proposedLayer = value;
NotifyOfPropertyChange(() => ProposedLayer);
}
@ -92,7 +97,8 @@ namespace Artemis.ViewModels
get { return _layerPropertiesViewModel; }
set
{
if (Equals(value, _layerPropertiesViewModel)) return;
if (Equals(value, _layerPropertiesViewModel))
return;
_layerPropertiesViewModel = value;
NotifyOfPropertyChange(() => LayerPropertiesViewModel);
}
@ -103,7 +109,8 @@ namespace Artemis.ViewModels
get { return _eventPropertiesViewModel; }
set
{
if (Equals(value, _eventPropertiesViewModel)) return;
if (Equals(value, _eventPropertiesViewModel))
return;
_eventPropertiesViewModel = value;
NotifyOfPropertyChange(() => EventPropertiesViewModel);
}
@ -114,7 +121,8 @@ namespace Artemis.ViewModels
get { return _selectedLayerType; }
set
{
if (Equals(value, _selectedLayerType)) return;
if (Equals(value, _selectedLayerType))
return;
_selectedLayerType = value;
NotifyOfPropertyChange(() => SelectedLayerType);
}
@ -167,15 +175,27 @@ namespace Artemis.ViewModels
LayerConditionVms.Add(new LayerConditionViewModel(this, condition));
}
public void AddKeybind()
{
var keybind = new LayerKeybindModel();
LayerKeybindVms.Add(new LayerKeybindViewModel(this, keybind));
}
public void Apply()
{
LayerPropertiesViewModel?.ApplyProperties();
Layer.Properties.DynamicProperties.Clear();
JsonConvert.PopulateObject(JsonConvert.SerializeObject(ProposedLayer), Layer);
Layer.Properties.Conditions.Clear();
foreach (var conditionViewModel in LayerConditionVms)
Layer.Properties.Conditions.Add(conditionViewModel.ConditionModel);
Layer.Properties.Conditions.Add(conditionViewModel.ConditionModel);
Layer.Properties.LayerKeybindModels.Clear();
foreach (var layerKeybindViewModel in LayerKeybindVms)
Layer.Properties.LayerKeybindModels.Add(layerKeybindViewModel.LayerKeybindModel);
// TODO: EventPropVM must have layer too
if (EventPropertiesViewModel != null)
@ -190,13 +210,6 @@ namespace Artemis.ViewModels
DialogService.ShowErrorMessageBox("Couldn't find or access the provided GIF file.");
}
public void DeleteCondition(LayerConditionViewModel layerConditionViewModel,
LayerConditionModel layerConditionModel)
{
LayerConditionVms.Remove(layerConditionViewModel);
Layer.Properties.Conditions.Remove(layerConditionModel);
}
public override async void CanClose(Action<bool> callback)
{
// Create a fake layer and apply the properties to it
@ -204,9 +217,17 @@ namespace Artemis.ViewModels
// TODO: EventPropVM must have layer too
if (EventPropertiesViewModel != null)
ProposedLayer.EventProperties = EventPropertiesViewModel.GetAppliedProperties();
ProposedLayer.Properties.Conditions.Clear();
foreach (var conditionViewModel in LayerConditionVms)
ProposedLayer.Properties.Conditions.Add(conditionViewModel.ConditionModel);
ProposedLayer.Properties.Conditions.Add(conditionViewModel.ConditionModel);
ProposedLayer.Properties.LayerKeybindModels.Clear();
foreach (var layerKeybindViewModel in LayerKeybindVms)
ProposedLayer.Properties.LayerKeybindModels.Add(layerKeybindViewModel.LayerKeybindModel);
// Ignore this property as it isn't user input
ProposedLayer.RenderAllowed = Layer.RenderAllowed;
// If not a keyboard, ignore size and position
if ((ProposedLayer.LayerType.DrawType != DrawType.Keyboard) || !ProposedLayer.LayerType.ShowInEdtor)
@ -236,9 +257,8 @@ namespace Artemis.ViewModels
return;
}
var close = await DialogService
.ShowQuestionMessageBox("Unsaved changes", "Do you want to discard your changes?");
var close = await DialogService.ShowQuestionMessageBox("Unsaved changes", "Do you want to discard your changes?");
callback(close.Value);
}
}
}
}

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -65,8 +66,8 @@ namespace Artemis.ViewModels
_loopManager = loopManager;
_moduleModel = moduleModel;
_dialogService = dialogService;
_copyKeybind = new KeybindModel("copy", new HotKey(Key.C, ModifierKeys.Control), KeyType.KeyDown, LayerToClipboard);
_pasteKeybind = new KeybindModel("paste", new HotKey(Key.V, ModifierKeys.Control), KeyType.KeyDown, ClipboardToLayer);
_copyKeybind = new KeybindModel("copy", new HotKey(Key.C, ModifierKeys.Control), PressType.Down, LayerToClipboard);
_pasteKeybind = new KeybindModel("paste", new HotKey(Key.V, ModifierKeys.Control), PressType.Up, ClipboardToLayer);
ProfileNames = new ObservableCollection<string>();
Layers = new ObservableCollection<LayerModel>();
@ -197,10 +198,8 @@ namespace Artemis.ViewModels
NotifyOfPropertyChange(() => LayerSelected);
}
}
public ImageSource KeyboardImage => ImageUtilities.BitmapToBitmapImage(_deviceManager.ActiveKeyboard?.PreviewSettings.Image ?? Resources.none);
public ProfileModel SelectedProfile => _moduleModel?.ProfileModel;
public PreviewSettings? PreviewSettings => _deviceManager.ActiveKeyboard?.PreviewSettings;
public bool ProfileSelected => SelectedProfile != null;
public bool LayerSelected => SelectedProfile != null && SelectedLayer != null;
public bool EditorEnabled => SelectedProfile != null && !SelectedProfile.IsDefault && _deviceManager.ActiveKeyboard != null;
@ -507,8 +506,7 @@ namespace Artemis.ViewModels
private void LoopManagerOnRenderCompleted(object sender, EventArgs eventArgs)
{
// Besides the usual checks, also check if the ActiveKeyboard isn't the NoneKeyboard
if (SelectedProfile == null || _deviceManager.ActiveKeyboard == null ||
_deviceManager.ActiveKeyboard.Slug == "none")
if (SelectedProfile == null || _deviceManager.ActiveKeyboard == null || _deviceManager.ActiveKeyboard.Slug == "none")
{
KeyboardPreview = null;
@ -519,6 +517,28 @@ namespace Artemis.ViewModels
return;
}
var renderedLayers = RenderLayers();
var visual = new DrawingVisual();
var previewSettings = _deviceManager.ActiveKeyboard.PreviewSettings;
using (var drawingContext = visual.RenderOpen())
{
var baseRect = new Rect(0, 0, previewSettings.BackgroundRectangle.Width, previewSettings.BackgroundRectangle.Height);
drawingContext.PushClip(new RectangleGeometry(baseRect));
// Draw the keyboard image
drawingContext.DrawImage(previewSettings.Image, baseRect);
// Draw the layers semi-transparent
drawingContext.PushOpacity(0.8);
drawingContext.DrawImage(renderedLayers, previewSettings.OverlayRectangle);
drawingContext.Pop();
drawingContext.Pop();
}
var drawnPreview = new DrawingImage(visual.Drawing);
drawnPreview.Freeze();
KeyboardPreview = drawnPreview;
}
private DrawingImage RenderLayers()
{
var renderLayers = GetRenderLayers();
// Draw the current frame to the preview
var keyboardRect = _deviceManager.ActiveKeyboard.KeyboardRectangle();
@ -544,7 +564,7 @@ namespace Artemis.ViewModels
var preview = new DrawingImage();
preview.Freeze();
KeyboardPreview = preview;
return;
return new DrawingImage();
}
var pen = new Pen(new SolidColorBrush((Color) accentColor), 0.4);
@ -578,11 +598,12 @@ namespace Artemis.ViewModels
}
var drawnPreview = new DrawingImage(visual.Drawing);
drawnPreview.Freeze();
KeyboardPreview = drawnPreview;
// Setup layers for the next frame
if (_moduleModel.IsInitialized && ActiveWindowHelper.MainWindowActive)
_moduleModel.PreviewLayers = renderLayers;
return drawnPreview;
}
public List<LayerModel> GetRenderLayers()
@ -681,13 +702,21 @@ namespace Artemis.ViewModels
private Point GetScaledPosition(MouseEventArgs e)
{
var previewSettings = _deviceManager.ActiveKeyboard.PreviewSettings;
var sourceImage = (Image) e.OriginalSource;
var pos = e.GetPosition(sourceImage);
var widthScale = sourceImage.ActualWidth / _deviceManager.ActiveKeyboard.PreviewSettings.BackgroundRectangle.Width;
var heightScale = sourceImage.ActualHeight / _deviceManager.ActiveKeyboard.PreviewSettings.BackgroundRectangle.Height;
// Remove the preview settings' offset from the cursor postion
pos.X = pos.X - (previewSettings.OverlayRectangle.X * widthScale);
pos.Y = pos.Y - (previewSettings.OverlayRectangle.Y * heightScale);
// Scale the X and Y position down to match the keyboard's physical size and thus the layer positions
pos.X = pos.X * (SelectedProfile.Width / sourceImage.ActualWidth);
pos.Y = pos.Y * (SelectedProfile.Height / sourceImage.ActualHeight);
pos.X = pos.X * (SelectedProfile.Width / (previewSettings.OverlayRectangle.Width*widthScale));
pos.Y = pos.Y * (SelectedProfile.Height / (previewSettings.OverlayRectangle.Height * heightScale));
return pos;
}
@ -866,12 +895,10 @@ namespace Artemis.ViewModels
}
/// <summary>
/// Handles chaning the active keyboard, updating the preview image and profiles collection
/// Handles chaning the active keyboard, updating the profiles collection
/// </summary>
private void DeviceManagerOnOnKeyboardChanged(object sender, KeyboardChangedEventArgs e)
{
NotifyOfPropertyChange(() => PreviewSettings);
NotifyOfPropertyChange(() => KeyboardImage);
LoadProfiles();
}

View File

@ -299,7 +299,7 @@ namespace Artemis.ViewModels.Profiles
/// </summary>
public void Delete()
{
_editorViewModel.DeleteCondition(this, ConditionModel);
_editorViewModel.LayerConditionVms.Remove(this);
}
public struct NamedOperator

View File

@ -0,0 +1,126 @@
using System.ComponentModel;
using System.Windows.Forms;
using Artemis.Profiles.Layers.Models;
using MahApps.Metro.Controls;
using Screen = Caliburn.Micro.Screen;
namespace Artemis.ViewModels.Profiles
{
public sealed class LayerKeybindViewModel : Screen
{
private readonly LayerEditorViewModel _editorViewModel;
private HotKey _hotKey;
private MouseButtons _mouseButtons;
private ToggleType _toggleType;
public LayerKeybindViewModel(LayerEditorViewModel editorViewModel, LayerKeybindModel layerKeybindModel)
{
_editorViewModel = editorViewModel;
LayerKeybindModel = layerKeybindModel;
PropertyChanged += MapViewToModel;
MapModelToView();
}
private void MapViewToModel(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "MouseButtonsVisible" || e.PropertyName == "HotkeyVisible")
return;
if (MouseButtonsVisible)
SetMouseBind();
else
SetKeyBind();
}
private void MapModelToView()
{
PropertyChanged -= MapViewToModel;
if (LayerKeybindModel.MouseButtons != null)
MouseButtons = LayerKeybindModel.MouseButtons.Value;
HotKey = LayerKeybindModel.HotKey;
ToggleType = LayerKeybindModel.ToggleType;
PropertyChanged += MapViewToModel;
}
public LayerKeybindModel LayerKeybindModel { get; set; }
public bool MouseButtonsVisible => LayerKeybindModel.MouseButtons != null;
public bool HotkeyVisible => LayerKeybindModel.MouseButtons == null;
public MouseButtons MouseButtons
{
get { return _mouseButtons; }
set
{
if (value == _mouseButtons)
return;
_mouseButtons = value;
NotifyOfPropertyChange(() => MouseButtons);
}
}
public HotKey HotKey
{
get { return _hotKey; }
set
{
if (Equals(value, _hotKey))
return;
_hotKey = value;
NotifyOfPropertyChange(() => HotKey);
}
}
public ToggleType ToggleType
{
get { return _toggleType; }
set
{
if (value == _toggleType)
return;
_toggleType = value;
NotifyOfPropertyChange(() => ToggleType);
}
}
public void ToggleBindType()
{
if (MouseButtonsVisible)
SetKeyBind();
else
SetMouseBind();
}
public void SetMouseBind()
{
LayerKeybindModel.Unregister();
LayerKeybindModel.HotKey = null;
LayerKeybindModel.MouseButtons = MouseButtons;
LayerKeybindModel.ToggleType = ToggleType;
NotifyOfPropertyChange(() => HotkeyVisible);
NotifyOfPropertyChange(() => MouseButtonsVisible);
}
public void SetKeyBind()
{
LayerKeybindModel.Unregister();
LayerKeybindModel.HotKey = HotKey;
LayerKeybindModel.MouseButtons = null;
LayerKeybindModel.ToggleType = ToggleType;
NotifyOfPropertyChange(() => HotkeyVisible);
NotifyOfPropertyChange(() => MouseButtonsVisible);
}
public void Delete()
{
_editorViewModel.LayerKeybindVms.Remove(this);
}
}
}

View File

@ -32,7 +32,7 @@
</Grid.ColumnDefinitions>
<!-- First column -->
<StackPanel Grid.Column="0" Grid.Row="0">
<StackPanel Grid.Column="0" Grid.Row="0" Margin="0,0,5,0">
<!-- Basic -->
<Label FontSize="20" Content="Basics" />
<Grid>
@ -75,7 +75,7 @@
</StackPanel>
<!-- Second column -->
<StackPanel Grid.Column="1" Grid.Row="0">
<StackPanel Grid.Column="1" Grid.Row="0" Margin="5,0,0,0">
<Label FontSize="20" Content="Conditions" />
<!-- Conditions -->
<Grid>
@ -103,8 +103,24 @@
</ListBox.Template>
</ListBox>
</Border>
<Button x:Name="AddCondition" Content="Add condition" VerticalAlignment="Center" Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Right" Height="30" Margin="0,10,10,10" ScrollViewer.VerticalScrollBarVisibility="Auto" />
<Button x:Name="AddCondition" Content="Add condition" VerticalAlignment="Center" Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Right" Height="30" Margin="0,10,10,-28" ScrollViewer.VerticalScrollBarVisibility="Auto" Panel.ZIndex="5"/>
<!-- Keybinds -->
<Label FontSize="20" Content="Keybinds" />
<!-- Conditions -->
<Border BorderThickness="1" BorderBrush="{StaticResource GrayBrush7}" Margin="10,0" SnapsToDevicePixels="True">
<ListBox Height="138" x:Name="LayerKeybindVms" ScrollViewer.VerticalScrollBarVisibility="Visible">
<ListBox.Template>
<ControlTemplate>
<ScrollViewer>
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
</ListBox>
</Border>
<Button x:Name="AddKeybind" Content="Add keybind" VerticalAlignment="Center" Style="{DynamicResource SquareButtonStyle}" Width="95" HorizontalAlignment="Right" Height="30" Margin="0,10,10,0" ScrollViewer.VerticalScrollBarVisibility="Auto" />
<!-- Event settings -->
<ContentControl x:Name="EventPropertiesViewModel" />
</StackPanel>

View File

@ -32,14 +32,10 @@
<Border.Effect>
<DropShadowEffect x:Name="ShadowEffect" ShadowDepth="0" Color="{DynamicResource HighlightColor}" Opacity="1" BlurRadius="25" />
</Border.Effect>
<Grid>
<Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=KeyboardImage}" MinHeight="10" MinWidth="10" Stretch="Uniform" />
<Image Grid.Column="0" Grid.Row="0" Source="{Binding Path=KeyboardPreview}" Opacity="0.8" Stretch="Uniform" Cursor="{Binding Path=KeyboardPreviewCursor}"
IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}" Margin="{Binding Path=PreviewSettings.Margin}" cal:Message.Attach="
<Image Source="{Binding Path=KeyboardPreview}" MinHeight="10" MinWidth="10" Stretch="Uniform" Cursor="{Binding Path=KeyboardPreviewCursor}" IsEnabled="{Binding Path=EditorEnabled, Mode=OneWay}" cal:Message.Attach="
[Event MouseMove] = [Action MouseMoveKeyboardPreview($eventArgs)];
[Event MouseDown] = [Action MouseDownKeyboardPreview($eventArgs)];
[Event MouseUp] = [Action MouseUpKeyboardPreview($eventArgs)]" />
</Grid>
</Border>
</Border>
<!-- Profile management -->

View File

@ -0,0 +1,77 @@
<UserControl x:Class="Artemis.Views.Profiles.LayerKeybindView"
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:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:converters="clr-namespace:Artemis.Utilities.Converters"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:properties="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:models="clr-namespace:Artemis.Profiles.Layers.Models"
mc:Ignorable="d" d:DesignWidth="600">
<UserControl.Resources>
<converters:EnumDescriptionConverter x:Key="HEnumDescriptionConverter" />
<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type system:Enum}" x:Key="ToggleTypeEnumValues">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="models:ToggleType" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type system:Enum}" x:Key="MouseButtonsEnumValues">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="properties:MouseButtons" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</UserControl.Resources>
<Grid Margin="1,5,5,5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- Type -->
<ComboBox Grid.Column="0" ItemsSource="{Binding Source={StaticResource ToggleTypeEnumValues}}" SelectedItem="{Binding Path=ToggleType}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource HEnumDescriptionConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<!-- Bind -->
<TextBlock Grid.Column="1" Text="bound to" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0" />
<controls:HotKeyBox Grid.Column="2" HotKey="{Binding Path=HotKey}" Watermark="Enter keybind" Visibility="{Binding Path=HotkeyVisible, Converter={StaticResource BoolToVis} }"/>
<ComboBox Grid.Column="2" ItemsSource="{Binding Source={StaticResource MouseButtonsEnumValues}}" SelectedItem="{Binding Path=MouseButtons}" Visibility="{Binding Path=MouseButtonsVisible, Converter={StaticResource BoolToVis} }">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource HEnumDescriptionConverter}}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<!-- Mouse/keyboard button -->
<Button Grid.Column="3" x:Name="ToggleBindType" Width="22" Height="22" Style="{DynamicResource SquareButtonStyle}" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,0,0,0">
<Button.Content>
<Rectangle Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Width="12" Height="12">
<Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_hardware_mouse}" Stretch="Fill" />
</Rectangle.OpacityMask>
</Rectangle>
</Button.Content>
</Button>
<!-- Delete button -->
<Button Grid.Column="4" x:Name="Delete" Width="22" Height="22" Style="{DynamicResource SquareButtonStyle}" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,0,0,0">
<Button.Content>
<Rectangle
Fill="{Binding Path=Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Width="12" Height="12">
<Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_delete}" Stretch="Fill" />
</Rectangle.OpacityMask>
</Rectangle>
</Button.Content>
</Button>
</Grid>
</UserControl>

View File

@ -0,0 +1,15 @@
using System.Windows.Controls;
namespace Artemis.Views.Profiles
{
/// <summary>
/// Interaction logic for LayerKeybindView.xaml
/// </summary>
public partial class LayerKeybindView : UserControl
{
public LayerKeybindView()
{
InitializeComponent();
}
}
}

View File

@ -10,7 +10,7 @@
xmlns:tb="http://www.hardcodet.net/taskbar"
dialogs:DialogParticipation.Register="{Binding RelativeSource={RelativeSource Self}, Path=DataContext}"
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:ShellViewModel}"
Title="Artemis" Height="800" Width="1210" ResizeMode="NoResize" GlowBrush="{DynamicResource AccentColorBrush}" Icon="../logo.ico">
Title="Artemis" Height="800" Width="1210" MinHeight="600" MinWidth="1000" GlowBrush="{DynamicResource AccentColorBrush}" Icon="../logo.ico">
<!-- Bit of extra code to use a different icon than in the taskbar -->
<Controls:MetroWindow.Resources>
<DrawingImage x:Key="BowIcon">