diff --git a/PowerToys.sln b/PowerToys.sln index b17039b9f..dbce787a2 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 -VisualStudioVersion = 16.0.28803.452 +VisualStudioVersion = 16.0.31410.357 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runner", "src\runner\runner.vcxproj", "{9412D5C6-2CF2-4FC2-A601-B55508EA9B27}" ProjectSection(ProjectDependencies) = postProject @@ -363,6 +363,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoConferenceProxyFilter" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "VideoConference", "VideoConference", "{470FBAF9-E1F8-4F3E-8786-198A1C81C8A8}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloModule", "src\modules\HelloModule\HelloModule.csproj", "{841BAE3A-60D7-492F-85FD-B1F3D2455CA1}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PdfThumbnailProvider", "src\modules\previewpane\PdfThumbnailProvider\PdfThumbnailProvider.csproj", "{11491FD8-F921-48BF-880C-7FEA185B80A1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests-PdfThumbnailProvider", "src\modules\previewpane\UnitTests-PdfThumbnailProvider\UnitTests-PdfThumbnailProvider.csproj", "{F40C3397-1834-4530-B2D9-8F8B8456BCDF}" @@ -953,6 +955,18 @@ Global {AC2857B4-103D-4D6D-9740-926EBF785042}.Release|x64.Build.0 = Release|x64 {AC2857B4-103D-4D6D-9740-926EBF785042}.Release|x86.ActiveCfg = Release|Win32 {AC2857B4-103D-4D6D-9740-926EBF785042}.Release|x86.Build.0 = Release|Win32 + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1}.Debug|x64.ActiveCfg = Debug|x64 + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1}.Debug|x64.Build.0 = Debug|x64 + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1}.Debug|x64.Deploy.0 = Debug|x64 + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1}.Debug|x86.ActiveCfg = Debug|x86 + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1}.Debug|x86.Build.0 = Debug|x86 + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1}.Debug|x86.Deploy.0 = Debug|x86 + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1}.Release|x64.ActiveCfg = Release|x64 + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1}.Release|x64.Build.0 = Release|x64 + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1}.Release|x64.Deploy.0 = Release|x64 + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1}.Release|x86.ActiveCfg = Release|x86 + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1}.Release|x86.Build.0 = Release|x86 + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1}.Release|x86.Deploy.0 = Release|x86 {11491FD8-F921-48BF-880C-7FEA185B80A1}.Debug|x64.ActiveCfg = Debug|x64 {11491FD8-F921-48BF-880C-7FEA185B80A1}.Debug|x64.Build.0 = Debug|x64 {11491FD8-F921-48BF-880C-7FEA185B80A1}.Debug|x86.ActiveCfg = Debug|x64 @@ -1078,6 +1092,7 @@ Global {5ABA70DE-3A3F-41F6-A1F5-D1F74F54F9BB} = {470FBAF9-E1F8-4F3E-8786-198A1C81C8A8} {AC2857B4-103D-4D6D-9740-926EBF785042} = {470FBAF9-E1F8-4F3E-8786-198A1C81C8A8} {470FBAF9-E1F8-4F3E-8786-198A1C81C8A8} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC} + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC} {11491FD8-F921-48BF-880C-7FEA185B80A1} = {2F305555-C296-497E-AC20-5FA1B237996A} {F40C3397-1834-4530-B2D9-8F8B8456BCDF} = {2F305555-C296-497E-AC20-5FA1B237996A} EndGlobalSection diff --git a/src/modules/HelloModule/App.xaml b/src/modules/HelloModule/App.xaml new file mode 100644 index 000000000..81bb3d54e --- /dev/null +++ b/src/modules/HelloModule/App.xaml @@ -0,0 +1,7 @@ + + + diff --git a/src/modules/HelloModule/App.xaml.cs b/src/modules/HelloModule/App.xaml.cs new file mode 100644 index 000000000..24de58095 --- /dev/null +++ b/src/modules/HelloModule/App.xaml.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.ApplicationModel; +using Windows.ApplicationModel.Activation; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +namespace HelloModule +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + sealed partial class App : Application + { + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + this.InitializeComponent(); + this.Suspending += OnSuspending; + } + + /// + /// Invoked when the application is launched normally by the end user. Other entry points + /// 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(LaunchActivatedEventArgs e) + { + Frame rootFrame = Window.Current.Content as Frame; + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (rootFrame == null) + { + // Create a Frame to act as the navigation context and navigate to the first page + rootFrame = new Frame(); + + rootFrame.NavigationFailed += OnNavigationFailed; + + if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) + { + //TODO: Load state from previously suspended application + } + + // Place the frame in the current Window + Window.Current.Content = rootFrame; + } + + if (e.PrelaunchActivated == false) + { + if (rootFrame.Content == null) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame.Navigate(typeof(MainPage), e.Arguments); + } + // Ensure the current window is active + Window.Current.Activate(); + } + } + + /// + /// Invoked when Navigation to a certain page fails + /// + /// The Frame which failed navigation + /// Details about the navigation failure + void OnNavigationFailed(object sender, NavigationFailedEventArgs e) + { + throw new Exception("Failed to load Page " + e.SourcePageType.FullName); + } + + /// + /// Invoked when application execution is being suspended. Application state is saved + /// without knowing whether the application will be terminated or resumed with the contents + /// of memory still intact. + /// + /// The source of the suspend request. + /// Details about the suspend request. + private void OnSuspending(object sender, SuspendingEventArgs e) + { + var deferral = e.SuspendingOperation.GetDeferral(); + //TODO: Save application state and stop any background activity + deferral.Complete(); + } + } +} diff --git a/src/modules/HelloModule/Assets/LockScreenLogo.scale-200.png b/src/modules/HelloModule/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 000000000..735f57adb Binary files /dev/null and b/src/modules/HelloModule/Assets/LockScreenLogo.scale-200.png differ diff --git a/src/modules/HelloModule/Assets/SplashScreen.scale-200.png b/src/modules/HelloModule/Assets/SplashScreen.scale-200.png new file mode 100644 index 000000000..023e7f1fe Binary files /dev/null and b/src/modules/HelloModule/Assets/SplashScreen.scale-200.png differ diff --git a/src/modules/HelloModule/Assets/Square150x150Logo.scale-200.png b/src/modules/HelloModule/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 000000000..af49fec1a Binary files /dev/null and b/src/modules/HelloModule/Assets/Square150x150Logo.scale-200.png differ diff --git a/src/modules/HelloModule/Assets/Square44x44Logo.scale-200.png b/src/modules/HelloModule/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 000000000..ce342a2ec Binary files /dev/null and b/src/modules/HelloModule/Assets/Square44x44Logo.scale-200.png differ diff --git a/src/modules/HelloModule/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/src/modules/HelloModule/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 000000000..f6c02ce97 Binary files /dev/null and b/src/modules/HelloModule/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/src/modules/HelloModule/Assets/StoreLogo.png b/src/modules/HelloModule/Assets/StoreLogo.png new file mode 100644 index 000000000..7385b56c0 Binary files /dev/null and b/src/modules/HelloModule/Assets/StoreLogo.png differ diff --git a/src/modules/HelloModule/Assets/Wide310x150Logo.scale-200.png b/src/modules/HelloModule/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 000000000..288995b39 Binary files /dev/null and b/src/modules/HelloModule/Assets/Wide310x150Logo.scale-200.png differ diff --git a/src/modules/HelloModule/HelloModule.csproj b/src/modules/HelloModule/HelloModule.csproj new file mode 100644 index 000000000..05817d023 --- /dev/null +++ b/src/modules/HelloModule/HelloModule.csproj @@ -0,0 +1,179 @@ + + + + + Debug + x86 + {841BAE3A-60D7-492F-85FD-B1F3D2455CA1} + AppContainerExe + Properties + HelloModule + HelloModule + en-US + UAP + 10.0.19041.0 + 10.0.17763.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + true + True + False + False + False + True + Never + 0 + HelloModule_TemporaryKey.pfx + SHA256 + + + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x86 + false + prompt + true + + + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x86 + false + prompt + true + true + + + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM + false + prompt + true + + + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM + false + prompt + true + true + + + true + bin\ARM64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM64 + false + prompt + true + true + + + bin\ARM64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM64 + false + prompt + true + true + + + true + bin\x64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x64 + false + prompt + true + + + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x64 + false + prompt + true + true + + + PackageReference + + + + App.xaml + + + MainPage.xaml + + + + + + Designer + + + + + + + + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + 6.2.12 + + + + + + + 14.0 + + + + \ No newline at end of file diff --git a/src/modules/HelloModule/MainPage.xaml b/src/modules/HelloModule/MainPage.xaml new file mode 100644 index 000000000..bdd853c96 --- /dev/null +++ b/src/modules/HelloModule/MainPage.xaml @@ -0,0 +1,16 @@ + + + + + + + + diff --git a/src/modules/HelloModule/MainPage.xaml.cs b/src/modules/HelloModule/MainPage.xaml.cs new file mode 100644 index 000000000..5fff1c0b6 --- /dev/null +++ b/src/modules/HelloModule/MainPage.xaml.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using System.Threading.Tasks; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.Storage; +using Windows.System; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 + +namespace HelloModule +{ + public class MainViewModel : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChangedEventHandler handler = PropertyChanged; + if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); + } + protected bool SetField(ref T field, T value, string propertyName) + { + if (EqualityComparer.Default.Equals(field, value)) return false; + field = value; + OnPropertyChanged(propertyName); + return true; + } + + + private string _stripProp; + public string StringProp + { + get + { + return _stripProp; + } + + set + { + if (value != _stripProp) + { + _stripProp = value; + OnPropertyChanged(nameof(StringProp)); + } + } + } + } + + + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class MainPage : Page + { + private async Task LoadSettings() + { + try + { + var path = UserDataPaths.GetDefault().LocalAppData; + path += "\\Microsoft\\PowerToys\\Hello World\\settings.json"; + var f = await StorageFile.GetFileFromPathAsync(path); + return await FileIO.ReadTextAsync(f); + + } + catch (Exception) + { + // from https://stackoverflow.com/a/53533414/657390 + await Launcher.LaunchUriAsync(new Uri("ms-settings:appsfeatures-app")); + return "Please enable filesystem for your app"; + } + + } + + public MainViewModel ViewModel { get; set; } + public MainPage() + { + this.InitializeComponent(); + ViewModel = new MainViewModel(); + DataContext = ViewModel; + } + + public async void Button_Click(object sender, RoutedEventArgs e) + { + Button btn = sender as Button; + MainPage content = btn.FindName("TheMainPage") as MainPage; + content.ViewModel.StringProp = await LoadSettings(); + } + + } + +} diff --git a/src/modules/HelloModule/Package.appxmanifest b/src/modules/HelloModule/Package.appxmanifest new file mode 100644 index 000000000..39e35a281 --- /dev/null +++ b/src/modules/HelloModule/Package.appxmanifest @@ -0,0 +1,51 @@ + + + + + + + + + + HelloModule + yuyoyuppe + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/modules/HelloModule/Properties/AssemblyInfo.cs b/src/modules/HelloModule/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..3b8a11a33 --- /dev/null +++ b/src/modules/HelloModule/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("HelloModule")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("HelloModule")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/src/modules/HelloModule/Properties/Default.rd.xml b/src/modules/HelloModule/Properties/Default.rd.xml new file mode 100644 index 000000000..af00722cd --- /dev/null +++ b/src/modules/HelloModule/Properties/Default.rd.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/EnabledModules.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/EnabledModules.cs index 227ebb948..97cd8363e 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/EnabledModules.cs +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/EnabledModules.cs @@ -159,6 +159,22 @@ namespace Microsoft.PowerToys.Settings.UI.Library } } + private bool helloWorld = true; + + [JsonPropertyName("HelloWorld")] + public bool HelloWorld + { + get => helloWorld; + set + { + if (helloWorld != value) + { + LogTelemetryEvent(value); + helloWorld = value; + } + } + } + private bool awake; [JsonPropertyName("Awake")] diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/Microsoft.PowerToys.Settings.UI.Library.csproj b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/Microsoft.PowerToys.Settings.UI.Library.csproj index dd61ee54f..63db56934 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/Microsoft.PowerToys.Settings.UI.Library.csproj +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/Microsoft.PowerToys.Settings.UI.Library.csproj @@ -14,7 +14,7 @@ Github PowerToys en-US - true + false Microsoft.PowerToys.Settings.UI.Lib @@ -27,6 +27,7 @@ x64 + diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj index 4a1595a5d..53d649691 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Microsoft.PowerToys.Settings.UI.csproj @@ -68,6 +68,7 @@ false prompt true + false ..\..\..\x64\Release\SettingsUI\ @@ -80,6 +81,7 @@ prompt true false + false PackageReference @@ -105,7 +107,7 @@ ShortcutDialogContentControl.xaml - + ShortcutWithTextLabelControl.xaml @@ -186,6 +188,9 @@ GeneralPage.xaml + + HelloWorldPage.xaml + ImageResizerPage.xaml @@ -421,6 +426,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw index 09e1f3aba..95352d320 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw @@ -228,6 +228,11 @@ Shortcut Guide Product name: Navigation view item name for Shortcut Guide + + Hello World + Product name: Navigation view item name for Hello World + + File Explorer add-ons Product name: Navigation view item name for File Explorer. Please use File Explorer as in the context of File Explorer in Windows diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/HelloWorldPage.xaml b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/HelloWorldPage.xaml new file mode 100644 index 000000000..cf58a5f2b --- /dev/null +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/HelloWorldPage.xaml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/HelloWorldPage.xaml.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/HelloWorldPage.xaml.cs new file mode 100644 index 000000000..34793b5f7 --- /dev/null +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/HelloWorldPage.xaml.cs @@ -0,0 +1,284 @@ +// 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.Runtime.CompilerServices; +using System.Text.Json.Serialization; +using Microsoft.PowerToys.Settings.UI.Helpers; +using Microsoft.PowerToys.Settings.UI.Library; +using Microsoft.PowerToys.Settings.UI.Library.Interfaces; +using Microsoft.PowerToys.Settings.UI.Library.ViewModels; +using Windows.UI.Xaml.Controls; + +namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels +{ + public class HelloWorldViewModel : Observable + { + private ISettingsUtils SettingsUtils { get; set; } + + private GeneralSettings GeneralSettingsConfig { get; set; } + + private HelloWorldSettings Settings { get; set; } + + private const string ModuleName = HelloWorldSettings.ModuleName; + + private Func SendConfigMSG { get; } + + private string _settingsConfigFileFolder = string.Empty; + private string _stringProp; + + public HelloWorldViewModel(ISettingsUtils settingsUtils, ISettingsRepository settingsRepository, ISettingsRepository moduleSettingsRepository, Func ipcMSGCallBackFunc, string configFileSubfolder = "") + { + SettingsUtils = settingsUtils; + + // Update Settings file folder: + _settingsConfigFileFolder = configFileSubfolder; + + // To obtain the general PowerToys settings. + if (settingsRepository == null) + { + throw new ArgumentNullException(nameof(settingsRepository)); + } + + GeneralSettingsConfig = settingsRepository.SettingsConfig; + + // To obtain the shortcut guide settings, if the file exists. + // If not, to create a file with the default settings and to return the default configurations. + if (moduleSettingsRepository == null) + { + throw new ArgumentNullException(nameof(moduleSettingsRepository)); + } + + Settings = moduleSettingsRepository.SettingsConfig; + + // set the callback functions value to hangle outgoing IPC message. + SendConfigMSG = ipcMSGCallBackFunc; + + _isEnabled = GeneralSettingsConfig.Enabled.HelloWorld; + _stringProp = Settings.Properties.StringProp.Value; + } + + private bool _isEnabled; + + public bool IsEnabled + { + get + { + return _isEnabled; + } + + set + { + if (value != _isEnabled) + { + _isEnabled = value; + + // To update the status of shortcut guide in General PowerToy settings. + GeneralSettingsConfig.Enabled.HelloWorld = value; + OutGoingGeneralSettings snd = new OutGoingGeneralSettings(GeneralSettingsConfig); + + OnPropertyChanged(nameof(IsEnabled)); + } + } + } + + public string StringProp + { + get + { + return _stringProp; + } + + set + { + if (value != _stringProp) + { + _stringProp = value; + Settings.Properties.StringProp.Value = value; + NotifyPropertyChanged(); + } + } + } + + public string GetSettingsSubPath() + { + return _settingsConfigFileFolder + "\\" + ModuleName; + } + + public void NotifyPropertyChanged([CallerMemberName] string propertyName = null) + { + OnPropertyChanged(propertyName); + + SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName); + } + } +} + +namespace Microsoft.PowerToys.Settings.UI.Library +{ + public class HelloWorldProperties + { + public HelloWorldProperties() + { + StringProp = new StringProperty(); + } + + [JsonPropertyName("string_prop")] + public StringProperty StringProp { get; set; } + } + + public class HelloWorldSettings : BasePTModuleSettings, ISettingsConfig + { + public const string ModuleName = "Hello World"; + + [JsonPropertyName("properties")] + public HelloWorldProperties Properties { get; set; } + + public HelloWorldSettings() + { + Name = ModuleName; + Properties = new HelloWorldProperties(); + Version = "1.0"; + } + + public string GetModuleName() + { + return Name; + } + + // This can be utilized in the future if the settings.json file is to be modified/deleted. + public bool UpgradeSettingsConfiguration() + { + return false; + } + } +} + +namespace Microsoft.PowerToys.Settings.UI.ViewModels +{ + public class HelloWorldViewModel : Observable + { + private ISettingsUtils SettingsUtils { get; set; } + + private GeneralSettings GeneralSettingsConfig { get; set; } + + private HelloWorldSettings Settings { get; set; } + + private const string ModuleName = HelloWorldSettings.ModuleName; + + private Func SendConfigMSG { get; } + + private string _settingsConfigFileFolder = string.Empty; + private string _stringProp; + + public HelloWorldViewModel(ISettingsUtils settingsUtils, ISettingsRepository settingsRepository, ISettingsRepository moduleSettingsRepository, Func ipcMSGCallBackFunc, string configFileSubfolder = "") + { + SettingsUtils = settingsUtils; + + // Update Settings file folder: + _settingsConfigFileFolder = configFileSubfolder; + + // To obtain the general PowerToys settings. + if (settingsRepository == null) + { + throw new ArgumentNullException(nameof(settingsRepository)); + } + + GeneralSettingsConfig = settingsRepository.SettingsConfig; + + // To obtain the shortcut guide settings, if the file exists. + // If not, to create a file with the default settings and to return the default configurations. + if (moduleSettingsRepository == null) + { + throw new ArgumentNullException(nameof(moduleSettingsRepository)); + } + + Settings = moduleSettingsRepository.SettingsConfig; + + // set the callback functions value to hangle outgoing IPC message. + SendConfigMSG = ipcMSGCallBackFunc; + + _isEnabled = GeneralSettingsConfig.Enabled.HelloWorld; + _stringProp = Settings.Properties.StringProp.Value; + } + + private bool _isEnabled; + + public bool IsEnabled + { + get + { + return _isEnabled; + } + + set + { + if (value != _isEnabled) + { + _isEnabled = value; + + // To update the status of shortcut guide in General PowerToy settings. + GeneralSettingsConfig.Enabled.HelloWorld = value; + OutGoingGeneralSettings snd = new OutGoingGeneralSettings(GeneralSettingsConfig); + + SendConfigMSG(snd.ToString()); + OnPropertyChanged(nameof(IsEnabled)); + } + } + } + + public string DisabledApps + { + get + { + return _stringProp; + } + + set + { + if (value != _stringProp) + { + _stringProp = value; + Settings.Properties.StringProp.Value = value; + NotifyPropertyChanged(); + } + } + } + + public string GetSettingsSubPath() + { + return _settingsConfigFileFolder + "\\" + ModuleName; + } + + public void NotifyPropertyChanged([CallerMemberName] string propertyName = null) + { + OnPropertyChanged(propertyName); + + SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName); + } + } + +} + + +namespace Microsoft.PowerToys.Settings.UI.Views +{ + public sealed partial class HelloWorldPage : Page + { + private HelloWorldViewModel ViewModel { get; set; } + + public HelloWorldPage() + { + InitializeComponent(); + + var settingsUtils = new SettingsUtils(); + ViewModel = new HelloWorldViewModel(settingsUtils, SettingsRepository.GetInstance(settingsUtils), SettingsRepository.GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage); + DataContext = ViewModel; + } + + private void OpenColorsSettings_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) + { + Helpers.StartProcessHelper.Start(Helpers.StartProcessHelper.ColorsSettings); + } + } +} diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/ShellPage.xaml b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/ShellPage.xaml index 6bf5be0c5..d4fef76ab 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/ShellPage.xaml +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/ShellPage.xaml @@ -129,7 +129,16 @@ ShowAsMonochrome="False" /> - + + + + + + +