using CommunityToolkit.Mvvm.ComponentModel; using OpenTap.Addin; using System.Windows; using System.Windows.Controls; namespace SeqEditor.SubWin { /// /// ArrayVarConfig.xaml 的交互逻辑 /// [ObservableObject] public partial class ArrayVarConfig : Window { [ObservableProperty] private string varName; [ObservableProperty] private TestVariableType varType; [ObservableProperty] private int length; private Func validateName; public ArrayVarConfig(Func func) { validateName = func; DataContext = this; InitializeComponent(); CbType.ItemsSource = Enum.GetValues(typeof(TestVariableType)); } private void Button_Click(object sender, RoutedEventArgs e) { Button btn = (Button)sender; if (!btn.IsCancel) { string msg = validateName(VarName); if (!string.IsNullOrEmpty(msg)) { FgName.ValidateResult = Panuon.WPF.UI.ValidateResult.Error; FgName.Message = msg; return; } else { FgName.ValidateResult = Panuon.WPF.UI.ValidateResult.None; FgName.Message = msg; } } this.DialogResult = !btn.IsCancel; this.Close(); } } }