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
|
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)
|
public override void UpdateValue(object model)
|
||||||
{
|
{
|
||||||
DisplayValue = model is T value ? value : default;
|
DisplayValue = model is T value ? value : default;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override object InternalGuard => null;
|
protected virtual void OnDisplayValueUpdated()
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -33,11 +34,22 @@ namespace Artemis.UI.Shared
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class DataModelDisplayViewModel : PropertyChangedBase
|
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>
|
/// <summary>
|
||||||
/// Prevents this type being implemented directly, implement <see cref="DataModelDisplayViewModel{T}" /> instead.
|
/// Prevents this type being implemented directly, implement <see cref="DataModelDisplayViewModel{T}" /> instead.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal abstract object InternalGuard { get; }
|
internal abstract object InternalGuard { get; }
|
||||||
|
|
||||||
|
public abstract void UpdateValue(object model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,7 +39,10 @@ namespace Artemis.UI.Shared
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (DisplayViewModel == null)
|
if (DisplayViewModel == null)
|
||||||
|
{
|
||||||
DisplayViewModel = dataModelUIService.GetDataModelDisplayViewModel(DataModelPath.GetPropertyType(), true);
|
DisplayViewModel = dataModelUIService.GetDataModelDisplayViewModel(DataModelPath.GetPropertyType(), true);
|
||||||
|
DisplayViewModel.PropertyDescription = DataModelPath.GetPropertyDescription();
|
||||||
|
}
|
||||||
|
|
||||||
DisplayValue = GetCurrentValue();
|
DisplayValue = GetCurrentValue();
|
||||||
DisplayValueType = DataModelPath.GetPropertyType();
|
DisplayValueType = DataModelPath.GetPropertyType();
|
||||||
|
|||||||
@ -5,18 +5,39 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:Artemis.UI.Shared.DefaultTypes.DataModel.Display"
|
xmlns:local="clr-namespace:Artemis.UI.Shared.DefaultTypes.DataModel.Display"
|
||||||
xmlns:s="https://github.com/canton7/Stylet"
|
xmlns:s="https://github.com/canton7/Stylet"
|
||||||
|
xmlns:shared="clr-namespace:Artemis.UI.Shared"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800"
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
d:DataContext="{d:DesignInstance local:DefaultDataModelDisplayViewModel}">
|
d:DataContext="{d:DesignInstance local:DefaultDataModelDisplayViewModel}">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<shared:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
||||||
|
</UserControl.Resources>
|
||||||
<Grid>
|
<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 -->
|
<!-- Value display -->
|
||||||
<TextBlock Text="{Binding DisplayValue, Mode=OneWay}"
|
<TextBlock Grid.Column="1"
|
||||||
|
Text="{Binding DisplayValue, Mode=OneWay}"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Visibility="{Binding ShowToString, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
Visibility="{Binding ShowToString, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
||||||
<TextBlock Text="null"
|
<TextBlock Grid.Column="1"
|
||||||
|
Text="null"
|
||||||
FontFamily="Consolas"
|
FontFamily="Consolas"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}"
|
Foreground="{DynamicResource MaterialDesignCheckBoxDisabled}"
|
||||||
Visibility="{Binding ShowNull, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
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>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
Loading…
x
Reference in New Issue
Block a user