Skip to content

Commit

Permalink
💄 About UI
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Aug 7, 2023
1 parent 7ac9acc commit 790d250
Show file tree
Hide file tree
Showing 15 changed files with 1,323 additions and 931 deletions.
7 changes: 7 additions & 0 deletions WattToolkit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WinAuth", "WinAuth", "{84FF
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinAuth", "ref\WinAuth\src\WinAuth\WinAuth.csproj", "{3F67183A-CC29-4B60-B534-08C2FB1A6746}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BD.WTTS.Client.Tools.OpenSourceLibraryList", "src\BD.WTTS.Client.Tools.OpenSourceLibraryList\BD.WTTS.Client.Tools.OpenSourceLibraryList.csproj", "{64F0101B-F54C-442E-BA70-738ACF72247F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -400,6 +402,10 @@ Global
{3F67183A-CC29-4B60-B534-08C2FB1A6746}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F67183A-CC29-4B60-B534-08C2FB1A6746}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F67183A-CC29-4B60-B534-08C2FB1A6746}.Release|Any CPU.Build.0 = Release|Any CPU
{64F0101B-F54C-442E-BA70-738ACF72247F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{64F0101B-F54C-442E-BA70-738ACF72247F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{64F0101B-F54C-442E-BA70-738ACF72247F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{64F0101B-F54C-442E-BA70-738ACF72247F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -463,6 +469,7 @@ Global
{3A790499-6030-48FF-AD0A-934A0B1EE404} = {5AB1998B-043D-4BC7-B8CE-8A02BCBB3D5E}
{84FF822C-BF60-493F-A8C8-6A413167E3DA} = {90E88965-DB90-4B49-94F5-6D2965491988}
{3F67183A-CC29-4B60-B534-08C2FB1A6746} = {84FF822C-BF60-493F-A8C8-6A413167E3DA}
{64F0101B-F54C-442E-BA70-738ACF72247F} = {D6C8A54D-878F-44A9-857F-6ED01491C7BD}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {567F588F-E95C-4286-8B30-DB3B2200221C}
Expand Down
2 changes: 1 addition & 1 deletion doc/open-source-library.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--👇图标如果发生更改,还需更改 Tools.OpenSourceLibraryList(Program.OpenSourceLibraryListEmoji) -->
<!--👇图标如果发生更改,还需更改 BD.WTTS.Client.Tools.OpenSourceLibraryList(Program.OpenSourceLibraryListEmoji) -->
## 📄 Open Source Library
* [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json)
* [System.Reactive](https://github.com/dotnet/reactive)
Expand Down
Binary file added doc/open-source-library.mpo
Binary file not shown.
1 change: 1 addition & 0 deletions res/icons/avalonia.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/BD.WTTS.Client.Avalonia/UI/Assets/Logos/avaloniaui-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
133 changes: 84 additions & 49 deletions src/BD.WTTS.Client.Avalonia/UI/Views/Pages/About/AboutPage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
<spp:OptionsDisplayItem
Description="{Binding Copyright}"
Expands="True"
Header="{Binding AppName}">
Header="{Binding AppName}"
IsExpanded="True">
<spp:OptionsDisplayItem.Icon>
<ui:ImageIcon Source="avares://BD.WTTS.Client.Avalonia/UI/Assets/ApplicationIcon.ico" />
</spp:OptionsDisplayItem.Icon>
Expand All @@ -46,13 +47,91 @@
Classes="readonlybox"
FontSize="14"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Text="链接" />
<ItemsRepeater>
Text="{ReflectionBinding Path=Res.Link,
Mode=OneWay,
Source={x:Static s:ResourceService.Current}}" />
<ItemsRepeater Margin="0,0,6,6" ItemsSource="{Binding Hyperlinks, Mode=OneTime}">
<ItemsRepeater.Layout>
<UniformGridLayout />
<UniformGridLayout MinItemWidth="166" />
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate />
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="spp:HyperlinkModel">
<ui:HyperlinkButton Command="{Binding Command, Mode=OneTime}" Content="{Binding Text, Mode=OneTime}" />
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
<Border
Height="1"
Margin="-50"
Background="{DynamicResource ApplicationPageBackgroundThemeBrush}" />
<TextBlock
Margin="0,12,0,0"
VerticalAlignment="Center"
Classes="readonlybox"
FontSize="14"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Text="{ReflectionBinding Path=Res.OpenSourceLibrary,
Mode=OneWay,
Source={x:Static s:ResourceService.Current}}" />
<ItemsRepeater Margin="0,0,6,6" ItemsSource="{Binding OSL, Mode=OneTime}">
<ItemsRepeater.Layout>
<UniformGridLayout MinItemWidth="440" />
</ItemsRepeater.Layout>
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="spp:HyperlinkModel">
<ui:HyperlinkButton Command="{Binding Command, Mode=OneTime}" Content="{Binding Text, Mode=OneTime}" />
</DataTemplate>
</ItemsRepeater.ItemTemplate>
</ItemsRepeater>
<Border
Height="1"
Margin="-50"
Background="{DynamicResource ApplicationPageBackgroundThemeBrush}" />
<StackPanel
Margin="0,10,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
Classes="readonlybox"
FontSize="12"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="Powered by " />
<TextBlock
Margin="1,0,0,0"
VerticalAlignment="Center"
Classes="readonlybox"
FontSize="12"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="{Binding RuntimeVersion}"
ToolTip.Tip="{Binding DotnetDesc, Mode=OneTime}" />
<TextBlock
Margin="2,0,2,0"
VerticalAlignment="Center"
Classes="readonlybox"
FontSize="12"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="&amp;" />
<DockPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
ToolTip.Tip="{Binding AvaloniaDesc, Mode=OneTime}">
<Image
Width="18"
Height="18"
Margin="0,0,2,0"
DockPanel.Dock="Left"
Source="avares://BD.WTTS.Client.Avalonia/UI/Assets/Logos/avaloniaui-logo.png" />
<TextBlock
VerticalAlignment="Center"
Classes="readonlybox"
DockPanel.Dock="Right"
FontSize="12"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="{Binding AvaloniaVersion}" />
</DockPanel>
</StackPanel>
</StackPanel>
<Border
Height="1"
Expand All @@ -61,49 +140,5 @@
</StackPanel>
</spp:OptionsDisplayItem.Content>
</spp:OptionsDisplayItem>
<StackPanel
Margin="0,20,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
Classes="readonlybox"
FontSize="12"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="Powered by" />
<DockPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
ToolTip.Tip="{Binding AvaloniaDesc}">
<Image
Width="18"
Height="18"
Margin="4,0,4,0"
DockPanel.Dock="Left"
Source="avares://BD.WTTS.Client.Avalonia/UI/Assets/Logos/avaloniaui-logo.png" />
<TextBlock
VerticalAlignment="Center"
Classes="readonlybox"
DockPanel.Dock="Right"
FontSize="12"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="{Binding AvaloniaVersion}" />
</DockPanel>
<TextBlock
Margin="4,0,5,0"
VerticalAlignment="Center"
Classes="readonlybox"
FontSize="12"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="&amp;" />
<TextBlock
VerticalAlignment="Center"
Classes="readonlybox"
FontSize="12"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
Text="{Binding RuntimeVersion}"
ToolTip.Tip="{Binding DotnetDesc}" />
</StackPanel>
</StackPanel>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyName>pub</AssemblyName>
<OutputType>Exe</OutputType>
<ApplicationIcon>..\..\res\icons\app\v2\Icon.ico</ApplicationIcon>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>TOOL_OSL;$(DefineConstants)</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Release'">
<AllowedReferenceRelatedFileExtensions>
<!-- Prevent default XML and PDB files copied to output in RELEASE.
Only *.allowedextension files will be included, which doesn't exist in my case.
-->
.allowedextension
</AllowedReferenceRelatedFileExtensions>
<DebugType>none</DebugType>
<DebugSymbols>false</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\AssemblyInfo.Constants.cs">
<LinkBase>Properties</LinkBase>
</Compile>
<Compile Remove="..\ImplicitUsings.Common.cs" />
<Compile Include="..\Utils.cs" />
<Compile Include="..\ImplicitUsings.MessagePack.cs">
<LinkBase>Properties</LinkBase>
</Compile>
<Compile Include="..\BD.WTTS.Client\Models\HyperlinkModel.cs">
<LinkBase>Models</LinkBase>
</Compile>
</ItemGroup>

<ItemGroup>
<!-- PackageReference -->
<PackageReference Include="BD.Common" />
</ItemGroup>

<Import Project="..\TFM_NETX.props" />

</Project>
49 changes: 49 additions & 0 deletions src/BD.WTTS.Client.Tools.OpenSourceLibraryList/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using BD.WTTS.Models;

const string OpenSourceLibraryListEmoji = "📄";

var path = Path.Combine(ProjectUtils.ProjPath, "doc", "open-source-library.md");

using var fs = IOPath.OpenRead(path, false);
using var sr = new StreamReader(fs!, Encoding.UTF8);

var list = new List<HyperlinkModel>();
var isOpenSourceLibraryList = false;
string? line;
do
{
line = sr.ReadLine();
if (line == null) break;
if (line.StartsWith("#"))
{
if (isOpenSourceLibraryList)
{
break;
}
if (line.Contains(OpenSourceLibraryListEmoji) && (line.Contains("开源") || (line.Contains("Open") && line.Contains("Source"))))
{
isOpenSourceLibraryList = true;
}
}
if (isOpenSourceLibraryList)
{
if (!string.IsNullOrWhiteSpace(line))
{
if (line.StartsWith("* "))
{
var name = line.Substring("[", "]");
if (string.IsNullOrWhiteSpace(line)) continue;
var index = line.IndexOf("]");
if (index < 0) continue;
var url = line[index..].Substring("(", ")");
if (string.IsNullOrWhiteSpace(url)) continue;
var item = new HyperlinkModel(name, url);
list.Add(item);
}
}
}
}
while (true);

var bytes = Serializable.SMP2(list.OrderBy(x => x.Text).ToArray());
File.WriteAllBytes(path.TrimEnd(".md") + ".mpo", bytes);
9 changes: 9 additions & 0 deletions src/BD.WTTS.Client/BD.WTTS.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Resources\Strings.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
Expand All @@ -200,6 +204,11 @@
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="Resources\Strings.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand Down
15 changes: 13 additions & 2 deletions src/BD.WTTS.Client/Models/HyperlinkModel.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
namespace BD.WTTS.Models;

public sealed class HyperlinkModel
[MP2Obj(SerializeLayout.Explicit)]
public sealed partial class HyperlinkModel
{
[MP2Constructor]
public HyperlinkModel(string text, string url)
{
Text = text;
Url = url;
#if !TOOL_OSL
Command = ReactiveCommand.CreateFromTask(async () =>
{
await Browser2.OpenAsync(url);
});
#endif
}

#if !TOOL_OSL
public HyperlinkModel(string text, ICommand command)
{
Text = text;
Command = command;
}
#endif

[MP2Key(0)]
public string? Text { get; }

[MP2Key(1)]
public string? Url { get; }

public ICommand Command { get; }
#if !TOOL_OSL
[MP2Ignore]
public ICommand? Command { get; }
#endif
}
Loading

0 comments on commit 790d250

Please sign in to comment.