Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Move QuietBackgroundProcesses UI to Windows customization #2511

Merged
merged 1 commit into from
Apr 3, 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
19 changes: 0 additions & 19 deletions DevHome.sln
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DevHome.QuietBackgroundProc
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DevHome.QuietBackgroundProcesses.Common", "tools\QuietBackgroundProcesses\DevHome.QuietBackgroundProcesses.Common\DevHome.QuietBackgroundProcesses.Common.vcxproj", "{4B370E2F-FB1D-4887-90BF-3B72517485CE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.QuietBackgroundProcesses.UI", "tools\QuietBackgroundProcesses\DevHome.QuietBackgroundProcesses.UI\DevHome.QuietBackgroundProcesses.UI.csproj", "{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{DCAF188B-60C3-4EDB-8049-BAA927FBCD7D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SampleTool", "SampleTool", "{E7C94F61-D6CF-464D-8D50-210488AF7A50}"
Expand Down Expand Up @@ -518,22 +516,6 @@ Global
{4B370E2F-FB1D-4887-90BF-3B72517485CE}.Release|x64.Build.0 = Release|x64
{4B370E2F-FB1D-4887-90BF-3B72517485CE}.Release|x86.ActiveCfg = Release|Win32
{4B370E2F-FB1D-4887-90BF-3B72517485CE}.Release|x86.Build.0 = Release|Win32
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Debug|Any CPU.ActiveCfg = Debug|x64
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Debug|Any CPU.Build.0 = Debug|x64
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Debug|arm64.ActiveCfg = Debug|arm64
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Debug|arm64.Build.0 = Debug|arm64
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Debug|x64.ActiveCfg = Debug|x64
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Debug|x64.Build.0 = Debug|x64
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Debug|x86.ActiveCfg = Debug|x86
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Debug|x86.Build.0 = Debug|x86
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Release|Any CPU.ActiveCfg = Release|x64
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Release|Any CPU.Build.0 = Release|x64
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Release|arm64.ActiveCfg = Release|arm64
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Release|arm64.Build.0 = Release|arm64
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Release|x64.ActiveCfg = Release|x64
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Release|x64.Build.0 = Release|x64
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Release|x86.ActiveCfg = Release|x86
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE}.Release|x86.Build.0 = Release|x86
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Debug|Any CPU.ActiveCfg = Debug|x64
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Debug|Any CPU.Build.0 = Debug|x64
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Debug|arm64.ActiveCfg = Debug|ARM64
Expand Down Expand Up @@ -785,7 +767,6 @@ Global
{092AC740-DA01-4872-8E93-B9557DAD6BE5} = {D04CD3A1-0B45-4CB3-925F-204F5F6AE2D8}
{80805B43-CE75-4C6E-92F8-F385C1039E53} = {D04CD3A1-0B45-4CB3-925F-204F5F6AE2D8}
{4B370E2F-FB1D-4887-90BF-3B72517485CE} = {D04CD3A1-0B45-4CB3-925F-204F5F6AE2D8}
{1477F3EA-A9F6-4B4F-82F4-C2427F57EBEE} = {D04CD3A1-0B45-4CB3-925F-204F5F6AE2D8}
{E7C94F61-D6CF-464D-8D50-210488AF7A50} = {A972EC5B-FC61-4964-A6FF-F9633EB75DFD}
{8FC9A04E-1FFD-42BA-B304-D1FA964D99CE} = {A972EC5B-FC61-4964-A6FF-F9633EB75DFD}
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0} = {8FC9A04E-1FFD-42BA-B304-D1FA964D99CE}
Expand Down
1 change: 0 additions & 1 deletion src/DevHome.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
<ProjectReference Include="..\tools\QuietBackgroundProcesses\DevHome.QuietBackgroundProcesses.ElevatedServer.Projection\DevHome.QuietBackgroundProcesses.ElevatedServer.Projection.csproj" />
<ProjectReference Include="..\tools\QuietBackgroundProcesses\DevHome.QuietBackgroundProcesses.ElevatedServer\DevHome.QuietBackgroundProcesses.ElevatedServer.vcxproj" />
<ProjectReference Include="..\tools\QuietBackgroundProcesses\DevHome.QuietBackgroundProcesses.Server\DevHome.QuietBackgroundProcesses.Server.vcxproj" />
<ProjectReference Include="..\tools\QuietBackgroundProcesses\DevHome.QuietBackgroundProcesses.UI\DevHome.QuietBackgroundProcesses.UI.csproj" />
<ProjectReference Include="..\tools\SetupFlow\DevHome.SetupFlow\DevHome.SetupFlow.csproj" />
<ProjectReference Include="..\tools\ExtensionLibrary\DevHome.ExtensionLibrary\DevHome.ExtensionLibrary.csproj" />
<ProjectReference Include="..\HyperVExtension\src\HyperVExtensionServer\HyperVExtensionServer.csproj" />
Expand Down
8 changes: 0 additions & 8 deletions src/NavConfig.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@
"viewModelFullName": "DevHome.Environments.ViewModels.LandingPageViewModel",
"icon": "E83B"
},
{
"identity": "DevHome.QuietBackgroundProcesses.UI",
"assembly": "DevHome.QuietBackgroundProcesses.UI",
"viewFullName": "DevHome.QuietBackgroundProcesses.UI.Views.QuietBackgroundProcessesPage",
"viewModelFullName": "DevHome.QuietBackgroundProcesses.UI.ViewModels.QuietBackgroundProcessesViewModel",
"icon": "f5b0",
"experimentalFeatureIdentity": "QuietBackgroundProcessesExperiment"
},
{
"identity": "DevHome.Customization",
"assembly": "DevHome.Customization",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

<ItemGroup>
<ProjectReference Include="..\..\..\common\DevHome.Common.csproj" />
<ProjectReference Include="..\..\SetupFlow\DevHome.SetupFlow.Common\DevHome.SetupFlow.Common.csproj" />
<ProjectReference Include="..\..\SetupFlow\DevHome.SetupFlow.Common\DevHome.SetupFlow.Common.csproj" />
<ProjectReference Include="..\..\SetupFlow\DevHome.SetupFlow\DevHome.SetupFlow.csproj" />
<ProjectReference Include="..\..\QuietBackgroundProcesses\DevHome.QuietBackgroundProcesses.ElevatedServer.Projection\DevHome.QuietBackgroundProcesses.ElevatedServer.Projection.csproj" />
</ItemGroup>

<ItemGroup>
Expand All @@ -39,6 +40,7 @@
<None Remove="Views\DevDriveInsightsView.xaml" />
<None Remove="Views\MainPage.xaml" />
<None Remove="Views\MainPageView.xaml" />
<None Remove="Views\QuietBackgroundProcessesPage.xaml" />
</ItemGroup>

<ItemGroup>
Expand All @@ -58,6 +60,9 @@
<Generator>MSBuild:Compile</Generator>
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Views\QuietBackgroundProcessesPage.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public static IServiceCollection AddWindowsCustomization(this IServiceCollection
services.AddSingleton<DevDriveInsightsViewModel>();
services.AddTransient<DevDriveInsightsPage>();

services.AddTransient<QuietBackgroundProcessesViewModel>();

return services;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,60 @@
<value>Windows developer settings</value>
<comment>The header for the Windows developer settings card</comment>
</data>

<!-- Quiet Background Processes -->
<data name="QuietBackgroundProcesses_QuietButton_Start" xml:space="preserve">
<value>Start session</value>
<comment>Button that starts a quiet background session</comment>
</data>
<data name="QuietBackgroundProcesses_QuietButton_Stop" xml:space="preserve">
<value>Stop session</value>
<comment>Button that stops a quiet background session</comment>
</data>
<data name="QuietBackgroundProcesses.Description" xml:space="preserve">
<value>Silence and track background processes that may hinder device performance</value>
<comment>Description of the Quiet Background Processes feature</comment>
</data>
<data name="QuietBackgroundProcesses.Header" xml:space="preserve">
<value>Quiet background processes</value>
<comment>Inline title of the Quiet Background Processes feature</comment>
</data>
<data name="QuietBackgroundProcessesExplanation.Description" xml:space="preserve">
<value>This feature can be activated for 2 hours.</value>
<comment>A description of the Quiet Background Processes time window</comment>
</data>
<data name="QuietBackgroundProcessesExplanation.Header" xml:space="preserve">
<value>Quiet background processes beta feature description</value>
<comment>Title of the next settings card that explains the feature in more detail</comment>
</data>
<data name="QuietBackgroundProcessesExplanation_LinkToDocs.Text" xml:space="preserve">
<value>Link to docs</value>
<comment>Link that launches documentation</comment>
</data>
<data name="QuietBackgroundProcessesExplanation_ProvideFeedback.Text" xml:space="preserve">
<value>Provide feedback</value>
<comment>Link that launches feedback</comment>
</data>
<data name="QuietBackgroundProcessesExplanation_RelatedLinks.Text" xml:space="preserve">
<value>Related links</value>
<comment>Label for the doc links</comment>
</data>

<!-- Quiet Background Processes Status Messages -->
<data name="QuietBackgroundProcesses_Status_FeatureNotSupported" xml:space="preserve">
<value>Feature not supported on this version of Windows</value>
<comment>Indicates that this OS isn't new enough to support the feature</comment>
</data>
<data name="QuietBackgroundProcesses_Status_SessionError" xml:space="preserve">
<value>Session Error</value>
<comment>Something went wrong when running the session</comment>
</data>
<data name="QuietBackgroundProcesses_Status_SessionEnded" xml:space="preserve">
<value>Session ended</value>
<comment>The quiet session was cancelled or the time expired</comment>
</data>
<data name="QuietBackgroundProcesses_Status_UnableToCancelSession" xml:space="preserve">
<value>Unable to cancel session</value>
<comment>Something went wrong when cancelling the session</comment>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using DevHome.Common.Services;
using DevHome.QuietBackgroundProcesses;
using Microsoft.UI.Xaml;
using Serilog;

namespace DevHome.QuietBackgroundProcesses.UI.ViewModels;
namespace DevHome.Customization.ViewModels;

public partial class QuietBackgroundProcessesViewModel : ObservableObject
{
private readonly ILogger _log = Log.ForContext("SourceContext", nameof(QuietBackgroundProcessesViewModel));

private readonly TimeSpan _zero = new TimeSpan(0, 0, 0);
private readonly TimeSpan _oneSecond = new TimeSpan(0, 0, 1);
private readonly IExperimentationService _experimentationService;

private readonly TimeSpan _zero = new(0, 0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: TimeSpan.FromSeconds(1)

private readonly TimeSpan _oneSecond = new(0, 0, 1);
#nullable enable
private DevHome.QuietBackgroundProcesses.QuietBackgroundProcessesSession? _session;
private QuietBackgroundProcessesSession? _session;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nullable is enabled in this project, you might want to review these #nullable statements. Not sure if disabling it is what you want.

#nullable disable

[ObservableProperty]
Expand All @@ -32,7 +35,7 @@ public partial class QuietBackgroundProcessesViewModel : ObservableObject
[ObservableProperty]
private string _quietButtonText;

private DevHome.QuietBackgroundProcesses.QuietBackgroundProcessesSession GetSession()
private QuietBackgroundProcessesSession GetSession()
{
if (_session == null)
{
Expand All @@ -44,7 +47,7 @@ private DevHome.QuietBackgroundProcesses.QuietBackgroundProcessesSession GetSess

private string GetString(string id)
{
var stringResource = new StringResource("DevHome.QuietBackgroundProcesses.UI.pri", "DevHome.QuietBackgroundProcesses.UI/Resources");
var stringResource = new StringResource("DevHome.Customization.pri", "DevHome.Customization/Resources");
return stringResource.GetLocalized(id);
}

Expand All @@ -53,9 +56,12 @@ private string GetStatusString(string id)
return GetString("QuietBackgroundProcesses_Status_" + id);
}

public QuietBackgroundProcessesViewModel()
public bool IsQuietBackgroundProcessesFeatureEnabled => _experimentationService.IsFeatureEnabled("QuietBackgroundProcessesExperiment");

public QuietBackgroundProcessesViewModel(IExperimentationService experimentationService)
{
IsFeaturePresent = DevHome.QuietBackgroundProcesses.QuietBackgroundProcessesSessionManager.IsFeaturePresent();
_experimentationService = experimentationService;
IsFeaturePresent = QuietBackgroundProcessesSessionManager.IsFeaturePresent();

var running = false;
if (IsFeaturePresent)
Expand Down Expand Up @@ -127,7 +133,7 @@ private bool GetIsActive()
{
try
{
_session = DevHome.QuietBackgroundProcesses.QuietBackgroundProcessesSessionManager.TryGetSession();
_session = QuietBackgroundProcessesSessionManager.TryGetSession();
if (_session != null)
{
return _session.IsActive;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:CommunityToolkit.WinUI"
mc:Ignorable="d">
xmlns:views="using:DevHome.Customization.Views">

<StackPanel Spacing="{StaticResource SettingsCardSpacing}">
<!-- Primary settings group (untitled) -->
Expand All @@ -17,6 +15,7 @@
Command="{x:Bind ViewModel.NavigateToDeveloperFileExplorerPageCommand}"
HeaderIcon="{ui:FontIcon Glyph=&#xEC50;}"
IsClickEnabled="True" />

<!-- Dev Drive Insights -->
<controls:SettingsCard
x:Uid="DevDriveInsightsCard"
Expand All @@ -28,6 +27,10 @@
<FontIcon Glyph="&#xE3AF;" FontFamily="{ThemeResource AmcFluentIcons}"/>
</controls:SettingsCard.HeaderIcon>
</controls:SettingsCard>

<!-- Quiet Background Processes -->
<views:QuietBackgroundProcessesView />

<!-- More Windows settings -->
<StackPanel>
<TextBlock x:Uid="MoreWindowsSettingsSectionHeader" Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl
x:Class="DevHome.Customization.Views.QuietBackgroundProcessesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ctControls="using:CommunityToolkit.WinUI.Controls">

<StackPanel Orientation="Vertical"
Visibility="{x:Bind ViewModel.IsQuietBackgroundProcessesFeatureEnabled, Mode=OneWay}">
<ctControls:SettingsExpander x:Uid="QuietBackgroundProcesses" IsExpanded="True" Margin="{ThemeResource SettingsCardMargin}">

<!-- Header icon -->
<ctControls:SettingsExpander.HeaderIcon>
<FontIcon FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xec7a;"/>
</ctControls:SettingsExpander.HeaderIcon>

<!-- Quiet session setting area -->
<StackPanel Orientation="Horizontal">
<TextBlock
Text="{x:Bind ViewModel.SessionStateText, Mode=OneWay}"
Style="{StaticResource BodyStrongTextBlockStyle}"
Foreground="{StaticResource AccentTextFillColorTertiaryBrush}"
Margin="{StaticResource MediumLeftRightMargin}"
VerticalAlignment="Center"
TextTrimming="CharacterEllipsis" />

<!-- Start/Stop button -->
<ToggleButton
Content="{x:Bind ViewModel.QuietButtonText, Mode=OneWay}"
IsEnabled="{x:Bind ViewModel.IsFeaturePresent, Mode=OneWay}"
IsChecked="{x:Bind ViewModel.QuietButtonChecked, Mode=OneWay}"
Command="{x:Bind ViewModel.QuietButtonClickedCommand}" />
</StackPanel>

<!-- Expander -->
<ctControls:SettingsExpander.Items>
<ctControls:SettingsCard x:Uid="QuietBackgroundProcessesExplanation" HorizontalContentAlignment="Left" >
</ctControls:SettingsCard>
Comment on lines +37 to +38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<ctControls:SettingsCard x:Uid="QuietBackgroundProcessesExplanation" HorizontalContentAlignment="Left" >
</ctControls:SettingsCard>
<ctControls:SettingsCard x:Uid="QuietBackgroundProcessesExplanation" HorizontalContentAlignment="Left" />

</ctControls:SettingsExpander.Items>

</ctControls:SettingsExpander>

</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using DevHome.Common.Extensions;
using DevHome.Customization.ViewModels;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace DevHome.Customization.Views;

public sealed partial class QuietBackgroundProcessesView : UserControl
{
public QuietBackgroundProcessesViewModel ViewModel
{
get;
}

public QuietBackgroundProcessesView()
{
InitializeComponent();

ViewModel = Application.Current.GetService<QuietBackgroundProcessesViewModel>();
}
}

This file was deleted.

Loading