Debugger - Replaced NavigationView in favor for something simpler

This commit is contained in:
Robert committed 2022-08-07 16:19:41 +02:00
1 parent faf5302975
commit 87e87ae15d
35 files changed
+452 -3293

No files matched your search

@@ -21,102 +21,102 @@
</TextBlock>
</StackPanel>
<TreeView Grid.Row="1" Items="{Binding MainDataModel.Children}">
<TreeView.Styles>
<Style Selector="TreeViewItem">
<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>
</TreeView.Styles>
<TreeView.DataTemplates>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelPropertiesViewModel}" ItemsSource="{Binding Children}">
<Grid ColumnDefinitions="Auto,Auto,*">
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
<TextBlock FontWeight="Bold" Text="{Binding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" />
<TextBlock FontWeight="Bold">]</TextBlock>
</StackPanel>
<TreeView Grid.Row="1" Items="{Binding MainDataModel.Children}">
<TreeView.Styles>
<Style Selector="TreeViewItem">
<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>
</TreeView.Styles>
<TreeView.DataTemplates>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelPropertiesViewModel}" ItemsSource="{Binding Children}">
<Grid ColumnDefinitions="Auto,Auto,*">
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
<TextBlock FontWeight="Bold" Text="{Binding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" />
<TextBlock FontWeight="Bold">]</TextBlock>
</StackPanel>
<TextBlock Grid.Column="1" Text="{Binding PropertyDescription.Name}" ToolTip.Tip="{Binding PropertyDescription.Description}" />
<TextBlock Grid.Column="2"
Text="{Binding DisplayValue}"
FontFamily="Consolas"
HorizontalAlignment="Right" />
</Grid>
<TextBlock Grid.Column="1" Text="{Binding PropertyDescription.Name}" ToolTip.Tip="{Binding PropertyDescription.Description}" />
<TextBlock Grid.Column="2"
Text="{Binding DisplayValue}"
FontFamily="Consolas"
HorizontalAlignment="Right" />
</Grid>
</TreeDataTemplate>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelListViewModel}" ItemsSource="{Binding ListChildren}">
<Grid ColumnDefinitions="Auto,Auto,*">
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
<TextBlock FontWeight="Bold" Text="{Binding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" />
<TextBlock FontWeight="Bold">]</TextBlock>
</StackPanel>
<TextBlock Grid.Column="1" Text="{Binding PropertyDescription.Name}" ToolTip.Tip="{Binding PropertyDescription.Description}" />
<TextBlock Grid.Column="2"
Text="{Binding CountDisplay, Mode=OneWay}"
FontFamily="Consolas"
HorizontalAlignment="Right" />
</Grid>
</TreeDataTemplate>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelPropertyViewModel}">
<Grid ColumnDefinitions="Auto,Auto,*">
<!-- Value description -->
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
<TextBlock FontWeight="Bold" Text="{Binding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" />
<TextBlock FontWeight="Bold">]</TextBlock>
</StackPanel>
<TextBlock Grid.Column="1" Text="{Binding PropertyDescription.Name}" ToolTip.Tip="{Binding PropertyDescription.Description}" />
</TreeDataTemplate>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelListViewModel}" ItemsSource="{Binding ListChildren}">
<Grid ColumnDefinitions="Auto,Auto,*">
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
<TextBlock FontWeight="Bold" Text="{Binding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" />
<TextBlock FontWeight="Bold">]</TextBlock>
</StackPanel>
<TextBlock Grid.Column="1" Text="{Binding PropertyDescription.Name}" ToolTip.Tip="{Binding PropertyDescription.Description}" />
<TextBlock Grid.Column="2"
Text="{Binding CountDisplay, Mode=OneWay}"
FontFamily="Consolas"
HorizontalAlignment="Right" />
</Grid>
</TreeDataTemplate>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelPropertyViewModel}">
<Grid ColumnDefinitions="Auto,Auto,*">
<!-- Value description -->
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
<TextBlock FontWeight="Bold" Text="{Binding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" />
<TextBlock FontWeight="Bold">]</TextBlock>
</StackPanel>
<TextBlock Grid.Column="1" Text="{Binding PropertyDescription.Name}" ToolTip.Tip="{Binding PropertyDescription.Description}" />
<!-- Value display -->
<ContentControl Grid.Column="2" Content="{Binding DisplayViewModel}" FontFamily="Consolas" />
</Grid>
</TreeDataTemplate>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelListItemViewModel}">
<Grid ColumnDefinitions="Auto,Auto,*">
<!-- Value description -->
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
<TextBlock FontWeight="Bold" Text="{Binding ListType, Converter={StaticResource TypeToStringConverter}}" />
<TextBlock FontWeight="Bold">]</TextBlock>
</StackPanel>
<!-- Value display -->
<ContentControl Grid.Column="2" Content="{Binding DisplayViewModel}" FontFamily="Consolas" />
</Grid>
</TreeDataTemplate>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelListItemViewModel}">
<Grid ColumnDefinitions="Auto,Auto,*">
<!-- Value description -->
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
<TextBlock FontWeight="Bold" Text="{Binding ListType, Converter={StaticResource TypeToStringConverter}}" />
<TextBlock FontWeight="Bold">]</TextBlock>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock>List item #</TextBlock>
<TextBlock Text="{Binding Index, Mode=OneWay}" />
</StackPanel>
<!-- Value display -->
<ContentControl Grid.Column="2" Content="{Binding DisplayViewModel}" FontFamily="Consolas" />
</Grid>
</TreeDataTemplate>
<ContentControl Grid.Column="2" Content="{Binding DisplayViewModel}" FontFamily="Consolas" />
</Grid>
</TreeDataTemplate>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelEventViewModel}" ItemsSource="{Binding Children}">
<Grid ColumnDefinitions="Auto,Auto,*">
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
<TextBlock FontWeight="Bold" Text="{Binding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" />
<TextBlock FontWeight="Bold">]</TextBlock>
</StackPanel>
<TextBlock Grid.Column="1" Text="{Binding PropertyDescription.Name}" ToolTip.Tip="{Binding PropertyDescription.Description}" />
<TextBlock Grid.Column="2"
Text="{Binding CountDisplay, Mode=OneWay}"
FontFamily="Consolas"
HorizontalAlignment="Right" />
</Grid>
</TreeDataTemplate>
<TreeDataTemplate DataType="{x:Type dataModel:DataModelEventViewModel}" ItemsSource="{Binding Children}">
<Grid ColumnDefinitions="Auto,Auto,*">
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="0 0 5 0">
<TextBlock FontWeight="Bold">[</TextBlock>
<TextBlock FontWeight="Bold" Text="{Binding DisplayValueType, Converter={StaticResource TypeToStringConverter}, Mode=OneWay}" />
<TextBlock FontWeight="Bold">]</TextBlock>
</StackPanel>
<TextBlock Grid.Column="1" Text="{Binding PropertyDescription.Name}" ToolTip.Tip="{Binding PropertyDescription.Description}" />
<TextBlock Grid.Column="2"
Text="{Binding CountDisplay, Mode=OneWay}"
FontFamily="Consolas"
HorizontalAlignment="Right" />
</Grid>
</TreeDataTemplate>
</TreeView.DataTemplates>
</TreeView>
</TreeView>
</Grid>
</UserControl>
@@ -1,18 +1,17 @@
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Debugger.DataModel
{
public class DataModelDebugView : ReactiveUserControl<DataModelDebugViewModel>
{
public DataModelDebugView()
{
InitializeComponent();
}
namespace Artemis.UI.Screens.Debugger.DataModel;
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public class DataModelDebugView : ReactiveUserControl<DataModelDebugViewModel>
{
public DataModelDebugView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
@@ -16,7 +16,7 @@ using ReactiveUI;
namespace Artemis.UI.Screens.Debugger.DataModel;
public class DataModelDebugViewModel : ActivatableViewModelBase, IRoutableViewModel
public class DataModelDebugViewModel : ActivatableViewModelBase
{
private readonly IDataModelUIService _dataModelUIService;
private readonly IPluginManagementService _pluginManagementService;
@@ -28,15 +28,15 @@ public class DataModelDebugViewModel : ActivatableViewModelBase, IRoutableViewMo
private Module? _selectedModule;
private bool _slowUpdates;
public DataModelDebugViewModel(IScreen hostScreen, IDataModelUIService dataModelUIService, IPluginManagementService pluginManagementService)
public DataModelDebugViewModel(IDataModelUIService dataModelUIService, IPluginManagementService pluginManagementService)
{
_dataModelUIService = dataModelUIService;
_pluginManagementService = pluginManagementService;
_updateTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(25), DispatcherPriority.DataBind, (_, _) => Update());
_updateTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(40), DispatcherPriority.Background, (_, _) => Update());
HostScreen = hostScreen;
DisplayName = "Data Model";
Modules = new ObservableCollection<Module>();
this.WhenActivated(disposables =>
{
Observable.FromEventPattern<PluginFeatureEventArgs>(x => pluginManagementService.PluginFeatureEnabled += x, x => pluginManagementService.PluginFeatureEnabled -= x)
@@ -142,7 +142,4 @@ public class DataModelDebugViewModel : ActivatableViewModelBase, IRoutableViewMo
SelectedModule = null;
}
}
public string UrlPathSegment => "data-model";
public IScreen HostScreen { get; }
}
@@ -10,7 +10,7 @@
On this page you can view Artemis's logs in real-time. Logging can come from Artemis itself, plugins and scripts.
</TextBlock>
<TextBlock Margin="0 20 0 0">TODO as there's no FlowDocumentScrollViewer in Avalonia and I'm too lazy to come up with an alternative.</TextBlock>
<TextBlock Classes="subtitle">#feelsbadman</TextBlock>
<TextBlock Margin="0 20 0 0">TODO as there's no FlowDocumentScrollViewer in Avalonia and I'm too lazy to come up with an alternative.</TextBlock>
<TextBlock Classes="subtitle">#feelsbadman</TextBlock>
</StackPanel>
</UserControl>
@@ -1,18 +1,17 @@
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Debugger.Logs
{
public class LogsDebugView : ReactiveUserControl<LogsDebugViewModel>
{
public LogsDebugView()
{
InitializeComponent();
}
namespace Artemis.UI.Screens.Debugger.Logs;
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public class LogsDebugView : ReactiveUserControl<LogsDebugViewModel>
{
public LogsDebugView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
@@ -1,16 +1,11 @@
using Artemis.UI.Shared;
using ReactiveUI;
namespace Artemis.UI.Screens.Debugger.Logs
namespace Artemis.UI.Screens.Debugger.Logs;
public class LogsDebugViewModel : ActivatableViewModelBase
{
public class LogsDebugViewModel : ActivatableViewModelBase, IRoutableViewModel
public LogsDebugViewModel()
{
public LogsDebugViewModel(IScreen hostScreen)
{
HostScreen = hostScreen;
}
public string UrlPathSegment => "logs";
public IScreen HostScreen { get; }
DisplayName = "Logs";
}
}
@@ -1,61 +1,59 @@
using Artemis.Core;
using Artemis.UI.Shared;
using ReactiveUI;
namespace Artemis.UI.Screens.Debugger.Performance
namespace Artemis.UI.Screens.Debugger.Performance;
public class PerformanceDebugMeasurementViewModel : ViewModelBase
{
public class PerformanceDebugMeasurementViewModel : ViewModelBase
private string? _average;
private string? _last;
private string? _max;
private string? _min;
private string? _percentile;
public PerformanceDebugMeasurementViewModel(ProfilingMeasurement measurement)
{
private string? _average;
private string? _last;
private string? _max;
private string? _min;
private string? _percentile;
Measurement = measurement;
}
public PerformanceDebugMeasurementViewModel(ProfilingMeasurement measurement)
{
Measurement = measurement;
}
public ProfilingMeasurement Measurement { get; }
public ProfilingMeasurement Measurement { get; }
public string? Last
{
get => _last;
set => RaiseAndSetIfChanged(ref _last, value);
}
public string? Last
{
get => _last;
set => RaiseAndSetIfChanged(ref _last, value);
}
public string? Average
{
get => _average;
set => RaiseAndSetIfChanged(ref _average, value);
}
public string? Average
{
get => _average;
set => RaiseAndSetIfChanged(ref _average, value);
}
public string? Min
{
get => _min;
set => RaiseAndSetIfChanged(ref _min, value);
}
public string? Min
{
get => _min;
set => RaiseAndSetIfChanged(ref _min, value);
}
public string? Max
{
get => _max;
set => RaiseAndSetIfChanged(ref _max, value);
}
public string? Max
{
get => _max;
set => RaiseAndSetIfChanged(ref _max, value);
}
public string? Percentile
{
get => _percentile;
set => RaiseAndSetIfChanged(ref _percentile, value);
}
public string? Percentile
{
get => _percentile;
set => RaiseAndSetIfChanged(ref _percentile, value);
}
public void Update()
{
Last = Measurement.GetLast().TotalMilliseconds + " ms";
Average = Measurement.GetAverage().TotalMilliseconds + " ms";
Min = Measurement.GetMin().TotalMilliseconds + " ms";
Max = Measurement.GetMax().TotalMilliseconds + " ms";
Percentile = Measurement.GetPercentile(0.95).TotalMilliseconds + " ms";
}
public void Update()
{
Last = Measurement.GetLast().TotalMilliseconds + " ms";
Average = Measurement.GetAverage().TotalMilliseconds + " ms";
Min = Measurement.GetMin().TotalMilliseconds + " ms";
Max = Measurement.GetMax().TotalMilliseconds + " ms";
Percentile = Measurement.GetPercentile(0.95).TotalMilliseconds + " ms";
}
}
@@ -5,14 +5,14 @@
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Debugger.Performance.PerformanceDebugPluginView">
<Border Classes="card-condensed" Margin="0 5">
<Border Classes="card-condensed" Margin="0 5">
<StackPanel>
<Grid ColumnDefinitions="40,*">
<shared:ArtemisIcon Grid.Column="0" Icon="{Binding Plugin.Info.ResolvedIcon}" Width="24" Height="24" />
<TextBlock Grid.Column="1" VerticalAlignment="Center" Classes="h5" Text="{Binding Plugin.Info.Name}" />
</Grid>
<ItemsControl Items="{Binding Profilers}"/>
<ItemsControl Items="{Binding Profilers}" />
</StackPanel>
</Border>
</UserControl>
</UserControl>
@@ -1,18 +1,17 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.Debugger.Performance
{
public partial class PerformanceDebugPluginView : UserControl
{
public PerformanceDebugPluginView()
{
InitializeComponent();
}
namespace Artemis.UI.Screens.Debugger.Performance;
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public class PerformanceDebugPluginView : UserControl
{
public PerformanceDebugPluginView()
{
InitializeComponent();
}
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
@@ -3,29 +3,28 @@ using System.Linq;
using Artemis.Core;
using Artemis.UI.Shared;
namespace Artemis.UI.Screens.Debugger.Performance
namespace Artemis.UI.Screens.Debugger.Performance;
public class PerformanceDebugPluginViewModel : ViewModelBase
{
public class PerformanceDebugPluginViewModel : ViewModelBase
public PerformanceDebugPluginViewModel(Plugin plugin)
{
public PerformanceDebugPluginViewModel(Plugin plugin)
Plugin = plugin;
}
public Plugin Plugin { get; }
public ObservableCollection<PerformanceDebugProfilerViewModel> Profilers { get; } = new();
public void Update()
{
foreach (Profiler pluginProfiler in Plugin.Profilers.Where(p => p.Measurements.Any()))
{
Plugin = plugin;
if (Profilers.All(p => p.Profiler != pluginProfiler))
Profilers.Add(new PerformanceDebugProfilerViewModel(pluginProfiler));
}
public Plugin Plugin { get; }
public ObservableCollection<PerformanceDebugProfilerViewModel> Profilers { get; } = new();
public void Update()
{
foreach (Profiler pluginProfiler in Plugin.Profilers.Where(p => p.Measurements.Any()))
{
if (Profilers.All(p => p.Profiler != pluginProfiler))
Profilers.Add(new PerformanceDebugProfilerViewModel(pluginProfiler));
}
foreach (PerformanceDebugProfilerViewModel profilerViewModel in Profilers)
profilerViewModel.Update();
}
foreach (PerformanceDebugProfilerViewModel profilerViewModel in Profilers)
profilerViewModel.Update();
}
}
@@ -14,7 +14,7 @@
IsReadOnly="True"
AutoGenerateColumns="False"
CanUserReorderColumns="False"
CanUserResizeColumns="False"
CanUserResizeColumns="False"
Margin="10 5 10 10">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Measurement.Identifier}" Header="Identifier" />
@@ -26,4 +26,4 @@
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</UserControl>
</UserControl>
@@ -1,18 +1,17 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Artemis.UI.Screens.Debugger.Performance
{
public partial class PerformanceDebugProfilerView : UserControl
{
public PerformanceDebugProfilerView()
{
InitializeComponent();
}
namespace Artemis.UI.Screens.Debugger.Performance;
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public class PerformanceDebugProfilerView : UserControl
{
public PerformanceDebugProfilerView()
{
InitializeComponent();
}
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
@@ -3,29 +3,28 @@ using System.Linq;
using Artemis.Core;
using Artemis.UI.Shared;
namespace Artemis.UI.Screens.Debugger.Performance
namespace Artemis.UI.Screens.Debugger.Performance;
public class PerformanceDebugProfilerViewModel : ViewModelBase
{
public class PerformanceDebugProfilerViewModel : ViewModelBase
public PerformanceDebugProfilerViewModel(Profiler profiler)
{
public PerformanceDebugProfilerViewModel(Profiler profiler)
Profiler = profiler;
}
public Profiler Profiler { get; }
public ObservableCollection<PerformanceDebugMeasurementViewModel> Measurements { get; } = new();
public void Update()
{
foreach ((string _, ProfilingMeasurement measurement) in Profiler.Measurements)
{
Profiler = profiler;
if (Measurements.All(m => m.Measurement != measurement))
Measurements.Add(new PerformanceDebugMeasurementViewModel(measurement));
}
public Profiler Profiler { get; }
public ObservableCollection<PerformanceDebugMeasurementViewModel> Measurements { get; } = new();
public void Update()
{
foreach ((string _, ProfilingMeasurement measurement) in Profiler.Measurements)
{
if (Measurements.All(m => m.Measurement != measurement))
Measurements.Add(new PerformanceDebugMeasurementViewModel(measurement));
}
foreach (PerformanceDebugMeasurementViewModel profilingMeasurementViewModel in Measurements)
profilingMeasurementViewModel.Update();
}
foreach (PerformanceDebugMeasurementViewModel profilingMeasurementViewModel in Measurements)
profilingMeasurementViewModel.Update();
}
}
@@ -28,12 +28,12 @@
<TextBlock Text="{Binding RenderWidth}" />
<TextBlock Text="x" />
<TextBlock Text="{Binding RenderHeight}" />
<TextBlock Text=" - Renderer: "></TextBlock>
<TextBlock Text="{Binding Renderer}"></TextBlock>
<TextBlock Text=" - Renderer: " />
<TextBlock Text="{Binding Renderer}" />
</StackPanel>
<ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto">
<ScrollViewer Grid.Row="2" VerticalScrollBarVisibility="Auto">
<ItemsControl Items="{Binding Items}" Margin="0 0 10 0" />
</ScrollViewer>
</Grid>
@@ -1,18 +1,17 @@
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Debugger.Performance
{
public class PerformanceDebugView : ReactiveUserControl<PerformanceDebugViewModel>
{
public PerformanceDebugView()
{
InitializeComponent();
}
namespace Artemis.UI.Screens.Debugger.Performance;
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public class PerformanceDebugView : ReactiveUserControl<PerformanceDebugViewModel>
{
public PerformanceDebugView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
@@ -12,7 +12,7 @@ using SkiaSharp;
namespace Artemis.UI.Screens.Debugger.Performance;
public class PerformanceDebugViewModel : ActivatableViewModelBase, IRoutableViewModel
public class PerformanceDebugViewModel : ActivatableViewModelBase
{
private readonly ICoreService _coreService;
private readonly IPluginManagementService _pluginManagementService;
@@ -22,13 +22,14 @@ public class PerformanceDebugViewModel : ActivatableViewModelBase, IRoutableView
private int _renderHeight;
private int _renderWidth;
public PerformanceDebugViewModel(IScreen hostScreen, ICoreService coreService, IPluginManagementService pluginManagementService)
public PerformanceDebugViewModel(ICoreService coreService, IPluginManagementService pluginManagementService)
{
HostScreen = hostScreen;
_coreService = coreService;
_pluginManagementService = pluginManagementService;
_updateTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(500), DispatcherPriority.Normal, (_, _) => Update());
DisplayName = "Performance";
this.WhenActivated(disposables =>
{
Observable.FromEventPattern<PluginFeatureEventArgs>(x => pluginManagementService.PluginFeatureEnabled += x, x => pluginManagementService.PluginFeatureEnabled -= x)
@@ -123,8 +124,4 @@ public class PerformanceDebugViewModel : ActivatableViewModelBase, IRoutableView
RenderHeight = bitmapInfo.Height;
RenderWidth = bitmapInfo.Width;
}
public string UrlPathSegment => "performance";
public IScreen HostScreen { get; }
}
@@ -20,25 +20,25 @@
<TextBlock Text="{Binding RenderWidth}" />
<TextBlock Text="x" />
<TextBlock Text="{Binding RenderHeight}" />
<TextBlock Text=" - Renderer: "></TextBlock>
<TextBlock Text="{Binding Renderer}"></TextBlock>
<TextBlock Text=" - Renderer: " />
<TextBlock Text="{Binding Renderer}" />
</StackPanel>
<Border Classes="card" Padding="10">
<ZoomBorder Name="ZoomBorder"
Stretch="None"
ClipToBounds="True"
Focusable="True"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Image Name="Visualization" Source="{Binding CurrentFrame}">
<Image.Transitions>
<Transitions>
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.2" Easing="CubicEaseOut"/>
</Transitions>
</Image.Transitions>
</Image>
</ZoomBorder>
<ZoomBorder Name="ZoomBorder"
Stretch="None"
ClipToBounds="True"
Focusable="True"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch">
<Image Name="Visualization" Source="{Binding CurrentFrame}">
<Image.Transitions>
<Transitions>
<TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.2" Easing="CubicEaseOut" />
</Transitions>
</Image.Transitions>
</Image>
</ZoomBorder>
</Border>
</StackPanel>
</UserControl>
@@ -1,18 +1,17 @@
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Debugger.Render
{
public class RenderDebugView : ReactiveUserControl<RenderDebugViewModel>
{
public RenderDebugView()
{
InitializeComponent();
}
namespace Artemis.UI.Screens.Debugger.Render;
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public class RenderDebugView : ReactiveUserControl<RenderDebugViewModel>
{
public RenderDebugView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
@@ -7,102 +7,99 @@ using Avalonia.Media.Imaging;
using ReactiveUI;
using SkiaSharp;
namespace Artemis.UI.Screens.Debugger.Render
namespace Artemis.UI.Screens.Debugger.Render;
public class RenderDebugViewModel : ActivatableViewModelBase
{
public class RenderDebugViewModel : ActivatableViewModelBase, IRoutableViewModel
private readonly ICoreService _coreService;
private double _currentFps;
private Bitmap? _currentFrame;
private string? _frameTargetPath;
private string? _renderer;
private int _renderHeight;
private int _renderWidth;
public RenderDebugViewModel(ICoreService coreService)
{
private readonly ICoreService _coreService;
private double _currentFps;
_coreService = coreService;
private Bitmap? _currentFrame;
private string? _frameTargetPath;
private string? _renderer;
private int _renderHeight;
private int _renderWidth;
DisplayName = "Rendering";
public RenderDebugViewModel(DebugViewModel hostScreen, ICoreService coreService)
this.WhenActivated(disposables =>
{
HostScreen = hostScreen;
_coreService = coreService;
HandleActivation();
Disposable.Create(HandleDeactivation).DisposeWith(disposables);
});
}
this.WhenActivated(disposables =>
{
HandleActivation();
Disposable.Create(HandleDeactivation).DisposeWith(disposables);
});
}
public Bitmap? CurrentFrame
{
get => _currentFrame;
set => RaiseAndSetIfChanged(ref _currentFrame, value);
}
public Bitmap? CurrentFrame
public double CurrentFps
{
get => _currentFps;
set => RaiseAndSetIfChanged(ref _currentFps, value);
}
public int RenderWidth
{
get => _renderWidth;
set => RaiseAndSetIfChanged(ref _renderWidth, value);
}
public int RenderHeight
{
get => _renderHeight;
set => RaiseAndSetIfChanged(ref _renderHeight, value);
}
public string? Renderer
{
get => _renderer;
set => RaiseAndSetIfChanged(ref _renderer, value);
}
private void HandleActivation()
{
Renderer = Constants.ManagedGraphicsContext != null ? Constants.ManagedGraphicsContext.GetType().Name : "Software";
_coreService.FrameRendered += CoreServiceOnFrameRendered;
}
private void HandleDeactivation()
{
_coreService.FrameRendered -= CoreServiceOnFrameRendered;
}
private void CoreServiceOnFrameRendered(object? sender, FrameRenderedEventArgs e)
{
CurrentFps = _coreService.FrameRate;
using SKImage skImage = e.Texture.Surface.Snapshot();
SKImageInfo bitmapInfo = e.Texture.ImageInfo;
if (_frameTargetPath != null)
{
get => _currentFrame;
set => RaiseAndSetIfChanged(ref _currentFrame, value);
}
public double CurrentFps
{
get => _currentFps;
set => RaiseAndSetIfChanged(ref _currentFps, value);
}
public int RenderWidth
{
get => _renderWidth;
set => RaiseAndSetIfChanged(ref _renderWidth, value);
}
public int RenderHeight
{
get => _renderHeight;
set => RaiseAndSetIfChanged(ref _renderHeight, value);
}
public string? Renderer
{
get => _renderer;
set => RaiseAndSetIfChanged(ref _renderer, value);
}
private void HandleActivation()
{
Renderer = Constants.ManagedGraphicsContext != null ? Constants.ManagedGraphicsContext.GetType().Name : "Software";
_coreService.FrameRendered += CoreServiceOnFrameRendered;
}
private void HandleDeactivation()
{
_coreService.FrameRendered -= CoreServiceOnFrameRendered;
}
private void CoreServiceOnFrameRendered(object? sender, FrameRenderedEventArgs e)
{
CurrentFps = _coreService.FrameRate;
using SKImage skImage = e.Texture.Surface.Snapshot();
SKImageInfo bitmapInfo = e.Texture.ImageInfo;
if (_frameTargetPath != null)
{
using (SKData data = skImage.Encode(SKEncodedImageFormat.Png, 100))
{
using (FileStream stream = File.OpenWrite(_frameTargetPath))
{
data.SaveTo(stream);
}
}
_frameTargetPath = null;
}
RenderHeight = bitmapInfo.Height;
RenderWidth = bitmapInfo.Width;
// TODO: This performs well enough but look into something else
using (SKData data = skImage.Encode(SKEncodedImageFormat.Png, 100))
{
CurrentFrame = new Bitmap(data.AsStream());
using (FileStream stream = File.OpenWrite(_frameTargetPath))
{
data.SaveTo(stream);
}
}
_frameTargetPath = null;
}
public string UrlPathSegment => "render";
public IScreen HostScreen { get; }
RenderHeight = bitmapInfo.Height;
RenderWidth = bitmapInfo.Width;
// TODO: This performs well enough but look into something else
using (SKData data = skImage.Encode(SKEncodedImageFormat.Png, 100))
{
CurrentFrame = new Bitmap(data.AsStream());
}
}
}
@@ -1,18 +1,17 @@
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Screens.Debugger.Settings
{
public class DebugSettingsView : ReactiveUserControl<DebugSettingsViewModel>
{
public DebugSettingsView()
{
InitializeComponent();
}
namespace Artemis.UI.Screens.Debugger.Settings;
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
public class DebugSettingsView : ReactiveUserControl<DebugSettingsViewModel>
{
public DebugSettingsView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
@@ -1,16 +1,11 @@
using Artemis.UI.Shared;
using ReactiveUI;
namespace Artemis.UI.Screens.Debugger.Settings
namespace Artemis.UI.Screens.Debugger.Settings;
public class DebugSettingsViewModel : ActivatableViewModelBase
{
public class DebugSettingsViewModel : ActivatableViewModelBase, IRoutableViewModel
public DebugSettingsViewModel()
{
public DebugSettingsViewModel(IScreen hostScreen)
{
HostScreen = hostScreen;
}
public string UrlPathSegment => "logs";
public IScreen HostScreen { get; }
DisplayName = "Settings";
}
}