mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Data model conditions - Expanded events UI logic
This commit is contained in:
parent
fbd319beb9
commit
e7ce16ba73
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
using Artemis.Storage.Entities.Profile.Abstract;
|
using Artemis.Storage.Entities.Profile.Abstract;
|
||||||
|
|
||||||
namespace Artemis.Core
|
namespace Artemis.Core
|
||||||
@ -36,6 +37,8 @@ namespace Artemis.Core
|
|||||||
_children.Insert(index.Value, dataModelConditionPart);
|
_children.Insert(index.Value, dataModelConditionPart);
|
||||||
else
|
else
|
||||||
_children.Add(dataModelConditionPart);
|
_children.Add(dataModelConditionPart);
|
||||||
|
|
||||||
|
OnChildAdded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,9 +52,19 @@ namespace Artemis.Core
|
|||||||
{
|
{
|
||||||
dataModelConditionPart.Parent = null;
|
dataModelConditionPart.Parent = null;
|
||||||
_children.Remove(dataModelConditionPart);
|
_children.Remove(dataModelConditionPart);
|
||||||
|
OnChildRemoved();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes all children. You monster.
|
||||||
|
/// </summary>
|
||||||
|
public void ClearChildren()
|
||||||
|
{
|
||||||
|
while (Children.Any())
|
||||||
|
RemoveChild(Children[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Evaluates the condition part on the data model
|
/// Evaluates the condition part on the data model
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -71,7 +84,7 @@ namespace Artemis.Core
|
|||||||
#region IDisposable
|
#region IDisposable
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disposed the condition part
|
/// Disposed the condition part
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
@ -88,5 +101,22 @@ namespace Artemis.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
|
||||||
|
public event EventHandler ChildAdded;
|
||||||
|
public event EventHandler ChildRemoved;
|
||||||
|
|
||||||
|
protected virtual void OnChildAdded()
|
||||||
|
{
|
||||||
|
ChildAdded?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void OnChildRemoved()
|
||||||
|
{
|
||||||
|
ChildRemoved?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,8 +93,7 @@ namespace Artemis.Core
|
|||||||
SubscribeToEventPath();
|
SubscribeToEventPath();
|
||||||
|
|
||||||
// Remove the old root group that was tied to the old data model
|
// Remove the old root group that was tied to the old data model
|
||||||
while (Children.Any())
|
ClearChildren();
|
||||||
RemoveChild(Children[0]);
|
|
||||||
|
|
||||||
if (EventPath != null)
|
if (EventPath != null)
|
||||||
{
|
{
|
||||||
@ -164,6 +163,8 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
internal void Initialize()
|
internal void Initialize()
|
||||||
{
|
{
|
||||||
|
ClearChildren();
|
||||||
|
|
||||||
if (Entity.EventPath == null)
|
if (Entity.EventPath == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@ -46,6 +46,8 @@ namespace Artemis.Core
|
|||||||
AddChild(new DataModelConditionGeneralPredicate(this, predicateEntity));
|
AddChild(new DataModelConditionGeneralPredicate(this, predicateEntity));
|
||||||
else if (childEntity is DataModelConditionListPredicateEntity listPredicateEntity)
|
else if (childEntity is DataModelConditionListPredicateEntity listPredicateEntity)
|
||||||
AddChild(new DataModelConditionListPredicate(this, listPredicateEntity));
|
AddChild(new DataModelConditionListPredicate(this, listPredicateEntity));
|
||||||
|
else if (childEntity is DataModelConditionEventPredicateEntity eventPredicateEntity)
|
||||||
|
AddChild(new DataModelConditionEventPredicate(this, eventPredicateEntity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -281,6 +281,13 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
Entity.Path = Path;
|
Entity.Path = Path;
|
||||||
Entity.DataModelGuid = DataModelGuid;
|
Entity.DataModelGuid = DataModelGuid;
|
||||||
|
|
||||||
|
Entity.WrapperType = Target switch
|
||||||
|
{
|
||||||
|
ListPredicateWrapperDataModel _ => PathWrapperType.List,
|
||||||
|
EventPredicateWrapperDataModel _ => PathWrapperType.Event,
|
||||||
|
_ => PathWrapperType.None
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Artemis.Core.LayerBrushes;
|
using Artemis.Core.LayerBrushes;
|
||||||
using Artemis.Core.LayerEffects;
|
using Artemis.Core.LayerEffects;
|
||||||
@ -68,27 +67,6 @@ namespace Artemis.Core
|
|||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal LayerEntity LayerEntity { get; set; }
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public override List<ILayerProperty> GetAllLayerProperties()
|
|
||||||
{
|
|
||||||
List<ILayerProperty> result = new List<ILayerProperty>();
|
|
||||||
result.AddRange(General.GetAllLayerProperties());
|
|
||||||
result.AddRange(Transform.GetAllLayerProperties());
|
|
||||||
if (LayerBrush?.BaseProperties != null)
|
|
||||||
result.AddRange(LayerBrush.BaseProperties.GetAllLayerProperties());
|
|
||||||
foreach (BaseLayerEffect layerEffect in LayerEffects)
|
|
||||||
{
|
|
||||||
if (layerEffect.BaseProperties != null)
|
|
||||||
result.AddRange(layerEffect.BaseProperties.GetAllLayerProperties());
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override RenderElementEntity RenderElementEntity => LayerEntity;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A collection of all the LEDs this layer is assigned to.
|
/// A collection of all the LEDs this layer is assigned to.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -131,6 +109,25 @@ namespace Artemis.Core
|
|||||||
internal set => SetAndNotify(ref _layerBrush, value);
|
internal set => SetAndNotify(ref _layerBrush, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal LayerEntity LayerEntity { get; set; }
|
||||||
|
|
||||||
|
internal override RenderElementEntity RenderElementEntity => LayerEntity;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override List<ILayerProperty> GetAllLayerProperties()
|
||||||
|
{
|
||||||
|
List<ILayerProperty> result = new List<ILayerProperty>();
|
||||||
|
result.AddRange(General.GetAllLayerProperties());
|
||||||
|
result.AddRange(Transform.GetAllLayerProperties());
|
||||||
|
if (LayerBrush?.BaseProperties != null)
|
||||||
|
result.AddRange(LayerBrush.BaseProperties.GetAllLayerProperties());
|
||||||
|
foreach (BaseLayerEffect layerEffect in LayerEffects)
|
||||||
|
if (layerEffect.BaseProperties != null)
|
||||||
|
result.AddRange(layerEffect.BaseProperties.GetAllLayerProperties());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
@ -309,7 +306,9 @@ namespace Artemis.Core
|
|||||||
if (stickToMainSegment)
|
if (stickToMainSegment)
|
||||||
{
|
{
|
||||||
if (!DisplayContinuously)
|
if (!DisplayContinuously)
|
||||||
|
{
|
||||||
TimelinePosition = StartSegmentLength + timeOverride;
|
TimelinePosition = StartSegmentLength + timeOverride;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double progress = timeOverride.TotalMilliseconds % MainSegmentLength.TotalMilliseconds;
|
double progress = timeOverride.TotalMilliseconds % MainSegmentLength.TotalMilliseconds;
|
||||||
@ -320,7 +319,9 @@ namespace Artemis.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
TimelinePosition = timeOverride;
|
TimelinePosition = timeOverride;
|
||||||
|
}
|
||||||
|
|
||||||
double delta = (TimelinePosition - beginTime).TotalSeconds;
|
double delta = (TimelinePosition - beginTime).TotalSeconds;
|
||||||
|
|
||||||
@ -356,7 +357,9 @@ namespace Artemis.Core
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (_layerBitmap == null)
|
if (_layerBitmap == null)
|
||||||
|
{
|
||||||
_layerBitmap = new SKBitmap(new SKImageInfo((int) Path.Bounds.Width, (int) Path.Bounds.Height));
|
_layerBitmap = new SKBitmap(new SKImageInfo((int) Path.Bounds.Width, (int) Path.Bounds.Height));
|
||||||
|
}
|
||||||
else if (_layerBitmap.Info.Width != (int) Path.Bounds.Width || _layerBitmap.Info.Height != (int) Path.Bounds.Height)
|
else if (_layerBitmap.Info.Width != (int) Path.Bounds.Width || _layerBitmap.Info.Height != (int) Path.Bounds.Height)
|
||||||
{
|
{
|
||||||
_layerBitmap.Dispose();
|
_layerBitmap.Dispose();
|
||||||
@ -388,7 +391,7 @@ namespace Artemis.Core
|
|||||||
else if (General.ResizeMode.CurrentValue == LayerResizeMode.Clip)
|
else if (General.ResizeMode.CurrentValue == LayerResizeMode.Clip)
|
||||||
ClipRender(layerCanvas, _layerBitmap.Info, layerPaint, layerPath);
|
ClipRender(layerCanvas, _layerBitmap.Info, layerPaint, layerPath);
|
||||||
|
|
||||||
using SKPaint canvasPaint = new SKPaint { BlendMode = General.BlendMode.CurrentValue };
|
using SKPaint canvasPaint = new SKPaint {BlendMode = General.BlendMode.CurrentValue};
|
||||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled))
|
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.Enabled))
|
||||||
baseLayerEffect.PostProcess(layerCanvas, _layerBitmap.Info, layerPath, canvasPaint);
|
baseLayerEffect.PostProcess(layerCanvas, _layerBitmap.Info, layerPath, canvasPaint);
|
||||||
|
|
||||||
@ -475,7 +478,9 @@ namespace Artemis.Core
|
|||||||
throw new ObjectDisposedException("Layer");
|
throw new ObjectDisposedException("Layer");
|
||||||
|
|
||||||
if (!Leds.Any())
|
if (!Leds.Any())
|
||||||
|
{
|
||||||
Path = new SKPath();
|
Path = new SKPath();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SKPath path = new SKPath {FillType = SKPathFillType.Winding};
|
SKPath path = new SKPath {FillType = SKPathFillType.Winding};
|
||||||
@ -548,6 +553,44 @@ namespace Artemis.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a transformation matrix that applies the current transformation settings
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="zeroBased">
|
||||||
|
/// If true, treats the layer as if it is located at 0,0 instead of its actual position on the
|
||||||
|
/// surface
|
||||||
|
/// </param>
|
||||||
|
/// <returns>The transformation matrix containing the current transformation settings</returns>
|
||||||
|
public SKMatrix GetTransformMatrix(bool zeroBased)
|
||||||
|
{
|
||||||
|
if (_disposed)
|
||||||
|
throw new ObjectDisposedException("Layer");
|
||||||
|
|
||||||
|
SKSize sizeProperty = Transform.Scale.CurrentValue;
|
||||||
|
float rotationProperty = Transform.Rotation.CurrentValue;
|
||||||
|
|
||||||
|
SKPoint anchorPosition = GetLayerAnchorPosition(Path, zeroBased);
|
||||||
|
SKPoint anchorProperty = Transform.AnchorPoint.CurrentValue;
|
||||||
|
|
||||||
|
// Translation originates from the unscaled center of the shape and is tied to the anchor
|
||||||
|
float x = anchorPosition.X - (zeroBased ? Bounds.MidX - Bounds.Left : Bounds.MidX) - anchorProperty.X * Bounds.Width;
|
||||||
|
float y = anchorPosition.Y - (zeroBased ? Bounds.MidY - Bounds.Top : Bounds.MidY) - anchorProperty.Y * Bounds.Height;
|
||||||
|
|
||||||
|
if (General.ResizeMode == LayerResizeMode.Normal)
|
||||||
|
{
|
||||||
|
SKMatrix transform = SKMatrix.MakeTranslation(x, y);
|
||||||
|
transform = transform.PostConcat(SKMatrix.MakeRotationDegrees(rotationProperty, anchorPosition.X, anchorPosition.Y));
|
||||||
|
transform = transform.PostConcat(SKMatrix.MakeScale(sizeProperty.Width / 100f, sizeProperty.Height / 100f, anchorPosition.X, anchorPosition.Y));
|
||||||
|
return transform;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SKMatrix transform = SKMatrix.MakeTranslation(x, y);
|
||||||
|
transform = transform.PostConcat(SKMatrix.MakeRotationDegrees(rotationProperty * -1, anchorPosition.X, anchorPosition.Y));
|
||||||
|
return transform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Excludes the provided path from the translations applied to the layer by applying translations that cancel the
|
/// Excludes the provided path from the translations applied to the layer by applying translations that cancel the
|
||||||
/// layer translations out
|
/// layer translations out
|
||||||
|
|||||||
@ -41,7 +41,7 @@ namespace Artemis.UI.Shared
|
|||||||
PopulateProperties(dataModelUIService);
|
PopulateProperties(dataModelUIService);
|
||||||
|
|
||||||
// Only update children if the parent is expanded
|
// Only update children if the parent is expanded
|
||||||
if (Parent != null && !Parent.IsVisualizationExpanded && !Parent.IsRootViewModel)
|
if (Parent != null && !Parent.IsRootViewModel && !Parent.IsVisualizationExpanded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (DataModelVisualizationViewModel dataModelVisualizationViewModel in Children)
|
foreach (DataModelVisualizationViewModel dataModelVisualizationViewModel in Children)
|
||||||
@ -50,9 +50,9 @@ namespace Artemis.UI.Shared
|
|||||||
|
|
||||||
public override object GetCurrentValue()
|
public override object GetCurrentValue()
|
||||||
{
|
{
|
||||||
if (Parent == null)
|
if (Parent == null || Parent.IsRootViewModel || IsRootViewModel)
|
||||||
return null;
|
return DataModel;
|
||||||
return Parent.IsRootViewModel ? DataModel : base.GetCurrentValue();
|
return base.GetCurrentValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@ -28,7 +28,7 @@ namespace Artemis.UI.Shared
|
|||||||
Children = new BindableCollection<DataModelVisualizationViewModel>();
|
Children = new BindableCollection<DataModelVisualizationViewModel>();
|
||||||
IsMatchingFilteredTypes = true;
|
IsMatchingFilteredTypes = true;
|
||||||
|
|
||||||
if (dataModel == null && parent == null && dataModelPath == null)
|
if (parent == null)
|
||||||
IsRootViewModel = true;
|
IsRootViewModel = true;
|
||||||
else
|
else
|
||||||
PropertyDescription = DataModelPath?.GetPropertyDescription() ?? DataModel.DataModelDescription;
|
PropertyDescription = DataModelPath?.GetPropertyDescription() ?? DataModel.DataModelDescription;
|
||||||
@ -184,7 +184,10 @@ namespace Artemis.UI.Shared
|
|||||||
|
|
||||||
internal void PopulateProperties(IDataModelUIService dataModelUIService)
|
internal void PopulateProperties(IDataModelUIService dataModelUIService)
|
||||||
{
|
{
|
||||||
if (IsRootViewModel)
|
// if (IsRootViewModel)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
if (Parent == null && DataModel == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Type modelType = Parent == null || Parent.IsRootViewModel ? DataModel.GetType() : DataModelPath.GetPropertyType();
|
Type modelType = Parent == null || Parent.IsRootViewModel ? DataModel.GetType() : DataModelPath.GetPropertyType();
|
||||||
@ -235,6 +238,7 @@ namespace Artemis.UI.Shared
|
|||||||
if (toRemoveDynamic.Any())
|
if (toRemoveDynamic.Any())
|
||||||
Children.RemoveRange(toRemoveDynamic);
|
Children.RemoveRange(toRemoveDynamic);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DataModelVisualizationViewModel CreateChild(IDataModelUIService dataModelUIService, string path, int depth)
|
private DataModelVisualizationViewModel CreateChild(IDataModelUIService dataModelUIService, string path, int depth)
|
||||||
{
|
{
|
||||||
if (depth > MaxDepth)
|
if (depth > MaxDepth)
|
||||||
|
|||||||
@ -1,17 +1,29 @@
|
|||||||
using Artemis.Core;
|
using System.Linq;
|
||||||
|
using Artemis.Core;
|
||||||
|
using Artemis.UI.Shared.Services;
|
||||||
|
|
||||||
namespace Artemis.UI.Shared
|
namespace Artemis.UI.Shared
|
||||||
{
|
{
|
||||||
public static class DataModelWrapperExtensions
|
public static class DataModelWrapperExtensions
|
||||||
{
|
{
|
||||||
public static DataModelPropertiesViewModel CreateViewModel(this EventPredicateWrapperDataModel wrapper)
|
public static DataModelPropertiesViewModel CreateViewModel(this EventPredicateWrapperDataModel wrapper, IDataModelUIService dataModelUIService)
|
||||||
{
|
{
|
||||||
return new DataModelPropertiesViewModel(wrapper, null, new DataModelPath(wrapper));
|
DataModelPropertiesViewModel viewModel = new DataModelPropertiesViewModel(wrapper, null, new DataModelPath(wrapper));
|
||||||
|
viewModel.Update(dataModelUIService);
|
||||||
|
viewModel.UpdateRequested += (sender, args) => viewModel.Update(dataModelUIService);
|
||||||
|
viewModel.Children.First().IsVisualizationExpanded = true;
|
||||||
|
|
||||||
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataModelPropertiesViewModel CreateViewModel(this ListPredicateWrapperDataModel wrapper)
|
public static DataModelPropertiesViewModel CreateViewModel(this ListPredicateWrapperDataModel wrapper, IDataModelUIService dataModelUIService)
|
||||||
{
|
{
|
||||||
return new DataModelPropertiesViewModel(wrapper, null, new DataModelPath(wrapper));
|
DataModelPropertiesViewModel viewModel = new DataModelPropertiesViewModel(wrapper, null, new DataModelPath(wrapper));
|
||||||
|
viewModel.Update(dataModelUIService);
|
||||||
|
viewModel.UpdateRequested += (sender, args) => viewModel.Update(dataModelUIService);
|
||||||
|
viewModel.Children.First().IsVisualizationExpanded = true;
|
||||||
|
|
||||||
|
return viewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="pack://application:,,,/Artemis.UI;component/ResourceDictionaries/DataModelConditions.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/Artemis.UI;component/ResourceDictionaries/DataModelConditions.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
<utilities:BindingProxy x:Key="DataContextProxy" Data="{Binding}" />
|
<Converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
@ -45,13 +45,24 @@
|
|||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Row="0"
|
<Button Grid.Row="0"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
ToolTip="Change the operator of the group, determining which conditions should match"
|
|
||||||
Style="{StaticResource DataModelConditionButtonLeftClickMenu}"
|
Style="{StaticResource DataModelConditionButtonLeftClickMenu}"
|
||||||
Background="#E74C4C"
|
Background="#E74C4C"
|
||||||
BorderBrush="#E74C4C"
|
BorderBrush="#E74C4C"
|
||||||
Margin="3 1"
|
Margin="3 1"
|
||||||
Content="{Binding SelectedBooleanOperator}"
|
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>
|
<Button.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="And"
|
<MenuItem Header="And"
|
||||||
|
|||||||
@ -19,6 +19,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
private readonly IProfileEditorService _profileEditorService;
|
private readonly IProfileEditorService _profileEditorService;
|
||||||
private bool _isInitialized;
|
private bool _isInitialized;
|
||||||
private bool _isRootGroup;
|
private bool _isRootGroup;
|
||||||
|
private bool _isEventGroup;
|
||||||
|
|
||||||
public DataModelConditionGroupViewModel(DataModelConditionGroup dataModelConditionGroup,
|
public DataModelConditionGroupViewModel(DataModelConditionGroup dataModelConditionGroup,
|
||||||
ConditionGroupType groupType,
|
ConditionGroupType groupType,
|
||||||
@ -48,6 +49,12 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
set => SetAndNotify(ref _isRootGroup, value);
|
set => SetAndNotify(ref _isRootGroup, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsEventGroup
|
||||||
|
{
|
||||||
|
get => _isEventGroup;
|
||||||
|
set => SetAndNotify(ref _isEventGroup, value);
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsInitialized
|
public bool IsInitialized
|
||||||
{
|
{
|
||||||
get => _isInitialized;
|
get => _isInitialized;
|
||||||
@ -98,7 +105,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
NotifyOfPropertyChange(nameof(SelectedBooleanOperator));
|
NotifyOfPropertyChange(nameof(SelectedBooleanOperator));
|
||||||
|
|
||||||
// Remove VMs of effects no longer applied on the layer
|
// Remove VMs of effects no longer applied on the layer
|
||||||
Items.RemoveRange(Items.Where(c => !DataModelConditionGroup.Children.Contains(c.Model)).ToList());
|
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)
|
foreach (DataModelConditionViewModel childViewModel in Items)
|
||||||
childViewModel.Update();
|
childViewModel.Update();
|
||||||
|
|
||||||
if (IsRootGroup && Parent is DisplayConditionsViewModel displayConditionsViewModel)
|
IsEventGroup = Items.Any(i => i is DataModelConditionEventViewModel);
|
||||||
displayConditionsViewModel.DisplayStartHint = !Items.Any();
|
if (IsEventGroup)
|
||||||
|
{
|
||||||
|
if (DataModelConditionGroup.BooleanOperator != BooleanOperator.And)
|
||||||
|
SelectBooleanOperator("And");
|
||||||
|
}
|
||||||
|
|
||||||
OnUpdated();
|
OnUpdated();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,7 +54,8 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
|
|
||||||
protected override List<DataModelPropertiesViewModel> GetExtraRightSideDataModelViewModels()
|
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()
|
private DataModelPropertiesViewModel GetEventDataModel()
|
||||||
@ -63,7 +64,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
DataModelConditionEventPredicate.DataModelConditionEvent.EventArgumentType
|
DataModelConditionEventPredicate.DataModelConditionEvent.EventArgumentType
|
||||||
);
|
);
|
||||||
|
|
||||||
return wrapper.CreateViewModel();
|
return wrapper.CreateViewModel(_dataModelUIService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -20,6 +20,10 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
: base(dataModelConditionGeneralPredicate, profileEditorService, dataModelUIService, conditionOperatorService, settingsService)
|
: base(dataModelConditionGeneralPredicate, profileEditorService, dataModelUIService, conditionOperatorService, settingsService)
|
||||||
{
|
{
|
||||||
_dataModelUIService = dataModelUIService;
|
_dataModelUIService = dataModelUIService;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnInitialActivate()
|
||||||
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,8 +33,13 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
List<Type> supportedInputTypes = editors.Select(e => e.SupportedType).ToList();
|
List<Type> supportedInputTypes = editors.Select(e => e.SupportedType).ToList();
|
||||||
supportedInputTypes.AddRange(editors.Where(e => e.CompatibleConversionTypes != null).SelectMany(e => e.CompatibleConversionTypes));
|
supportedInputTypes.AddRange(editors.Where(e => e.CompatibleConversionTypes != null).SelectMany(e => e.CompatibleConversionTypes));
|
||||||
supportedInputTypes.Add(typeof(IEnumerable<>));
|
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;
|
return supportedInputTypes;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -179,5 +179,17 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</materialDesign:ColorZone>
|
</materialDesign:ColorZone>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Indicator for events, overlaps the previous grid -->
|
||||||
|
<materialDesign:Card Grid.Row="3"
|
||||||
|
Grid.Column="0"
|
||||||
|
Margin="-10 0 -10 -10"
|
||||||
|
Opacity="0.95"
|
||||||
|
Background="{DynamicResource MaterialDesignPaper}"
|
||||||
|
Visibility="{Binding IsEventCondition, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||||
|
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14">
|
||||||
|
<materialDesign:PackIcon Kind="FlashAlert" Height="20" Width="20" Margin="0 -5" /> Timeline modes not available to event-based conditions
|
||||||
|
</TextBlock>
|
||||||
|
</materialDesign:Card>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
using Artemis.UI.Ninject.Factories;
|
using Artemis.UI.Ninject.Factories;
|
||||||
using Artemis.UI.Screens.ProfileEditor.Conditions;
|
using Artemis.UI.Screens.ProfileEditor.Conditions;
|
||||||
@ -14,6 +15,7 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
|
|||||||
private readonly IProfileEditorService _profileEditorService;
|
private readonly IProfileEditorService _profileEditorService;
|
||||||
private RenderProfileElement _renderProfileElement;
|
private RenderProfileElement _renderProfileElement;
|
||||||
private bool _displayStartHint;
|
private bool _displayStartHint;
|
||||||
|
private bool _isEventCondition;
|
||||||
|
|
||||||
public DisplayConditionsViewModel(IProfileEditorService profileEditorService, IDataModelConditionsVmFactory dataModelConditionsVmFactory)
|
public DisplayConditionsViewModel(IProfileEditorService profileEditorService, IDataModelConditionsVmFactory dataModelConditionsVmFactory)
|
||||||
{
|
{
|
||||||
@ -27,6 +29,12 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
|
|||||||
set => SetAndNotify(ref _displayStartHint, value);
|
set => SetAndNotify(ref _displayStartHint, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsEventCondition
|
||||||
|
{
|
||||||
|
get => _isEventCondition;
|
||||||
|
set => SetAndNotify(ref _isEventCondition, value);
|
||||||
|
}
|
||||||
|
|
||||||
public RenderProfileElement RenderProfileElement
|
public RenderProfileElement RenderProfileElement
|
||||||
{
|
{
|
||||||
get => _renderProfileElement;
|
get => _renderProfileElement;
|
||||||
@ -71,7 +79,14 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
|
|||||||
|
|
||||||
private void ProfileEditorServiceOnProfileElementSelected(object sender, RenderProfileElementEventArgs e)
|
private void ProfileEditorServiceOnProfileElementSelected(object sender, RenderProfileElementEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (RenderProfileElement != null)
|
||||||
|
{
|
||||||
|
RenderProfileElement.DisplayCondition.ChildAdded -= DisplayConditionOnChildrenModified;
|
||||||
|
RenderProfileElement.DisplayCondition.ChildRemoved -= DisplayConditionOnChildrenModified;
|
||||||
|
}
|
||||||
|
|
||||||
RenderProfileElement = e.RenderProfileElement;
|
RenderProfileElement = e.RenderProfileElement;
|
||||||
|
|
||||||
NotifyOfPropertyChange(nameof(DisplayContinuously));
|
NotifyOfPropertyChange(nameof(DisplayContinuously));
|
||||||
NotifyOfPropertyChange(nameof(AlwaysFinishTimeline));
|
NotifyOfPropertyChange(nameof(AlwaysFinishTimeline));
|
||||||
NotifyOfPropertyChange(nameof(ConditionBehaviourEnabled));
|
NotifyOfPropertyChange(nameof(ConditionBehaviourEnabled));
|
||||||
@ -90,8 +105,17 @@ namespace Artemis.UI.Screens.ProfileEditor.DisplayConditions
|
|||||||
ActiveItem.IsRootGroup = true;
|
ActiveItem.IsRootGroup = true;
|
||||||
ActiveItem.Update();
|
ActiveItem.Update();
|
||||||
|
|
||||||
// Only show the intro to conditions once, and only if the layer has no conditions
|
DisplayStartHint = !RenderProfileElement.DisplayCondition.Children.Any();
|
||||||
DisplayStartHint = !ActiveItem.Items.Any();
|
IsEventCondition = RenderProfileElement.DisplayCondition.Children.Any(c => c is DataModelConditionEvent);
|
||||||
|
|
||||||
|
RenderProfileElement.DisplayCondition.ChildAdded += DisplayConditionOnChildrenModified;
|
||||||
|
RenderProfileElement.DisplayCondition.ChildRemoved += DisplayConditionOnChildrenModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DisplayConditionOnChildrenModified(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DisplayStartHint = !RenderProfileElement.DisplayCondition.Children.Any();
|
||||||
|
IsEventCondition = RenderProfileElement.DisplayCondition.Children.Any(c => c is DataModelConditionEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -13,6 +13,12 @@ namespace Artemis.Plugins.DataModelExpansions.TestData
|
|||||||
{
|
{
|
||||||
_rand = new Random();
|
_rand = new Random();
|
||||||
AddTimedUpdate(TimeSpan.FromSeconds(1), TimedUpdate);
|
AddTimedUpdate(TimeSpan.FromSeconds(1), TimedUpdate);
|
||||||
|
AddTimedUpdate(TimeSpan.FromSeconds(5), TriggerEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TriggerEvent(double obj)
|
||||||
|
{
|
||||||
|
DataModel.Event2.Trigger(new TestEventArgs(Guid.NewGuid().ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DisablePlugin()
|
public override void DisablePlugin()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user