diff --git a/PowerToys.slnx b/PowerToys.slnx
index a6bfd3a935..4382ca5934 100644
--- a/PowerToys.slnx
+++ b/PowerToys.slnx
@@ -4,10 +4,6 @@
-
-
-
-
diff --git a/src/common/AllExperiments/AllExperiments.csproj b/src/common/AllExperiments/AllExperiments.csproj
deleted file mode 100644
index 2ecd131532..0000000000
--- a/src/common/AllExperiments/AllExperiments.csproj
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
- enable
- enable
- PowerToys.AllExperiments
- .\Microsoft.VariantAssignment\
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/common/AllExperiments/Experiments.cs b/src/common/AllExperiments/Experiments.cs
deleted file mode 100644
index d527c52c81..0000000000
--- a/src/common/AllExperiments/Experiments.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Globalization;
-using System.Text.Json;
-
-using Microsoft.PowerToys.Settings.UI.Library.Telemetry.Events;
-using Microsoft.PowerToys.Telemetry;
-using Microsoft.VariantAssignment.Client;
-using Microsoft.VariantAssignment.Contract;
-using Windows.System.Profile;
-
-namespace AllExperiments
-{
- // The dependencies required to build this project are only available in the official build pipeline and are internal to Microsoft.
- // However, this project is not required to build a test version of the application.
- public class Experiments
- {
- public enum ExperimentState
- {
- Enabled,
- Disabled,
- NotLoaded,
- }
-
-#pragma warning disable SA1401 // Need to use LandingPageExperiment as a static property in OobeShellPage.xaml.cs
-#pragma warning disable CA2211 // Non-constant fields should not be visible
- public static ExperimentState LandingPageExperiment = ExperimentState.NotLoaded;
-#pragma warning restore CA2211
-#pragma warning restore SA1401
-
- public async Task EnableLandingPageExperimentAsync()
- {
- if (Experiments.LandingPageExperiment != ExperimentState.NotLoaded)
- {
- return Experiments.LandingPageExperiment == ExperimentState.Enabled;
- }
-
- Experiments varServ = new Experiments();
- await varServ.VariantAssignmentProvider_Initialize();
- var landingPageExperiment = varServ.IsExperiment;
-
- Experiments.LandingPageExperiment = landingPageExperiment ? ExperimentState.Enabled : ExperimentState.Disabled;
-
- return landingPageExperiment;
- }
-
- private async Task VariantAssignmentProvider_Initialize()
- {
- IsExperiment = false;
- string jsonFilePath = CreateFilePath();
-
- var vaSettings = new VariantAssignmentClientSettings
- {
- Endpoint = new Uri("https://default.exp-tas.com/exptas77/a7a397e7-6fbe-4f21-a4e9-3f542e4b000e-exppowertoys/api/v1/tas"),
- EnableCaching = true,
- ResponseCacheTime = TimeSpan.FromMinutes(5),
- };
-
- try
- {
- var vaClient = vaSettings.GetTreatmentAssignmentServiceClient();
- var vaRequest = GetVariantAssignmentRequest();
- using var variantAssignments = await vaClient.GetVariantAssignmentsAsync(vaRequest).ConfigureAwait(false);
-
- if (variantAssignments.AssignedVariants.Count != 0)
- {
- var dataVersion = variantAssignments.DataVersion;
- var featureVariables = variantAssignments.GetFeatureVariables();
- var assignmentContext = variantAssignments.GetAssignmentContext();
- var featureFlagValue = featureVariables[0].GetStringValue();
-
- var experimentGroup = string.Empty;
- string json = File.ReadAllText(jsonFilePath);
- var jsonDictionary = JsonSerializer.Deserialize>(json);
-
- if (jsonDictionary != null)
- {
- if (!jsonDictionary.TryGetValue("dataversion", out object? value))
- {
- value = dataVersion;
- jsonDictionary.Add("dataversion", value);
- }
-
- if (!jsonDictionary.ContainsKey("variantassignment"))
- {
- jsonDictionary.Add("variantassignment", featureFlagValue);
- }
- else
- {
- var jsonDataVersion = value.ToString();
- if (jsonDataVersion != null && int.Parse(jsonDataVersion, CultureInfo.InvariantCulture) < dataVersion)
- {
- jsonDictionary["dataversion"] = dataVersion;
- jsonDictionary["variantassignment"] = featureFlagValue;
- }
- }
-
- experimentGroup = jsonDictionary["variantassignment"].ToString();
-
- string output = JsonSerializer.Serialize(jsonDictionary);
- File.WriteAllText(jsonFilePath, output);
- }
-
- if (experimentGroup == "alternate" && AssignmentUnit != string.Empty)
- {
- IsExperiment = true;
- }
-
- PowerToysTelemetry.Log.WriteEvent(new OobeVariantAssignmentEvent() { AssignmentContext = assignmentContext, ClientID = AssignmentUnit });
- }
- }
- catch (HttpRequestException ex)
- {
- string json = File.ReadAllText(jsonFilePath);
- var jsonDictionary = JsonSerializer.Deserialize>(json);
-
- if (jsonDictionary != null)
- {
- if (jsonDictionary.TryGetValue("variantassignment", out object? value))
- {
- if (value.ToString() == "alternate" && AssignmentUnit != string.Empty)
- {
- IsExperiment = true;
- }
- }
- else
- {
- jsonDictionary["variantassignment"] = "current";
- }
- }
-
- string output = JsonSerializer.Serialize(jsonDictionary);
- File.WriteAllText(jsonFilePath, output);
-
- Logger.LogError("Error getting to TAS endpoint", ex);
- }
- catch (Exception ex)
- {
- Logger.LogError("Error getting variant assignments for experiment", ex);
- }
- }
-
- public bool IsExperiment { get; set; }
-
- private string? AssignmentUnit { get; set; }
-
- private VariantAssignmentRequest GetVariantAssignmentRequest()
- {
- var jsonFilePath = CreateFilePath();
- try
- {
- if (!File.Exists(jsonFilePath))
- {
- AssignmentUnit = Guid.NewGuid().ToString();
- var data = new Dictionary()
- {
- ["clientid"] = AssignmentUnit,
- };
- string jsonData = JsonSerializer.Serialize(data);
- File.WriteAllText(jsonFilePath, jsonData);
- }
- else
- {
- string json = File.ReadAllText(jsonFilePath);
- var jsonDictionary = System.Text.Json.JsonSerializer.Deserialize>(json);
- if (jsonDictionary != null)
- {
- AssignmentUnit = jsonDictionary["clientid"]?.ToString();
- }
- }
- }
- catch (Exception ex)
- {
- Logger.LogError("Error creating/getting AssignmentUnit", ex);
- }
-
- var attrNames = new List { "FlightRing", "c:InstallLanguage" };
- var attrData = AnalyticsInfo.GetSystemPropertiesAsync(attrNames).AsTask().GetAwaiter().GetResult();
-
- var flightRing = string.Empty;
- var installLanguage = string.Empty;
-
- if (attrData.ContainsKey("FlightRing"))
- {
- flightRing = attrData["FlightRing"];
- }
-
- if (attrData.ContainsKey("InstallLanguage"))
- {
- installLanguage = attrData["InstallLanguage"];
- }
-
- return new VariantAssignmentRequest
- {
- Parameters =
- {
- { "installLanguage", installLanguage },
- { "flightRing", flightRing },
- { "clientid", AssignmentUnit },
- },
- };
- }
-
- private string CreateFilePath()
- {
- var exeDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
- var settingsPath = @"Microsoft\PowerToys\experimentation.json";
- var filePath = Path.Combine(exeDir, settingsPath);
- return filePath;
- }
- }
-}
diff --git a/src/common/AllExperiments/Logger.cs b/src/common/AllExperiments/Logger.cs
deleted file mode 100644
index b9e1f20969..0000000000
--- a/src/common/AllExperiments/Logger.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Diagnostics;
-using System.Globalization;
-using System.IO.Abstractions;
-
-namespace AllExperiments
-{
- public static class Logger
- {
- private static readonly IFileSystem FileSystem = new FileSystem();
- private static readonly IPath Path = FileSystem.Path;
- private static readonly IDirectory Directory = FileSystem.Directory;
-
- private static readonly string ApplicationLogPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft\\PowerToys\\Settings Logs\\Experimentation");
-
- static Logger()
- {
- if (!Directory.Exists(ApplicationLogPath))
- {
- Directory.CreateDirectory(ApplicationLogPath);
- }
-
- // Using InvariantCulture since this is used for a log file name
- var logFilePath = Path.Combine(ApplicationLogPath, "Log_" + DateTime.Now.ToString(@"yyyy-MM-dd", CultureInfo.InvariantCulture) + ".log");
-
- Trace.Listeners.Add(new TextWriterTraceListener(logFilePath));
-
- Trace.AutoFlush = true;
- }
-
- public static void LogInfo(string message)
- {
- Log(message, "INFO");
- }
-
- public static void LogError(string message)
- {
- Log(message, "ERROR");
-#if DEBUG
- Debugger.Break();
-#endif
- }
-
- public static void LogError(string message, Exception e)
- {
- Log(
- message + Environment.NewLine +
- e?.Message + Environment.NewLine +
- "Inner exception: " + Environment.NewLine +
- e?.InnerException?.Message + Environment.NewLine +
- "Stack trace: " + Environment.NewLine +
- e?.StackTrace,
- "ERROR");
-#if DEBUG
- Debugger.Break();
-#endif
- }
-
- private static void Log(string message, string type)
- {
- Trace.WriteLine(type + ": " + DateTime.Now.TimeOfDay);
- Trace.Indent();
- Trace.WriteLine(GetCallerInfo());
- Trace.WriteLine(message);
- Trace.Unindent();
- }
-
- private static string GetCallerInfo()
- {
- StackTrace stackTrace = new StackTrace();
-
- var methodName = stackTrace.GetFrame(3)?.GetMethod();
- var className = methodName?.DeclaringType?.Name;
- return "[Method]: " + methodName?.Name + " [Class]: " + className;
- }
- }
-}
diff --git a/src/common/AllExperiments/Microsoft.VariantAssignment/Client/VariantAssignmentClientExtensionMethods.cs b/src/common/AllExperiments/Microsoft.VariantAssignment/Client/VariantAssignmentClientExtensionMethods.cs
deleted file mode 100644
index ee08acd718..0000000000
--- a/src/common/AllExperiments/Microsoft.VariantAssignment/Client/VariantAssignmentClientExtensionMethods.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using Microsoft.VariantAssignment.Contract;
-
-// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
-namespace Microsoft.VariantAssignment.Client
-{
-#pragma warning disable SA1200 // Using directives should be placed correctly
- using TreatmentAssignmentServiceClient = VariantAssignmentServiceClient;
-#pragma warning restore SA1200 // Using directives should be placed correctly
-
- public static class VariantAssignmentClientExtensionMethods
- {
- public static IVariantAssignmentProvider GetTreatmentAssignmentServiceClient(this VariantAssignmentClientSettings settings)
- {
- return new TreatmentAssignmentServiceClient();
- }
- }
-}
diff --git a/src/common/AllExperiments/Microsoft.VariantAssignment/Client/VariantAssignmentServiceClient.cs b/src/common/AllExperiments/Microsoft.VariantAssignment/Client/VariantAssignmentServiceClient.cs
deleted file mode 100644
index 373651f83a..0000000000
--- a/src/common/AllExperiments/Microsoft.VariantAssignment/Client/VariantAssignmentServiceClient.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using Microsoft.VariantAssignment.Contract;
-
-// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
-namespace Microsoft.VariantAssignment.Client
-{
- internal sealed partial class VariantAssignmentServiceClient : IVariantAssignmentProvider, IDisposable
- where TServerResponse : VariantAssignmentServiceResponse
- {
- public void Dispose()
- {
- throw new NotImplementedException();
- }
-
- public Task GetVariantAssignmentsAsync(IVariantAssignmentRequest request, CancellationToken ct = default)
- {
- return Task.FromResult(EmptyVariantAssignmentResponse.Instance);
- }
- }
-}
diff --git a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/EmptyVariantAssignmentResponse.cs b/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/EmptyVariantAssignmentResponse.cs
deleted file mode 100644
index 0e0cd54094..0000000000
--- a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/EmptyVariantAssignmentResponse.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
-namespace Microsoft.VariantAssignment.Contract
-{
- public class EmptyVariantAssignmentResponse : IVariantAssignmentResponse
- {
- ///
- /// Singleton instance of .
- ///
- public static readonly IVariantAssignmentResponse Instance = new EmptyVariantAssignmentResponse();
-
- public EmptyVariantAssignmentResponse()
- {
- }
-
- public long DataVersion => 0;
-
- public string Thumbprint => string.Empty;
-
- ///
- public IReadOnlyCollection AssignedVariants => Array.Empty();
-
- ///
-#pragma warning disable CS8603 // Possible null reference return.
- public IFeatureVariable GetFeatureVariable(IReadOnlyList path) => null;
-#pragma warning restore CS8603 // Possible null reference return.
-
- ///
- public IReadOnlyList GetFeatureVariables(IReadOnlyList prefix) => Array.Empty();
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- }
-
- string IVariantAssignmentResponse.GetAssignmentContext()
- {
- throw new NotImplementedException();
- }
-
- IReadOnlyList IVariantAssignmentResponse.GetFeatureVariables()
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IAssignedVariant.cs b/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IAssignedVariant.cs
deleted file mode 100644
index 6c9a31e8ce..0000000000
--- a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IAssignedVariant.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
-namespace Microsoft.VariantAssignment.Contract
-{
- public interface IAssignedVariant
- {
- }
-}
diff --git a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IFeatureVariable.cs b/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IFeatureVariable.cs
deleted file mode 100644
index fc9193ed0d..0000000000
--- a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IFeatureVariable.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
-namespace Microsoft.VariantAssignment.Contract
-{
- public interface IFeatureVariable
- {
- ///
- /// Gets the variable's value as a string.
- ///
- /// String value of the variable.
- string GetStringValue();
- }
-}
diff --git a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IVariantAssignmentProvider.cs b/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IVariantAssignmentProvider.cs
deleted file mode 100644
index dad9d39038..0000000000
--- a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IVariantAssignmentProvider.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
-namespace Microsoft.VariantAssignment.Contract
-{
- public interface IVariantAssignmentProvider : IDisposable
- {
- ///
- /// Computes variant assignments based on data.
- ///
- /// Variant assignment parameters.
- /// Propagates notification that operations should be canceled.
- /// An awaitable task that returns a .
- Task GetVariantAssignmentsAsync(IVariantAssignmentRequest request, CancellationToken ct = default);
- }
-}
diff --git a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IVariantAssignmentRequest.cs b/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IVariantAssignmentRequest.cs
deleted file mode 100644
index 9639a3a58d..0000000000
--- a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IVariantAssignmentRequest.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
-namespace Microsoft.VariantAssignment.Contract
-{
- public interface IVariantAssignmentRequest
- {
- ///
- /// Gets inputs used for evaluating filters, assignment units, etc.
- ///
- IReadOnlyCollection<(string Key, string Value)> Parameters { get; }
- }
-}
diff --git a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IVariantAssignmentResponse.cs b/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IVariantAssignmentResponse.cs
deleted file mode 100644
index 29ee2209de..0000000000
--- a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/IVariantAssignmentResponse.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
-namespace Microsoft.VariantAssignment.Contract
-{
- ///
- /// Snapshot of variant assignments.
- ///
- public interface IVariantAssignmentResponse : IDisposable
- {
- /////
- ///// Gets the serial number of variant assignment configuration snapshot used when assigning variants.
- /////
- long DataVersion { get; }
-
- /////
- ///// Get a hash of the response suitable for caching.
- /////
- // string Thumbprint { get; }
-
- ///
- /// Gets the variants assigned based on request parameters and a variant configuration snapshot.
- ///
- IReadOnlyCollection AssignedVariants { get; }
-
- ///
- /// Gets feature variables assigned by variants in this response.
- ///
- /// (Optional) Filter feature variables where contains the .
- /// Range of matching feature variables.
- IReadOnlyList GetFeatureVariables(IReadOnlyList prefix);
-
- // this actually part of the interface but gets the job done
- IReadOnlyList GetFeatureVariables();
-
- // this actually part of the interface but gets the job done
- string GetAssignmentContext();
-
- ///
- /// Gets a single feature variable assigned by variants in this response.
- ///
- /// Exact feature variable path.
- /// Matching feature variable or null.
- IFeatureVariable GetFeatureVariable(IReadOnlyList path);
- }
-}
diff --git a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/TreatmentAssignmentServiceResponse.cs b/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/TreatmentAssignmentServiceResponse.cs
deleted file mode 100644
index 6db91f6ffd..0000000000
--- a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/TreatmentAssignmentServiceResponse.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
-namespace Microsoft.VariantAssignment.Contract
-{
- internal sealed class TreatmentAssignmentServiceResponse : VariantAssignmentServiceResponse
- {
- }
-}
diff --git a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/VariantAssignmentClientSettings.cs b/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/VariantAssignmentClientSettings.cs
deleted file mode 100644
index f57986368c..0000000000
--- a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/VariantAssignmentClientSettings.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.ComponentModel.DataAnnotations;
-
-// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
-namespace Microsoft.VariantAssignment.Contract
-{
- ///
- /// Configuration for variant assignment service client.
- ///
- public class VariantAssignmentClientSettings
- {
- ///
- /// Gets or sets the variant assignment service endpoint URL.
- ///
- [Required]
- public Uri? Endpoint { get; set; }
-
- ///
- /// Gets or sets a value indicating whether gets or sets a value whether client side request caching should be enabled.
- ///
- public bool EnableCaching { get; set; }
-
- ///
- /// Gets or sets the maximum time a cached variant assignment response may be used without re-validating.
- ///
- public TimeSpan ResponseCacheTime { get; set; }
- }
-}
diff --git a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/VariantAssignmentRequest.cs b/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/VariantAssignmentRequest.cs
deleted file mode 100644
index 976ce53531..0000000000
--- a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/VariantAssignmentRequest.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Collections.Specialized;
-
-// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
-namespace Microsoft.VariantAssignment.Contract
-{
- public class VariantAssignmentRequest : IVariantAssignmentRequest
- {
- private NameValueCollection _parameters = new NameValueCollection();
-
- ///
- /// Gets or sets mutable .
- ///
- public NameValueCollection Parameters { get => _parameters; set => _parameters = value; }
-
- IReadOnlyCollection<(string Key, string Value)> IVariantAssignmentRequest.Parameters => (IReadOnlyCollection<(string Key, string Value)>)_parameters;
- }
-}
diff --git a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/VariantAssignmentServiceResponse.cs b/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/VariantAssignmentServiceResponse.cs
deleted file mode 100644
index e87425f4d3..0000000000
--- a/src/common/AllExperiments/Microsoft.VariantAssignment/Contract/VariantAssignmentServiceResponse.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-// The goal of this class is to just mock out the Microsoft.VariantAssignment close source objects
-namespace Microsoft.VariantAssignment.Contract
-{
- ///
- /// Mutable implementation of for (de)serialization.
- ///
- internal class VariantAssignmentServiceResponse : IVariantAssignmentResponse, IDisposable
- {
- ///
- public virtual long DataVersion { get; set; }
-
- public virtual IReadOnlyCollection AssignedVariants { get; set; } = Array.Empty();
-
- public IFeatureVariable GetFeatureVariable(IReadOnlyList path)
- {
- throw new NotImplementedException();
- }
-
- public IReadOnlyList GetFeatureVariables(IReadOnlyList prefix)
- {
- throw new NotImplementedException();
- }
-
- protected virtual void Dispose(bool disposing)
- {
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- public IReadOnlyList GetFeatureVariables()
- {
- throw new NotImplementedException();
- }
-
- public string GetAssignmentContext()
- {
- return string.Empty;
- }
- }
-}
diff --git a/src/common/ManagedCommon/WindowHelpers.cs b/src/common/ManagedCommon/WindowHelpers.cs
index c5ee13f69c..442ca34e27 100644
--- a/src/common/ManagedCommon/WindowHelpers.cs
+++ b/src/common/ManagedCommon/WindowHelpers.cs
@@ -41,6 +41,7 @@ namespace ManagedCommon
/// black. Calls DwmExtendFrameIntoClientArea() with a cyTopHeight of 2 to force
/// the window's top border to be visible.
/// Is a no-op on versions other than Windows 10.
+ /// WinUI issue: https://github.com/microsoft/microsoft-ui-xaml/issues/6901
///
public static void ForceTopBorder1PixelInsetOnWindows10(IntPtr handle)
{
diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Modules/APDialog.dark.png b/src/settings-ui/Settings.UI/Assets/Settings/Modules/APDialog.dark.png
deleted file mode 100644
index fc4d7a0292..0000000000
Binary files a/src/settings-ui/Settings.UI/Assets/Settings/Modules/APDialog.dark.png and /dev/null differ
diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Modules/APDialog.light.png b/src/settings-ui/Settings.UI/Assets/Settings/Modules/APDialog.light.png
deleted file mode 100644
index 8bc91ca89a..0000000000
Binary files a/src/settings-ui/Settings.UI/Assets/Settings/Modules/APDialog.light.png and /dev/null differ
diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Modules/CmdPal.png b/src/settings-ui/Settings.UI/Assets/Settings/Modules/CmdPal.png
index 70512fdbe1..834de00437 100644
Binary files a/src/settings-ui/Settings.UI/Assets/Settings/Modules/CmdPal.png and b/src/settings-ui/Settings.UI/Assets/Settings/Modules/CmdPal.png differ
diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Modules/CmdPal_Background.png b/src/settings-ui/Settings.UI/Assets/Settings/Modules/CmdPal_Background.png
deleted file mode 100644
index 929a637d34..0000000000
Binary files a/src/settings-ui/Settings.UI/Assets/Settings/Modules/CmdPal_Background.png and /dev/null differ
diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Modules/CmdPal_Hero.png b/src/settings-ui/Settings.UI/Assets/Settings/Modules/CmdPal_Hero.png
deleted file mode 100644
index a8889dcc05..0000000000
Binary files a/src/settings-ui/Settings.UI/Assets/Settings/Modules/CmdPal_Hero.png and /dev/null differ
diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Modules/OOBE/CmdPal.png b/src/settings-ui/Settings.UI/Assets/Settings/Modules/OOBE/CmdPal.png
index 17d7a300a8..5bae6296af 100644
Binary files a/src/settings-ui/Settings.UI/Assets/Settings/Modules/OOBE/CmdPal.png and b/src/settings-ui/Settings.UI/Assets/Settings/Modules/OOBE/CmdPal.png differ
diff --git a/src/settings-ui/Settings.UI/Assets/Settings/Modules/OOBE/PTHeroShort.png b/src/settings-ui/Settings.UI/Assets/Settings/Modules/OOBE/PTHeroShort.png
deleted file mode 100644
index 085b113599..0000000000
Binary files a/src/settings-ui/Settings.UI/Assets/Settings/Modules/OOBE/PTHeroShort.png and /dev/null differ
diff --git a/src/settings-ui/Settings.UI/OOBE/ViewModel/OobeShellViewModel.cs b/src/settings-ui/Settings.UI/OOBE/ViewModel/OobeShellViewModel.cs
index 6159b58690..a9aa7f9d15 100644
--- a/src/settings-ui/Settings.UI/OOBE/ViewModel/OobeShellViewModel.cs
+++ b/src/settings-ui/Settings.UI/OOBE/ViewModel/OobeShellViewModel.cs
@@ -2,12 +2,73 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
+
namespace Microsoft.PowerToys.Settings.UI.OOBE.ViewModel
{
public class OobeShellViewModel
{
+ public ObservableCollection Modules { get; } = new();
+
public OobeShellViewModel()
{
+ Modules = new ObservableCollection(
+ new (PowerToysModules Module, bool IsNew)[]
+ {
+ (PowerToysModules.Overview, false),
+ (PowerToysModules.AdvancedPaste, false),
+ (PowerToysModules.AlwaysOnTop, false),
+ (PowerToysModules.Awake, false),
+ (PowerToysModules.CmdNotFound, false),
+ (PowerToysModules.CmdPal, false),
+ (PowerToysModules.ColorPicker, false),
+ (PowerToysModules.CropAndLock, false),
+ (PowerToysModules.EnvironmentVariables, false),
+ (PowerToysModules.FancyZones, false),
+ (PowerToysModules.FileLocksmith, false),
+ (PowerToysModules.FileExplorer, false),
+ (PowerToysModules.ImageResizer, false),
+ (PowerToysModules.KBM, false),
+ (PowerToysModules.LightSwitch, false),
+ (PowerToysModules.MouseUtils, false),
+ (PowerToysModules.MouseWithoutBorders, false),
+ (PowerToysModules.Peek, false),
+ (PowerToysModules.PowerDisplay, true),
+ (PowerToysModules.PowerRename, false),
+ (PowerToysModules.Run, false),
+ (PowerToysModules.QuickAccent, false),
+ (PowerToysModules.ShortcutGuide, false),
+ (PowerToysModules.TextExtractor, false),
+ (PowerToysModules.MeasureTool, false),
+ (PowerToysModules.Hosts, false),
+ (PowerToysModules.Workspaces, false),
+ (PowerToysModules.RegistryPreview, false),
+ (PowerToysModules.NewPlus, false),
+ (PowerToysModules.ZoomIt, false),
+ }
+ .Select(x => new OobePowerToysModule
+ {
+ ModuleName = x.Module.ToString(),
+ IsNew = x.IsNew,
+ }));
+ }
+
+ public OobePowerToysModule GetModule(PowerToysModules module)
+ {
+ return Modules.First(m => m.ModuleName == module.ToString());
+ }
+
+ public OobePowerToysModule GetModuleFromTag(string tag)
+ {
+ if (!Enum.TryParse(tag, ignoreCase: true, out var module))
+ {
+ throw new ArgumentException($"Invalid module tag: {tag}", nameof(tag));
+ }
+
+ return GetModule(module);
}
}
}
diff --git a/src/settings-ui/Settings.UI/PowerToys.Settings.csproj b/src/settings-ui/Settings.UI/PowerToys.Settings.csproj
index c2b7d81ee4..c1f15281c7 100644
--- a/src/settings-ui/Settings.UI/PowerToys.Settings.csproj
+++ b/src/settings-ui/Settings.UI/PowerToys.Settings.csproj
@@ -28,8 +28,6 @@
-
-
@@ -115,7 +113,6 @@
-
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs
index 026b142e7c..06db073a12 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/App.xaml.cs
@@ -13,6 +13,8 @@ using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Telemetry.Events;
+using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
+using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel;
using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Microsoft.PowerToys.Settings.UI.Services;
using Microsoft.PowerToys.Settings.UI.Views;
@@ -25,11 +27,14 @@ using WinUIEx;
namespace Microsoft.PowerToys.Settings.UI
{
- ///
- /// Provides application-specific behavior to supplement the default Application class.
- ///
public partial class App : Application
{
+ public static OobeShellViewModel OobeShellViewModel { get; } = new();
+
+ private OobeWindow oobeWindow;
+
+ private ScoobeWindow scoobeWindow;
+
private enum Arguments
{
PTPipeName = 1,
@@ -231,10 +236,6 @@ namespace Microsoft.PowerToys.Settings.UI
// https://github.com/microsoft/microsoft-ui-xaml/issues/7595 - Activate doesn't bring window to the foreground
// Need to call SetForegroundWindow to actually gain focus.
WindowHelpers.BringToForeground(settingsWindow.GetWindowHandle());
-
- // https://github.com/microsoft/microsoft-ui-xaml/issues/8948 - A window's top border incorrectly
- // renders as black on Windows 10.
- WindowHelpers.ForceTopBorder1PixelInsetOnWindows10(WindowNative.GetWindowHandle(settingsWindow));
}
else
{
@@ -245,20 +246,11 @@ namespace Microsoft.PowerToys.Settings.UI
if (ShowOobe)
{
- PowerToysTelemetry.Log.WriteEvent(new OobeStartedEvent());
- OobeWindow oobeWindow = new OobeWindow(OOBE.Enums.PowerToysModules.Overview);
- oobeWindow.Activate();
- oobeWindow.ExtendsContentIntoTitleBar = true;
- WindowHelpers.ForceTopBorder1PixelInsetOnWindows10(WindowNative.GetWindowHandle(settingsWindow));
- SetOobeWindow(oobeWindow);
+ OpenOobe();
}
else if (ShowScoobe)
{
- PowerToysTelemetry.Log.WriteEvent(new ScoobeStartedEvent());
- ScoobeWindow newScoobeWindow = new ScoobeWindow();
- newScoobeWindow.Activate();
- WindowHelpers.ForceTopBorder1PixelInsetOnWindows10(WindowNative.GetWindowHandle(settingsWindow));
- SetScoobeWindow(newScoobeWindow);
+ OpenScoobe();
}
}
}
@@ -268,7 +260,7 @@ namespace Microsoft.PowerToys.Settings.UI
/// will be used such as when the application is launched to open a specific file.
///
/// Details about the launch request and process.
- protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
+ protected override void OnLaunched(LaunchActivatedEventArgs args)
{
var cmdArgs = Environment.GetCommandLineArgs();
@@ -294,8 +286,6 @@ namespace Microsoft.PowerToys.Settings.UI
// For debugging purposes
// Window is also needed to show MessageDialog
settingsWindow = new MainWindow();
- settingsWindow.ExtendsContentIntoTitleBar = true;
- WindowHelpers.ForceTopBorder1PixelInsetOnWindows10(WindowNative.GetWindowHandle(settingsWindow));
settingsWindow.Activate();
settingsWindow.NavigateToSection(StartupPage);
@@ -303,7 +293,7 @@ namespace Microsoft.PowerToys.Settings.UI
GlobalHotkeyConflictManager.Initialize(message =>
{
// In debug mode, just log or do nothing
- System.Diagnostics.Debug.WriteLine($"IPC Message: {message}");
+ Debug.WriteLine($"IPC Message: {message}");
return 0;
});
#else
@@ -335,8 +325,6 @@ namespace Microsoft.PowerToys.Settings.UI
public static ThemeService ThemeService => themeService;
private static MainWindow settingsWindow;
- private static OobeWindow oobeWindow;
- private static ScoobeWindow scoobeWindow;
public static void ClearSettingsWindow()
{
@@ -348,34 +336,52 @@ namespace Microsoft.PowerToys.Settings.UI
return settingsWindow;
}
- public static OobeWindow GetOobeWindow()
+ public static bool IsOobeOrScoobeOpen()
{
- return oobeWindow;
+ var app = (App)Current;
+ return app.oobeWindow != null || app.scoobeWindow != null;
}
- public static void SetOobeWindow(OobeWindow window)
+ public void OpenScoobe()
{
- oobeWindow = window;
+ PowerToysTelemetry.Log.WriteEvent(new ScoobeStartedEvent());
+
+ if (scoobeWindow == null)
+ {
+ scoobeWindow = new ScoobeWindow();
+
+ scoobeWindow.Closed += (_, _) =>
+ {
+ scoobeWindow = null;
+ };
+
+ scoobeWindow.Activate();
+ }
+ else
+ {
+ WindowHelpers.BringToForeground(scoobeWindow.GetWindowHandle());
+ }
}
- public static void ClearOobeWindow()
+ public void OpenOobe()
{
- oobeWindow = null;
- }
+ PowerToysTelemetry.Log.WriteEvent(new OobeStartedEvent());
- public static ScoobeWindow GetScoobeWindow()
- {
- return scoobeWindow;
- }
+ if (oobeWindow == null)
+ {
+ oobeWindow = new OobeWindow();
- public static void SetScoobeWindow(ScoobeWindow window)
- {
- scoobeWindow = window;
- }
+ oobeWindow.Closed += (_, _) =>
+ {
+ oobeWindow = null;
+ };
- public static void ClearScoobeWindow()
- {
- scoobeWindow = null;
+ oobeWindow.Activate();
+ }
+ else
+ {
+ WindowHelpers.BringToForeground(oobeWindow.GetWindowHandle());
+ }
}
public static Type GetPage(string settingWindow)
@@ -399,6 +405,7 @@ namespace Microsoft.PowerToys.Settings.UI
case "MouseWithoutBorders": return typeof(MouseWithoutBordersPage);
case "Peek": return typeof(PeekPage);
case "PowerAccent": return typeof(PowerAccentPage);
+ case "PowerDisplay": return typeof(PowerDisplayPage);
case "PowerLauncher": return typeof(PowerLauncherPage);
case "PowerPreview": return typeof(PowerPreviewPage);
case "PowerRename": return typeof(PowerRenamePage);
@@ -415,7 +422,6 @@ namespace Microsoft.PowerToys.Settings.UI
case "Workspaces": return typeof(WorkspacesPage);
case "CmdPal": return typeof(CmdPalPage);
case "ZoomIt": return typeof(ZoomItPage);
- case "PowerDisplay": return typeof(PowerDisplayPage);
default:
// Fallback to Dashboard
Debug.Assert(false, "Unexpected SettingsWindow argument value");
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/MainWindow.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/MainWindow.xaml.cs
index e85633f9e8..20834e8f44 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/MainWindow.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/MainWindow.xaml.cs
@@ -12,6 +12,7 @@ using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Views;
using Microsoft.PowerToys.Telemetry;
using Microsoft.UI;
+using Microsoft.UI.Dispatching;
using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
using Windows.Data.Json;
@@ -75,7 +76,7 @@ namespace Microsoft.PowerToys.Settings.UI
// open main window
ShellPage.SetOpenMainWindowCallback(type =>
{
- DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal, () =>
+ DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Normal, () =>
App.OpenSettingsWindow(type));
});
@@ -106,30 +107,8 @@ namespace Microsoft.PowerToys.Settings.UI
return needToUpdate;
});
- // open oobe
- ShellPage.SetOpenOobeCallback(() =>
- {
- if (App.GetOobeWindow() == null)
- {
- App.SetOobeWindow(new OobeWindow(OOBE.Enums.PowerToysModules.Overview));
- }
-
- App.GetOobeWindow().Activate();
- });
-
- // open whats new window
- ShellPage.SetOpenWhatIsNewCallback(() =>
- {
- if (App.GetScoobeWindow() == null)
- {
- App.SetScoobeWindow(new ScoobeWindow());
- }
-
- App.GetScoobeWindow().Activate();
- });
-
this.InitializeComponent();
- SetAppTitleBar();
+ SetTitleBar();
// receive IPC Message
App.IPCMessageReceivedCallback = (string msg) =>
@@ -156,21 +135,22 @@ namespace Microsoft.PowerToys.Settings.UI
PowerToysTelemetry.Log.WriteEvent(new SettingsBootEvent() { BootTimeMs = bootTime.ElapsedMilliseconds });
}
- private void SetAppTitleBar()
+ private void SetTitleBar()
{
// We need to assign the window here so it can configure the custom title bar area correctly.
shellPage.TitleBar.Window = this;
+ this.ExtendsContentIntoTitleBar = true;
WindowHelpers.ForceTopBorder1PixelInsetOnWindows10(WindowNative.GetWindowHandle(this));
}
- public void NavigateToSection(System.Type type)
+ public void NavigateToSection(Type type)
{
ShellPage.Navigate(type);
}
public void CloseHiddenWindow()
{
- var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
+ var hWnd = WindowNative.GetWindowHandle(this);
if (!NativeMethods.IsWindowVisible(hWnd))
{
Close();
@@ -179,10 +159,10 @@ namespace Microsoft.PowerToys.Settings.UI
private void Window_Closed(object sender, WindowEventArgs args)
{
- var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
+ var hWnd = WindowNative.GetWindowHandle(this);
WindowHelper.SerializePlacement(hWnd);
- if (App.GetOobeWindow() == null && App.GetScoobeWindow() == null)
+ if (!App.IsOobeOrScoobeOpen())
{
App.ClearSettingsWindow();
}
@@ -198,10 +178,7 @@ namespace Microsoft.PowerToys.Settings.UI
private void Window_Activated_SetIcon(object sender, WindowActivatedEventArgs args)
{
// Set window icon
- var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
- WindowId windowId = Win32Interop.GetWindowIdFromWindow(hWnd);
- AppWindow appWindow = AppWindow.GetFromWindowId(windowId);
- appWindow.SetIcon("Assets\\Settings\\icon.ico");
+ this.SetIcon("Assets\\Settings\\icon.ico");
}
private void Window_Activated(object sender, WindowActivatedEventArgs args)
@@ -209,7 +186,7 @@ namespace Microsoft.PowerToys.Settings.UI
if (args.WindowActivationState != WindowActivationState.Deactivated)
{
this.Activated -= Window_Activated;
- var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
+ var hWnd = WindowNative.GetWindowHandle(this);
var placement = WindowHelper.DeserializePlacementOrDefault(hWnd);
NativeMethods.SetWindowPlacement(hWnd, ref placement);
}
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeAdvancedPaste.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeAdvancedPaste.xaml.cs
index 73e25ed856..c0d4a9926c 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeAdvancedPaste.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeAdvancedPaste.xaml.cs
@@ -18,15 +18,16 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeAdvancedPaste()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.AdvancedPaste]);
+
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.AdvancedPaste);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(AdvancedPastePage));
+ OobeWindow.OpenMainWindowCallback(typeof(AdvancedPastePage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeAlwaysOnTop.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeAlwaysOnTop.xaml.cs
index 08fb0f8a80..8a353a2638 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeAlwaysOnTop.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeAlwaysOnTop.xaml.cs
@@ -18,15 +18,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeAlwaysOnTop()
{
InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.AlwaysOnTop]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.AlwaysOnTop);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(AlwaysOnTopPage));
+ OobeWindow.OpenMainWindowCallback(typeof(AlwaysOnTopPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeAwake.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeAwake.xaml.cs
index 624e473523..153b7e5472 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeAwake.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeAwake.xaml.cs
@@ -17,15 +17,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeAwake()
{
InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.Awake]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.Awake);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(AwakePage));
+ OobeWindow.OpenMainWindowCallback(typeof(AwakePage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeCmdNotFound.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeCmdNotFound.xaml.cs
index 1dea42fa74..65b30533bf 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeCmdNotFound.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeCmdNotFound.xaml.cs
@@ -18,15 +18,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeCmdNotFound()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.CmdNotFound]);
+ ViewModel = ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.CmdNotFound);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(CmdNotFoundPage));
+ OobeWindow.OpenMainWindowCallback(typeof(CmdNotFoundPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeCmdPal.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeCmdPal.xaml.cs
index ab68213a32..14a87af7b7 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeCmdPal.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeCmdPal.xaml.cs
@@ -18,15 +18,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeCmdPal()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.CmdPal]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.CmdPal);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(CmdPalPage));
+ OobeWindow.OpenMainWindowCallback(typeof(CmdPalPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeColorPicker.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeColorPicker.xaml.cs
index ce69157269..0a4ff41970 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeColorPicker.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeColorPicker.xaml.cs
@@ -21,15 +21,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeColorPicker()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.ColorPicker]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.ColorPicker);
DataContext = ViewModel;
}
private void Start_ColorPicker_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.ColorPickerSharedEventCallback != null)
+ if (OobeWindow.ColorPickerSharedEventCallback != null)
{
- using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, OobeShellPage.ColorPickerSharedEventCallback()))
+ using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, OobeWindow.ColorPickerSharedEventCallback()))
{
eventHandle.Set();
}
@@ -40,9 +40,9 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(ColorPickerPage));
+ OobeWindow.OpenMainWindowCallback(typeof(ColorPickerPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeCropAndLock.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeCropAndLock.xaml.cs
index d4c439927d..1bc2781d03 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeCropAndLock.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeCropAndLock.xaml.cs
@@ -18,15 +18,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeCropAndLock()
{
InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.CropAndLock]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.CropAndLock);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(CropAndLockPage));
+ OobeWindow.OpenMainWindowCallback(typeof(CropAndLockPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeEnvironmentVariables.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeEnvironmentVariables.xaml.cs
index ed13489f78..77da91326a 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeEnvironmentVariables.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeEnvironmentVariables.xaml.cs
@@ -22,7 +22,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeEnvironmentVariables()
{
InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.EnvironmentVariables]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.EnvironmentVariables);
DataContext = ViewModel;
}
@@ -55,9 +55,9 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private void Launch_Settings_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(EnvironmentVariablesPage));
+ OobeWindow.OpenMainWindowCallback(typeof(EnvironmentVariablesPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeFancyZones.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeFancyZones.xaml.cs
index 5308336e16..7461f055d7 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeFancyZones.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeFancyZones.xaml.cs
@@ -18,15 +18,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeFancyZones()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.FancyZones]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.FancyZones);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(FancyZonesPage));
+ OobeWindow.OpenMainWindowCallback(typeof(FancyZonesPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeFileExplorer.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeFileExplorer.xaml.cs
index e23250f316..3de75f2715 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeFileExplorer.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeFileExplorer.xaml.cs
@@ -10,9 +10,6 @@ using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobeFileExplorer : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -20,15 +17,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeFileExplorer()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.FileExplorer]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.FileExplorer);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(PowerPreviewPage));
+ OobeWindow.OpenMainWindowCallback(typeof(PowerPreviewPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeFileLocksmith.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeFileLocksmith.xaml.cs
index 148dae83c1..79565e0cd8 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeFileLocksmith.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeFileLocksmith.xaml.cs
@@ -10,9 +10,6 @@ using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobeFileLocksmith : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -20,15 +17,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeFileLocksmith()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.FileLocksmith]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.FileLocksmith);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(FileLocksmithPage));
+ OobeWindow.OpenMainWindowCallback(typeof(FileLocksmithPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeHosts.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeHosts.xaml.cs
index 2c0ec62fd8..114c23a9c8 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeHosts.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeHosts.xaml.cs
@@ -22,7 +22,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeHosts()
{
InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.Hosts]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.Hosts);
DataContext = ViewModel;
}
@@ -55,9 +55,9 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private void Launch_Settings_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(HostsPage));
+ OobeWindow.OpenMainWindowCallback(typeof(HostsPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeImageResizer.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeImageResizer.xaml.cs
index f60f36a37e..b57292f659 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeImageResizer.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeImageResizer.xaml.cs
@@ -10,9 +10,6 @@ using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobeImageResizer : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -20,15 +17,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeImageResizer()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.ImageResizer]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.ImageResizer);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(ImageResizerPage));
+ OobeWindow.OpenMainWindowCallback(typeof(ImageResizerPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeKBM.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeKBM.xaml.cs
index a583e351f5..b45a4d7982 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeKBM.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeKBM.xaml.cs
@@ -10,9 +10,6 @@ using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobeKBM : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -20,15 +17,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeKBM()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.KBM]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.KBM);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(KeyboardManagerPage));
+ OobeWindow.OpenMainWindowCallback(typeof(KeyboardManagerPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeLightSwitch.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeLightSwitch.xaml.cs
index 32978130f9..d7d1983c57 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeLightSwitch.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeLightSwitch.xaml.cs
@@ -17,14 +17,14 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeLightSwitch()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.LightSwitch]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.LightSwitch);
}
private void SettingsLaunchButton_Click(object sender, RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(LightSwitchPage));
+ OobeWindow.OpenMainWindowCallback(typeof(LightSwitchPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeMeasureTool.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeMeasureTool.xaml.cs
index e8a24b9fc5..49bff0daca 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeMeasureTool.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeMeasureTool.xaml.cs
@@ -11,9 +11,6 @@ using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobeMeasureTool : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -21,15 +18,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeMeasureTool()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.MeasureTool]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.MeasureTool);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(MeasureToolPage));
+ OobeWindow.OpenMainWindowCallback(typeof(MeasureToolPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeMouseUtils.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeMouseUtils.xaml.cs
index d62ab2f85f..5d96e3f7ae 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeMouseUtils.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeMouseUtils.xaml.cs
@@ -17,15 +17,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeMouseUtils()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.MouseUtils]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.MouseUtils);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(MouseUtilsPage));
+ OobeWindow.OpenMainWindowCallback(typeof(MouseUtilsPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeMouseWithoutBorders.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeMouseWithoutBorders.xaml.cs
index 243e871cdd..c4a64db872 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeMouseWithoutBorders.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeMouseWithoutBorders.xaml.cs
@@ -10,9 +10,6 @@ using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobeMouseWithoutBorders : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -20,15 +17,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeMouseWithoutBorders()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.MouseWithoutBorders]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.MouseWithoutBorders);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(MouseWithoutBordersPage));
+ OobeWindow.OpenMainWindowCallback(typeof(MouseWithoutBordersPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeNewPlus.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeNewPlus.xaml.cs
index 381a2b35ff..fe25e57b41 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeNewPlus.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeNewPlus.xaml.cs
@@ -10,9 +10,6 @@ using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobeNewPlus : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -20,15 +17,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeNewPlus()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.NewPlus]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.NewPlus);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(NewPlusPage));
+ OobeWindow.OpenMainWindowCallback(typeof(NewPlusPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverview.xaml b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverview.xaml
index 20815cd81c..0570a76d1f 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverview.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverview.xaml
@@ -52,26 +52,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverview.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverview.xaml.cs
index 933a4d0c24..c153e0e43d 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverview.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverview.xaml.cs
@@ -4,18 +4,11 @@
using System.ComponentModel;
using global::PowerToys.GPOWrapper;
-using Microsoft.PowerToys.Settings.UI.Helpers;
-using Microsoft.PowerToys.Settings.UI.Library;
-using Microsoft.PowerToys.Settings.UI.Library.HotkeyConflicts;
-using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel;
-using Microsoft.PowerToys.Settings.UI.Services;
-using Microsoft.PowerToys.Settings.UI.SettingsXAML.Controls.Dashboard;
using Microsoft.PowerToys.Settings.UI.Views;
using Microsoft.PowerToys.Telemetry;
using Microsoft.UI.Xaml.Controls;
-using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
@@ -25,10 +18,6 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobePowerToysModule ViewModel { get; set; }
private bool _enableDataDiagnostics;
- private AllHotkeyConflictsData _allHotkeyConflictsData = new AllHotkeyConflictsData();
- private Windows.ApplicationModel.Resources.ResourceLoader resourceLoader = Helpers.ResourceLoaderInstance.ResourceLoader;
-
- private int _conflictCount;
public bool EnableDataDiagnostics
{
@@ -53,165 +42,6 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
}
}
- public AllHotkeyConflictsData AllHotkeyConflictsData
- {
- get => _allHotkeyConflictsData;
- set
- {
- if (_allHotkeyConflictsData != value)
- {
- _allHotkeyConflictsData = value;
-
- UpdateConflictCount();
-
- OnPropertyChanged(nameof(AllHotkeyConflictsData));
- OnPropertyChanged(nameof(ConflictCount));
- OnPropertyChanged(nameof(ConflictText));
- OnPropertyChanged(nameof(ConflictDescription));
- OnPropertyChanged(nameof(HasConflicts));
- OnPropertyChanged(nameof(IconGlyph));
- OnPropertyChanged(nameof(IconForeground));
- }
- }
- }
-
- public int ConflictCount => _conflictCount;
-
- private void UpdateConflictCount()
- {
- int count = 0;
- if (AllHotkeyConflictsData == null)
- {
- _conflictCount = count;
- }
-
- if (AllHotkeyConflictsData.InAppConflicts != null)
- {
- foreach (var inAppConflict in AllHotkeyConflictsData.InAppConflicts)
- {
- var hotkey = inAppConflict.Hotkey;
- var hotkeySettings = new HotkeySettings(hotkey.Win, hotkey.Ctrl, hotkey.Alt, hotkey.Shift, hotkey.Key);
- if (!HotkeyConflictIgnoreHelper.IsIgnoringConflicts(hotkeySettings))
- {
- count++;
- }
- }
- }
-
- if (AllHotkeyConflictsData.SystemConflicts != null)
- {
- foreach (var systemConflict in AllHotkeyConflictsData.SystemConflicts)
- {
- var hotkey = systemConflict.Hotkey;
- var hotkeySettings = new HotkeySettings(hotkey.Win, hotkey.Ctrl, hotkey.Alt, hotkey.Shift, hotkey.Key);
- if (!HotkeyConflictIgnoreHelper.IsIgnoringConflicts(hotkeySettings))
- {
- count++;
- }
- }
- }
-
- _conflictCount = count;
- }
-
- public string ConflictText
- {
- get
- {
- var count = ConflictCount;
- if (count == 0)
- {
- // Return no-conflict message
- try
- {
- return resourceLoader.GetString("ShortcutConflictControl_NoConflictsFound");
- }
- catch
- {
- return "No conflicts found";
- }
- }
- else if (count == 1)
- {
- // Try to get localized string
- try
- {
- return resourceLoader.GetString("ShortcutConflictControl_SingleConflictFound");
- }
- catch
- {
- return "1 shortcut conflict";
- }
- }
- else
- {
- // Try to get localized string
- try
- {
- var template = resourceLoader.GetString("ShortcutConflictControl_MultipleConflictsFound");
- return string.Format(System.Globalization.CultureInfo.CurrentCulture, template, count);
- }
- catch
- {
- return $"{count} shortcut conflicts";
- }
- }
- }
- }
-
- public string ConflictDescription
- {
- get
- {
- var count = ConflictCount;
- if (count == 0)
- {
- // Return no-conflict description
- try
- {
- return resourceLoader.GetString("ShortcutConflictWindow_NoConflictsDescription");
- }
- catch
- {
- return "All shortcuts function correctly";
- }
- }
- else
- {
- // Return conflict description
- try
- {
- return resourceLoader.GetString("Oobe_Overview_Hotkey_Conflict_Card_Description");
- }
- catch
- {
- return "Shortcuts configured by PowerToys are conflicting";
- }
- }
- }
- }
-
- public bool HasConflicts => ConflictCount > 0;
-
- public string IconGlyph => HasConflicts ? "\uE814" : "\uE73E";
-
- public SolidColorBrush IconForeground
- {
- get
- {
- if (HasConflicts)
- {
- // Red color for conflicts
- return (SolidColorBrush)App.Current.Resources["SystemFillColorCriticalBrush"];
- }
- else
- {
- // Green color for no conflicts
- return (SolidColorBrush)App.Current.Resources["SystemFillColorSuccessBrush"];
- }
- }
- }
-
public bool ShowDataDiagnosticsSetting => GetIsDataDiagnosticsInfoBarEnabled();
public event PropertyChangedEventHandler PropertyChanged;
@@ -229,23 +59,8 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
_enableDataDiagnostics = DataDiagnosticsSettings.GetEnabledValue();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.Overview]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.Overview);
DataContext = this;
-
- // Subscribe to hotkey conflict updates
- if (GlobalHotkeyConflictManager.Instance != null)
- {
- GlobalHotkeyConflictManager.Instance.ConflictsUpdated += OnConflictsUpdated;
- GlobalHotkeyConflictManager.Instance.RequestAllConflicts();
- }
- }
-
- private void OnConflictsUpdated(object sender, AllHotkeyConflictsEventArgs e)
- {
- this.DispatcherQueue.TryEnqueue(Microsoft.UI.Dispatching.DispatcherQueuePriority.Normal, () =>
- {
- AllHotkeyConflictsData = e.Conflicts ?? new AllHotkeyConflictsData();
- });
}
private void OnPropertyChanged(string propertyName)
@@ -255,9 +70,9 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(DashboardPage));
+ OobeWindow.OpenMainWindowCallback(typeof(DashboardPage));
}
ViewModel.LogOpeningSettingsEvent();
@@ -265,26 +80,14 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private void GeneralSettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(GeneralPage));
+ OobeWindow.OpenMainWindowCallback(typeof(GeneralPage));
}
ViewModel.LogOpeningSettingsEvent();
}
- private void ShortcutConflictBtn_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
- {
- if (AllHotkeyConflictsData == null || !HasConflicts)
- {
- return;
- }
-
- // Create and show the shortcut conflict window
- var conflictWindow = new ShortcutConflictWindow();
- conflictWindow.Activate();
- }
-
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.LogOpeningModuleEvent();
@@ -293,12 +96,6 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
ViewModel.LogClosingModuleEvent();
-
- // Unsubscribe from conflict updates when leaving the page
- if (GlobalHotkeyConflictManager.Instance != null)
- {
- GlobalHotkeyConflictManager.Instance.ConflictsUpdated -= OnConflictsUpdated;
- }
}
}
}
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverviewAlternate.xaml b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverviewAlternate.xaml
deleted file mode 100644
index 7373133878..0000000000
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverviewAlternate.xaml
+++ /dev/null
@@ -1,191 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverviewAlternate.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverviewAlternate.xaml.cs
deleted file mode 100644
index cbd05fc7ed..0000000000
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverviewAlternate.xaml.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using Microsoft.PowerToys.Settings.UI.Library;
-using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
-using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel;
-using Microsoft.PowerToys.Settings.UI.Views;
-using Microsoft.UI.Xaml.Controls;
-using Microsoft.UI.Xaml.Navigation;
-
-namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
-{
- public sealed partial class OobeOverviewAlternate : Page
- {
- public OobePowerToysModule ViewModel { get; set; }
-
- public OobeOverviewAlternate()
- {
- this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.Overview]);
- DataContext = ViewModel;
-
- FancyZonesHotkeyControl.Keys = SettingsRepository.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.FancyzonesEditorHotkey.Value.GetKeysList();
- RunHotkeyControl.Keys = SettingsRepository.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.OpenPowerLauncher.GetKeysList();
- ColorPickerHotkeyControl.Keys = SettingsRepository.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.ActivationShortcut.GetKeysList();
- AlwaysOnTopHotkeyControl.Keys = SettingsRepository.GetInstance(SettingsUtils.Default).SettingsConfig.Properties.Hotkey.Value.GetKeysList();
- }
-
- private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
- {
- if (OobeShellPage.OpenMainWindowCallback != null)
- {
- OobeShellPage.OpenMainWindowCallback(typeof(DashboardPage));
- }
-
- ViewModel.LogOpeningSettingsEvent();
- }
-
- protected override void OnNavigatedTo(NavigationEventArgs e)
- {
- ViewModel.LogOpeningModuleEvent();
- }
-
- protected override void OnNavigatedFrom(NavigationEventArgs e)
- {
- ViewModel.LogClosingModuleEvent();
- }
- }
-}
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverviewPlaceholder.xaml b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverviewPlaceholder.xaml
deleted file mode 100644
index 0acd55a8fd..0000000000
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverviewPlaceholder.xaml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverviewPlaceholder.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverviewPlaceholder.xaml.cs
deleted file mode 100644
index c7767e2424..0000000000
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeOverviewPlaceholder.xaml.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Threading.Tasks;
-
-using AllExperiments;
-using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
-using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel;
-using Microsoft.PowerToys.Settings.UI.Services;
-using Microsoft.PowerToys.Settings.UI.Views;
-using Microsoft.UI.Xaml.Controls;
-using Microsoft.UI.Xaml.Navigation;
-
-namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
-{
- public sealed partial class OobeOverviewPlaceholder : Page
- {
- public OobePowerToysModule ViewModel { get; set; }
-
- public OobeOverviewPlaceholder()
- {
- this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.Overview]);
- DataContext = ViewModel;
- }
-
- private static async Task GetIsExperiment()
- {
- Experiments landingPageExp = new Experiments();
- var experimentEnabled = await landingPageExp.EnableLandingPageExperimentAsync();
- return experimentEnabled;
- }
-
- private async void Reload()
- {
- var isExperiment = await GetIsExperiment();
-
- if (isExperiment)
- {
- this.Frame.Navigate(typeof(OobeOverviewAlternate));
- }
- else
- {
- this.Frame.Navigate(typeof(OobeOverview));
- }
- }
-
- private void Page_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
- {
- Reload();
- }
-
- private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
- {
- if (OobeShellPage.OpenMainWindowCallback != null)
- {
- OobeShellPage.OpenMainWindowCallback(typeof(DashboardPage));
- }
-
- ViewModel.LogOpeningSettingsEvent();
- }
-
- protected override void OnNavigatedTo(NavigationEventArgs e)
- {
- ViewModel.LogOpeningModuleEvent();
- }
-
- protected override void OnNavigatedFrom(NavigationEventArgs e)
- {
- ViewModel.LogClosingModuleEvent();
- }
- }
-}
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePeek.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePeek.xaml.cs
index 6782f4adc7..c40727dcca 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePeek.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePeek.xaml.cs
@@ -11,9 +11,6 @@ using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobePeek : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -21,15 +18,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobePeek()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.Peek]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.Peek);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(PeekPage));
+ OobeWindow.OpenMainWindowCallback(typeof(PeekPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerAccent.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerAccent.xaml.cs
index 74aca45538..310045cb47 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerAccent.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerAccent.xaml.cs
@@ -17,15 +17,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobePowerAccent()
{
InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.QuickAccent]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.QuickAccent);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(PowerAccentPage));
+ OobeWindow.OpenMainWindowCallback(typeof(PowerAccentPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerDisplay.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerDisplay.xaml.cs
index 5b26d9d551..5b28a27efa 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerDisplay.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerDisplay.xaml.cs
@@ -14,9 +14,6 @@ using PowerToys.Interop;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobePowerDisplay : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -24,7 +21,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobePowerDisplay()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.PowerDisplay]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.PowerDisplay);
DataContext = ViewModel;
}
@@ -38,9 +35,9 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(PowerDisplayPage));
+ OobeWindow.OpenMainWindowCallback(typeof(PowerDisplayPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerOCR.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerOCR.xaml.cs
index cf607d370e..8b198c308a 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerOCR.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerOCR.xaml.cs
@@ -18,15 +18,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobePowerOCR()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.TextExtractor]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.TextExtractor);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(PowerOcrPage));
+ OobeWindow.OpenMainWindowCallback(typeof(PowerOcrPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerRename.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerRename.xaml.cs
index dc34bc5383..12559f656c 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerRename.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobePowerRename.xaml.cs
@@ -10,9 +10,6 @@ using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobePowerRename : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -20,15 +17,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobePowerRename()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.PowerRename]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.PowerRename);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(PowerRenamePage));
+ OobeWindow.OpenMainWindowCallback(typeof(PowerRenamePage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeRegistryPreview.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeRegistryPreview.xaml.cs
index a0505bf2e9..e5e081ddfd 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeRegistryPreview.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeRegistryPreview.xaml.cs
@@ -12,9 +12,6 @@ using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobeRegistryPreview : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -22,7 +19,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeRegistryPreview()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.RegistryPreview]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.RegistryPreview);
DataContext = ViewModel;
}
@@ -33,9 +30,9 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(RegistryPreviewPage));
+ OobeWindow.OpenMainWindowCallback(typeof(RegistryPreviewPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeRun.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeRun.xaml.cs
index 5d9f13f7e6..9033c976aa 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeRun.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeRun.xaml.cs
@@ -14,9 +14,6 @@ using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobeRun : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -24,15 +21,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeRun()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.Run]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.Run);
DataContext = ViewModel;
}
private void Start_Run_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.RunSharedEventCallback != null)
+ if (OobeWindow.RunSharedEventCallback != null)
{
- using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, OobeShellPage.RunSharedEventCallback()))
+ using (var eventHandle = new EventWaitHandle(false, EventResetMode.AutoReset, OobeWindow.RunSharedEventCallback()))
{
eventHandle.Set();
}
@@ -43,9 +40,9 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(PowerLauncherPage));
+ OobeWindow.OpenMainWindowCallback(typeof(PowerLauncherPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShellPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShellPage.xaml
deleted file mode 100644
index b75ddf6751..0000000000
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShellPage.xaml
+++ /dev/null
@@ -1,177 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShellPage.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShellPage.xaml.cs
deleted file mode 100644
index 456fbc228a..0000000000
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShellPage.xaml.cs
+++ /dev/null
@@ -1,349 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Collections.ObjectModel;
-using System.Globalization;
-using ManagedCommon;
-using Microsoft.PowerToys.Settings.UI.Library;
-using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
-using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel;
-using Microsoft.UI.Xaml;
-using Microsoft.UI.Xaml.Controls;
-using Microsoft.UI.Xaml.Input;
-
-namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
-{
- public sealed partial class OobeShellPage : Page
- {
- public static Func RunSharedEventCallback { get; set; }
-
- public static void SetRunSharedEventCallback(Func implementation)
- {
- RunSharedEventCallback = implementation;
- }
-
- public static Func ColorPickerSharedEventCallback { get; set; }
-
- public static void SetColorPickerSharedEventCallback(Func implementation)
- {
- ColorPickerSharedEventCallback = implementation;
- }
-
- public static Action OpenMainWindowCallback { get; set; }
-
- public static void SetOpenMainWindowCallback(Action implementation)
- {
- OpenMainWindowCallback = implementation;
- }
-
- ///
- /// Gets view model.
- ///
- public OobeShellViewModel ViewModel { get; } = new OobeShellViewModel();
-
- ///
- /// Gets or sets a shell handler to be used to update contents of the shell dynamically from page within the frame.
- ///
- public static OobeShellPage OobeShellHandler { get; set; }
-
- public ObservableCollection Modules { get; }
-
- private static SettingsUtils settingsUtils = SettingsUtils.Default;
-
- /* NOTE: Experimentation for OOBE is currently turned off on server side. Keeping this code in a comment to allow future experiments.
- private bool ExperimentationToggleSwitchEnabled { get; set; } = true;
- */
-
- public OobeShellPage()
- {
- InitializeComponent();
-
- // NOTE: Experimentation for OOBE is currently turned off on server side. Keeping this code in a comment to allow future experiments.
- // ExperimentationToggleSwitchEnabled = SettingsRepository.GetInstance(settingsUtils).SettingsConfig.EnableExperimentation;
- DataContext = ViewModel;
- OobeShellHandler = this;
- Modules = new ObservableCollection();
-
- Modules.Insert((int)PowerToysModules.Overview, new OobePowerToysModule()
- {
- ModuleName = "Overview",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.AdvancedPaste, new OobePowerToysModule()
- {
- ModuleName = "AdvancedPaste",
- IsNew = true,
- });
- Modules.Insert((int)PowerToysModules.AlwaysOnTop, new OobePowerToysModule()
- {
- ModuleName = "AlwaysOnTop",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.Awake, new OobePowerToysModule()
- {
- ModuleName = "Awake",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.CmdNotFound, new OobePowerToysModule()
- {
- ModuleName = "CmdNotFound",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.CmdPal, new OobePowerToysModule()
- {
- ModuleName = "CmdPal",
- IsNew = true,
- });
- Modules.Insert((int)PowerToysModules.ColorPicker, new OobePowerToysModule()
- {
- ModuleName = "ColorPicker",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.CropAndLock, new OobePowerToysModule()
- {
- ModuleName = "CropAndLock",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.EnvironmentVariables, new OobePowerToysModule()
- {
- ModuleName = "EnvironmentVariables",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.FancyZones, new OobePowerToysModule()
- {
- ModuleName = "FancyZones",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.FileLocksmith, new OobePowerToysModule()
- {
- ModuleName = "FileLocksmith",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.FileExplorer, new OobePowerToysModule()
- {
- ModuleName = "FileExplorer",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.ImageResizer, new OobePowerToysModule()
- {
- ModuleName = "ImageResizer",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.KBM, new OobePowerToysModule()
- {
- ModuleName = "KBM",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.LightSwitch, new OobePowerToysModule()
- {
- ModuleName = "LightSwitch",
- IsNew = true,
- });
- Modules.Insert((int)PowerToysModules.MouseUtils, new OobePowerToysModule()
- {
- ModuleName = "MouseUtils",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.MouseWithoutBorders, new OobePowerToysModule()
- {
- ModuleName = "MouseWithoutBorders",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.Peek, new OobePowerToysModule()
- {
- ModuleName = "Peek",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.PowerRename, new OobePowerToysModule()
- {
- ModuleName = "PowerRename",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.Run, new OobePowerToysModule()
- {
- ModuleName = "Run",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.QuickAccent, new OobePowerToysModule()
- {
- ModuleName = "QuickAccent",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.ShortcutGuide, new OobePowerToysModule()
- {
- ModuleName = "ShortcutGuide",
- IsNew = false,
- });
- Modules.Insert((int)PowerToysModules.TextExtractor, new OobePowerToysModule()
- {
- ModuleName = "TextExtractor",
- IsNew = false,
- });
-
- Modules.Insert((int)PowerToysModules.MeasureTool, new OobePowerToysModule()
- {
- ModuleName = "MeasureTool",
- IsNew = false,
- });
-
- Modules.Insert((int)PowerToysModules.Hosts, new OobePowerToysModule()
- {
- ModuleName = "Hosts",
- IsNew = false,
- });
-
- Modules.Insert((int)PowerToysModules.Workspaces, new OobePowerToysModule()
- {
- ModuleName = "Workspaces",
- IsNew = true,
- });
-
- Modules.Insert((int)PowerToysModules.RegistryPreview, new OobePowerToysModule()
- {
- ModuleName = "RegistryPreview",
- IsNew = false,
- });
-
- Modules.Insert((int)PowerToysModules.PowerDisplay, new OobePowerToysModule()
- {
- ModuleName = "PowerDisplay",
- IsNew = true,
- });
-
- Modules.Insert((int)PowerToysModules.NewPlus, new OobePowerToysModule()
- {
- ModuleName = "NewPlus",
- IsNew = true,
- });
-
- Modules.Insert((int)PowerToysModules.ZoomIt, new OobePowerToysModule()
- {
- ModuleName = "ZoomIt",
- IsNew = true,
- });
- }
-
- public void OnClosing()
- {
- NavigationViewItem selectedItem = this.navigationView.SelectedItem as NavigationViewItem;
- if (selectedItem != null)
- {
- Modules[(int)(PowerToysModules)Enum.Parse(typeof(PowerToysModules), (string)selectedItem.Tag, true)].LogClosingModuleEvent();
- }
- }
-
- public void NavigateToModule(PowerToysModules selectedModule)
- {
- navigationView.SelectedItem = navigationView.MenuItems[(int)selectedModule];
- }
-
- private static void OpenScoobeWindow()
- {
- if (App.GetScoobeWindow() == null)
- {
- App.SetScoobeWindow(new ScoobeWindow());
- }
-
- App.GetScoobeWindow().Activate();
- }
-
- private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
- {
- NavigationViewItem selectedItem = args.SelectedItem as NavigationViewItem;
-
- if (selectedItem != null)
- {
- switch (selectedItem.Tag)
- {
- case "Overview": NavigationFrame.Navigate(typeof(OobeOverview)); break;
- /* NOTE: Experimentation for OOBE is currently turned off on server side. Keeping this code in a comment to allow future experiments.
- if (ExperimentationToggleSwitchEnabled && GPOWrapper.GetAllowExperimentationValue() != GpoRuleConfigured.Disabled)
- {
- switch (AllExperiments.Experiments.LandingPageExperiment)
- {
- case Experiments.ExperimentState.Enabled:
- NavigationFrame.Navigate(typeof(OobeOverviewAlternate)); break;
- case Experiments.ExperimentState.Disabled:
- NavigationFrame.Navigate(typeof(OobeOverview)); break;
- case Experiments.ExperimentState.NotLoaded:
- NavigationFrame.Navigate(typeof(OobeOverviewPlaceholder)); break;
- }
-
- break;
- }
- else
- {
- NavigationFrame.Navigate(typeof(OobeOverview));
- break;
- }
- */
-
- case "AdvancedPaste": NavigationFrame.Navigate(typeof(OobeAdvancedPaste)); break;
- case "AlwaysOnTop": NavigationFrame.Navigate(typeof(OobeAlwaysOnTop)); break;
- case "Awake": NavigationFrame.Navigate(typeof(OobeAwake)); break;
- case "CmdNotFound": NavigationFrame.Navigate(typeof(OobeCmdNotFound)); break;
- case "CmdPal": NavigationFrame.Navigate(typeof(OobeCmdPal)); break;
- case "ColorPicker": NavigationFrame.Navigate(typeof(OobeColorPicker)); break;
- case "CropAndLock": NavigationFrame.Navigate(typeof(OobeCropAndLock)); break;
- case "EnvironmentVariables": NavigationFrame.Navigate(typeof(OobeEnvironmentVariables)); break;
- case "FancyZones": NavigationFrame.Navigate(typeof(OobeFancyZones)); break;
- case "FileLocksmith": NavigationFrame.Navigate(typeof(OobeFileLocksmith)); break;
- case "Run": NavigationFrame.Navigate(typeof(OobeRun)); break;
- case "ImageResizer": NavigationFrame.Navigate(typeof(OobeImageResizer)); break;
- case "KBM": NavigationFrame.Navigate(typeof(OobeKBM)); break;
- case "LightSwitch": NavigationFrame.Navigate(typeof(OobeLightSwitch)); break;
- case "PowerRename": NavigationFrame.Navigate(typeof(OobePowerRename)); break;
- case "QuickAccent": NavigationFrame.Navigate(typeof(OobePowerAccent)); break;
- case "FileExplorer": NavigationFrame.Navigate(typeof(OobeFileExplorer)); break;
- case "ShortcutGuide": NavigationFrame.Navigate(typeof(OobeShortcutGuide)); break;
- case "TextExtractor": NavigationFrame.Navigate(typeof(OobePowerOCR)); break;
- case "MouseUtils": NavigationFrame.Navigate(typeof(OobeMouseUtils)); break;
- case "MouseWithoutBorders": NavigationFrame.Navigate(typeof(OobeMouseWithoutBorders)); break;
- case "MeasureTool": NavigationFrame.Navigate(typeof(OobeMeasureTool)); break;
- case "Hosts": NavigationFrame.Navigate(typeof(OobeHosts)); break;
- case "RegistryPreview": NavigationFrame.Navigate(typeof(OobeRegistryPreview)); break;
- case "Peek": NavigationFrame.Navigate(typeof(OobePeek)); break;
- case "NewPlus": NavigationFrame.Navigate(typeof(OobeNewPlus)); break;
- case "Workspaces": NavigationFrame.Navigate(typeof(OobeWorkspaces)); break;
- case "PowerDisplay": NavigationFrame.Navigate(typeof(OobePowerDisplay)); break;
- case "ZoomIt": NavigationFrame.Navigate(typeof(OobeZoomIt)); break;
- }
- }
- }
-
- private void ShellPage_Loaded(object sender, RoutedEventArgs e)
- {
- // Select the first module by default
- if (navigationView.MenuItems.Count > 0)
- {
- navigationView.SelectedItem = navigationView.MenuItems[0];
- }
- }
-
- private void NavigationView_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
- {
- if (args.DisplayMode == NavigationViewDisplayMode.Compact || args.DisplayMode == NavigationViewDisplayMode.Minimal)
- {
- TitleBarIcon.Margin = new Thickness(0, 0, 8, 0); // Workaround, see XAML comment
- AppTitleBar.IsPaneToggleButtonVisible = true;
- }
- else
- {
- TitleBarIcon.Margin = new Thickness(16, 0, 0, 0); // Workaround, see XAML comment
- AppTitleBar.IsPaneToggleButtonVisible = false;
- }
- }
-
- private void TitleBar_PaneButtonClick(TitleBar sender, object args)
- {
- navigationView.IsPaneOpen = !navigationView.IsPaneOpen;
- }
-
- private void WhatIsNewItem_Tapped(object sender, TappedRoutedEventArgs e)
- {
- OpenScoobeWindow();
- }
- }
-}
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShortcutGuide.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShortcutGuide.xaml.cs
index 91f0402af1..f979ddb6a4 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShortcutGuide.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeShortcutGuide.xaml.cs
@@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
-
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
@@ -17,9 +16,6 @@ using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobeShortcutGuide : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -27,7 +23,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeShortcutGuide()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.ShortcutGuide]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.ShortcutGuide);
DataContext = ViewModel;
}
@@ -46,9 +42,9 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(ShortcutGuidePage));
+ OobeWindow.OpenMainWindowCallback(typeof(ShortcutGuidePage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeWorkspaces.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeWorkspaces.xaml.cs
index 98a8bccb84..993adbc0fc 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeWorkspaces.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeWorkspaces.xaml.cs
@@ -11,9 +11,6 @@ using Microsoft.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
- ///
- /// An empty page that can be used on its own or navigated to within a Frame.
- ///
public sealed partial class OobeWorkspaces : Page
{
public OobePowerToysModule ViewModel { get; set; }
@@ -21,15 +18,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeWorkspaces()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.Workspaces]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.Workspaces);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(WorkspacesPage));
+ OobeWindow.OpenMainWindowCallback(typeof(WorkspacesPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeZoomIt.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeZoomIt.xaml.cs
index 6db561bfbc..2812d9212f 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeZoomIt.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/OobeZoomIt.xaml.cs
@@ -18,15 +18,15 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
public OobeZoomIt()
{
this.InitializeComponent();
- ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModules.ZoomIt]);
+ ViewModel = App.OobeShellViewModel.GetModule(PowerToysModules.ZoomIt);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
- if (OobeShellPage.OpenMainWindowCallback != null)
+ if (OobeWindow.OpenMainWindowCallback != null)
{
- OobeShellPage.OpenMainWindowCallback(typeof(ZoomItPage));
+ OobeWindow.OpenMainWindowCallback(typeof(ZoomItPage));
}
ViewModel.LogOpeningSettingsEvent();
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeReleaseGroupViewModel.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeReleaseGroupViewModel.cs
index 4689d179b2..e384ea8a13 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeReleaseGroupViewModel.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeReleaseGroupViewModel.cs
@@ -47,7 +47,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
}
}
- private static string GetVersionFromRelease(PowerToysReleaseInfo release)
+ internal static string GetVersionFromRelease(PowerToysReleaseInfo release)
{
// TagName is typically like "v0.96.0", Name might be "Release v0.96.0"
string version = release.TagName ?? release.Name ?? "Unknown";
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeReleaseNotesPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeReleaseNotesPage.xaml
index 5bd267fee5..b5e0abb4f6 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeReleaseNotesPage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeReleaseNotesPage.xaml
@@ -29,33 +29,35 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeShellPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeShellPage.xaml
deleted file mode 100644
index 4ea411a574..0000000000
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeShellPage.xaml
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeShellPage.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeShellPage.xaml.cs
deleted file mode 100644
index a18ea16a22..0000000000
--- a/src/settings-ui/Settings.UI/SettingsXAML/OOBE/Views/ScoobeShellPage.xaml.cs
+++ /dev/null
@@ -1,194 +0,0 @@
-// Copyright (c) Microsoft Corporation
-// The Microsoft Corporation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Net.Http;
-using System.Text.Json;
-using System.Threading.Tasks;
-using ManagedCommon;
-using Microsoft.PowerToys.Settings.UI.Helpers;
-using Microsoft.PowerToys.Settings.UI.SerializationContext;
-using Microsoft.UI.Xaml;
-using Microsoft.UI.Xaml.Controls;
-
-namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
-{
- public sealed partial class ScoobeShellPage : Page
- {
- public static Action OpenMainWindowCallback { get; set; }
-
- public static void SetOpenMainWindowCallback(Action implementation)
- {
- OpenMainWindowCallback = implementation;
- }
-
- ///
- /// Gets or sets a shell handler to be used to update contents of the shell dynamically from page within the frame.
- ///
- public static ScoobeShellPage ScoobeShellHandler { get; set; }
-
- ///
- /// Gets the list of release groups loaded from GitHub (grouped by major.minor version).
- ///
- public IList> ReleaseGroups { get; private set; }
-
- private bool _isLoading;
-
- public ScoobeShellPage()
- {
- InitializeComponent();
- ScoobeShellHandler = this;
- }
-
- private async void ShellPage_Loaded(object sender, RoutedEventArgs e)
- {
- SetTitleBar();
- await LoadReleasesAsync();
- }
-
- private async Task LoadReleasesAsync()
- {
- if (_isLoading)
- {
- return;
- }
-
- _isLoading = true;
- LoadingProgressRing.Visibility = Visibility.Visible;
- ErrorInfoBar.IsOpen = false;
- navigationView.MenuItems.Clear();
-
- try
- {
- var releases = await FetchReleasesFromGitHubAsync();
- ReleaseGroups = GroupReleasesByMajorMinor(releases);
- PopulateNavigationItems();
- }
- catch (Exception ex)
- {
- Logger.LogError("Failed to load releases", ex);
- ErrorInfoBar.IsOpen = true;
- }
- finally
- {
- LoadingProgressRing.Visibility = Visibility.Collapsed;
- _isLoading = false;
- }
- }
-
- private static async Task> FetchReleasesFromGitHubAsync()
- {
- using var proxyClientHandler = new HttpClientHandler
- {
- DefaultProxyCredentials = CredentialCache.DefaultCredentials,
- Proxy = WebRequest.GetSystemWebProxy(),
- PreAuthenticate = true,
- };
-
- using var httpClient = new HttpClient(proxyClientHandler);
- httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "PowerToys");
-
- string json = await httpClient.GetStringAsync("https://api.github.com/repos/microsoft/PowerToys/releases?per_page=20");
- var allReleases = JsonSerializer.Deserialize>(json, SourceGenerationContextContext.Default.IListPowerToysReleaseInfo);
-
- return allReleases
- .OrderByDescending(r => r.PublishedDate)
- .ToList();
- }
-
- private static IList> GroupReleasesByMajorMinor(IList releases)
- {
- return releases
- .GroupBy(r => GetMajorMinorVersion(r))
- .Select(g => g.OrderByDescending(r => r.PublishedDate).ToList() as IList)
- .ToList();
- }
-
- private static string GetMajorMinorVersion(PowerToysReleaseInfo release)
- {
- string version = GetVersionFromRelease(release);
- var parts = version.Split('.');
- if (parts.Length >= 2)
- {
- return $"{parts[0]}.{parts[1]}";
- }
-
- return version;
- }
-
- private static string GetVersionFromRelease(PowerToysReleaseInfo release)
- {
- // TagName is typically like "v0.96.0", Name might be "Release v0.96.0"
- string version = release.TagName ?? release.Name ?? "Unknown";
- if (version.StartsWith("v", StringComparison.OrdinalIgnoreCase))
- {
- version = version.Substring(1);
- }
-
- return version;
- }
-
- private void PopulateNavigationItems()
- {
- if (ReleaseGroups == null || ReleaseGroups.Count == 0)
- {
- return;
- }
-
- foreach (var releaseGroup in ReleaseGroups)
- {
- var viewModel = new ScoobeReleaseGroupViewModel(releaseGroup);
- navigationView.MenuItems.Add(viewModel);
- }
-
- // Select the first item to trigger navigation
- navigationView.SelectedItem = navigationView.MenuItems[0];
- }
-
- private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
- {
- if (args.SelectedItem is ScoobeReleaseGroupViewModel viewModel)
- {
- NavigationFrame.Navigate(typeof(ScoobeReleaseNotesPage), viewModel.Releases);
- }
- }
-
- private async void RetryButton_Click(object sender, RoutedEventArgs e)
- {
- await LoadReleasesAsync();
- }
-
- private void SetTitleBar()
- {
- var window = App.GetScoobeWindow();
- if (window != null)
- {
- window.ExtendsContentIntoTitleBar = true;
- window.SetTitleBar(AppTitleBar);
- }
- }
-
- private void NavigationView_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
- {
- if (args.DisplayMode == NavigationViewDisplayMode.Compact || args.DisplayMode == NavigationViewDisplayMode.Minimal)
- {
- TitleBarIcon.Margin = new Thickness(0, 0, 8, 0); // Workaround, see XAML comment
- AppTitleBar.IsPaneToggleButtonVisible = true;
- }
- else
- {
- TitleBarIcon.Margin = new Thickness(16, 0, 0, 0); // Workaround, see XAML comment
- AppTitleBar.IsPaneToggleButtonVisible = false;
- }
- }
-
- private void TitleBar_PaneButtonClick(TitleBar sender, object args)
- {
- navigationView.IsPaneOpen = !navigationView.IsPaneOpen;
- }
- }
-}
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OobeWindow.xaml b/src/settings-ui/Settings.UI/SettingsXAML/OobeWindow.xaml
index f277350fbc..93e197f66e 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OobeWindow.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OobeWindow.xaml
@@ -5,13 +5,183 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Microsoft.PowerToys.Settings.UI.OOBE.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:ui="using:CommunityToolkit.WinUI"
xmlns:winuiex="using:WinUIEx"
+ Width="1100"
+ Height="700"
MinWidth="480"
MinHeight="480"
+ Activated="Window_Activated"
Closed="Window_Closed"
mc:Ignorable="d">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/OobeWindow.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/OobeWindow.xaml.cs
index 6a63054773..cc98149397 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/OobeWindow.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/OobeWindow.xaml.cs
@@ -3,125 +3,157 @@
// See the LICENSE file in the project root for more information.
using System;
-
+using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers;
-using Microsoft.PowerToys.Settings.UI.OOBE.Enums;
+using Microsoft.PowerToys.Settings.UI.OOBE.ViewModel;
using Microsoft.PowerToys.Settings.UI.OOBE.Views;
-using Microsoft.UI;
-using Microsoft.UI.Windowing;
using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Input;
using PowerToys.Interop;
-using Windows.Graphics;
+using WinRT.Interop;
using WinUIEx;
-using WinUIEx.Messaging;
namespace Microsoft.PowerToys.Settings.UI
{
- ///
- /// An empty window that can be used on its own or navigated to within a Frame.
- ///
- public sealed partial class OobeWindow : WindowEx, IDisposable
+ public sealed partial class OobeWindow : WindowEx
{
- private PowerToysModules initialModule;
+ public OobeShellViewModel ViewModel => App.OobeShellViewModel;
- private const int ExpectedWidth = 1100;
- private const int ExpectedHeight = 700;
- private const int DefaultDPI = 96;
- private int _currentDPI;
- private WindowId _windowId;
- private IntPtr _hWnd;
- private AppWindow _appWindow;
- private bool disposedValue;
+ public static Func RunSharedEventCallback { get; set; }
- public OobeWindow(PowerToysModules initialModule)
+ public static void SetRunSharedEventCallback(Func implementation)
+ {
+ RunSharedEventCallback = implementation;
+ }
+
+ public static Func ColorPickerSharedEventCallback { get; set; }
+
+ public static void SetColorPickerSharedEventCallback(Func implementation)
+ {
+ ColorPickerSharedEventCallback = implementation;
+ }
+
+ public static Action OpenMainWindowCallback { get; set; }
+
+ public static void SetOpenMainWindowCallback(Action implementation)
+ {
+ OpenMainWindowCallback = implementation;
+ }
+
+ public OobeWindow()
{
App.ThemeService.ThemeChanged += OnThemeChanged;
App.ThemeService.ApplyTheme();
this.InitializeComponent();
- _hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
- _windowId = Win32Interop.GetWindowIdFromWindow(_hWnd);
- _appWindow = AppWindow.GetFromWindowId(_windowId);
- this.Activated += Window_Activated_SetIcon;
- this.ExtendsContentIntoTitleBar = true;
+ SetTitleBar();
- var dpi = NativeMethods.GetDpiForWindow(_hWnd);
- _currentDPI = dpi;
- float scalingFactor = (float)dpi / DefaultDPI;
- int width = (int)(ExpectedWidth * scalingFactor);
- int height = (int)(ExpectedHeight * scalingFactor);
+ RootGrid.DataContext = ViewModel;
- SizeInt32 size;
- size.Width = width;
- size.Height = height;
- _appWindow.Resize(size);
-
- this.initialModule = initialModule;
-
- this.SizeChanged += OobeWindow_SizeChanged;
-
- var loader = ResourceLoaderInstance.ResourceLoader;
- Title = loader.GetString("OobeWindow_Title");
-
- if (shellPage != null)
- {
- shellPage.NavigateToModule(this.initialModule);
- }
-
- OobeShellPage.SetRunSharedEventCallback(() =>
+ SetRunSharedEventCallback(() =>
{
return Constants.PowerLauncherSharedEvent();
});
- OobeShellPage.SetColorPickerSharedEventCallback(() =>
+ SetColorPickerSharedEventCallback(() =>
{
return Constants.ShowColorPickerSharedEvent();
});
- OobeShellPage.SetOpenMainWindowCallback((Type type) =>
+ SetOpenMainWindowCallback((Type type) =>
{
App.OpenSettingsWindow(type);
});
}
- public void SetAppWindow(PowerToysModules module)
+ private void SetTitleBar()
{
- if (shellPage != null)
+ WindowHelpers.ForceTopBorder1PixelInsetOnWindows10(WindowNative.GetWindowHandle(this));
+ this.ExtendsContentIntoTitleBar = true;
+ this.SetTitleBar(AppTitleBar);
+ Title = ResourceLoaderInstance.ResourceLoader.GetString("OobeWindow_Title");
+ }
+
+ private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
+ {
+ if (navigationView.SelectedItem is NavigationViewItem selectedItem)
{
- shellPage.NavigateToModule(module);
+ switch (selectedItem.Tag)
+ {
+ case "Overview": NavigationFrame.Navigate(typeof(OobeOverview)); break;
+ case "AdvancedPaste": NavigationFrame.Navigate(typeof(OobeAdvancedPaste)); break;
+ case "AlwaysOnTop": NavigationFrame.Navigate(typeof(OobeAlwaysOnTop)); break;
+ case "Awake": NavigationFrame.Navigate(typeof(OobeAwake)); break;
+ case "CmdNotFound": NavigationFrame.Navigate(typeof(OobeCmdNotFound)); break;
+ case "CmdPal": NavigationFrame.Navigate(typeof(OobeCmdPal)); break;
+ case "ColorPicker": NavigationFrame.Navigate(typeof(OobeColorPicker)); break;
+ case "CropAndLock": NavigationFrame.Navigate(typeof(OobeCropAndLock)); break;
+ case "EnvironmentVariables": NavigationFrame.Navigate(typeof(OobeEnvironmentVariables)); break;
+ case "FancyZones": NavigationFrame.Navigate(typeof(OobeFancyZones)); break;
+ case "FileLocksmith": NavigationFrame.Navigate(typeof(OobeFileLocksmith)); break;
+ case "Run": NavigationFrame.Navigate(typeof(OobeRun)); break;
+ case "ImageResizer": NavigationFrame.Navigate(typeof(OobeImageResizer)); break;
+ case "KBM": NavigationFrame.Navigate(typeof(OobeKBM)); break;
+ case "LightSwitch": NavigationFrame.Navigate(typeof(OobeLightSwitch)); break;
+ case "PowerRename": NavigationFrame.Navigate(typeof(OobePowerRename)); break;
+ case "PowerDisplay": NavigationFrame.Navigate(typeof(OobePowerDisplay)); break;
+ case "QuickAccent": NavigationFrame.Navigate(typeof(OobePowerAccent)); break;
+ case "FileExplorer": NavigationFrame.Navigate(typeof(OobeFileExplorer)); break;
+ case "ShortcutGuide": NavigationFrame.Navigate(typeof(OobeShortcutGuide)); break;
+ case "TextExtractor": NavigationFrame.Navigate(typeof(OobePowerOCR)); break;
+ case "MouseUtils": NavigationFrame.Navigate(typeof(OobeMouseUtils)); break;
+ case "MouseWithoutBorders": NavigationFrame.Navigate(typeof(OobeMouseWithoutBorders)); break;
+ case "MeasureTool": NavigationFrame.Navigate(typeof(OobeMeasureTool)); break;
+ case "Hosts": NavigationFrame.Navigate(typeof(OobeHosts)); break;
+ case "RegistryPreview": NavigationFrame.Navigate(typeof(OobeRegistryPreview)); break;
+ case "Peek": NavigationFrame.Navigate(typeof(OobePeek)); break;
+ case "NewPlus": NavigationFrame.Navigate(typeof(OobeNewPlus)); break;
+ case "Workspaces": NavigationFrame.Navigate(typeof(OobeWorkspaces)); break;
+ case "ZoomIt": NavigationFrame.Navigate(typeof(OobeZoomIt)); break;
+ }
}
}
- private void Window_Activated_SetIcon(object sender, WindowActivatedEventArgs args)
+ private void NavigationView_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
+ {
+ if (args.DisplayMode == NavigationViewDisplayMode.Compact || args.DisplayMode == NavigationViewDisplayMode.Minimal)
+ {
+ TitleBarIcon.Margin = new Thickness(0, 0, 8, 0); // Workaround, see XAML comment
+ AppTitleBar.IsPaneToggleButtonVisible = true;
+ }
+ else
+ {
+ TitleBarIcon.Margin = new Thickness(16, 0, 0, 0); // Workaround, see XAML comment
+ AppTitleBar.IsPaneToggleButtonVisible = false;
+ }
+ }
+
+ private void TitleBar_PaneButtonClick(Microsoft.UI.Xaml.Controls.TitleBar sender, object args)
+ {
+ navigationView.IsPaneOpen = !navigationView.IsPaneOpen;
+ }
+
+ private void WhatIsNewItem_Tapped(object sender, TappedRoutedEventArgs e)
+ {
+ ((App)App.Current)!.OpenScoobe();
+ }
+
+ private void Window_Activated(object sender, WindowActivatedEventArgs args)
{
// Set window icon
- _appWindow.SetIcon("Assets\\Settings\\icon.ico");
- }
-
- private void OobeWindow_SizeChanged(object sender, WindowSizeChangedEventArgs args)
- {
- var dpi = NativeMethods.GetDpiForWindow(_hWnd);
- if (_currentDPI != dpi)
- {
- // Reacting to a DPI change. Should not cause a resize -> sizeChanged loop.
- _currentDPI = dpi;
- float scalingFactor = (float)dpi / DefaultDPI;
- int width = (int)(ExpectedWidth * scalingFactor);
- int height = (int)(ExpectedHeight * scalingFactor);
- SizeInt32 size;
- size.Width = width;
- size.Height = height;
- _appWindow.Resize(size);
- }
+ this.SetIcon("Assets\\Settings\\icon.ico");
}
private void Window_Closed(object sender, WindowEventArgs args)
{
- App.ClearOobeWindow();
+ if (navigationView.SelectedItem is NavigationViewItem selectedItem && selectedItem.Tag is string tag)
+ {
+ App.OobeShellViewModel.GetModuleFromTag(tag).LogClosingModuleEvent();
+ }
- var mainWindow = App.GetSettingsWindow();
- if (mainWindow != null)
+ if (App.GetSettingsWindow() is MainWindow mainWindow)
{
mainWindow.CloseHiddenWindow();
}
@@ -134,19 +166,13 @@ namespace Microsoft.PowerToys.Settings.UI
WindowHelper.SetTheme(this, theme);
}
- private void Dispose(bool disposing)
+ private void NavigationView_Loaded(object sender, RoutedEventArgs e)
{
- if (!disposedValue)
+ // Select the first module by default
+ if (navigationView.MenuItems.Count > 0)
{
- disposedValue = true;
+ navigationView.SelectedItem = navigationView.MenuItems[0];
}
}
-
- public void Dispose()
- {
- // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
- Dispose(disposing: true);
- GC.SuppressFinalize(this);
- }
}
}
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/ScoobeWindow.xaml b/src/settings-ui/Settings.UI/SettingsXAML/ScoobeWindow.xaml
index 934229cea1..3e6bb53da5 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/ScoobeWindow.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/ScoobeWindow.xaml
@@ -6,12 +6,95 @@
xmlns:local="using:Microsoft.PowerToys.Settings.UI.OOBE.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:winuiex="using:WinUIEx"
+ Width="1100"
+ Height="700"
MinWidth="480"
MinHeight="480"
+ Activated="Window_Activated"
Closed="Window_Closed"
mc:Ignorable="d">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/ScoobeWindow.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/ScoobeWindow.xaml.cs
index 446d0e2d0d..378df70063 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/ScoobeWindow.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/ScoobeWindow.xaml.cs
@@ -3,29 +3,38 @@
// See the LICENSE file in the project root for more information.
using System;
-
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Text.Json;
+using System.Threading.Tasks;
+using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.OOBE.Views;
-using Microsoft.UI;
-using Microsoft.UI.Windowing;
+using Microsoft.PowerToys.Settings.UI.SerializationContext;
using Microsoft.UI.Xaml;
-using PowerToys.Interop;
-using Windows.Graphics;
+using Microsoft.UI.Xaml.Controls;
+using WinRT.Interop;
using WinUIEx;
-using WinUIEx.Messaging;
namespace Microsoft.PowerToys.Settings.UI
{
- public sealed partial class ScoobeWindow : WindowEx, IDisposable
+ public sealed partial class ScoobeWindow : WindowEx
{
- private const int ExpectedWidth = 1100;
- private const int ExpectedHeight = 700;
- private const int DefaultDPI = 96;
- private int _currentDPI;
- private WindowId _windowId;
- private IntPtr _hWnd;
- private AppWindow _appWindow;
- private bool disposedValue;
+ public static Action OpenMainWindowCallback { get; set; }
+
+ public static void SetOpenMainWindowCallback(Action implementation)
+ {
+ OpenMainWindowCallback = implementation;
+ }
+
+ ///
+ /// Gets the list of release groups loaded from GitHub (grouped by major.minor version).
+ ///
+ public IList> ReleaseGroups { get; private set; }
+
+ private bool _isLoading;
public ScoobeWindow()
{
@@ -34,63 +43,31 @@ namespace Microsoft.PowerToys.Settings.UI
this.InitializeComponent();
- _hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
- _windowId = Win32Interop.GetWindowIdFromWindow(_hWnd);
- _appWindow = AppWindow.GetFromWindowId(_windowId);
- this.Activated += Window_Activated_SetIcon;
- this.ExtendsContentIntoTitleBar = true;
+ SetTitleBar();
- var dpi = NativeMethods.GetDpiForWindow(_hWnd);
- _currentDPI = dpi;
- float scalingFactor = (float)dpi / DefaultDPI;
- int width = (int)(ExpectedWidth * scalingFactor);
- int height = (int)(ExpectedHeight * scalingFactor);
-
- SizeInt32 size;
- size.Width = width;
- size.Height = height;
- _appWindow.Resize(size);
-
- this.SizeChanged += ScoobeWindow_SizeChanged;
-
- var loader = Helpers.ResourceLoaderInstance.ResourceLoader;
- Title = loader.GetString("ScoobeWindow_Title");
-
- ScoobeShellPage.SetOpenMainWindowCallback((Type type) =>
+ SetOpenMainWindowCallback((Type type) =>
{
App.OpenSettingsWindow(type);
});
}
- private void Window_Activated_SetIcon(object sender, WindowActivatedEventArgs args)
+ private void SetTitleBar()
{
- // Set window icon
- _appWindow.SetIcon("Assets\\Settings\\icon.ico");
+ WindowHelpers.ForceTopBorder1PixelInsetOnWindows10(WindowNative.GetWindowHandle(this));
+ this.ExtendsContentIntoTitleBar = true;
+ this.SetTitleBar(AppTitleBar);
+ Title = ResourceLoaderInstance.ResourceLoader.GetString("ScoobeWindow_Title");
}
- private void ScoobeWindow_SizeChanged(object sender, WindowSizeChangedEventArgs args)
+ private void Window_Activated(object sender, WindowActivatedEventArgs args)
{
- var dpi = NativeMethods.GetDpiForWindow(_hWnd);
- if (_currentDPI != dpi)
- {
- // Reacting to a DPI change. Should not cause a resize -> sizeChanged loop.
- _currentDPI = dpi;
- float scalingFactor = (float)dpi / DefaultDPI;
- int width = (int)(ExpectedWidth * scalingFactor);
- int height = (int)(ExpectedHeight * scalingFactor);
- SizeInt32 size;
- size.Width = width;
- size.Height = height;
- _appWindow.Resize(size);
- }
+ // Set window icon
+ this.SetIcon("Assets\\Settings\\icon.ico");
}
private void Window_Closed(object sender, WindowEventArgs args)
{
- App.ClearScoobeWindow();
-
- var mainWindow = App.GetSettingsWindow();
- if (mainWindow != null)
+ if (App.GetSettingsWindow() is MainWindow mainWindow)
{
mainWindow.CloseHiddenWindow();
}
@@ -103,19 +80,133 @@ namespace Microsoft.PowerToys.Settings.UI
WindowHelper.SetTheme(this, theme);
}
- private void Dispose(bool disposing)
+ private async void NavigationView_Loaded(object sender, RoutedEventArgs e)
{
- if (!disposedValue)
+ await LoadReleasesAsync();
+ }
+
+ private async Task LoadReleasesAsync()
+ {
+ if (_isLoading)
{
- disposedValue = true;
+ return;
+ }
+
+ _isLoading = true;
+ LoadingProgressRing.Visibility = Visibility.Visible;
+ ErrorInfoBar.IsOpen = false;
+ navigationView.MenuItems.Clear();
+
+ try
+ {
+ var releases = await FetchReleasesFromGitHubAsync();
+ ReleaseGroups = GroupReleasesByMajorMinor(releases);
+ PopulateNavigationItems();
+ }
+ catch (Exception ex)
+ {
+ Logger.LogError("Failed to load releases", ex);
+ ErrorInfoBar.IsOpen = true;
+ }
+ finally
+ {
+ LoadingProgressRing.Visibility = Visibility.Collapsed;
+ _isLoading = false;
}
}
- public void Dispose()
+ private static async Task> FetchReleasesFromGitHubAsync()
{
- // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
- Dispose(disposing: true);
- GC.SuppressFinalize(this);
+ using var proxyClientHandler = new HttpClientHandler
+ {
+ DefaultProxyCredentials = CredentialCache.DefaultCredentials,
+ Proxy = WebRequest.GetSystemWebProxy(),
+ PreAuthenticate = true,
+ };
+
+ using var httpClient = new HttpClient(proxyClientHandler);
+ httpClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "PowerToys");
+
+ string json = await httpClient.GetStringAsync("https://api.github.com/repos/microsoft/PowerToys/releases?per_page=20");
+ var allReleases = JsonSerializer.Deserialize>(json, SourceGenerationContextContext.Default.IListPowerToysReleaseInfo);
+
+ if (allReleases is null || allReleases.Count == 0)
+ {
+ return [];
+ }
+
+ return allReleases
+ .OrderByDescending(r => r.PublishedDate)
+ .ToList();
+ }
+
+ private static IList> GroupReleasesByMajorMinor(IList releases)
+ {
+ return releases
+ .GroupBy(GetMajorMinorVersion)
+ .Select(g => g.OrderByDescending(r => r.PublishedDate).ToList() as IList)
+ .ToList();
+ }
+
+ private static string GetMajorMinorVersion(PowerToysReleaseInfo release)
+ {
+ string version = ScoobeReleaseGroupViewModel.GetVersionFromRelease(release);
+ var parts = version.Split('.');
+ if (parts.Length >= 2)
+ {
+ return $"{parts[0]}.{parts[1]}";
+ }
+
+ return version;
+ }
+
+ private void PopulateNavigationItems()
+ {
+ if (ReleaseGroups == null || ReleaseGroups.Count == 0)
+ {
+ return;
+ }
+
+ foreach (var releaseGroup in ReleaseGroups)
+ {
+ var viewModel = new ScoobeReleaseGroupViewModel(releaseGroup);
+ navigationView.MenuItems.Add(viewModel);
+ }
+
+ // Select the first item to trigger navigation
+ navigationView.SelectedItem = navigationView.MenuItems[0];
+ }
+
+ private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
+ {
+ if (args.SelectedItem is ScoobeReleaseGroupViewModel viewModel)
+ {
+ NavigationFrame.Navigate(typeof(ScoobeReleaseNotesPage), viewModel.Releases);
+ }
+ }
+
+ private async void RetryButton_Click(object sender, RoutedEventArgs e)
+ {
+ await LoadReleasesAsync();
+ }
+
+ private void NavigationView_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args)
+ {
+ if (args.DisplayMode == NavigationViewDisplayMode.Compact || args.DisplayMode == NavigationViewDisplayMode.Minimal)
+ {
+ TitleBarIcon.Margin = new Thickness(0, 0, 8, 0); // Workaround, see XAML comment
+ AppTitleBar.IsPaneToggleButtonVisible = true;
+ }
+ else
+ {
+ TitleBarIcon.Margin = new Thickness(16, 0, 0, 0); // Workaround, see XAML comment
+ AppTitleBar.IsPaneToggleButtonVisible = false;
+ }
+ }
+
+ private void TitleBar_PaneButtonClick(Microsoft.UI.Xaml.Controls.TitleBar sender, object args)
+ {
+ navigationView.IsPaneOpen = !navigationView.IsPaneOpen;
}
}
}
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/AdvancedPastePage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/AdvancedPastePage.xaml
index bc2c9d2840..95bfab7ad2 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/AdvancedPastePage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/AdvancedPastePage.xaml
@@ -21,15 +21,12 @@
- ms-appx:///Assets/Settings/Modules/APDialog.dark.pngms-appx:///Assets/Settings/Icons/Models/OpenAI.dark.svg
- ms-appx:///Assets/Settings/Modules/APDialog.light.pngms-appx:///Assets/Settings/Icons/Models/OpenAI.light.svg
- ms-appx:///Assets/Settings/Modules/APDialog.light.pngms-appx:///Assets/Settings/Icons/Models/OpenAI.light.svg
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/CmdPalPage.xaml b/src/settings-ui/Settings.UI/SettingsXAML/Views/CmdPalPage.xaml
index b34a516f58..e18927bcb9 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/CmdPalPage.xaml
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/CmdPalPage.xaml
@@ -28,7 +28,10 @@
-
+
@@ -40,17 +43,24 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/DashboardPage.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Views/DashboardPage.xaml.cs
index ceff1c7918..c697199249 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/DashboardPage.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/DashboardPage.xaml.cs
@@ -48,12 +48,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
private void WhatsNewButton_Click(object sender, RoutedEventArgs e)
{
- if (App.GetScoobeWindow() == null)
- {
- App.SetScoobeWindow(new ScoobeWindow());
- }
-
- App.GetScoobeWindow().Activate();
+ ((App)App.Current)!.OpenScoobe();
}
private void SortAlphabetical_Click(object sender, RoutedEventArgs e)
diff --git a/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs b/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs
index c8f3284432..7515cad863 100644
--- a/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs
+++ b/src/settings-ui/Settings.UI/SettingsXAML/Views/ShellPage.xaml.cs
@@ -48,16 +48,6 @@ namespace Microsoft.PowerToys.Settings.UI.Views
///
public delegate bool UpdatingGeneralSettingsCallback(ModuleType moduleType, bool isEnabled);
- ///
- /// Declaration for opening oobe window callback function.
- ///
- public delegate void OobeOpeningCallback();
-
- ///
- /// Declaration for opening whats new window callback function.
- ///
- public delegate void WhatIsNewOpeningCallback();
-
///
/// Gets or sets a shell handler to be used to update contents of the shell dynamically from page within the frame.
///
@@ -88,16 +78,6 @@ namespace Microsoft.PowerToys.Settings.UI.Views
///
public static UpdatingGeneralSettingsCallback UpdateGeneralSettingsCallback { get; set; }
- ///
- /// Gets or sets callback function for opening oobe window
- ///
- public static OobeOpeningCallback OpenOobeWindowCallback { get; set; }
-
- ///
- /// Gets or sets callback function for opening oobe window
- ///
- public static WhatIsNewOpeningCallback OpenWhatIsNewWindowCallback { get; set; }
-
///
/// Gets view model.
///
@@ -223,24 +203,6 @@ namespace Microsoft.PowerToys.Settings.UI.Views
UpdateGeneralSettingsCallback = implementation;
}
- ///
- /// Set oobe opening callback function
- ///
- /// delegate function implementation.
- public static void SetOpenOobeCallback(OobeOpeningCallback implementation)
- {
- OpenOobeWindowCallback = implementation;
- }
-
- ///
- /// Set whats new opening callback function
- ///
- /// delegate function implementation.
- public static void SetOpenWhatIsNewCallback(WhatIsNewOpeningCallback implementation)
- {
- OpenWhatIsNewWindowCallback = implementation;
- }
-
public static void SetElevationStatus(bool isElevated)
{
IsElevated = isElevated;
@@ -325,7 +287,12 @@ namespace Microsoft.PowerToys.Settings.UI.Views
private void OOBEItem_Tapped(object sender, TappedRoutedEventArgs e)
{
- OpenOobeWindowCallback();
+ ((App)App.Current)!.OpenOobe();
+ }
+
+ private void WhatIsNewItem_Tapped(object sender, TappedRoutedEventArgs e)
+ {
+ ((App)App.Current)!.OpenScoobe();
}
private async void FeedbackItem_Tapped(object sender, TappedRoutedEventArgs e)
@@ -333,15 +300,9 @@ namespace Microsoft.PowerToys.Settings.UI.Views
await Launcher.LaunchUriAsync(new Uri("https://aka.ms/powerToysGiveFeedback"));
}
- private void WhatIsNewItem_Tapped(object sender, TappedRoutedEventArgs e)
- {
- OpenWhatIsNewWindowCallback();
- }
-
private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{
- NavigationViewItem selectedItem = args.SelectedItem as NavigationViewItem;
- if (selectedItem != null)
+ if (args.SelectedItem is NavigationViewItem selectedItem)
{
Type pageType = selectedItem.GetValue(NavHelper.NavigateToProperty) as Type;
@@ -409,7 +370,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
navigationView.IsPaneOpen = !navigationView.IsPaneOpen;
}
- private async void Close_Tapped(object sender, Microsoft.UI.Xaml.Input.TappedRoutedEventArgs e)
+ private async void Close_Tapped(object sender, TappedRoutedEventArgs e)
{
await CloseDialog.ShowAsync();
}
diff --git a/src/settings-ui/Settings.UI/ViewModels/ZoomItViewModel.cs b/src/settings-ui/Settings.UI/ViewModels/ZoomItViewModel.cs
index b925782191..ccadf776ff 100644
--- a/src/settings-ui/Settings.UI/ViewModels/ZoomItViewModel.cs
+++ b/src/settings-ui/Settings.UI/ViewModels/ZoomItViewModel.cs
@@ -8,8 +8,8 @@ using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.Json;
-using AllExperiments;
using global::PowerToys.GPOWrapper;
+using ManagedCommon;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Library;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;