127 lines
4.1 KiB
C#
127 lines
4.1 KiB
C#
using BeWo.ServiceProxy;
|
|
using BeWo.View.Detail.AI;
|
|
using BeWo.ViewModel;
|
|
using BeWo.ViewModel.Controls.AI;
|
|
using BeWo.ViewModel.View.AI;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts.Feature.AI;
|
|
using BS.Shared.Exceptions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace BeWo.View.Controls.AI
|
|
{
|
|
public enum AiChatButtonOrientation
|
|
{
|
|
Right, Left
|
|
}
|
|
|
|
/// <summary>
|
|
/// Interaktionslogik für AiGenericConversationButton.xaml
|
|
/// </summary>
|
|
public partial class AiChatButton : UserControl
|
|
{
|
|
public AiChatButtonOrientation AiChatButtonOrientation
|
|
{
|
|
get { return (AiChatButtonOrientation)GetValue(AiChatButtonOrientationProperty); }
|
|
set { SetValue(AiChatButtonOrientationProperty, value); }
|
|
}
|
|
|
|
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
|
|
public static readonly DependencyProperty AiChatButtonOrientationProperty =
|
|
DependencyProperty.Register("AiChatButtonOrientation", typeof(AiChatButtonOrientation), typeof(AiChatButton), new PropertyMetadata(AiChatButtonOrientation.Left, OnOrientationChanged));
|
|
|
|
static void OnOrientationChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
var control = (AiChatButton)d;
|
|
control.UpdateOrientation((AiChatButtonOrientation)e.NewValue);
|
|
}
|
|
|
|
public AiChatButtonViewModel ViewModel => DataContext as AiChatButtonViewModel;
|
|
|
|
public AiChatButton()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
ViewModel?.ReloadData(true, InitPromptbausteine);
|
|
}
|
|
|
|
private void InitPromptbausteine(AiActionType actionType, List<AiPromptbausteinFolderDC> folders)
|
|
{
|
|
VMFactory.CreateAiPromptbausteinFolderListVM(folders, (listvm) =>
|
|
{
|
|
var viewmodel = new AiPromptbausteinSelectionComplexViewModel(actionType, listvm);
|
|
viewmodel.ItemAccepted += ItemAccepted;
|
|
viewmodel.RequestClose += (s, e) => viewmodel.ResetSelection();
|
|
ViewModel.AllPromptsViewModel = viewmodel;
|
|
|
|
var viewmodel2 = new AiPromptbausteinSelectionComplexViewModel(actionType, listvm, true);
|
|
viewmodel2.ItemAccepted += ItemAccepted;
|
|
popup_promptbaustein_favoriten.Closed += (s, e) => viewmodel2.ResetSelection();
|
|
var view2 = new AiPromptbausteinComplexSelectionFavoritenView(viewmodel2);
|
|
viewmodel2.SelectedFolder = viewmodel2.Folders.VMList[0];
|
|
view2.Padding = new Thickness(3);
|
|
view2.Background = FindResource("ObjectEditBackgroundBrush") as System.Windows.Media.Brush;
|
|
border_promptbaustein_favoriten.Child = view2;
|
|
|
|
viewmodel.VMListReloaded += (s, e) => viewmodel2.ReloadVMList(false);
|
|
});
|
|
}
|
|
|
|
private void ItemAccepted(object sender, AbstractBaseVM e)
|
|
{
|
|
ViewModel.ItemAccepted(e);
|
|
}
|
|
|
|
private void btnOpenAi5_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
|
|
{
|
|
ViewModel.OpenFavoritePromptsPopupCommand.Execute(null);
|
|
}
|
|
|
|
void UpdateOrientation(AiChatButtonOrientation orientation)
|
|
{
|
|
if(orientation == AiChatButtonOrientation.Left)
|
|
{
|
|
Grid.SetColumn(btnOpenAiConversation, 0);
|
|
Grid.SetColumn(btnOpenAiPromptbaustein, 1);
|
|
Grid.SetColumn(imgWarning, 2);
|
|
Grid.SetColumn(stackpanelUndoRedo, 3);
|
|
|
|
stackpanelUndoRedo.Margin = new Thickness(6, 0, 0, 0);
|
|
btnOpenAiConversation.Margin = new Thickness(0, 0, 6, 0);
|
|
btnOpenAiPromptbaustein.Margin = new Thickness(6, 0, 6, 0);
|
|
}
|
|
else if(orientation == AiChatButtonOrientation.Right)
|
|
{
|
|
Grid.SetColumn(stackpanelUndoRedo, 0);
|
|
Grid.SetColumn(imgWarning, 1);
|
|
Grid.SetColumn(btnOpenAiConversation, 2);
|
|
Grid.SetColumn(btnOpenAiPromptbaustein, 3);
|
|
|
|
stackpanelUndoRedo.Margin = new Thickness(0, 0, 6, 0);
|
|
btnOpenAiConversation.Margin = new Thickness(6, 0, 6, 0);
|
|
btnOpenAiPromptbaustein.Margin = new Thickness(6, 0, 0, 0);
|
|
}
|
|
else
|
|
{
|
|
throw BeWoNotImplementedException.CreateFromEnum(orientation);
|
|
}
|
|
}
|
|
}
|
|
}
|