Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove analytics service from WinUI sample app #840

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions samples/ComputeSharp.SwapChain.WinUI/Constants/Error.cs

This file was deleted.

16 changes: 0 additions & 16 deletions samples/ComputeSharp.SwapChain.WinUI/Constants/Event.cs

This file was deleted.

This file was deleted.

23 changes: 0 additions & 23 deletions samples/ComputeSharp.SwapChain.WinUI/Services/IAnalyticsService.cs

This file was deleted.

49 changes: 1 addition & 48 deletions samples/ComputeSharp.SwapChain.WinUI/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System.Collections.Generic;
using CommunityToolkit.Diagnostics;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using ComputeSharp.SwapChain.Core.Constants;
using ComputeSharp.SwapChain.Core.Enums;
using ComputeSharp.SwapChain.Core.Services;
using ComputeSharp.SwapChain.Core.Shaders;
using ComputeSharp.SwapChain.Core.Shaders.Runners;
using ComputeSharp.SwapChain.Shaders;
Expand All @@ -17,19 +14,11 @@ namespace ComputeSharp.SwapChain.Core.ViewModels;
/// </summary>
public sealed partial 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(IAnalyticsService analyticsService)
public MainViewModel()
{
Guard.IsNotNull(analyticsService);

this.analyticsService = analyticsService;
this.selectedRenderingMode = RenderingMode.DirectX12;
this.isVerticalSyncEnabled = true;
this.isDynamicResolutionEnabled = true;
Expand Down Expand Up @@ -157,46 +146,10 @@ private void ToggleRenderingPaused()
IsRenderingPaused = !IsRenderingPaused;
}

/// <inheritdoc/>
partial void OnSelectedRenderingModeChanged(RenderingMode value)
{
this.analyticsService.Log(Event.SelectedRenderingModeChanged, (nameof(value), value));
}

/// <inheritdoc/>
partial void OnIsVerticalSyncEnabledChanged(bool value)
{
this.analyticsService.Log(Event.IsVerticalSyncEnabledChanged, (nameof(value), value));
}

/// <inheritdoc/>
partial void OnIsDynamicResolutionEnabledChanged(bool value)
{
this.analyticsService.Log(Event.IsDynamicResolutionEnabledChanged, (nameof(value), value));
}

/// <inheritdoc/>
partial void OnSelectedResolutionScaleChanged(int value)
{
this.analyticsService.Log(Event.SelectedResolutionScaleChanged, (nameof(value), value));
}

/// <inheritdoc/>
partial void OnSelectedComputeShaderChanging(ShaderRunnerViewModel? oldValue, ShaderRunnerViewModel newValue)
{
oldValue!.IsSelected = false;
newValue.IsSelected = true;
}

/// <inheritdoc/>
partial void OnSelectedComputeShaderChanged(ShaderRunnerViewModel value)
{
this.analyticsService.Log(Event.SelectedComputeShaderChanged, (nameof(value.ShaderType), value.ShaderType));
}

/// <inheritdoc/>
partial void OnIsRenderingPausedChanged(bool value)
{
this.analyticsService.Log(Event.IsRenderingPausedChanged, (nameof(value), value));
}
}
7 changes: 5 additions & 2 deletions samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
xmlns:enums="using:ComputeSharp.SwapChain.Core.Enums"
xmlns:media="using:CommunityToolkit.WinUI.UI.Media"
xmlns:ui="using:CommunityToolkit.WinUI.UI"
xmlns:viewmodels="using:ComputeSharp.SwapChain.Core.ViewModels"
xmlns:viewModels="using:ComputeSharp.SwapChain.Core.ViewModels"
xmlns:views="using:ComputeSharp.SwapChain.WinUI.Views"
SizeChanged="Window_SizeChanged">

<Grid x:Name="Root">
<Grid.DataContext>
<viewModels:MainViewModel x:Name="ViewModel"/>
</Grid.DataContext>
<Grid.Resources>

<!--
Expand Down Expand Up @@ -109,7 +112,7 @@
<ListView.ItemTemplate>

<!-- Shader template -->
<DataTemplate x:DataType="viewmodels:ShaderRunnerViewModel">
<DataTemplate x:DataType="viewModels:ShaderRunnerViewModel">
<controls:ConstrainedBox
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Expand Down
8 changes: 0 additions & 8 deletions samples/ComputeSharp.SwapChain.WinUI/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Runtime.CompilerServices;
using ComputeSharp.SwapChain.Core.Services;
using ComputeSharp.SwapChain.Core.ViewModels;
using ComputeSharp.WinUI;
using Microsoft.UI.Xaml;
Expand All @@ -25,15 +24,8 @@ public MainWindow()
ExtendsContentIntoTitleBar = true;

SetTitleBar(this.TitleBarRectangle);

this.Root.DataContext = new MainViewModel(new DebugAnalyticsService());
}

/// <summary>
/// Gets the <see cref="MainViewModel"/> instance for the current view.
/// </summary>
public MainViewModel ViewModel => (MainViewModel)this.Root.DataContext;

/// <summary>
/// Stops all rendering when the application is closing.
/// </summary>
Expand Down