diff --git a/Artemis/Artemis.sln b/Artemis/Artemis.sln
index d48581c3b..6c8abbab3 100644
--- a/Artemis/Artemis.sln
+++ b/Artemis/Artemis.sln
@@ -5,6 +5,8 @@ VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis", "Artemis\Artemis.csproj", "{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Razer2Artemis", "Razer2Artemis\Razer2Artemis.vcxproj", "{39711909-C1D5-46CE-A9EA-2D561692EA47}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
CD_ROM|Any CPU = CD_ROM|Any CPU
@@ -54,6 +56,34 @@ Global
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x64.Build.0 = Release|x64
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.ActiveCfg = Release|x86
{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.SingleImage|x86.Build.0 = Release|x86
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|Any CPU.ActiveCfg = Release|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|Any CPU.Build.0 = Release|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|x64.ActiveCfg = Release|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|x64.Build.0 = Release|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|x86.ActiveCfg = Release|Win32
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.CD_ROM|x86.Build.0 = Release|Win32
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|x64.ActiveCfg = Debug|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|x64.Build.0 = Debug|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|x86.ActiveCfg = Debug|Win32
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.Debug|x86.Build.0 = Debug|Win32
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|Any CPU.ActiveCfg = Release|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|Any CPU.Build.0 = Release|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|x64.ActiveCfg = Debug|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|x64.Build.0 = Debug|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|x86.ActiveCfg = Debug|Win32
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.DVD-5|x86.Build.0 = Debug|Win32
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|Any CPU.ActiveCfg = Release|Win32
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|x64.ActiveCfg = Release|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|x64.Build.0 = Release|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|x86.ActiveCfg = Release|Win32
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.Release|x86.Build.0 = Release|Win32
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|Any CPU.ActiveCfg = Release|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|Any CPU.Build.0 = Release|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x64.ActiveCfg = Release|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x64.Build.0 = Release|x64
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x86.ActiveCfg = Release|Win32
+ {39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Artemis/Artemis/App.xaml.cs b/Artemis/Artemis/App.xaml.cs
index 5379a5cf8..e2b94fb9c 100644
--- a/Artemis/Artemis/App.xaml.cs
+++ b/Artemis/Artemis/App.xaml.cs
@@ -1,4 +1,5 @@
using System;
+using System.Security.Principal;
using System.Windows;
using System.Windows.Threading;
using Artemis.Utilities;
@@ -14,12 +15,20 @@ namespace Artemis
{
public App()
{
- if (!GeneralHelpers.IsRunAsAdministrator())
+ if (!IsRunAsAdministrator())
GeneralHelpers.RunAsAdministrator();
InitializeComponent();
}
+ private static bool IsRunAsAdministrator()
+ {
+ var wi = WindowsIdentity.GetCurrent();
+ var wp = new WindowsPrincipal(wi);
+
+ return wp.IsInRole(WindowsBuiltInRole.Administrator);
+ }
+
public bool DoHandle { get; set; }
private void Application_Startup(object sender, StartupEventArgs e)
diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj
index 542b424c5..955cc87d2 100644
--- a/Artemis/Artemis/Artemis.csproj
+++ b/Artemis/Artemis/Artemis.csproj
@@ -464,17 +464,18 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
@@ -508,25 +509,25 @@
Witcher3View.xaml
-
+
FolderPropertiesView.xaml
-
+
HeadsetPropertiesView.xaml
-
+
KeyboardPropertiesView.xaml
-
+
LayerConditionView.xaml
-
+
LayerDynamicPropertiesView.xaml
-
+
LayerEditorView.xaml
-
+
MousePropertiesView.xaml
@@ -535,7 +536,7 @@
VolumeDisplayView.xaml
-
+
ProfileEditorView.xaml
@@ -696,31 +697,31 @@
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
-
+
MSBuild:Compile
Designer
-
+
Designer
MSBuild:Compile
@@ -732,7 +733,7 @@
Designer
MSBuild:Compile
-
+
Designer
MSBuild:Compile
diff --git a/Artemis/Artemis/InjectionFactories/IProfileEditorViewModelFactory.cs b/Artemis/Artemis/InjectionFactories/IProfileEditorViewModelFactory.cs
index 1ed1c17aa..31eb5138c 100644
--- a/Artemis/Artemis/InjectionFactories/IProfileEditorViewModelFactory.cs
+++ b/Artemis/Artemis/InjectionFactories/IProfileEditorViewModelFactory.cs
@@ -1,6 +1,7 @@
using Artemis.Managers;
using Artemis.Models;
using Artemis.ViewModels;
+using Artemis.ViewModels.Profiles;
using Caliburn.Micro;
namespace Artemis.InjectionFactories
diff --git a/Artemis/Artemis/InjectionModules/ArtemisModules.cs b/Artemis/Artemis/InjectionModules/ArtemisModules.cs
index 5b5ae02a9..4f013698d 100644
--- a/Artemis/Artemis/InjectionModules/ArtemisModules.cs
+++ b/Artemis/Artemis/InjectionModules/ArtemisModules.cs
@@ -20,6 +20,8 @@ namespace Artemis.InjectionModules
{
public override void Load()
{
+ #region Modules
+
// Effects
Bind().To().InSingletonScope();
Bind().To().InSingletonScope();
@@ -36,7 +38,10 @@ namespace Artemis.InjectionModules
// Overlays
Bind().To().InSingletonScope();
- // Device Providers
+ #endregion
+
+ #region Devices
+
// Keyboards
Bind().To().InSingletonScope();
Bind().To().InSingletonScope();
@@ -45,6 +50,8 @@ namespace Artemis.InjectionModules
Bind().To().InSingletonScope();
// Headsets
Bind().To().InSingletonScope();
+
+ #endregion
}
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/InjectionModules/BaseModules.cs b/Artemis/Artemis/InjectionModules/BaseModules.cs
index 46c2fcd2a..dcbcc440b 100644
--- a/Artemis/Artemis/InjectionModules/BaseModules.cs
+++ b/Artemis/Artemis/InjectionModules/BaseModules.cs
@@ -3,6 +3,7 @@ using Artemis.Modules.Effects.ProfilePreview;
using Artemis.Services;
using Artemis.ViewModels;
using Artemis.ViewModels.Abstract;
+using Artemis.ViewModels.Profiles;
using Caliburn.Micro;
using Ninject.Extensions.Factory;
using Ninject.Modules;
@@ -16,6 +17,7 @@ namespace Artemis.InjectionModules
// ViewModels
Bind().To().InSingletonScope();
Bind().ToFactory();
+ Bind().ToSelf();
Bind().To().InSingletonScope();
Bind().To().InSingletonScope();
diff --git a/Artemis/Artemis/Managers/ProfileManager.cs b/Artemis/Artemis/Managers/ProfileManager.cs
index f998913bc..0bdf27565 100644
--- a/Artemis/Artemis/Managers/ProfileManager.cs
+++ b/Artemis/Artemis/Managers/ProfileManager.cs
@@ -3,6 +3,7 @@ using System.Linq;
using System.Timers;
using Artemis.Models;
using Artemis.Modules.Effects.ProfilePreview;
+using Artemis.Settings;
using Artemis.ViewModels.Abstract;
using Ninject.Extensions.Logging;
@@ -10,13 +11,14 @@ namespace Artemis.Managers
{
public class ProfileManager
{
- private readonly EffectManager _effectManager;
private readonly DeviceManager _deviceManager;
- private readonly LoopManager _loopManager;
+ private readonly EffectManager _effectManager;
private readonly ILogger _logger;
+ private readonly LoopManager _loopManager;
private EffectModel _prePreviewEffect;
- public ProfileManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager, LoopManager loopManager)
+ public ProfileManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager,
+ LoopManager loopManager)
{
_logger = logger;
_effectManager = effectManager;
@@ -41,7 +43,8 @@ namespace Artemis.Managers
///
private void SetupProfilePreview(object sender, ElapsedEventArgs e)
{
- if (_deviceManager.ActiveKeyboard == null ||_deviceManager.ChangingKeyboard || ProfilePreviewModel == null)
+ if (string.IsNullOrEmpty(General.Default.LastKeyboard) || _deviceManager.ChangingKeyboard ||
+ ProfilePreviewModel == null)
return;
var activePreview = GameViewModels.FirstOrDefault(vm => vm.IsActive);
@@ -73,7 +76,7 @@ namespace Artemis.Managers
// LoopManager might be running, this method won't do any harm in that case.
_loopManager.Start();
-
+
if (!ReferenceEquals(ProfilePreviewModel.SelectedProfile, activePreview.ProfileEditor.SelectedProfile))
ProfilePreviewModel.SelectedProfile = activePreview.ProfileEditor.SelectedProfile;
}
diff --git a/Artemis/Artemis/Models/Profiles/LayerModel.cs b/Artemis/Artemis/Models/Profiles/LayerModel.cs
index f6e6b1ad6..16a8afa72 100644
--- a/Artemis/Artemis/Models/Profiles/LayerModel.cs
+++ b/Artemis/Artemis/Models/Profiles/LayerModel.cs
@@ -101,7 +101,7 @@ namespace Artemis.Models.Profiles
else
appliedProperties = Properties.Brush.Dispatcher.Invoke(() => GeneralHelpers.Clone(Properties));
- // TODO: Animations
+ // TODO: Mouse/headset animations
// Update animations on layer types that support them
//if (LayerType != LayerType.Folder && updateAnimations)
//{
diff --git a/Artemis/Artemis/Models/Profiles/ProfileModel.cs b/Artemis/Artemis/Models/Profiles/ProfileModel.cs
index 43de4b4e9..83e237b8f 100644
--- a/Artemis/Artemis/Models/Profiles/ProfileModel.cs
+++ b/Artemis/Artemis/Models/Profiles/ProfileModel.cs
@@ -154,6 +154,10 @@ namespace Artemis.Models.Profiles
return layers;
}
+ ///
+ /// Looks at all the layers wthin the profile and makes sure they are within boundaries of the given rectangle
+ ///
+ ///
public void FixBoundaries(Rect keyboardRectangle)
{
foreach (var layer in GetLayers(false))
diff --git a/Artemis/Artemis/Modules/Effects/ProfilePreview/ProfilePreviewModel.cs b/Artemis/Artemis/Modules/Effects/ProfilePreview/ProfilePreviewModel.cs
index 1bb6a0fe7..3e9f97177 100644
--- a/Artemis/Artemis/Modules/Effects/ProfilePreview/ProfilePreviewModel.cs
+++ b/Artemis/Artemis/Modules/Effects/ProfilePreview/ProfilePreviewModel.cs
@@ -36,6 +36,8 @@ namespace Artemis.Modules.Effects.ProfilePreview
public override Bitmap GenerateBitmap()
{
+ if (MainManager.DeviceManager.ActiveKeyboard == null)
+ return null;
var bitmap = MainManager.DeviceManager.ActiveKeyboard.KeyboardBitmap(4);
if (SelectedProfile == null)
diff --git a/Artemis/Artemis/Utilities/GeneralHelpers.cs b/Artemis/Artemis/Utilities/GeneralHelpers.cs
index 5003a40c1..3fc206095 100644
--- a/Artemis/Artemis/Utilities/GeneralHelpers.cs
+++ b/Artemis/Artemis/Utilities/GeneralHelpers.cs
@@ -38,22 +38,6 @@ namespace Artemis.Utilities
Environment.Exit(0);
}
- public static bool IsRunAsAdministrator()
- {
- var wi = WindowsIdentity.GetCurrent();
- var wp = new WindowsPrincipal(wi);
-
- return wp.IsInRole(WindowsBuiltInRole.Administrator);
- }
-
- public static void CopyProperties(object dest, object src)
- {
- foreach (PropertyDescriptor item in TypeDescriptor.GetProperties(src))
- {
- item.SetValue(dest, item.GetValue(src));
- }
- }
-
///
/// Perform a deep Copy of the object.
///
@@ -87,7 +71,6 @@ namespace Artemis.Utilities
}
public static List GenerateTypeMap(object o) => GenerateTypeMap(o.GetType().GetProperties());
- public static List GenerateTypeMap() => GenerateTypeMap(typeof(T).GetProperties());
private static List GenerateTypeMap(IEnumerable getProperties,
string path = "")
diff --git a/Artemis/Artemis/Utilities/ImageUtilities.cs b/Artemis/Artemis/Utilities/ImageUtilities.cs
index 3e395ee62..a83f22e67 100644
--- a/Artemis/Artemis/Utilities/ImageUtilities.cs
+++ b/Artemis/Artemis/Utilities/ImageUtilities.cs
@@ -37,30 +37,6 @@ namespace Artemis.Utilities
return result;
}
- public static Bitmap BitmapSourceToBitmap(BitmapSource srs)
- {
- var width = srs.PixelWidth;
- var height = srs.PixelHeight;
- var stride = width*((srs.Format.BitsPerPixel + 7)/8);
- var ptr = IntPtr.Zero;
- try
- {
- ptr = Marshal.AllocHGlobal(height*stride);
- srs.CopyPixels(new Int32Rect(0, 0, width, height), ptr, height*stride, stride);
- using (var btm = new Bitmap(width, height, stride, PixelFormat.Format1bppIndexed, ptr))
- {
- // Clone the bitmap so that we can dispose it and
- // release the unmanaged memory at ptr
- return new Bitmap(btm);
- }
- }
- finally
- {
- if (ptr != IntPtr.Zero)
- Marshal.FreeHGlobal(ptr);
- }
- }
-
public static BitmapImage BitmapToBitmapImage(Bitmap b)
{
if (b == null)
diff --git a/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs b/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs
index 5c1040255..dc98fae7b 100644
--- a/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Abstract/GameViewModel.cs
@@ -6,6 +6,7 @@ using Artemis.Managers;
using Artemis.Models;
using Artemis.Modules.Effects.ProfilePreview;
using Artemis.Services;
+using Artemis.ViewModels.Profiles;
using Caliburn.Micro;
using Ninject;
using Ninject.Extensions.Logging;
@@ -103,13 +104,13 @@ namespace Artemis.ViewModels.Abstract
protected override void OnActivate()
{
base.OnActivate();
- ProfileEditor.PreviewTimer.Start();
+ ProfileEditor.ProfileViewModel.Activate();
}
protected override void OnDeactivate(bool close)
{
base.OnDeactivate(close);
- ProfileEditor.PreviewTimer.Stop();
+ ProfileEditor.ProfileViewModel.Deactivate();
}
}
diff --git a/Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs b/Artemis/Artemis/ViewModels/Profiles/LayerConditionViewModel.cs
similarity index 96%
rename from Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs
rename to Artemis/Artemis/ViewModels/Profiles/LayerConditionViewModel.cs
index edc26b714..b3af86ea1 100644
--- a/Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Profiles/LayerConditionViewModel.cs
@@ -1,236 +1,236 @@
-using System.ComponentModel;
-using System.Linq;
-using Artemis.Models.Profiles;
-using Artemis.Utilities;
-using Caliburn.Micro;
-
-namespace Artemis.ViewModels.LayerEditor
-{
- public sealed class LayerConditionViewModel : Screen
- {
- private readonly NamedOperator[] _boolOperators =
- {
- new NamedOperator("True", "== True"),
- new NamedOperator("False", "== False")
- };
-
- private readonly LayerEditorViewModel _conditionModel;
-
- private readonly NamedOperator[] _int32Operators =
- {
- new NamedOperator("Lower than", "<"),
- new NamedOperator("Lower or equal to", "<="),
- new NamedOperator("Higher than", ">"),
- new NamedOperator("Higher or equal to", ">="),
- new NamedOperator("Equal to", "=="),
- new NamedOperator("Not equal to", "!=")
- };
-
- private readonly NamedOperator[] _operators =
- {
- new NamedOperator("Equal to", "=="),
- new NamedOperator("Not equal to", "!=")
- };
-
- private bool _enumValueIsVisible;
- private bool _preselecting;
- private GeneralHelpers.PropertyCollection _selectedDataModelProp;
- private string _selectedEnum;
- private NamedOperator _selectedOperator;
- private string _userValue;
- private bool _userValueIsVisible;
-
- public LayerConditionViewModel(LayerEditorViewModel conditionModel, LayerConditionModel layerConditionModel,
- BindableCollection dataModelProps)
- {
- _conditionModel = conditionModel;
- _preselecting = false;
-
- LayerConditionModel = layerConditionModel;
- DataModelProps = dataModelProps;
- Operators = new BindableCollection();
- Enums = new BindableCollection();
-
- PropertyChanged += UpdateModel;
- PropertyChanged += UpdateForm;
-
- PreSelect();
- }
-
- public LayerConditionModel LayerConditionModel { get; set; }
-
- public BindableCollection DataModelProps { get; set; }
-
- public BindableCollection Operators { get; set; }
- public BindableCollection Enums { get; set; }
-
- public string UserValue
- {
- get { return _userValue; }
- set
- {
- if (value == _userValue) return;
- _userValue = value;
- NotifyOfPropertyChange(() => UserValue);
- }
- }
-
- public GeneralHelpers.PropertyCollection SelectedDataModelProp
- {
- get { return _selectedDataModelProp; }
- set
- {
- if (value.Equals(_selectedDataModelProp)) return;
- _selectedDataModelProp = value;
- NotifyOfPropertyChange(() => SelectedDataModelProp);
- }
- }
-
-
- public bool UserValueIsVisible
- {
- get { return _userValueIsVisible; }
- set
- {
- if (value == _userValueIsVisible) return;
- _userValueIsVisible = value;
- NotifyOfPropertyChange(() => UserValueIsVisible);
- }
- }
-
- public bool EnumValueIsVisible
- {
- get { return _enumValueIsVisible; }
- set
- {
- if (value == _enumValueIsVisible) return;
- _enumValueIsVisible = value;
- NotifyOfPropertyChange(() => EnumValueIsVisible);
- }
- }
-
- public NamedOperator SelectedOperator
- {
- get { return _selectedOperator; }
- set
- {
- if (value.Equals(_selectedOperator)) return;
- _selectedOperator = value;
- NotifyOfPropertyChange(() => SelectedOperator);
- }
- }
-
- public string SelectedEnum
- {
- get { return _selectedEnum; }
- set
- {
- if (value == _selectedEnum) return;
- _selectedEnum = value;
- NotifyOfPropertyChange(() => SelectedEnum);
- }
- }
-
- ///
- /// Handles updating the form to match the selected data model property
- ///
- ///
- ///
- private void UpdateForm(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName != "SelectedDataModelProp")
- return;
-
- Operators.Clear();
- UserValueIsVisible = false;
- EnumValueIsVisible = false;
-
- switch (SelectedDataModelProp.Type)
- {
- case "Int32":
- Operators.AddRange(_int32Operators);
- UserValueIsVisible = true;
- break;
- case "Boolean":
- Operators.AddRange(_boolOperators);
- break;
- default:
- Operators.AddRange(_operators);
- UserValueIsVisible = true;
- break;
- }
-
- // Setup Enum selection if needed
- if (SelectedDataModelProp.EnumValues != null)
- {
- Enums.AddRange(SelectedDataModelProp.EnumValues);
- EnumValueIsVisible = true;
- }
-
- SelectedOperator = Operators.First();
- }
-
-
- ///
- /// Handles saving user input to the model
- /// TODO: Data validation?
- ///
- ///
- ///
- private void UpdateModel(object sender, PropertyChangedEventArgs e)
- {
- // Don't mess with model during preselect
- if (_preselecting)
- return;
-
- // Only care about these fields
- if (e.PropertyName != "UserValue" &&
- e.PropertyName != "SelectedOperator" &&
- e.PropertyName != "SelectedDataModelProp" &&
- e.PropertyName != "SelectedEnum")
- return;
-
- LayerConditionModel.Field = SelectedDataModelProp.Path;
- LayerConditionModel.Operator = SelectedOperator.Value;
- LayerConditionModel.Type = SelectedDataModelProp.Type;
- LayerConditionModel.Value = SelectedDataModelProp.Type == "Enum" ? SelectedEnum : UserValue;
- }
-
- ///
- /// Setup the current UI elements to show the backing model
- ///
- private void PreSelect()
- {
- _preselecting = true;
- SelectedDataModelProp = DataModelProps.FirstOrDefault(m => m.Path == LayerConditionModel.Field);
- SelectedOperator = Operators.FirstOrDefault(o => o.Value == LayerConditionModel.Operator);
- LayerConditionModel.Type = SelectedDataModelProp.Type;
- if (LayerConditionModel.Type =="Enum")
- SelectedEnum = LayerConditionModel.Value;
- else
- UserValue = LayerConditionModel.Value;
-
- _preselecting = false;
- }
-
- ///
- /// Delete the current model from the parent
- ///
- public void Delete()
- {
- _conditionModel.DeleteCondition(this, LayerConditionModel);
- }
-
- public struct NamedOperator
- {
- public string Display { get; set; }
- public string Value { get; set; }
-
- public NamedOperator(string display, string value)
- {
- Display = display;
- Value = value;
- }
- }
- }
+using System.ComponentModel;
+using System.Linq;
+using Artemis.Models.Profiles;
+using Artemis.Utilities;
+using Caliburn.Micro;
+
+namespace Artemis.ViewModels.Profiles
+{
+ public sealed class LayerConditionViewModel : Screen
+ {
+ private readonly NamedOperator[] _boolOperators =
+ {
+ new NamedOperator("True", "== True"),
+ new NamedOperator("False", "== False")
+ };
+
+ private readonly LayerEditorViewModel _conditionModel;
+
+ private readonly NamedOperator[] _int32Operators =
+ {
+ new NamedOperator("Lower than", "<"),
+ new NamedOperator("Lower or equal to", "<="),
+ new NamedOperator("Higher than", ">"),
+ new NamedOperator("Higher or equal to", ">="),
+ new NamedOperator("Equal to", "=="),
+ new NamedOperator("Not equal to", "!=")
+ };
+
+ private readonly NamedOperator[] _operators =
+ {
+ new NamedOperator("Equal to", "=="),
+ new NamedOperator("Not equal to", "!=")
+ };
+
+ private bool _enumValueIsVisible;
+ private bool _preselecting;
+ private GeneralHelpers.PropertyCollection _selectedDataModelProp;
+ private string _selectedEnum;
+ private NamedOperator _selectedOperator;
+ private string _userValue;
+ private bool _userValueIsVisible;
+
+ public LayerConditionViewModel(LayerEditorViewModel conditionModel, LayerConditionModel layerConditionModel,
+ BindableCollection dataModelProps)
+ {
+ _conditionModel = conditionModel;
+ _preselecting = false;
+
+ LayerConditionModel = layerConditionModel;
+ DataModelProps = dataModelProps;
+ Operators = new BindableCollection();
+ Enums = new BindableCollection();
+
+ PropertyChanged += UpdateModel;
+ PropertyChanged += UpdateForm;
+
+ PreSelect();
+ }
+
+ public LayerConditionModel LayerConditionModel { get; set; }
+
+ public BindableCollection DataModelProps { get; set; }
+
+ public BindableCollection Operators { get; set; }
+ public BindableCollection Enums { get; set; }
+
+ public string UserValue
+ {
+ get { return _userValue; }
+ set
+ {
+ if (value == _userValue) return;
+ _userValue = value;
+ NotifyOfPropertyChange(() => UserValue);
+ }
+ }
+
+ public GeneralHelpers.PropertyCollection SelectedDataModelProp
+ {
+ get { return _selectedDataModelProp; }
+ set
+ {
+ if (value.Equals(_selectedDataModelProp)) return;
+ _selectedDataModelProp = value;
+ NotifyOfPropertyChange(() => SelectedDataModelProp);
+ }
+ }
+
+
+ public bool UserValueIsVisible
+ {
+ get { return _userValueIsVisible; }
+ set
+ {
+ if (value == _userValueIsVisible) return;
+ _userValueIsVisible = value;
+ NotifyOfPropertyChange(() => UserValueIsVisible);
+ }
+ }
+
+ public bool EnumValueIsVisible
+ {
+ get { return _enumValueIsVisible; }
+ set
+ {
+ if (value == _enumValueIsVisible) return;
+ _enumValueIsVisible = value;
+ NotifyOfPropertyChange(() => EnumValueIsVisible);
+ }
+ }
+
+ public NamedOperator SelectedOperator
+ {
+ get { return _selectedOperator; }
+ set
+ {
+ if (value.Equals(_selectedOperator)) return;
+ _selectedOperator = value;
+ NotifyOfPropertyChange(() => SelectedOperator);
+ }
+ }
+
+ public string SelectedEnum
+ {
+ get { return _selectedEnum; }
+ set
+ {
+ if (value == _selectedEnum) return;
+ _selectedEnum = value;
+ NotifyOfPropertyChange(() => SelectedEnum);
+ }
+ }
+
+ ///
+ /// Handles updating the form to match the selected data model property
+ ///
+ ///
+ ///
+ private void UpdateForm(object sender, PropertyChangedEventArgs e)
+ {
+ if (e.PropertyName != "SelectedDataModelProp")
+ return;
+
+ Operators.Clear();
+ UserValueIsVisible = false;
+ EnumValueIsVisible = false;
+
+ switch (SelectedDataModelProp.Type)
+ {
+ case "Int32":
+ Operators.AddRange(_int32Operators);
+ UserValueIsVisible = true;
+ break;
+ case "Boolean":
+ Operators.AddRange(_boolOperators);
+ break;
+ default:
+ Operators.AddRange(_operators);
+ UserValueIsVisible = true;
+ break;
+ }
+
+ // Setup Enum selection if needed
+ if (SelectedDataModelProp.EnumValues != null)
+ {
+ Enums.AddRange(SelectedDataModelProp.EnumValues);
+ EnumValueIsVisible = true;
+ }
+
+ SelectedOperator = Operators.First();
+ }
+
+
+ ///
+ /// Handles saving user input to the model
+ /// TODO: Data validation?
+ ///
+ ///
+ ///
+ private void UpdateModel(object sender, PropertyChangedEventArgs e)
+ {
+ // Don't mess with model during preselect
+ if (_preselecting)
+ return;
+
+ // Only care about these fields
+ if (e.PropertyName != "UserValue" &&
+ e.PropertyName != "SelectedOperator" &&
+ e.PropertyName != "SelectedDataModelProp" &&
+ e.PropertyName != "SelectedEnum")
+ return;
+
+ LayerConditionModel.Field = SelectedDataModelProp.Path;
+ LayerConditionModel.Operator = SelectedOperator.Value;
+ LayerConditionModel.Type = SelectedDataModelProp.Type;
+ LayerConditionModel.Value = SelectedDataModelProp.Type == "Enum" ? SelectedEnum : UserValue;
+ }
+
+ ///
+ /// Setup the current UI elements to show the backing model
+ ///
+ private void PreSelect()
+ {
+ _preselecting = true;
+ SelectedDataModelProp = DataModelProps.FirstOrDefault(m => m.Path == LayerConditionModel.Field);
+ SelectedOperator = Operators.FirstOrDefault(o => o.Value == LayerConditionModel.Operator);
+ LayerConditionModel.Type = SelectedDataModelProp.Type;
+ if (LayerConditionModel.Type =="Enum")
+ SelectedEnum = LayerConditionModel.Value;
+ else
+ UserValue = LayerConditionModel.Value;
+
+ _preselecting = false;
+ }
+
+ ///
+ /// Delete the current model from the parent
+ ///
+ public void Delete()
+ {
+ _conditionModel.DeleteCondition(this, LayerConditionModel);
+ }
+
+ public struct NamedOperator
+ {
+ public string Display { get; set; }
+ public string Value { get; set; }
+
+ public NamedOperator(string display, string value)
+ {
+ Display = display;
+ Value = value;
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/Artemis/Artemis/ViewModels/LayerEditor/LayerDynamicPropertiesViewModel.cs b/Artemis/Artemis/ViewModels/Profiles/LayerDynamicPropertiesViewModel.cs
similarity index 98%
rename from Artemis/Artemis/ViewModels/LayerEditor/LayerDynamicPropertiesViewModel.cs
rename to Artemis/Artemis/ViewModels/Profiles/LayerDynamicPropertiesViewModel.cs
index 150d23e29..dcdb69303 100644
--- a/Artemis/Artemis/ViewModels/LayerEditor/LayerDynamicPropertiesViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Profiles/LayerDynamicPropertiesViewModel.cs
@@ -4,7 +4,7 @@ using Artemis.Models.Profiles.Properties;
using Artemis.Utilities;
using Caliburn.Micro;
-namespace Artemis.ViewModels.LayerEditor
+namespace Artemis.ViewModels.Profiles
{
public sealed class LayerDynamicPropertiesViewModel : PropertyChangedBase
{
@@ -33,7 +33,7 @@ namespace Artemis.ViewModels.LayerEditor
Proposed.LayerPropertyType = LayerPropertyType.PercentageOf;
}
else
- GeneralHelpers.CopyProperties(Proposed, original);
+ Proposed = GeneralHelpers.Clone(original);
PropertyChanged += OnPropertyChanged;
SetupControls(dataModelProps);
diff --git a/Artemis/Artemis/ViewModels/LayerEditor/LayerEditorViewModel.cs b/Artemis/Artemis/ViewModels/Profiles/LayerEditorViewModel.cs
similarity index 98%
rename from Artemis/Artemis/ViewModels/LayerEditor/LayerEditorViewModel.cs
rename to Artemis/Artemis/ViewModels/Profiles/LayerEditorViewModel.cs
index 6b151b23c..28257dcc9 100644
--- a/Artemis/Artemis/ViewModels/LayerEditor/LayerEditorViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Profiles/LayerEditorViewModel.cs
@@ -6,11 +6,11 @@ using Artemis.Models.Profiles;
using Artemis.Models.Profiles.Properties;
using Artemis.Services;
using Artemis.Utilities;
-using Artemis.ViewModels.LayerEditor.Properties;
+using Artemis.ViewModels.Profiles.Properties;
using Caliburn.Micro;
using Ninject;
-namespace Artemis.ViewModels.LayerEditor
+namespace Artemis.ViewModels.Profiles
{
public sealed class LayerEditorViewModel : Screen
{
diff --git a/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs b/Artemis/Artemis/ViewModels/Profiles/ProfileEditorViewModel.cs
similarity index 60%
rename from Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs
rename to Artemis/Artemis/ViewModels/Profiles/ProfileEditorViewModel.cs
index a7d9c2920..94de681dd 100644
--- a/Artemis/Artemis/ViewModels/ProfileEditorViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Profiles/ProfileEditorViewModel.cs
@@ -1,760 +1,548 @@
-using System;
-using System.ComponentModel;
-using System.Dynamic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Timers;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Forms;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Threading;
-using Artemis.DAL;
-using Artemis.DeviceProviders;
-using Artemis.Events;
-using Artemis.Managers;
-using Artemis.Models;
-using Artemis.Models.Profiles;
-using Artemis.Models.Profiles.Properties;
-using Artemis.Services;
-using Artemis.Styles.DropTargetAdorners;
-using Artemis.Utilities;
-using Artemis.ViewModels.LayerEditor;
-using Caliburn.Micro;
-using GongSolutions.Wpf.DragDrop;
-using MahApps.Metro;
-using Ninject;
-using Application = System.Windows.Application;
-using Cursor = System.Windows.Input.Cursor;
-using Cursors = System.Windows.Input.Cursors;
-using DragDropEffects = System.Windows.DragDropEffects;
-using IDropTarget = GongSolutions.Wpf.DragDrop.IDropTarget;
-using MouseEventArgs = System.Windows.Input.MouseEventArgs;
-using Screen = Caliburn.Micro.Screen;
-using Timer = System.Timers.Timer;
-
-namespace Artemis.ViewModels
-{
- public sealed class ProfileEditorViewModel : Screen, IHandle, IDropTarget
- {
- private readonly GameModel _gameModel;
- private readonly MainManager _mainManager;
- private DateTime _downTime;
- private LayerModel _draggingLayer;
- private Point? _draggingLayerOffset;
- private LayerEditorViewModel _editorVm;
- private ImageSource _keyboardPreview;
- private Cursor _keyboardPreviewCursor;
- private BindableCollection _layers;
- private BindableCollection _profiles;
- private bool _resizing;
- private LayerModel _selectedLayer;
- private ProfileModel _selectedProfile;
-
- public ProfileEditorViewModel(IEventAggregator events, MainManager mainManager, GameModel gameModel,
- MetroDialogService dialogService)
- {
- _mainManager = mainManager;
- _gameModel = gameModel;
-
- Profiles = new BindableCollection();
- Layers = new BindableCollection();
- ActiveKeyboard = _mainManager.DeviceManager.ActiveKeyboard;
- DialogService = dialogService;
-
- events.Subscribe(this);
-
- PreviewTimer = new Timer(40);
- PreviewTimer.Elapsed += InvokeUpdateKeyboardPreview;
-
- PropertyChanged += PropertyChangeHandler;
- LoadProfiles();
- }
-
- [Inject]
- public MetroDialogService DialogService { get; set; }
-
- public Timer PreviewTimer { get; set; }
-
- public BindableCollection Profiles
- {
- get { return _profiles; }
- set
- {
- if (Equals(value, _profiles)) return;
- _profiles = value;
- NotifyOfPropertyChange(() => Profiles);
- }
- }
-
- public BindableCollection Layers
- {
- get { return _layers; }
- set
- {
- if (Equals(value, _layers)) return;
- _layers = value;
- NotifyOfPropertyChange(() => Layers);
- }
- }
-
- public LayerModel SelectedLayer
- {
- get { return _selectedLayer; }
- set
- {
- if (Equals(value, _selectedLayer)) return;
- _selectedLayer = value;
- NotifyOfPropertyChange(() => SelectedLayer);
- NotifyOfPropertyChange(() => LayerSelected);
- }
- }
-
- public Cursor KeyboardPreviewCursor
- {
- get { return _keyboardPreviewCursor; }
- set
- {
- if (Equals(value, _keyboardPreviewCursor)) return;
- _keyboardPreviewCursor = value;
- NotifyOfPropertyChange(() => KeyboardPreviewCursor);
- }
- }
-
- public ProfileModel SelectedProfile
- {
- get { return _selectedProfile; }
- set
- {
- if (Equals(value, _selectedProfile)) return;
- _selectedProfile = value;
-
- Layers.Clear();
- if (_selectedProfile != null)
- Layers.AddRange(SelectedProfile.Layers);
-
- NotifyOfPropertyChange(() => SelectedProfile);
- NotifyOfPropertyChange(() => ProfileSelected);
- NotifyOfPropertyChange(() => LayerSelected);
- }
- }
-
- public ImageSource KeyboardPreview
- {
- get { return _keyboardPreview; }
- set
- {
- if (Equals(value, _keyboardPreview)) return;
- _keyboardPreview = value;
- NotifyOfPropertyChange(() => KeyboardPreview);
- }
- }
-
- public ImageSource KeyboardImage => ImageUtilities.BitmapToBitmapImage(ActiveKeyboard?.PreviewSettings.Image);
-
- public PreviewSettings? PreviewSettings => ActiveKeyboard?.PreviewSettings;
-
- public bool ProfileSelected => SelectedProfile != null;
- public bool LayerSelected => SelectedProfile != null && _selectedLayer != null;
-
- private KeyboardProvider ActiveKeyboard { get; set; }
-
- public void DragOver(IDropInfo dropInfo)
- {
- var source = dropInfo.Data as LayerModel;
- var target = dropInfo.TargetItem as LayerModel;
- if (source == null || target == null || source == target)
- return;
-
- if (dropInfo.InsertPosition == RelativeInsertPosition.TargetItemCenter &&
- target.LayerType == LayerType.Folder)
- {
- dropInfo.DropTargetAdorner = typeof(DropTargetMetroHighlightAdorner);
- dropInfo.Effects = DragDropEffects.Copy;
- }
- else
- {
- dropInfo.DropTargetAdorner = typeof(DropTargetMetroInsertionAdorner);
- dropInfo.Effects = DragDropEffects.Move;
- }
- }
-
- public void Drop(IDropInfo dropInfo)
- {
- var source = dropInfo.Data as LayerModel;
- var target = dropInfo.TargetItem as LayerModel;
- if (source == null || target == null || source == target)
- return;
-
- // Don't allow a folder to become it's own child, that's just weird
- if (target.Parent == source)
- return;
-
- // Remove the source from it's old profile/parent
- if (source.Parent == null)
- source.Profile.Layers.Remove(source);
- else
- source.Parent.Children.Remove(source);
-
- if (dropInfo.InsertPosition == RelativeInsertPosition.TargetItemCenter &&
- target.LayerType == LayerType.Folder)
- {
- // Insert into folder
- source.Order = -1;
- target.Children.Add(source);
- target.FixOrder();
- }
- else
- {
- // Insert the source into it's new profile/parent and update the order
- if (dropInfo.InsertPosition == RelativeInsertPosition.AfterTargetItem)
- source.Order = target.Order + 1;
- else
- source.Order = target.Order - 1;
- if (target.Parent == null)
- target.Profile.Layers.Add(source);
- else
- target.Parent.Children.Add(source);
- }
-
- target.Profile?.FixOrder();
- target.Parent?.FixOrder();
- UpdateLayerList(source);
- }
-
- ///
- /// Handles chaning the active keyboard, updating the preview image and profiles collection
- ///
- ///
- public void Handle(ActiveKeyboardChanged message)
- {
- ActiveKeyboard = _mainManager.DeviceManager.ActiveKeyboard;
- NotifyOfPropertyChange(() => KeyboardImage);
- NotifyOfPropertyChange(() => PreviewSettings);
- LoadProfiles();
- }
-
- ///
- /// Handles refreshing the layer preview
- ///
- ///
- ///
- private void PropertyChangeHandler(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == "KeyboardPreview")
- return;
-
- if (SelectedProfile != null)
- ProfileProvider.AddOrUpdate(SelectedProfile);
- }
-
- ///
- /// Loads all profiles for the current game and keyboard
- ///
- private void LoadProfiles()
- {
- Profiles.Clear();
- if (_gameModel == null || ActiveKeyboard == null)
- return;
-
- Profiles.AddRange(ProfileProvider.GetAll(_gameModel, ActiveKeyboard));
- SelectedProfile = Profiles.FirstOrDefault();
- }
-
- public void EditLayer()
- {
- if (SelectedLayer == null)
- return;
-
- LayerEditor(SelectedLayer);
- }
-
- ///
- /// Opens a new LayerEditorView for the given layer
- ///
- /// The layer to open the view for
- public void LayerEditor(LayerModel layer)
- {
- IWindowManager manager = new WindowManager();
- _editorVm = new LayerEditorViewModel(_gameModel.GameDataModel, layer);
- dynamic settings = new ExpandoObject();
-
- settings.Title = "Artemis | Edit " + layer.Name;
- manager.ShowDialog(_editorVm, null, settings);
-
- // If the layer was a folder, but isn't anymore, assign it's children to it's parent.
- if (layer.LayerType != LayerType.Folder && layer.Children.Any())
- {
- while (layer.Children.Any())
- {
- var child = layer.Children[0];
- layer.Children.Remove(child);
- if (layer.Parent != null)
- {
- layer.Parent.Children.Add(child);
- layer.Parent.FixOrder();
- }
- else
- {
- layer.Profile.Layers.Add(child);
- layer.Profile.FixOrder();
- }
- }
- }
-
- UpdateLayerList(layer);
- }
-
- ///
- /// Adds a new layer to the profile and selects it
- ///
- public void AddLayer()
- {
- if (SelectedProfile == null)
- return;
-
- var layer = SelectedProfile.AddLayer();
- Layers.Add(layer);
-
- SelectedLayer = layer;
- }
-
- ///
- /// Removes the currently selected layer from the profile
- ///
- public void RemoveLayer()
- {
- if (SelectedProfile == null || _selectedLayer == null)
- return;
-
- SelectedProfile.Layers.Remove(_selectedLayer);
- Layers.Remove(_selectedLayer);
-
- SelectedProfile.FixOrder();
- }
-
- ///
- /// Removes the given layer from the profile
- ///
- ///
- public void RemoveLayerFromMenu(LayerModel layer)
- {
- SelectedProfile.Layers.Remove(layer);
- Layers.Remove(layer);
-
- SelectedProfile.FixOrder();
- }
-
- public void CloneLayer()
- {
- if (SelectedLayer == null)
- return;
-
- CloneLayer(SelectedLayer);
- }
-
- ///
- /// Clones the given layer and adds it to the profile, on top of the original
- ///
- ///
- public void CloneLayer(LayerModel layer)
- {
- var clone = GeneralHelpers.Clone(layer);
- clone.Order = layer.Order - 1;
- SelectedProfile.Layers.Add(clone);
- Layers.Add(clone);
-
- SelectedProfile.FixOrder();
- }
-
- private void UpdateLayerList(LayerModel selectModel)
- {
- // Update the UI
- Layers.Clear();
- if (SelectedProfile != null)
- Layers.AddRange(SelectedProfile.Layers);
-
- // A small delay to allow the profile list to rebuild
- Task.Factory.StartNew(() =>
- {
- Thread.Sleep(20);
- SelectedLayer = selectModel;
- });
- }
-
- ///
- /// Handler for clicking
- ///
- ///
- public void MouseDownKeyboardPreview(MouseButtonEventArgs e)
- {
- if (e.LeftButton == MouseButtonState.Pressed)
- _downTime = DateTime.Now;
- }
-
- ///
- /// Second handler for clicking, selects a the layer the user clicked on
- /// if the used clicked on an empty spot, deselects the current layer
- ///
- ///
- public void MouseUpKeyboardPreview(MouseButtonEventArgs e)
- {
- if (SelectedProfile == null)
- return;
-
- var timeSinceDown = DateTime.Now - _downTime;
- if (!(timeSinceDown.TotalMilliseconds < 500))
- return;
-
- var pos = e.GetPosition((Image) e.OriginalSource);
- var x = pos.X/((double) ActiveKeyboard.PreviewSettings.Width/ActiveKeyboard.Width);
- var y = pos.Y/((double) ActiveKeyboard.PreviewSettings.Height/ActiveKeyboard.Height);
-
- var hoverLayer = SelectedProfile.GetLayers()
- .Where(l => l.MustDraw())
- .FirstOrDefault(l => ((KeyboardPropertiesModel) l.Properties)
- .GetRect(1)
- .Contains(x, y));
-
- SelectedLayer = hoverLayer;
- }
-
- ///
- /// Handler for resizing and moving the currently selected layer
- ///
- ///
- public void MouseMoveKeyboardPreview(MouseEventArgs e)
- {
- if (SelectedProfile == null)
- return;
-
- var pos = e.GetPosition((Image) e.OriginalSource);
- var x = pos.X/((double) ActiveKeyboard.PreviewSettings.Width/ActiveKeyboard.Width);
- var y = pos.Y/((double) ActiveKeyboard.PreviewSettings.Height/ActiveKeyboard.Height);
- var hoverLayer = SelectedProfile.GetLayers()
- .Where(l => l.MustDraw())
- .FirstOrDefault(l => ((KeyboardPropertiesModel) l.Properties)
- .GetRect(1).Contains(x, y));
-
- HandleDragging(e, x, y, hoverLayer);
-
- if (hoverLayer == null)
- {
- KeyboardPreviewCursor = Cursors.Arrow;
- return;
- }
-
-
- // Turn the mouse pointer into a hand if hovering over an active layer
- if (hoverLayer == SelectedLayer)
- {
- var rect = ((KeyboardPropertiesModel) hoverLayer.Properties).GetRect(1);
- KeyboardPreviewCursor =
- Math.Sqrt(Math.Pow(x - rect.BottomRight.X, 2) + Math.Pow(y - rect.BottomRight.Y, 2)) < 0.6
- ? Cursors.SizeNWSE
- : Cursors.SizeAll;
- }
- else
- KeyboardPreviewCursor = Cursors.Hand;
- }
-
- private void InvokeUpdateKeyboardPreview(object sender, ElapsedEventArgs e)
- {
- Application.Current.Dispatcher.InvokeAsync(UpdateKeyboardPreview, DispatcherPriority.ContextIdle);
- }
-
- ///
- /// Generates a new image for the keyboard preview
- ///
- public void UpdateKeyboardPreview()
- {
- if (SelectedProfile == null || ActiveKeyboard == null)
- {
- KeyboardPreview = new DrawingImage();
- return;
- }
-
- var keyboardRect = ActiveKeyboard.KeyboardRectangle(4);
- var visual = new DrawingVisual();
- using (var drawingContext = visual.RenderOpen())
- {
- // Setup the DrawingVisual's size
- drawingContext.PushClip(new RectangleGeometry(keyboardRect));
- drawingContext.DrawRectangle(new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)), null, keyboardRect);
-
- // Draw the layers
- var drawLayers = SelectedProfile.Layers
- .OrderByDescending(l => l.Order)
- .Where(l => l.Enabled &&
- (l.LayerType == LayerType.Keyboard ||
- l.LayerType == LayerType.KeyboardGif ||
- l.LayerType == LayerType.Folder));
- foreach (var layer in drawLayers)
- layer.Draw