Skip to content

Commit

Permalink
Customization craftsmanship review updates (#2582)
Browse files Browse the repository at this point in the history
  • Loading branch information
nieubank authored Apr 12, 2024
1 parent e91cd0b commit 073ee2d
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 70 deletions.
8 changes: 4 additions & 4 deletions tools/Customization/DevHome.Customization/Customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ MainPage hosts links to other pages via SettingsCard controls. These pages conta
New feature additions to should expect to implement the following:

1. **View**: Generally a StackPanel that contains all the user interface for the new feature or setting(s). This View should generally be implemented as a UserControl that can be hosted in any number of Pages.
- e.g. [DeveloperFileExplorerView](Views\DeveloperFileExplorerView.xaml)
- e.g. [FileExplorerView](Views\FileExplorerView.xaml)

1. **ViewModel**: Generally the implementation of data binding and commands needed to support the View, including notifications to trigger changes in the View's UI.
- e.g. [DeveloperFileExplorerViewModel](ViewModels\DeveloperFileExplorerViewModel.cs)
- e.g. [FileExplorerViewModel](ViewModels\FileExplorerViewModel.cs)

1. **Page**: Optionally include a page that hosts the View as a navigation target from the [MainPage](Views\MainPage.xaml). This may not be needed if the settings are minimal and can be hosted on the [MainPageView](Views\MainPageView.xaml) (e.g., as a SettingsExpander).
- e.g. [DeveloperFileExplorerPage](Views\DeveloperFileExplorerPage.xaml)
- e.g. [FileExplorerPage](Views\FileExplorerPage.xaml)

1. **Model**: Any implementation details for the setting or feature, i.e. the data model and any business or validation logic.
- e.g. [DeveloperFileExplorerSettings](Models\DeveloperFileExplorerSettings.cs)
- e.g. [FileExplorerSettings](Models\FileExplorerSettings.cs)

1. **Service entries**: Pages, ViewModels, and any other services participating in dependency injection should be placed in AddWindowsCustomization in [ServiceExtensions.cs](Extensions\ServiceExtensions.cs)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
</ItemGroup>

<ItemGroup>
<None Remove="Views\DeveloperFileExplorerPage.xaml" />
<None Remove="Views\DeveloperFileExplorerView.xaml" />
<None Remove="Views\FileExplorerPage.xaml" />
<None Remove="Views\FileExplorerView.xaml" />
<None Remove="Views\DevDriveInsightsPage.xaml" />
<None Remove="Views\DevDriveInsightsView.xaml" />
<None Remove="Views\MainPage.xaml" />
Expand All @@ -44,11 +44,11 @@
</ItemGroup>

<ItemGroup>
<Page Update="Views\DeveloperFileExplorerPage.xaml">
<Page Update="Views\FileExplorerPage.xaml">
<Generator>MSBuild:Compile</Generator>
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Views\DeveloperFileExplorerView.xaml">
<Page Update="Views\FileExplorerView.xaml">
<Generator>MSBuild:Compile</Generator>
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static class PageExtensions
{
public static void ConfigureCustomizationPages(this IPageService pageService)
{
pageService.Configure<DeveloperFileExplorerViewModel, DeveloperFileExplorerPage>();
pageService.Configure<FileExplorerViewModel, FileExplorerPage>();
pageService.Configure<DevDriveInsightsViewModel, DevDriveInsightsPage>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public static IServiceCollection AddWindowsCustomization(this IServiceCollection
services.AddSingleton<MainPageViewModel>();
services.AddTransient<MainPage>();

services.AddSingleton<DeveloperFileExplorerViewModel>();
services.AddTransient<DeveloperFileExplorerPage>();

services.AddSingleton<OptimizeDevDriveDialogViewModelFactory>(sp => (cacheLocation, environmentVariable, exampleDevDriveLocation, existingDevDriveLetters) => ActivatorUtilities.CreateInstance<OptimizeDevDriveDialogViewModel>(sp, cacheLocation, environmentVariable, exampleDevDriveLocation, existingDevDriveLetters));
services.AddSingleton<DevDriveInsightsViewModel>();
services.AddSingleton<FileExplorerViewModel>();
services.AddTransient<FileExplorerPage>();

services.AddSingleton<OptimizeDevDriveDialogViewModelFactory>(sp => (cacheLocation, environmentVariable, exampleDevDriveLocation, existingDevDriveLetters) => ActivatorUtilities.CreateInstance<OptimizeDevDriveDialogViewModel>(sp, cacheLocation, environmentVariable, exampleDevDriveLocation, existingDevDriveLetters));
services.AddSingleton<DevDriveInsightsViewModel>();
services.AddTransient<DevDriveInsightsPage>();

services.AddTransient<QuietBackgroundProcessesViewModel>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace DevHome.Customization.Models;

internal static class DeveloperFileExplorerSettings
internal static class FileExplorerSettings
{
public static bool ShowFileExtensionsEnabled()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,17 @@
<value>{0} {1} used</value>
<comment>Dev drive size used</comment>
</data>
<data name="DeveloperFileExplorerCard.Description" xml:space="preserve">
<data name="FileExplorerCard.Description" xml:space="preserve">
<value>Adjust these settings for a more developer-friendly experience using File Explorer</value>
<comment>The description for the Developer File Explorer settings card</comment>
<comment>The description for the File Explorer settings card</comment>
</data>
<data name="DeveloperFileExplorerCard.Header" xml:space="preserve">
<value>Developer File Explorer</value>
<comment>The header for the Developer File Explorer settings card</comment>
<data name="FileExplorerCard.Header" xml:space="preserve">
<value>File Explorer</value>
<comment>The header for the File Explorer settings card</comment>
</data>
<data name="DeveloperFileExplorer_Header" xml:space="preserve">
<value>Developer File Explorer</value>
<comment>Header for Developer File Explorer page in the breadcrumb bar</comment>
<data name="FileExplorer_Header" xml:space="preserve">
<value>File Explorer</value>
<comment>Header for the File Explorer page in the breadcrumb bar</comment>
</data>
<data name="EndTaskOnTaskBar.Description" xml:space="preserve">
<value>Enable end task in taskbar by right click</value>
Expand Down Expand Up @@ -271,10 +271,6 @@
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,51 @@

namespace DevHome.Customization.ViewModels;

public partial class DeveloperFileExplorerViewModel : ObservableObject
public partial class FileExplorerViewModel : ObservableObject
{
private readonly ShellSettings _shellSettings;

private readonly ShellSettings _shellSettings;

public ObservableCollection<Breadcrumb> Breadcrumbs { get; }

public DeveloperFileExplorerViewModel()
public FileExplorerViewModel()
{
_shellSettings = new ShellSettings();

var stringResource = new StringResource("DevHome.Customization.pri", "DevHome.Customization/Resources");
Breadcrumbs =
[
new(stringResource.GetLocalized("MainPage_Header"), typeof(MainPageViewModel).FullName!),
new(stringResource.GetLocalized("DeveloperFileExplorer_Header"), typeof(DeveloperFileExplorerViewModel).FullName!)
_shellSettings = new ShellSettings();

var stringResource = new StringResource("DevHome.Customization.pri", "DevHome.Customization/Resources");
Breadcrumbs =
[
new(stringResource.GetLocalized("MainPage_Header"), typeof(MainPageViewModel).FullName!),
new(stringResource.GetLocalized("FileExplorer_Header"), typeof(FileExplorerViewModel).FullName!)
];
}

public bool ShowFileExtensions
{
get => DeveloperFileExplorerSettings.ShowFileExtensionsEnabled();
get => FileExplorerSettings.ShowFileExtensionsEnabled();
set
{
SettingChangedEvent.Log("ShowFileExtensions", value.ToString());
DeveloperFileExplorerSettings.SetShowFileExtensionsEnabled(value);
FileExplorerSettings.SetShowFileExtensionsEnabled(value);
}
}

public bool ShowHiddenAndSystemFiles
{
get => DeveloperFileExplorerSettings.ShowHiddenAndSystemFilesEnabled();
get => FileExplorerSettings.ShowHiddenAndSystemFilesEnabled();
set
{
SettingChangedEvent.Log("ShowHiddenAndSystemFiles", value.ToString());
DeveloperFileExplorerSettings.SetShowHiddenAndSystemFilesEnabled(value);
FileExplorerSettings.SetShowHiddenAndSystemFilesEnabled(value);
}
}

public bool ShowFullPathInTitleBar
{
get => DeveloperFileExplorerSettings.ShowFullPathInTitleBarEnabled();
get => FileExplorerSettings.ShowFullPathInTitleBarEnabled();
set
{
SettingChangedEvent.Log("ShowFullPathInTitleBar", value.ToString());
DeveloperFileExplorerSettings.SetShowFullPathInTitleBarEnabled(value);
FileExplorerSettings.SetShowFullPathInTitleBarEnabled(value);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ private async Task LaunchWindowsDeveloperSettings()
}

[RelayCommand]
private void NavigateToDeveloperFileExplorerPage()
private void NavigateToFileExplorerPage()
{
NavigationService.NavigateTo(typeof(DeveloperFileExplorerViewModel).FullName!);
NavigationService.NavigateTo(typeof(FileExplorerViewModel).FullName!);
}

[RelayCommand]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Page
x:Class="DevHome.Customization.Views.DeveloperFileExplorerPage"
x:Class="DevHome.Customization.Views.FileExplorerPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="using:DevHome.Common.Behaviors"
Expand All @@ -15,7 +15,7 @@
</Grid.RowDefinitions>

<ScrollView Grid.Row="2" VerticalAlignment="Top">
<views:DeveloperFileExplorerView />
<views:FileExplorerView />
</ScrollView>
</Grid>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

namespace DevHome.Customization.Views;

public sealed partial class DeveloperFileExplorerPage : Page
public sealed partial class FileExplorerPage : Page
{
public DeveloperFileExplorerViewModel ViewModel
public FileExplorerViewModel ViewModel
{
get;
}

public DeveloperFileExplorerPage()
public FileExplorerPage()
{
ViewModel = Application.Current.GetService<DeveloperFileExplorerViewModel>();
ViewModel = Application.Current.GetService<FileExplorerViewModel>();
this.InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<UserControl
x:Class="DevHome.Customization.Views.DeveloperFileExplorerView"
x:Class="DevHome.Customization.Views.FileExplorerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

namespace DevHome.Customization.Views;

public sealed partial class DeveloperFileExplorerView : UserControl
public sealed partial class FileExplorerView : UserControl
{
public DeveloperFileExplorerViewModel ViewModel
public FileExplorerViewModel ViewModel
{
get;
}

public DeveloperFileExplorerView()
public FileExplorerView()
{
InitializeComponent();

ViewModel = Application.Current.GetService<DeveloperFileExplorerViewModel>();
ViewModel = Application.Current.GetService<FileExplorerViewModel>();
}
}
28 changes: 17 additions & 11 deletions tools/Customization/DevHome.Customization/Views/MainPageView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@

<StackPanel Spacing="{StaticResource SettingsCardSpacing}">
<!-- Primary settings group (untitled) -->
<controls:SettingsCard
x:Uid="DeveloperFileExplorerCard"
AutomationProperties.AccessibilityView="Control"
AutomationProperties.AutomationId="NavigateDeveloperFileExplorerCardButton"
Command="{x:Bind ViewModel.NavigateToDeveloperFileExplorerPageCommand}"
HeaderIcon="{ui:FontIcon Glyph=&#xEC50;}"
IsClickEnabled="True" />
<StackPanel>
<!-- File Explorer Settings -->
<controls:SettingsCard
x:Uid="FileExplorerCard"
AutomationProperties.AccessibilityView="Control"
AutomationProperties.AutomationId="NavigateFileExplorerCardButton"
Command="{x:Bind ViewModel.NavigateToFileExplorerPageCommand}"
HeaderIcon="{ui:FontIcon Glyph=&#xEC50;}"
IsClickEnabled="True"
Margin="{ThemeResource SettingsCardMargin}"/>

<!-- Dev Drive Insights -->
<controls:SettingsCard
Expand All @@ -28,14 +31,16 @@
AutomationProperties.AutomationId="NavigateDevDriveInsightsCardButton"
Command="{x:Bind ViewModel.NavigateToDevDriveInsightsPageCommand}"
Visibility="{Binding AnyDevDrivesPresent, Converter={StaticResource BoolToVisibilityConverter}}"
IsClickEnabled="True" >
IsClickEnabled="True"
Margin="{ThemeResource SettingsCardMargin}">
<controls:SettingsCard.HeaderIcon>
<FontIcon Glyph="&#xE3AF;" FontFamily="{ThemeResource AmcFluentIcons}"/>
</controls:SettingsCard.HeaderIcon>
</controls:SettingsCard>

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

<!-- More Windows settings -->
<StackPanel>
Expand All @@ -48,7 +53,8 @@
AutomationProperties.AutomationId="LaunchWindowsDeveloperSettingsButton"
Command="{x:Bind ViewModel.LaunchWindowsDeveloperSettingsCommand}"
HeaderIcon="{ui:FontIcon Glyph=&#xEC7A;}"
IsClickEnabled="True" />
IsClickEnabled="True"
Margin="{ThemeResource SettingsCardMargin}"/>
</StackPanel>
</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

<!-- Header icon -->
<ctControls:SettingsExpander.HeaderIcon>
Expand All @@ -34,7 +34,7 @@

<!-- Expander -->
<ctControls:SettingsExpander.Items>
<ctControls:SettingsCard x:Uid="QuietBackgroundProcessesExplanation" HorizontalContentAlignment="Left" >
<ctControls:SettingsCard x:Uid="QuietBackgroundProcessesExplanation" HorizontalContentAlignment="Left" Margin="{ThemeResource SettingsCardMargin}">
</ctControls:SettingsCard>
</ctControls:SettingsExpander.Items>

Expand Down

0 comments on commit 073ee2d

Please sign in to comment.