mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Data model conditions - Expanded events UI logic
This commit is contained in:
1 parent
fbd319beb9
commit
e7ce16ba73
15 files changed
+226
-54
No files matched your search
@@ -17,7 +17,7 @@
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Artemis.UI;component/ResourceDictionaries/DataModelConditions.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<utilities:BindingProxy x:Key="DataContextProxy" Data="{Binding}" />
|
||||
<Converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
@@ -45,13 +45,24 @@
|
||||
</Button>
|
||||
<Button Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
ToolTip="Change the operator of the group, determining which conditions should match"
|
||||
Style="{StaticResource DataModelConditionButtonLeftClickMenu}"
|
||||
Background="#E74C4C"
|
||||
BorderBrush="#E74C4C"
|
||||
Margin="3 1"
|
||||
Content="{Binding SelectedBooleanOperator}"
|
||||
Visibility="{Binding DisplayBooleanOperator, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
Visibility="{Binding DisplayBooleanOperator, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"
|
||||
IsEnabled="{Binding IsEventGroup, Converter={StaticResource InverseBooleanConverter}}"
|
||||
ToolTipService.ShowOnDisabled="True">
|
||||
<Button.ToolTip>
|
||||
<StackPanel>
|
||||
<TextBlock Visibility="{Binding IsEventGroup, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}">
|
||||
Change the operator of the group, determining which conditions should match
|
||||
</TextBlock>
|
||||
<TextBlock Visibility="{Binding IsEventGroup, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
The operator of the root group cannot be changed for event-based conditions
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</Button.ToolTip>
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="And"
|
||||
|
||||
+13
-3
@@ -19,6 +19,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private bool _isInitialized;
|
||||
private bool _isRootGroup;
|
||||
private bool _isEventGroup;
|
||||
|
||||
public DataModelConditionGroupViewModel(DataModelConditionGroup dataModelConditionGroup,
|
||||
ConditionGroupType groupType,
|
||||
@@ -48,6 +49,12 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
set => SetAndNotify(ref _isRootGroup, value);
|
||||
}
|
||||
|
||||
public bool IsEventGroup
|
||||
{
|
||||
get => _isEventGroup;
|
||||
set => SetAndNotify(ref _isEventGroup, value);
|
||||
}
|
||||
|
||||
public bool IsInitialized
|
||||
{
|
||||
get => _isInitialized;
|
||||
@@ -98,7 +105,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
public override void Update()
|
||||
{
|
||||
NotifyOfPropertyChange(nameof(SelectedBooleanOperator));
|
||||
|
||||
// Remove VMs of effects no longer applied on the layer
|
||||
Items.RemoveRange(Items.Where(c => !DataModelConditionGroup.Children.Contains(c.Model)).ToList());
|
||||
|
||||
@@ -140,8 +146,12 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
foreach (DataModelConditionViewModel childViewModel in Items)
|
||||
childViewModel.Update();
|
||||
|
||||
if (IsRootGroup && Parent is DisplayConditionsViewModel displayConditionsViewModel)
|
||||
displayConditionsViewModel.DisplayStartHint = !Items.Any();
|
||||
IsEventGroup = Items.Any(i => i is DataModelConditionEventViewModel);
|
||||
if (IsEventGroup)
|
||||
{
|
||||
if (DataModelConditionGroup.BooleanOperator != BooleanOperator.And)
|
||||
SelectBooleanOperator("And");
|
||||
}
|
||||
|
||||
OnUpdated();
|
||||
}
|
||||
|
||||
+3
-2
@@ -54,7 +54,8 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
|
||||
protected override List<DataModelPropertiesViewModel> GetExtraRightSideDataModelViewModels()
|
||||
{
|
||||
return new List<DataModelPropertiesViewModel> {GetEventDataModel()};
|
||||
// Extra data models are expected to not have an empty root, so lets return the child
|
||||
return GetEventDataModel().Children.Cast<DataModelPropertiesViewModel>().ToList();
|
||||
}
|
||||
|
||||
private DataModelPropertiesViewModel GetEventDataModel()
|
||||
@@ -63,7 +64,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
DataModelConditionEventPredicate.DataModelConditionEvent.EventArgumentType
|
||||
);
|
||||
|
||||
return wrapper.CreateViewModel();
|
||||
return wrapper.CreateViewModel(_dataModelUIService);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
-2
@@ -20,6 +20,10 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
: base(dataModelConditionGeneralPredicate, profileEditorService, dataModelUIService, conditionOperatorService, settingsService)
|
||||
{
|
||||
_dataModelUIService = dataModelUIService;
|
||||
}
|
||||
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
@@ -29,8 +33,13 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
||||
List<Type> supportedInputTypes = editors.Select(e => e.SupportedType).ToList();
|
||||
supportedInputTypes.AddRange(editors.Where(e => e.CompatibleConversionTypes != null).SelectMany(e => e.CompatibleConversionTypes));
|
||||
supportedInputTypes.Add(typeof(IEnumerable<>));
|
||||
supportedInputTypes.Add(typeof(DataModelEvent));
|
||||
supportedInputTypes.Add(typeof(DataModelEvent<>));
|
||||
|
||||
// Events are only supported in the root group enforce that here
|
||||
if (Parent is DataModelConditionGroupViewModel groupViewModel && groupViewModel.IsRootGroup)
|
||||
{
|
||||
supportedInputTypes.Add(typeof(DataModelEvent));
|
||||
supportedInputTypes.Add(typeof(DataModelEvent<>));
|
||||
}
|
||||
|
||||
return supportedInputTypes;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user