style: Weniger Rätsel, mehr Interface

This commit is contained in:
2026-05-29 12:26:37 +02:00
parent 33ae8a7c96
commit 2b3ae451b7
9 changed files with 142 additions and 22 deletions

View File

@@ -14,8 +14,8 @@ namespace BeWo.ViewModel.Controls.AI
{
private readonly ITextProvider _provider;
private readonly string _key;
private int _currentIndex;
public int CurrentIndex { get; set; }
public List<string> History { get; set; }
public string CurrentValue
@@ -24,7 +24,20 @@ namespace BeWo.ViewModel.Controls.AI
set => _provider.SetText(_key, value);
}
public int CurrentIndex
{
get => _currentIndex;
set {
if(SetProperty(ref _currentIndex, value, nameof(CurrentIndex)))
{
FirePropertyChanged(nameof(IsUndoButtonVisible));
FirePropertyChanged(nameof(IsRedoButtonVisible));
}
}
}
public override bool IsHistoryEnabled => true;
public override bool IsHistoryVisible => History.Count > 1;
public bool IsUndoButtonVisible => CurrentIndex > 0;
public bool IsRedoButtonVisible => CurrentIndex < History.Count - 1;
@@ -51,8 +64,8 @@ namespace BeWo.ViewModel.Controls.AI
Name = "Ersetzen"
},
};
UndoAiActionCommand= new DelegateCommand(UndoAiAction);
RedoAiActionCommand= new DelegateCommand(RedoAiAction);
UndoAiActionCommand = new DelegateCommand(UndoAiAction);
RedoAiActionCommand = new DelegateCommand(RedoAiAction);
_provider = provider;
_key = key;
@@ -66,8 +79,7 @@ namespace BeWo.ViewModel.Controls.AI
History.Add(CurrentValue);
CurrentIndex = 0;
FirePropertyChanged(nameof(IsRedoButtonVisible));
FirePropertyChanged(nameof(IsUndoButtonVisible));
FirePropertyChanged(nameof(IsHistoryVisible));
}
public void UndoAiAction()
@@ -120,7 +132,11 @@ namespace BeWo.ViewModel.Controls.AI
History.RemoveRange(idx + 1, last_idx - idx);
}
if (CurrentValue != History[CurrentIndex])
if (History.Count == 0)
{
History.Add(CurrentValue);
}
else if (CurrentValue != History[CurrentIndex])
{
History.Add(CurrentValue);
CurrentIndex++;
@@ -130,6 +146,8 @@ namespace BeWo.ViewModel.Controls.AI
CurrentIndex++;
CurrentValue = str;
FirePropertyChanged(nameof(IsHistoryVisible));
}
}
}