[AlwaysOnTop] Round corners on Windows 11 (#19109)

* check window corners

* draw rounded rectangle

* draw rounded corners

* switch between rounded and not rounded rects

* added enabled corners setting

* update corner
This commit is contained in:
Seraphima Zykova
2022-07-01 17:56:45 +02:00
committed by GitHub
parent 35bb4280d0
commit d201ae4335
14 changed files with 175 additions and 28 deletions

View File

@@ -14,9 +14,10 @@ namespace Microsoft.PowerToys.Settings.UI.Library
public const bool DefaultFrameEnabled = true;
public const int DefaultFrameThickness = 15;
public const string DefaultFrameColor = "#0099cc";
public const bool DefaultFrameAccentColor = true;
public const bool DefaultSoundEnabled = true;
public const bool DefaultDoNotActivateOnGameMode = true;
public const bool DefaultFrameAccentColor = true;
public const bool DefaultRoundCornersEnabled = true;
public AlwaysOnTopProperties()
{
@@ -24,10 +25,11 @@ namespace Microsoft.PowerToys.Settings.UI.Library
FrameEnabled = new BoolProperty(DefaultFrameEnabled);
FrameThickness = new IntProperty(DefaultFrameThickness);
FrameColor = new StringProperty(DefaultFrameColor);
FrameAccentColor = new BoolProperty(DefaultFrameAccentColor);
SoundEnabled = new BoolProperty(DefaultSoundEnabled);
DoNotActivateOnGameMode = new BoolProperty(DefaultDoNotActivateOnGameMode);
RoundCornersEnabled = new BoolProperty(DefaultRoundCornersEnabled);
ExcludedApps = new StringProperty();
FrameAccentColor = new BoolProperty(DefaultFrameAccentColor);
}
[JsonPropertyName("hotkey")]
@@ -42,6 +44,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[JsonPropertyName("frame-color")]
public StringProperty FrameColor { get; set; }
[JsonPropertyName("frame-accent-color")]
public BoolProperty FrameAccentColor { get; set; }
[JsonPropertyName("sound-enabled")]
public BoolProperty SoundEnabled { get; set; }
@@ -51,8 +56,8 @@ namespace Microsoft.PowerToys.Settings.UI.Library
[JsonPropertyName("excluded-apps")]
public StringProperty ExcludedApps { get; set; }
[JsonPropertyName("frame-accent-color")]
public BoolProperty FrameAccentColor { get; set; }
[JsonPropertyName("round-corners-enabled")]
public BoolProperty RoundCornersEnabled { get; set; }
public string ToJsonString()
{

View File

@@ -8,6 +8,7 @@ using System.Runtime.CompilerServices;
using System.Text.Json;
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
{
@@ -51,10 +52,12 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
_frameEnabled = Settings.Properties.FrameEnabled.Value;
_frameThickness = Settings.Properties.FrameThickness.Value;
_frameColor = Settings.Properties.FrameColor.Value;
_frameAccentColor = Settings.Properties.FrameAccentColor.Value;
_soundEnabled = Settings.Properties.SoundEnabled.Value;
_doNotActivateOnGameMode = Settings.Properties.DoNotActivateOnGameMode.Value;
_roundCornersEnabled = Settings.Properties.RoundCornersEnabled.Value;
_excludedApps = Settings.Properties.ExcludedApps.Value;
_frameAccentColor = Settings.Properties.FrameAccentColor.Value;
_windows11 = Helper.Windows11();
// set the callback functions value to hangle outgoing IPC message.
SendConfigMSG = ipcMSGCallBackFunc;
@@ -186,6 +189,21 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
}
}
public bool RoundCornersEnabled
{
get => _roundCornersEnabled;
set
{
if (value != _roundCornersEnabled)
{
_roundCornersEnabled = value;
Settings.Properties.RoundCornersEnabled.Value = value;
NotifyPropertyChanged();
}
}
}
public string ExcludedApps
{
get => _excludedApps;
@@ -216,6 +234,16 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
}
}
public bool Windows11
{
get => _windows11;
set
{
_windows11 = value;
}
}
public void NotifyPropertyChanged([CallerMemberName] string propertyName = null)
{
OnPropertyChanged(propertyName);
@@ -227,9 +255,11 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
private bool _frameEnabled;
private int _frameThickness;
private string _frameColor;
private bool _frameAccentColor;
private bool _soundEnabled;
private bool _doNotActivateOnGameMode;
private bool _roundCornersEnabled;
private string _excludedApps;
private bool _frameAccentColor;
private bool _windows11;
}
}

View File

@@ -1996,7 +1996,7 @@ From there, simply click on one of the supported files in the File Explorer and
<data name="FileExplorerPreview_ToggleSwitch_Preview_GCODE.Header" xml:space="preserve">
<value>Geometric Code</value>
<comment>File type, do not translate</comment>
</data>
</data>
<data name="FileExplorerPreview_ToggleSwitch_Preview_GCODE.Description" xml:space="preserve">
<value>Only .gcode files with embedded thumbnails are supported</value>
</data>
@@ -2125,4 +2125,7 @@ From there, simply click on one of the supported files in the File Explorer and
<data name="FancyZones_DisableRoundCornersOnWindowSnap.Content" xml:space="preserve">
<value>Disable round corners when window is snapped</value>
</data>
</root>
<data name="AlwaysOnTop_RoundCorners.Content" xml:space="preserve">
<value>Enable round corners</value>
</data>
</root>

View File

@@ -12,6 +12,7 @@
<Page.Resources>
<converters:BoolToObjectConverter x:Key="BoolToComboBoxIndexConverter" TrueValue="1" FalseValue="0"/>
<converters:BoolToVisibilityConverter x:Key="FalseToVisibleConverter" TrueValue="Collapsed" FalseValue="Visible"/>
<converters:BoolToVisibilityConverter x:Key="TrueToVisibleConverter" TrueValue="Visible" FalseValue="Collapsed"/>
</Page.Resources>
<controls:SettingsPageControl x:Uid="AlwaysOnTop" IsTabStop="False"
@@ -84,6 +85,12 @@
LargeChange="5"/>
</controls:Setting.ActionContent>
</controls:Setting>
<CheckBox x:Uid="AlwaysOnTop_RoundCorners"
IsChecked="{x:Bind Mode=TwoWay, Path=ViewModel.RoundCornersEnabled}"
Margin="{StaticResource ExpanderSettingMargin}"
Visibility="{x:Bind Mode=OneWay, Path=ViewModel.Windows11, Converter={StaticResource TrueToVisibleConverter}}"/>
</StackPanel>
</controls:SettingExpander.Content>
</controls:SettingExpander>