Skip to content

Commit

Permalink
Merge pull request #3544 from BeyondDimension/feature/info_icon
Browse files Browse the repository at this point in the history
✨ 网络测试页面延迟后增加info图标
  • Loading branch information
rmbadmin authored Nov 25, 2024
2 parents c93db63 + 77b4391 commit 08ffcfc
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,24 @@
Text="Beta" />
</Border>
</StackPanel>
<TextBlock
<StackPanel
Orientation="Horizontal"
Margin="0,0,4,0"
HorizontalAlignment="Right"
DockPanel.Dock="Right"
Foreground="{Binding DelayColor}"
Text="{Binding DelayMillseconds}"
ToolTip.ShowDelay="0"
ToolTip.Tip="此数值代表测试网页打开访问所需时间,请以实际浏览器访问网页状况为准" />
DockPanel.Dock="Right">
<TextBlock x:Name="DelayValue"
Foreground="{Binding DelayColor}" VerticalAlignment="Center"
Text="{Binding DelayMillseconds}" />

<ui:FontIcon
Margin="3,0"
FontSize="20"
Glyph="&#xE946;"
ToolTip.ShowDelay="0"
ToolTip.Tip="此数值代表测试网页打开访问所需时间,请以实际浏览器访问网页状况为准"
IsVisible="{Binding Text, ElementName=DelayValue, Converter={x:Static StringConverters.IsNotNullOrEmpty}}">
</ui:FontIcon>
</StackPanel>
</DockPanel>
</TreeDataTemplate>
</TreeView.ItemTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,17 @@ async void OpenBrowserCore(ActionItem tag)
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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using FluentAvalonia.UI.Controls;

namespace BD.WTTS.UI.ViewModels;

public partial class ArchiSteamFarmExePathSettingsPageViewModel : ViewModelBase
Expand All @@ -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)
{
Expand All @@ -19,8 +21,41 @@ public ArchiSteamFarmExePathSettingsPageViewModel()
}
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<float> 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<float>();
progress.ProgressChanged += (_, value) =>
{
// Value here report 1-100
downloadDialog.Content = $"正在下载 {value}%";
downloadDialog.SetProgressBarState(value, TaskDialogProgressState.Normal);

if (value >= 100)
{
downloadDialog.Hide();
}
};

return (downloadDialog, progress);
}
}

0 comments on commit 08ffcfc

Please sign in to comment.