alielie
2026-09-10 9ec80cafc23f5ee3278cacce3c9f86f4087b435a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using CommunityToolkit.Mvvm.ComponentModel;
using OpenTap.Addin;
using System.Windows;
using System.Windows.Controls;
 
namespace SeqEditor.SubWin
{
    /// <summary>
    /// ArrayVarConfig.xaml 的交互逻辑
    /// </summary>
    [ObservableObject]
    public partial class ArrayVarConfig : Window
    {
        [ObservableProperty]
        private string varName;
 
        [ObservableProperty]
        private TestVariableType varType;
 
        [ObservableProperty]
        private int length;
 
        private Func<string,string> validateName;
 
        public ArrayVarConfig(Func<string, string> 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();
        }
    }
}