From 12cb51634433fe6dc5a3bd2eb64483b6ea62360b Mon Sep 17 00:00:00 2001 From: Rene Evertz Date: Tue, 27 May 2025 09:24:12 +0200 Subject: [PATCH] PdfViewer umgezogen --- BeWo/Services/BeWoControlFactory.cs | 14 +++- BeWo/Services/BeWoWindowFactory.cs | 47 ++--------- BeWo/Services/BeWoWindowService.cs | 84 ++++++++++++++++--- BeWo/Services/IControlFactory.cs | 7 +- BeWo/Services/IWindowFactory.cs | 4 +- BeWo/Services/IWindowService.cs | 7 +- .../Detail/Accounting/InvoiceOverview.xaml.cs | 2 +- Shared/AppSender/OwnSoftSender.cs | 15 ---- 8 files changed, 107 insertions(+), 73 deletions(-) delete mode 100644 Shared/AppSender/OwnSoftSender.cs diff --git a/BeWo/Services/BeWoControlFactory.cs b/BeWo/Services/BeWoControlFactory.cs index e368896a9..efe57308d 100644 --- a/BeWo/Services/BeWoControlFactory.cs +++ b/BeWo/Services/BeWoControlFactory.cs @@ -1,7 +1,9 @@ -using BeWo.View.Detail.AI; +using BeWo.View.Controls; +using BeWo.View.Detail.AI; using BS.Shared; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -24,6 +26,16 @@ namespace BeWo.Services return control; } + public PdfViewer GetPdfViewer(byte[] bytes) => GetPdfViewer(new MemoryStream(bytes)); + public PdfViewer GetPdfViewer(MemoryStream ms) + { + var control = new PdfViewer(); + + control.PdfData = ms; + + return control; + } + private string getStyleString(UIContext uIContext) { switch (uIContext) { diff --git a/BeWo/Services/BeWoWindowFactory.cs b/BeWo/Services/BeWoWindowFactory.cs index 4ae304a18..3481d184a 100644 --- a/BeWo/Services/BeWoWindowFactory.cs +++ b/BeWo/Services/BeWoWindowFactory.cs @@ -13,30 +13,7 @@ namespace BeWo.Services { internal class BeWoWindowFactory : IWindowFactory { - public Dictionary UIContext2Header { get; set; } = new Dictionary() - { - {UIContext.ServiceRecord, "KI Chat: Zeiterfassung" }, - {UIContext.Customer, "KI Chat: Klienten Übersicht" }, - {UIContext.Person, "KI Chat: Personen Übersicht" }, - {UIContext.Employee, "KI Chat: Mitarbeiter Übersicht" }, - {UIContext.Organisation, "KI Chat: Organisation Übersicht" }, - {UIContext.SupportConcept, "KI Chat: Hilfeplan Übersicht" }, - {UIContext.CustomerSingle, "KI Chat: Klient" }, - }; - - public AnimatedBeWoWindow GetAiConversationWindow(UIContext uIContext, Control control, double height = 600, double width = 1200) - { - UIContext2Header.TryGetValue(uIContext, out string title); - - if (string.IsNullOrEmpty(title)) - title = "default"; - - var window = GetAnimatedBeWoWindow(title, control,height, width); - - return window; - } - - private AnimatedBeWoWindow GetAnimatedBeWoWindow(string title, Control control, double height = 600, double width = 600) + public AnimatedBeWoWindow GetAnimatedBeWoWindow(string title, Control control, double height, double width) { var beWoWindow = new AnimatedBeWoWindow(); @@ -52,27 +29,19 @@ namespace BeWo.Services return beWoWindow; } - public Control GetAiModalViewWindow(UIContext uIContext, Control control, double height = 600, double width = 1200) - { - UIContext2Header.TryGetValue(uIContext, out string title); - - if (string.IsNullOrEmpty(title)) - title = "default"; - - var popup = GetAiModalViewWindow(title, control, height, width); - - return popup; - } - - private Control GetAiModalViewWindow(string title, Control control, double height = 600, double width = 600) + public Control GetGenericModalViewWindow(string title, Control control, double? height , double? width) { var popup = new GroupBox(); popup.Style = Application.Current.FindResource("PopUpWindowStyle") as Style; popup.Header = title; popup.Content = control; - popup.Height = height; - popup.Width = width; + + if(height is double h) + popup.Height = h; + + if (width is double w) + popup.Width= w; return popup; } diff --git a/BeWo/Services/BeWoWindowService.cs b/BeWo/Services/BeWoWindowService.cs index ecf66a07a..04dfe1108 100644 --- a/BeWo/Services/BeWoWindowService.cs +++ b/BeWo/Services/BeWoWindowService.cs @@ -2,7 +2,9 @@ using BS.Shared; using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows; @@ -22,48 +24,106 @@ namespace BeWo.Services _controlFactory = controlFactory; } - public void ShowAiConversationWindow(UIContext uIContext, Dictionary bewoObjects, long? reference_oid = null) + public void ShowAiConversationWindow(UIContext uIContext, Dictionary bewoObjects, long? reference_oid, double height, double width) { #if !DEBUG BeWoApp.ShowInfoMessage("Diese Funktion befindet sich in der Testphase."); return; #endif - ShowWindowDialog( + getAiTitle(uIContext), cf => cf.GetAiConversationControl(uIContext, bewoObjects, reference_oid), - (wf, ctrl) => wf.GetAiConversationWindow(uIContext, ctrl)); + height, width); } - public void ShowAiConversationModalViewWindow(UIContext uIContext, Dictionary bewoObjects, long? reference_oid = null) + public void ShowAiConversationModalViewWindow(UIContext uIContext, Dictionary bewoObjects, long? reference_oid, double height, double width) { #if !DEBUG BeWoApp.ShowInfoMessage("Diese Funktion befindet sich in der Testphase."); return; #endif - ShowModalViewWindow(cf => cf.GetAiConversationControl(uIContext, bewoObjects, reference_oid), - (wf, ctrl) => wf.GetAiModalViewWindow(uIContext, ctrl)); + ShowModalViewWindow( + getAiTitle(uIContext), + cf => cf.GetAiConversationControl(uIContext, bewoObjects, reference_oid), + height, width); } - private void ShowWindow(Func getControl, Func getWindow) + public void ShowERechnungModalViewWindow(MemoryStream pdf) + { + ShowModalViewWindow( + "E-Rechnung", + cf => cf.GetPdfViewer(pdf)); + } + + private void ShowWindow(string title, Func getControl, double height, double width) { var control = getControl(_controlFactory); - var window = getWindow(_builder, control); + var window = _builder.GetAnimatedBeWoWindow(title, control, height, width); window.Show(); } - private void ShowWindowDialog(Func getControl, Func getWindow) + private void ShowWindowDialog(string title, Func getControl, double height, double width) { var control = getControl(_controlFactory); - var window = getWindow(_builder, control); + var window = _builder.GetAnimatedBeWoWindow(title, control, height, width); window.ShowDialog(); } - private void ShowModalViewWindow(Func getControl, Func getPopup) + private void ShowModalViewWindow(string title, Func getControl) { var control = getControl(_controlFactory); - var window = getPopup(_builder, control); + var window = _builder.GetGenericModalViewWindow(title, control); window.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => BeWoApp.MainControl.CloseCurrentPopUp())); BeWoApp.MainControl.ShowControlAsModalPopup(window); } + + private void ShowModalViewWindow(string title, Func getControl, double height, double width) + { + var control = getControl(_controlFactory); + var window = _builder.GetGenericModalViewWindow(title, control, height, width); + window.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => BeWoApp.MainControl.CloseCurrentPopUp())); + BeWoApp.MainControl.ShowControlAsModalPopup(window); + } + + //private void ShowWindow(Func getControl, Func getWindow) + //{ + // var control = getControl(_controlFactory); + // var window = getWindow(_builder, control); + // window.Show(); + //} + + //private void ShowWindowDialog(Func getControl, Func getWindow) + //{ + // var control = getControl(_controlFactory); + // var window = getWindow(_builder, control); + // window.ShowDialog(); + //} + + //private void ShowModalViewWindow(Func getControl, Func getPopup) + //{ + // var control = getControl(_controlFactory); + // var window = getPopup(_builder, control); + // window.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => BeWoApp.MainControl.CloseCurrentPopUp())); + // BeWoApp.MainControl.ShowControlAsModalPopup(window); + //} + + + public Dictionary UIContext2Header { get; set; } = new Dictionary() + { + {UIContext.ServiceRecord, "KI Chat: Zeiterfassung" }, + {UIContext.Customer, "KI Chat: Klienten Übersicht" }, + {UIContext.Person, "KI Chat: Personen Übersicht" }, + {UIContext.Employee, "KI Chat: Mitarbeiter Übersicht" }, + {UIContext.Organisation, "KI Chat: Organisation Übersicht" }, + {UIContext.SupportConcept, "KI Chat: Hilfeplan Übersicht" }, + {UIContext.CustomerSingle, "KI Chat: Klient" }, + }; + private string getAiTitle(UIContext context) + { + if (UIContext2Header.TryGetValue(context, out string title)) + return title; + + return "default"; + } } } diff --git a/BeWo/Services/IControlFactory.cs b/BeWo/Services/IControlFactory.cs index e1202ebf9..bcb836b63 100644 --- a/BeWo/Services/IControlFactory.cs +++ b/BeWo/Services/IControlFactory.cs @@ -1,6 +1,8 @@ -using BS.Shared; +using BeWo.View.Controls; +using BS.Shared; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -12,5 +14,8 @@ namespace BeWo.Services internal interface IControlFactory { Control GetAiConversationControl(UIContext uIContext, Dictionary context, long? reference_oid = null); + + PdfViewer GetPdfViewer(MemoryStream ms); + PdfViewer GetPdfViewer(byte[] bytes); } } diff --git a/BeWo/Services/IWindowFactory.cs b/BeWo/Services/IWindowFactory.cs index ad99ef312..59614a279 100644 --- a/BeWo/Services/IWindowFactory.cs +++ b/BeWo/Services/IWindowFactory.cs @@ -12,7 +12,7 @@ namespace BeWo.Services { internal interface IWindowFactory { - AnimatedBeWoWindow GetAiConversationWindow(UIContext uIContext, Control control, double height = 600, double width = 1200); - Control GetAiModalViewWindow(UIContext uIContext, Control control, double height = 600, double width = 1200); + AnimatedBeWoWindow GetAnimatedBeWoWindow(string title, Control control, double height, double width); + Control GetGenericModalViewWindow(string title, Control control, double? height = null, double? width = null); } } diff --git a/BeWo/Services/IWindowService.cs b/BeWo/Services/IWindowService.cs index 4cc7c3ef9..7e9c839aa 100644 --- a/BeWo/Services/IWindowService.cs +++ b/BeWo/Services/IWindowService.cs @@ -1,6 +1,7 @@ using BS.Shared; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -11,7 +12,9 @@ namespace BeWo.Services { internal interface IWindowService { - void ShowAiConversationWindow(UIContext uIContext, Dictionary bewoObjects, long? reference_oid = null); - void ShowAiConversationModalViewWindow(UIContext uIContext, Dictionary bewoObjects, long? reference_oid = null); + void ShowAiConversationWindow(UIContext uIContext, Dictionary bewoObjects, long? reference_oid = null, double height = 600, double width = 1200); + void ShowAiConversationModalViewWindow(UIContext uIContext, Dictionary bewoObjects, long? reference_oid = null, double height = 600, double width = 1200); + + void ShowERechnungModalViewWindow(MemoryStream pdf); } } diff --git a/BeWo/View/Detail/Accounting/InvoiceOverview.xaml.cs b/BeWo/View/Detail/Accounting/InvoiceOverview.xaml.cs index efc6ac4cb..7d7c08ee1 100644 --- a/BeWo/View/Detail/Accounting/InvoiceOverview.xaml.cs +++ b/BeWo/View/Detail/Accounting/InvoiceOverview.xaml.cs @@ -634,7 +634,7 @@ namespace BeWo.View.Detail.Accounting if (res.HasErrors) BeWoApp.ShowErrorMessage("Fehler: " + res.ResponseString); else - BeWoUtils.ShowPdfWindow(res.ResponseBytes); + MainControl.WindowService.ShowERechnungModalViewWindow(new MemoryStream(res.ResponseBytes)); } private void btn_xRechnung_Click(object sender, RoutedEventArgs e) diff --git a/Shared/AppSender/OwnSoftSender.cs b/Shared/AppSender/OwnSoftSender.cs deleted file mode 100644 index 5f003d6b3..000000000 --- a/Shared/AppSender/OwnSoftSender.cs +++ /dev/null @@ -1,15 +0,0 @@ -using BS.Shared.Core; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading.Tasks; - -namespace BS.Shared.AppSender -{ - public static class OwnSoftSender - { - - } -}