DeveloperWindow
+ cleane Shortcuts
This commit is contained in:
@@ -143,7 +143,7 @@ namespace BeWo.ViewModel.Controls.AI
|
||||
vm.SendAfterLoaded = true;
|
||||
vm.PromptInput = prompt;
|
||||
vm.MessageInput = prompt.Prompt;
|
||||
BeWoApp.MainControl.WindowService.Show(vm);
|
||||
BeWoApp.WindowService.Show(vm);
|
||||
return;
|
||||
}
|
||||
else if (e is AiPromptbausteinRoutineVM routine)
|
||||
@@ -152,7 +152,7 @@ namespace BeWo.ViewModel.Controls.AI
|
||||
vm.SendAfterLoaded = true;
|
||||
vm.RoutineInput = routine;
|
||||
vm.MessageInput = routine.Steps.VMList[0].PromptReference.Prompt;
|
||||
BeWoApp.MainControl.WindowService.Show(vm);
|
||||
BeWoApp.WindowService.Show(vm);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -170,12 +170,12 @@ namespace BeWo.ViewModel.Controls.AI
|
||||
|
||||
private protected void OpenConversationPopup()
|
||||
{
|
||||
BeWoApp.MainControl.WindowService.Show(GetConversationViewModel());
|
||||
BeWoApp.WindowService.Show(GetConversationViewModel());
|
||||
}
|
||||
|
||||
private protected void OpenAllPromptsPopup()
|
||||
{
|
||||
BeWoApp.MainControl.WindowService.Show(AllPromptsViewModel);
|
||||
BeWoApp.WindowService.Show(AllPromptsViewModel);
|
||||
}
|
||||
|
||||
private protected void OpenFavoritePromptsPopup()
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
// Holt bereits geladene
|
||||
if (invoice_base.XRechnungStoredFileVM is StoredFileVM vm && vm.Data is byte[] bytes)
|
||||
{
|
||||
BeWoApp.MainControl.WindowService.ShowERechnungWindow(new MemoryStream(bytes));
|
||||
BeWoApp.WindowService.ShowERechnungWindow(new MemoryStream(bytes));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace BeWo.ViewModel.ListViewModel
|
||||
|
||||
invoice_base.XRechnungStoredFileVM.Data = bytes;
|
||||
|
||||
BeWoApp.MainControl.WindowService.ShowERechnungWindow(new MemoryStream(bytes));
|
||||
BeWoApp.WindowService.ShowERechnungWindow(new MemoryStream(bytes));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace BeWo.ViewModel.View.AI
|
||||
public AiPromptbausteinSelectionComplexViewModel(AiActionType aiActionType) : this()
|
||||
{
|
||||
AiActionType = aiActionType;
|
||||
WindowService = BeWoApp.MainControl.WindowService;
|
||||
WindowService = BeWoApp.WindowService;
|
||||
InitCommands();
|
||||
}
|
||||
public AiPromptbausteinSelectionComplexViewModel(AiActionType aiActionType, AiPromptbausteinFolderListVM viewModel, bool isFavorite = false, bool canOpen = true) : this(aiActionType)
|
||||
|
||||
@@ -4,6 +4,7 @@ using BeWo.ViewModel.ListViewModel;
|
||||
using BS.Shared;
|
||||
using BS.Shared.DataContracts.Compact;
|
||||
using BS.Shared.DataContracts.Feature.AI;
|
||||
using DevExpress.DataProcessing;
|
||||
using DevExpress.Mvvm;
|
||||
using DevExpress.Utils.Extensions;
|
||||
using DevExpress.Xpf.Layout.Core;
|
||||
@@ -51,6 +52,9 @@ namespace BeWo.ViewModel.View.Administration
|
||||
public DelegateCommand DeleteRoutineCommand { get; private set; }
|
||||
public DelegateCommand ChangeFavoritenStateRoutineCommand { get; private set; }
|
||||
|
||||
public DelegateCommand OpenEditItemDialogCommand { get; private set; }
|
||||
public DelegateCommand DeleteItemCommand { get; private set; }
|
||||
public DelegateCommand ChangeFavoritenStateItemCommand { get; private set; }
|
||||
|
||||
public bool CanEditPromptbausteine { get; set; }
|
||||
|
||||
@@ -59,19 +63,32 @@ namespace BeWo.ViewModel.View.Administration
|
||||
get => _SelectedFolder;
|
||||
set
|
||||
{
|
||||
SetProperty(ref _SelectedFolder, value, nameof(SelectedFolder));
|
||||
var success = SetProperty(ref _SelectedFolder, value, nameof(SelectedFolder));
|
||||
|
||||
if (SelectedItem is AiPromptbausteinPromptVM vm)
|
||||
{
|
||||
SelectedItem = null;
|
||||
}
|
||||
|
||||
if (!success)
|
||||
return;
|
||||
|
||||
UpdateFolderCommands();
|
||||
UpdatePromptCommands();
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractBaseVM SelectedItem
|
||||
{
|
||||
get => _SelectedItem;
|
||||
set => SetProperty(ref _SelectedItem, value, nameof(SelectedItem));
|
||||
set {
|
||||
var success = SetProperty(ref _SelectedItem, value, nameof(SelectedItem));
|
||||
|
||||
if (!success)
|
||||
return;
|
||||
|
||||
UpdateItemCommands();
|
||||
}
|
||||
}
|
||||
|
||||
public AiPromptbausteinComplexTreeViewModel() : this(null, AiActionType.ServiceRecordConversation)
|
||||
@@ -107,6 +124,18 @@ namespace BeWo.ViewModel.View.Administration
|
||||
DeleteRoutineCommand = new DelegateCommand(OpenDeleteRoutineDialog, canOpenDeleteRoutineDialog, false);
|
||||
ChangeFavoritenStateRoutineCommand = new DelegateCommand(ChangeFavoritenStateRoutine, canChangeFavoritenStateRoutine, false);
|
||||
|
||||
Action executeEditItem = () => ExecuteItem(OpenEditPromptDialog, OpenEditRoutineDialog);
|
||||
Func<bool> canExecuteEditItem = () => canExecuteItem(canOpenEditPromptDialog, canOpenEditRoutineDialog);
|
||||
OpenEditItemDialogCommand = new DelegateCommand(executeEditItem, canExecuteEditItem, true);
|
||||
|
||||
Action executeDeleteItem = () => ExecuteItem(OpenDeletePromptDialog, OpenDeleteRoutineDialog);
|
||||
Func<bool> canExecuteDeleteItem = () => canExecuteItem(canOpenDeletePromptDialog, canOpenDeleteRoutineDialog);
|
||||
DeleteItemCommand = new DelegateCommand(executeDeleteItem, canExecuteDeleteItem, true);
|
||||
|
||||
Action executeFavoriteItem = () => ExecuteItem(ChangeFavoritenStatePrompt, ChangeFavoritenStateRoutine);
|
||||
Func<bool> canExecuteFavoriteItem = () => canExecuteItem(canChangeFavoritenStatePrompt, canChangeFavoritenStateRoutine);
|
||||
ChangeFavoritenStateItemCommand = new DelegateCommand(executeFavoriteItem, canExecuteFavoriteItem, true);
|
||||
|
||||
CanEditPromptbausteine = BeWoApp.HasLoggedOnUserRight(UserRightType.AiModulePromptbausteineEdit);
|
||||
}
|
||||
|
||||
@@ -140,7 +169,13 @@ namespace BeWo.ViewModel.View.Administration
|
||||
OpenAddRoutineDialogCommand.RaiseCanExecuteChanged();
|
||||
OpenEditRoutineDialogCommand.RaiseCanExecuteChanged();
|
||||
DeleteRoutineCommand.RaiseCanExecuteChanged();
|
||||
ChangeFavoritenStateRoutineCommand.RaiseCanExecuteChanged();
|
||||
ChangeFavoritenStateRoutineCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
public void UpdateItemCommands()
|
||||
{
|
||||
OpenEditItemDialogCommand.RaiseCanExecuteChanged();
|
||||
DeleteItemCommand.RaiseCanExecuteChanged();
|
||||
ChangeFavoritenStateItemCommand.RaiseCanExecuteChanged();
|
||||
}
|
||||
|
||||
internal void ReloadVMList()
|
||||
@@ -226,7 +261,7 @@ namespace BeWo.ViewModel.View.Administration
|
||||
|
||||
bool canOpenAddFolderDialog()
|
||||
{
|
||||
return CanEditPromptbausteine && (SelectedFolder?.CanAddFolder ?? true);
|
||||
return CanEditPromptbausteine && (SelectedFolder?.CanAddFolder ?? false);
|
||||
}
|
||||
bool canOpenEditFolderDialog()
|
||||
{
|
||||
@@ -533,6 +568,25 @@ namespace BeWo.ViewModel.View.Administration
|
||||
bool canOpenDeleteRoutineDialog() => CanEditPromptbausteine && ((SelectedItem as AiPromptbausteinRoutineVM)?.CanEdit ?? false);
|
||||
bool canChangeFavoritenStateRoutine() => SelectedItem is AiPromptbausteinRoutineVM;
|
||||
|
||||
void ExecuteItem(Action prompt_action, Action routine_action)
|
||||
{
|
||||
if (SelectedItem is AiPromptbausteinPromptVM)
|
||||
prompt_action();
|
||||
else if (SelectedItem is AiPromptbausteinRoutineVM)
|
||||
routine_action();
|
||||
else
|
||||
throw new NotImplementedException("item is not AiPromptbausteinPromptVM or AiPromptbausteinRoutineVM");
|
||||
}
|
||||
bool canExecuteItem(Func<bool> prompt_func, Func<bool> routine_func)
|
||||
{
|
||||
if (SelectedItem is AiPromptbausteinPromptVM)
|
||||
return prompt_func();
|
||||
else if (SelectedItem is AiPromptbausteinRoutineVM)
|
||||
return routine_func();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void InitDesigner()
|
||||
{
|
||||
var root = PredefinedAiPromptbausteinFolders.CreateSubTree(AiActionType.ServiceRecordConversation);
|
||||
|
||||
17
BeWo/ViewModel/View/Developer/DesignDeveloperViewModel.cs
Normal file
17
BeWo/ViewModel/View/Developer/DesignDeveloperViewModel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeWo.ViewModel.View.Developer
|
||||
{
|
||||
public class DesignDeveloperViewModel : DeveloperViewModel
|
||||
{
|
||||
public DesignDeveloperViewModel()
|
||||
{
|
||||
KeyboardFocus = "Button";
|
||||
LogicalFocus = "Button";
|
||||
}
|
||||
}
|
||||
}
|
||||
66
BeWo/ViewModel/View/Developer/DeveloperViewModel.cs
Normal file
66
BeWo/ViewModel/View/Developer/DeveloperViewModel.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using System.Windows;
|
||||
|
||||
namespace BeWo.ViewModel.View.Developer
|
||||
{
|
||||
public class DeveloperViewModel : WindowViewModel
|
||||
{
|
||||
private string _keyboardFocus;
|
||||
private string _logicalFocus;
|
||||
|
||||
public string KeyboardFocus
|
||||
{
|
||||
get => _keyboardFocus;
|
||||
set => SetProperty(ref _keyboardFocus, value, nameof(KeyboardFocus));
|
||||
}
|
||||
|
||||
public string LogicalFocus
|
||||
{
|
||||
get => _logicalFocus;
|
||||
set => SetProperty(ref _logicalFocus, value, nameof(LogicalFocus));
|
||||
}
|
||||
|
||||
public DeveloperViewModel()
|
||||
{
|
||||
var timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(200) };
|
||||
timer.Tick += (s, e) => Refresh();
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
// Keyboard Focus – globaler Input-Fokus, nur ein Element systemweit
|
||||
var keyboard = Keyboard.FocusedElement;
|
||||
KeyboardFocus = FormatElement(keyboard);
|
||||
|
||||
// Logical Focus – pro FocusScope, kann vom Keyboard Focus abweichen
|
||||
// z.B. wenn ein Menü oder Toolbar aktiv ist
|
||||
var mainWindow = Application.Current.MainWindow;
|
||||
var logical = mainWindow != null
|
||||
? FocusManager.GetFocusedElement(mainWindow)
|
||||
: null;
|
||||
LogicalFocus = FormatElement(logical);
|
||||
}
|
||||
|
||||
private static string FormatElement(object element)
|
||||
{
|
||||
if (element is null)
|
||||
return "(kein Fokus)";
|
||||
|
||||
if (element is FrameworkElement fe)
|
||||
{
|
||||
var name = string.IsNullOrEmpty(fe.Name) ? "(kein Name)" : fe.Name;
|
||||
var dc = fe.DataContext?.GetType().Name ?? "–";
|
||||
return $"{fe.GetType().Name} | Name: {name} | DC: {dc}";
|
||||
}
|
||||
|
||||
return element.GetType().Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user