mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Data model debugger - Display prefixes and affixes
This commit is contained in:
parent
3fcfe4ceec
commit
5b80c1e4fe
@ -1,4 +1,5 @@
|
||||
using Stylet;
|
||||
using Artemis.Core.DataModelExpansions;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
@ -16,16 +17,16 @@ namespace Artemis.UI.Shared
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnDisplayValueUpdated()
|
||||
{
|
||||
}
|
||||
internal override object InternalGuard => null;
|
||||
|
||||
public override void UpdateValue(object model)
|
||||
{
|
||||
DisplayValue = model is T value ? value : default;
|
||||
}
|
||||
|
||||
internal override object InternalGuard => null;
|
||||
protected virtual void OnDisplayValueUpdated()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -33,11 +34,22 @@ namespace Artemis.UI.Shared
|
||||
/// </summary>
|
||||
public abstract class DataModelDisplayViewModel : PropertyChangedBase
|
||||
{
|
||||
public abstract void UpdateValue(object model);
|
||||
private DataModelPropertyAttribute _propertyDescription;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the property description of this value
|
||||
/// </summary>
|
||||
public DataModelPropertyAttribute PropertyDescription
|
||||
{
|
||||
get => _propertyDescription;
|
||||
internal set => SetAndNotify(ref _propertyDescription, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prevents this type being implemented directly, implement <see cref="DataModelDisplayViewModel{T}" /> instead.
|
||||
/// </summary>
|
||||
internal abstract object InternalGuard { get; }
|
||||
|
||||
public abstract void UpdateValue(object model);
|
||||
}
|
||||
}
|
||||
@ -39,13 +39,16 @@ namespace Artemis.UI.Shared
|
||||
return;
|
||||
|
||||
if (DisplayViewModel == null)
|
||||
{
|
||||
DisplayViewModel = dataModelUIService.GetDataModelDisplayViewModel(DataModelPath.GetPropertyType(), true);
|
||||
DisplayViewModel.PropertyDescription = DataModelPath.GetPropertyDescription();
|
||||
}
|
||||
|
||||
DisplayValue = GetCurrentValue();
|
||||
DisplayValueType = DataModelPath.GetPropertyType();
|
||||
UpdateDisplayParameters();
|
||||
}
|
||||
|
||||
|
||||
protected void UpdateDisplayParameters()
|
||||
{
|
||||
DisplayViewModel?.UpdateValue(DisplayValue);
|
||||
|
||||
@ -1,22 +1,43 @@
|
||||
<UserControl x:Class="Artemis.UI.Shared.DefaultTypes.DataModel.Display.DefaultDataModelDisplayView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Shared.DefaultTypes.DataModel.Display"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:DefaultDataModelDisplayViewModel}">
|
||||
<UserControl.Resources>
|
||||
<shared:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0"
|
||||
Text="{Binding PropertyDescription.Prefix}"
|
||||
Visibility="{Binding PropertyDescription.Prefix, Converter={StaticResource NullToVisibilityConverter}}"
|
||||
Margin="0 0 5 0" />
|
||||
<!-- Value display -->
|
||||
<TextBlock Text="{Binding DisplayValue, Mode=OneWay}"
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="{Binding DisplayValue, Mode=OneWay}"
|
||||
HorizontalAlignment="Right"
|
||||
Visibility="{Binding ShowToString, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
||||
<TextBlock Text="null"
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="null"
|
||||
FontFamily="Consolas"
|
||||
HorizontalAlignment="Right"
|
||||
Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}"
|
||||
Visibility="{Binding ShowNull, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
||||
|
||||
<TextBlock Grid.Column="2"
|
||||
Text="{Binding PropertyDescription.Affix}"
|
||||
Visibility="{Binding PropertyDescription.Affix, Converter={StaticResource NullToVisibilityConverter}}"
|
||||
Margin="5 0 0 0" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
Loading…
x
Reference in New Issue
Block a user