Compare commits

..

5 Commits

Author SHA1 Message Date
Aigio Liu ee4a12e9b5 🚧 Misc 2024-08-13 20:33:37 +08:00
Aigio Liu 5e815ac0d3 🚧 Misc 2024-08-08 21:41:00 +08:00
Aigio Liu 96a14d69bd 🚧 Misc 2024-08-06 17:09:13 +08:00
Aigio Liu c79fba98d3 🚧 Misc 2024-07-04 17:51:15 +08:00
Aigio Liu 4160bb43c5 🚧 Misc 2024-06-29 00:57:23 +08:00
458 changed files with 4042 additions and 9994 deletions
+5 -5
View File
@@ -68,19 +68,19 @@ jobs:
run: dotnet --info
- name: Build BD.WTTS.Client.AppHost
run: dotnet build -c Release src\BD.WTTS.Client.AppHost\BD.WTTS.Client.AppHost.csproj --nologo -v q --property:WarningLevel=1 --property:DebugType=pdbonly
run: dotnet build -c Release src\BD.WTTS.Client.AppHost\BD.WTTS.Client.AppHost.csproj --nologo -v q --property:WarningLevel=1;DebugType=pdbonly
- name: Build BD.WTTS.Client.Plugins.Accelerator.ReverseProxy
run: dotnet build -c Release src\BD.WTTS.Client.Plugins.Accelerator.ReverseProxy\BD.WTTS.Client.Plugins.Accelerator.ReverseProxy.csproj --nologo -v q --property:WarningLevel=1 --property:DebugType=pdbonly
run: dotnet build -c Release src\BD.WTTS.Client.Plugins.Accelerator.ReverseProxy\BD.WTTS.Client.Plugins.Accelerator.ReverseProxy.csproj --nologo -v q --property:WarningLevel=1;DebugType=pdbonly
- name: Build BD.WTTS.Client.Avalonia.App
run: dotnet build -c Release src\BD.WTTS.Client.Avalonia.App\BD.WTTS.Client.Avalonia.App.csproj --nologo -v q --property:WarningLevel=1 --property:DebugType=pdbonly
run: dotnet build -c Release src\BD.WTTS.Client.Avalonia.App\BD.WTTS.Client.Avalonia.App.csproj --nologo -v q --property:WarningLevel=1;DebugType=pdbonly
- name: Build BD.WTTS.Client.Avalonia.Designer.HostApp
run: dotnet build -c Release src\BD.WTTS.Client.Avalonia.Designer.HostApp\BD.WTTS.Client.Avalonia.Designer.HostApp.csproj --nologo -v q --property:WarningLevel=1 --property:DebugType=pdbonly
run: dotnet build -c Release src\BD.WTTS.Client.Avalonia.Designer.HostApp\BD.WTTS.Client.Avalonia.Designer.HostApp.csproj --nologo -v q --property:WarningLevel=1;DebugType=pdbonly
- name: Test
run: dotnet test src/BD.WTTS.UnitTest/BD.WTTS.UnitTest.csproj -c Release -p:GeneratePackageOnBuild=false --nologo -v q --property:WarningLevel=1 --property:DebugType=pdbonly
run: dotnet test src/BD.WTTS.UnitTest/BD.WTTS.UnitTest.csproj -c Release -p:GeneratePackageOnBuild=false --nologo -v q --property:WarningLevel=1;DebugType=pdbonly
# release:
# name: Release
+1 -1
View File
@@ -16,7 +16,7 @@
[![NET 7.0](https://img.shields.io/badge/dotnet-7.0-purple.svg?style=flat-square&color=512bd4)](https://learn.microsoft.com/zh-cn/dotnet/core/whats-new/dotnet-7)
[![C# 11](https://img.shields.io/badge/c%23-11-brightgreen.svg?style=flat-square&color=6da86a)](https://learn.microsoft.com/zh-cn/dotnet/csharp/whats-new/csharp-11)
[![爱发电](https://img.shields.io/badge/爱发电-软妹币玩家-blue.svg?style=flat-square&color=ea4aaa&logo=github-sponsors)](https://afdian.com/@rmbgame)
[![爱发电](https://img.shields.io/badge/爱发电-软妹币玩家-blue.svg?style=flat-square&color=ea4aaa&logo=github-sponsors)](https://afdian.net/@rmbgame)
[![Kofi](https://img.shields.io/badge/Kofi-RMBGAME-orange.svg?style=flat-square&logo=kofi)](https://ko-fi.com/rmbgame)
[![Patreon](https://img.shields.io/badge/Patreon-RMBGAME-red.svg?style=flat-square&logo=patreon)](https://www.patreon.com/rmbgame)
+9 -63
View File
@@ -3,12 +3,6 @@
default_base_path="$HOME/WattToolkit"
base_path="$default_base_path"
# 检查是否以root身份执行
if [ "$EUID" -eq 0 ]; then
echo "此脚本不能以root身份执行。"
exit 1
fi
# 循环直到用户输入有效路径或直接回车
while true; do
# 使用 zenity 提示用户选择安装路径或使用默认路径
@@ -47,45 +41,7 @@ base_url="https://api.steampp.net"
architecture=1
app_name="Watt Toolkit"
PROCESS_NAMES=("$exec_name" "$app_name")
Check_LC_Code() {
# 检查当前 LANG 环境变量
current_lang="${LC_ALL:-$LANG}"
echo "当前语言环境: $current_lang"
# 检查是否为 C 或 C.UTF-8
if [ "$current_lang" = "C" ] || [ "$current_lang" = "C.UTF-8" ]; then
echo "当前语言环境是 C 或 C.UTF-8,需要修改。"
# 列出系统支持的语言环境
supported_locales=$(locale -a)
if [ -z "$supported_locales" ]; then
echo "未能获取到支持的语言环境列表。请检查系统配置。"
return 1
fi
# 遍历支持的语言环境列表,找到第一个不是 C 或 C.UTF-8 的项
first_non_c_locale=""
for locale in $supported_locales; do
if [ "$locale" != "C" ] && [ "$locale" != "C.UTF-8" ]; then
first_non_c_locale="$locale"
break
fi
done
# 检查是否找到了非 C/C.UTF-8 的语言环境
if [ -n "$first_non_c_locale" ]; then
echo "修改语言环境为支持列表中的第一个非 C/C.UTF-8 项:$first_non_c_locale"
export LC_ALL="$first_non_c_locale"
echo "语言环境已修改为 $first_non_c_locale。"
else
echo "未能找到非 C/C.UTF-8 的语言环境。请检查系统配置。"
return 1
fi
else
echo "当前语言环境不是 C 或 C.UTF-8,无需修改。"
fi
}
Check_LC_Code
export LC_ALL=en_US.UTF-8
Install_certutil() {
# 判断发行版类型
if command -v certutil &>/dev/null; then
@@ -404,44 +360,34 @@ Kill_Process
Decompression
# xdg-icon-resource install "$base_path/Icons/Watt-Toolkit.png" --size 128 Watt-Toolkit
InitDesktop() {
# 检查XDG_DESKTOP_DIR环境变量,如果未设置则使用默认值
XDG_DESKTOP_DIR="${XDG_DESKTOP_DIR:-$HOME/Desktop}"
while true; do
# 使用 zenity 提示用户选择安装路径或使用默认路径
choice=$(zenity --list --radiolist --title="请选择要添加到的位置" \
--column="选择" --column="路径" \
TRUE "$XDG_DESKTOP_DIR" \
FALSE "$HOME/.local/share/applications/")
choice=$(zenity --list --radiolist --title="请选择要添加到的位置" --column="选择" --column="路径" TRUE "$HOME/.local/share/applications/" FALSE "$HOME/Desktop")
# 检查用户输入
if [ "$choice" == "$HOME/.local/share/applications/" ]; then
target_dir="$HOME/.local/share/applications/"
break
elif [ "$choice" == "$XDG_DESKTOP_DIR" ]; then
target_dir="$XDG_DESKTOP_DIR"
elif [ "$choice" == "$HOME/Desktop" ]; then
target_dir="$HOME/Desktop/"
break
else
# 无效选项时给出提示,并继续循环
zenity --info --text="无效选项,请重新选择。"
echo "无效选项,请输入 1 或 2。"
fi
done
# 添加桌面文件
#添加桌面文件
rm -rf "$target_dir/Watt Toolkit.desktop" 2>/dev/null
cat <<EOT > "$target_dir/Watt Toolkit.desktop"
echo "#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Watt Toolkit
Exec=$base_path/$exec_name.sh
Icon=$base_path/Icons/Watt-Toolkit.png
Terminal=false
Type=Application
StartupNotify=false
EOT
StartupNotify=false" >"$target_dir/Watt Toolkit.desktop"
chmod +x "$target_dir/Watt Toolkit.desktop"
}
InitDesktop
# update-desktop-database ~/.local/share/applications
#运行程序
+1 -10
View File
@@ -973,7 +973,7 @@
},
{
"TypeName": "string",
"PropertyName": "CustomDohAddres2",
"PropertyName": "CustomDohAddres",
"DefaultValue": "null",
"DefaultValueIsConst": true,
"Summary": "自定义 DNS over HTTPS 地址",
@@ -988,15 +988,6 @@
"Summary": "加速页面 Tab 选项卡选中下标",
"IsRegionOrEndregion": null,
"IsValueType": null
},
{
"TypeName": "bool",
"PropertyName": "AutoShowWattAcceleratorWindow",
"DefaultValue": "true",
"DefaultValueIsConst": true,
"Summary": "加速后自动唤起 Watt 加速器界面",
"IsRegionOrEndregion": null,
"IsValueType": null
}
],
"Usings": ""
-5
View File
@@ -1,5 +0,0 @@
<Project>
<PropertyGroup>
<CheckEolWorkloads>false</CheckEolWorkloads>
</PropertyGroup>
</Project>
BIN
View File
Binary file not shown.
-11
View File
@@ -1,11 +0,0 @@
static void WinDivert()
{
var dllWinDivert = Path.Combine(ProjectUtils.ProjPath, "ref", "WinDivert.dll");
var sysWinDivert64 = Path.Combine(ProjectUtils.ProjPath, "ref", "WinDivert64.sys");
byte[][] data = [File.ReadAllBytes(dllWinDivert), File.ReadAllBytes(sysWinDivert64)];
var bytes = MemoryPackSerializer.Serialize(data);
bytes.AsSpan().Reverse();
File.WriteAllBytes(Path.Combine(ProjectUtils.ProjPath, "ref", "WinDivert.mpo"), bytes);
}
+27 -3
View File
@@ -3,6 +3,14 @@ namespace BD.WTTS;
/// <summary>
/// 提供用来获取应用程序信息(如版本号、说明、加载的程序集等)的属性。
/// </summary>
[Mobius3(
"""
Mobius.AssemblyInfo
AssemblyInfo.cs
AssemblyInfo.Version.cs
AssemblyInfo.Version.NativeHost.cs
AssemblyInfo.Version.Setup.Windows.cs
""")]
public static partial class AssemblyInfo
{
const string Version2 = "3.0";
@@ -16,14 +24,14 @@ public static partial class AssemblyInfo
/// <summary>
/// 预览版本号,范围 1~9,只增不减
/// </summary>
const string ver_for_preview = "9";
const string ver_for_preview = "8";
/// <summary>
/// RC 版本号,范围 0~9,只增不减
/// </summary>
const string ver_for_rc = "12";
const string ver_for_rc = "8";
public const string FileVersion = $"{Version2}.{ver_for_rc}1{ver_for_preview}.0";
public const string FileVersion = $"{Version2}.{ver_for_rc}0{ver_for_preview}.0";
//public const string InformationalVersion = Version;
//public const string InformationalVersion = $"{Version}-preview.{ver_for_preview}";
@@ -146,4 +154,20 @@ false
#endif
}
[AttributeUsage(AttributeTargets.All, Inherited = false)]
sealed class Mobius3Attribute : Attribute
{
public Mobius3Attribute()
{
}
public Mobius3Attribute(string str)
{
}
public bool Obsolete { get; set; }
}
+1
View File
@@ -1,3 +1,4 @@
// Mobius Properties\XmlnsDefinition.cs
#if (WINDOWS || MACCATALYST || MACOS || LINUX) && !(IOS || ANDROID)
// C# 10 定义全局 using
@@ -7,7 +7,6 @@
<DelaySign>false</DelaySign>
<AssemblyOriginatorKeyFile>$(MSBuildProjectDirectory)\..\..\avalonia.snk</AssemblyOriginatorKeyFile>
<!--https://github.com/AvaloniaUI/Avalonia/blob/0.10.10/build/SharedVersion.props#L18-->
<AvaloniaAccessUnstablePrivateApis>true</AvaloniaAccessUnstablePrivateApis>
</PropertyGroup>
<ItemGroup>
File diff suppressed because it is too large Load Diff
@@ -11,7 +11,7 @@
<Identity
Name="4651ED44255E.47979655102CE"
Publisher="CN=A90E406B-B2D3-4A23-B061-0FA1D65C4F66"
Version="3.0.207.0" />
Version="3.0.999.0" />
<Properties>
<DisplayName>Watt Toolkit</DisplayName>
@@ -66,15 +66,6 @@
</Application>
</Applications>
<Extensions>
<desktop2:Extension Category="windows.firewallRules">
<desktop2:FirewallRules Executable="Steam++\modules\Accelerator\Steam++.Accelerator.exe">
<desktop2:Rule Direction="in" IPProtocol="TCP" Profile="all"/>
<desktop2:Rule Direction="in" IPProtocol="UDP" Profile="all"/>
</desktop2:FirewallRules>
</desktop2:Extension>
</Extensions>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
@@ -91,6 +91,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BD.Common.XmlnsDefinition.Avalonia">
<Aliases>BD_Common_XmlnsDefinition_Avalonia</Aliases>
</PackageReference>
<ProjectReference Include="..\BD.WTTS.Client.Avalonia\BD.WTTS.Client.Avalonia.csproj" />
<ProjectReference Include="..\BD.WTTS.Client\BD.WTTS.Client.csproj" />
</ItemGroup>
@@ -68,6 +68,9 @@
<ItemGroup>
<PackageReference Include="Moq" />
<PackageReference Include="BD.Common.XmlnsDefinition.Avalonia">
<Aliases>BD_Common_XmlnsDefinition_Avalonia</Aliases>
</PackageReference>
<ProjectReference Include="..\BD.WTTS.Client.Avalonia\BD.WTTS.Client.Avalonia.csproj" />
<ProjectReference Include="..\BD.WTTS.Client.Plugins.Accelerator\BD.WTTS.Client.Plugins.Accelerator.csproj" />
<ProjectReference Include="..\BD.WTTS.Client.Plugins.ArchiSteamFarmPlus\BD.WTTS.Client.Plugins.ArchiSteamFarmPlus.csproj" />
@@ -4,7 +4,6 @@
<RootNamespace>BD.WTTS</RootNamespace>
<DefineConstants>AVALONIA;$(DefineConstants)</DefineConstants>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<AvaloniaAccessUnstablePrivateApis>true</AvaloniaAccessUnstablePrivateApis>
</PropertyGroup>
<ItemGroup>
@@ -73,6 +72,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BD.Common.XmlnsDefinition.Avalonia">
<Aliases>BD_Common_XmlnsDefinition_Avalonia</Aliases>
</PackageReference>
<PackageReference Include="BD.Common" />
<PackageReference Include="BD.Common.Primitives" />
<PackageReference Include="BD.Common.Essentials" />
@@ -1,203 +0,0 @@
using Avalonia.Reactive;
using Avalonia.Xaml.Interactions.Responsive;
using Avalonia.Xaml.Interactivity;
namespace BD.WTTS.Behaviors;
/// <summary>
/// Observes <see cref="Behavior{T}.AssociatedObject"/> control or <see cref="SourceControl"/> control <see cref="Visual.Bounds"/> property changes and if triggered sets or removes style classes when conditions from <see cref="AdaptiveClassSetter"/> are met.
/// </summary>
public class AdaptiveBehavior : Behavior<Control>
{
private IDisposable? _disposable;
private AvaloniaList<AdaptiveClassSetter>? _setters;
/// <summary>
/// Identifies the <seealso cref="SourceControl"/> avalonia property.
/// </summary>
public static readonly StyledProperty<Control?> SourceControlProperty =
AvaloniaProperty.Register<AdaptiveBehavior, Control?>(nameof(SourceControl));
/// <summary>
/// Identifies the <seealso cref="TargetControl"/> avalonia property.
/// </summary>
public static readonly StyledProperty<Control?> TargetControlProperty =
AvaloniaProperty.Register<AdaptiveBehavior, Control?>(nameof(TargetControl));
/// <summary>
/// Identifies the <seealso cref="Setters"/> avalonia property.
/// </summary>
public static readonly DirectProperty<AdaptiveBehavior, AvaloniaList<AdaptiveClassSetter>> SettersProperty =
AvaloniaProperty.RegisterDirect<AdaptiveBehavior, AvaloniaList<AdaptiveClassSetter>>(nameof(Setters), t => t.Setters);
/// <summary>
/// Gets or sets the the source control that <see cref="Visual.BoundsProperty"/> property are observed from, if not set <see cref="Behavior{T}.AssociatedObject"/> is used. This is a avalonia property.
/// </summary>
[ResolveByName]
public Control? SourceControl
{
get => GetValue(SourceControlProperty);
set => SetValue(SourceControlProperty, value);
}
/// <summary>
/// Gets or sets the target control that class name that should be added or removed when triggered, if not set <see cref="Behavior{T}.AssociatedObject"/> is used or <see cref="AdaptiveClassSetter.TargetControl"/> from <see cref="AdaptiveClassSetter"/>. This is a avalonia property.
/// </summary>
[ResolveByName]
public Control? TargetControl
{
get => GetValue(TargetControlProperty);
set => SetValue(TargetControlProperty, value);
}
/// <summary>
/// Gets adaptive class setters collection. This is a avalonia property.
/// </summary>
[Content]
public AvaloniaList<AdaptiveClassSetter> Setters => _setters ??= new AvaloniaList<AdaptiveClassSetter>();
/// <inheritdoc/>
protected override void OnAttachedToVisualTree()
{
base.OnAttachedToVisualTree();
StopObserving();
StartObserving();
}
/// <inheritdoc/>
protected override void OnDetachedFromVisualTree()
{
base.OnDetachedFromVisualTree();
StopObserving();
}
private void StartObserving()
{
var sourceControl = GetValue(SourceControlProperty) is not null
? SourceControl
: AssociatedObject;
if (sourceControl is not null)
{
_disposable = ObserveBounds(sourceControl);
}
}
private void StopObserving()
{
_disposable?.Dispose();
}
private IDisposable ObserveBounds(Control sourceControl)
{
if (sourceControl is null)
{
throw new ArgumentNullException(nameof(sourceControl));
}
return sourceControl.GetObservable(Visual.BoundsProperty)
.Subscribe(new AnonymousObserver<Rect>(bounds => ValueChanged(sourceControl, Setters, bounds)));
}
private void ValueChanged(Control? sourceControl, AvaloniaList<AdaptiveClassSetter>? setters, Rect bounds)
{
if (sourceControl is null || setters is null)
{
return;
}
foreach (var setter in setters)
{
var isMinOrMaxWidthSet = setter.IsSet(AdaptiveClassSetter.MinWidthProperty)
|| setter.IsSet(AdaptiveClassSetter.MaxWidthProperty);
var widthConditionTriggered = GetResult(setter.MinWidthOperator, bounds.Width, setter.MinWidth)
&& GetResult(setter.MaxWidthOperator, bounds.Width, setter.MaxWidth);
var isMinOrMaxHeightSet = setter.IsSet(AdaptiveClassSetter.MinHeightProperty)
|| setter.IsSet(AdaptiveClassSetter.MaxHeightProperty);
var heightConditionTriggered = GetResult(setter.MinHeightOperator, bounds.Height, setter.MinHeight)
&& GetResult(setter.MaxHeightOperator, bounds.Height, setter.MaxHeight);
var isAddClassTriggered = isMinOrMaxWidthSet switch
{
true when !isMinOrMaxHeightSet => widthConditionTriggered,
false when isMinOrMaxHeightSet => heightConditionTriggered,
true when isMinOrMaxHeightSet => widthConditionTriggered && heightConditionTriggered,
_ => false
};
var targetControl = setter.GetValue(AdaptiveClassSetter.TargetControlProperty) is not null
? setter.TargetControl
: GetValue(TargetControlProperty) is not null
? TargetControl
: AssociatedObject;
if (targetControl is not null)
{
var className = setter.ClassName;
var isPseudoClass = setter.IsPseudoClass;
if (isAddClassTriggered)
{
Add(targetControl, className, isPseudoClass);
}
else
{
Remove(targetControl, className, isPseudoClass);
}
}
}
}
private bool GetResult(ComparisonConditionType comparisonConditionType, double property, double value)
{
return comparisonConditionType switch
{
// ReSharper disable once CompareOfFloatsByEqualityOperator
ComparisonConditionType.Equal => property == value,
// ReSharper disable once CompareOfFloatsByEqualityOperator
ComparisonConditionType.NotEqual => property != value,
ComparisonConditionType.LessThan => property < value,
ComparisonConditionType.LessThanOrEqual => property <= value,
ComparisonConditionType.GreaterThan => property > value,
ComparisonConditionType.GreaterThanOrEqual => property >= value,
_ => throw new ArgumentOutOfRangeException()
};
}
private static void Add(Control targetControl, string? className, bool isPseudoClass)
{
if (className is null || string.IsNullOrEmpty(className) || targetControl.Classes.Contains(className))
{
return;
}
if (isPseudoClass)
{
((IPseudoClasses)targetControl.Classes).Add(className);
}
else
{
targetControl.Classes.Add(className);
}
}
private static void Remove(Control targetControl, string? className, bool isPseudoClass)
{
if (className is null || string.IsNullOrEmpty(className) || !targetControl.Classes.Contains(className))
{
return;
}
if (isPseudoClass)
{
((IPseudoClasses)targetControl.Classes).Remove(className);
}
else
{
targetControl.Classes.Remove(className);
}
}
}
@@ -1,5 +1,9 @@
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.WaveProgressGradientOffsetConverter
""")]
public sealed class BitmapAssetValueConverter : ImageValueConverter
{
public override object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
@@ -1,5 +1,9 @@
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.ColorStringToBrushConverter
""")]
public sealed class ColorStringToBrushConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
@@ -1,5 +1,9 @@
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.EnumConverter
""")]
public sealed class EnumConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
@@ -2,6 +2,10 @@ using IBinding = BD.WTTS.Converters.Abstractions.IBinding;
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.EnumEqualValueConverter
""")]
public sealed class EnumEqualValueConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
@@ -1,5 +1,9 @@
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.EnumLocalizationNameConverter
""")]
public sealed class EnumLocalizationNameConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
@@ -2,6 +2,10 @@ using SkiaSharp;
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.Abstractions.ImageValueConverter
""")]
public abstract class ImageValueConverter : IValueConverter
{
public abstract object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture);
@@ -46,6 +50,7 @@ public abstract class ImageValueConverter : IValueConverter
/// <param name="clipStream"></param>
/// <param name="bitmap"></param>
/// <returns></returns>
[Mobius("", Obsolete = true)]
static bool TryGetBitmap([NotNullWhen(true)] ImageSource.ClipStream? clipStream, [NotNullWhen(true)] out SKBitmap? bitmap)
{
if (clipStream?.Stream == null)
@@ -1,5 +1,9 @@
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.IsNullConverter
""")]
public sealed class IsNullConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
@@ -1,5 +1,9 @@
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.NameToFontFamilyConverter
""")]
public sealed class NameToFontFamilyConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
@@ -1,5 +1,9 @@
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.RangeToSweepConverter
""")]
public sealed class RangeToSweepConverter : IMultiValueConverter
{
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
@@ -1,5 +1,9 @@
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.ResourceKeyValueConverter
""")]
public sealed class ResourceKeyValueConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
@@ -1,5 +1,9 @@
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.StringEqualsConverter
""")]
public class StringEqualsConverter : IValueConverter
{
static string ToString(object? obj) => obj?.ToString() ?? string.Empty;
@@ -2,6 +2,10 @@ using SteamKit2;
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.StringFormatConverter
""")]
public sealed class StringFormatConverter : IValueConverter, IMultiValueConverter
{
const string Size = "size";
@@ -1,5 +1,9 @@
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.VisibleStringConverter
""")]
public sealed class VisibleStringConverter : IMultiValueConverter
{
public object? Convert(IList<object?> values, Type targetType, object? parameter, CultureInfo culture)
@@ -1,5 +1,9 @@
namespace BD.WTTS.Converters;
[Mobius(
"""
Mobius.UI.Converters.WaveProgressValueConverter
""")]
public sealed class WaveProgressValueConverter : IValueConverter
{
public static readonly WaveProgressValueConverter Instance = new();
@@ -18,6 +22,10 @@ public sealed class WaveProgressValueConverter : IValueConverter
}
}
[Mobius(
"""
Mobius.UI.Converters.WaveProgressValueColorConverter
""")]
public class WaveProgressValueColorConverter : IValueConverter
{
public static readonly WaveProgressValueColorConverter Instance = new();
@@ -37,6 +45,10 @@ public class WaveProgressValueColorConverter : IValueConverter
}
}
[Mobius(
"""
Mobius.UI.Converters.WaveProgressValueTextConverter
""")]
public class WaveProgressValueTextConverter : IValueConverter
{
public static readonly WaveProgressValueTextConverter Instance = new();
@@ -54,6 +66,10 @@ public class WaveProgressValueTextConverter : IValueConverter
}
}
[Mobius(
"""
Mobius.UI.Converters.WaveProgressGradientOffsetConverter
""")]
public class WaveProgressGradientOffsetConverter : IValueConverter
{
public static readonly WaveProgressGradientOffsetConverter Instance = new();
@@ -2,6 +2,10 @@ namespace BD.WTTS.UI;
public static class ControlExtensions
{
[Mobius(
"""
Mobius.UI.ControlExtensions.SetViewModel
""")]
public static void SetViewModel<T>(this Control c, bool useCache = false) where T : ViewModelBase, new()
{
if (c.DataContext == null || c.DataContext.GetType() != typeof(T))
@@ -3,6 +3,10 @@ namespace BD.WTTS;
/// <summary>
/// <see cref="IEnumerable"/> extensions methods
/// </summary>
[Mobius(
"""
Mobius.IEnumerableExtensions
""")]
public static class IEnumerableExtensions
{
public static IEnumerable<IEnumerable> Batch(this IEnumerable source, int size)
@@ -1,6 +1,10 @@
// ReSharper disable once CheckNamespace
namespace Avalonia.Controls;
[BD.Mobius(
"""
Mobius.UI.WindowExtensions
""")]
public static partial class WindowExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -3,6 +3,10 @@ namespace BD.WTTS;
public static class WindowTransparencyLevelExtensions
{
[Mobius(
"""
Mobius.Enums.UI.WindowTransparencyLevelExtensions
""")]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static WindowTransparencyLevel ToWindowTransparencyLevel(
this WindowBackgroundMaterial value)
@@ -13,7 +17,6 @@ public static class WindowTransparencyLevelExtensions
WindowBackgroundMaterial.Blur => WindowTransparencyLevel.Blur,
WindowBackgroundMaterial.AcrylicBlur => WindowTransparencyLevel.AcrylicBlur,
WindowBackgroundMaterial.Mica => WindowTransparencyLevel.Mica,
WindowBackgroundMaterial.Transparent => WindowTransparencyLevel.Transparent,
_ => WindowTransparencyLevel.None,
};
}
@@ -2,6 +2,10 @@ using BD.WTTS.Markup.Abstractions;
namespace BD.WTTS.Markup;
[Mobius(
"""
Mobius.UI.Markup.OnPlatformExtension
""")]
public sealed class OnPlatformExtension : MarkupExtension<bool>
{
public OnPlatformExtension(string member) : base(member)
@@ -11,7 +11,6 @@
[assembly: XmlnsDefinition("https://steampp.net/ui", "BD.WTTS.UI.Views.Windows")]
[assembly: XmlnsDefinition("https://steampp.net/ui", "BD.WTTS.Converters")]
[assembly: XmlnsDefinition("https://steampp.net/ui", "BD.WTTS.Markup")]
[assembly: XmlnsDefinition("https://steampp.net/ui", "BD.WTTS.Behaviors")]
[assembly: XmlnsDefinition("https://steampp.net/services", "BD.WTTS.Services")]
[assembly: XmlnsDefinition("https://steampp.net/services", "BD.WTTS.Plugins")]
[assembly: XmlnsDefinition("https://steampp.net/services", "BD.WTTS.Plugins.Abstractions")]
@@ -1,5 +1,9 @@
namespace BD.WTTS.Services.Implementation;
[Mobius(
"""
BD.Common8.Essentials.Services.Implementation.AvaloniaMainThreadPlatformServiceImpl
""")]
sealed class MainThreadPlatformServiceImpl : IMainThreadPlatformService
{
public bool PlatformIsMainThread
@@ -4,10 +4,18 @@ using System.Collections.Immutable;
namespace BD.WTTS.Services.Implementation;
/// <inheritdoc cref="IWindowManager"/>
[Mobius(
"""
Mobius.Services.WindowManagerService
""")]
public sealed class AvaloniaWindowManagerImpl : IWindowManagerImpl
{
Type? IWindowManagerImpl.WindowType => typeof(Window);
[Mobius(
"""
Mobius.Services.WindowManagerService.GetWindowTopLevel
""")]
public static TopLevel? GetWindowTopLevel()
{
if (App.Instance.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
@@ -95,7 +103,7 @@ public sealed class AvaloniaWindowManagerImpl : IWindowManagerImpl
Func<bool>? cancelCloseAction = null,
bool disableScroll = false)
where TPageViewModel : ViewModelBase
{
{
var td = new TaskDialogEx
{
Title = title,
@@ -111,12 +119,6 @@ public sealed class AvaloniaWindowManagerImpl : IWindowManagerImpl
XamlRoot = GetWindowTopLevel(),
};
if (td.XamlRoot == null)
{
Toast.LogAndShowT(new Exception("在 AppWindow 为 Null 时,无法弹出 Taskdialog."));
return false;
}
if (viewModel != null)
{
if (viewModel is IWindowViewModel window)
@@ -3,6 +3,10 @@ using static System.Net.Mime.MediaTypeNames;
namespace BD.WTTS.Services.Implementation;
[Mobius(
"""
BD.Common8.Essentials.Services.Implementation.AvaloniaClipboardPlatformServiceImpl
""")]
public sealed class AvaloniaClipboardPlatformService : IClipboardPlatformService
{
public bool PlatformHasText => !string.IsNullOrEmpty(PlatformGetTextAsync().GetAwaiter().GetResult());
@@ -5,6 +5,10 @@ using AvaNotificationType = Avalonia.Controls.Notifications.NotificationType;
namespace BD.WTTS.Services.Implementation;
[Mobius(
"""
Mobius.Services.ToastService
""")]
[TemplatePart("PART_Items", typeof(Panel))]
[PseudoClasses(":topleft", ":topright", ":bottomleft", ":bottomright")]
sealed class AvaloniaToastServiceImpl : IToastService
@@ -44,14 +48,12 @@ sealed class AvaloniaToastServiceImpl : IToastService
if (NotificationManager == null)
{
var host = AvaloniaWindowManagerImpl.GetWindowTopLevel();
if (host != null)
NotificationManager = new SnackbarManager(host)
{
NotificationManager = new SnackbarManager(host)
{
Position = NotificationPosition.BottomRight,
MaxItems = 5,
};
}
Position = NotificationPosition.BottomRight,
MaxItems = 5,
};
}
var notificationType = GetNotificationType(icon);
@@ -8,6 +8,10 @@ using WinUI = Windows.UI.StartScreen;
namespace BD.WTTS.Services.Implementation;
/// <inheritdoc cref="IJumpListService"/>
[Mobius(
"""
Mobius.Services.Platform.Windows.Abstractions.IJumpListService
""")]
internal sealed class JumpListServiceImpl : IJumpListService
{
#if WINDOWS
@@ -6,6 +6,10 @@ using System.Xml.Linq;
namespace BD.WTTS.Services.Implementation;
[Mobius(
"""
Mobius.Services.NavigationService
""")]
public sealed class NavigationService : INavigationService
{
public static NavigationService Instance { get; } = (NavigationService)Ioc.Get<INavigationService>();
@@ -14,6 +18,14 @@ public sealed class NavigationService : INavigationService
public Type? CurrnetPage => _frame?.CurrentSourcePageType;
[Mobius(
"""
isCreateInstance = true
Mobius.Services.NavigationService.GetViewModelToPageContent
isCreateInstance = false
Mobius.Services.NavigationService.GetViewModelToPageContentType
""")]
public object? GetViewModelToPageContent(object viewModel, bool isCreateInstance = true)
{
string name;
@@ -7,12 +7,28 @@ namespace BD.WTTS.UI;
partial class App
{
[Mobius(
"""
App.DefaultActualTheme
""")]
const AppTheme _DefaultActualTheme = AppTheme.FollowingSystem;
[Mobius(
"""
App.DefaultActualTheme
""")]
AppTheme IApplication.DefaultActualTheme => _DefaultActualTheme;
[Mobius(
"""
App.mTheme
""")]
AppTheme mTheme = _DefaultActualTheme;
[Mobius(
"""
App.Theme
""")]
public AppTheme Theme
{
get => mTheme;
@@ -50,6 +66,10 @@ partial class App
}
}
[Mobius(
"""
App.SetThemeNotChangeValue
""")]
public void SetThemeNotChangeValue(AppTheme value)
{
var mode = value switch
@@ -71,6 +91,10 @@ partial class App
}
}
[Mobius(
"""
App.SetThemeAccent
""")]
public static void SetThemeAccent(string? colorHex)
{
if (colorHex == null)
+29 -41
View File
@@ -9,14 +9,34 @@ namespace BD.WTTS.UI;
partial class App
{
[Mobius(
"""
App.TrayMenus
""")]
public Dictionary<string, TrayMenuItem> TrayMenus { get; } = new Dictionary<string, TrayMenuItem>();
[Mobius(
"""
App.TrayIcons
""")]
public TrayIcons TrayIcons { get; init; } = new TrayIcons();
[Mobius(
"""
App.trayIconMenus
""")]
readonly Dictionary<string, ICommand> trayIconMenus = new();
[Mobius(
"""
App.TrayIconMenus
""")]
public IReadOnlyDictionary<string, ICommand> TrayIconMenus => trayIconMenus;
[Mobius(
"""
App.InitTrayIcon
""")]
void InitTrayIcon()
{
if (ApplicationLifetime is not
@@ -63,50 +83,14 @@ partial class App
#else
s.HasTrayIcon ? ShutdownMode.OnExplicitShutdown : ShutdownMode.OnMainWindowClose;
#endif
#if MACOS
if (Current!.TryGetFeature<IActivatableLifetime>() is { } activatableLifetime)
{
activatableLifetime.Activated += ActivatableLifetimeOnActivated;
// macOS 中 右键隐藏 会触发目前不需要使用
//activatableLifetime.Deactivated += ActivatableLifetimeOnDeactivated;
}
#endif
}
}
#if MACOS
/// <summary>
/// 从 macOS Dock 栏恢复窗口显示
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ActivatableLifetimeOnActivated(object? sender, ActivatedEventArgs e)
{
switch (e.Kind)
{
case ActivationKind.Background:
case ActivationKind.Reopen:
RestoreMainWindow();
break;
}
}
///// <summary>
///// macOS 中 右键隐藏 会触发目前不需要使用
///// </summary>
///// <param name="sender"></param>
///// <param name="e"></param>
//private void ActivatableLifetimeOnDeactivated(object? sender, ActivatedEventArgs e)
//{
// switch (e.Kind)
// {
// case ActivationKind.Background:
// Console.WriteLine($"ActivatableLifetimeOnDeactivated {e.Kind}");
// break;
// }
//}
#endif
[Mobius(
"""
App.UpdateMenuItems
""")]
public void UpdateMenuItems()
{
MainThread2.BeginInvokeOnMainThread(() =>
@@ -206,6 +190,10 @@ partial class App
});
}
[Mobius(
"""
App.UpdateMenuItems
""")]
public void UpdateMenuItems(string menuKey, TrayMenuItem trayMenuItem)
{
if (TrayMenus != null)
+15 -6
View File
@@ -7,6 +7,10 @@ using System.Drawing.Drawing2D;
namespace BD.WTTS.UI;
[Mobius(
"""
Mobius.UI.App
""")]
public sealed partial class App : Application
{
const string TAG = "AvaApp";
@@ -111,12 +115,6 @@ public sealed partial class App : Application
{
Task2.InBackground(() => appWindow.SplashScreen?.RunTasks(CancellationToken.None));
}
IPlatformService.Instance.SetSystemSessionEnding(() =>
{
Log.Info("System Shutdown", "Application SafeExit...");
Shutdown();
});
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleView)
{
@@ -239,6 +237,12 @@ public sealed partial class App : Application
public ICommand OpenBrowserCommand { get; }
[Mobius(
"""
Mobius.UI.App.OpenBrowserCommandCore
1. 不提示 打开链接失败
2. 使用统一的 OpenAuthUrl
""")]
public async void OpenBrowserCommandCore(object? url)
{
try
@@ -272,6 +276,11 @@ public sealed partial class App : Application
public ICommand CopyToClipboardCommand { get; }
[Mobius(
"""
Mobius.UI.App.OpenBrowserCommandCore
1. 不提示 复制内容失败
""")]
public async void CopyToClipboardCommandCore(object? text)
{
try
@@ -5,6 +5,10 @@ using Visual = Avalonia.Visual;
namespace BD.WTTS.UI;
[Mobius(
"""
Mobius.UI.Animations.Animations
""")]
public static class Animations
{
private static readonly Easing DefaultEasing = new LinearEasing();
@@ -3,6 +3,10 @@ using System.Windows.Input;
namespace BD.WTTS.UI;
[Mobius(
"""
Mobius.UI.Views.Controls.Stepper.DelegateInputCommand
""")]
internal class Command : ICommand
{
private readonly Action<object?> _onExecute;
@@ -3,6 +3,10 @@ using FluentAvalonia.UI.Media.Animation;
namespace BD.WTTS.UI;
[Mobius(
"""
Mobius.UI.Animations.FrameEffect
""")]
public static class FrameEffect
{
public static SlideNavigationTransitionEffect GetEffect(int oldIndex, int index)
@@ -6,6 +6,10 @@ using System.Collections.Specialized;
namespace BD.WTTS.UI;
[Mobius(
"""
Mobius.UI.Behaviors.ItemDragBehavior
""")]
public class ItemDragBehavior : Behavior<Control>
{
private bool _enableDrag;
@@ -65,7 +65,7 @@
</spp:AppItem>
<spp:AppItem
Title="Wo Long: Fallen Dynasty (卧龙:苍天陨落)(卧龙:苍天陨落)(卧龙:苍天陨落)(卧龙:苍天陨落)"
Title="Wo Long: Fallen Dynasty (卧龙:苍天陨落)"
MaxHeight="120"
Description="This is a description of whatver this does"
Tags="111">
@@ -181,7 +181,7 @@
Grid.Row="2"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="0,5,12,5"
Margin="0,5"
VerticalAlignment="Top"
Classes="CaptionTextBlockStyle"
FontSize="12"
@@ -9,11 +9,6 @@
<StackPanel Spacing="10">
<HyperlinkButton Content="更新日志" />
<Button Content="更新日志" Theme="{StaticResource HyperlinkButton}" />
<Button Classes="TransparentAccent" Content="更新日志" />
<Button
Classes="TransparentAccent"
Content="更新日志"
IsEnabled="False" />
<Button
Content="更新日志"
IsEnabled="False"
@@ -226,15 +221,6 @@
<Setter Property="Background" Value="Transparent" />
</Style>
<Style Selector="Button.TransparentAccent /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonForeground}" />
</Style>
<Style Selector="Button.TransparentAccent:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonForegroundPointerOver}" />
</Style>
<Style Selector="Button.TransparentAccent:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource HyperlinkButtonForegroundPressed}" />
</Style>
</Styles>
@@ -97,7 +97,7 @@
</Design.PreviewWith>
<Styles.Resources>
<Thickness x:Key="AppPageMargin">20,10,20,20</Thickness>
<Thickness x:Key="AppPageMargin">20</Thickness>
</Styles.Resources>
<Style Selector="spp|PageBase">
@@ -313,7 +313,7 @@
<Setter Property="Grid.Row" Value="2" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Margin" Value="0 12 0 0" />
<Setter Property="Margin" Value="0 12" />
</Style>
<Style Selector="^ /template/ Panel#PageDetails">
@@ -3,6 +3,10 @@ namespace BD.WTTS.UI.Styling;
/// <summary>
/// Includes the fluent theme in an application.
/// </summary>
[Mobius(
"""
Mobius.UI.Styling.CustomTheme
""")]
public class CustomTheme : Styles, IResourceProvider
{
public const string LightModeString = "Light";
@@ -86,10 +86,4 @@
<StreamGeometry x:Key="Phone">
M15.75 2C16.9926 2 18 3.00736 18 4.25V19.75C18 20.9926 16.9926 22 15.75 22H8.25C7.00736 22 6 20.9926 6 19.75V4.25C6 3.00736 7.00736 2 8.25 2H15.75ZM13.25 18H10.75C10.3358 18 10 18.3358 10 18.75C10 19.1642 10.3358 19.5 10.75 19.5H13.25C13.6642 19.5 14 19.1642 14 18.75C14 18.3358 13.6642 18 13.25 18Z
</StreamGeometry>
<StreamGeometry x:Key="GOGGalaxy">
M304.99296 650.144H185.98496a17.12 17.12 0 0 0-16.992 17.184v85.344c0 8.992 7.68 16.992 16.992 16.992h119.52v56.32H156.16096a43.84 43.84 0 0 1-43.488-44v-144.512c0-23.968 19.68-43.488 44-43.488h148.32z m43.168-157.824c0 24.832-20 44.832-44.832 44.832H112.19296v-57.696h161.312a16.896 16.896 0 0 0 17.024-16.992V272.64a17.024 17.024 0 0 0-17.024-17.184H187.36096a17.152 17.152 0 0 0-17.536 17.184v86.144c0 9.856 7.68 17.024 17.024 17.024H256.00096v57.632H157.02496a44.544 44.544 0 0 1-44.832-44.32V242.304c0-24.352 20.192-44.32 44.832-44.32H303.04096c24.672 0 44.64 19.968 44.64 44.32v249.984z m563.168 333.664h-56.32v-175.84h-39.68a17.12 17.12 0 0 0-16.992 17.184v158.624h-56.832v-175.84h-39.68a17.12 17.12 0 0 0-16.992 17.184v158.624h-56.832v-188.512c0-23.968 19.68-43.488 44-43.488h239.328z m0.512-333.664c0 24.832-20.192 44.832-44.832 44.832h-191.136v-57.696h161.312a16.96 16.96 0 0 0 17.024-16.992V272.64a17.12 17.12 0 0 0-17.024-17.184h-86.656a17.024 17.024 0 0 0-17.024 17.184v86.144c0 9.856 7.68 17.024 17.024 17.024h69.152v57.632h-98.688a44.352 44.352 0 0 1-44.64-44.32V242.304c0-24.352 19.968-44.32 44.64-44.32h146.336c24.832 0 44.832 19.968 44.832 44.32v249.984zM585.34496 198.016h-146.688c-24.832 0-44.512 19.968-44.512 44.32v146.816a44.16 44.16 0 0 0 44.512 44.32h146.688a44.48 44.48 0 0 0 44.512-44.32V242.336c0-24.352-20.192-44.32-44.512-44.32z m-12.672 74.656v86.144c0 9.504-7.68 17.024-17.152 17.024h-86.688a16.96 16.96 0 0 1-16.992-17.024V272.96c0-9.312 7.328-16.992 16.992-16.992h85.856c9.824 0 16.992 7.68 16.992 16.992z m-33.824 321.344h-144.672c-24.16 0-43.808 19.488-43.808 43.488v144.512c0 24.32 19.68 44 43.808 44h144.672c24.32 0 44-19.68 44-44v-144.512c0-23.968-19.68-43.488-44-43.488z m-12.864 73.344v85.344a16.96 16.96 0 0 1-16.992 16.992v-0.352h-84.864a17.12 17.12 0 0 1-17.152-17.152v-84.832a17.28 17.28 0 0 1 17.152-17.184h85.344c9.344 0 17.024 7.84 17.024 17.184z m476.16-620.352A74.24 74.24 0 0 0 949.31296 24.64H74.65696A74.304 74.304 0 0 0 0.00096 99.296v825.344a74.304 74.304 0 0 0 74.656 74.656h874.656a74.304 74.304 0 0 0 74.656-74.656V99.296c0-20.32-8.48-39.168-21.856-52.832z m0 877.664a52.416 52.416 0 0 1-52.832 52.832H74.65696a52.576 52.576 0 0 1-53.344-52.832V99.328a52.672 52.672 0 0 1 52.832-52.832H948.80096c29.344 0 52.992 23.68 52.992 52.832v825.344z
</StreamGeometry>
<StreamGeometry x:Key="Discord">
M1049.062 139.672a3 3 0 0 0-1.528-1.4A970.13 970.13 0 0 0 808.162 64.06a3.632 3.632 0 0 0-3.846 1.82 674.922 674.922 0 0 0-29.8 61.2 895.696 895.696 0 0 0-268.852 0 619.082 619.082 0 0 0-30.27-61.2 3.78 3.78 0 0 0-3.848-1.82 967.378 967.378 0 0 0-239.376 74.214 3.424 3.424 0 0 0-1.576 1.352C78.136 367.302 36.372 589.38 56.86 808.708a4.032 4.032 0 0 0 1.53 2.75 975.332 975.332 0 0 0 293.65 148.378 3.8 3.8 0 0 0 4.126-1.352A696.4 696.4 0 0 0 416.24 860.8a3.72 3.72 0 0 0-2.038-5.176 642.346 642.346 0 0 1-91.736-43.706 3.77 3.77 0 0 1-0.37-6.252 502.094 502.094 0 0 0 18.218-14.274 3.638 3.638 0 0 1 3.8-0.512c192.458 87.834 400.82 87.834 591 0a3.624 3.624 0 0 1 3.848 0.466 469.066 469.066 0 0 0 18.264 14.32 3.768 3.768 0 0 1-0.324 6.252 602.814 602.814 0 0 1-91.78 43.66 3.75 3.75 0 0 0-2 5.222 782.11 782.11 0 0 0 60.028 97.63 3.728 3.728 0 0 0 4.126 1.4A972.096 972.096 0 0 0 1221.4 811.458a3.764 3.764 0 0 0 1.53-2.704c24.528-253.566-41.064-473.824-173.868-669.082zM444.982 675.16c-57.944 0-105.688-53.174-105.688-118.478s46.818-118.482 105.688-118.482c59.33 0 106.612 53.64 105.686 118.478 0 65.308-46.82 118.482-105.686 118.482z m390.76 0c-57.942 0-105.686-53.174-105.686-118.478s46.818-118.482 105.686-118.482c59.334 0 106.614 53.64 105.688 118.478 0 65.308-46.354 118.482-105.688 118.482z
</StreamGeometry>
</ResourceDictionary>
@@ -5,6 +5,10 @@ using FluentAvalonia.UI.Navigation;
namespace BD.WTTS.UI.Views.Pages;
[Mobius(
"""
Mobius.UI.Views.Pages.Abstractions.PageBase
""")]
public class PageBase : UserControl
{
public PageBase() : base()
@@ -321,6 +325,10 @@ public class PageBase : UserControl
private CompositeDisposable _disposables;
}
[Mobius(
"""
Mobius.UI.Views.Pages.Abstractions.PageBase<TViewModel>
""")]
public class PageBase<TViewModel> : PageBase, IViewFor<TViewModel> where TViewModel : class
{
public static readonly StyledProperty<TViewModel?> ViewModelProperty = AvaloniaProperty.Register<PageBase<TViewModel>, TViewModel?>(nameof(ViewModel));
@@ -7,6 +7,10 @@ namespace BD.WTTS.UI.Views.Windows;
/// and vice versa.
/// </summary>
/// <typeparam name="TViewModel">ViewModel type.</typeparam>
[Mobius(
"""
Mobius.UI.Views.Windows.Abstractions.ReactiveAppWindow<TViewModel>
""")]
public class ReactiveAppWindow<TViewModel> : AppWindow, IViewFor<TViewModel>, IViewFor, IActivatableView where TViewModel : class
{
public static readonly StyledProperty<TViewModel?> ViewModelProperty = ReactiveWindow<TViewModel>.ViewModelProperty.AddOwner<ReactiveAppWindow<TViewModel>>();
@@ -14,8 +18,6 @@ public class ReactiveAppWindow<TViewModel> : AppWindow, IViewFor<TViewModel>, IV
public static readonly StyledProperty<bool> IsSaveWindowSizeProperty = AvaloniaProperty
.Register<ReactiveAppWindow<TViewModel>, bool>(nameof(IsSaveWindowSize), true);
private bool _isInitialize;
/// <summary>
/// Initializes a new instance of the <see cref="ReactiveAppWindow{TViewModel}"/> class.
/// </summary>
@@ -129,32 +131,27 @@ public class ReactiveAppWindow<TViewModel> : AppWindow, IViewFor<TViewModel>, IV
{
var primaryScreenBounds = screen.Bounds;
if (CanResize && !_isInitialize && !IsVisible)
if (CanResize && !IsVisible)
{
WindowStartupLocation = WindowStartupLocation.Manual;
var scalingOffset = 31 - ((screen.Scaling - 1) / 0.5); // appwindow偏移量
if (SizePosition.Width > 0 &&
primaryScreenBounds.Width >= SizePosition.Width)
Width = SizePosition.Width;
if (SizePosition.Height > 0 &&
primaryScreenBounds.Height >= SizePosition.Height)
Height = SizePosition.Height - scalingOffset;
Height = SizePosition.Height;
if (SizePosition.X > 0 && SizePosition.Y > 0)
{
var offsetY = (int)Math.Round(scalingOffset * screen.Scaling);
//var offsetY = scalingOffset;
var leftTopPoint = new PixelPoint(SizePosition.X, SizePosition.Y + offsetY);
var leftTopPoint = new PixelPoint(SizePosition.X, SizePosition.Y);
var rightBottomPoint = new PixelPoint(SizePosition.X + (int)Width, SizePosition.Y + (int)Height);
if (primaryScreenBounds.Contains(leftTopPoint) &&
primaryScreenBounds.Contains(rightBottomPoint))
{
Position = leftTopPoint;
WindowStartupLocation = WindowStartupLocation.Manual;
}
}
_isInitialize = true;
}
}
}
@@ -4,6 +4,10 @@ using FluentAvalonia.Core;
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public partial class AdControl : UserControl
{
/// <summary>
@@ -4,6 +4,10 @@ using System.Numerics;
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public class AppItem : TemplatedControl
{
public static readonly StyledProperty<string> TitleProperty =
@@ -4,6 +4,10 @@ using FluentAvalonia.Core;
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public class ContentLoader : ContentControl
{
/// <summary>
@@ -2,6 +2,10 @@ using Avalonia.Input;
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public sealed class CustomFilePicker : ContentControl
{
public static readonly StyledProperty<string?> FileNameProperty = AvaloniaProperty.Register<CustomFilePicker, string?>(nameof(FileName), null);
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public enum AlignContent
{
FlexStart,
@@ -1,6 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public enum AlignItems
{
FlexStart,
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public static class Flex
{
/// <summary>
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public readonly struct FlexBasis : IEquatable<FlexBasis>
{
public double Value { get; }
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public enum FlexBasisKind
{
Auto,
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public enum FlexDirection
{
Row,
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public sealed class FlexPanel : Panel
{
private static readonly Func<Layoutable, int> s_getOrder = x => x is { } y ? Flex.GetOrder(y) : 0;
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public enum FlexWrap
{
NoWrap,
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public enum JustifyContent
{
FlexStart,
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
internal readonly struct Uv(double u, double v)
{
public double U { get; } = u;
@@ -2,6 +2,10 @@ using Avalonia.Controls;
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public class OptionsDisplayItem : TemplatedControl
{
public static readonly StyledProperty<object?> HeaderProperty =
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public class PureCircle : Control
{
public static readonly StyledProperty<double> DiameterProperty = AvaloniaProperty.Register<PureCircle, double>(
@@ -3,6 +3,10 @@ namespace BD.WTTS.UI.Views.Controls;
/// <summary>
/// Provide the most simplified shape implementation. This is a rectangle with a background, without border and corner radius.
/// </summary>
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public class PureRectangle : Control
{
public static readonly StyledProperty<IBrush?> BackgroundProperty =
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public class PureRing : PureCircle
{
public static readonly StyledProperty<double> InnerDiameterProperty = AvaloniaProperty.Register<PureRing, double>(
@@ -6,6 +6,10 @@ namespace BD.WTTS.UI.Views.Controls;
/// <summary>
/// An <see cref="INotificationManager"/> that displays notifications in a <see cref="Window"/>.
/// </summary>
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
[TemplatePart("PART_Items", typeof(Panel))]
[PseudoClasses(":topleft", ":topright", ":bottomleft", ":bottomright")]
public class SnackbarManager : TemplatedControl, IManagedNotificationManager
@@ -61,10 +65,6 @@ public class SnackbarManager : TemplatedControl, IManagedNotificationManager
{
Install(host);
}
else
{
Log.Error("SnackbarManager", "Install Faild, host is null");
}
UpdatePseudoClasses(Position);
}
@@ -197,39 +197,4 @@ public class SnackbarManager : TemplatedControl, IManagedNotificationManager
PseudoClasses.Set(":bottomleft", position == NotificationPosition.BottomLeft);
PseudoClasses.Set(":bottomright", position == NotificationPosition.BottomRight);
}
/// <inheritdoc/>
public void Close(INotification notification)
{
Dispatcher.UIThread.VerifyAccess();
//if (_items.Remove(notification, out var notificationCard))
//{
// notificationCard.Close();
//}
}
/// <inheritdoc/>
public void Close(object content)
{
Dispatcher.UIThread.VerifyAccess();
//if (_items.Remove(content, out var notificationCard))
//{
// notificationCard.Close();
//}
}
/// <inheritdoc/>
public void CloseAll()
{
Dispatcher.UIThread.VerifyAccess();
//foreach (var kvp in _items)
//{
// kvp.Close();
//}
_items?.Clear();
}
}
@@ -2,6 +2,10 @@ using Avalonia.Controls;
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public partial class SplashScreen : UserControl
{
public SplashScreen()
@@ -3,6 +3,10 @@ using BD.Common.Models.Abstractions;
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public partial class TitleBar : UserControl
{
public Image WindowIcon => BarIcon;
@@ -3,6 +3,10 @@ using FluentAvalonia.Core;
namespace BD.WTTS.UI.Views.Controls
{
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public partial class CarouselBanner : UserControl
{
/// <summary>
@@ -5,6 +5,10 @@ using System.Reactive;
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public class CarouselItems : ItemsControl
{
/// <summary>
@@ -5,6 +5,10 @@ namespace BD.WTTS.UI.Views.Controls;
/// <summary>
/// 固定的 WrapPanel
/// </summary>
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public class FixedWrapPanel : Panel, INavigableContainer
{
/// <summary>
@@ -85,36 +89,44 @@ public class FixedWrapPanel : Panel, INavigableContainer
/// <inheritdoc/>
protected override Size MeasureOverride(Size constraint)
{
var panelSize = default(MutableSize);
var lineSize = default(MutableSize);
int itemsInCurrentLine = 0;
double itemWidth = (constraint.Width - (Spacing * (ItemsPerLine - 1))) / ItemsPerLine;
MutableSize currentLineSize = default;
MutableSize panelSize = default;
Size lineConstraint = new(constraint.Width, constraint.Height);
Size childConstraint = new(itemWidth - Spacing, constraint.Height);
foreach (var child in Children.OfType<Control>())
for (int i = 0, count = Children.Count; i < count; i++)
{
child.Measure(new Size(itemWidth, constraint.Height));
var childSize = child.DesiredSize;
if (itemsInCurrentLine == ItemsPerLine)
Control child = Children[i];
if (child is null)
{
// Start a new line
panelSize.Width = Math.Max(panelSize.Width, lineSize.Width);
panelSize.Height += lineSize.Height + Spacing;
lineSize = new MutableSize(childSize.Width, childSize.Height);
itemsInCurrentLine = 1;
continue;
}
child.Measure(childConstraint);
Size childSize = new(itemWidth, child.DesiredSize.Height);
if (MathUtilities.GreaterThan(currentLineSize.Width + childSize.Width + Spacing, lineConstraint.Width))
{
// Need to switch to another line
panelSize.Width = Max(currentLineSize.Width, panelSize.Width);
panelSize.Height += currentLineSize.Height;
currentLineSize = new(childSize);
}
else
{
// Add to the current line
lineSize.Width += childSize.Width + (itemsInCurrentLine > 0 ? Spacing : 0);
lineSize.Height = Math.Max(lineSize.Height, childSize.Height);
itemsInCurrentLine++;
// Continue to accumulate a line
currentLineSize.Width += childSize.Width + Spacing;
currentLineSize.Height = Max(childSize.Height, currentLineSize.Height);
}
}
// Add the last line size
panelSize.Width = Math.Max(panelSize.Width, lineSize.Width);
panelSize.Height += lineSize.Height;
// The last line size, if any should be added
panelSize.Width = Max(currentLineSize.Width, panelSize.Width);
panelSize.Height = currentLineSize.Height;
if (double.IsInfinity(panelSize.Width))
panelSize.Width = 0;
return panelSize.ToSize();
}
@@ -122,33 +134,41 @@ public class FixedWrapPanel : Panel, INavigableContainer
/// <inheritdoc/>
protected override Size ArrangeOverride(Size finalSize)
{
var itemWidth = (finalSize.Width - (Spacing * (ItemsPerLine - 1))) / ItemsPerLine;
var position = default(MutablePoint);
var lineHeight = 0.0;
int itemsInCurrentLine = 0;
try
double itemWidth = (finalSize.Width - (Spacing * (ItemsPerLine - 1))) / ItemsPerLine;
int firstInLine = 0;
double accumulatedHeight = 0;
var currentLineSize = default(MutableSize);
for (int i = 0; i < Children.Count; i++)
{
foreach (var child in Children.OfType<Control>())
Control child = Children[i];
if (child == null)
{
if (itemsInCurrentLine == ItemsPerLine)
{
// Move to the next line
position.X = 0;
position.Y += lineHeight + Spacing;
lineHeight = 0;
itemsInCurrentLine = 0;
}
continue;
}
var childSize = new Size(itemWidth, child.DesiredSize.Height);
child.Arrange(new Rect(position.ToPoint(), childSize));
position.X += itemWidth + Spacing;
lineHeight = Math.Max(lineHeight, childSize.Height);
itemsInCurrentLine++;
MutableSize itemSize = new(itemWidth, child.DesiredSize.Height);
if (MathUtilities.GreaterThan(currentLineSize.Width + itemSize.Width, finalSize.Width))
{
// Need to switch to another line
ArrangeLine(accumulatedHeight, currentLineSize.Height, firstInLine, i, itemWidth);
accumulatedHeight += currentLineSize.Height;
currentLineSize = itemSize;
firstInLine = i;
}
else
{
// Continue to accumulate a line
currentLineSize.Width += itemSize.Width;
currentLineSize.Height = Max(itemSize.Height, currentLineSize.Height);
}
}
catch
{ }
if (firstInLine < Children.Count)
{
// Arrange the last line, if any
ArrangeLine(accumulatedHeight, currentLineSize.Height, firstInLine, Children.Count, itemWidth);
}
return finalSize;
}
@@ -164,32 +184,19 @@ public class FixedWrapPanel : Panel, INavigableContainer
continue;
}
try
if (i < end - 1)
{
if (i < end - 1 || i % ItemsPerLine == 0)
{
child.Arrange(new Rect(x, y, width - Spacing, height));
x += width + Spacing;
}
else
{
child.Arrange(new Rect(x, y, width, height));
x += width;
}
child.Arrange(new Rect(x, y, width - Spacing, height));
x += width + Spacing;
}
else
{
child.Arrange(new Rect(x, y, width, height));
x += width;
}
catch { }
}
}
record struct MutablePoint
{
internal double X;
internal double Y;
internal readonly Point ToPoint() => new Point(X, Y);
}
record struct MutableSize
{
internal MutableSize(double width, double height)
@@ -3,6 +3,10 @@ using Avalonia.Controls.Shapes;
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public class Ripple : Ellipse
{
private static Easing _easing = new CircularEaseOut();
@@ -2,6 +2,10 @@ using Avalonia.Controls.Shapes;
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public class RippleEffect : ContentControl
{
// ReSharper disable once InconsistentNaming
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public class Skeleton : ContentControl
{
public static readonly StyledProperty<bool> IsActiveProperty =
@@ -3,6 +3,10 @@ using Avalonia.Controls.Notifications;
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public class Snackbar : InfoBar
{
private bool _isClosing;
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
[TemplatePart("PART_ItemsPresenter", typeof(ItemsPresenter))]
[TemplatePart("PART_ProgressBar", typeof(ProgressBar))]
public class Stepper : SelectingItemsControl
@@ -4,6 +4,10 @@ using Avalonia.Controls.Mixins;
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
[PseudoClasses(":pressed", ":selected")]
public class StepperItem : ContentControl, ISelectable
{
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public sealed class TaskDialogEx : TaskDialog
{
private Button? _closeButton;
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Controls;
[Mobius(
"""
Mobius.UI.Views.Controls
""")]
public sealed partial class WaveProgress : UserControl
{
public static readonly DirectProperty<WaveProgress, double> ValueProperty =
@@ -3,6 +3,10 @@ using BD.WTTS.Services;
namespace BD.WTTS.UI.Views.Pages;
[Mobius(
"""
Mobius.UI.Views.Pages
""")]
public partial class AboutPage : ReactiveUserControl<AboutPageViewModel>
{
public AboutPage()
@@ -1,5 +1,9 @@
namespace BD.WTTS.UI.Views.Pages;
[Mobius(
"""
Mobius.UI.Views.Pages
""")]
public partial class MessageBoxPage : ReactiveUserControl<MessageBoxWindowViewModel>
{
public MessageBoxPage()
@@ -2,6 +2,10 @@ using Avalonia.Markup.Xaml.MarkupExtensions;
namespace BD.WTTS.UI.Views.Pages;
[Mobius(
"""
Mobius.UI.Views.Pages
""")]
public partial class TextInputDialogPage : ReactiveUserControl<TextBoxWindowViewModel>
{
public TextInputDialogPage()
@@ -135,15 +135,11 @@
<ItemsControl>
<ItemsControl.Items>
<Border Height="30" Background="Red" />
<Border Height="30" Background="Blue" />
<Border Background="Blue" />
<Border Background="Yellow" />
<Border Height="30" Background="Yellow" />
<Border Height="30" Background="Yellow" />
<Border Height="30" Background="Red" />
<Border Height="30" Background="Blue" />
<Border Height="30" Background="Blue" />
<Border Height="30" Background="Blue" />
<Border Height="30" Background="Blue" />
<Border Height="30" Background="Red" />
<Border Background="Red" />
<Border Background="Blue" />
</ItemsControl.Items>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
@@ -2,6 +2,10 @@ using Avalonia.Controls;
namespace BD.WTTS.UI.Views.Pages;
[Mobius(
"""
Mobius.UI.Views.Pages
""")]
public partial class DebugPage : PageBase<DebugPageViewModel>
{
public DebugPage()
@@ -2,6 +2,10 @@ using Avalonia.Controls;
namespace BD.WTTS.UI.Views.Pages;
[Mobius(
"""
Mobius.UI.Views.Pages
""")]
public partial class ErrorPage : UserControl
{
public ErrorPage()

Some files were not shown because too many files have changed in this diff Show More