diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index 7246f1dd3..42093a7fa 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -173,6 +173,8 @@ + + @@ -219,6 +221,9 @@ DatenbereinigungView.xaml + + DeveloperView.xaml + TeamFolderRightView.xaml @@ -371,6 +376,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/BeWo/BeWoApp.xaml.cs b/BeWo/BeWoApp.xaml.cs index 1c526e7e4..bf48c71a8 100644 --- a/BeWo/BeWoApp.xaml.cs +++ b/BeWo/BeWoApp.xaml.cs @@ -37,6 +37,7 @@ using DevExpress.XtraScheduler; using System.ServiceModel; using BeWo.View.Windows; using System.Diagnostics; +using BeWo.Services; namespace BeWo { @@ -81,6 +82,8 @@ namespace BeWo public static bool IsInDesignMode = DesignerProperties.GetIsInDesignMode(new DependencyObject()); + internal static IBeWoWindowService WindowService { get; set; } + public static EmployeeDC LoggedOnEmployee { get => _LoggedOnEmployee; @@ -1083,16 +1086,11 @@ namespace BeWo FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))); - BeWoAppInfo.BeWoAppVersion.TryActiveDeveloperMode(e.Args); + var controlFactory = new BeWoControlFactory(); + var windowFactory = new BeWoWindowFactory(); + WindowService = new BeWoWindowService(windowFactory, controlFactory); - //if(e.Args.LastOrDefault(x => x.StartsWith("/timeout:") || x.StartsWith("--timeout:")) is string str) - //{ - // var valuePart = str.Substring(str.IndexOf(':') + 1); - // if(int.TryParse(valuePart, out int parsedTimeout)) - // { - // AiTimeout = parsedTimeout; - // } - //} + BeWoAppInfo.BeWoAppVersion.TryActiveDeveloperMode(e.Args); } public static void ShowInfoMessage(string message) diff --git a/BeWo/Converter/TestDebugConverter.cs b/BeWo/Converter/TestDebugConverter.cs index d428f40b1..a44afd236 100644 --- a/BeWo/Converter/TestDebugConverter.cs +++ b/BeWo/Converter/TestDebugConverter.cs @@ -1,4 +1,5 @@ using BeWo.ViewModel; +using DevExpress.Mvvm; using System; using System.Globalization; using System.Windows.Data; @@ -12,6 +13,8 @@ namespace BeWo.Converter if (value is null) return null; + var t = ((DelegateCommand)value).CanExecute(null); + return value; } diff --git a/BeWo/DebugConfig.cs b/BeWo/DebugConfig.cs index 4b82cedc8..4bd0935f8 100644 --- a/BeWo/DebugConfig.cs +++ b/BeWo/DebugConfig.cs @@ -53,6 +53,8 @@ namespace BeWo public bool EnableAutoRemoteDebugging { get; set; } public bool EnableAllUserRightsInDebug { get; set; } = false; + public bool EnableDeveloperView { get; set; } = false; + public static DebugConfig SimpleAutoLogin => new DebugConfig() { DebugConfigMode = DebugConfigMode.SimpleAutoLogin, @@ -152,7 +154,8 @@ namespace BeWo //DefaultLoginUsername = "m1", //DefaultLoginPassword = "bewobewo", //DefaultProfilename = "5000000000", - EnableAutoRemoteDebugging = true + EnableAutoRemoteDebugging = true, + EnableDeveloperView = true }); name2config.Add("FeatureXRechnung", diff --git a/BeWo/MainControl.xaml.cs b/BeWo/MainControl.xaml.cs index 62539f6d8..51863271c 100644 --- a/BeWo/MainControl.xaml.cs +++ b/BeWo/MainControl.xaml.cs @@ -192,11 +192,16 @@ namespace BeWo UpdateMandator(); - var controlFactory = new BeWoControlFactory(); - var windowFactory = new BeWoWindowFactory(); - WindowService = new BeWoWindowService(windowFactory, controlFactory); +#if DEBUG + if (DebugConfig.CurrentConfig is DebugConfig config && config.EnableDeveloperView) + { + WindowService.ShowDeveloper(); + } +#endif } + public IBeWoWindowService WindowService => BeWoApp.WindowService; + private AnimatedBeWoWindow _CurrentAnimatedBeWoWindow; public AnimatedBeWoWindow CurrentAnimatedBeWoWindow { @@ -217,8 +222,6 @@ namespace BeWo } } - internal IBeWoWindowService WindowService { get; set; } - public List OpenedModalViewWindows { get; set; } internal Dictionary Views diff --git a/BeWo/Services/BeWoWindowService.cs b/BeWo/Services/BeWoWindowService.cs index f4bf4b8bb..efed9b5cc 100644 --- a/BeWo/Services/BeWoWindowService.cs +++ b/BeWo/Services/BeWoWindowService.cs @@ -23,6 +23,10 @@ using System.Windows.Controls.Primitives; using static DevExpress.XtraPrinting.Native.ExportOptionsPropertiesNames; using DevExpress.Mvvm.Native; using BeWo.ViewModel.View.Gkv; +using BeWo.ViewModel.View.Developer; +using BeWo.View.Developer; +using System.Windows.Forms; +using static DevExpress.Mvvm.Native.Either; namespace BeWo.Services { @@ -78,7 +82,7 @@ namespace BeWo.Services } } - public void ShowAiConversationWindow(AiConversationChatViewModel viewModel) + private void ShowAiConversationWindow(AiConversationChatViewModel viewModel) { var control = _controlFactory.GetAiConversationControl(viewModel); var title = _windowFactory.GetAiTitle(viewModel.ActionType); @@ -89,7 +93,7 @@ namespace BeWo.Services }; Show(title, control, viewModel, options); } - public void ShowAiPromptbausteinFolderWindow(AiPromptbausteinFolderViewModel viewModel) + private void ShowAiPromptbausteinFolderWindow(AiPromptbausteinFolderViewModel viewModel) { var control = new AiPromptbausteinFolderView(viewModel); var options = new BeWoWindowOptions() @@ -99,7 +103,7 @@ namespace BeWo.Services }; Show("KI Promptbaustein Ordner", control, viewModel, options); } - public void ShowAiPromptbausteinPromptWindow(AiPromptbausteinPromptViewModel viewModel) + private void ShowAiPromptbausteinPromptWindow(AiPromptbausteinPromptViewModel viewModel) { var control = new AiPromptbausteinPromptView(viewModel); var options = new BeWoWindowOptions() @@ -109,7 +113,7 @@ namespace BeWo.Services }; Show("KI Promptbaustein Prompt", control, viewModel, options); } - public void ShowAiPromptbausteinRoutineWindow(AiPromptbausteinRoutineViewModel viewModel) + private void ShowAiPromptbausteinRoutineWindow(AiPromptbausteinRoutineViewModel viewModel) { var control = new AiPromptbausteinRoutineView(viewModel); var options = new BeWoWindowOptions() @@ -119,7 +123,7 @@ namespace BeWo.Services }; Show("KI Promptbaustein Routine", control, viewModel, options); } - public void ShowAiPromptbausteinActionResultWindow(AiPromptbausteinActionResultViewModel viewModel) + private void ShowAiPromptbausteinActionResultWindow(AiPromptbausteinActionResultViewModel viewModel) { var control = new AiPromptbausteinActionResultView(viewModel); var options = new BeWoWindowOptions() @@ -130,7 +134,7 @@ namespace BeWo.Services Show("KI Promptbaustein Ergebnis", control, viewModel, options); } - public void ShowAiPromptbausteinSelectionComplexWindow(AiPromptbausteinSelectionComplexViewModel viewModel) + private void ShowAiPromptbausteinSelectionComplexWindow(AiPromptbausteinSelectionComplexViewModel viewModel) { var control = new AiPromptbausteinComplexSelectionView(viewModel); var options = new BeWoWindowOptions() @@ -140,7 +144,45 @@ namespace BeWo.Services }; Show("KI Promptbaustein Auswahl", control, viewModel, options); } - + +#if DEBUG + public void ShowDeveloper(DeveloperViewModel viewModel = null) + { + if(viewModel == null) + viewModel = new DeveloperViewModel(); + + var control = new DeveloperView(viewModel); + + var window = new Window(); + + window.Title = "Developer Informations"; + window.Content = control; + window.Height = 600; + window.Width = 800; + window.WindowStartupLocation = WindowStartupLocation.CenterOwner; + window.Topmost = true; + window.Deactivated += (s, e) => + { + window.Topmost = false; // set topmost false first + window.Topmost = true; // then set topmost true again. + }; + + var screens = Screen.AllScreens; + var firstSecondary = screens.LastOrDefault(s => s.Primary == false); + if (firstSecondary != null) + { + window.WindowStartupLocation = WindowStartupLocation.Manual; + // Ensure Window is minimized on creation + window.WindowState = WindowState.Minimized; + // Define Position on Secondary screen, for "Normal" window-mode + // ( Here Top/Left-Position ) + window.Left = firstSecondary.Bounds.Left; + window.Top = firstSecondary.Bounds.Top; + } + + window.Show(); + } +#endif public void ShowGkvAbrechnungDetailWindow(GkvAbrechnungDialogViewModel vm) { @@ -179,7 +221,7 @@ namespace BeWo.Services Show(title, control, null, pOptions); } - private void Show(string title, Control control, WindowViewModel windowViewModel, BeWoWindowOptions options) + private void Show(string title, System.Windows.Controls.Control control, WindowViewModel windowViewModel, BeWoWindowOptions options) { if (options.ShowAsModal) { diff --git a/BeWo/Services/IBeWoWindowService.cs b/BeWo/Services/IBeWoWindowService.cs index b64ea2caa..6338cd40a 100644 --- a/BeWo/Services/IBeWoWindowService.cs +++ b/BeWo/Services/IBeWoWindowService.cs @@ -1,8 +1,10 @@ -using BeWo.ViewModel; +using BeWo.View.Developer; +using BeWo.ViewModel; using BeWo.ViewModel.Light; using BeWo.ViewModel.View; using BeWo.ViewModel.View.Administration; using BeWo.ViewModel.View.AI; +using BeWo.ViewModel.View.Developer; using BeWo.ViewModel.View.Gkv; using BS.Shared; using System; @@ -20,7 +22,6 @@ namespace BeWo.Services public interface IBeWoWindowService { #region special - void ShowAiConversationWindow(AiConversationChatViewModel viewModel); void ShowGkvAbrechnungDetailWindow(GkvAbrechnungDialogViewModel vm); #endregion @@ -34,5 +35,9 @@ namespace BeWo.Services #endregion void Show(T windowViewModel) where T : WindowViewModel; + +#if DEBUG + void ShowDeveloper(DeveloperViewModel windowViewModel = null); +#endif } } diff --git a/BeWo/Styles/ControlStyles/ButtonStyles.xaml b/BeWo/Styles/ControlStyles/ButtonStyles.xaml index 8cb76f064..8b60d1bf0 100644 --- a/BeWo/Styles/ControlStyles/ButtonStyles.xaml +++ b/BeWo/Styles/ControlStyles/ButtonStyles.xaml @@ -2,6 +2,7 @@ \ No newline at end of file diff --git a/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml b/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml index 65b0b5792..8595c2dc7 100644 --- a/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml +++ b/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml @@ -13,8 +13,10 @@ xmlns:view="clr-namespace:BeWo.View" xmlns:vm="clr-namespace:BeWo.ViewModel" x:Name="root" + Focusable="True" + Background="Transparent" d:DataContext="{d:DesignInstance Type=administration:AiPromptbausteinComplexTreeViewModel, - IsDesignTimeCreatable=True}" + IsDesignTimeCreatable=True}" d:DesignHeight="450" d:DesignWidth="800" mc:Ignorable="d"> @@ -29,6 +31,7 @@ TargetType="ListBoxItem" /> + + + + + @@ -399,6 +407,7 @@ AllowDrop="True" BorderThickness="1,0,0,1" ContextMenuOpening="treeView_ContextMenuOpening" + Focusable="True" ItemContainerStyle="{DynamicResource igoal_treeitemstyle}" ItemTemplate="{StaticResource ai_promptbaustein_folder_itemtemplate}" ItemsSource="{Binding Folders.VMList, UpdateSourceTrigger=PropertyChanged}" @@ -416,14 +425,14 @@ - + Modifiers="Ctrl" />--> @@ -436,7 +445,7 @@ @@ -486,245 +495,329 @@ Width="1" HorizontalAlignment="Center" Background="#878890" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Hier sind noch keine Prompts/Routinen angelegt. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Hier sind noch keine Prompts angelegt. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Hier sind noch keine Routinen angelegt. - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Hier sind noch keine Prompts/Routinen angelegt. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Hier sind noch keine Prompts angelegt. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Hier sind noch keine Routinen angelegt. + + + + + + + + + + + + + + + + diff --git a/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml.cs b/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml.cs index 6d3167e07..9fa4c2485 100644 --- a/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml.cs +++ b/BeWo/View/Detail/AI/AiPromptbausteinComplexTreeView.xaml.cs @@ -38,7 +38,7 @@ namespace BeWo.View.Detail.AI InitializeComponent(); if (viewModel == null ) - viewModel = new AiPromptbausteinComplexTreeViewModel(BeWoApp.MainControl.WindowService, BS.Shared.AiActionType.ServiceRecordConversation); + viewModel = new AiPromptbausteinComplexTreeViewModel(BeWoApp.WindowService, BS.Shared.AiActionType.ServiceRecordConversation); DataContext = ViewModel = viewModel; @@ -51,7 +51,7 @@ namespace BeWo.View.Detail.AI private void OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e) { - TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject); + TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject); if (treeViewItem != null) { @@ -72,12 +72,12 @@ namespace BeWo.View.Detail.AI } } - static TreeViewItem VisualUpwardSearch(DependencyObject source) + static T VisualUpwardSearch(DependencyObject source) where T : DependencyObject { - while (source != null && !(source is TreeViewItem)) + while (source != null && !(source is T)) source = VisualTreeHelper.GetParent(source); - return source as TreeViewItem; + return source as T; } private void treeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) @@ -90,14 +90,17 @@ namespace BeWo.View.Detail.AI private void Grid_PreviewMouseDown(object sender, MouseButtonEventArgs e) { - TreeViewItem treeViewItem = VisualUpwardSearch(e.OriginalSource as DependencyObject); + TreeViewItem treeViewItem = VisualUpwardSearch(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; } @@ -111,7 +114,7 @@ namespace BeWo.View.Detail.AI private void treeView_ContextMenuOpening(object sender, ContextMenuEventArgs e) { - ViewModel.UpdateFolderCommands(); + } private void ListBox_ContextMenuOpening(object sender, ContextMenuEventArgs e) @@ -158,5 +161,40 @@ namespace BeWo.View.Detail.AI e.Handled = true; } } + + private void listBoxEdit3_PreviewKeyDown(object sender, KeyEventArgs e) + { + //TreeViewItem treeViewItem = VisualUpwardSearch(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(e.OriginalSource as DependencyObject); + + if(listBoxItem is null) + { + ((ListBoxEdit)sender).Focus(); + e.Handled = true; + return; + } + } + + private void listBoxEdit3_PreviewMouseDown_1(object sender, MouseButtonEventArgs e) + { + + } } } diff --git a/BeWo/View/Detail/CustomerView.xaml.cs b/BeWo/View/Detail/CustomerView.xaml.cs index a864bfc4f..5b9eb920e 100644 --- a/BeWo/View/Detail/CustomerView.xaml.cs +++ b/BeWo/View/Detail/CustomerView.xaml.cs @@ -308,21 +308,21 @@ namespace BeWo.View.Detail return dict; } - private AiConversationChatViewModel getAiConversationChatViewModel() - { - throw new NotImplementedException(); - //var customer_oid = ViewModel.DataContract.CustomerOid; - //var context = GetVisibleInformationReferences(); + // private AiConversationChatViewModel getAiConversationChatViewModel() + // { + // throw new NotImplementedException(); + // //var customer_oid = ViewModel.DataContract.CustomerOid; + // //var context = GetVisibleInformationReferences(); - // var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.CustomerDetail, context, customer_oid); + // // var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.CustomerDetail, context, customer_oid); - // return vm; - } + // // return vm; + //} - private void OpenAiWindow() - { - MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel()); - } + //private void OpenAiWindow() + //{ + // MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel()); + //} void Image_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e) { diff --git a/BeWo/View/Developer/DeveloperView.xaml b/BeWo/View/Developer/DeveloperView.xaml new file mode 100644 index 000000000..152f9f032 --- /dev/null +++ b/BeWo/View/Developer/DeveloperView.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BeWo/View/Developer/DeveloperView.xaml.cs b/BeWo/View/Developer/DeveloperView.xaml.cs new file mode 100644 index 000000000..6fc4d5c81 --- /dev/null +++ b/BeWo/View/Developer/DeveloperView.xaml.cs @@ -0,0 +1,38 @@ +using BeWo.ViewModel.View.Administration; +using BeWo.ViewModel.View.Developer; +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.Developer +{ + /// + /// Interaktionslogik für DeveloperView.xaml + /// + public partial class DeveloperView : BeWoView + { + public DeveloperViewModel ViewModel + { + get => DataContext as DeveloperViewModel; + set => DataContext = value; + } + + public DeveloperView(DeveloperViewModel viewModel) + { + InitializeComponent(); + + ViewModel = viewModel; + } + } +} diff --git a/BeWo/View/Navigation/CustomerNavigationView.xaml.cs b/BeWo/View/Navigation/CustomerNavigationView.xaml.cs index f459de501..ce34fd7ce 100644 --- a/BeWo/View/Navigation/CustomerNavigationView.xaml.cs +++ b/BeWo/View/Navigation/CustomerNavigationView.xaml.cs @@ -233,20 +233,20 @@ namespace BeWo.View.Navigation return dict; } - private AiConversationChatViewModel getAiConversationChatViewModel() - { - throw new NotImplementedException(); - // var context = GetVisibleInformationReferences(); + //private AiConversationChatViewModel getAiConversationChatViewModel() + //{ + // throw new NotImplementedException(); + //// var context = GetVisibleInformationReferences(); - // var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.CustomerNavigation, context); + //// var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.CustomerNavigation, context); - // return vm; - } + //// return vm; + //} - private void OpenAiWindow() - { - MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel()); - } + //private void OpenAiWindow() + //{ + // MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel()); + //} private void SupportConceptFilterComboBoxOnSelectionChanged(object o, SelectionChangedEventArgs selectionChangedEventArgs) { diff --git a/BeWo/View/Navigation/EmployeeNavigationView.xaml.cs b/BeWo/View/Navigation/EmployeeNavigationView.xaml.cs index fba9477c1..0f857a75b 100644 --- a/BeWo/View/Navigation/EmployeeNavigationView.xaml.cs +++ b/BeWo/View/Navigation/EmployeeNavigationView.xaml.cs @@ -108,20 +108,20 @@ namespace BeWo.View.Navigation return dict; } - private AiConversationChatViewModel getAiConversationChatViewModel() - { - throw new NotImplementedException(); - //var context = GetVisibleInformationReferences(); + //private AiConversationChatViewModel getAiConversationChatViewModel() + //{ + // throw new NotImplementedException(); + // //var context = GetVisibleInformationReferences(); - //var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.EmployeeNavigation, context); + // //var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.EmployeeNavigation, context); - //return vm; - } + // //return vm; + //} - private void OpenAiWindow() - { - MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel()); - } + //private void OpenAiWindow() + //{ + // MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel()); + //} private bool MainNavigationView_ArchiveObject(IFilterableDC obj) { diff --git a/BeWo/View/Navigation/OrganisationNavigationView.xaml.cs b/BeWo/View/Navigation/OrganisationNavigationView.xaml.cs index 5ed0c7c5e..e6e77cba1 100644 --- a/BeWo/View/Navigation/OrganisationNavigationView.xaml.cs +++ b/BeWo/View/Navigation/OrganisationNavigationView.xaml.cs @@ -73,20 +73,20 @@ namespace BeWo.View.Navigation return dict; } - private AiConversationChatViewModel getAiConversationChatViewModel() - { - throw new NotImplementedException(); - //var context = GetVisibleInformationReferences(); + //private AiConversationChatViewModel getAiConversationChatViewModel() + //{ + // throw new NotImplementedException(); + // //var context = GetVisibleInformationReferences(); - //var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.OrganisationNavigation, context); + // //var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.OrganisationNavigation, context); - //return vm; - } + // //return vm; + //} - private void OpenAiWindow() - { - MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel()); - } + //private void OpenAiWindow() + //{ + // MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel()); + //} private void mainNavigationView_CreateNewObject() { diff --git a/BeWo/View/Navigation/PersonNavigationView.xaml.cs b/BeWo/View/Navigation/PersonNavigationView.xaml.cs index c157194a5..ba06c1168 100644 --- a/BeWo/View/Navigation/PersonNavigationView.xaml.cs +++ b/BeWo/View/Navigation/PersonNavigationView.xaml.cs @@ -148,20 +148,20 @@ namespace BeWo.View.Navigation return dict; } - private AiConversationChatViewModel getAiConversationChatViewModel() - { - throw new NotImplementedException(); - //var context = GetVisibleInformationReferences(); + //private AiConversationChatViewModel getAiConversationChatViewModel() + //{ + // throw new NotImplementedException(); + // //var context = GetVisibleInformationReferences(); - //var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.PersonNavigation, context); + // //var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.PersonNavigation, context); - //return vm; - } + // //return vm; + //} - private void OpenAiWindow() - { - MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel()); - } + //private void OpenAiWindow() + //{ + // MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel()); + //} private void SupportConceptFilterComboBoxOnSelectionChanged(object o, SelectionChangedEventArgs selectionChangedEventArgs) { diff --git a/BeWo/View/Navigation/SupportConceptNavigationView.xaml.cs b/BeWo/View/Navigation/SupportConceptNavigationView.xaml.cs index 66b78e417..71be58f06 100644 --- a/BeWo/View/Navigation/SupportConceptNavigationView.xaml.cs +++ b/BeWo/View/Navigation/SupportConceptNavigationView.xaml.cs @@ -223,21 +223,21 @@ namespace BeWo.View.Navigation return dict; } - private AiConversationChatViewModel getAiConversationChatViewModel() - { - throw new NotImplementedException(); + //private AiConversationChatViewModel getAiConversationChatViewModel() + //{ + // throw new NotImplementedException(); - //var context = GetVisibleInformationReferences(); + // //var context = GetVisibleInformationReferences(); - //var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.SupportConceptNavigation, context); + // //var vm = VMFactory.CreateAiConversationChatViewModel(AiContextType.SupportConceptNavigation, context); - //return vm; - } + // //return vm; + //} - private void OpenAiWindow() - { - MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel()); - } + //private void OpenAiWindow() + //{ + // MainControl.WindowService.ShowAiConversationWindow(getAiConversationChatViewModel()); + //} private void SupportConceptFilterComboBoxOnSelectionChanged(object o, SelectionChangedEventArgs selectionChangedEventArgs) { diff --git a/BeWo/ViewModel/Controls/AI/AiChatButtonViewModel.cs b/BeWo/ViewModel/Controls/AI/AiChatButtonViewModel.cs index 04d90fdb6..66ef8f2e0 100644 --- a/BeWo/ViewModel/Controls/AI/AiChatButtonViewModel.cs +++ b/BeWo/ViewModel/Controls/AI/AiChatButtonViewModel.cs @@ -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() diff --git a/BeWo/ViewModel/ListViewModel/InvoiceBaseListVM.cs b/BeWo/ViewModel/ListViewModel/InvoiceBaseListVM.cs index 714719eb2..a58d0ba93 100644 --- a/BeWo/ViewModel/ListViewModel/InvoiceBaseListVM.cs +++ b/BeWo/ViewModel/ListViewModel/InvoiceBaseListVM.cs @@ -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 { diff --git a/BeWo/ViewModel/View/AI/AiPromptbausteinComplexSelectionViewModel.cs b/BeWo/ViewModel/View/AI/AiPromptbausteinComplexSelectionViewModel.cs index 2bf2a6081..369efa73c 100644 --- a/BeWo/ViewModel/View/AI/AiPromptbausteinComplexSelectionViewModel.cs +++ b/BeWo/ViewModel/View/AI/AiPromptbausteinComplexSelectionViewModel.cs @@ -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) diff --git a/BeWo/ViewModel/View/Administration/AiPromptbausteinComplexTreeViewModel.cs b/BeWo/ViewModel/View/Administration/AiPromptbausteinComplexTreeViewModel.cs index 8152dd318..99185ed6b 100644 --- a/BeWo/ViewModel/View/Administration/AiPromptbausteinComplexTreeViewModel.cs +++ b/BeWo/ViewModel/View/Administration/AiPromptbausteinComplexTreeViewModel.cs @@ -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 canExecuteEditItem = () => canExecuteItem(canOpenEditPromptDialog, canOpenEditRoutineDialog); + OpenEditItemDialogCommand = new DelegateCommand(executeEditItem, canExecuteEditItem, true); + + Action executeDeleteItem = () => ExecuteItem(OpenDeletePromptDialog, OpenDeleteRoutineDialog); + Func canExecuteDeleteItem = () => canExecuteItem(canOpenDeletePromptDialog, canOpenDeleteRoutineDialog); + DeleteItemCommand = new DelegateCommand(executeDeleteItem, canExecuteDeleteItem, true); + + Action executeFavoriteItem = () => ExecuteItem(ChangeFavoritenStatePrompt, ChangeFavoritenStateRoutine); + Func 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 prompt_func, Func 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); diff --git a/BeWo/ViewModel/View/Developer/DesignDeveloperViewModel.cs b/BeWo/ViewModel/View/Developer/DesignDeveloperViewModel.cs new file mode 100644 index 000000000..649e0da98 --- /dev/null +++ b/BeWo/ViewModel/View/Developer/DesignDeveloperViewModel.cs @@ -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"; + } + } +} diff --git a/BeWo/ViewModel/View/Developer/DeveloperViewModel.cs b/BeWo/ViewModel/View/Developer/DeveloperViewModel.cs new file mode 100644 index 000000000..b0885b8f0 --- /dev/null +++ b/BeWo/ViewModel/View/Developer/DeveloperViewModel.cs @@ -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; + } + } +} diff --git a/Service/Plugins/AiService2.cs b/Service/Plugins/AiService2.cs index a7ac5a04e..adf164483 100644 --- a/Service/Plugins/AiService2.cs +++ b/Service/Plugins/AiService2.cs @@ -147,22 +147,22 @@ namespace BeWo.Service.Plugins return conv_dc; } - public AiConversationDC CreateAiConversationWithPromptbaustein(AiConversationDC conversation, AiViewContextDC view_context, long oid) - { - var config = GetAiConfig(); + //public AiConversationDC CreateAiConversationWithPromptbaustein(AiConversationDC conversation, AiViewContextDC view_context, long oid) + //{ + // var config = GetAiConfig(); - var conv = createAiConversation(conversation.ActionType, view_context, config); + // var conv = createAiConversation(conversation.ActionType, view_context, config); - var promptbaustein = DAOFactory.GenericDAO.LoadByID(oid); + // var promptbaustein = DAOFactory.GenericDAO.LoadByID(oid); - var new_messages = sendNewMessage(conv, promptbaustein.Prompt, config); + // var new_messages = sendNewMessage(conv, promptbaustein.Prompt, config); - DAOFactory.GenericDAO.Insert(conv); + // DAOFactory.GenericDAO.Insert(conv); - var conv_dc = MapperFactory.AiConversation.MapToNewDC(conv); + // var conv_dc = MapperFactory.AiConversation.MapToNewDC(conv); - return conv_dc; - } + // return conv_dc; + //} public virtual AiConversationDC CloneAiConversation(long conversation_oid, long? last_message_oid) { var parent_conv = DAOFactory.GenericDAO.GetByID(conversation_oid); @@ -236,6 +236,40 @@ namespace BeWo.Service.Plugins return sendNewMessage(conv, message); } + public virtual AiConversationMessageDC[] ExecuteAiConversationWithMessage(long conversation, AiViewContextDC view_context, long routine, int step) + { + var conv = DAOFactory.GenericDAO.LoadByID(conversation); + + var routine_ent = DAOFactory.GenericDAO.LoadByID(routine); + + var step_ent = routine_ent.Steps[step]; + + var message = step_ent.PromptReference.Prompt; + + var actionType = conv.ActionType; + + var conv_messages = conv.Messages; + var conv_messages_filtered = conv_messages.Where(x => x.Role != AiConversationMessageRole.System); + + var new_conv = createAiConversation(actionType, view_context); + + if (routine_ent.RoutineType == AiRoutineType.Stack) + { + // Stack + return sendNewMessage(new_conv, message); + } + else if (routine_ent.RoutineType == AiRoutineType.Chain) + { + + } + else + { + throw BeWoNotImplementedException.CreateFromEnum(routine_ent.RoutineType); + } + + return sendNewMessage(conv, message); + } + public virtual bool CheckContextSize(AiActionType actionType, AiViewContextDC view_context) { var modell_oid_value = GetAiConfig().SelectedModel.Oid.Value; diff --git a/Service/ServiceContracts/Enhanced/IAiEnhancedService.cs b/Service/ServiceContracts/Enhanced/IAiEnhancedService.cs index af4d3b855..2792b26c1 100644 --- a/Service/ServiceContracts/Enhanced/IAiEnhancedService.cs +++ b/Service/ServiceContracts/Enhanced/IAiEnhancedService.cs @@ -20,22 +20,22 @@ namespace BeWo.Service.ServiceContracts.Enhanced { [FaultContract(typeof(BeWoFault))] [OperationContract] - [RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] + //[RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] AiConfigDC GetAiConfig(); [FaultContract(typeof(BeWoFault))] [OperationContract] - [RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] + //[RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] AiConfigDC UpdateAiConfig(AiConfigDC toUpdate); [FaultContract(typeof(BeWoFault))] [OperationContract] - [RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] + //[RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] IEnumerable GetAiModels(); [FaultContract(typeof(BeWoFault))] [OperationContract] - [RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] + //[RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] IEnumerable GetAiConversations(AiActionType actionType, long? oid); [FaultContract(typeof(BeWoFault))] @@ -48,31 +48,29 @@ namespace BeWo.Service.ServiceContracts.Enhanced [FaultContract(typeof(BeWoFault))] [OperationContract] - AiConversationDC CreateAiConversationWithPromptbaustein(AiConversationDC conversation, AiViewContextDC view_context, long prompt_oid); - - [FaultContract(typeof(BeWoFault))] - [OperationContract] - [RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] + //[RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] AiConversationDC CloneAiConversation(long conversation_oid, long? message_oid); [FaultContract(typeof(BeWoFault))] [OperationContract] - [RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] + //[RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] long UpdateAiConversationDisplayname(long oid, long version, string displayname); [FaultContract(typeof(BeWoFault))] [OperationContract] - [RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] void DeleteAiConversation(long conversation_oid); [FaultContract(typeof(BeWoFault))] [OperationContract] - [RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] AiConversationMessageDC[] SendNewMessage(long conversation, string message); [FaultContract(typeof(BeWoFault))] [OperationContract] - [RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] + AiConversationMessageDC[] ExecuteAiConversationWithMessage(long conversation, AiViewContextDC view_context, long routine, int step); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + //[RequireWcfAuthorization(UserRightType.AiModuleServiceRecordChat)] bool CheckContextSize(AiActionType actionType, AiViewContextDC view_context); [FaultContract(typeof(BeWoFault))] diff --git a/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs b/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs index dc8020418..0935bf43c 100644 --- a/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs +++ b/Service/ServiceImplementations/Enhanced/AiEnhancedServiceImp.cs @@ -35,8 +35,6 @@ namespace BeWo.Service.ServiceImplementations.Enhanced => GetAiService().CreateAiConversation(conversation, view_context); public AiConversationDC CreateAiConversationWithMessage(AiConversationDC conversation, AiViewContextDC view_context, string message) => GetAiService().CreateAiConversationWithMessage(conversation, view_context, message); - public AiConversationDC CreateAiConversationWithPromptbaustein(AiConversationDC conversation, AiViewContextDC view_context, long prompt_oid) - => GetAiService().CreateAiConversationWithPromptbaustein(conversation, view_context, prompt_oid); public AiConversationDC CloneAiConversation(long conversation_oid, long? last_message_oid) => GetAiService().CloneAiConversation(conversation_oid, last_message_oid); @@ -50,6 +48,9 @@ namespace BeWo.Service.ServiceImplementations.Enhanced public AiConversationMessageDC[] SendNewMessage(long conversation, string message) => GetAiService().SendNewMessage(conversation, message); + public AiConversationMessageDC[] ExecuteAiConversationWithMessage(long conversation, AiViewContextDC view_context, long routine, int step) + => GetAiService().ExecuteAiConversationWithMessage(conversation, view_context, routine, step); + public bool CheckContextSize(AiActionType actionType, AiViewContextDC view_context) => GetAiService().CheckContextSize(actionType, view_context);