1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Ironed out LayerEditor conditions design

This commit is contained in:
SpoinkyNL 2016-03-26 23:44:37 +01:00
parent 9c32bb6ce6
commit c2cfadf942
2 changed files with 50 additions and 15 deletions

View File

@ -8,6 +8,7 @@ using System.Security.Principal;
using System.Windows; using System.Windows;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using static System.String;
namespace Artemis.Utilities namespace Artemis.Utilities
{ {
@ -63,9 +64,18 @@ namespace Artemis.Utilities
var list = new List<PropertyCollection>(); var list = new List<PropertyCollection>();
foreach (var propertyInfo in getProperties) foreach (var propertyInfo in getProperties)
{ {
var friendlyName = Empty;
if (propertyInfo.PropertyType.Name == "Int32")
friendlyName = "(Number) ";
else if (propertyInfo.PropertyType.Name == "String")
friendlyName = "(Text) ";
if (propertyInfo.PropertyType.BaseType?.Name == "Enum")
friendlyName = "(Choice) ";
var parent = new PropertyCollection var parent = new PropertyCollection
{ {
Type = propertyInfo.PropertyType.Name, Type = propertyInfo.PropertyType.Name,
DisplayType = friendlyName,
Display = $"{path.Replace(".", " ")}{propertyInfo.Name}", Display = $"{path.Replace(".", " ")}{propertyInfo.Name}",
Path = $"{path}{propertyInfo.Name}" Path = $"{path}{propertyInfo.Name}"
}; };
@ -76,7 +86,9 @@ namespace Artemis.Utilities
parent.Type = "Enum"; parent.Type = "Enum";
} }
list.Add(parent); if (friendlyName != Empty)
list.Add(parent);
list.AddRange(GenerateTypeMap(propertyInfo.PropertyType.GetProperties(), path + $"{propertyInfo.Name}.")); list.AddRange(GenerateTypeMap(propertyInfo.PropertyType.GetProperties(), path + $"{propertyInfo.Name}."));
} }
return list; return list;
@ -94,6 +106,7 @@ namespace Artemis.Utilities
public string[] EnumValues { get; set; } public string[] EnumValues { get; set; }
public List<PropertyCollection> Children { get; set; } public List<PropertyCollection> Children { get; set; }
public string DisplayType { get; set; }
} }
} }
} }

View File

@ -6,35 +6,57 @@
xmlns:local="clr-namespace:Artemis.Views.LayerEditor" xmlns:local="clr-namespace:Artemis.Views.LayerEditor"
xmlns:cal="http://www.caliburnproject.org" xmlns:cal="http://www.caliburnproject.org"
xmlns:utilities="clr-namespace:Artemis.Utilities" xmlns:utilities="clr-namespace:Artemis.Utilities"
mc:Ignorable="d" mc:Ignorable="d" d:DesignWidth="613.296" Height="46">
d:DesignHeight="132.061" d:DesignWidth="632.296"> <UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Resources/Icons.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid Margin="10"> <Grid Margin="10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="30" /> <ColumnDefinition Width="30" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
<ColumnDefinition Width="120" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- Left --> <!-- Left -->
<ComboBox x:Name="DataModelProps" Grid.Column="0" Width="250" MaxDropDownHeight="125" <ComboBox x:Name="DataModelProps" Grid.Column="0" Width="250" MaxDropDownHeight="125"
HorizontalAlignment="Center" VerticalAlignment="Top" DisplayMemberPath="Display" /> HorizontalAlignment="Center" VerticalAlignment="Top">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel DataContext="{Binding}" Orientation="Horizontal">
<TextBlock FontWeight="Bold" Text="{Binding Path=DisplayType}"/>
<TextBlock Text="{Binding Path=Display}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<!-- Center --> <!-- Center -->
<TextBlock Grid.Column="1" Text="is" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,3,0,0" /> <TextBlock Grid.Column="1" Text="is" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,3,0,0" />
<ComboBox x:Name="Operators" Grid.Column="2" Width="150" MaxDropDownHeight="125" HorizontalAlignment="Center" <ComboBox x:Name="Operators" Grid.Column="2" Width="150" MaxDropDownHeight="125" HorizontalAlignment="Center"
VerticalAlignment="Top" Margin="0,0,20,0" /> VerticalAlignment="Top" />
<!-- Right --> <!-- Right -->
<Grid Grid.Column="3"> <Grid Grid.Column="3" HorizontalAlignment="Left" Margin="10,0,0,0" Width="152">
<Grid.RowDefinitions> <Grid.ColumnDefinitions>
<RowDefinition /> <ColumnDefinition Width="125"/>
<RowDefinition /> <ColumnDefinition Width="Auto"/>
</Grid.RowDefinitions> </Grid.ColumnDefinitions>
<StackPanel Grid.Row="0" x:Name="UserValueIsVisible"> <StackPanel Grid.Column="0" x:Name="UserValueIsVisible" HorizontalAlignment="Left" VerticalAlignment="Top">
<TextBox x:Name="UserValue" VerticalAlignment="Top" /> <TextBox x:Name="UserValue" VerticalAlignment="Center" HorizontalAlignment="Left" Width="115"/>
</StackPanel> </StackPanel>
<Button Grid.Row="1" x:Name="Delete" Content="Delete condition" VerticalAlignment="Bottom" Width="100" <Button Grid.Column="1" x:Name="Delete" Width="26" Height="26" Style="{DynamicResource SquareButtonStyle}" VerticalAlignment="Top" HorizontalAlignment="Right" >
Style="{DynamicResource SquareButtonStyle}" HorizontalAlignment="Right" /> <Button.Content>
<Rectangle Fill="Black" Width="12" Height="12">
<Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_delete}" Stretch="Fill" />
</Rectangle.OpacityMask>
</Rectangle>
</Button.Content>
</Button>
</Grid> </Grid>
</Grid> </Grid>