[AlwaysOnTop] Proof of concept (#14360)

Co-authored-by: Niels Laute <niels.laute@live.nl>
This commit is contained in:
Seraphima Zykova
2021-12-29 20:33:20 +03:00
committed by GitHub
parent d39c4121a9
commit fa81968dbb
60 changed files with 2859 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Enums
public enum PowerToysModulesEnum
{
Overview = 0,
AlwaysOnTop,
Awake,
ColorPicker,
FancyZones,

View File

@@ -0,0 +1,41 @@
<Page
x:Class="Microsoft.PowerToys.Settings.UI.OOBE.Views.OobeAlwaysOnTop"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Microsoft.PowerToys.Settings.UI.OOBE.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
xmlns:toolkitcontrols="using:Microsoft.Toolkit.Uwp.UI.Controls">
<controls:OOBEPageControl ModuleTitle="{x:Bind ViewModel.ModuleName}"
ModuleImageSource="{x:Bind ViewModel.PreviewImageSource}"
ModuleDescription="{x:Bind ViewModel.Description}">
<controls:OOBEPageControl.ModuleContent>
<StackPanel Orientation="Vertical">
<TextBlock x:Uid="Oobe_HowToUse"
Style="{ThemeResource OobeSubtitleStyle}" />
<controls:ShortcutWithTextLabelControl x:Name="HotkeyControl" x:Uid="Oobe_AlwaysOnTop_HowToUse" />
<TextBlock x:Uid="Oobe_TipsAndTricks"
Style="{ThemeResource OobeSubtitleStyle}"/>
<toolkitcontrols:MarkdownTextBlock Background="Transparent" x:Uid="Oobe_AlwaysOnTop_TipsAndTricks" />
<StackPanel Orientation="Horizontal" Spacing="12" Margin="0,24,0,0">
<Button x:Uid="OOBE_Settings"
Click="SettingsLaunchButton_Click"/>
<HyperlinkButton NavigateUri="{x:Bind ViewModel.Link}"
Style="{StaticResource TextButtonStyle}">
<TextBlock x:Uid="LearnMore_AlwaysOnTop"
TextWrapping="Wrap" />
</HyperlinkButton>
</StackPanel>
</StackPanel>
</controls:OOBEPageControl.ModuleContent>
</controls:OOBEPageControl>
</Page>

View File

@@ -0,0 +1,46 @@
// 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 Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
{
public sealed partial class OobeAlwaysOnTop : Page
{
public OobePowerToysModule ViewModel { get; set; }
public OobeAlwaysOnTop()
{
InitializeComponent();
ViewModel = new OobePowerToysModule(OobeShellPage.OobeShellHandler.Modules[(int)PowerToysModulesEnum.AlwaysOnTop]);
DataContext = ViewModel;
}
private void SettingsLaunchButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
if (OobeShellPage.OpenMainWindowCallback != null)
{
OobeShellPage.OpenMainWindowCallback(typeof(AlwaysOnTopPage));
}
ViewModel.LogOpeningSettingsEvent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel.LogOpeningModuleEvent();
HotkeyControl.Keys = SettingsRepository<AlwaysOnTopSettings>.GetInstance(new SettingsUtils()).SettingsConfig.Properties.Hotkey.Value.GetKeysList();
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
ViewModel.LogClosingModuleEvent();
}
}
}

View File

@@ -71,6 +71,18 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
DescriptionLink = "https://aka.ms/PowerToysOverview",
Link = "https://github.com/microsoft/PowerToys/releases/",
});
Modules.Insert((int)PowerToysModulesEnum.AlwaysOnTop, new OobePowerToysModule()
{
ModuleName = loader.GetString("Oobe_AlwaysOnTop"),
Tag = "AlwaysOnTop",
IsNew = true,
Icon = "\uEC32",
Image = "ms-appx:///Assets/Modules/AlwaysOnTop.png",
FluentIcon = "ms-appx:///Assets/FluentIcons/FluentIconsAlwaysOnTop.png",
PreviewImageSource = "ms-appx:///Assets/Modules/OOBE/AlwaysOnTop.png",
Description = loader.GetString("Oobe_AlwaysOnTop_Description"),
Link = "https://aka.ms/PowerToysOverview_AlwaysOnTop",
});
Modules.Insert((int)PowerToysModulesEnum.Awake, new OobePowerToysModule()
{
ModuleName = loader.GetString("Oobe_Awake"),
@@ -230,6 +242,7 @@ namespace Microsoft.PowerToys.Settings.UI.OOBE.Views
switch (selectedItem.Tag)
{
case "Overview": NavigationFrame.Navigate(typeof(OobeOverview)); break;
case "AlwaysOnTop": NavigationFrame.Navigate(typeof(OobeAlwaysOnTop)); break;
case "Awake": NavigationFrame.Navigate(typeof(OobeAwake)); break;
case "ColorPicker": NavigationFrame.Navigate(typeof(OobeColorPicker)); break;
case "FancyZones": NavigationFrame.Navigate(typeof(OobeFancyZones)); break;