Skip to content

Commit

Permalink
Merge pull request #309 from mujianwu/main
Browse files Browse the repository at this point in the history
Separate CanResize and Maximize
  • Loading branch information
kikipoulet authored Oct 16, 2024
2 parents ba0008a + d64ea26 commit aaba8e2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion SukiUI/Controls/SukiWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</Button>
<Button Name="PART_MaximizeButton"
Classes="Basic Rounded WindowControlsButton"
IsVisible="{TemplateBinding CanResize}">
IsVisible="{TemplateBinding CanMaximize}">
<PathIcon x:Name="MaximizeIcon" Data="{x:Static icons:Icons.WindowMaximize}" />
</Button>
<Button Name="PART_MinimizeButton"
Expand Down
14 changes: 11 additions & 3 deletions SukiUI/Controls/SukiWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ public bool CanMinimize
set => SetValue(CanMinimizeProperty, value);
}

public static readonly StyledProperty<bool> CanMaximizeProperty =
AvaloniaProperty.Register<SukiWindow, bool>(nameof(CanMaximize), defaultValue: true);
public bool CanMaximize
{
get => GetValue(CanMaximizeProperty);
set => SetValue(CanMaximizeProperty, value);
}

public static readonly StyledProperty<bool> CanMoveProperty =
AvaloniaProperty.Register<SukiWindow, bool>(nameof(CanMove), defaultValue: true);

Expand Down Expand Up @@ -268,7 +276,7 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)

private void OnMaximizeButtonClicked(object? sender, RoutedEventArgs args)
{
if (!CanResize) return;
if (!CanMaximize) return;
WindowState = WindowState == WindowState.Maximized
? WindowState.Normal
: WindowState.Maximized;
Expand All @@ -284,7 +292,7 @@ private void EnableWindowsSnapLayout(Button maximize)
{
case 533:
if (!pointerOnMaxButton) break;
if (!CanResize) break;
if (!CanMaximize) break;
WindowState = WindowState == WindowState.Maximized
? WindowState.Normal
: WindowState.Maximized;
Expand Down Expand Up @@ -325,7 +333,7 @@ static int ToInt32(IntPtr ptr) => IntPtr.Size == 4
private void OnWindowStateChanged(WindowState state)
{
if (state == WindowState.FullScreen)
CanResize = CanMove = false;
CanMaximize = CanResize = CanMove = false;
if (state == WindowState.Maximized)
Margin = new Thickness(7);
else
Expand Down

0 comments on commit aaba8e2

Please sign in to comment.