1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-31 09:43:46 +00:00

Dynamic properties extensions

This commit is contained in:
SpoinkyNL 2016-05-19 00:01:18 +02:00
parent 4667ea21f9
commit 2edccddc12
2 changed files with 22 additions and 9 deletions

View File

@ -1,8 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Threading;
using System.Linq;
using System.Reflection;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Forms; using System.Windows.Forms;
@ -27,6 +25,8 @@ namespace Artemis
BindSpecialValues(); BindSpecialValues();
} }
public Mutex Mutex { get; set; }
private void BindSpecialValues() private void BindSpecialValues()
{ {
MessageBinder.SpecialValues.Add("$scaledmousex", ctx => MessageBinder.SpecialValues.Add("$scaledmousex", ctx =>
@ -109,8 +109,9 @@ namespace Artemis
private void CheckDuplicateInstances() private void CheckDuplicateInstances()
{ {
if (Process.GetProcesses().Count(p => p.ProcessName.Contains(Assembly.GetExecutingAssembly() bool aIsNewInstance;
.FullName.Split(',')[0]) && !p.Modules[0].FileName.Contains("vshost")) < 2) Mutex = new Mutex(true, "ArtemisMutex", out aIsNewInstance);
if (aIsNewInstance)
return; return;
MessageBox.Show("An instance of Artemis is already running (check your system tray).", MessageBox.Show("An instance of Artemis is already running (check your system tray).",

View File

@ -1,5 +1,4 @@
using System; using System.ComponentModel;
using System.ComponentModel;
using Artemis.Models.Interfaces; using Artemis.Models.Interfaces;
using Artemis.Utilities; using Artemis.Utilities;
using static System.Decimal; using static System.Decimal;
@ -33,6 +32,11 @@ namespace Artemis.Models.Profiles.Properties
/// </summary> /// </summary>
public LayerPropertyType LayerPropertyType { get; set; } public LayerPropertyType LayerPropertyType { get; set; }
/// <summary>
/// Extra options on top of the selected properties
/// </summary>
public LayerPropertyOptions LayerPropertyOptions { get; set; }
internal void ApplyProperty(IGameDataModel dataModel, KeyboardPropertiesModel properties) internal void ApplyProperty(IGameDataModel dataModel, KeyboardPropertiesModel properties)
{ {
if (LayerPropertyType == LayerPropertyType.PercentageOf) if (LayerPropertyType == LayerPropertyType.PercentageOf)
@ -53,7 +57,7 @@ namespace Artemis.Models.Profiles.Properties
return; return;
var percentage = ToDouble(gameProperty)/percentageSource; var percentage = ToDouble(gameProperty)/percentageSource;
var appliedValue = percentage*(double)layerProp.GetValue(properties); var appliedValue = percentage*(double) layerProp.GetValue(properties);
// Opacity requires some special treatment as it causes an exception if it's < 0.0 or > 1.0 // Opacity requires some special treatment as it causes an exception if it's < 0.0 or > 1.0
if (LayerProperty == "Opacity") if (LayerProperty == "Opacity")
@ -81,4 +85,12 @@ namespace Artemis.Models.Profiles.Properties
[Description("% of")] PercentageOf, [Description("% of")] PercentageOf,
[Description("% of property")] PercentageOfProperty [Description("% of property")] PercentageOfProperty
} }
public enum LayerPropertyOptions
{
[Description("Left to right")] LeftToRight,
[Description("Right to left")] RightToLeft,
[Description("Downwards")] Downwards,
[Description("Upwards")] Upwards
}
} }