89 lines
2.2 KiB
C#
89 lines
2.2 KiB
C#
using BeWo.ServiceProxy;
|
|
using BeWo.Services;
|
|
using BeWo.ViewModel.ListViewModel;
|
|
using BS.Shared;
|
|
using BS.Shared.Extensions.CustomInterfaces;
|
|
using DevExpress.Mvvm;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Input;
|
|
|
|
namespace BeWo.ViewModel.View.AI
|
|
{
|
|
public class AiPromptbausteinSelectionComplexViewModel : DialogViewModel
|
|
{
|
|
public event EventHandler<AiPromptbausteinPromptVM> PromptAccepted;
|
|
|
|
private AiPromptbausteinFolderVM _SelectedFolder;
|
|
|
|
public AiPromptbausteinSelectionComplexViewModel()
|
|
{
|
|
SendCommand = new DelegateCommand(Send, CanSend, true);
|
|
|
|
if (BeWoApp.IsInDesignMode)
|
|
{
|
|
Folders = new AiPromptbausteinFolderListVM();
|
|
}
|
|
}
|
|
public AiPromptbausteinSelectionComplexViewModel(AiActionType aiActionType) : this()
|
|
{
|
|
AiActionType = aiActionType;
|
|
}
|
|
public AiPromptbausteinSelectionComplexViewModel(AiActionType aiActionType, AiPromptbausteinFolderListVM viewModel) : this(aiActionType)
|
|
{
|
|
LoadedActionType = aiActionType;
|
|
Folders = viewModel;
|
|
}
|
|
|
|
public ICommand SendCommand { get; set; }
|
|
|
|
public AiActionType AiActionType { get; set; }
|
|
|
|
public AiPromptbausteinFolderVM SelectedFolder
|
|
{
|
|
get => _SelectedFolder;
|
|
set
|
|
{
|
|
_SelectedFolder = value;
|
|
FirePropertyChanged(nameof(SelectedFolder));
|
|
}
|
|
}
|
|
public AiPromptbausteinPromptVM SelectedPrompt { get; set; }
|
|
public AiPromptbausteinFolderListVM Folders { get; private set; }
|
|
public AiActionType LoadedActionType { get; set; }
|
|
|
|
public void Send()
|
|
{
|
|
CloseDialogCommand.Execute(null);
|
|
|
|
PromptAccepted?.Invoke(this, SelectedPrompt);
|
|
}
|
|
public bool CanSend()
|
|
{
|
|
return SelectedPrompt is object;
|
|
}
|
|
public void InitVMList()
|
|
{
|
|
if (Folders is object && LoadedActionType == AiActionType)
|
|
return;
|
|
|
|
LoadedActionType = AiActionType;
|
|
|
|
VMFactory.CreateAiPromptbausteinFolderListVMAsync(AiActionType, UpdateVMList);
|
|
}
|
|
public void ReloadVMList()
|
|
{
|
|
VMFactory.CreateAiPromptbausteinFolderListVMAsync(AiActionType, UpdateVMList);
|
|
}
|
|
private void UpdateVMList(AiPromptbausteinFolderListVM new_list)
|
|
{
|
|
Folders = new_list;
|
|
FirePropertyChanged(nameof(Folders));
|
|
}
|
|
}
|
|
}
|