diff --git a/.gitignore b/.gitignore index 58942535c..ffc11549c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ DebugConfig.txt Host/Multitenancy/demo.config *.log.txt *temp.txt +*.Secrets.config # Folder bin[Rr]elease/ diff --git a/BeWo/BeWo.csproj b/BeWo/BeWo.csproj index 970ae7d9b..9945947dc 100644 --- a/BeWo/BeWo.csproj +++ b/BeWo/BeWo.csproj @@ -94,8 +94,15 @@ + + + + + + + AiConfigView.xaml @@ -107,7 +114,6 @@ RtfEditView.xaml - AnimatedBeWoWindow.xaml @@ -3512,7 +3518,6 @@ - diff --git a/BeWo/BeWoApp.xaml.cs b/BeWo/BeWoApp.xaml.cs index 27ba0440a..dedd7573f 100644 --- a/BeWo/BeWoApp.xaml.cs +++ b/BeWo/BeWoApp.xaml.cs @@ -45,11 +45,15 @@ namespace BeWo public partial class BeWoApp : INotifyPropertyChanged { private static DebugMessageLogView _DebugMessageLogView; - private static FrameworkElement _lockedContent; + private static AppSettings _AppSettings; + private static CompactEmployeeDC _CompactLoggedOnEmployee; + private static EmployeeDC _LoggedOnEmployee; + private static UserDC _LoggedOnUser; + private static MandatorDC _Mandator; + private static bool _IsInDeveloperMode; public static LoginControl LoginControl; - public static MainControl MainControl; public static string ShortVersion = "3.25"; @@ -57,43 +61,39 @@ namespace BeWo public static string Version = "Version 3.25"; public static int RenderTier = 0; - public static bool IsInDesignMode = DesignerProperties.GetIsInDesignMode(new DependencyObject()); internal static string IpAddress = string.Empty; - internal static string Tenant = string.Empty; - internal static string ServerName = string.Empty; - internal static string UserName = string.Empty; - internal static string UserPassword = string.Empty; - internal static string TwoFactorPin = string.Empty; - internal static string chatServerURL = string.Empty; - private static AppSettings _AppSettings; - - private static CompactEmployeeDC _CompactLoggedOnEmployee; - private static EmployeeDC _LoggedOnEmployee; - - private static UserDC _LoggedOnUser; - - private static MandatorDC _Mandator; private static string _ServerAddress; private static int _LockUITime = 30; - private static List OpenDevExpressEditForms = new List(); + private static List OpenDevExpressEditForms = new List(); private static DocumentWatcher _DocumentWatcher; internal static PasswortSecurityStrength PasswortStrength; public static BeWoApp CurrentBeWo => Current as BeWoApp; - public static Dictionary ICD10Diagnosis { get; set; } + public static bool IsInDeveloperMode { + get => _IsInDeveloperMode; + set + { + if(IsInDeveloperMode == value) + return; + + _IsInDeveloperMode = value; + CurrentBeWo.FirePropertyChanged(nameof(IsInDeveloperMode)); + } + } + public static EmployeeDC LoggedOnEmployee { get => _LoggedOnEmployee; @@ -561,6 +561,7 @@ namespace BeWo // REFACTOR: getUserSetting verwenden? AppSettings.ModuleAiEnabled = getUserSetting(SettingsKeys.ModuleAiEnabled); + AppSettings.ModuleAiSettingsEnabled = getUserSetting(SettingsKeys.ModuleAiSettingsEnabled); switch (_Mandator.BeWoClientType) { @@ -622,15 +623,18 @@ namespace BeWo showDienstplanung = true; showHilfeplanBezeichnung = true; AppSettings.AllowStorno = true; - AppSettings.ShowAI = true; - AppSettings.ShowAIInternal = true; + //AppSettings.ShowAI = true; + //AppSettings.ShowAIInternal = true; AppSettings.ShowWorktime = true; AppSettings.ShowPersehImport = true; AppSettings.ShowWohnhilfe = true; //AppSettings.AllowGkvAbrechnung = true; //AppSettings.AllowGkvAbrechnung = false; //showInfoButtonInCalender = true; + IsInDeveloperMode = true; + //IsInDeveloperMode = false; AppSettings.ModuleAiEnabled = true; + AppSettings.ModuleAiSettingsEnabled = false; #endif AppSettings.ShowDatevFields = showDatevFields; @@ -671,6 +675,11 @@ namespace BeWo BS.Shared.Settings.ApplicationSettings.SupportConceptExpirationLimitInMonths = AppSettings.HilfeplanAuslaufAuswahl; + if (IsInDeveloperMode) + { + applyDeveloperMode(); + } + if(MainControl is object) { MainControl.UpdateMandator(); @@ -678,6 +687,11 @@ namespace BeWo } } + private static void applyDeveloperMode() + { + AppSettings.ModuleAiSettingsEnabled = true; + } + private static bool getUserSetting(string key) { var val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, key); @@ -932,7 +946,11 @@ namespace BeWo internal static void ShowError(string message, Exception ex, bool showSupportForm, bool showStacktrace) { - if (MainControl != null) + if (MainControl?.CurrentAnimatedBeWoWindow is object) + { + MessageBox.Show(message + "\n\n" + ex); + } + else if (MainControl != null) { MainControl.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action) (() => { diff --git a/BeWo/Converter/Features/AiConversationMessageSystemConverter.cs b/BeWo/Converter/Features/AiConversationMessageSystemConverter.cs new file mode 100644 index 000000000..9b27509d5 --- /dev/null +++ b/BeWo/Converter/Features/AiConversationMessageSystemConverter.cs @@ -0,0 +1,32 @@ +using BeWo.View.Navigation.Filter; +using BS.Shared.DataContracts; +using BS.Shared; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using BeWo.ViewModel; + +namespace BeWo.Converter.Features +{ + public class AiConversationMessageSystemConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (BeWoApp.IsInDeveloperMode) + return value; + + var ret = (value as IEnumerable).Where(vm => vm.Role != AiConversationMessageRole.System); + + return ret; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/BeWo/Core/BeWoWpfUtils.cs b/BeWo/Core/BeWoWpfUtils.cs index 6eda82e55..86083b566 100644 --- a/BeWo/Core/BeWoWpfUtils.cs +++ b/BeWo/Core/BeWoWpfUtils.cs @@ -293,5 +293,15 @@ namespace BeWo.Core return null; } + + public static void ScrollToBottom(ListBox listBox) + { + if (VisualTreeHelper.GetChildrenCount(listBox) > 0) + { + Border border = (Border)VisualTreeHelper.GetChild(listBox, 0); + ScrollViewer scrollViewer = (ScrollViewer)VisualTreeHelper.GetChild(border, 0); + scrollViewer.ScrollToBottom(); + } + } } } \ No newline at end of file diff --git a/BeWo/Core/Config/AppSettings.cs b/BeWo/Core/Config/AppSettings.cs index a76a67672..aadbe5fa1 100644 --- a/BeWo/Core/Config/AppSettings.cs +++ b/BeWo/Core/Config/AppSettings.cs @@ -487,6 +487,7 @@ namespace BeWo.Core.Config public bool AllowGkvAbrechnung { get; set; } public bool ModuleAiEnabled { get; set; } + public bool ModuleAiSettingsEnabled { get; set; } public bool ShowWohnhilfe { get; set; } public bool ShowImportAbschlagszahlungen { get; set; } diff --git a/BeWo/DebugConfig.cs b/BeWo/DebugConfig.cs index ad6d26b7f..badf2fb8b 100644 --- a/BeWo/DebugConfig.cs +++ b/BeWo/DebugConfig.cs @@ -147,9 +147,9 @@ namespace BeWo AutoLogin = true, //SelectView = UIContext.AiConversation, //SelectIndex = 8, - //DefaultLoginUsername = "m1", - //DefaultLoginPassword = "bewobewo", - //DefaultProfilename = "5000000000", + DefaultLoginUsername = "m1", + DefaultLoginPassword = "bewobewo", + DefaultProfilename = "5000000000", EnableAutoRemoteDebugging = true }); diff --git a/BeWo/MainControl.xaml.cs b/BeWo/MainControl.xaml.cs index 761f15d7a..e50af7cca 100644 --- a/BeWo/MainControl.xaml.cs +++ b/BeWo/MainControl.xaml.cs @@ -2,7 +2,9 @@ using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +using System.IO.Ports; using System.Linq; +using System.Runtime.Remoting.Contexts; using System.Security.Cryptography; using System.Text; using System.Windows; @@ -19,6 +21,7 @@ using BeWo.Core.Service; using BeWo.Scheduler.View; using BeWo.SchulbegleitenderDienst; using BeWo.ServiceProxy; +using BeWo.Services; using BeWo.View; using BeWo.View.Detail; using BeWo.View.Detail.Zeiterfassung; @@ -33,6 +36,7 @@ using BS.Shared.Core; using BS.Shared.DataContracts; using BS.Shared.Extensions; using BS.Shared.Translation; +using DevExpress.XtraEditors; using Hyperlink = System.Windows.Documents.Hyperlink; namespace BeWo @@ -180,9 +184,35 @@ namespace BeWo #endif UpdateMandator(); + + ControlFactory = new BeWoControlFactory(); + WindowFactory = new BeWoWindowFactory(); + WindowService = new BeWoWindowService(WindowFactory, ControlFactory); } - public AnimatedBeWoWindow CurrentAnimatedBeWoWindow { get; set; } + private AnimatedBeWoWindow _CurrentAnimatedBeWoWindow; + public AnimatedBeWoWindow CurrentAnimatedBeWoWindow + { + get => _CurrentAnimatedBeWoWindow; + set + { + if (value == _CurrentAnimatedBeWoWindow) + return; + + _CurrentAnimatedBeWoWindow = value; + + if (value is null) + HideModalBackgroundFade(.5); + else + { + ShowModalBackgroundFade(.5); + } + } + } + + internal IControlFactory ControlFactory { get; set; } + internal IWindowFactory WindowFactory { get; set; } + internal IWindowService WindowService { get; set; } public List OpenedModalViewWindows { get; set; } @@ -379,8 +409,7 @@ namespace BeWo if (_ModalPopupControls.Count == 0) { - grid_main.Children.Remove(ModalPopupBackGround); - ModalPopupBackGround = null; + HideModalBackground(); } else { @@ -471,16 +500,6 @@ namespace BeWo } } - public void ShowViewAsModalPopup(string title, Control control, HorizontalAlignment horizontalAlignment = HorizontalAlignment.Center, VerticalAlignment verticalAlignment = VerticalAlignment.Center) - { - var groupbox = new GroupBox(); - - groupbox.Header = title; - groupbox.Content = control; - - ShowControlAsModalPopup(groupbox, horizontalAlignment, verticalAlignment); - } - public void ShowControlAsModalPopup(Control control) { ShowControlAsModalPopup(control, HorizontalAlignment.Center, VerticalAlignment.Center); @@ -931,13 +950,26 @@ namespace BeWo } } - internal void ShowModalBackground() + internal void ShowModalBackgroundFade(double duration = 0.3, double opacity = 0.5) { + if (ModalPopupBackGround is Grid && grid_main.Children.Contains(ModalPopupBackGround)) + return; + + ShowModalBackground(0); + DoubleAnimation lAnim = new DoubleAnimation(opacity, new Duration(TimeSpan.FromSeconds(duration))); + ModalPopupBackGround.BeginAnimation(OpacityProperty, lAnim); + } + + internal void ShowModalBackground(double start_opacity = .5) + { + if (ModalPopupBackGround is Grid && grid_main.Children.Contains(ModalPopupBackGround)) + return; + ModalPopupBackGround = new Grid { IsHitTestVisible = true, Background = Brushes.White, - Opacity = .5 + Opacity = start_opacity }; Grid.SetColumnSpan(ModalPopupBackGround, 3); @@ -948,6 +980,28 @@ namespace BeWo Panel.SetZIndex(ModalPopupBackGround, 500); } + internal void HideModalBackgroundFade(double duration = 0.3) + { + if (ModalPopupBackGround is null || !grid_main.Children.Contains(ModalPopupBackGround)) + return; + + DoubleAnimation lAnim = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(duration))); + lAnim.Completed += (s, e) => + { + HideModalBackground(); + }; + ModalPopupBackGround.BeginAnimation(OpacityProperty, lAnim); + } + + internal void HideModalBackground() + { + if (ModalPopupBackGround is null || !grid_main.Children.Contains(ModalPopupBackGround)) + return; + + grid_main.Children.Remove(ModalPopupBackGround); + ModalPopupBackGround = null; + } + private void logoutanimation_Completed(object sender, EventArgs e) { //var navigationService = NavigationService.GetNavigationService(this); diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml b/BeWo/Scheduler/View/NewSchedulerView.xaml index 88bd0f4cc..f5d187b71 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml @@ -1,261 +1,472 @@ - + - - - - - - - + + + + + + + - - + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + - - - + + + + - + - - - + + + - - - + + - + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -269,77 +480,160 @@ - - - + + + - + - - + + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -349,312 +643,570 @@ - - - - - - + + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - + - - - - - - - - - - - - - - - + + + + diff --git a/BeWo/View/Detail/AI/AiConversationChatView.xaml.cs b/BeWo/View/Detail/AI/AiConversationChatView.xaml.cs index 228b195b3..d75ac5e6c 100644 --- a/BeWo/View/Detail/AI/AiConversationChatView.xaml.cs +++ b/BeWo/View/Detail/AI/AiConversationChatView.xaml.cs @@ -1,4 +1,5 @@ -using BeWo.ServiceProxy; +using BeWo.Core; +using BeWo.ServiceProxy; using BeWo.ViewModel.ListViewModel; using BS.Shared.Extensions; using DevExpress.Mvvm; @@ -30,11 +31,20 @@ namespace BeWo.View.Detail.AI { InitializeComponent(); - OpenAiSettingCommand = new DelegateCommand(OpenAiSetting); - ((INotifyCollectionChanged)listbox_messages.Items).CollectionChanged += listbox_conversations_SelectionChanged; popup_settings.Closed += (s, e) => ViewModel.UpdateConfig(); + + ViewModel.SendNewMessageSuccess += (s, e) => + { + if (txt_input_message.Visibility == Visibility.Visible) + txt_input_message.Focus(); + }; + } + + public AiConversationChatView(string stylestring) : this() + { + rootgroupbox.Style = (Style)FindResource(stylestring); } public AiConversationListVM ViewModel @@ -43,32 +53,48 @@ namespace BeWo.View.Detail.AI set => DataContext = value; } - public DelegateCommand OpenAiSettingCommand { get; set; } - private void BeWoView_Loaded(object sender, RoutedEventArgs e) { if (BeWoApp.IsInDesignMode) return; + ViewModel.ReloadConfigCommand.Execute(null); ViewModel.ReloadConversationsCommand.Execute(null); } - private void OpenAiSetting() - { - ServiceFacade.DoAiEnhancedServiceAsnyc(x => x.GetAiModels(), (x) => - { - ViewModel.Models.MakeEqualTo(x); - popup_settings.IsOpen = true; - }, true, this); - } - private void listbox_conversations_SelectionChanged(object sender, NotifyCollectionChangedEventArgs e) { - if (VisualTreeHelper.GetChildrenCount(listbox_messages) > 0) + BeWoWpfUtils.ScrollToBottom(listbox_messages); + } + + private void popup_conversation_clone_Loaded(object sender, RoutedEventArgs e) + { + BeWoWpfUtils.ScrollToBottom(listbox_messages_clone); + } + + private void Grid_PreviewKeyDown(object sender, KeyEventArgs e) + { + if (e.Key == Key.Enter) { - Border border = (Border)VisualTreeHelper.GetChild(listbox_messages, 0); - ScrollViewer scrollViewer = (ScrollViewer)VisualTreeHelper.GetChild(border, 0); - scrollViewer.ScrollToBottom(); + if ((Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) + { + // Shift + Enter gedrückt + Console.WriteLine("Shift + Enter erkannt"); + } + else + { + // Nur Enter gedrückt + // Console.WriteLine("Enter erkannt"); + + object p = null; + if(ViewModel.SendNewMessageCommand.CanExecute(p)) + ViewModel.SendNewMessageCommand.Execute(p); + + e.Handled = true; + } + + // Optional: Event als behandelt markieren, wenn du die Standardaktion unterdrücken willst + // e.Handled = true; } } } diff --git a/BeWo/View/Detail/CustomerView.xaml b/BeWo/View/Detail/CustomerView.xaml index 16217dd8d..a7797c6ff 100644 --- a/BeWo/View/Detail/CustomerView.xaml +++ b/BeWo/View/Detail/CustomerView.xaml @@ -804,6 +804,7 @@ + @@ -3786,10 +3787,10 @@ Selector.Selected="tabitem_log_Selected" /> @@ -3798,12 +3799,40 @@ + + + + + + + + +