diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj
index 1f96f9a96..6e1f6f181 100644
--- a/Artemis/Artemis/Artemis.csproj
+++ b/Artemis/Artemis/Artemis.csproj
@@ -378,6 +378,7 @@
Offsets.settings
+
diff --git a/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs b/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs
index adfd56704..545711dd3 100644
--- a/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs
+++ b/Artemis/Artemis/KeyboardProviders/Logitech/Orion.cs
@@ -11,8 +11,6 @@ namespace Artemis.KeyboardProviders.Logitech
{
internal class Orion : KeyboardProvider
{
- private string _versionString;
-
public Orion()
{
Name = "Logitech G910 RGB";
diff --git a/Artemis/Artemis/Utilities/ExtensionMethods.cs b/Artemis/Artemis/Utilities/ExtensionMethods.cs
new file mode 100644
index 000000000..a5defa83d
--- /dev/null
+++ b/Artemis/Artemis/Utilities/ExtensionMethods.cs
@@ -0,0 +1,12 @@
+using System.Text.RegularExpressions;
+
+namespace Artemis.Utilities
+{
+ public static class ExtensionMethods
+ {
+ public static string SplitCamelCase(this string str)
+ {
+ return Regex.Replace(Regex.Replace(str, @"(\P{Ll})(\P{Ll}\p{Ll})", "$1 $2"), @"(\p{Ll})(\P{Ll})", "$1 $2");
+ }
+ }
+}
\ No newline at end of file
diff --git a/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs b/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs
index ea201aabc..169477783 100644
--- a/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs
+++ b/Artemis/Artemis/ViewModels/Flyouts/FlyoutSettingsViewModel.cs
@@ -11,7 +11,6 @@ namespace Artemis.ViewModels.Flyouts
public class FlyoutSettingsViewModel : FlyoutBaseViewModel, IHandle, IHandle
{
private string _activeEffectName;
- private bool _enabled;
private GeneralSettings _generalSettings;
private string _selectedKeyboardProvider;
diff --git a/Artemis/Artemis/ViewModels/GamesViewModel.cs b/Artemis/Artemis/ViewModels/GamesViewModel.cs
index 13448ac52..e8621002c 100644
--- a/Artemis/Artemis/ViewModels/GamesViewModel.cs
+++ b/Artemis/Artemis/ViewModels/GamesViewModel.cs
@@ -22,7 +22,7 @@ namespace Artemis.ViewModels
_counterStrikeVm = new CounterStrikeViewModel(mainManager) {DisplayName = "CS:GO"};
_dota2Vm = new Dota2ViewModel(mainManager) {DisplayName = "Dota 2"};
_witcher3Vm = new Witcher3ViewModel(mainManager) {DisplayName = "The Witcher 3"};
- // _divisionVm = new TheDivisionViewModel(mainManager) {DisplayName = "The Division"};
+ _divisionVm = new TheDivisionViewModel(mainManager) {DisplayName = "The Division"};
}
protected override void OnActivate()
@@ -33,7 +33,7 @@ namespace Artemis.ViewModels
ActivateItem(_counterStrikeVm);
ActivateItem(_dota2Vm);
ActivateItem(_witcher3Vm);
- // ActivateItem(_divisionVm);
+ ActivateItem(_divisionVm);
}
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs b/Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs
index 6d7288c7b..2134bb8d3 100644
--- a/Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs
+++ b/Artemis/Artemis/ViewModels/LayerEditor/LayerConditionViewModel.cs
@@ -1,4 +1,5 @@
-using System.Linq;
+using System.ComponentModel;
+using System.Linq;
using Artemis.Models.Profiles;
using Artemis.Utilities;
using Caliburn.Micro;
@@ -7,24 +8,67 @@ namespace Artemis.ViewModels.LayerEditor
{
public 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 _preselecting;
+
private GeneralHelpers.PropertyCollection _selectedDataModelProp;
- private string _selectedOperator;
+ 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();
+ Operators = new BindableCollection();
+
+ PropertyChanged += UpdateModel;
+ PropertyChanged += UpdateForm;
+
+ PreSelect();
+ }
+
+ public string UserValue
+ {
+ get { return _userValue; }
+ set
+ {
+ if (value == _userValue) return;
+ _userValue = value;
+ NotifyOfPropertyChange(() => UserValue);
+ }
}
public LayerConditionModel LayerConditionModel { get; set; }
public BindableCollection DataModelProps { get; set; }
- public BindableCollection Operators { get; set; }
+ public BindableCollection Operators { get; set; }
public GeneralHelpers.PropertyCollection SelectedDataModelProp
{
@@ -33,21 +77,10 @@ namespace Artemis.ViewModels.LayerEditor
{
if (value.Equals(_selectedDataModelProp)) return;
_selectedDataModelProp = value;
- OnSelectedItemChangedAction(_selectedDataModelProp);
NotifyOfPropertyChange(() => SelectedDataModelProp);
}
}
- public string SelectedOperator
- {
- get { return _selectedOperator; }
- set
- {
- if (value == _selectedOperator) return;
- _selectedOperator = value;
- NotifyOfPropertyChange(() => SelectedOperator);
- }
- }
public bool UserValueIsVisible
{
@@ -60,31 +93,47 @@ namespace Artemis.ViewModels.LayerEditor
}
}
- public void OnSelectedItemChangedAction(GeneralHelpers.PropertyCollection prop)
+ public NamedOperator SelectedOperator
{
- Operators.Clear();
- if (prop.EnumValues != null)
+ get { return _selectedOperator; }
+ set
{
- Operators.AddRange(prop.EnumValues);
+ if (value.Equals(_selectedOperator)) return;
+ _selectedOperator = value;
+ NotifyOfPropertyChange(() => SelectedOperator);
+ }
+ }
+
+ ///
+ /// 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();
+ if (SelectedDataModelProp.EnumValues != null)
+ {
+ Operators.AddRange(
+ SelectedDataModelProp.EnumValues.Select(val => new NamedOperator(val.SplitCamelCase(), "== " + val)));
UserValueIsVisible = false;
}
else
- switch (prop.Type)
+ switch (SelectedDataModelProp.Type)
{
case "Int32":
- Operators.AddRange(new[]
- {
- "Lower than", "Lower or equal to", "Higher than", "Higher or equal to", "Equal to",
- "Not equal to"
- });
+ Operators.AddRange(_int32Operators);
UserValueIsVisible = true;
break;
case "Boolean":
- Operators.AddRange(new[] {"False", "True"});
+ Operators.AddRange(_boolOperators);
UserValueIsVisible = false;
break;
default:
- Operators.AddRange(new[] {"Equal to", "Not equal to"});
+ Operators.AddRange(_operators);
UserValueIsVisible = true;
break;
}
@@ -92,9 +141,59 @@ namespace Artemis.ViewModels.LayerEditor
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")
+ return;
+
+ LayerConditionModel.Field = SelectedDataModelProp.Path;
+ LayerConditionModel.Operator = SelectedOperator.Value;
+ LayerConditionModel.Value = 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);
+ 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/Views/LayerEditor/LayerConditionView.xaml b/Artemis/Artemis/Views/LayerEditor/LayerConditionView.xaml
index 67c8f7ef0..621501fc9 100644
--- a/Artemis/Artemis/Views/LayerEditor/LayerConditionView.xaml
+++ b/Artemis/Artemis/Views/LayerEditor/LayerConditionView.xaml
@@ -22,7 +22,7 @@
-
@@ -37,7 +37,7 @@
+ VerticalAlignment="Top" DisplayMemberPath="Display" />
diff --git a/Artemis/Artemis/Views/LayerEditorView.xaml b/Artemis/Artemis/Views/LayerEditorView.xaml
index 087e0200d..9547afe6c 100644
--- a/Artemis/Artemis/Views/LayerEditorView.xaml
+++ b/Artemis/Artemis/Views/LayerEditorView.xaml
@@ -9,24 +9,57 @@
mc:Ignorable="d"
Title="Artemis | Edit Layer" Height="800" Width="630"
GlowBrush="{DynamicResource AccentColorBrush}" Icon="../logo.ico" ResizeMode="NoResize">
-
+
-
-
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file