Skip to content

Commit

Permalink
ASF
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbadmin committed Nov 1, 2021
1 parent 8f767f0 commit 99cc0b7
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 23 deletions.
2 changes: 1 addition & 1 deletion references/ArchiSteamFarm
2 changes: 1 addition & 1 deletion references/AvaloniaGif
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ public virtual object ConvertBack(object value, Type targetType, object paramete
protected static Bitmap? DownloadImage(string? url, int width = 0)
{
if (url == null) return null;
using var web = new WebClient();
var ua = DI.Get<IHttpPlatformHelperService>().UserAgent;
web.Headers.Add("User-Agent", ua);
var bt = web.DownloadData(url);
var stream = new MemoryStream(bt);
//var task = IHttpService.Instance.GetAsync<Stream>(url, MediaTypeNames.All);
//if (stream == null) return null;
//using var web = new WebClient();
//var ua = DI.Get<IHttpPlatformHelperService>().UserAgent;
//web.Headers.Add("User-Agent", ua);
//var bt = web.DownloadData(url);
//var stream = new MemoryStream(bt);
var task = IHttpService.Instance.GetAsync<Stream>(url, MediaTypeNames.All);
var stream = task.GetAwaiter().GetResult();
if (stream == null) return null;
return GetDecodeBitmap(stream, width);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,15 @@
<ia:InvokeCommandAction Command="{ReflectionBinding #u.DataContext.OpenUserProfileUrl}" CommandParameter="{Binding}"/>
</ia:EventTriggerBehavior>
</i:Interaction.Behaviors>
<!--<gif:Image2
<gif:Image2
Width="184"
AutoStart="true"
Stretch="Uniform"
Source="{Binding AvatarUrl}">
</gif:Image2>-->
<Image Width="184"
</gif:Image2>
<!--<Image Width="184"
Stretch="Uniform"
Source="{Binding AvatarUrl,Converter={StaticResource BitmapAssetValueConverter}}">
</Image>
</Image>-->
<!--<Image Width="184" Stretch="Uniform" IsVisible="{Binding AvatarStream^,Converter={StaticResource IsNullConverter}}"
Source="avares://System.Application.SteamTools.Client.Avalonia/Application/UI/Assets/AppResources/avatar.jpg">
</Image>-->
Expand Down Expand Up @@ -125,7 +124,7 @@
VerticalAlignment="Center"
HorizontalAlignment="Right">
<TextBlock VerticalAlignment="Center"
Text="{Binding WalletBalance,StringFormat={}{0:C}}"/>
Text="{Binding WalletBalanceM,StringFormat={}{0:C}}"/>
</WrapPanel>
</DockPanel>

Expand Down Expand Up @@ -167,7 +166,16 @@
<Button ToolTip.Tip="Bot配置" >
<PathIcon Data="{StaticResource SettingsDrawing}" />
</Button>
<Button ToolTip.Tip="禁用Bot" >
<Button ToolTip.Tip="启用"
IsVisible="{Binding !KeepRunning}"
Command="{ReflectionBinding #u.DataContext.EnableOrDisableBot}"
CommandParameter="{Binding}">
<PathIcon Data="{StaticResource BlockDrawing}" />
</Button>
<Button ToolTip.Tip="禁用"
IsVisible="{Binding KeepRunning}"
Command="{ReflectionBinding #u.DataContext.EnableOrDisableBot}"
CommandParameter="{Binding}">
<PathIcon Data="{StaticResource BlockDrawing}" />
</Button>
</StackPanel>
Expand All @@ -184,9 +192,15 @@
<Border Classes="paper"
ClipToBounds="True">
<Panel>
<Image Source="{Binding ImageUrl,Converter={StaticResource BitmapAssetValueConverter}}"
<gif:Image2
MaxWidth="184"
MaxHeight="86"
Stretch="Uniform"
Source="{Binding ImageUrl}">
</gif:Image2>
<!--<Image Source="{Binding ImageUrl,Converter={StaticResource BitmapAssetValueConverter}}"
Width="184"
Stretch="Uniform"/>
Stretch="Uniform"/>-->
<Border VerticalAlignment="Bottom"
HorizontalAlignment="Stretch"
Background="{DynamicResource ThemeColorKey}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async Task Start(string[]? args = null)
ReadLineTask = new(TaskCreationOptions.AttachedToParent);
IsReadPasswordLine = isPassword;
#if NET6_0_OR_GREATER
var result = await ReadLineTask.Task.WaitAsync(TimeSpan.FromSeconds(20));
var result = await ReadLineTask.Task.WaitAsync(TimeSpan.FromSeconds(60));
#else
var result = await ReadLineTask.Task;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void EnableOrDisableBot(Bot bot)
{
(bool success, string message) result;

if (bot.CardsFarmer.Paused)
if (bot.KeepRunning)
{
result = bot.Actions.Stop();
}
Expand All @@ -109,7 +109,12 @@ public async void RedeemKeyBot(Bot bot)

public void GoToBotSettings(Bot bot)
{
OpenBrowser("WebBotConfig", bot.BotName);
if (!ASFService.Current.IsASFRuning)
{
Toast.Show("请先运行ASF功能");
return;
}
Browser2.Open(IPCUrl + "/bot/" + bot.BotName);
}

public void OpenFolder(string tag)
Expand All @@ -133,7 +138,7 @@ static string GetFolderPath(string path)
IPlatformService.Instance.OpenFolder(path);
}

public void OpenBrowser(string? tag, string? botName = null)
public void OpenBrowser(string? tag)
{
var url = tag switch
{
Expand All @@ -142,7 +147,6 @@ public void OpenBrowser(string? tag, string? botName = null)
"ConfigGenerator" => "https://justarchinet.github.io/ASF-WebConfigGenerator/",
"WebConfig" => IPCUrl + "/asf-config",
"WebAddBot" => IPCUrl + "/bot/new",
"WebBotConfig" => IPCUrl + "/bot/" + botName,
_ => IPCUrl,
};

Expand Down

0 comments on commit 99cc0b7

Please sign in to comment.