using System.Windows.Input;
using Microsoft.UI.Xaml.Automation;
using XFEEDToolBox.Core.Galaxy;
namespace XFEEDToolBox.Controls;
public sealed partial class GalaxyFilterPanel
{
public static readonly DependencyProperty FleetTargetsProperty=DependencyProperty.Register(nameof(FleetTargets),typeof(IReadOnlyList<GalaxyFleetMapTarget>),typeof(GalaxyFilterPanel),new PropertyMetadata(null,Changed));
public static readonly DependencyProperty FleetStatusProperty=DependencyProperty.Register(nameof(FleetStatus),typeof(string),typeof(GalaxyFilterPanel),new PropertyMetadata("",Changed));
public static readonly DependencyProperty SelectFleetCommandProperty=DependencyProperty.Register(nameof(SelectFleetCommand),typeof(ICommand),typeof(GalaxyFilterPanel),new PropertyMetadata(null,Changed));
public IReadOnlyList<GalaxyFleetMapTarget> FleetTargets {get=>(IReadOnlyList<GalaxyFleetMapTarget>?)GetValue(FleetTargetsProperty)??[];set=>SetValue(FleetTargetsProperty,value);}
public string FleetStatus {get=>(string)GetValue(FleetStatusProperty);set=>SetValue(FleetStatusProperty,value);}
public ICommand? SelectFleetCommand {get=>(ICommand?)GetValue(SelectFleetCommandProperty);set=>SetValue(SelectFleetCommandProperty,value);}
private readonly TextBlock fleetStatus=new(){FontSize=11,TextWrapping=TextWrapping.Wrap};
private readonly StackPanel fleetTargets=new(){Spacing=5};
private IReadOnlyList<GalaxyFleetMapTarget>? renderedFleetTargets;
private ICommand? renderedFleetCommand;
private FrameworkElement BuildFleetControls()
{
var content=new StackPanel{Spacing=6};content.Children.Add(fleetStatus);content.Children.Add(fleetTargets);
return new Expander{Header="原游戏飞船逐条定位",Content=content,HorizontalAlignment=HorizontalAlignment.Stretch,HorizontalContentAlignment=HorizontalAlignment.Stretch};
}
private void RefreshFleetControls()
{
fleetStatus.Text=FleetStatus;
if(ReferenceEquals(renderedFleetTargets,FleetTargets)&&ReferenceEquals(renderedFleetCommand,SelectFleetCommand))return;
renderedFleetTargets=FleetTargets;renderedFleetCommand=SelectFleetCommand;fleetTargets.Children.Clear();
foreach(var target in FleetTargets)
{
var content=new StackPanel{Spacing=2};content.Children.Add(new TextBlock{Text=target.Label,FontSize=12,TextWrapping=TextWrapping.Wrap});content.Children.Add(new TextBlock{Text=$"原条目 {target.Id} · 星系地址 {target.SystemAddress}",FontSize=10,TextWrapping=TextWrapping.Wrap});
var button=new Button{Content=content,Command=SelectFleetCommand,CommandParameter=target,HorizontalAlignment=HorizontalAlignment.Stretch,HorizontalContentAlignment=HorizontalAlignment.Stretch};AutomationProperties.SetName(button,"定位原列表飞船 "+target.ShipId);fleetTargets.Children.Add(button);
}
}
}
using System.Windows.Input;
using Microsoft.UI.Xaml.Automation;
using XFEEDToolBox.Core.Galaxy;
namespace XFEEDToolBox.Controls;
public sealed partial class GalaxyFilterPanel
{
public static readonly DependencyProperty FleetTargetsProperty=DependencyProperty.Register(nameof(FleetTargets),typeof(IReadOnlyList<GalaxyFleetMapTarget>),typeof(GalaxyFilterPanel),new PropertyMetadata(null,Changed));
public static readonly DependencyProperty FleetStatusProperty=DependencyProperty.Register(nameof(FleetStatus),typeof(string),typeof(GalaxyFilterPanel),new PropertyMetadata("",Changed));
public static readonly DependencyProperty SelectFleetCommandProperty=DependencyProperty.Register(nameof(SelectFleetCommand),typeof(ICommand),typeof(GalaxyFilterPanel),new PropertyMetadata(null,Changed));
public IReadOnlyList<GalaxyFleetMapTarget> FleetTargets {get=>(IReadOnlyList<GalaxyFleetMapTarget>?)GetValue(FleetTargetsProperty)??[];set=>SetValue(FleetTargetsProperty,value);}
public string FleetStatus {get=>(string)GetValue(FleetStatusProperty);set=>SetValue(FleetStatusProperty,value);}
public ICommand? SelectFleetCommand {get=>(ICommand?)GetValue(SelectFleetCommandProperty);set=>SetValue(SelectFleetCommandProperty,value);}
private readonly TextBlock fleetStatus=new(){FontSize=11,TextWrapping=TextWrapping.Wrap};
private readonly StackPanel fleetTargets=new(){Spacing=5};
private IReadOnlyList<GalaxyFleetMapTarget>? renderedFleetTargets;
private ICommand? renderedFleetCommand;
private FrameworkElement BuildFleetControls()
{
var content=new StackPanel{Spacing=6};content.Children.Add(fleetStatus);content.Children.Add(fleetTargets);
return new Expander{Header="原游戏飞船逐条定位",Content=content,HorizontalAlignment=HorizontalAlignment.Stretch,HorizontalContentAlignment=HorizontalAlignment.Stretch};
}
private void RefreshFleetControls()
{
fleetStatus.Text=FleetStatus;
if(ReferenceEquals(renderedFleetTargets,FleetTargets)&&ReferenceEquals(renderedFleetCommand,SelectFleetCommand))return;
renderedFleetTargets=FleetTargets;renderedFleetCommand=SelectFleetCommand;fleetTargets.Children.Clear();
foreach(var target in FleetTargets)
{
var content=new StackPanel{Spacing=2};content.Children.Add(new TextBlock{Text=target.Label,FontSize=12,TextWrapping=TextWrapping.Wrap});content.Children.Add(new TextBlock{Text=$"原条目 {target.Id} · 星系地址 {target.SystemAddress}",FontSize=10,TextWrapping=TextWrapping.Wrap});
var button=new Button{Content=content,Command=SelectFleetCommand,CommandParameter=target,HorizontalAlignment=HorizontalAlignment.Stretch,HorizontalContentAlignment=HorizontalAlignment.Stretch};AutomationProperties.SetName(button,"定位原列表飞船 "+target.ShipId);fleetTargets.Children.Add(button);
}
}
}