using CommunityToolkit.Mvvm.ComponentModel;
|
using OpenTap;
|
using OpenTap.Addin;
|
using System.Collections.ObjectModel;
|
using System.Windows;
|
using System.Windows.Controls;
|
|
namespace OpenTapEditor
|
{
|
/// <summary>
|
/// VariablesControl.xaml 的交互逻辑
|
/// </summary>
|
[ObservableObject]
|
public partial class VariablesControl : UserControl
|
{
|
public event EventHandler SequencePropertyChanged;
|
|
public static DependencyProperty VariablesProperty = DependencyProperty.Register("Variables",
|
typeof(ObservableCollection<TestVariable>),
|
typeof(VariablesControl),
|
new PropertyMetadata(null));
|
|
public ObservableCollection<TestVariable> Variables
|
{
|
get => (ObservableCollection<TestVariable>)GetValue(VariablesProperty);
|
set
|
{
|
SetValue(VariablesProperty, value);
|
}
|
}
|
|
private TestPlan plan;
|
|
public VariablesControl()
|
{
|
DataContext = this;
|
InitializeComponent();
|
Variables = new ObservableCollection<TestVariable>() {
|
new TestVariable(){
|
Name = "Locals",
|
NameCanEdit = false,
|
Type = TestVariableType.Container
|
},
|
new TestVariable(){
|
Name = "Parameters",
|
NameCanEdit = false,
|
Type = TestVariableType.Container
|
},
|
new TestVariable(){
|
Name = "FileGlobals",
|
NameCanEdit = false,
|
Type = TestVariableType.Container
|
},
|
new TestVariable(){
|
Name = "StationGlobals",
|
NameCanEdit = false,
|
Type = TestVariableType.Container,
|
Children = UIStationGlobalsManager.Instance.Datasource
|
},
|
};
|
}
|
|
public void SetPlan(TestPlan plan)
|
{
|
this.plan = plan;
|
if (plan == null)
|
{
|
Variables = new ObservableCollection<TestVariable>();
|
}
|
else
|
{
|
Variables[2].ContextName = plan.VisualPath;
|
Variables[2].Children = plan.Variables;
|
}
|
}
|
|
public void SetSeq(TestStepList seq)
|
{
|
Variables[0].Children = seq?.Variables;
|
Variables[0].ContextName = seq?.SequenceName;
|
|
Variables[1].Children = seq?.Parameters;
|
Variables[1].ContextName = seq?.SequenceName;
|
}
|
}
|
}
|