2026-01-07 16:53:26 +01:00
|
|
|
|
using BeWo.Core;
|
|
|
|
|
|
using BeWo.ViewModel;
|
2025-12-30 11:30:01 +01:00
|
|
|
|
using BeWo.ViewModel.View.Administration;
|
|
|
|
|
|
using DevExpress.Mvvm;
|
|
|
|
|
|
using DevExpress.Xpf.Accordion;
|
2026-01-07 16:53:26 +01:00
|
|
|
|
using DevExpress.Xpf.Core.Native;
|
|
|
|
|
|
using DevExpress.Xpf.Editors;
|
|
|
|
|
|
using DevExpress.XtraEditors.TextEditController.Win32;
|
2025-12-30 11:30:01 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2026-01-07 16:53:26 +01:00
|
|
|
|
using System.Diagnostics;
|
2025-12-30 11:30:01 +01:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Runtime.Remoting.Messaging;
|
|
|
|
|
|
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.Detail.AI
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Interaktionslogik für AiPromptbausteinTreeView.xaml
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class AiPromptbausteinComplexTreeView : BeWoView
|
|
|
|
|
|
{
|
2026-01-07 16:53:26 +01:00
|
|
|
|
public bool IsDragging = false;
|
|
|
|
|
|
|
2025-12-30 11:30:01 +01:00
|
|
|
|
public AiPromptbausteinComplexTreeView(AiPromptbausteinComplexTreeViewModel viewModel = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
|
|
if (viewModel == null )
|
2026-06-10 15:41:31 +02:00
|
|
|
|
viewModel = new AiPromptbausteinComplexTreeViewModel(BeWoApp.WindowService, BS.Shared.AiActionType.ServiceRecordConversation);
|
2025-12-30 11:30:01 +01:00
|
|
|
|
|
|
|
|
|
|
DataContext = ViewModel = viewModel;
|
|
|
|
|
|
|
|
|
|
|
|
Loaded += (s, e) => ViewModel.ReloadVMList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public AiPromptbausteinComplexTreeViewModel ViewModel { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public override bool IsDirty => ViewModel is object && ViewModel.IsDirty;
|
|
|
|
|
|
|
|
|
|
|
|
private void OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
|
{
|
2026-06-10 15:41:31 +02:00
|
|
|
|
TreeViewItem treeViewItem = VisualUpwardSearch<TreeViewItem>(e.OriginalSource as DependencyObject);
|
2025-12-30 11:30:01 +01:00
|
|
|
|
|
|
|
|
|
|
if (treeViewItem != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
treeViewItem.Focus();
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (ViewModel.SelectedFolder == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_LastTreeViewItem.IsSelected = false;
|
|
|
|
|
|
|
|
|
|
|
|
treeView.Focus();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-10 15:41:31 +02:00
|
|
|
|
static T VisualUpwardSearch<T>(DependencyObject source) where T : DependencyObject
|
2025-12-30 11:30:01 +01:00
|
|
|
|
{
|
2026-06-10 15:41:31 +02:00
|
|
|
|
while (source != null && !(source is T))
|
2025-12-30 11:30:01 +01:00
|
|
|
|
source = VisualTreeHelper.GetParent(source);
|
|
|
|
|
|
|
2026-06-10 15:41:31 +02:00
|
|
|
|
return source as T;
|
2025-12-30 11:30:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void treeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (ViewModel is null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
ViewModel.SelectedFolder = treeView.SelectedValue as AiPromptbausteinFolderVM;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Grid_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
|
{
|
2026-06-10 15:41:31 +02:00
|
|
|
|
TreeViewItem treeViewItem = VisualUpwardSearch<TreeViewItem>(e.OriginalSource as DependencyObject);
|
2025-12-30 11:30:01 +01:00
|
|
|
|
|
|
|
|
|
|
if (treeViewItem is null)
|
2026-06-10 15:41:31 +02:00
|
|
|
|
{
|
|
|
|
|
|
treeView.Focus();
|
|
|
|
|
|
e.Handled = true;
|
2025-12-30 11:30:01 +01:00
|
|
|
|
return;
|
2026-06-10 15:41:31 +02:00
|
|
|
|
}
|
2025-12-30 11:30:01 +01:00
|
|
|
|
|
|
|
|
|
|
if (e.ClickCount == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
ViewModel.OpenEditFolderDialogCommand.Execute(null);
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private TreeViewItem _LastTreeViewItem;
|
|
|
|
|
|
private void treeView_Selected(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
_LastTreeViewItem = e.OriginalSource as TreeViewItem;
|
2025-12-30 14:43:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void treeView_ContextMenuOpening(object sender, ContextMenuEventArgs e)
|
|
|
|
|
|
{
|
2026-06-10 15:41:31 +02:00
|
|
|
|
|
2025-12-30 14:43:25 +01:00
|
|
|
|
}
|
2025-12-31 10:47:00 +01:00
|
|
|
|
|
|
|
|
|
|
private void ListBox_ContextMenuOpening(object sender, ContextMenuEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
ViewModel.UpdatePromptCommands();
|
|
|
|
|
|
}
|
2026-01-07 16:53:26 +01:00
|
|
|
|
|
|
|
|
|
|
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
|
}
|
2026-02-10 12:58:13 +01:00
|
|
|
|
|
|
|
|
|
|
private void Grid_PreviewMouseDown_1(object sender, MouseButtonEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!ViewModel.OpenEditPromptDialogCommand.CanExecute(null))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (e.ClickCount == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
ViewModel.OpenEditPromptDialogCommand.Execute(null);
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-05-06 15:57:24 +02:00
|
|
|
|
|
|
|
|
|
|
private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(e.OriginalSource is TabControl)
|
|
|
|
|
|
{
|
2026-05-15 12:11:44 +02:00
|
|
|
|
listBoxEdit1.UnSelectAll();
|
|
|
|
|
|
listBoxEdit2.UnSelectAll();
|
2026-05-12 11:47:04 +02:00
|
|
|
|
listBoxEdit3.UnSelectAll();
|
2026-05-06 15:57:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-05-15 11:51:34 +02:00
|
|
|
|
|
|
|
|
|
|
private void Grid_PreviewMouseDown_2(object sender, MouseButtonEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!ViewModel.OpenEditRoutineDialogCommand.CanExecute(null))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (e.ClickCount == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
ViewModel.OpenEditRoutineDialogCommand.Execute(null);
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-06-10 15:41:31 +02:00
|
|
|
|
|
|
|
|
|
|
private void listBoxEdit3_PreviewKeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
//TreeViewItem treeViewItem = VisualUpwardSearch<ListViewItem>(e.OriginalSource as DependencyObject);
|
|
|
|
|
|
|
|
|
|
|
|
//if (treeViewItem is null)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// treeView.Focus();
|
|
|
|
|
|
// e.Handled = true;
|
|
|
|
|
|
// return;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//if (e.ClickCount == 2)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// ViewModel.OpenEditFolderDialogCommand.Execute(null);
|
|
|
|
|
|
// e.Handled = true;
|
|
|
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void listBoxEdit3_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
ListBoxItem listBoxItem = VisualUpwardSearch<ListBoxItem>(e.OriginalSource as DependencyObject);
|
|
|
|
|
|
|
|
|
|
|
|
if(listBoxItem is null)
|
|
|
|
|
|
{
|
|
|
|
|
|
((ListBoxEdit)sender).Focus();
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void listBoxEdit3_PreviewMouseDown_1(object sender, MouseButtonEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-12-30 11:30:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|