131 lines
4.5 KiB
C#
131 lines
4.5 KiB
C#
using BeWo.View.Controls;
|
|
using BeWo.View;
|
|
using BeWo.View.Windows;
|
|
using BeWo.ViewModel;
|
|
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;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.ComponentModel;
|
|
|
|
namespace BeWo.Services
|
|
{
|
|
internal class BeWoWindowService : IWindowService
|
|
{
|
|
private readonly IWindowFactory _windowFactory;
|
|
private readonly IControlFactory _controlFactory;
|
|
|
|
public BeWoWindowService(IWindowFactory builder, IControlFactory controlFactory)
|
|
{
|
|
_windowFactory = builder;
|
|
_controlFactory = controlFactory;
|
|
}
|
|
|
|
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(
|
|
wf => wf.GetAiTitle(uIContext),
|
|
cf => cf.GetAiConversationControl(uIContext, bewoObjects, reference_oid),
|
|
height, width);
|
|
}
|
|
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(
|
|
wf => wf.GetAiTitle(uIContext),
|
|
cf => cf.GetAiConversationControl(uIContext, bewoObjects, reference_oid),
|
|
height, width);
|
|
}
|
|
|
|
public void ShowERechnungWindow(MemoryStream pdf)
|
|
{
|
|
ShowWindowDialog(
|
|
"E-Rechnung",
|
|
cf => cf.GetPdfViewer(pdf));
|
|
}
|
|
|
|
public void ShowERechnungModalViewWindow(MemoryStream pdf)
|
|
{
|
|
ShowModalViewWindow(
|
|
"E-Rechnung",
|
|
cf => cf.GetPdfViewer(pdf));
|
|
}
|
|
|
|
public void ShowTextViewerWindow(string title, string text, double height, double width)
|
|
{
|
|
ShowWindowDialog(
|
|
title,
|
|
cf => cf.GetTextViewer(text),
|
|
height, width);
|
|
}
|
|
|
|
public void ShowPdfViewerWindow(string title, MemoryStream pdf, double height = 900, double width = 600)
|
|
{
|
|
ShowWindowDialog(title,
|
|
cf => cf.GetPdfViewer(pdf),
|
|
height, width);
|
|
}
|
|
|
|
public void ShowPdfViewerModalViewWindow(string title, MemoryStream pdf)
|
|
{
|
|
ShowModalViewWindow(title,
|
|
cf => cf.GetPdfViewer(pdf));
|
|
}
|
|
|
|
public void ShowGkvAbrechnungDetailWindow(GkvAbrechnungVM vm, CancelEventHandler cancelEvent, double height, double width)
|
|
{
|
|
// Kleiner Hack
|
|
// - Ggf WindowFactory kapselt Zuorgnudn von Control zu Window
|
|
var title = _windowFactory.GetGkvTitle(vm);
|
|
var control = _controlFactory.GetGkvAbrechnungDetailControl(vm);
|
|
var window = _windowFactory.GetAnimatedBeWoWindow(title, control, height, width);
|
|
window.Closing += cancelEvent;
|
|
window.ShowDialog();
|
|
}
|
|
|
|
private void ShowWindow(Func<IWindowFactory, string> getTitle, Func<IControlFactory, Control> getControl, double height, double width)
|
|
=> ShowWindow(getTitle(_windowFactory), getControl, height, width);
|
|
private void ShowWindowDialog(Func<IWindowFactory, string> getTitle, Func<IControlFactory, Control> getControl, double? height = null, double? width = null)
|
|
=> ShowWindowDialog(getTitle(_windowFactory), getControl, height, width);
|
|
private void ShowModalViewWindow(Func<IWindowFactory, string> getTitle, Func<IControlFactory, Control> getControl, double? height = null, double? width = null)
|
|
=> ShowModalViewWindow(getTitle(_windowFactory), getControl, height, width);
|
|
|
|
private void ShowWindow(string title, Func<IControlFactory, Control> getControl, double? height = null, double? width = null)
|
|
{
|
|
var control = getControl(_controlFactory);
|
|
var window = _windowFactory.GetAnimatedBeWoWindow(title, control, height, width);
|
|
window.Show();
|
|
}
|
|
|
|
private void ShowWindowDialog(string title, Func<IControlFactory, Control> getControl, double? height = null, double? width = null)
|
|
{
|
|
var control = getControl(_controlFactory);
|
|
var window = _windowFactory.GetAnimatedBeWoWindow(title, control, height, width);
|
|
window.ShowDialog();
|
|
}
|
|
|
|
private void ShowModalViewWindow(string title, Func<IControlFactory, Control> getControl, double? height = null, double? width = null)
|
|
{
|
|
var control = getControl(_controlFactory);
|
|
var window = _windowFactory.GetGenericModalViewWindow(title, control, height, width);
|
|
window.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => BeWoApp.MainControl.CloseCurrentPopUp()));
|
|
BeWoApp.MainControl.ShowControlAsModalPopup(window);
|
|
}
|
|
}
|
|
}
|