Skip to content

Commit cf4a253

Browse files
committed
修复 变量删除时错误的处理
新增 变量添加按钮可执行变化
1 parent e86c1a3 commit cf4a253

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

KitopiaAvalonia/Windows/TaskEditors/TaskEditorValueNodeShow.axaml.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,41 @@ static TaskEditorValueNodeShow()
6464
x.AddCommand = new RelayCommand(() =>
6565
{
6666
if (values1.ContainsKey(x.ValueNameToAdd)) return;
67-
67+
if (x.ValueType != ValueType.TempValue && x.ValueTypeToAdd == null)
68+
{
69+
return;
70+
}
6871

6972
values1.Add(x.ValueNameToAdd,
7073
new CustomScenarioValue(x.ValueTypeToAdd == null ? typeof(object) : x.ValueTypeToAdd.Type, null!));
7174

7275
x.ValueNameToAdd = null!;
76+
}, () =>
77+
{
78+
if (x.ValueType != ValueType.TempValue && x.ValueTypeToAdd == null)
79+
{
80+
return false;
81+
}
82+
83+
return !string.IsNullOrWhiteSpace(x.ValueNameToAdd) && !values1.ContainsKey(x.ValueNameToAdd);
7384
});
85+
7486
x.DelCommand = new RelayCommand<object>((s) =>
7587
{
7688
if (s is not KeyValuePair<string, CustomScenarioValue> str) return;
7789
values1.Remove(str.Key);
7890
});
7991
});
92+
ValueTypeToAddProperty.Changed.AddClassHandler<TaskEditorValueNodeShow>((x, e) =>
93+
{
94+
if (x.AddCommand is RelayCommand cmd)
95+
cmd.NotifyCanExecuteChanged();
96+
});
97+
ValueNameToAddProperty.Changed.AddClassHandler<TaskEditorValueNodeShow>((x, e) =>
98+
{
99+
if (x.AddCommand is RelayCommand cmd)
100+
cmd.NotifyCanExecuteChanged();
101+
});
80102
}
81103

82104
public TaskEditorValueNodeShow()

KitopiaAvalonia/Windows/TaskEditors/TaskEditorValueToScenarioMethodNode.axaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ public KeyValuePair<string, CustomScenarioValue> Source
7171

7272
private static void Action(TaskEditorValueToScenarioMethodNode x, AvaloniaPropertyChangedEventArgs e)
7373
{
74+
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
75+
if (x.Source.Key == null || x.Source.Value == null)
76+
{
77+
return;
78+
}
79+
7480
switch (x.ValueType)
7581
{
7682
case ValueType.None:

0 commit comments

Comments
 (0)