Skip to content

Commit

Permalink
💄 无边框窗口页面UI改进
Browse files Browse the repository at this point in the history
  • Loading branch information
luojunyuan committed Aug 9, 2024
1 parent 442ad2d commit dccce87
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
<None Remove="UI\Assets\CounterStrike.png" />
<None Remove="UI\Assets\CPU.png" />
<None Remove="UI\Assets\movecross.png" />
<None Remove="UI\Assets\movecross_hide.png" />
</ItemGroup>

<ItemGroup>
<AvaloniaResource Include="UI\Assets\BorderlessWindow.png" />
<AvaloniaResource Include="UI\Assets\CounterStrike.png" />
<AvaloniaResource Include="UI\Assets\CPU.png" />
<AvaloniaResource Include="UI\Assets\movecross.png" />
<AvaloniaResource Include="UI\Assets\movecross_hide.png" />
<AvaloniaResource Include="UI\Assets\toolbox.ico" />
</ItemGroup>

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Avalonia.Platform;
using BD.WTTS.UI.Views.Pages;
using static System.Net.Mime.MediaTypeNames;

namespace BD.WTTS.UI.ViewModels;

Expand Down Expand Up @@ -44,15 +45,25 @@ public ObservableCollection<NativeWindowModel> WindowList

public BorderlessGamePageViewModel()
{
}

public async void CopyGameInfo_Click()
{
var text = $"{Strings.GameRelated_Borderless_Title}: {SelectWindow!.Title}\n" +
$"{Strings.GameRelated_Borderless_Title}: {SelectWindow!.Title}\n" +
$"{Strings.GameRelated_Borderless_ClassName}: {SelectWindow!.Name}\n" +
$"{Strings.GameRelated_Borderless_Path}: {SelectWindow!.Path}";
await Clipboard2.SetTextAsync(text);
Toast.Show(ToastIcon.Success, Strings.CopyToClipboard);
}

public void Cross_MouseDown()
{
windowApi.GetMoveMouseDownWindow((window) =>
{
SelectWindow = window;
WindowList.Insert(0, window);
if (window is not null)
WindowList.Insert(0, window);
});
}

Expand Down
294 changes: 203 additions & 91 deletions src/BD.WTTS.Client.Plugins.GameTools/UI/Views/BorderlessGamePage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
xmlns:spp="https://steampp.net/ui"
xmlns:ui="using:FluentAvalonia.UI.Controls"
Title="游戏无边框窗口化"
d:DesignHeight="450"
d:DesignHeight="850"
d:DesignWidth="800"
x:CompileBindings="True"
x:DataType="spp:BorderlessGamePageViewModel"
Expand Down Expand Up @@ -103,102 +103,214 @@
</StackPanel>
</spp:PageBase.PaneContent>

<ScrollViewer Padding="10">
<StackPanel Spacing="20">
<WrapPanel HorizontalAlignment="Center">
<Image
x:Name="move"
Width="64"
HorizontalAlignment="Left"
Source="avares://BD.WTTS.Client.Plugins.GameTools/UI/Assets/movecross.png">
<i:Interaction.Behaviors>
<ia:EventTriggerBehavior EventName="PointerPressed" SourceObject="{Binding #move}">
<ia:InvokeCommandAction Command="{ReflectionBinding $parent[spp:PageBase].((spp:BorderlessGamePageViewModel)DataContext).Cross_MouseDown}" />
</ia:EventTriggerBehavior>
</i:Interaction.Behaviors>
</Image>
<TextBlock
Margin="10,0"
VerticalAlignment="Center"
Text="{Binding Path=Res.GameRelated_Borderless_MoveMouseTip, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
</WrapPanel>
<ScrollViewer>
<StackPanel x:Name="Grid_Menu" MaxWidth="1000">
<Border Padding="20" Classes="paper"
Height="180" Margin="16">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid HorizontalAlignment="Center" Grid.Column="0">
<Image
Width="64"
HorizontalAlignment="Left"
Source="avares://BD.WTTS.Client.Plugins.GameTools/UI/Assets/movecross_hide.png">
</Image>
<Image
x:Name="move"
Width="64"
HorizontalAlignment="Left"
Source="avares://BD.WTTS.Client.Plugins.GameTools/UI/Assets/movecross.png">
<i:Interaction.Behaviors>
<ia:EventTriggerBehavior EventName="PointerPressed" SourceObject="{Binding #move}">
<ia:InvokeCommandAction Command="{ReflectionBinding $parent[spp:PageBase].((spp:BorderlessGamePageViewModel)DataContext).Cross_MouseDown}" />
</ia:EventTriggerBehavior>
</i:Interaction.Behaviors>
</Image>
</Grid>
<TextBlock Grid.Column="1"
Margin="10"
VerticalAlignment="Center"
Text="{Binding Path=Res.GameRelated_Borderless_MoveMouseTip, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"
TextWrapping="WrapWithOverflow"/>
</Grid>
</Border>

<Grid
HorizontalAlignment="Center"
ColumnDefinitions="Auto,*"
IsVisible="{ReflectionBinding !!SelectWindow}"
RowDefinitions="Auto,Auto,Auto,Auto">
<TextBlock VerticalAlignment="Center" Text="{Binding Path=Res.GameRelated_Borderless_Title, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
<TextBox
Grid.Column="1"
Margin="0,0,0,10"
IsReadOnly="True"
Text="{ReflectionBinding SelectWindow.Title,
Mode=OneWay}"
TextWrapping="WrapWithOverflow" />
<Expander Margin="16" IsExpanded="True">
<Expander.Styles>
<Style Selector="Expander /template/ ToggleButton#ExpanderHeader">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</Expander.Styles>
<Expander.Header>
<DockPanel>
<StackPanel Orientation="Horizontal" >
<ui:FontIcon FontSize="26" Margin="0 0 12 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE946;" />
<TextBlock VerticalAlignment="Center" Text="游戏信息" />
<!--<TextBlock VerticalAlignment="Center" Text="{Binding Path=Res.SteamAppType_Game, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />-->
<!--<TextBlock VerticalAlignment="Center" Text="{Binding Path=Res.Info, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />-->
</StackPanel>
<Button DockPanel.Dock="Right" HorizontalAlignment="Right"
Width="100" Content="{Binding Path=Res.Copy, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"
Command="{ReflectionBinding CopyGameInfo_Click}"
IsEnabled="{ReflectionBinding !!SelectWindow}" />
</DockPanel>
</Expander.Header>

<StackPanel>
<Grid
HorizontalAlignment="Stretch"
ColumnDefinitions="Auto,*"
RowDefinitions="Auto,Auto,Auto,Auto">
<TextBlock VerticalAlignment="Top" Text="{Binding Path=Res.GameRelated_Borderless_Title, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
<SelectableTextBlock
Grid.Column="1"
Margin="4,0,0,10"
Text="{ReflectionBinding SelectWindow.Title,
Mode=OneWay}"
TextWrapping="WrapWithOverflow"
Foreground="Gray" VerticalAlignment="Top" />

<TextBlock
Grid.Row="1"
VerticalAlignment="Center"
Text="{Binding Path=Res.GameRelated_Borderless_Process, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
<TextBox
Grid.Row="1"
Grid.Column="1"
Margin="0,0,0,10"
IsReadOnly="True"
Text="{ReflectionBinding SelectWindow.Title,
Mode=OneWay}"
TextWrapping="WrapWithOverflow" />
<TextBlock
Grid.Row="1"
VerticalAlignment="Top"
Text="{Binding Path=Res.GameRelated_Borderless_Process, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
<SelectableTextBlock
Grid.Row="1"
Grid.Column="1"
Margin="4,0,0,10"
Text="{ReflectionBinding SelectWindow.Title,
Mode=OneWay}"
TextWrapping="WrapWithOverflow"
Foreground="Gray" VerticalAlignment="Top" />

<TextBlock
Grid.Row="2"
VerticalAlignment="Center"
Text="{Binding Path=Res.GameRelated_Borderless_ClassName, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
<TextBox
Grid.Row="2"
Grid.Column="1"
Margin="0,0,0,10"
IsReadOnly="True"
Text="{ReflectionBinding SelectWindow.Name,
Mode=OneWay}"
TextWrapping="WrapWithOverflow" />
<TextBlock
Grid.Row="2"
VerticalAlignment="Top"
Text="{Binding Path=Res.GameRelated_Borderless_ClassName, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
<SelectableTextBlock
Grid.Row="2"
Grid.Column="1"
Margin="4,0,0,10"
Text="{ReflectionBinding SelectWindow.Name,
Mode=OneWay}"
TextWrapping="WrapWithOverflow"
Foreground="Gray" VerticalAlignment="Top" />

<TextBlock
Grid.Row="3"
VerticalAlignment="Center"
Text="{Binding Path=Res.GameRelated_Borderless_Path, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
<TextBox
Grid.Row="3"
Grid.Column="1"
Margin="0,0,0,10"
IsReadOnly="True"
Text="{ReflectionBinding SelectWindow.Path,
Mode=OneWay}"
TextWrapping="WrapWithOverflow" />
</Grid>
<TextBlock
Grid.Row="3"
VerticalAlignment="Top"
Text="{Binding Path=Res.GameRelated_Borderless_Path, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
<SelectableTextBlock
Grid.Row="3"
Grid.Column="1"
Margin="4,0,0,10"
Text="{ReflectionBinding SelectWindow.Path,
Mode=OneWay}"
TextWrapping="WrapWithOverflow"
Foreground="Gray" VerticalAlignment="Top" />
</Grid>

<WrapPanel HorizontalAlignment="Center" Orientation="Horizontal">
<WrapPanel.Styles>
<Style Selector="Button">
<Setter Property="Height" Value="30" />
<Setter Property="Margin" Value="3" />
</Style>
</WrapPanel.Styles>
<Button Command="{ReflectionBinding WindowKill_Click}" Content="{Binding Path=Res.GameRelated_Borderless_KillProcess, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
<Button Command="{ReflectionBinding BorderlessWindow_Click}" Content="{Binding Path=Res.GameRelated_Borderless_BorderlessWindow, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
<Button Command="{ReflectionBinding MaximizeWindow_Click}" Content="{Binding Path=Res.GameRelated_Borderless_Maximize, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
<Button Command="{ReflectionBinding NormalWindow_Click}" Content="{Binding Path=Res.GameRelated_Borderless_Normal, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
<Button Command="{ReflectionBinding HideWindow_Click}" Content="{Binding Path=Res.GameRelated_Borderless_Hide, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
<Button Command="{ReflectionBinding ShowWindow_Click}" Content="{Binding Path=Res.GameRelated_Borderless_Show, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
<Button
Command="{ReflectionBinding ToWallerpaperWindow_Click}"
Content="{Binding Path=Res.GameRelated_Borderless_ToWallerpaper, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"
ToolTip.Tip="{Binding Path=Res.GameRelated_Borderless_ToWallerpaperTip, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
<Button Command="{ReflectionBinding ResetWallerpaper_Click}" Content="{Binding Path=Res.GameRelated_Borderless_ResetWallerpaper, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
</WrapPanel>
<Border x:Name="ButtonGroup" Padding="4" Classes="paper" Margin="-16 16 -16 -16"
Height="200">
<WrapPanel HorizontalAlignment="Center" Orientation="Horizontal">
<WrapPanel.Styles>
<Style Selector="Button">
<Setter Property="Height" Value="30" />
<Setter Property="Margin" Value="8" />
<Setter Property="Width" Value="120" />
</Style>
</WrapPanel.Styles>

<!--<TextBlock Text="{ReflectionBinding Path=Res.GameRelated_Borderless_ToWallerpaperTip, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat=*{0}}" TextWrapping="WrapWithOverflow" />-->
<!--Button Group 1-->
<Button Classes="accent" Command="{ReflectionBinding BorderlessWindow_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}" >
<!--<Button.Styles>
<Style Selector="Button">
<Setter Property="Background" Value="#0071c7" />
<Setter Property="Foreground" Value="White" />
</Style>
<Style Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="TextElement.Foreground" Value="White" />
<Setter Property="TextElement.Background" Value="#006abb" />
</Style>
<Style Selector="Button:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="#0062ae" />
</Style>
</Button.Styles>-->

</StackPanel>
<StackPanel Orientation="Horizontal">
<ui:FontIcon Glyph="&#xf58a;" FontFamily="Segoe Fluent Icons" />
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_BorderlessWindow, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
</StackPanel>
</Button>
<Button Command="{ReflectionBinding MaximizeWindow_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}">
<StackPanel Orientation="Horizontal">
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE922;" />
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_Maximize, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
</StackPanel>
</Button>
<Button Command="{ReflectionBinding NormalWindow_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}">
<StackPanel Orientation="Horizontal">
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE923;" />
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_Normal, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
</StackPanel>
</Button>

<!--Button Group 2-->
<Button Command="{ReflectionBinding HideWindow_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}">
<StackPanel Orientation="Horizontal">
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xed1a;" />
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_Hide, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
</StackPanel>
</Button>
<Button Command="{ReflectionBinding ShowWindow_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}">
<StackPanel Orientation="Horizontal">
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe7b3;" />
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_Show, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
</StackPanel>
</Button>

<!--Button Group 3-->
<Button
Command="{ReflectionBinding ToWallerpaperWindow_Click}"
IsEnabled="{ReflectionBinding !!SelectWindow}"
ToolTip.Tip="{Binding Path=Res.GameRelated_Borderless_ToWallerpaperTip, Mode=OneWay, Source={x:Static s:ResourceService.Current}}">
<StackPanel Orientation="Horizontal">
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE718;" />
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_ToWallerpaper, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
</StackPanel>
</Button>
<Button Command="{ReflectionBinding ResetWallerpaper_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}">
<StackPanel Orientation="Horizontal">
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE72C;" />
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_ResetWallerpaper, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
</StackPanel>
</Button>

<Button Command="{ReflectionBinding WindowKill_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}">
<Button.Styles>
<Style Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="TextElement.Foreground" Value="White" />
<Setter Property="TextElement.Background" Value="Red" />
</Style>
<Style Selector="Button:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="#f1707a" />
</Style>
</Button.Styles>
<StackPanel Orientation="Horizontal">
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE8BB;" />
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_KillProcess, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
</StackPanel>
</Button>

</WrapPanel>
</Border>
</StackPanel>
</Expander>
</StackPanel>

<!--<TextBlock Text="{ReflectionBinding Path=Res.GameRelated_Borderless_ToWallerpaperTip, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat=*{0}}" TextWrapping="WrapWithOverflow" />-->
</ScrollViewer>
</spp:PageBase>
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,16 @@ public BorderlessGamePage()
{
InitializeComponent();
DataContext ??= new BorderlessGamePageViewModel();

move.PointerPressed += (_, _) => move.IsVisible = false;
move.PointerReleased += (_, _) => move.IsVisible = true;

const int threeLineButtonWidth = 554;
const int fourLineButtonWidth = 418;
Observable.FromEventPattern<Avalonia.Controls.SizeChangedEventArgs>(ButtonGroup, nameof(ButtonGroup.SizeChanged))
.Select(eventPattern => eventPattern.EventArgs.NewSize.Width)
.Select(width => width < fourLineButtonWidth ? 200 : width < threeLineButtonWidth ? 150 : 100)
.DistinctUntilChanged()
.Subscribe(newHeight => ButtonGroup.Height = newHeight);
}
}
Loading

0 comments on commit dccce87

Please sign in to comment.