ITextProvider

This commit is contained in:
2026-05-26 15:22:54 +02:00
parent bd9d0b2f06
commit d5f0575bf0
6 changed files with 59 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
using BS.Shared;
using BS.Shared.Interface;
using DevExpress.Mvvm;
using DevExpress.XtraPrinting;
using System;
@@ -11,15 +12,16 @@ namespace BeWo.ViewModel.Controls.AI
{
public class AiChatButtonWithHistoryViewModel : AiChatButtonViewModel
{
private string currentValue;
private readonly ITextProvider _provider;
private readonly string _key;
public int CurrentIndex { get; set; }
public List<string> History { get; set; }
public string CurrentValue
{
get => currentValue;
set => SetProperty(ref currentValue, value, nameof(CurrentValue));
get => _provider.GetText(_key);
set => _provider.SetText(_key, value);
}
public override bool IsHistoryEnabled => true;
@@ -30,7 +32,7 @@ namespace BeWo.ViewModel.Controls.AI
public DelegateCommand UndoAiActionCommand { get; protected set; }
public DelegateCommand RedoAiActionCommand { get; protected set; }
public AiChatButtonWithHistoryViewModel(AiActionType aiActionType) : base(aiActionType)
public AiChatButtonWithHistoryViewModel(AiActionType aiActionType, ITextProvider provider, string key) : base(aiActionType)
{
History = new List<string>();
CurrentIndex = 0;
@@ -51,6 +53,9 @@ namespace BeWo.ViewModel.Controls.AI
};
UndoAiActionCommand= new DelegateCommand(UndoAiAction);
RedoAiActionCommand= new DelegateCommand(RedoAiAction);
_provider = provider;
_key = key;
}
public override bool CanSendNewMessage => base.CanSendNewMessage && !string.IsNullOrEmpty(CurrentValue);