This repository was archived by the owner on Jun 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Move QuietBackgroundProcesses UI to Windows customization #2511
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
private readonly TimeSpan _oneSecond = new(0, 0, 1); | ||
#nullable enable | ||
private DevHome.QuietBackgroundProcesses.QuietBackgroundProcessesSession? _session; | ||
private QuietBackgroundProcessesSession? _session; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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] | ||
|
@@ -32,7 +35,7 @@ public partial class QuietBackgroundProcessesViewModel : ObservableObject | |
[ObservableProperty] | ||
private string _quietButtonText; | ||
|
||
private DevHome.QuietBackgroundProcesses.QuietBackgroundProcessesSession GetSession() | ||
private QuietBackgroundProcessesSession GetSession() | ||
{ | ||
if (_session == null) | ||
{ | ||
|
@@ -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); | ||
} | ||
|
||
|
@@ -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) | ||
|
@@ -127,7 +133,7 @@ private bool GetIsActive() | |
{ | ||
try | ||
{ | ||
_session = DevHome.QuietBackgroundProcesses.QuietBackgroundProcessesSessionManager.TryGetSession(); | ||
_session = QuietBackgroundProcessesSessionManager.TryGetSession(); | ||
if (_session != null) | ||
{ | ||
return _session.IsActive; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
tools/Customization/DevHome.Customization/Views/QuietBackgroundProcessesView.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=""/> | ||||||||
</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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
</ctControls:SettingsExpander.Items> | ||||||||
|
||||||||
</ctControls:SettingsExpander> | ||||||||
|
||||||||
</StackPanel> | ||||||||
</UserControl> |
24 changes: 24 additions & 0 deletions
24
tools/Customization/DevHome.Customization/Views/QuietBackgroundProcessesView.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>(); | ||
} | ||
} |
30 changes: 0 additions & 30 deletions
30
...dProcesses/DevHome.QuietBackgroundProcesses.UI/DevHome.QuietBackgroundProcesses.UI.csproj
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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)