147 lines
4.6 KiB
C#
147 lines
4.6 KiB
C#
using BeWo.View;
|
|
using BeWo.View.Detail.AI;
|
|
using BeWo.View.Windows;
|
|
using BeWo.ViewModel;
|
|
using BeWo.ViewModel.View.Administration;
|
|
using BeWo.ViewModel.View.AI;
|
|
using BeWo.ViewModel.View.Dialogs;
|
|
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;
|
|
using BeWo.ViewModel.Light;
|
|
using static DevExpress.Drawing.Internal.Fonts.DXFontMetrics;
|
|
|
|
namespace BeWo.Services
|
|
{
|
|
public class BeWoWindowService : IWindowService
|
|
{
|
|
private readonly IWindowFactory _windowFactory;
|
|
private readonly IControlFactory _controlFactory;
|
|
|
|
public BeWoWindowService(IWindowFactory builder, IControlFactory controlFactory)
|
|
{
|
|
_windowFactory = builder;
|
|
_controlFactory = controlFactory;
|
|
}
|
|
|
|
public void ShowAiConversationWindow(AiConversationChatViewModel viewModel)
|
|
{
|
|
ShowWindowDialog(
|
|
cf => cf.GetAiConversationControl(viewModel),
|
|
(wf, ctrl) => wf.GetAiConversationWindow(viewModel, ctrl));
|
|
}
|
|
public void ShowAiConversationModalViewWindow(AiConversationChatViewModel viewModel)
|
|
{
|
|
ShowModalViewWindow(
|
|
cf => cf.GetAiConversationControl(viewModel),
|
|
(wf, ctrl) => wf.GetAiModalViewWindow(viewModel, ctrl));
|
|
}
|
|
|
|
public void ShowAiPromptbausteinDetailWindow(AiPromptbausteinDetailViewModel viewModel)
|
|
{
|
|
ShowDialog(
|
|
cf => new AiPromptbausteinDetailView(viewModel),
|
|
(wf, ctrl) => wf.GetAnimatedBeWoWindow("AiPromptbaustein", ctrl, 200, 400),
|
|
viewModel);
|
|
}
|
|
|
|
public void ShowAiPromptbausteinSelectionWindow(AiPromptbausteinSelectionViewModel viewModel)
|
|
{
|
|
ShowDialog(
|
|
cf => new AiPromptbausteinSelectionView(viewModel),
|
|
(wf, ctrl) => wf.GetAnimatedBeWoWindow("AiPromptbausteinSelection", ctrl, 400, 600),
|
|
viewModel);
|
|
}
|
|
|
|
public void ShowERechnungWindow(MemoryStream pdf)
|
|
{
|
|
ShowWindowDialog(
|
|
cf => cf.GetPdfViewer(pdf),
|
|
(wf, ctrl) => wf.GetAnimatedBeWoWindow("E-Rechnung", ctrl));
|
|
}
|
|
|
|
public void ShowERechnungModalViewWindow(MemoryStream pdf)
|
|
{
|
|
ShowModalViewWindow(
|
|
cf => cf.GetPdfViewer(pdf),
|
|
(wf, ctrl) => wf.GetAnimatedBeWoWindow("E-Rechnung", ctrl));
|
|
}
|
|
|
|
public void ShowTextViewerWindow(string title, string text)
|
|
{
|
|
ShowWindowDialog(
|
|
cf => cf.GetTextViewer(text),
|
|
(wf, ctrl) => wf.GetAnimatedBeWoWindow(title, ctrl));
|
|
}
|
|
|
|
public void ShowPdfViewerWindow(string title, MemoryStream pdf)
|
|
{
|
|
ShowWindowDialog(
|
|
cf => cf.GetPdfViewer(pdf),
|
|
(wf, ctrl) => wf.GetAnimatedBeWoWindow(title, ctrl));
|
|
}
|
|
|
|
public void ShowPdfViewerModalViewWindow(string title, MemoryStream pdf)
|
|
{
|
|
ShowModalViewWindow(
|
|
cf => cf.GetPdfViewer(pdf),
|
|
(wf, ctrl) => wf.GetAnimatedBeWoWindow(title, ctrl));
|
|
}
|
|
|
|
public void ShowGkvAbrechnungDetailWindow(GkvAbrechnungDialogViewModel vm)
|
|
{
|
|
// Kleiner Hack
|
|
// - Ggf WindowFactory kapselt Zuorgnudn von Control zu Window
|
|
var title = _windowFactory.GetGkvTitle(vm.Abrechnung);
|
|
var control = _controlFactory.GetGkvAbrechnungDetailControl(vm.Abrechnung);
|
|
var window = _windowFactory.GetAnimatedBeWoWindow(title, control, 900, 600);
|
|
window.ShowDialog();
|
|
}
|
|
|
|
//private void ShowWindow(string title, Func<IControlFactory, Control> getControl, double? height = null, double? width = null)
|
|
//{
|
|
// // Problem mit dem Warte Fenster
|
|
// throw new NotImplementedException();
|
|
|
|
// var control = getControl(_controlFactory);
|
|
// var window = _windowFactory.GetAnimatedBeWoWindow(title, control, height, width);
|
|
// window.Show();
|
|
//}
|
|
|
|
private void ShowDialog(Func<IControlFactory, Control> getControl, Func<IWindowFactory, Control, Window> getWindow, BaseDialogViewModel dialogViewModel)
|
|
{
|
|
var control = getControl(_controlFactory);
|
|
var window = getWindow(_windowFactory, control);
|
|
if (dialogViewModel != null)
|
|
{
|
|
dialogViewModel.RequestClose += (s, e) => window.Close();
|
|
}
|
|
window.ShowDialog();
|
|
}
|
|
|
|
private void ShowWindowDialog(Func<IControlFactory, Control> getControl, Func<IWindowFactory, Control, Window> getWindow)
|
|
{
|
|
var control = getControl(_controlFactory);
|
|
var window = getWindow(_windowFactory, control);
|
|
var test = window.ShowDialog();
|
|
}
|
|
|
|
private void ShowModalViewWindow(Func<IControlFactory, Control> getControl, Func<IWindowFactory, Control, Control> getPopup)
|
|
{
|
|
var control = getControl(_controlFactory);
|
|
var window = getPopup(_windowFactory, control);
|
|
window.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => BeWoApp.MainControl.CloseCurrentPopUp()));
|
|
BeWoApp.MainControl.ShowControlAsModalPopup(window);
|
|
}
|
|
}
|
|
}
|