Merge pull request #616 from sakuraxp/dev

feat.自动战斗界面增加显示干员阵容和攻略url。
This commit is contained in:
MistEO
2022-05-30 02:12:50 +08:00
committed by GitHub
2 changed files with 51 additions and 1 deletions

View File

@@ -12,9 +12,11 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -45,6 +47,12 @@ namespace MeoAsstGui
//LogItemViewModels.Insert(0, new LogItemViewModel(time + content, color, weight));
}
public void AddLogWithUrl(string content,string url, string color = "Gray", string weight = "Regular")
{
LogItemViewModels.Add(new LogItemViewModel(content, color, weight));
//LogItemViewModels.Insert(0, new LogItemViewModel(time + content, color, weight));
}
private bool _idel = true;
public bool Idle
@@ -119,8 +127,25 @@ namespace MeoAsstGui
details_color = doc["details_color"].ToString();
}
AddLog(details, details_color);
{
Url = "";
var linkParser = new Regex(@"(?:https?://)\S+\b", RegexOptions.Compiled | RegexOptions.IgnoreCase);
foreach (Match m in linkParser.Matches(details))
{
Url = m.Value;
break;
}
}
}
}
AddLog(string.Format("\n共{0}名干员", ((JContainer)json["opers"]).Count), "black");
foreach (JObject oper in json["opers"])
{
AddLog(string.Format("{0}, {1}技能", oper["name"], oper["skill"]), "black");
}
}
catch (Exception)
{
}
@@ -200,5 +225,27 @@ namespace MeoAsstGui
asstProxy.AsstStop();
Idle = true;
}
private string _url = "";
public string Url
{
get => _url;
set => SetAndNotify(ref _url, value);
}
public void Hyperlink_Click(string url)
{
try
{
if (!string.IsNullOrEmpty(url))
{
Process.Start(new ProcessStartInfo(url));
}
}
catch (Exception)
{
}
}
}
}

View File

@@ -22,6 +22,9 @@
<CheckBox IsChecked="{Binding Form}" HorizontalAlignment="Center" IsHitTestVisible="{Binding Idle}" Content="自动编队" Height="50" Margin="10" />
<Button Command="{s:Action Start}" IsEnabled="{Binding Idle}" Content="开始" Width="120" Height="50" Margin="10" />
<Button Command="{s:Action Stop}" Content="停止" Width="120" Height="50" Margin="10" />
<TextBlock Style="{StaticResource TextBlockDefault}" Block.TextAlignment="Center" Margin="10" >
<Hyperlink Command="{s:Action Hyperlink_Click}" CommandParameter="{Binding Url}"><TextBlock Text="{Binding Url}"/></Hyperlink>
</TextBlock>
</StackPanel>
<ScrollViewer Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="10"