Skip to content

Commit d97fa7d

Browse files
committed
界面优化
1 parent 8f89e66 commit d97fa7d

File tree

3 files changed

+73
-58
lines changed

3 files changed

+73
-58
lines changed

Mikoto/Windows/MainWindow.xaml

+34-11
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,42 @@
2121
IsVisibleChanged="Window_IsVisibleChanged">
2222
<Grid Margin="5">
2323
<Grid.RowDefinitions>
24+
<RowDefinition />
2425
<RowDefinition Height="8*" />
2526
<RowDefinition />
2627
</Grid.RowDefinitions>
2728
<Grid.ColumnDefinitions>
2829
<ColumnDefinition />
2930
<ColumnDefinition />
3031
</Grid.ColumnDefinitions>
32+
<StackPanel Orientation="Horizontal"
33+
Grid.Row="0"
34+
Grid.Column="0"
35+
HorizontalAlignment="Left"
36+
VerticalAlignment="Top">
37+
<Button Content="&#xE710;"
38+
FontFamily="Segoe MDL2 Assets"
39+
HorizontalAlignment="Left"
40+
VerticalAlignment="Bottom"
41+
Foreground="{StaticResource MainBtnColor}"
42+
FontSize="40"
43+
Background="#01FFFFFF"
44+
Height="64"
45+
Width="64"
46+
Effect="{StaticResource EffectShadow5}"
47+
Click="AddGameButton_Click"
48+
BorderBrush="Transparent"
49+
ToolTip="{DynamicResource MainWindow_Tip_AutoStart}" />
50+
</StackPanel>
3151
<!--游戏列表-->
32-
<hc:ScrollViewer Grid.Row="0"
52+
<hc:ScrollViewer Grid.Row="1"
3353
Grid.Column="0"
3454
Grid.ColumnSpan="2"
35-
Margin="10,10,10,10.5"
55+
Margin="10"
3656
HorizontalScrollBarVisibility="Auto"
37-
VerticalScrollBarVisibility="Hidden"
38-
hc:ScrollViewerAttach.Orientation="Horizontal">
57+
VerticalScrollBarVisibility="Disabled"
58+
hc:ScrollViewerAttach.Orientation="Horizontal"
59+
Effect="{Binding GameCollectionEffect}">
3960
<ItemsControl ItemsSource="{Binding GamePanelCollection}">
4061
<ItemsControl.ItemsPanel>
4162
<ItemsPanelTemplate>
@@ -54,7 +75,9 @@
5475

5576
<!--左下角-->
5677
<StackPanel Orientation="Horizontal"
57-
Grid.Row="1"
78+
HorizontalAlignment="Left"
79+
VerticalAlignment="Bottom"
80+
Grid.Row="2"
5881
Grid.Column="0">
5982
<Button Content="&#xE945;"
6083
FontFamily="Segoe MDL2 Assets"
@@ -71,12 +94,11 @@
7194
BorderBrush="Transparent"
7295
ToolTip="{DynamicResource MainWindow_Tip_AutoStart}" />
7396

74-
7597
</StackPanel>
7698

7799
<!--右下角-->
78100
<StackPanel Orientation="Horizontal"
79-
Grid.Row="1"
101+
Grid.Row="2"
80102
Grid.Column="1"
81103
HorizontalAlignment="Right"
82104
VerticalAlignment="Bottom">
@@ -172,20 +194,21 @@
172194
<hc:Drawer Name="GameInfoDrawer"
173195
ShowMode="Press"
174196
MaskCanClose="True"
175-
Dock="Left">
197+
Dock="Left"
198+
IsOpen="{Binding GameInfoDrawerIsOpen}">
176199
<Border Background="{DynamicResource PrimaryBackground}"
177200
Width="300"
178201
BorderBrush="{DynamicResource BorderBrush}">
179202
<ScrollViewer>
180203
<StackPanel>
181-
<DockPanel >
204+
<DockPanel>
182205
<Button HorizontalAlignment="Left"
183206
BorderThickness="0"
184207
Foreground="{DynamicResource PrimaryForeground}"
185208
Content="&#xE713;"
186209
FontFamily="Segoe MDL2 Assets"
187-
Click="OpenGameInfoFileBtn_Click"
188-
Visibility="{Binding GameInfoFileButtonVisibility}"/>
210+
Click="OpenGameInfoFileBtn_Click"
211+
Visibility="{Binding GameInfoFileButtonVisibility}" />
189212
<Button HorizontalAlignment="Right"
190213
BorderThickness="0"
191214
Foreground="{DynamicResource PrimaryForeground}"

Mikoto/Windows/MainWindow.xaml.cs

+12-44
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using System.Windows.Input;
1818
using System.Windows.Media;
1919
using System.Windows.Media.Animation;
20+
using System.Windows.Media.Effects;
2021
using System.Windows.Media.Imaging;
2122
using MessageBox = HandyControl.Controls.MessageBox;
2223

@@ -105,7 +106,6 @@ private void SetRandomBlurredBackground()
105106
private void InitGameLibraryPanel()
106107
{
107108
_viewModel.GamePanelCollection.Clear();
108-
InitAddGamePanel();
109109
for (var i = 0; i < GameInfoList.Count; i++)
110110
{
111111
AddGame(i);
@@ -141,6 +141,7 @@ private void AddGame(int gid)
141141
CornerRadius = new CornerRadius(4),
142142
Name = "game" + gid,
143143
Width = 150,
144+
Height = 120,
144145
Child = gd,
145146
Margin = new Thickness(3),
146147
};
@@ -151,43 +152,6 @@ private void AddGame(int gid)
151152
_viewModel.GamePanelCollection.Add(back);
152153
}
153154

154-
private void InitAddGamePanel()
155-
{
156-
var textBlock = new TextBlock()
157-
{
158-
Foreground = Brushes.White,
159-
VerticalAlignment = VerticalAlignment.Center,
160-
HorizontalAlignment = HorizontalAlignment.Center,
161-
TextWrapping = TextWrapping.Wrap,
162-
FontSize = (double)Application.Current.Resources["SubHeadFontSize"]
163-
};
164-
textBlock.SetResourceReference(TextBlock.TextProperty, "MainWindow_ScrollViewer_AddNewGame");
165-
var grid = new Grid();
166-
grid.Children.Add(new Border()
167-
{
168-
Background = (SolidColorBrush)Application.Current.Resources["BoxBtnColor"],
169-
CornerRadius = new CornerRadius(4),
170-
});
171-
grid.Children.Add(textBlock);
172-
var border = new Border()
173-
{
174-
Name = "AddNewName",
175-
Width = 150,
176-
Child = grid,
177-
Margin = new Thickness(3),
178-
CornerRadius = new CornerRadius(4),
179-
};
180-
border.MouseEnter += Border_MouseEnter;
181-
border.MouseLeave += Border_MouseLeave;
182-
border.MouseLeftButtonDown += Border_MouseLeftButtonDown;
183-
_viewModel.GamePanelCollection.Add(border);
184-
}
185-
186-
private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
187-
{
188-
AddNewGameDrawer.IsOpen = true;
189-
}
190-
191155
private WeakReference<SettingsWindow>? _settingsWindow;
192156

193157
private void SettingsBtn_Click(object sender, RoutedEventArgs e)
@@ -258,10 +222,9 @@ private void Back_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
258222
GameNameTag.Tag = _gid;
259223
GameNameTag.Text = GameInfoList[_gid].GameName;
260224

261-
262225
_viewModel.LastStartTime = GameInfoList[_gid].LastPlayAt.ToString();
263226

264-
GameInfoDrawer.IsOpen = true;
227+
_viewModel.GameInfoDrawerIsOpen = true;
265228
e.Handled = true;
266229
}
267230

@@ -409,7 +372,7 @@ public static bool StartProcessAsAdmin(string fileName)
409372
}
410373
private void CloseDrawerBtn_Click(object sender, RoutedEventArgs e)
411374
{
412-
GameInfoDrawer.IsOpen = false;
375+
_viewModel.GameInfoDrawerIsOpen = false;
413376
}
414377

415378
private async void StartBtn_Click(object sender, RoutedEventArgs e)
@@ -423,7 +386,7 @@ private async void StartBtn_Click(object sender, RoutedEventArgs e)
423386
return;
424387
}
425388
Process.Start(path);
426-
GameInfoDrawer.IsOpen = false;
389+
_viewModel.GameInfoDrawerIsOpen = false;
427390
await StartTranslateByGid(_gid);
428391
Refresh();
429392
}
@@ -459,7 +422,7 @@ private async void LEStartBtn_Click(object sender, RoutedEventArgs e)
459422
p.UseShellExecute = false;
460423
p.WorkingDirectory = lePath;
461424
Process.Start(p);
462-
GameInfoDrawer.IsOpen = false;
425+
_viewModel.GameInfoDrawerIsOpen = false;
463426
await StartTranslateByGid(_gid);
464427
Refresh();
465428
}
@@ -473,7 +436,7 @@ private void DeleteGameBtn_Click(object sender, RoutedEventArgs e)
473436
{
474437
GameHelper.DeleteGameByID(GameInfoList[_gid].GameID);
475438
_viewModel.GamePanelCollection.Remove(_viewModel.GamePanelCollection.Where(p => p.Name == $"game{_gid}").First());
476-
GameInfoDrawer.IsOpen = false;
439+
_viewModel.GameInfoDrawerIsOpen = false;
477440
}
478441

479442
}
@@ -654,6 +617,11 @@ private void OpenGameInfoFileBtn_Click(object sender, RoutedEventArgs e)
654617
string gameInfoFilePath = Path.Combine(Common.DataFolder, "games", $"{GameInfoList[_gid].GameID}.json");
655618
Process.Start(new ProcessStartInfo(gameInfoFilePath) { UseShellExecute = true });
656619
}
620+
621+
private void AddGameButton_Click(object sender, RoutedEventArgs e)
622+
{
623+
AddNewGameDrawer.IsOpen = true;
624+
}
657625
}
658626
}
659627

Mikoto/Windows/MainWindowViewModel.cs

+27-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
using Mikoto.Helpers.ViewModel;
1+
using Mikoto.Helpers.Graphics;
2+
using Mikoto.Helpers.ViewModel;
23
using System.Collections.ObjectModel;
34
using System.Windows;
45
using System.Windows.Controls;
6+
using System.Windows.Media.Effects;
57

68
namespace Mikoto.Windows
79
{
810
internal class MainWindowViewModel : ViewModelBase
911
{
1012
public ObservableCollection<Border> GamePanelCollection { get; set; } = new();
1113

12-
private System.Windows.Visibility _LEEnabled;
13-
public System.Windows.Visibility LEEnabled
14+
private Visibility _LEEnabled;
15+
public Visibility LEEnabled
1416
{
1517
get
1618
{
@@ -30,6 +32,28 @@ public System.Windows.Visibility LEEnabled
3032
private Visibility gameInfoFileButtonVisibility = Visibility.Collapsed;
3133

3234
public Visibility GameInfoFileButtonVisibility { get => gameInfoFileButtonVisibility; set => SetProperty(ref gameInfoFileButtonVisibility, value); }
35+
36+
private Effect? _gameCollectionEffect = null;
37+
public Effect? GameCollectionEffect { get => _gameCollectionEffect; set => SetProperty(ref _gameCollectionEffect, value); }
38+
39+
BlurEffect _blur = new BlurEffect();
40+
41+
private bool gameInfoDrawerIsOpen;
42+
public bool GameInfoDrawerIsOpen
43+
{
44+
get => gameInfoDrawerIsOpen; set
45+
{
46+
if (value)
47+
{
48+
GameCollectionEffect = _blur;
49+
}
50+
else
51+
{
52+
GameCollectionEffect = null;
53+
}
54+
SetProperty(ref gameInfoDrawerIsOpen, value);
55+
}
56+
}
3357
}
3458

3559
}

0 commit comments

Comments
 (0)