Skip to content

Commit

Permalink
updated to WinAppSDK 1.3.230502000 (#4666)
Browse files Browse the repository at this point in the history
This PR does 3 things :

1. Update WinUICS project template to 1.3.230502000.
2. Make tests pass by modifying code for StyleCop
3. Adds code which support dynamic changing of titlebar theme whenever system theme changes even when the app is running
  • Loading branch information
pratikone authored May 12, 2023
1 parent 665590f commit 6c5d007
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion code/TemplateStudio.WinUICs.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"solution": {
"path": "TemplateStudio.sln",
"projects": [
"ProjectTemplates\\WinUICs\\TemplateStudioForWinUICs.ProjectTemplates.csproj",
"SharedFunctionality.Core\\SharedFunctionality.Core.shproj",
"SharedFunctionality.UI\\SharedFunctionality.UI.shproj",
"SharedResources\\SharedResources.csproj",
"TemplateStudioForWinUICs\\TemplateStudioForWinUICs.csproj",
"ProjectTemplates\\WinUICs\\TemplateStudioForWinUICs.ProjectTemplates.csproj",
"test\\SharedFunctionality.Core.Tests\\SharedFunctionality.Core.Tests.csproj",
"test\\SharedFunctionality.Tests\\SharedFunctionality.Tests.shproj",
"test\\SharedFunctionality.UI.Tests\\SharedFunctionality.UI.Tests.csproj",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"actionId": "0B814718-16A3-4F7F-89F1-69C0F9170EAD",
"args": {
"packageId": "Microsoft.WindowsAppSDK",
"version": "1.3.230331000",
"version": "1.3.230502000",
"projectPath": "Param_ProjectName\\Param_ProjectName.vcxproj"
},
"continueOnError": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"actionId": "0B814718-16A3-4F7F-89F1-69C0F9170EAD",
"args": {
"packageId": "Microsoft.WindowsAppSDK",
"version": "1.3.230331000",
"version": "1.3.230502000",
"projectPath": "Param_ProjectName\\Param_ProjectName.csproj"
},
"continueOnError": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace Param_RootNamespace;
public partial class App : Application
{
public static WindowEx MainWindow { get; } = new MainWindow();
public static UIElement? AppTitlebar;

public static UIElement? AppTitlebar { get; set; }

public App()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void UpdateTitleBar(ElementTheme theme)

theme = background == Colors.White ? ElementTheme.Light : ElementTheme.Dark;
}

if (theme == ElementTheme.Default)
{
theme = Application.Current.RequestedTheme == ApplicationTheme.Light ? ElementTheme.Light : ElementTheme.Dark;
Expand Down Expand Up @@ -116,5 +116,4 @@ public static void ApplySystemThemeToCaptionButtons()
UpdateTitleBar(frame.ActualTheme);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ namespace Param_RootNamespace;

public sealed partial class MainWindow : WindowEx
{
public Microsoft.UI.Dispatching.DispatcherQueue dispatcherQueue;
private UISettings _settings;
private Microsoft.UI.Dispatching.DispatcherQueue dispatcherQueue;

private UISettings settings;

public MainWindow()
{
InitializeComponent();
Expand All @@ -16,13 +18,13 @@ public MainWindow()

// Theme change code picked from https://github.com/microsoft/WinUI-Gallery/pull/1239
dispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread();
_settings = new UISettings();
_settings.ColorValuesChanged += _settings_ColorValuesChanged; // cannot use FrameworkElement.ActualThemeChanged event because the triggerTitleBarRepaint workaround no longer works
settings = new UISettings();
settings.ColorValuesChanged += Settings_ColorValuesChanged; // cannot use FrameworkElement.ActualThemeChanged event
}

// this handles updating the caption button colors correctly when indows system theme is changed
// while the app is open
private void _settings_ColorValuesChanged(UISettings sender, object args)
private void Settings_ColorValuesChanged(UISettings sender, object args)
{
// This calls comes off-thread, hence we will need to dispatch it to current app's thread
dispatcherQueue.TryEnqueue(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ private void MainWindow_Activated(object sender, WindowActivatedEventArgs args)

AppTitleBarText.Foreground = (SolidColorBrush)App.Current.Resources[resource];
App.AppTitlebar = AppTitleBarText as UIElement;

}

private void NavigationViewControl_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
Expand Down
5 changes: 3 additions & 2 deletions code/test/SharedFunctionality.Tests/BaseGenAndBuildFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,14 @@ private void CleanUpOldTests()
}
}
}

// Find a better way to get the installed VS root as well as pick one if there are multiple VS instances installed
// issue link : https://github.com/microsoft/TemplateStudio/issues/4667
public static string GetVsInstallRoot()
{
var VsEditions = new List<string> { "Enterprise", "Preview", "Professional", "Community" };

// Try both of these to allow for wonderful inconsistencies in resolving
var progFileLocations = new List<string> { Environment.GetEnvironmentVariable("ProgramW6432"), Environment.GetEnvironmentVariable("ProgramFiles") };
var progFileLocations = new List<string> { Environment.GetEnvironmentVariable("ProgramW6432"), Environment.GetEnvironmentVariable("ProgramFiles"), "D:\\Program Files" };

var basePath = "{0}\\Microsoft Visual Studio\\2022\\{1}\\";

Expand Down

0 comments on commit 6c5d007

Please sign in to comment.