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

Add missing debugger folder

Moved device VMs
This commit is contained in:
Robert 2021-11-06 21:54:44 +01:00
parent 87117cc110
commit 8ebd098186
33 changed files with 462 additions and 27 deletions

View File

@ -35,6 +35,18 @@
<Compile Update="MainWindow.axaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<Compile Update="Screens\Device\Tabs\Views\DeviceInfoTabView.axaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<Compile Update="Screens\Device\Tabs\Views\DeviceLedsTabView.axaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<Compile Update="Screens\Device\Tabs\Views\DevicePropertiesTabView.axaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<Compile Update="Screens\Device\Tabs\Views\InputMappingsTabView.axaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<Compile Update="Screens\Root\Views\SidebarCategoryView.axaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>

View File

@ -1,6 +1,7 @@
using System.Collections.ObjectModel;
using Artemis.Core;
using Artemis.UI.Avalonia.Screens.Device.ViewModels;
using Artemis.UI.Avalonia.Screens.Device;
using Artemis.UI.Avalonia.Screens.Device.Tabs.ViewModels;
using Artemis.UI.Avalonia.Screens.Root.ViewModels;
using Artemis.UI.Avalonia.Screens.SurfaceEditor.ViewModels;
using ReactiveUI;

View File

@ -0,0 +1,26 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="800"
x:Class="Artemis.UI.Avalonia.Screens.Debugger.DebugView"
Title="Artemis | Debugger"
Width="1200"
Height="800"
ExtendClientAreaToDecorationsHint="True">
<Grid RowDefinitions="Auto,*" ColumnDefinitions="Auto,*">
<TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=Title}"
IsHitTestVisible="False"
Margin="10" />
<Border Grid.Row="1" Grid.Column="0">
<TextBlock>Test</TextBlock>
</Border>
<Border Grid.Row="1" Grid.Column="1">
<TextBlock>Test</TextBlock>
</Border>
</Grid>
</Window>

View File

@ -0,0 +1,53 @@
using System;
using System.Reactive.Disposables;
using Artemis.UI.Avalonia.Shared.Events;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
using FluentAvalonia.Core;
using FluentAvalonia.UI.Controls;
using ReactiveUI;
namespace Artemis.UI.Avalonia.Screens.Debugger
{
public class DebugView : ReactiveWindow<DebugViewModel>
{
private readonly NavigationView _navigation;
public DebugView()
{
Activated += OnActivated;
Deactivated += OnDeactivated;
InitializeComponent();
_navigation = this.Get<NavigationView>("Navigation");
this.WhenActivated(d =>
{
ViewModel!.WhenAnyValue(vm => vm!.IsActive).Subscribe(_ => Activate()).DisposeWith(d);
ViewModel!.SelectedItem = (NavigationViewItem) _navigation.MenuItems.ElementAt(0);
});
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private void OnDeactivated(object? sender, EventArgs e)
{
if (ViewModel != null)
ViewModel.IsActive = false;
}
private void OnActivated(object? sender, EventArgs e)
{
if (ViewModel != null)
ViewModel.IsActive = true;
}
private void DeviceVisualizer_OnLedClicked(object? sender, LedClickedEventArgs e)
{
}
}
}

View File

@ -0,0 +1,76 @@
using System;
using System.Reactive.Disposables;
using Artemis.UI.Avalonia.Screens.Debugger.Tabs.DataModel;
using Artemis.UI.Avalonia.Screens.Debugger.Tabs.Logs;
using Artemis.UI.Avalonia.Screens.Debugger.Tabs.Performance;
using Artemis.UI.Avalonia.Screens.Debugger.Tabs.Render;
using Artemis.UI.Avalonia.Services.Interfaces;
using FluentAvalonia.UI.Controls;
using Ninject;
using Ninject.Parameters;
using ReactiveUI;
namespace Artemis.UI.Avalonia.Screens.Debugger
{
public class DebugViewModel : ActivatableViewModelBase, IScreen
{
private readonly IKernel _kernel;
private readonly IDebugService _debugService;
private bool _isActive;
private NavigationViewItem? _selectedItem;
public DebugViewModel(IKernel kernel, IDebugService debugService)
{
_kernel = kernel;
_debugService = debugService;
this.WhenAnyValue(x => x.SelectedItem).WhereNotNull().Subscribe(NavigateToSelectedItem);
this.WhenActivated(disposables =>
{
Disposable
.Create(HandleDeactivation)
.DisposeWith(disposables);
});
}
public bool IsActive
{
get => _isActive;
set => this.RaiseAndSetIfChanged(ref _isActive, value);
}
public NavigationViewItem? SelectedItem
{
get => _selectedItem;
set => this.RaiseAndSetIfChanged(ref _selectedItem, value);
}
private void NavigateToSelectedItem(NavigationViewItem item)
{
// Kind of a lame way to do this but it's so static idc
ConstructorArgument hostScreen = new("hostScreen", this);
switch ((string) item.Content)
{
case "Rendering":
Router.Navigate.Execute(_kernel.Get<RenderDebugViewModel>(hostScreen));
break;
case "Logs":
Router.Navigate.Execute(_kernel.Get<LogsDebugViewModel>(hostScreen));
break;
case "Data Model":
Router.Navigate.Execute(_kernel.Get<DataModelDebugViewModel>(hostScreen));
break;
case "Performance":
Router.Navigate.Execute(_kernel.Get<PerformanceDebugViewModel>(hostScreen));
break;
}
}
private void HandleDeactivation()
{
_debugService.ClearDebugger();
}
public RoutingState Router { get; } = new();
}
}

View File

@ -0,0 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Avalonia.Screens.Debugger.Tabs.DataModel.DataModelDebugView">
<TextBlock>Data Model</TextBlock>
</UserControl>

View File

@ -0,0 +1,18 @@
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Avalonia.Screens.Debugger.Tabs.DataModel
{
public class DataModelDebugView : ReactiveUserControl<DataModelDebugViewModel>
{
public DataModelDebugView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

View File

@ -0,0 +1,15 @@
using ReactiveUI;
namespace Artemis.UI.Avalonia.Screens.Debugger.Tabs.DataModel
{
public class DataModelDebugViewModel : ActivatableViewModelBase, IRoutableViewModel
{
public DataModelDebugViewModel(IScreen hostScreen)
{
HostScreen = hostScreen;
}
public string UrlPathSegment => "data-model";
public IScreen HostScreen { get; }
}
}

View File

@ -0,0 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Avalonia.Screens.Debugger.Tabs.Logs.LogsDebugView">
<TextBlock>Logs</TextBlock>
</UserControl>

View File

@ -0,0 +1,18 @@
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Avalonia.Screens.Debugger.Tabs.Logs
{
public class LogsDebugView : ReactiveUserControl<LogsDebugViewModel>
{
public LogsDebugView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

View File

@ -0,0 +1,15 @@
using ReactiveUI;
namespace Artemis.UI.Avalonia.Screens.Debugger.Tabs.Logs
{
public class LogsDebugViewModel : ActivatableViewModelBase, IRoutableViewModel
{
public LogsDebugViewModel(IScreen hostScreen)
{
HostScreen = hostScreen;
}
public string UrlPathSegment => "logs";
public IScreen HostScreen { get; }
}
}

View File

@ -0,0 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Avalonia.Screens.Debugger.Tabs.Performance.PerformanceDebugView">
<TextBlock>Performance</TextBlock>
</UserControl>

View File

@ -0,0 +1,18 @@
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Avalonia.Screens.Debugger.Tabs.Performance
{
public class PerformanceDebugView : ReactiveUserControl<PerformanceDebugViewModel>
{
public PerformanceDebugView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

View File

@ -0,0 +1,15 @@
using ReactiveUI;
namespace Artemis.UI.Avalonia.Screens.Debugger.Tabs.Performance
{
public class PerformanceDebugViewModel : ActivatableViewModelBase, IRoutableViewModel
{
public PerformanceDebugViewModel(IScreen hostScreen)
{
HostScreen = hostScreen;
}
public string UrlPathSegment => "performance";
public IScreen HostScreen { get; }
}
}

View File

@ -0,0 +1,16 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Avalonia.Screens.Debugger.Tabs.Render.RenderDebugView">
<Grid Margin="12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock>Render</TextBlock>
<Image Source="{Binding CurrentFrame}" Grid.Row="1"></Image>
</Grid>
</UserControl>

View File

@ -0,0 +1,18 @@
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Avalonia.Screens.Debugger.Tabs.Render
{
public class RenderDebugView : ReactiveUserControl<RenderDebugViewModel>
{
public RenderDebugView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
}

View File

@ -0,0 +1,118 @@
using System.IO;
using System.Reactive.Disposables;
using System.Timers;
using Artemis.Core;
using Artemis.Core.Services;
using ReactiveUI;
using SkiaSharp;
namespace Artemis.UI.Avalonia.Screens.Debugger.Tabs.Render
{
public class RenderDebugViewModel : ActivatableViewModelBase, IRoutableViewModel
{
private readonly ICoreService _coreService;
private readonly Timer _fpsTimer;
private double _currentFps;
private SKImage? _currentFrame;
private int _frames;
private string? _frameTargetPath;
private string _renderer;
private int _renderHeight;
private int _renderWidth;
public RenderDebugViewModel(DebugViewModel hostScreen, ICoreService coreService)
{
HostScreen = hostScreen;
_coreService = coreService;
_fpsTimer = new Timer(1000);
_fpsTimer.Start();
this.WhenActivated(disposables =>
{
HandleActivation();
Disposable.Create(HandleDeactivation).DisposeWith(disposables);
});
}
public SKImage? CurrentFrame
{
get => _currentFrame;
set => this.RaiseAndSetIfChanged(ref _currentFrame, value);
}
public double CurrentFps
{
get => _currentFps;
set => this.RaiseAndSetIfChanged(ref _currentFps, value);
}
public int RenderWidth
{
get => _renderWidth;
set => this.RaiseAndSetIfChanged(ref _renderWidth, value);
}
public int RenderHeight
{
get => _renderHeight;
set => this.RaiseAndSetIfChanged(ref _renderHeight, value);
}
public string Renderer
{
get => _renderer;
set => this.RaiseAndSetIfChanged(ref _renderer, value);
}
private void HandleActivation()
{
_coreService.FrameRendered += CoreServiceOnFrameRendered;
_fpsTimer.Elapsed += FpsTimerOnElapsed;
}
private void HandleDeactivation()
{
_coreService.FrameRendered -= CoreServiceOnFrameRendered;
_fpsTimer.Elapsed -= FpsTimerOnElapsed;
_fpsTimer.Dispose();
}
private void CoreServiceOnFrameRendered(object? sender, FrameRenderedEventArgs e)
{
_frames++;
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;
CurrentFrame = e.Texture.Surface.Snapshot();
}
private void FpsTimerOnElapsed(object sender, ElapsedEventArgs e)
{
CurrentFps = _frames;
Renderer = Constants.ManagedGraphicsContext != null ? Constants.ManagedGraphicsContext.GetType().Name : "Software";
_frames = 0;
}
public string UrlPathSegment => "render";
public IScreen HostScreen { get; }
}
}

View File

@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:Artemis.UI.Avalonia.Shared.Controls;assembly=Artemis.UI.Avalonia.Shared"
mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="800"
x:Class="Artemis.UI.Avalonia.Screens.Device.Views.DevicePropertiesView"
x:Class="Artemis.UI.Avalonia.Screens.Device.DevicePropertiesView"
Title="Artemis | Device Properties"
Width="1250"
Height="900"

View File

@ -1,10 +1,8 @@
using Artemis.UI.Avalonia.Screens.Device.ViewModels;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Avalonia.Screens.Device.Views
namespace Artemis.UI.Avalonia.Screens.Device
{
public partial class DevicePropertiesView : ReactiveWindow<DevicePropertiesViewModel>
{

View File

@ -4,7 +4,7 @@ using Artemis.UI.Avalonia.Ninject.Factories;
using RGB.NET.Core;
using ArtemisLed = Artemis.Core.ArtemisLed;
namespace Artemis.UI.Avalonia.Screens.Device.ViewModels
namespace Artemis.UI.Avalonia.Screens.Device
{
public class DevicePropertiesViewModel : ActivatableViewModelBase
{

View File

@ -3,7 +3,7 @@ using Artemis.Core;
using Avalonia;
using RGB.NET.Core;
namespace Artemis.UI.Avalonia.Screens.Device.ViewModels
namespace Artemis.UI.Avalonia.Screens.Device.Tabs.ViewModels
{
public class DeviceInfoTabViewModel : ActivatableViewModelBase
{

View File

@ -7,7 +7,7 @@ using Artemis.Core;
using DynamicData.Binding;
using ReactiveUI;
namespace Artemis.UI.Avalonia.Screens.Device.ViewModels
namespace Artemis.UI.Avalonia.Screens.Device.Tabs.ViewModels
{
public class DeviceLedsTabViewModel : ActivatableViewModelBase
{

View File

@ -9,7 +9,7 @@ using Artemis.UI.Avalonia.Shared.Services.Interfaces;
using ReactiveUI;
using SkiaSharp;
namespace Artemis.UI.Avalonia.Screens.Device.ViewModels
namespace Artemis.UI.Avalonia.Screens.Device.Tabs.ViewModels
{
public class DevicePropertiesTabViewModel : ActivatableViewModelBase
{

View File

@ -8,7 +8,7 @@ using Artemis.UI.Avalonia.Exceptions;
using ReactiveUI;
using RGB.NET.Core;
namespace Artemis.UI.Avalonia.Screens.Device.ViewModels
namespace Artemis.UI.Avalonia.Screens.Device.Tabs.ViewModels
{
public class InputMappingsTabViewModel : ActivatableViewModelBase
{

View File

@ -3,6 +3,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Avalonia.Screens.Device.Views.DeviceInfoTabView">
x:Class="Artemis.UI.Avalonia.Screens.Device.Tabs.Views.DeviceInfoTabView">
Welcome to Avalonia!
</UserControl>

View File

@ -1,8 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Artemis.UI.Avalonia.Screens.Device.Views
namespace Artemis.UI.Avalonia.Screens.Device.Tabs.Views
{
public partial class DeviceInfoTabView : UserControl
{

View File

@ -3,6 +3,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Avalonia.Screens.Device.Views.DeviceLedsTabView">
x:Class="Artemis.UI.Avalonia.Screens.Device.Tabs.Views.DeviceLedsTabView">
Welcome to Avalonia!
</UserControl>

View File

@ -1,8 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Artemis.UI.Avalonia.Screens.Device.Views
namespace Artemis.UI.Avalonia.Screens.Device.Tabs.Views
{
public partial class DeviceLedsTabView : UserControl
{

View File

@ -4,10 +4,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:viewModels="clr-namespace:Artemis.UI.Avalonia.Screens.Device.ViewModels"
xmlns:converters="clr-namespace:Artemis.UI.Avalonia.Shared.Converters;assembly=Artemis.UI.Avalonia.Shared"
xmlns:viewModels="clr-namespace:Artemis.UI.Avalonia.Screens.Device.Tabs.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="1200"
x:Class="Artemis.UI.Avalonia.Screens.Device.Views.DevicePropertiesTabView">
x:Class="Artemis.UI.Avalonia.Screens.Device.Tabs.Views.DevicePropertiesTabView">
<UserControl.Resources>
<converters:SKColorToColorConverter x:Key="SKColorToColorConverter" />
</UserControl.Resources>

View File

@ -1,12 +1,9 @@
using System.Threading.Tasks;
using Artemis.UI.Avalonia.Screens.Device.ViewModels;
using Avalonia;
using Avalonia.Controls;
using Artemis.UI.Avalonia.Screens.Device.Tabs.ViewModels;
using Avalonia.Input;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
namespace Artemis.UI.Avalonia.Screens.Device.Views
namespace Artemis.UI.Avalonia.Screens.Device.Tabs.Views
{
public partial class DevicePropertiesTabView : ReactiveUserControl<DevicePropertiesTabViewModel>
{

View File

@ -3,6 +3,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Avalonia.Screens.Device.Views.InputMappingsTabView">
x:Class="Artemis.UI.Avalonia.Screens.Device.Tabs.Views.InputMappingsTabView">
Welcome to Avalonia!
</UserControl>

View File

@ -1,8 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace Artemis.UI.Avalonia.Screens.Device.Views
namespace Artemis.UI.Avalonia.Screens.Device.Tabs.Views
{
public partial class InputMappingsTabView : UserControl
{

View File

@ -1,4 +1,4 @@
using Artemis.UI.Avalonia.Screens.Debug;
using Artemis.UI.Avalonia.Screens.Debugger;
using Artemis.UI.Avalonia.Services.Interfaces;
using Artemis.UI.Avalonia.Shared.Services.Interfaces;