Skip to content

Commit dccce87

Browse files
committed
💄 无边框窗口页面UI改进
1 parent 442ad2d commit dccce87

File tree

6 files changed

+240
-100
lines changed

6 files changed

+240
-100
lines changed

src/BD.WTTS.Client.Plugins.GameTools/BD.WTTS.Client.Plugins.GameTools.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
<None Remove="UI\Assets\CounterStrike.png" />
1313
<None Remove="UI\Assets\CPU.png" />
1414
<None Remove="UI\Assets\movecross.png" />
15+
<None Remove="UI\Assets\movecross_hide.png" />
1516
</ItemGroup>
1617

1718
<ItemGroup>
1819
<AvaloniaResource Include="UI\Assets\BorderlessWindow.png" />
1920
<AvaloniaResource Include="UI\Assets\CounterStrike.png" />
2021
<AvaloniaResource Include="UI\Assets\CPU.png" />
2122
<AvaloniaResource Include="UI\Assets\movecross.png" />
23+
<AvaloniaResource Include="UI\Assets\movecross_hide.png" />
2224
<AvaloniaResource Include="UI\Assets\toolbox.ico" />
2325
</ItemGroup>
2426

3.4 KB
Loading

src/BD.WTTS.Client.Plugins.GameTools/UI/ViewModels/BorderlessGamePageViewModel.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Avalonia.Platform;
22
using BD.WTTS.UI.Views.Pages;
3+
using static System.Net.Mime.MediaTypeNames;
34

45
namespace BD.WTTS.UI.ViewModels;
56

@@ -44,15 +45,25 @@ public ObservableCollection<NativeWindowModel> WindowList
4445

4546
public BorderlessGamePageViewModel()
4647
{
48+
}
4749

50+
public async void CopyGameInfo_Click()
51+
{
52+
var text = $"{Strings.GameRelated_Borderless_Title}: {SelectWindow!.Title}\n" +
53+
$"{Strings.GameRelated_Borderless_Title}: {SelectWindow!.Title}\n" +
54+
$"{Strings.GameRelated_Borderless_ClassName}: {SelectWindow!.Name}\n" +
55+
$"{Strings.GameRelated_Borderless_Path}: {SelectWindow!.Path}";
56+
await Clipboard2.SetTextAsync(text);
57+
Toast.Show(ToastIcon.Success, Strings.CopyToClipboard);
4858
}
4959

5060
public void Cross_MouseDown()
5161
{
5262
windowApi.GetMoveMouseDownWindow((window) =>
5363
{
5464
SelectWindow = window;
55-
WindowList.Insert(0, window);
65+
if (window is not null)
66+
WindowList.Insert(0, window);
5667
});
5768
}
5869

src/BD.WTTS.Client.Plugins.GameTools/UI/Views/BorderlessGamePage.axaml

Lines changed: 203 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
xmlns:spp="https://steampp.net/ui"
1111
xmlns:ui="using:FluentAvalonia.UI.Controls"
1212
Title="游戏无边框窗口化"
13-
d:DesignHeight="450"
13+
d:DesignHeight="850"
1414
d:DesignWidth="800"
1515
x:CompileBindings="True"
1616
x:DataType="spp:BorderlessGamePageViewModel"
@@ -103,102 +103,214 @@
103103
</StackPanel>
104104
</spp:PageBase.PaneContent>
105105

106-
<ScrollViewer Padding="10">
107-
<StackPanel Spacing="20">
108-
<WrapPanel HorizontalAlignment="Center">
109-
<Image
110-
x:Name="move"
111-
Width="64"
112-
HorizontalAlignment="Left"
113-
Source="avares://BD.WTTS.Client.Plugins.GameTools/UI/Assets/movecross.png">
114-
<i:Interaction.Behaviors>
115-
<ia:EventTriggerBehavior EventName="PointerPressed" SourceObject="{Binding #move}">
116-
<ia:InvokeCommandAction Command="{ReflectionBinding $parent[spp:PageBase].((spp:BorderlessGamePageViewModel)DataContext).Cross_MouseDown}" />
117-
</ia:EventTriggerBehavior>
118-
</i:Interaction.Behaviors>
119-
</Image>
120-
<TextBlock
121-
Margin="10,0"
122-
VerticalAlignment="Center"
123-
Text="{Binding Path=Res.GameRelated_Borderless_MoveMouseTip, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
124-
</WrapPanel>
106+
<ScrollViewer>
107+
<StackPanel x:Name="Grid_Menu" MaxWidth="1000">
108+
<Border Padding="20" Classes="paper"
109+
Height="180" Margin="16">
110+
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
111+
<Grid.ColumnDefinitions>
112+
<ColumnDefinition Width="*" />
113+
<ColumnDefinition Width="*" />
114+
</Grid.ColumnDefinitions>
115+
<Grid HorizontalAlignment="Center" Grid.Column="0">
116+
<Image
117+
Width="64"
118+
HorizontalAlignment="Left"
119+
Source="avares://BD.WTTS.Client.Plugins.GameTools/UI/Assets/movecross_hide.png">
120+
</Image>
121+
<Image
122+
x:Name="move"
123+
Width="64"
124+
HorizontalAlignment="Left"
125+
Source="avares://BD.WTTS.Client.Plugins.GameTools/UI/Assets/movecross.png">
126+
<i:Interaction.Behaviors>
127+
<ia:EventTriggerBehavior EventName="PointerPressed" SourceObject="{Binding #move}">
128+
<ia:InvokeCommandAction Command="{ReflectionBinding $parent[spp:PageBase].((spp:BorderlessGamePageViewModel)DataContext).Cross_MouseDown}" />
129+
</ia:EventTriggerBehavior>
130+
</i:Interaction.Behaviors>
131+
</Image>
132+
</Grid>
133+
<TextBlock Grid.Column="1"
134+
Margin="10"
135+
VerticalAlignment="Center"
136+
Text="{Binding Path=Res.GameRelated_Borderless_MoveMouseTip, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"
137+
TextWrapping="WrapWithOverflow"/>
138+
</Grid>
139+
</Border>
125140

126-
<Grid
127-
HorizontalAlignment="Center"
128-
ColumnDefinitions="Auto,*"
129-
IsVisible="{ReflectionBinding !!SelectWindow}"
130-
RowDefinitions="Auto,Auto,Auto,Auto">
131-
<TextBlock VerticalAlignment="Center" Text="{Binding Path=Res.GameRelated_Borderless_Title, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
132-
<TextBox
133-
Grid.Column="1"
134-
Margin="0,0,0,10"
135-
IsReadOnly="True"
136-
Text="{ReflectionBinding SelectWindow.Title,
137-
Mode=OneWay}"
138-
TextWrapping="WrapWithOverflow" />
141+
<Expander Margin="16" IsExpanded="True">
142+
<Expander.Styles>
143+
<Style Selector="Expander /template/ ToggleButton#ExpanderHeader">
144+
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
145+
</Style>
146+
</Expander.Styles>
147+
<Expander.Header>
148+
<DockPanel>
149+
<StackPanel Orientation="Horizontal" >
150+
<ui:FontIcon FontSize="26" Margin="0 0 12 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE946;" />
151+
<TextBlock VerticalAlignment="Center" Text="游戏信息" />
152+
<!--<TextBlock VerticalAlignment="Center" Text="{Binding Path=Res.SteamAppType_Game, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />-->
153+
<!--<TextBlock VerticalAlignment="Center" Text="{Binding Path=Res.Info, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />-->
154+
</StackPanel>
155+
<Button DockPanel.Dock="Right" HorizontalAlignment="Right"
156+
Width="100" Content="{Binding Path=Res.Copy, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"
157+
Command="{ReflectionBinding CopyGameInfo_Click}"
158+
IsEnabled="{ReflectionBinding !!SelectWindow}" />
159+
</DockPanel>
160+
</Expander.Header>
161+
162+
<StackPanel>
163+
<Grid
164+
HorizontalAlignment="Stretch"
165+
ColumnDefinitions="Auto,*"
166+
RowDefinitions="Auto,Auto,Auto,Auto">
167+
<TextBlock VerticalAlignment="Top" Text="{Binding Path=Res.GameRelated_Borderless_Title, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
168+
<SelectableTextBlock
169+
Grid.Column="1"
170+
Margin="4,0,0,10"
171+
Text="{ReflectionBinding SelectWindow.Title,
172+
Mode=OneWay}"
173+
TextWrapping="WrapWithOverflow"
174+
Foreground="Gray" VerticalAlignment="Top" />
139175

140-
<TextBlock
141-
Grid.Row="1"
142-
VerticalAlignment="Center"
143-
Text="{Binding Path=Res.GameRelated_Borderless_Process, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
144-
<TextBox
145-
Grid.Row="1"
146-
Grid.Column="1"
147-
Margin="0,0,0,10"
148-
IsReadOnly="True"
149-
Text="{ReflectionBinding SelectWindow.Title,
150-
Mode=OneWay}"
151-
TextWrapping="WrapWithOverflow" />
176+
<TextBlock
177+
Grid.Row="1"
178+
VerticalAlignment="Top"
179+
Text="{Binding Path=Res.GameRelated_Borderless_Process, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
180+
<SelectableTextBlock
181+
Grid.Row="1"
182+
Grid.Column="1"
183+
Margin="4,0,0,10"
184+
Text="{ReflectionBinding SelectWindow.Title,
185+
Mode=OneWay}"
186+
TextWrapping="WrapWithOverflow"
187+
Foreground="Gray" VerticalAlignment="Top" />
152188

153-
<TextBlock
154-
Grid.Row="2"
155-
VerticalAlignment="Center"
156-
Text="{Binding Path=Res.GameRelated_Borderless_ClassName, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
157-
<TextBox
158-
Grid.Row="2"
159-
Grid.Column="1"
160-
Margin="0,0,0,10"
161-
IsReadOnly="True"
162-
Text="{ReflectionBinding SelectWindow.Name,
163-
Mode=OneWay}"
164-
TextWrapping="WrapWithOverflow" />
189+
<TextBlock
190+
Grid.Row="2"
191+
VerticalAlignment="Top"
192+
Text="{Binding Path=Res.GameRelated_Borderless_ClassName, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
193+
<SelectableTextBlock
194+
Grid.Row="2"
195+
Grid.Column="1"
196+
Margin="4,0,0,10"
197+
Text="{ReflectionBinding SelectWindow.Name,
198+
Mode=OneWay}"
199+
TextWrapping="WrapWithOverflow"
200+
Foreground="Gray" VerticalAlignment="Top" />
165201

166-
<TextBlock
167-
Grid.Row="3"
168-
VerticalAlignment="Center"
169-
Text="{Binding Path=Res.GameRelated_Borderless_Path, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
170-
<TextBox
171-
Grid.Row="3"
172-
Grid.Column="1"
173-
Margin="0,0,0,10"
174-
IsReadOnly="True"
175-
Text="{ReflectionBinding SelectWindow.Path,
176-
Mode=OneWay}"
177-
TextWrapping="WrapWithOverflow" />
178-
</Grid>
202+
<TextBlock
203+
Grid.Row="3"
204+
VerticalAlignment="Top"
205+
Text="{Binding Path=Res.GameRelated_Borderless_Path, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat={}{0}:}" />
206+
<SelectableTextBlock
207+
Grid.Row="3"
208+
Grid.Column="1"
209+
Margin="4,0,0,10"
210+
Text="{ReflectionBinding SelectWindow.Path,
211+
Mode=OneWay}"
212+
TextWrapping="WrapWithOverflow"
213+
Foreground="Gray" VerticalAlignment="Top" />
214+
</Grid>
179215

180-
<WrapPanel HorizontalAlignment="Center" Orientation="Horizontal">
181-
<WrapPanel.Styles>
182-
<Style Selector="Button">
183-
<Setter Property="Height" Value="30" />
184-
<Setter Property="Margin" Value="3" />
185-
</Style>
186-
</WrapPanel.Styles>
187-
<Button Command="{ReflectionBinding WindowKill_Click}" Content="{Binding Path=Res.GameRelated_Borderless_KillProcess, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
188-
<Button Command="{ReflectionBinding BorderlessWindow_Click}" Content="{Binding Path=Res.GameRelated_Borderless_BorderlessWindow, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
189-
<Button Command="{ReflectionBinding MaximizeWindow_Click}" Content="{Binding Path=Res.GameRelated_Borderless_Maximize, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
190-
<Button Command="{ReflectionBinding NormalWindow_Click}" Content="{Binding Path=Res.GameRelated_Borderless_Normal, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
191-
<Button Command="{ReflectionBinding HideWindow_Click}" Content="{Binding Path=Res.GameRelated_Borderless_Hide, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
192-
<Button Command="{ReflectionBinding ShowWindow_Click}" Content="{Binding Path=Res.GameRelated_Borderless_Show, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
193-
<Button
194-
Command="{ReflectionBinding ToWallerpaperWindow_Click}"
195-
Content="{Binding Path=Res.GameRelated_Borderless_ToWallerpaper, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"
196-
ToolTip.Tip="{Binding Path=Res.GameRelated_Borderless_ToWallerpaperTip, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
197-
<Button Command="{ReflectionBinding ResetWallerpaper_Click}" Content="{Binding Path=Res.GameRelated_Borderless_ResetWallerpaper, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
198-
</WrapPanel>
216+
<Border x:Name="ButtonGroup" Padding="4" Classes="paper" Margin="-16 16 -16 -16"
217+
Height="200">
218+
<WrapPanel HorizontalAlignment="Center" Orientation="Horizontal">
219+
<WrapPanel.Styles>
220+
<Style Selector="Button">
221+
<Setter Property="Height" Value="30" />
222+
<Setter Property="Margin" Value="8" />
223+
<Setter Property="Width" Value="120" />
224+
</Style>
225+
</WrapPanel.Styles>
199226

200-
<!--<TextBlock Text="{ReflectionBinding Path=Res.GameRelated_Borderless_ToWallerpaperTip, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat=*{0}}" TextWrapping="WrapWithOverflow" />-->
227+
<!--Button Group 1-->
228+
<Button Classes="accent" Command="{ReflectionBinding BorderlessWindow_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}" >
229+
<!--<Button.Styles>
230+
<Style Selector="Button">
231+
<Setter Property="Background" Value="#0071c7" />
232+
<Setter Property="Foreground" Value="White" />
233+
</Style>
234+
<Style Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
235+
<Setter Property="TextElement.Foreground" Value="White" />
236+
<Setter Property="TextElement.Background" Value="#006abb" />
237+
</Style>
238+
<Style Selector="Button:pressed /template/ ContentPresenter#PART_ContentPresenter">
239+
<Setter Property="Background" Value="#0062ae" />
240+
</Style>
241+
</Button.Styles>-->
201242

202-
</StackPanel>
243+
<StackPanel Orientation="Horizontal">
244+
<ui:FontIcon Glyph="&#xf58a;" FontFamily="Segoe Fluent Icons" />
245+
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_BorderlessWindow, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
246+
</StackPanel>
247+
</Button>
248+
<Button Command="{ReflectionBinding MaximizeWindow_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}">
249+
<StackPanel Orientation="Horizontal">
250+
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE922;" />
251+
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_Maximize, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
252+
</StackPanel>
253+
</Button>
254+
<Button Command="{ReflectionBinding NormalWindow_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}">
255+
<StackPanel Orientation="Horizontal">
256+
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE923;" />
257+
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_Normal, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
258+
</StackPanel>
259+
</Button>
260+
261+
<!--Button Group 2-->
262+
<Button Command="{ReflectionBinding HideWindow_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}">
263+
<StackPanel Orientation="Horizontal">
264+
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xed1a;" />
265+
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_Hide, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
266+
</StackPanel>
267+
</Button>
268+
<Button Command="{ReflectionBinding ShowWindow_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}">
269+
<StackPanel Orientation="Horizontal">
270+
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xe7b3;" />
271+
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_Show, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
272+
</StackPanel>
273+
</Button>
274+
275+
<!--Button Group 3-->
276+
<Button
277+
Command="{ReflectionBinding ToWallerpaperWindow_Click}"
278+
IsEnabled="{ReflectionBinding !!SelectWindow}"
279+
ToolTip.Tip="{Binding Path=Res.GameRelated_Borderless_ToWallerpaperTip, Mode=OneWay, Source={x:Static s:ResourceService.Current}}">
280+
<StackPanel Orientation="Horizontal">
281+
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE718;" />
282+
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_ToWallerpaper, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
283+
</StackPanel>
284+
</Button>
285+
<Button Command="{ReflectionBinding ResetWallerpaper_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}">
286+
<StackPanel Orientation="Horizontal">
287+
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE72C;" />
288+
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_ResetWallerpaper, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
289+
</StackPanel>
290+
</Button>
291+
292+
<Button Command="{ReflectionBinding WindowKill_Click}" IsEnabled="{ReflectionBinding !!SelectWindow}">
293+
<Button.Styles>
294+
<Style Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
295+
<Setter Property="TextElement.Foreground" Value="White" />
296+
<Setter Property="TextElement.Background" Value="Red" />
297+
</Style>
298+
<Style Selector="Button:pressed /template/ ContentPresenter#PART_ContentPresenter">
299+
<Setter Property="Background" Value="#f1707a" />
300+
</Style>
301+
</Button.Styles>
302+
<StackPanel Orientation="Horizontal">
303+
<ui:FontIcon Margin="0 0 4 0" FontFamily="{StaticResource SymbolThemeFontFamily}" Glyph="&#xE8BB;" />
304+
<TextBlock Text="{Binding Path=Res.GameRelated_Borderless_KillProcess, Mode=OneWay, Source={x:Static s:ResourceService.Current}}"/>
305+
</StackPanel>
306+
</Button>
307+
308+
</WrapPanel>
309+
</Border>
310+
</StackPanel>
311+
</Expander>
312+
</StackPanel>
313+
314+
<!--<TextBlock Text="{ReflectionBinding Path=Res.GameRelated_Borderless_ToWallerpaperTip, Mode=OneWay, Source={x:Static s:ResourceService.Current}, StringFormat=*{0}}" TextWrapping="WrapWithOverflow" />-->
203315
</ScrollViewer>
204316
</spp:PageBase>

src/BD.WTTS.Client.Plugins.GameTools/UI/Views/BorderlessGamePage.axaml.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,16 @@ public BorderlessGamePage()
66
{
77
InitializeComponent();
88
DataContext ??= new BorderlessGamePageViewModel();
9+
10+
move.PointerPressed += (_, _) => move.IsVisible = false;
11+
move.PointerReleased += (_, _) => move.IsVisible = true;
12+
13+
const int threeLineButtonWidth = 554;
14+
const int fourLineButtonWidth = 418;
15+
Observable.FromEventPattern<Avalonia.Controls.SizeChangedEventArgs>(ButtonGroup, nameof(ButtonGroup.SizeChanged))
16+
.Select(eventPattern => eventPattern.EventArgs.NewSize.Width)
17+
.Select(width => width < fourLineButtonWidth ? 200 : width < threeLineButtonWidth ? 150 : 100)
18+
.DistinctUntilChanged()
19+
.Subscribe(newHeight => ButtonGroup.Height = newHeight);
920
}
1021
}

0 commit comments

Comments
 (0)