Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.
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
22 changes: 22 additions & 0 deletions DevHome.sln
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ExtensionLibrary", "Extensi
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.Experiments", "tools\Experiments\src\DevHome.Experiments.csproj", "{2F9AD5AF-EF3B-496A-8566-9E9539E3DF43}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Environments", "Environments", "{8FC9A04E-1FFD-42BA-B304-D1FA964D99CE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevHome.Environments", "tools\Environments\DevHome.Environments\DevHome.Environments.csproj", "{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -413,6 +417,22 @@ Global
{2F9AD5AF-EF3B-496A-8566-9E9539E3DF43}.Release|x64.Build.0 = Release|x64
{2F9AD5AF-EF3B-496A-8566-9E9539E3DF43}.Release|x86.ActiveCfg = Release|x86
{2F9AD5AF-EF3B-496A-8566-9E9539E3DF43}.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
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Debug|arm64.Build.0 = Debug|ARM64
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Debug|x64.ActiveCfg = Debug|x64
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Debug|x64.Build.0 = Debug|x64
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Debug|x86.ActiveCfg = Debug|x86
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Debug|x86.Build.0 = Debug|x86
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Release|Any CPU.ActiveCfg = Release|x64
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Release|Any CPU.Build.0 = Release|x64
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Release|arm64.ActiveCfg = Release|ARM64
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Release|arm64.Build.0 = Release|ARM64
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Release|x64.ActiveCfg = Release|x64
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Release|x64.Build.0 = Release|x64
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Release|x86.ActiveCfg = Release|x86
{CFD8A90D-8B6D-4ED6-BA35-FF894BEB46C0}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -434,6 +454,8 @@ Global
{69F8B7DF-F52B-4B74-9A16-AB3241BB8912} = {F6EAB7D3-8F0A-4455-8969-2EF4A67314A0}
{F6EAB7D3-8F0A-4455-8969-2EF4A67314A0} = {A972EC5B-FC61-4964-A6FF-F9633EB75DFD}
{2F9AD5AF-EF3B-496A-8566-9E9539E3DF43} = {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}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {030B5641-B206-46BB-BF71-36FF009088FA}
Expand Down
16 changes: 16 additions & 0 deletions common/Contracts/IComputeSystemService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using DevHome.Common.Environments.Models;
using DevHome.Common.Models;
using Microsoft.Windows.DevHome.SDK;

namespace DevHome.Common.Contracts.Services;

public interface IComputeSystemService
{
public Task<Dictionary<IComputeSystemProvider, List<IDeveloperId>>> GetComputeSystemProvidersAsync();
}
15 changes: 15 additions & 0 deletions common/Contracts/IWindowsIdentityService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DevHome.Common.Contracts;

public interface IWindowsIdentityService
{
public bool IsUserHyperVAdmin();
}
20 changes: 19 additions & 1 deletion common/DevHome.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<DevHomeSDKVersion Condition="$(DevHomeSDKVersion) == ''">$(DevHomeSDKVersion)</DevHomeSDKVersion>
</PropertyGroup>
<ItemGroup>
<None Remove="Environments\CustomControls\CardBody.xaml" />
<None Remove="Environments\CustomControls\CardHeader.xaml" />
<None Remove="Environments\Styles\HorizontalCardStyles.xaml" />
<None Remove="Environments\Templates\EnvironmentsTemplates.xaml" />
<None Remove="Views\Banner.xaml" />
<None Remove="Views\CloseButton.xaml" />
<None Remove="Views\HyperlinkTextBlock.xaml" />
Expand All @@ -27,7 +31,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.DevHome.SDK" Version="0.100.369" />
<PackageReference Include="Microsoft.Windows.DevHome.SDK" Version="0.1099.404.803" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.231115000" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Internal.Windows.DevHome.Helpers" Version="1.0.20230706-x2201" />
Expand All @@ -39,6 +43,8 @@
<PackageReference Include="AdaptiveCards.ObjectModel.WinUI3" Version="1.0.0" />
<PackageReference Include="AdaptiveCards.Rendering.WinUI3" Version="1.0.2" />
<PackageReference Include="AdaptiveCards.Templating" Version="1.4.0" />
<PackageReference Include="CommunityToolkit.Common" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.Labs.WinUI.Shimmer" Version="0.1.230830" />
</ItemGroup>

<ItemGroup>
Expand All @@ -47,6 +53,18 @@
</ItemGroup>

<ItemGroup>
<Page Update="Environments\CustomControls\CardBody.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Environments\CustomControls\CardHeader.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Environments\Styles\HorizontalCardStyles.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Environments\Templates\EnvironmentsTemplates.xaml">
<XamlRuntime>$(DefaultXamlRuntime)</XamlRuntime>
</Page>
<Page Update="Views\Banner.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions common/Environments/Converters/CardStateColorToBrushConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using DevHome.Common.Environments.Models;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Media;

namespace DevHome.Common.Environments.Converters;

/// <summary>
/// Converter to convert the CardStateColor enum value to a brush that will be displayed in the Environment Card.
/// </summary>
public class CardStateColorToBrushConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
SolidColorBrush signalBrush = new();

if (value is CardStateColor status)
{
signalBrush = status switch
{
CardStateColor.Success => (SolidColorBrush)Application.Current.Resources["SystemFillColorSuccessBrush"],
CardStateColor.Neutral => (SolidColorBrush)Application.Current.Resources["SystemFillColorSolidNeutralBrush"],
CardStateColor.Caution => (SolidColorBrush)Application.Current.Resources["SystemFillColorCautionBrush"],
_ => (SolidColorBrush)Application.Current.Resources["SystemFillColorCautionBrush"],
};
}

return signalBrush;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using DevHome.Common.Services;
using Microsoft.UI.Xaml.Data;
using Microsoft.Windows.DevHome.SDK;

namespace DevHome.Common.Environments.Converters;

/// <summary>
/// Converter to convert the ComputeSystemState enum to its localized text version.
/// Note: the 'ComputeSystem' prefix should be added to every new state in the
/// resources.resw file.
/// </summary>
public class CardStateToLocalizedTextConverter : IValueConverter
{
private static readonly StringResource _stringResource = new("DevHome.Common/Resources");
private const string Prefix = "ComputeSystem";

public object Convert(object value, Type targetType, object parameter, string language)
{
var localizedText = string.Empty;

if (value is ComputeSystemState status)
{
var localizationKey = Prefix + status;
localizedText = _stringResource.GetLocalized(localizationKey);
}

return localizedText;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
91 changes: 91 additions & 0 deletions common/Environments/CustomControls/CardBody.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl
x:Class="DevHome.Common.Environments.CustomControls.CardBody"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:devEnvConverters="using:DevHome.Common.Environments.Converters"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
mc:Ignorable="d">
<UserControl.Resources>
<devEnvConverters:CardStateColorToBrushConverter x:Key="CardStateColorToBrushConverter"/>
<devEnvConverters:CardStateToLocalizedTextConverter x:Key="CardStateToLocalizedTextConverter"/>
</UserControl.Resources>

<Grid
Style="{StaticResource CardBodyContainerStyle}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- 64x64 image for the compute system. -->
<Viewbox
Grid.Column="0"
Style="{StaticResource ComputeSystemImageStyle}">
<Grid>
<!-- Image for card body. -->
<Border Style="{StaticResource ComputeSystemImageBorderStyle}">
<Image
Source="{x:Bind ComputeSystemImage, Mode=OneWay}"
Width="{StaticResource ComputeSystemImage64px}"
Height="{StaticResource ComputeSystemImage64px}"
Stretch="Fill"/>
</Border>
</Grid>
</Viewbox>
<!--
Stackpanel containing name of compute system, dot indicating status of compute system, state of compute system in text and a list of
the compute system properties.
-->
<StackPanel
Grid.Column="1"
Style="{StaticResource CardBodyStackPanelStyle}">
<StackPanel Orientation="Horizontal">
<TextBlock
Style="{StaticResource CardBodyStackPanelTextBlockStyle}"
Text="{x:Bind ComputeSystemTitle, Mode=OneWay}"/>
<TextBlock
Style="{StaticResource CardBodyStackPanelAltTextBlockStyle}"
Text="{x:Bind ComputeSystemAlternativeTitle, Mode=OneWay}"/>
</StackPanel>
<Grid
ColumnSpacing="{StaticResource ContainerElementSpacing}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Colored dot that indicates the visual state of the compute system. -->
<Ellipse
Grid.Column="0"
Fill="{x:Bind StateColor, Converter={StaticResource CardStateColorToBrushConverter}, Mode=OneWay}"
Style="{StaticResource CardBodyElipsisStyle}"/>
<!-- String that indicates the internal state of the compute system. -->
<TextBlock
Grid.Column="1"
Text="{x:Bind CardState, Converter={StaticResource CardStateToLocalizedTextConverter}, Mode=OneWay}"
Style="{StaticResource CardBodyStateTextBlockStyle}"/>
</Grid>
<!-- Wrap panel from community toolkit that will display properties of variable length. -->
<ItemsRepeater
ItemsSource="{x:Bind ComputeSystemProperties, Mode=OneWay}"
ItemTemplate="{x:Bind ComputeSystemPropertyTemplate, Mode=OneWay}">
<ItemsRepeater.Layout>
<controls:WrapLayout
Orientation="Horizontal"
HorizontalSpacing="15"/>
</ItemsRepeater.Layout>
</ItemsRepeater>
</StackPanel>
<!--
For an action control, like a splitbutton or checkbox. Pass a Datatemplate to the CardBody's ActionControlTemplate in xaml.
-->
<ContentControl
Grid.Column="2"
IsTabStop="False"
HorizontalContentAlignment="Right"
VerticalContentAlignment="Stretch"
ContentTemplate="{x:Bind ActionControlTemplate, Mode=OneWay}"/>
</Grid>
</UserControl>
79 changes: 79 additions & 0 deletions common/Environments/CustomControls/CardBody.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Collections.ObjectModel;
using DevHome.Common.Environments.Models;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Imaging;
using Microsoft.Windows.DevHome.SDK;

namespace DevHome.Common.Environments.CustomControls;

public sealed partial class CardBody : UserControl
{
public const string DefaultCardBodyImagePath = "ms-appx:///DevHome.Common/Environments/Assets/EnvironmentsDefaultWallpaper.png";

public CardBody()
{
this.InitializeComponent();
}

public DataTemplate ActionControlTemplate
{
get => (DataTemplate)GetValue(ActionControlTemplateProperty);
set => SetValue(ActionControlTemplateProperty, value);
}

public string ComputeSystemTitle
{
get => (string)GetValue(ComputeSystemTitleProperty);
set => SetValue(ComputeSystemTitleProperty, value);
}

public string ComputeSystemAlternativeTitle
{
get => (string)GetValue(ComputeSystemAlternativeTitleProperty);
set => SetValue(ComputeSystemAlternativeTitleProperty, value);
}

public BitmapImage ComputeSystemImage
{
get => (BitmapImage)GetValue(ComputeSystemImageProperty);
set => SetValue(ComputeSystemImageProperty, value);
}

public CardStateColor StateColor
{
get => (CardStateColor)GetValue(StateColorProperty);
set => SetValue(StateColorProperty, value);
}

public ComputeSystemState CardState
{
get => (ComputeSystemState)GetValue(CardStateProperty);
set => SetValue(CardStateProperty, value);
}

public ObservableCollection<ICardProperty> ComputeSystemProperties
{
get => (ObservableCollection<ICardProperty>)GetValue(ComputeSystemPropertiesProperty);
set => SetValue(ComputeSystemPropertiesProperty, value);
}

public DataTemplate ComputeSystemPropertyTemplate
{
get => (DataTemplate)GetValue(ComputeSystemPropertyTemplateProperty);
set => SetValue(ComputeSystemPropertyTemplateProperty, value);
}

private static readonly DependencyProperty ActionControlTemplateProperty = DependencyProperty.Register(nameof(ActionControlTemplate), typeof(DataTemplate), typeof(CardBody), new PropertyMetadata(null));
private static readonly DependencyProperty ComputeSystemTitleProperty = DependencyProperty.Register(nameof(ComputeSystemTitle), typeof(string), typeof(CardBody), new PropertyMetadata(null));
private static readonly DependencyProperty ComputeSystemAlternativeTitleProperty = DependencyProperty.Register(nameof(ComputeSystemAlternativeTitle), typeof(string), typeof(CardBody), new PropertyMetadata(null));
private static readonly DependencyProperty StateColorProperty = DependencyProperty.Register(nameof(StateColor), typeof(CardStateColor), typeof(CardBody), new PropertyMetadata(CardStateColor.Neutral));
private static readonly DependencyProperty CardStateProperty = DependencyProperty.Register(nameof(CardState), typeof(ComputeSystemState), typeof(CardBody), new PropertyMetadata(ComputeSystemState.Unknown));
private static readonly DependencyProperty ComputeSystemImageProperty = DependencyProperty.Register(nameof(ComputeSystemImage), typeof(BitmapImage), typeof(CardBody), new PropertyMetadata(new BitmapImage { UriSource = new Uri(DefaultCardBodyImagePath), }));
private static readonly DependencyProperty ComputeSystemPropertiesProperty = DependencyProperty.Register(nameof(ComputeSystemProperties), typeof(ObservableCollection<ICardProperty>), typeof(CardBody), new PropertyMetadata(null));
private static readonly DependencyProperty ComputeSystemPropertyTemplateProperty = DependencyProperty.Register(nameof(ComputeSystemPropertyTemplate), typeof(DataTemplate), typeof(CardBody), new PropertyMetadata(null));
}
Loading