// 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.IO; namespace PowerDisplay.Common { /// /// Centralized path constants for PowerDisplay module. /// Provides unified access to all file and folder paths used by PowerDisplay and related integrations. /// public static class PathConstants { private static readonly Lazy _localAppDataPath = new Lazy( () => Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)); private static readonly Lazy _powerToysBasePath = new Lazy( () => Path.Combine(_localAppDataPath.Value, "Microsoft", "PowerToys")); /// /// Gets the base PowerToys settings folder path. /// Example: C:\Users\{User}\AppData\Local\Microsoft\PowerToys /// public static string PowerToysBasePath => _powerToysBasePath.Value; /// /// Gets the PowerDisplay module folder path. /// Example: C:\Users\{User}\AppData\Local\Microsoft\PowerToys\PowerDisplay /// public static string PowerDisplayFolderPath => Path.Combine(PowerToysBasePath, "PowerDisplay"); /// /// Gets the PowerDisplay profiles file path. /// Example: C:\Users\{User}\AppData\Local\Microsoft\PowerToys\PowerDisplay\profiles.json /// public static string ProfilesFilePath => Path.Combine(PowerDisplayFolderPath, ProfilesFileName); /// /// Gets the PowerDisplay settings file path. /// Example: C:\Users\{User}\AppData\Local\Microsoft\PowerToys\PowerDisplay\settings.json /// public static string SettingsFilePath => Path.Combine(PowerDisplayFolderPath, SettingsFileName); /// /// Gets the LightSwitch module folder path. /// Example: C:\Users\{User}\AppData\Local\Microsoft\PowerToys\LightSwitch /// public static string LightSwitchFolderPath => Path.Combine(PowerToysBasePath, "LightSwitch"); /// /// Gets the LightSwitch settings file path. /// Example: C:\Users\{User}\AppData\Local\Microsoft\PowerToys\LightSwitch\settings.json /// public static string LightSwitchSettingsFilePath => Path.Combine(LightSwitchFolderPath, SettingsFileName); /// /// The name of the profiles file. /// public const string ProfilesFileName = "profiles.json"; /// /// The name of the settings file. /// public const string SettingsFileName = "settings.json"; /// /// The name of the monitor state file. /// public const string MonitorStateFileName = "monitor_state.json"; /// /// Gets the monitor state file path. /// Example: C:\Users\{User}\AppData\Local\Microsoft\PowerToys\PowerDisplay\monitor_state.json /// public static string MonitorStateFilePath => Path.Combine(PowerDisplayFolderPath, MonitorStateFileName); /// /// Event name for LightSwitch light theme change notifications. /// Signaled when LightSwitch switches to light mode. /// Must match CommonSharedConstants::LIGHT_SWITCH_LIGHT_THEME_EVENT in shared_constants.h. /// public const string LightSwitchLightThemeEventName = "Local\\PowerToysLightSwitch-LightThemeEvent-50077121-2ffc-4841-9c86-ab1bd3f9baca"; /// /// Event name for LightSwitch dark theme change notifications. /// Signaled when LightSwitch switches to dark mode. /// Must match CommonSharedConstants::LIGHT_SWITCH_DARK_THEME_EVENT in shared_constants.h. /// public const string LightSwitchDarkThemeEventName = "Local\\PowerToysLightSwitch-DarkThemeEvent-b3a835c0-eaa2-49b0-b8eb-f793e3df3368"; /// /// Ensures the PowerDisplay folder exists. Creates it if necessary. /// /// The PowerDisplay folder path public static string EnsurePowerDisplayFolderExists() => EnsureFolderExists(PowerDisplayFolderPath); /// /// Ensures the LightSwitch folder exists. Creates it if necessary. /// /// The LightSwitch folder path public static string EnsureLightSwitchFolderExists() => EnsureFolderExists(LightSwitchFolderPath); /// /// Ensures the specified folder exists. Creates it if necessary. /// /// The folder path to ensure exists /// The folder path private static string EnsureFolderExists(string folderPath) { if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } return folderPath; } } }