mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Darthified code
This commit is contained in:
1 parent
5b80c1e4fe
commit
ae64db8a13
198 files changed
+1339
-1305
No files matched your search
+9
-8
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using Artemis.Core;
|
||||
@@ -48,7 +49,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
{
|
||||
ConditionalDataBinding.ConditionsUpdated -= ConditionalDataBindingOnConditionsUpdated;
|
||||
|
||||
foreach (var conditionViewModel in ConditionViewModels)
|
||||
foreach (DataBindingConditionViewModel<TLayerProperty, TProperty> conditionViewModel in ConditionViewModels)
|
||||
conditionViewModel.Dispose();
|
||||
ConditionViewModels.Clear();
|
||||
}
|
||||
@@ -57,10 +58,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
|
||||
public void AddCondition(string type)
|
||||
{
|
||||
var condition = ConditionalDataBinding.AddCondition();
|
||||
DataBindingCondition<TLayerProperty, TProperty> condition = ConditionalDataBinding.AddCondition();
|
||||
|
||||
// Find the VM of the new condition
|
||||
var viewModel = ConditionViewModels.First(c => c.DataBindingCondition == condition);
|
||||
DataBindingConditionViewModel<TLayerProperty, TProperty> viewModel = ConditionViewModels.First(c => c.DataBindingCondition == condition);
|
||||
viewModel.ActiveItem.AddCondition(type);
|
||||
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
@@ -71,15 +72,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
_updating = true;
|
||||
|
||||
// Remove old VMs
|
||||
var toRemove = ConditionViewModels.Where(c => !ConditionalDataBinding.Conditions.Contains(c.DataBindingCondition)).ToList();
|
||||
foreach (var dataBindingConditionViewModel in toRemove)
|
||||
List<DataBindingConditionViewModel<TLayerProperty, TProperty>> toRemove = ConditionViewModels.Where(c => !ConditionalDataBinding.Conditions.Contains(c.DataBindingCondition)).ToList();
|
||||
foreach (DataBindingConditionViewModel<TLayerProperty, TProperty> dataBindingConditionViewModel in toRemove)
|
||||
{
|
||||
ConditionViewModels.Remove(dataBindingConditionViewModel);
|
||||
dataBindingConditionViewModel.Dispose();
|
||||
}
|
||||
|
||||
// Add missing VMs
|
||||
foreach (var condition in ConditionalDataBinding.Conditions)
|
||||
foreach (DataBindingCondition<TLayerProperty, TProperty> condition in ConditionalDataBinding.Conditions)
|
||||
{
|
||||
if (ConditionViewModels.All(c => c.DataBindingCondition != condition))
|
||||
ConditionViewModels.Add(_dataBindingsVmFactory.DataBindingConditionViewModel(condition));
|
||||
@@ -103,9 +104,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
if (_updating || e.Action != NotifyCollectionChangedAction.Add)
|
||||
return;
|
||||
|
||||
for (var index = 0; index < ConditionViewModels.Count; index++)
|
||||
for (int index = 0; index < ConditionViewModels.Count; index++)
|
||||
{
|
||||
var conditionViewModel = ConditionViewModels[index];
|
||||
DataBindingConditionViewModel<TLayerProperty, TProperty> conditionViewModel = ConditionViewModels[index];
|
||||
conditionViewModel.DataBindingCondition.Order = index + 1;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -226,7 +226,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
Registration.DataBinding.Update(0.04);
|
||||
if (ActiveItem.SupportsTestValue)
|
||||
{
|
||||
var currentValue = Registration.Converter.ConvertFromObject(ActiveItem?.GetTestValue() ?? default(TProperty));
|
||||
TProperty currentValue = Registration.Converter.ConvertFromObject(ActiveItem?.GetTestValue() ?? default(TProperty));
|
||||
TestInputValue.UpdateValue(currentValue);
|
||||
TestResultValue.UpdateValue(Registration.DataBinding != null ? Registration.DataBinding.GetValue(currentValue) : default);
|
||||
}
|
||||
|
||||
+5
-3
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Stylet;
|
||||
@@ -36,15 +38,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
{
|
||||
Items.Clear();
|
||||
|
||||
var layerProperty = _profileEditorService.SelectedDataBinding;
|
||||
ILayerProperty layerProperty = _profileEditorService.SelectedDataBinding;
|
||||
if (layerProperty == null)
|
||||
return;
|
||||
|
||||
var registrations = layerProperty.GetAllDataBindingRegistrations();
|
||||
List<IDataBindingRegistration> registrations = layerProperty.GetAllDataBindingRegistrations();
|
||||
|
||||
// Create a data binding VM for each data bindable property. These VMs will be responsible for retrieving
|
||||
// and creating the actual data bindings
|
||||
foreach (var registration in registrations)
|
||||
foreach (IDataBindingRegistration registration in registrations)
|
||||
Items.Add(_dataBindingsVmFactory.DataBindingViewModel(registration));
|
||||
|
||||
SelectedItemIndex = 0;
|
||||
|
||||
+7
-6
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
@@ -92,7 +93,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
{
|
||||
if (Modifier.ParameterType == ProfileRightSideType.Dynamic)
|
||||
{
|
||||
var sourceType = Modifier.DirectDataBinding.GetSourceType();
|
||||
Type sourceType = Modifier.DirectDataBinding.GetSourceType();
|
||||
Modifier.UpdateParameter((Modifier.ModifierType.ParameterType ?? sourceType).GetDefault());
|
||||
}
|
||||
else
|
||||
@@ -116,7 +117,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var sourceType = Modifier.DirectDataBinding.GetSourceType();
|
||||
Type sourceType = Modifier.DirectDataBinding.GetSourceType();
|
||||
if (sourceType == null)
|
||||
throw new ArtemisUIException("Cannot use a data binding modifier VM for a data binding without a source");
|
||||
|
||||
@@ -150,11 +151,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
}
|
||||
|
||||
// Modifier type
|
||||
var root = new ModifierTypeCategoryViewModel(null, null);
|
||||
var modifierTypes = _dataBindingService.GetCompatibleModifierTypes(sourceType).GroupBy(t => t.Category);
|
||||
foreach (var dataBindingModifierTypes in modifierTypes)
|
||||
ModifierTypeCategoryViewModel root = new ModifierTypeCategoryViewModel(null, null);
|
||||
IEnumerable<IGrouping<string, DataBindingModifierType>> modifierTypes = _dataBindingService.GetCompatibleModifierTypes(sourceType).GroupBy(t => t.Category);
|
||||
foreach (IGrouping<string, DataBindingModifierType> dataBindingModifierTypes in modifierTypes)
|
||||
{
|
||||
var viewModels = dataBindingModifierTypes.Select(t => new ModifierTypeViewModel(t));
|
||||
IEnumerable<ModifierTypeViewModel> viewModels = dataBindingModifierTypes.Select(t => new ModifierTypeViewModel(t));
|
||||
if (dataBindingModifierTypes.Key == null)
|
||||
root.Children.AddRange(viewModels);
|
||||
else
|
||||
|
||||
+7
-6
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using Artemis.Core;
|
||||
@@ -75,7 +76,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
TargetSelectionViewModel.Dispose();
|
||||
DirectDataBinding.ModifiersUpdated -= DirectDataBindingOnModifiersUpdated;
|
||||
|
||||
foreach (var dataBindingModifierViewModel in ModifierViewModels)
|
||||
foreach (DataBindingModifierViewModel<TLayerProperty, TProperty> dataBindingModifierViewModel in ModifierViewModels)
|
||||
dataBindingModifierViewModel.Dispose();
|
||||
ModifierViewModels.Clear();
|
||||
}
|
||||
@@ -96,9 +97,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
if (_updating || e.Action != NotifyCollectionChangedAction.Add)
|
||||
return;
|
||||
|
||||
for (var index = 0; index < ModifierViewModels.Count; index++)
|
||||
for (int index = 0; index < ModifierViewModels.Count; index++)
|
||||
{
|
||||
var dataBindingModifierViewModel = ModifierViewModels[index];
|
||||
DataBindingModifierViewModel<TLayerProperty, TProperty> dataBindingModifierViewModel = ModifierViewModels[index];
|
||||
dataBindingModifierViewModel.Modifier.Order = index + 1;
|
||||
}
|
||||
|
||||
@@ -132,15 +133,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
_updating = true;
|
||||
|
||||
// Remove old VMs
|
||||
var toRemove = ModifierViewModels.Where(m => !DirectDataBinding.Modifiers.Contains(m.Modifier)).ToList();
|
||||
foreach (var modifierViewModel in toRemove)
|
||||
List<DataBindingModifierViewModel<TLayerProperty, TProperty>> toRemove = ModifierViewModels.Where(m => !DirectDataBinding.Modifiers.Contains(m.Modifier)).ToList();
|
||||
foreach (DataBindingModifierViewModel<TLayerProperty, TProperty> modifierViewModel in toRemove)
|
||||
{
|
||||
ModifierViewModels.Remove(modifierViewModel);
|
||||
modifierViewModel.Dispose();
|
||||
}
|
||||
|
||||
// Add missing VMs
|
||||
foreach (var modifier in DirectDataBinding.Modifiers)
|
||||
foreach (DataBindingModifier<TLayerProperty, TProperty> modifier in DirectDataBinding.Modifiers)
|
||||
{
|
||||
if (ModifierViewModels.All(m => m.Modifier != modifier))
|
||||
ModifierViewModels.Add(_dataBindingsVmFactory.DataBindingModifierViewModel(modifier));
|
||||
|
||||
Reference in new issue
Block a user