From 3ae002db91a3cf48983033f491a07d9ae078f8fe Mon Sep 17 00:00:00 2001 From: k1mlka Date: Tue, 19 Nov 2024 15:54:13 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=A8=20=E7=BD=91=E7=BB=9C=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E9=A1=B5=E9=9D=A2=E5=BB=B6=E8=BF=9F=E5=90=8E=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0info=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI/StringNotEmptyToVisibilityConverter.cs | 16 +++++++++++ .../Controls/AcceleratorServiceStatus.axaml | 28 +++++++++++++++---- 2 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 src/BD.WTTS.Client.Plugins.Accelerator/UI/StringNotEmptyToVisibilityConverter.cs diff --git a/src/BD.WTTS.Client.Plugins.Accelerator/UI/StringNotEmptyToVisibilityConverter.cs b/src/BD.WTTS.Client.Plugins.Accelerator/UI/StringNotEmptyToVisibilityConverter.cs new file mode 100644 index 000000000..960f40ff3 --- /dev/null +++ b/src/BD.WTTS.Client.Plugins.Accelerator/UI/StringNotEmptyToVisibilityConverter.cs @@ -0,0 +1,16 @@ +using Avalonia.Data.Converters; + +namespace BD.WTTS.UI; + +public class StringNotEmptyToVisibilityConverter : IValueConverter +{ + public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + return !string.IsNullOrEmpty(value as string); + } + + public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorServiceStatus.axaml b/src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorServiceStatus.axaml index 3b634d046..3eb8430e8 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorServiceStatus.axaml +++ b/src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorServiceStatus.axaml @@ -7,11 +7,17 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:spp="https://steampp.net/ui" xmlns:ui="using:FluentAvalonia.UI.Controls" + xmlns:local="using:BD.WTTS.UI" d:DesignHeight="450" d:DesignWidth="800" x:CompileBindings="True" x:DataType="spp:AcceleratorPageViewModel" mc:Ignorable="d"> + + + + + - + DockPanel.Dock="Right"> + + + + + From 498626626855adb452433d73592f0abdf4344457 Mon Sep 17 00:00:00 2001 From: k1mlka Date: Wed, 20 Nov 2024 14:33:19 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E2=9C=A8=20ASF=20=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E6=89=93=E5=BC=80=E9=A2=9D=E5=A4=96=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E4=B8=8B=E7=9A=84=E6=96=87=E6=A1=A3=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Mvvm/ASFService.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/Services/Mvvm/ASFService.cs b/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/Services/Mvvm/ASFService.cs index b53d85482..edcf2b20a 100644 --- a/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/Services/Mvvm/ASFService.cs +++ b/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/Services/Mvvm/ASFService.cs @@ -180,6 +180,17 @@ public sealed class ASFService : ReactiveObject ActionItem.Repo => "https://github.com/JustArchiNET/ArchiSteamFarm", ActionItem.Wiki => "https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Home-zh-CN", ActionItem.ConfigGenerator => "https://justarchinet.github.io/ASF-WebConfigGenerator", + _ => string.Empty, + }; + + if (url != string.Empty) + { + await Browser2.OpenAsync(url, BrowserLaunchMode.External); + return; + } + + url = tag switch + { ActionItem.WebConfig => IPCUrl + "/asf-config", ActionItem.WebAddBot => IPCUrl + "/bot/new", _ => IPCUrl, From c9118b5abed15e27295a5ec2fdbbb152d8d781eb Mon Sep 17 00:00:00 2001 From: k1mlka Date: Thu, 21 Nov 2024 11:39:16 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E2=9C=A8=20ASF=20=E5=AF=B9=E4=BD=8E?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=93=8D=E4=BD=9C=E7=B3=BB=E7=BB=9F=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...hiSteamFarmExePathSettingsPageViewModel.cs | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/UI/ViewModels/ArchiSteamFarmExePathSettingsPageViewModel.cs b/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/UI/ViewModels/ArchiSteamFarmExePathSettingsPageViewModel.cs index 24c833a27..fa5e0199a 100644 --- a/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/UI/ViewModels/ArchiSteamFarmExePathSettingsPageViewModel.cs +++ b/src/BD.WTTS.Client.Plugins.ArchiSteamFarmPlus/UI/ViewModels/ArchiSteamFarmExePathSettingsPageViewModel.cs @@ -1,3 +1,5 @@ +using FluentAvalonia.UI.Controls; + namespace BD.WTTS.UI.ViewModels; public partial class ArchiSteamFarmExePathSettingsPageViewModel : ViewModelBase @@ -9,7 +11,7 @@ public partial class ArchiSteamFarmExePathSettingsPageViewModel : ViewModelBase public ArchiSteamFarmExePathSettingsPageViewModel() { SelectProgramPath = ReactiveCommand.Create(ASFService.Current.SelectASFProgramLocationAsync); - DownloadASF = ReactiveCommand.Create(() => + DownloadASF = ReactiveCommand.Create(async () => { if (INotificationService.Instance.IsSupportNotifyDownload) { @@ -19,8 +21,41 @@ public partial class ArchiSteamFarmExePathSettingsPageViewModel : ViewModelBase } else { - Toast.Show(ToastIcon.Error, "当前平台无法调用下载通知,请自行下载", ToastLength.Short); + var (downloadDialog, progress) = CreateDownloadDialog(); + ASFService.Current.DownloadASFAsync(progress: progress); + _ = await downloadDialog.ShowAsync(true); } }); } -} + + private static (TaskDialog DownloadDialog, IProgress Progress) CreateDownloadDialog() + { + var downloadDialog = new TaskDialog + { + Title = "下载插件", + ShowProgressBar = true, + IconSource = new SymbolIconSource { Symbol = Symbol.Download }, + SubHeader = "开始下载 ASF", + Content = "正在初始化,请稍候", + XamlRoot = AvaloniaWindowManagerImpl.GetWindowTopLevel(), + // DownloadASFAsync() 无法取消后再次开启下载 + //Buttons = [new TaskDialogButton("取消", TaskDialogStandardResult.Cancel)], + }; + downloadDialog.Opened += (_, _) => { downloadDialog.SetProgressBarState(0, TaskDialogProgressState.Normal); }; + + var progress = new Progress(); + progress.ProgressChanged += (_, value) => + { + // Value here report 1-100 + downloadDialog.Content = $"正在下载 {value}%"; + downloadDialog.SetProgressBarState(value, TaskDialogProgressState.Normal); + + if (value >= 100) + { + downloadDialog.Hide(); + } + }; + + return (downloadDialog, progress); + } +} \ No newline at end of file From 77b43918f11752f8657044c111001629b009e3f1 Mon Sep 17 00:00:00 2001 From: k1mlka Date: Fri, 22 Nov 2024 10:18:37 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=92=84=20=E5=8E=BB=E9=99=A4StringNotE?= =?UTF-8?q?mptyToVisibilityConverter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI/StringNotEmptyToVisibilityConverter.cs | 16 ---------------- .../Controls/AcceleratorServiceStatus.axaml | 8 +------- 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 src/BD.WTTS.Client.Plugins.Accelerator/UI/StringNotEmptyToVisibilityConverter.cs diff --git a/src/BD.WTTS.Client.Plugins.Accelerator/UI/StringNotEmptyToVisibilityConverter.cs b/src/BD.WTTS.Client.Plugins.Accelerator/UI/StringNotEmptyToVisibilityConverter.cs deleted file mode 100644 index 960f40ff3..000000000 --- a/src/BD.WTTS.Client.Plugins.Accelerator/UI/StringNotEmptyToVisibilityConverter.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Avalonia.Data.Converters; - -namespace BD.WTTS.UI; - -public class StringNotEmptyToVisibilityConverter : IValueConverter -{ - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) - { - return !string.IsNullOrEmpty(value as string); - } - - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } -} \ No newline at end of file diff --git a/src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorServiceStatus.axaml b/src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorServiceStatus.axaml index 3eb8430e8..ea6b5a798 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorServiceStatus.axaml +++ b/src/BD.WTTS.Client.Plugins.Accelerator/UI/Views/Controls/AcceleratorServiceStatus.axaml @@ -7,17 +7,11 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:spp="https://steampp.net/ui" xmlns:ui="using:FluentAvalonia.UI.Controls" - xmlns:local="using:BD.WTTS.UI" d:DesignHeight="450" d:DesignWidth="800" x:CompileBindings="True" x:DataType="spp:AcceleratorPageViewModel" mc:Ignorable="d"> - - - - - + IsVisible="{Binding Text, ElementName=DelayValue, Converter={x:Static StringConverters.IsNotNullOrEmpty}}">