mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Data model debugger - Display ToString of object if overridden
This commit is contained in:
parent
6c41a6b1f2
commit
a3906e3fe3
@ -8,6 +8,7 @@ namespace Artemis.UI.Shared
|
|||||||
public class DataModelPropertiesViewModel : DataModelVisualizationViewModel
|
public class DataModelPropertiesViewModel : DataModelVisualizationViewModel
|
||||||
{
|
{
|
||||||
private Type _displayValueType;
|
private Type _displayValueType;
|
||||||
|
private object _displayValue;
|
||||||
|
|
||||||
internal DataModelPropertiesViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, DataModelPath dataModelPath) : base(dataModel, parent, dataModelPath)
|
internal DataModelPropertiesViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, DataModelPath dataModelPath) : base(dataModel, parent, dataModelPath)
|
||||||
{
|
{
|
||||||
@ -19,9 +20,23 @@ namespace Artemis.UI.Shared
|
|||||||
set => SetAndNotify(ref _displayValueType, value);
|
set => SetAndNotify(ref _displayValueType, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object DisplayValue
|
||||||
|
{
|
||||||
|
get => _displayValue;
|
||||||
|
set => SetAndNotify(ref _displayValue, value);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update(IDataModelUIService dataModelUIService)
|
public override void Update(IDataModelUIService dataModelUIService)
|
||||||
{
|
{
|
||||||
DisplayValueType = DataModelPath?.GetPropertyType();
|
DisplayValueType = DataModelPath?.GetPropertyType();
|
||||||
|
|
||||||
|
// Only set a display value if ToString returns useful information and not just the type name
|
||||||
|
object currentValue = GetCurrentValue();
|
||||||
|
if (currentValue != null && currentValue.ToString() != currentValue.GetType().ToString())
|
||||||
|
DisplayValue = currentValue.ToString();
|
||||||
|
else
|
||||||
|
DisplayValue = null;
|
||||||
|
|
||||||
// Always populate properties
|
// Always populate properties
|
||||||
PopulateProperties(dataModelUIService);
|
PopulateProperties(dataModelUIService);
|
||||||
|
|
||||||
@ -35,6 +50,8 @@ namespace Artemis.UI.Shared
|
|||||||
|
|
||||||
public override object GetCurrentValue()
|
public override object GetCurrentValue()
|
||||||
{
|
{
|
||||||
|
if (Parent == null)
|
||||||
|
return null;
|
||||||
return Parent.IsRootViewModel ? DataModel : base.GetCurrentValue();
|
return Parent.IsRootViewModel ? DataModel : base.GetCurrentValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,18 @@
|
|||||||
<StackPanel>
|
<StackPanel>
|
||||||
<StackPanel.Resources>
|
<StackPanel.Resources>
|
||||||
<DataTemplate DataType="{x:Type dataModel:DataModelPropertiesViewModel}">
|
<DataTemplate DataType="{x:Type dataModel:DataModelPropertiesViewModel}">
|
||||||
<TextBlock Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" ToolTipService.ShowOnDisabled="True"/>
|
<Grid ToolTip="{Binding PropertyDescription.Description}" ToolTipService.ShowOnDisabled="True">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<!-- Value description -->
|
||||||
|
<TextBlock Grid.Column="0" Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" ToolTipService.ShowOnDisabled="True"/>
|
||||||
|
|
||||||
|
<!-- Value display -->
|
||||||
|
<TextBlock Grid.Column="1" Text="{Binding DisplayValue}" HorizontalAlignment="Right" FontFamily="Consolas" Margin="15 0.5 0 0"/>
|
||||||
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
<DataTemplate DataType="{x:Type dataModel:DataModelListViewModel}">
|
<DataTemplate DataType="{x:Type dataModel:DataModelListViewModel}">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
|
|||||||
@ -65,6 +65,7 @@
|
|||||||
<HierarchicalDataTemplate DataType="{x:Type dataModel:DataModelPropertiesViewModel}" ItemsSource="{Binding Children}">
|
<HierarchicalDataTemplate DataType="{x:Type dataModel:DataModelPropertiesViewModel}" ItemsSource="{Binding Children}">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
@ -72,6 +73,10 @@
|
|||||||
<Run>[</Run><Run Text="{Binding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" /><Run>]</Run>
|
<Run>[</Run><Run Text="{Binding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" /><Run>]</Run>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<TextBlock Grid.Column="1" Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" />
|
<TextBlock Grid.Column="1" Text="{Binding PropertyDescription.Name}" ToolTip="{Binding PropertyDescription.Description}" />
|
||||||
|
<TextBlock Grid.Column="2"
|
||||||
|
Text="{Binding DisplayValue}"
|
||||||
|
FontFamily="Consolas"
|
||||||
|
HorizontalAlignment="Right"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
</HierarchicalDataTemplate>
|
</HierarchicalDataTemplate>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user