mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 17:53:32 +00:00
Added condition type to layers to resolve #244
This commit is contained in:
parent
b457c566dd
commit
21b7132ada
@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Interfaces;
|
using Artemis.Profiles.Layers.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
@ -11,7 +12,17 @@ namespace Artemis.Profiles.Layers.Conditions
|
|||||||
{
|
{
|
||||||
lock (layerModel.Properties.Conditions)
|
lock (layerModel.Properties.Conditions)
|
||||||
{
|
{
|
||||||
return layerModel.Properties.Conditions.All(cm => cm.ConditionMet(dataModel));
|
switch (layerModel.Properties.ConditionType)
|
||||||
|
{
|
||||||
|
case ConditionType.AnyMet:
|
||||||
|
return layerModel.Properties.Conditions.Any(cm => cm.ConditionMet(dataModel));
|
||||||
|
case ConditionType.AllMet:
|
||||||
|
return layerModel.Properties.Conditions.All(cm => cm.ConditionMet(dataModel));
|
||||||
|
case ConditionType.NoneMet:
|
||||||
|
return !layerModel.Properties.Conditions.Any(cm => cm.ConditionMet(dataModel));
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using Artemis.Models.Interfaces;
|
using Artemis.Models.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Interfaces;
|
using Artemis.Profiles.Layers.Interfaces;
|
||||||
using Artemis.Profiles.Layers.Models;
|
using Artemis.Profiles.Layers.Models;
|
||||||
@ -11,7 +12,19 @@ namespace Artemis.Profiles.Layers.Conditions
|
|||||||
{
|
{
|
||||||
lock (layerModel.Properties.Conditions)
|
lock (layerModel.Properties.Conditions)
|
||||||
{
|
{
|
||||||
var conditionsMet = layerModel.Properties.Conditions.All(cm => cm.ConditionMet(dataModel));
|
var conditionsMet = false;
|
||||||
|
switch (layerModel.Properties.ConditionType)
|
||||||
|
{
|
||||||
|
case ConditionType.AnyMet:
|
||||||
|
conditionsMet = layerModel.Properties.Conditions.Any(cm => cm.ConditionMet(dataModel));
|
||||||
|
break;
|
||||||
|
case ConditionType.AllMet:
|
||||||
|
conditionsMet = layerModel.Properties.Conditions.All(cm => cm.ConditionMet(dataModel));
|
||||||
|
break;
|
||||||
|
case ConditionType.NoneMet:
|
||||||
|
conditionsMet = !layerModel.Properties.Conditions.Any(cm => cm.ConditionMet(dataModel));
|
||||||
|
break;
|
||||||
|
}
|
||||||
layerModel.EventProperties.Update(layerModel, conditionsMet);
|
layerModel.EventProperties.Update(layerModel, conditionsMet);
|
||||||
|
|
||||||
if (conditionsMet && layerModel.EventProperties.CanTrigger)
|
if (conditionsMet && layerModel.EventProperties.CanTrigger)
|
||||||
|
|||||||
@ -387,7 +387,7 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
get { return Profile; }
|
get { return Profile; }
|
||||||
set { Profile = value; }
|
set { Profile = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.Utilities.Converters;
|
using Artemis.Utilities.Converters;
|
||||||
@ -24,6 +25,7 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
Opacity = source.Opacity;
|
Opacity = source.Opacity;
|
||||||
AnimationSpeed = source.AnimationSpeed;
|
AnimationSpeed = source.AnimationSpeed;
|
||||||
Conditions = source.Conditions;
|
Conditions = source.Conditions;
|
||||||
|
ConditionType = source.ConditionType;
|
||||||
DynamicProperties = source.DynamicProperties;
|
DynamicProperties = source.DynamicProperties;
|
||||||
Brush = source.Brush;
|
Brush = source.Brush;
|
||||||
HeightEase = source.HeightEase;
|
HeightEase = source.HeightEase;
|
||||||
@ -47,6 +49,7 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
public string WidthEase { set; get; }
|
public string WidthEase { set; get; }
|
||||||
public string HeightEase { get; set; }
|
public string HeightEase { get; set; }
|
||||||
public string OpacityEase { get; set; }
|
public string OpacityEase { get; set; }
|
||||||
|
public ConditionType ConditionType { get; set; }
|
||||||
public List<LayerConditionModel> Conditions { get; set; } = new List<LayerConditionModel>();
|
public List<LayerConditionModel> Conditions { get; set; } = new List<LayerConditionModel>();
|
||||||
public List<DynamicPropertiesModel> DynamicProperties { get; set; } = new List<DynamicPropertiesModel>();
|
public List<DynamicPropertiesModel> DynamicProperties { get; set; } = new List<DynamicPropertiesModel>();
|
||||||
|
|
||||||
@ -80,4 +83,11 @@ namespace Artemis.Profiles.Layers.Models
|
|||||||
return new Rect(X*scale, Y*scale, Width*scale, Height*scale);
|
return new Rect(X*scale, Y*scale, Width*scale, Height*scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ConditionType
|
||||||
|
{
|
||||||
|
[Description("All met")] AllMet,
|
||||||
|
[Description("Any met")] AnyMet,
|
||||||
|
[Description("None met")] NoneMet
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ namespace Artemis.ViewModels.Profiles
|
|||||||
NotifyOfPropertyChange(() => SelectedLayerType);
|
NotifyOfPropertyChange(() => SelectedLayerType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PreSelect()
|
public void PreSelect()
|
||||||
{
|
{
|
||||||
SelectedLayerType = LayerTypes.FirstOrDefault(t => t.Name == ProposedLayer.LayerType.Name);
|
SelectedLayerType = LayerTypes.FirstOrDefault(t => t.Name == ProposedLayer.LayerType.Name);
|
||||||
|
|||||||
@ -44,7 +44,6 @@
|
|||||||
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitchButton.Win10}"
|
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitchButton.Win10}"
|
||||||
HorizontalAlignment="Right" />
|
HorizontalAlignment="Right" />
|
||||||
|
|
||||||
|
|
||||||
<!-- Show on startup -->
|
<!-- Show on startup -->
|
||||||
<Label Grid.Row="2" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
|
<Label Grid.Row="2" Grid.Column="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||||
Content="Show on startup:" />
|
Content="Show on startup:" />
|
||||||
|
|||||||
@ -9,8 +9,18 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Artemis | Edit Layer" Height="820" Width="630"
|
Title="Artemis | Edit Layer" Height="820" Width="630"
|
||||||
xmlns:cal="http://www.caliburnproject.org"
|
xmlns:cal="http://www.caliburnproject.org"
|
||||||
|
xmlns:converters="clr-namespace:Artemis.Utilities.Converters"
|
||||||
|
xmlns:models="clr-namespace:Artemis.Profiles.Layers.Models"
|
||||||
GlowBrush="{DynamicResource AccentColorBrush}" Icon="../../Resources/bow.png"
|
GlowBrush="{DynamicResource AccentColorBrush}" Icon="../../Resources/bow.png"
|
||||||
ResizeMode="NoResize">
|
ResizeMode="NoResize">
|
||||||
|
<controls:MetroWindow.Resources>
|
||||||
|
<converters:EnumDescriptionConverter x:Key="HEnumDescriptionConverter" />
|
||||||
|
<ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type sys:Enum}" x:Key="ConditionTypeValues">
|
||||||
|
<ObjectDataProvider.MethodParameters>
|
||||||
|
<x:Type TypeName="models:ConditionType" />
|
||||||
|
</ObjectDataProvider.MethodParameters>
|
||||||
|
</ObjectDataProvider>
|
||||||
|
</controls:MetroWindow.Resources>
|
||||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||||
<Grid Margin="10,0">
|
<Grid Margin="10,0">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@ -68,7 +78,22 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Condition editor -->
|
<!-- Condition editor -->
|
||||||
<Label Grid.Row="2" Grid.Column="0" FontSize="20" Content="Display if.." />
|
<Grid Grid.Row="2" Grid.Column="0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label FontSize="20" Content="Display if.." Grid.Column="0" />
|
||||||
|
<ComboBox SelectedItem="{Binding Path=ProposedLayer.Properties.ConditionType}" Grid.Column="1"
|
||||||
|
ItemsSource="{Binding Source={StaticResource ConditionTypeValues}}" Margin="10,0"
|
||||||
|
VerticalAlignment="Center" Height="22">
|
||||||
|
<ComboBox.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBlock Text="{Binding Converter={StaticResource HEnumDescriptionConverter}}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</ComboBox.ItemTemplate>
|
||||||
|
</ComboBox>
|
||||||
|
</Grid>
|
||||||
<Border Grid.Row="3" Grid.Column="0" BorderThickness="1" BorderBrush="{StaticResource GrayBrush7}"
|
<Border Grid.Row="3" Grid.Column="0" BorderThickness="1" BorderBrush="{StaticResource GrayBrush7}"
|
||||||
Margin="10,0" SnapsToDevicePixels="True">
|
Margin="10,0" SnapsToDevicePixels="True">
|
||||||
<ListBox Height="138" x:Name="LayerConditionVms" ScrollViewer.VerticalScrollBarVisibility="Visible">
|
<ListBox Height="138" x:Name="LayerConditionVms" ScrollViewer.VerticalScrollBarVisibility="Visible">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user