1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +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.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
@ -27,6 +25,8 @@ namespace Artemis
BindSpecialValues();
}
public Mutex Mutex { get; set; }
private void BindSpecialValues()
{
MessageBinder.SpecialValues.Add("$scaledmousex", ctx =>
@ -109,8 +109,9 @@ namespace Artemis
private void CheckDuplicateInstances()
{
if (Process.GetProcesses().Count(p => p.ProcessName.Contains(Assembly.GetExecutingAssembly()
.FullName.Split(',')[0]) && !p.Modules[0].FileName.Contains("vshost")) < 2)
bool aIsNewInstance;
Mutex = new Mutex(true, "ArtemisMutex", out aIsNewInstance);
if (aIsNewInstance)
return;
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.Utilities;
using static System.Decimal;
@ -32,7 +31,12 @@ namespace Artemis.Models.Profiles.Properties
/// Type of property
/// </summary>
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)
{
if (LayerPropertyType == LayerPropertyType.PercentageOf)
@ -53,7 +57,7 @@ namespace Artemis.Models.Profiles.Properties
return;
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
if (LayerProperty == "Opacity")
@ -81,4 +85,12 @@ namespace Artemis.Models.Profiles.Properties
[Description("% of")] PercentageOf,
[Description("% of property")] PercentageOfProperty
}
public enum LayerPropertyOptions
{
[Description("Left to right")] LeftToRight,
[Description("Right to left")] RightToLeft,
[Description("Downwards")] Downwards,
[Description("Upwards")] Upwards
}
}