PdfViewer umgezogen

This commit is contained in:
2025-05-27 09:24:12 +02:00
parent 375ba4b36b
commit 12cb516344
8 changed files with 107 additions and 73 deletions

View File

@@ -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)
{

View File

@@ -13,30 +13,7 @@ namespace BeWo.Services
{
internal class BeWoWindowFactory : IWindowFactory
{
public Dictionary<UIContext, string> UIContext2Header { get; set; } = new Dictionary<UIContext, string>()
{
{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;
}

View File

@@ -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<TableID, long[]> bewoObjects, long? reference_oid = null)
public void ShowAiConversationWindow(UIContext uIContext, Dictionary<TableID, long[]> 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<TableID, long[]> bewoObjects, long? reference_oid = null)
public void ShowAiConversationModalViewWindow(UIContext uIContext, Dictionary<TableID, long[]> 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<IControlFactory, Control> getControl, Func<IWindowFactory, Control, Window> getWindow)
public void ShowERechnungModalViewWindow(MemoryStream pdf)
{
ShowModalViewWindow(
"E-Rechnung",
cf => cf.GetPdfViewer(pdf));
}
private void ShowWindow(string title, Func<IControlFactory, Control> 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<IControlFactory, Control> getControl, Func<IWindowFactory, Control, Window> getWindow)
private void ShowWindowDialog(string title, Func<IControlFactory, Control> 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<IControlFactory, Control> getControl, Func<IWindowFactory, Control, Control> getPopup)
private void ShowModalViewWindow(string title, Func<IControlFactory, Control> 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<IControlFactory, Control> 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<IControlFactory, Control> getControl, Func<IWindowFactory, Control, Window> getWindow)
//{
// var control = getControl(_controlFactory);
// var window = getWindow(_builder, control);
// window.Show();
//}
//private void ShowWindowDialog(Func<IControlFactory, Control> getControl, Func<IWindowFactory, Control, Window> getWindow)
//{
// var control = getControl(_controlFactory);
// var window = getWindow(_builder, control);
// window.ShowDialog();
//}
//private void ShowModalViewWindow(Func<IControlFactory, Control> getControl, Func<IWindowFactory, Control, Control> 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<UIContext, string> UIContext2Header { get; set; } = new Dictionary<UIContext, string>()
{
{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";
}
}
}

View File

@@ -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<TableID, long[]> context, long? reference_oid = null);
PdfViewer GetPdfViewer(MemoryStream ms);
PdfViewer GetPdfViewer(byte[] bytes);
}
}

View File

@@ -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);
}
}

View File

@@ -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<TableID, long[]> bewoObjects, long? reference_oid = null);
void ShowAiConversationModalViewWindow(UIContext uIContext, Dictionary<TableID, long[]> bewoObjects, long? reference_oid = null);
void ShowAiConversationWindow(UIContext uIContext, Dictionary<TableID, long[]> bewoObjects, long? reference_oid = null, double height = 600, double width = 1200);
void ShowAiConversationModalViewWindow(UIContext uIContext, Dictionary<TableID, long[]> bewoObjects, long? reference_oid = null, double height = 600, double width = 1200);
void ShowERechnungModalViewWindow(MemoryStream pdf);
}
}

View File

@@ -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)

View File

@@ -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
{
}
}