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

Dev drive insights and pip cache move rebased to changes from main #2486

Merged
merged 6 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions DevHome.sln
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Customization", "Customization", "{623998FD-B0A6-4980-95D5-A5072301CA10}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.Customization", "tools\Customization\DevHome.Customization\DevHome.Customization.csproj", "{AF527EA4-6A24-4BD6-BC6E-A5863DC3489C}"
ProjectSection(ProjectDependencies) = postProject
{0901B260-1B88-4B99-A9F8-477ED0A74FBD} = {0901B260-1B88-4B99-A9F8-477ED0A74FBD}
{54082587-A435-423F-AE1B-01B906FFA7C5} = {54082587-A435-423F-AE1B-01B906FFA7C5}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Binary file added src/Assets/Fonts/AMCIcons.ttf
Binary file not shown.
2 changes: 2 additions & 0 deletions src/Styles/FontFamilies.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
https://github.com/microsoft/cascadia-code/issues/55-->
<FontFamily x:Key="CascadiaMonoFontFamily">ms-appx:///Assets/Fonts/CascadiaMono.ttf#Cascadia Mono,MS Gothic, NSimSun</FontFamily>
<FontFamily x:Key="DevHomeFluentIcons">ms-appx:///Assets/Fonts/DevHome.ttf#DevHome Fluent Icons</FontFamily>
<!-- Needed for icons on Windows Customization -> Dev Drive Insights page -->
<FontFamily x:Key="AmcFluentIcons">ms-appx:///Assets/Fonts/AmcIcons.ttf#Amc Fluent Icons</FontFamily>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

<ItemGroup>
<ProjectReference Include="..\..\..\common\DevHome.Common.csproj" />
<ProjectReference Include="..\..\SetupFlow\DevHome.SetupFlow.Common\DevHome.SetupFlow.Common.csproj" />
Copy link
Collaborator

@krschau krschau Apr 1, 2024

Choose a reason for hiding this comment

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

Would be great if you could add the DevHome.Customization project to the mermaid diagram of project relationships in https://github.com/microsoft/devhome/blob/main/docs/architecture.md #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

<ProjectReference Include="..\..\SetupFlow\DevHome.SetupFlow\DevHome.SetupFlow.csproj" />
</ItemGroup>

<ItemGroup>
Expand All @@ -33,6 +35,8 @@
<ItemGroup>
<None Remove="Views\DeveloperFileExplorerPage.xaml" />
<None Remove="Views\DeveloperFileExplorerView.xaml" />
<None Remove="Views\DevDriveInsightsPage.xaml" />
<None Remove="Views\DevDriveInsightsView.xaml" />
<None Remove="Views\MainPage.xaml" />
<None Remove="Views\MainPageView.xaml" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static class PageExtensions
{
public static void ConfigureCustomizationPages(this IPageService pageService)
{
pageService.Configure<DeveloperFileExplorerViewModel, DeveloperFileExplorerPage>();
pageService.Configure<DeveloperFileExplorerViewModel, DeveloperFileExplorerPage>();
pageService.Configure<DevDriveInsightsViewModel, DevDriveInsightsPage>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using DevHome.Customization.ViewModels;
using DevHome.Customization.ViewModels.DevDriveInsights;
using DevHome.Customization.Views;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
Expand All @@ -16,7 +17,11 @@ public static IServiceCollection AddWindowsCustomization(this IServiceCollection
services.AddTransient<MainPage>();

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

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

return services;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,34 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ChooseDirectoryPromptText" xml:space="preserve">
<value>Choose directory on dev drive...</value>
Copy link
Collaborator

@krschau krschau Apr 1, 2024

Choose a reason for hiding this comment

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

Dev Drive should be capitalized, I believe. (Applies to all instances on this page)

Suggested change
<value>Choose directory on dev drive...</value>
<value>Choose directory on Dev Drive...</value>
``` #Resolved

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is what it says in the Figma.

Copy link
Contributor

Choose a reason for hiding this comment

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

actually @SohamDas2021 it should be like Kristen outlined, If I recall, it was from Marketing who said that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So capitalize all Dev Drive in the text?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks.

<comment>Choose directory on dev drive</comment>
</data>
<data name="DevDriveFreeSizeText" xml:space="preserve">
<value>{0} {1} free</value>
<comment>Dev drive size free</comment>
</data>
<data name="DevDriveInsightsCard.Description" xml:space="preserve">
<value>All things, dev drives, optimizations, etc.</value>
Copy link
Contributor

@bbonaby bbonaby Apr 1, 2024

Choose a reason for hiding this comment

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

Missed this one, but will let you update it in another PR #Resolved

<comment>The description for the Dev Drive Insights settings card</comment>
</data>
<data name="DevDriveInsightsCard.Header" xml:space="preserve">
<value>Dev Drive Insights</value>
<comment>The header for the Dev Drive Insights settings card</comment>
</data>
<data name="DevDriveInsights_Header" xml:space="preserve">
<value>Dev Drive Insights</value>
<comment>Header for Dev Drive insights page in the breadcrumb bar</comment>
</data>
<data name="DevDriveSizeText" xml:space="preserve">
<value>Size - {0} {1}</value>
<comment>Dev drive size</comment>
</data>
<data name="DevDriveUsedSizeText" xml:space="preserve">
<value>{0} {1} used</value>
<comment>Dev drive size used</comment>
</data>
<data name="DeveloperFileExplorerCard.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>
Expand All @@ -133,10 +161,22 @@
<value>Enable end task in taskbar by right click</value>
<comment>The description for the end task on task bar settings card</comment>
</data>
<data name="ExampleDevDriveLocation" xml:space="preserve">
<value>Example: E:\packages\pip</value>
<comment>Example dev drive location</comment>
</data>
<data name="EndTaskOnTaskBar.Header" xml:space="preserve">
<value>End Task</value>
<comment>The header for the end task on task bar settings card</comment>
</data>
<data name="MakeChangesText" xml:space="preserve">
<value>Make changes</value>
<comment>Make changes button on dialog</comment>
</data>
<data name="MakeTheChangeText" xml:space="preserve">
<value>Make the change</value>
<comment>Make the change button on optimizer card</comment>
</data>
<data name="MoreWindowsSettingsSectionDescription.Text" xml:space="preserve">
<value>Additional settings below can be configured in the system settings app</value>
<comment>Description and context for a group of Windows settings in the system settings app</comment>
Expand All @@ -149,6 +189,18 @@
<value>Windows customization</value>
<comment>Navigation pane content</comment>
</data>
<data name="OptimizedDevDriveDescription" xml:space="preserve">
<value>The environment variable {0} is set to {1}</value>
<comment>Optimized dev drive description</comment>
</data>
<data name="OptimizeDevDriveDialogDescription.Text" xml:space="preserve">
<value>Contents of {0} will be copied to chosen directory. And {1} will be set to chosen directory.</value>
<comment>Optimize dev drive dialog description</comment>
</data>
<data name="OptimizerDevDriveDescription" xml:space="preserve">
<value>Global environment variable {0} is set to {1}, which is not located on dev drive. Move contents of this folder to a directory on dev drive such as {2} and set {3} to that chosen directory on dev drive</value>
<comment>Optimizer dev drive description</comment>
</data>
<data name="SettingsAutoSuggestBox.PlaceholderText" xml:space="preserve">
<value>Search</value>
<comment>The placholder text for the settings auto suggest box</comment>
Expand All @@ -173,6 +225,14 @@
<value>Show hidden and system files</value>
<comment>The header for the show hidden and system files setting.</comment>
</data>
<data name="DevDriveOptimizationSuggestion" xml:space="preserve">
<value>Suggestion</value>
<comment>Dev drive optimization suggestion</comment>
</data>
<data name="DevDriveOptimized" xml:space="preserve">
<value>Optimized</value>
<comment>Dev drive optimized indicator</comment>
</data>
<data name="MainPage_Header" xml:space="preserve">
<value>Windows customization</value>
<comment>Header for main Windows customization page in the breadcrumb bar</comment>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using CommunityToolkit.Mvvm.ComponentModel;
using DevHome.Common.Models;
using DevHome.Common.Services;
using DevHome.SetupFlow.Utilities;

using Dispatching = Microsoft.UI.Dispatching;

namespace DevHome.Customization.ViewModels.DevDriveInsights;

/// <summary>
/// View model for the card that represents a dev drive on the dev drive insights page.
/// </summary>
public partial class DevDriveCardViewModel : ObservableObject
{
private readonly Dispatching.DispatcherQueue _dispatcher;

private readonly DevHome.Common.Services.IDevDriveManager _devDriveManager;

public string DevDriveLabel { get; set; }

public ulong DevDriveSize { get; set; }

public ulong DevDriveFreeSize { get; set; }

public ulong DevDriveUsedSize { get; set; }

public double DevDriveFillPercentage { get; set; }

public string DevDriveUnitOfMeasure { get; set; }

public string DevDriveSizeText { get; set; }

public string DevDriveUsedSizeText { get; set; }

public string DevDriveFreeSizeText { get; set; }

public DevDriveCardViewModel(IDevDrive devDrive, IDevDriveManager manager)
{
_dispatcher = Dispatching.DispatcherQueue.GetForCurrentThread();
_devDriveManager = manager;

DevDriveLabel = devDrive.DriveLabel;
var divider = (ulong)((devDrive.DriveUnitOfMeasure == ByteUnit.TB) ? 1000_000_000_000 : 1000_000_000);
DevDriveSize = devDrive.DriveSizeInBytes / divider;
DevDriveFreeSize = devDrive.DriveSizeRemainingInBytes / divider;
DevDriveUsedSize = DevDriveSize - DevDriveFreeSize;
DevDriveUnitOfMeasure = (devDrive.DriveUnitOfMeasure == ByteUnit.TB) ? "TB" : "GB";
DevDriveFillPercentage = ((DevDriveSize - DevDriveFreeSize) * 100) / DevDriveSize;
var stringResource = new StringResource("DevHome.Customization.pri", "DevHome.Customization/Resources");
DevDriveSizeText = stringResource.GetLocalized("DevDriveSizeText", DevDriveSize, DevDriveUnitOfMeasure);
DevDriveUsedSizeText = stringResource.GetLocalized("DevDriveUsedSizeText", DevDriveUsedSize, DevDriveUnitOfMeasure);
DevDriveFreeSizeText = stringResource.GetLocalized("DevDriveFreeSizeText", DevDriveFreeSize, DevDriveUnitOfMeasure);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using CommunityToolkit.Mvvm.ComponentModel;
using DevHome.Common.Services;

namespace DevHome.Customization.ViewModels.DevDriveInsights;

/// <summary>
/// View model for the card that represents an optimized cache on the dev drive insights page.
/// </summary>
public partial class DevDriveOptimizedCardViewModel : ObservableObject
{
public string CacheMoved { get; set; }

public string OptimizedCacheLocation { get; set; }

public string EnvironmentVariableSet { get; set; }

public string OptimizedDevDriveDescription { get; set; }

public string DevDriveOptimized { get; set; }

public DevDriveOptimizedCardViewModel(string cacheMoved, string optimizedCacheLocation, string environmentVariableSet)
{
CacheMoved = cacheMoved;
OptimizedCacheLocation = optimizedCacheLocation;
EnvironmentVariableSet = environmentVariableSet;
var stringResource = new StringResource("DevHome.Customization.pri", "DevHome.Customization/Resources");
OptimizedDevDriveDescription = stringResource.GetLocalized("OptimizedDevDriveDescription", EnvironmentVariableSet, OptimizedCacheLocation);
DevDriveOptimized = stringResource.GetLocalized("DevDriveOptimized");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using DevHome.Common.Services;
using DevHome.Customization.Views;
using Microsoft.UI.Xaml.Controls;

namespace DevHome.Customization.ViewModels.DevDriveInsights;

/// <summary>
/// View model for the card that represents a dev drive optimizer on the dev drive insights page.
/// </summary>
public partial class DevDriveOptimizerCardViewModel : ObservableObject
{
public OptimizeDevDriveDialogViewModelFactory OptimizeDevDriveDialogViewModelFactory { get; set; }

public string CacheToBeMoved { get; set; }

public string DevDriveOptimizationSuggestion { get; set; }

public string ExistingCacheLocation { get; set; }

public string ExampleLocationOnDevDrive { get; set; }

public string EnvironmentVariableToBeSet { get; set; }

public string OptimizerDevDriveDescription { get; set; }

public string MakeTheChangeText { get; set; }

/// <summary>
/// User wants to optimize a dev drive.
/// </summary>
[RelayCommand]
private async Task OptimizeDevDriveAsync(object sender)
{
var settingsCard = sender as Button;
if (settingsCard != null)
{
var optimizeDevDriveViewModel = OptimizeDevDriveDialogViewModelFactory(ExistingCacheLocation, EnvironmentVariableToBeSet);
var optimizeDevDriveDialog = new OptimizeDevDriveDialog(optimizeDevDriveViewModel);
optimizeDevDriveDialog.XamlRoot = settingsCard.XamlRoot;
optimizeDevDriveDialog.RequestedTheme = settingsCard.ActualTheme;
await optimizeDevDriveDialog.ShowAsync();
}
}

public DevDriveOptimizerCardViewModel(OptimizeDevDriveDialogViewModelFactory optimizeDevDriveDialogViewModelFactory, string cacheToBeMoved, string existingCacheLocation, string exampleLocationOnDevDrive, string environmentVariableToBeSet)
{
OptimizeDevDriveDialogViewModelFactory = optimizeDevDriveDialogViewModelFactory;
CacheToBeMoved = cacheToBeMoved;
ExistingCacheLocation = existingCacheLocation;
ExampleLocationOnDevDrive = exampleLocationOnDevDrive;
EnvironmentVariableToBeSet = environmentVariableToBeSet;
var stringResource = new StringResource("DevHome.Customization.pri", "DevHome.Customization/Resources");
OptimizerDevDriveDescription = stringResource.GetLocalized("OptimizerDevDriveDescription", EnvironmentVariableToBeSet, ExistingCacheLocation, ExampleLocationOnDevDrive, EnvironmentVariableToBeSet);
MakeTheChangeText = stringResource.GetLocalized("MakeTheChangeText");
DevDriveOptimizationSuggestion = stringResource.GetLocalized("DevDriveOptimizationSuggestion");
}
}
Loading