Skip to content

Commit

Permalink
feat: 更新ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaitonn committed Aug 28, 2024
1 parent f6149e7 commit 9afa590
Show file tree
Hide file tree
Showing 19 changed files with 325 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: Serein.Pro_win-x64
path: ./src/Serein.Pro/bin/Debug/net8.0-windows10.0.19041.0/win-x64
path: ./src/Serein.Pro/bin/Debug/net8.0-windows10.0.19041/win-x64

# Serein.Cli
- name: Upload binary files(Serein.Cli_win-x64)
Expand Down
1 change: 1 addition & 0 deletions src/Serein.Pro/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private static SereinApp Build()

builder.Services.AddTransient<ShellViewModel>();
builder.Services.AddTransient<SettingViewModel>();
builder.Services.AddTransient<AboutViewModel>();

builder.Services.AddSingleton<ILogger, NotificationLogger>();
builder.Services.AddSingleton<IPluginLogger, PluginLogger>();
Expand Down
51 changes: 31 additions & 20 deletions src/Serein.Pro/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,35 @@
<MicaBackdrop Kind="Base" />
</Window.SystemBackdrop>

<Grid>
<Frame x:Name="RootFrame" />
<InfoBar
x:Name="GlobalInfoBar"
MaxWidth="500"
Margin="0,20"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
CloseButtonClick="GlobalInfoBar_CloseButtonClick">
<InfoBar.Resources>
<Storyboard x:Name="GlobalInfoBarPopIn">
<PopInThemeAnimation TargetName="GlobalInfoBar" />
</Storyboard>
<Storyboard x:Name="GlobalInfoBarPopOut">
<PopOutThemeAnimation TargetName="GlobalInfoBar" />
</Storyboard>
</InfoBar.Resources>
</InfoBar>
</Grid>

<Border
x:Name="DragBorder"
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AllowDrop="True"
BorderBrush="Transparent"
BorderThickness="2"
DragEnter="DragBorder_DragEnter"
DragLeave="DragBorder_DragLeave"
DragOver="DragBorder_DragOver">
<Grid>
<Frame x:Name="RootFrame" />
<InfoBar
x:Name="GlobalInfoBar"
MaxWidth="500"
Margin="0,20"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
CloseButtonClick="GlobalInfoBar_CloseButtonClick">
<InfoBar.Resources>
<Storyboard x:Name="GlobalInfoBarPopIn">
<PopInThemeAnimation TargetName="GlobalInfoBar" />
</Storyboard>
<Storyboard x:Name="GlobalInfoBarPopOut">
<PopOutThemeAnimation TargetName="GlobalInfoBar" />
</Storyboard>
</InfoBar.Resources>
</InfoBar>
</Grid>
</Border>
</windowex:WindowEx>
28 changes: 26 additions & 2 deletions src/Serein.Pro/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@
using System.Threading;
using System.Threading.Tasks;

using Microsoft.UI;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;

using Serein.Pro.Models;
using Serein.Pro.Views;

using Windows.ApplicationModel.DataTransfer;

using WinUIEx;

namespace Serein.Pro;

public sealed partial class MainWindow : WindowEx
{
private readonly DispatcherQueue _dispatcherQueue;
private CancellationTokenSource ?_cancellationTokenSource;
private CancellationTokenSource? _cancellationTokenSource;

public MainWindow(ShellPage shellPage)
{
Expand All @@ -39,7 +44,7 @@ public void ShowInfoBar(InfoBarTask infoBarTask)
GlobalInfoBar.IsOpen = true;

_cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(infoBarTask.CancellationToken);

GlobalInfoBarPopIn.Completed += Wait;
GlobalInfoBarPopIn.Begin();

Expand Down Expand Up @@ -74,4 +79,23 @@ private void GlobalInfoBar_CloseButtonClick(InfoBar sender, object args)
if (_cancellationTokenSource?.IsCancellationRequested is false)
_cancellationTokenSource.Cancel();
}

private void DragBorder_DragOver(object sender, DragEventArgs e)
{
if (e.DataView.Contains(StandardDataFormats.StorageItems))
{
e.AcceptedOperation = DataPackageOperation.Copy;
DragBorder.BorderBrush = new SolidColorBrush(Colors.Goldenrod);
}
}

private void DragBorder_DragLeave(object sender, DragEventArgs e)
{
DragBorder.BorderBrush = new SolidColorBrush(Colors.Transparent);
}

private void DragBorder_DragEnter(object sender, DragEventArgs e)
{

}
}
7 changes: 7 additions & 0 deletions src/Serein.Pro/Serein.Pro.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<None Remove="Views\BugSolvingPage.xaml" />
<None Remove="Views\MatchPage.xaml" />
<None Remove="Views\ServerPage.xaml" />
<None Remove="Views\Settings\AboutPage.xaml" />
<None Remove="Views\Settings\ConnectionSettingPage.xaml" />
<None Remove="Views\Settings\SettingPage.xaml" />
</ItemGroup>
Expand All @@ -33,6 +34,12 @@
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>

<ItemGroup>
<Page Update="Views\Settings\AboutPage.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>

<ItemGroup>
<Page Update="Views\BugSolvingPage.xaml">
<Generator>MSBuild:Compile</Generator>
Expand Down
13 changes: 13 additions & 0 deletions src/Serein.Pro/ViewModels/AboutViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Serein.Core;

namespace Serein.Pro.ViewModels;
public class AboutViewModel
{
public string Version { get; } = SereinApp.Version;

public string DetailedVersion { get; } = SereinApp.FullVersion ?? "未知";

public string AssemblyName { get; } = typeof(AboutViewModel).Assembly.ToString();

public string AssemblyPath { get; } = typeof(AboutViewModel).Assembly.Location;
}
2 changes: 2 additions & 0 deletions src/Serein.Pro/ViewModels/SettingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ namespace Serein.Pro.ViewModels;
public class SettingViewModel
{
public Type Connection { get; } = typeof(ConnectionSettingPage);

public Type About { get; } = typeof(AboutPage);
}
2 changes: 1 addition & 1 deletion src/Serein.Pro/Views/BugSolvingPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<!--
To solve a crush caused by using Microsoft.UI.Xaml.Controls.SelectorBar
solution: https://github.com/microsoft/microsoft-ui-xaml/issues/9424#issuecomment-2035733908
solution: https://github.com/microsoft/microsoft-ui-xaml/issues/9424#issuecomment-2035668868
-->
<ItemsRepeater />
</Page>
1 change: 0 additions & 1 deletion src/Serein.Pro/Views/HomePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Serein.Pro.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">

<Grid />
Expand Down
44 changes: 43 additions & 1 deletion src/Serein.Pro/Views/MatchPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,42 @@
mc:Ignorable="d">

<Grid>
<controls:DataGrid AutoGenerateColumns="False" ItemsSource="{x:Bind MatchesProvider.Value}">
<controls:DataGrid
VerticalAlignment="Stretch"
AutoGenerateColumns="False"
ItemsSource="{x:Bind MatchesProvider.Value}">
<controls:DataGrid.ContextFlyout>
<MenuBarItemFlyout Opening="MenuBarItemFlyout_Opening">
<MenuFlyoutItem
Click="MenuFlyoutItem_Click"
Icon="Add"
Tag="Add"
Text="添加..." />
<MenuFlyoutItem
x:Name="EditMenuFlyoutItem"
Click="MenuFlyoutItem_Click"
Icon="Edit"
Tag="Edit"
Text="编辑..." />
<MenuFlyoutItem
x:Name="RemoveMenuFlyoutItem"
Click="MenuFlyoutItem_Click"
Icon="Delete"
Tag="Remove"
Text="删除" />
<MenuFlyoutItem
Click="MenuFlyoutItem_Click"
Icon="Refresh"
Tag="Refresh"
Text="刷新" />
<MenuFlyoutSeparator />
<MenuFlyoutItem
Click="MenuFlyoutItem_Click"
Icon="Globe"
Tag="OpenDoc"
Text="打开介绍文档" />
</MenuBarItemFlyout>
</controls:DataGrid.ContextFlyout>
<controls:DataGrid.Columns>
<controls:DataGridTextColumn Binding="{Binding RegExp, UpdateSourceTrigger=PropertyChanged}" Header="正则表达式" />
<controls:DataGridTemplateColumn CanUserSort="True" Header="匹配域">
Expand Down Expand Up @@ -43,5 +78,12 @@
<controls:DataGridTextColumn Binding="{Binding Exclusions}" Header="排除" />
</controls:DataGrid.Columns>
</controls:DataGrid>
<StackPanel
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Orientation="Horizontal">
<Button Content="" />
<Button Margin="5" Content="" />
</StackPanel>
</Grid>
</Page>
10 changes: 10 additions & 0 deletions src/Serein.Pro/Views/MatchPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,14 @@ public MatchPage()

InitializeComponent();
}

private void MenuFlyoutItem_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{

}

private void MenuBarItemFlyout_Opening(object sender, object e)
{

}
}
7 changes: 7 additions & 0 deletions src/Serein.Pro/Views/ServerPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
Unloaded="Page_Unloaded"
mc:Ignorable="d">

<Page.Resources>
<MenuFlyout x:Name="TabViewMenuFlyout">
<MenuFlyoutItem Icon="Add" Text="添加" />
<MenuFlyoutItem Icon="Import" Text="导入" />
</MenuFlyout>
</Page.Resources>

<TabView
x:Name="TabView"
Margin="0,5"
Expand Down
4 changes: 3 additions & 1 deletion src/Serein.Pro/Views/ServerPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ public sealed partial class ServerPage : Page
private readonly DispatcherQueue _dispatcherQueue;
private readonly InfoBarProvider _infoBarProvider;
private readonly MenuBarItemFlyout _tabMenuBarItem;
private readonly MainWindow _mainWindow;
private CancellationTokenSource? _cancellationTokenSource;

public ServerPage()
{
_services = SereinApp.Current!.Services;
_serverManager = _services.GetRequiredService<ServerManager>();
_infoBarProvider = _services.GetRequiredService<InfoBarProvider>();
_mainWindow = _services.GetRequiredService<MainWindow>();
_dispatcherQueue = DispatcherQueue.GetForCurrentThread();

var item1 = new MenuFlyoutItem
Expand Down Expand Up @@ -135,7 +137,7 @@ private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)

private void TabView_AddTabButtonClick(TabView sender, object args)
{

TabViewMenuFlyout.ShowAt(sender);
}

private void Page_Unloaded(object sender, RoutedEventArgs e)
Expand Down
93 changes: 93 additions & 0 deletions src/Serein.Pro/Views/Settings/AboutPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8" ?>
<Page
x:Class="Serein.Pro.Views.Settings.AboutPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Serein.Pro.Views.Settings"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
NavigationCacheMode="Disabled"
mc:Ignorable="d">

<ScrollViewer>
<StackPanel Margin="20">
<controls:SettingsExpander
Description="Copyright © 2022 Zaitonn. All Rights Reserved."
Header="Serein.Pro"
IsExpanded="True">
<controls:SettingsExpander.HeaderIcon>
<BitmapIcon ShowAsMonochrome="False" UriSource="/Assets/logo.ico" />
</controls:SettingsExpander.HeaderIcon>

<controls:SettingsExpander.Items>
<controls:SettingsCard Header="分发许可证">
<HyperlinkButton NavigateUri="https://github.com/SereinDev/Serein?tab=GPL-3.0-1-ov-file#">
GPL-3.0 license
</HyperlinkButton>
</controls:SettingsCard>

<controls:SettingsCard Header="版本号">
<TextBlock
FontSize="12"
IsTextSelectionEnabled="True"
Text="{x:Bind ViewModel.Version}" />
</controls:SettingsCard>

<controls:SettingsCard Header="详细版本">
<TextBlock
FontSize="12"
IsTextSelectionEnabled="True"
Text="{x:Bind ViewModel.DetailedVersion}" />
</controls:SettingsCard>

<controls:SettingsCard Header="程序集">
<TextBlock
FontSize="12"
IsTextSelectionEnabled="True"
Text="{x:Bind ViewModel.AssemblyName}" />
</controls:SettingsCard>

<controls:SettingsCard Header="路径">
<TextBlock
FontSize="12"
IsTextSelectionEnabled="True"
Text="{x:Bind ViewModel.AssemblyPath}" />
</controls:SettingsCard>


<controls:SettingsCard HorizontalContentAlignment="Left" ContentAlignment="Left">
<StackPanel Orientation="Horizontal">
<StackPanel.Resources>
<Style BasedOn="{StaticResource DefaultHyperlinkButtonStyle}" TargetType="HyperlinkButton">
<Setter Property="Margin" Value="3" />
</Style>
</StackPanel.Resources>
<HyperlinkButton Content="Github仓库" NavigateUri="https://github.com/SereinDev/Serein" />
<HyperlinkButton Content="官网/文档" NavigateUri="https://sereindev.github.io/" />
<HyperlinkButton Content="交流群" NavigateUri="https://jq.qq.com/?_wv=1027&amp;k=XNZqPSPv" />
</StackPanel>
</controls:SettingsCard>
</controls:SettingsExpander.Items>
</controls:SettingsExpander>

<TextBlock
Margin="0,10"
Style="{StaticResource SubtitleTextBlockStyle}"
Text="免责声明" />
<TextBlock IsTextSelectionEnabled="True" TextWrapping="WrapWholeWords">
本程序不涉及分发、修改和传播Minecraft客户端及服务端,仅作为服务端的管理软件方便服务器管理员(软件用户)控制服务器,一切行为导致的后果或纠纷由用户自行承担。<LineBreak />
<LineBreak />
· “Minecraft”是 Mojang Synergies AB 的商标<LineBreak />
· 此软件与Mojang Studio、网易、Microsoft没有从属关系<LineBreak />
· 使用本程序启动任何Minecraft服务端即代表您已阅读并同意了<Hyperlink NavigateUri="https://www.minecraft.net/zh-hans/eula">
MINECRAFT 最终用户许可协议
</Hyperlink>
和<Hyperlink NavigateUri="https://account.mojang.com/documents/commercial_guidelines">
MINECRAFT 商业使用准则
</Hyperlink>
</TextBlock>

</StackPanel>
</ScrollViewer>
</Page>
Loading

0 comments on commit 9afa590

Please sign in to comment.