AI Promptbaustein Auswahl flüssiger (IsSelected Bug) Reset Selection bei Popup Closed
108 lines
2.6 KiB
C#
108 lines
2.6 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;
|
|
private AiPromptbausteinPromptVM _SelectedPrompt;
|
|
|
|
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, bool isFavorite = false) : this(aiActionType)
|
|
{
|
|
LoadedActionType = aiActionType;
|
|
Folders = viewModel;
|
|
IsFavorite = isFavorite;
|
|
}
|
|
|
|
public bool IsFavorite { get; set; }
|
|
|
|
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 => _SelectedPrompt;
|
|
set
|
|
{
|
|
_SelectedPrompt = value;
|
|
FirePropertyChanged(nameof(SelectedPrompt));
|
|
}
|
|
}
|
|
public AiPromptbausteinFolderListVM Folders { get; private set; }
|
|
public AiActionType LoadedActionType { get; set; }
|
|
|
|
public void ResetSelection()
|
|
{
|
|
if (!IsFavorite)
|
|
SelectedFolder = null;
|
|
|
|
SelectedPrompt = null;
|
|
}
|
|
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));
|
|
}
|
|
}
|
|
}
|