Add analytics service base setup to UWP sample app

このコミットが含まれているのは:
Sergio Pedri committed 2022-01-05 20:49:38 +01:00
1 親 1477e50c01
コミット c8d597018a
11ファイル変更
+198 -17

検索条件に一致するファイルはありません

+21 -11
ファイルの表示
@@ -2,6 +2,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using ComputeSharp.SwapChain.Core.Models;
using ComputeSharp.SwapChain.Core.Services;
using ComputeSharp.SwapChain.Core.Shaders.Runners;
using ComputeSharp.SwapChain.Shaders;
#if WINDOWS_UWP
@@ -9,6 +10,7 @@ using ComputeSharp.Uwp;
#else
using ComputeSharp.WinUI;
#endif
using Microsoft.Toolkit.Diagnostics;
#nullable enable
@@ -19,11 +21,19 @@ namespace ComputeSharp.SwapChain.Core.ViewModels;
/// </summary>
public sealed class MainViewModel : ObservableObject
{
/// <summary>
/// The <see cref="IAnalyticsService"/> instance currently in use.
/// </summary>
private readonly IAnalyticsService analyticsService;
/// <summary>
/// Creates a new <see cref="MainViewModel"/> instance.
/// </summary>
public MainViewModel()
public MainViewModel(IAnalyticsService analyticsService)
{
Guard.IsNotNull(analyticsService, nameof(analyticsService));
this.analyticsService = analyticsService;
this.isDynamicResolutionEnabled = true;
this.selectedResolutionScale = 100;
this.selectedComputeShader = ComputeShaderOptions[0];
@@ -78,16 +88,16 @@ public sealed class MainViewModel : ObservableObject
/// </summary>
public IReadOnlyList<ComputeShader> ComputeShaderOptions { get; } = new ComputeShader[]
{
new("Colorful infinity", new ShaderRunner<ColorfulInfinity>(static time => new((float)time.TotalSeconds))),
new("Extruded truchet", new ShaderRunner<ExtrudedTruchetPattern>(static time => new((float)time.TotalSeconds))),
new("Fractal tiling", new ShaderRunner<FractalTiling>(static time => new((float)time.TotalSeconds))),
new("Menger Journey", new ShaderRunner<MengerJourney>(static time => new((float)time.TotalSeconds))),
new("Octagrams", new ShaderRunner<Octagrams>(static time => new((float)time.TotalSeconds))),
new("Protean clouds", new ShaderRunner<ProteanClouds>(static time => new((float)time.TotalSeconds))),
new("Two tiled truchet", new ShaderRunner<TwoTiledTruchet>(static time => new((float)time.TotalSeconds))),
new("Pyramid pattern", new ShaderRunner<PyramidPattern>(static time => new((float)time.TotalSeconds))),
new("Triangle grid contouring", new ShaderRunner<TriangleGridContouring>(static time => new((float)time.TotalSeconds))),
new("Contoured layers", new ContouredLayersRunner())
new("Colorful infinity", new ShaderRunner<ColorfulInfinity>(static time => new((float)time.TotalSeconds))),
new("Extruded truchet", new ShaderRunner<ExtrudedTruchetPattern>(static time => new((float)time.TotalSeconds))),
new("Fractal tiling", new ShaderRunner<FractalTiling>(static time => new((float)time.TotalSeconds))),
new("Menger Journey", new ShaderRunner<MengerJourney>(static time => new((float)time.TotalSeconds))),
new("Octagrams", new ShaderRunner<Octagrams>(static time => new((float)time.TotalSeconds))),
new("Protean clouds", new ShaderRunner<ProteanClouds>(static time => new((float)time.TotalSeconds))),
new("Two tiled truchet", new ShaderRunner<TwoTiledTruchet>(static time => new((float)time.TotalSeconds))),
new("Pyramid pattern", new ShaderRunner<PyramidPattern>(static time => new((float)time.TotalSeconds))),
new("Triangle grid contouring", new ShaderRunner<TriangleGridContouring>(static time => new((float)time.TotalSeconds))),
new("Contoured layers", new ContouredLayersRunner())
};
private ComputeShader selectedComputeShader;