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

Debugger - Added the ability to copy data model paths

This commit is contained in:
Robert 2022-07-15 21:06:31 +02:00
parent 3b4194cb9d
commit 0b9fcfdcbe
2 changed files with 21 additions and 1 deletions

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Reactive;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using Artemis.Core; using Artemis.Core;
@ -33,12 +34,20 @@ public abstract class DataModelVisualizationViewModel : ReactiveObject, IDisposa
DataModelPath = dataModelPath; DataModelPath = dataModelPath;
IsMatchingFilteredTypes = true; IsMatchingFilteredTypes = true;
CopyPath = ReactiveCommand.CreateFromTask(async () =>
{
if (Avalonia.Application.Current?.Clipboard != null && Path != null)
await Avalonia.Application.Current.Clipboard.SetTextAsync(Path);
});
if (parent == null) if (parent == null)
IsRootViewModel = true; IsRootViewModel = true;
else else
PropertyDescription = DataModelPath?.GetPropertyDescription() ?? DataModel?.DataModelDescription; PropertyDescription = DataModelPath?.GetPropertyDescription() ?? DataModel?.DataModelDescription;
} }
public ReactiveCommand<Unit,Unit> CopyPath { get; }
/// <summary> /// <summary>
/// Gets a boolean indicating whether this view model is at the root of the data model /// Gets a boolean indicating whether this view model is at the root of the data model
/// </summary> /// </summary>

View File

@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dataModel="clr-namespace:Artemis.UI.Shared.DataModelVisualization.Shared;assembly=Artemis.UI.Shared" xmlns:dataModel="clr-namespace:Artemis.UI.Shared.DataModelVisualization.Shared;assembly=Artemis.UI.Shared"
xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared" xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Debugger.DataModel.DataModelDebugView"> x:Class="Artemis.UI.Screens.Debugger.DataModel.DataModelDebugView">
<UserControl.Resources> <UserControl.Resources>
@ -24,6 +25,17 @@
<TreeView.Styles> <TreeView.Styles>
<Style Selector="TreeViewItem"> <Style Selector="TreeViewItem">
<Setter Property="IsExpanded" Value="{Binding IsVisualizationExpanded, Mode=TwoWay}" /> <Setter Property="IsExpanded" Value="{Binding IsVisualizationExpanded, Mode=TwoWay}" />
<Setter Property="ContextFlyout">
<Setter.Value>
<MenuFlyout>
<MenuItem Header="Copy path" Command="{Binding CopyPath}">
<MenuItem.Icon>
<avalonia:MaterialIcon Kind="ContentCopy" />
</MenuItem.Icon>
</MenuItem>
</MenuFlyout>
</Setter.Value>
</Setter>
</Style> </Style>
</TreeView.Styles> </TreeView.Styles>
<TreeView.DataTemplates> <TreeView.DataTemplates>
@ -59,7 +71,6 @@
</TreeDataTemplate> </TreeDataTemplate>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelPropertyViewModel}"> <TreeDataTemplate DataType="{x:Type dataModel:DataModelPropertyViewModel}">
<Grid ColumnDefinitions="Auto,Auto,*"> <Grid ColumnDefinitions="Auto,Auto,*">
<!-- Value description --> <!-- Value description -->
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0"> <StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock> <TextBlock FontWeight="Bold">[</TextBlock>