214 lines
6.1 KiB
C#
214 lines
6.1 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 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;
|
|
using BeWo.ViewModel.View;
|
|
using System.Windows.Controls.Primitives;
|
|
using static DevExpress.XtraPrinting.Native.ExportOptionsPropertiesNames;
|
|
using DevExpress.Mvvm.Native;
|
|
using BeWo.ViewModel.View.Gkv;
|
|
|
|
namespace BeWo.Services
|
|
{
|
|
public class BeWoWindowOptions
|
|
{
|
|
public bool ShowAsModal { get; set; } = false;
|
|
public bool ShowAsDialog { get; set; } = true;
|
|
|
|
public double Height { get; set; } = 600;
|
|
public double Width { get; set; } = 400;
|
|
}
|
|
|
|
public class BeWoWindowService : IBeWoWindowService
|
|
{
|
|
private readonly BeWoWindowFactory _windowFactory;
|
|
private readonly BeWoControlFactory _controlFactory;
|
|
|
|
public BeWoWindowService(BeWoWindowFactory builder, BeWoControlFactory controlFactory)
|
|
{
|
|
_windowFactory = builder;
|
|
_controlFactory = controlFactory;
|
|
}
|
|
|
|
public void Show<T>(T windowViewModel) where T : WindowViewModel
|
|
{
|
|
if(windowViewModel is AiConversationChatViewModel viewModel)
|
|
{
|
|
ShowAiConversationWindow(viewModel);
|
|
}
|
|
else if (windowViewModel is AiPromptbausteinFolderViewModel viewModel3)
|
|
{
|
|
ShowAiPromptbausteinFolderWindow(viewModel3);
|
|
}
|
|
else if(windowViewModel is AiPromptbausteinPromptViewModel viewModel4)
|
|
{
|
|
ShowAiPromptbausteinPromptWindow(viewModel4);
|
|
}
|
|
else if(windowViewModel is AiPromptbausteinActionResultViewModel viewModel5)
|
|
{
|
|
ShowAiPromptbausteinActionResultWindow(viewModel5);
|
|
}
|
|
else if(windowViewModel is AiPromptbausteinSelectionComplexViewModel viewModel6)
|
|
{
|
|
ShowAiPromptbausteinSelectionComplexWindow(viewModel6);
|
|
}
|
|
else if (windowViewModel is AiPromptbausteinRoutineViewModel viewModel7)
|
|
{
|
|
ShowAiPromptbausteinRoutineWindow(viewModel7);
|
|
}
|
|
else
|
|
{
|
|
throw new NotImplementedException($"type not implemented: {typeof(T)}");
|
|
}
|
|
}
|
|
|
|
public void ShowAiConversationWindow(AiConversationChatViewModel viewModel)
|
|
{
|
|
var control = _controlFactory.GetAiConversationControl(viewModel);
|
|
var title = _windowFactory.GetAiTitle(viewModel.ActionType);
|
|
var options = new BeWoWindowOptions()
|
|
{
|
|
Height = 600,
|
|
Width = 1200
|
|
};
|
|
Show(title, control, viewModel, options);
|
|
}
|
|
public void ShowAiPromptbausteinFolderWindow(AiPromptbausteinFolderViewModel viewModel)
|
|
{
|
|
var control = new AiPromptbausteinFolderView(viewModel);
|
|
var options = new BeWoWindowOptions()
|
|
{
|
|
Height = 400,
|
|
Width = 600
|
|
};
|
|
Show("KI Promptbaustein Ordner", control, viewModel, options);
|
|
}
|
|
public void ShowAiPromptbausteinPromptWindow(AiPromptbausteinPromptViewModel viewModel)
|
|
{
|
|
var control = new AiPromptbausteinPromptView(viewModel);
|
|
var options = new BeWoWindowOptions()
|
|
{
|
|
Height = 400,
|
|
Width = 600
|
|
};
|
|
Show("KI Promptbaustein Prompt", control, viewModel, options);
|
|
}
|
|
public void ShowAiPromptbausteinRoutineWindow(AiPromptbausteinRoutineViewModel viewModel)
|
|
{
|
|
var control = new AiPromptbausteinRoutineView(viewModel);
|
|
var options = new BeWoWindowOptions()
|
|
{
|
|
Height = 400,
|
|
Width = 600
|
|
};
|
|
Show("KI Promptbaustein Routine", control, viewModel, options);
|
|
}
|
|
public void ShowAiPromptbausteinActionResultWindow(AiPromptbausteinActionResultViewModel viewModel)
|
|
{
|
|
var control = new AiPromptbausteinActionResultView(viewModel);
|
|
var options = new BeWoWindowOptions()
|
|
{
|
|
Height = 400,
|
|
Width = 600
|
|
};
|
|
Show("KI Promptbaustein Ergebnis", control, viewModel, options);
|
|
}
|
|
|
|
public void ShowAiPromptbausteinSelectionComplexWindow(AiPromptbausteinSelectionComplexViewModel viewModel)
|
|
{
|
|
var control = new AiPromptbausteinComplexSelectionView(viewModel);
|
|
var options = new BeWoWindowOptions()
|
|
{
|
|
Height = 400,
|
|
Width = 600
|
|
};
|
|
Show("KI Promptbaustein Auswahl", control, viewModel, options);
|
|
}
|
|
|
|
|
|
public void ShowGkvAbrechnungDetailWindow(GkvAbrechnungDialogViewModel vm)
|
|
{
|
|
var control = _controlFactory.GetGkvAbrechnungDetailControl(vm.Abrechnung);
|
|
var title = _windowFactory.GetGkvTitle(vm.Abrechnung);
|
|
var options = new BeWoWindowOptions()
|
|
{
|
|
Height = 900,
|
|
Width = 600
|
|
};
|
|
Show(title, control, vm, options);
|
|
}
|
|
|
|
public void ShowERechnungWindow(MemoryStream pdf)
|
|
{
|
|
var control = _controlFactory.GetPdfViewer(pdf);
|
|
var options = new BeWoWindowOptions();
|
|
Show("E-Rechnung", control, null, options);
|
|
}
|
|
|
|
public void ShowTextViewerWindow(string title, string text, BeWoWindowOptions pOptions = null)
|
|
{
|
|
if(pOptions is null)
|
|
pOptions = new BeWoWindowOptions();
|
|
|
|
var control = _controlFactory.GetTextViewer(text);
|
|
Show(title, control, null, pOptions);
|
|
}
|
|
|
|
public void ShowPdfViewerWindow(string title, MemoryStream pdf, BeWoWindowOptions pOptions = null)
|
|
{
|
|
if (pOptions is null)
|
|
pOptions = new BeWoWindowOptions();
|
|
|
|
var control = _controlFactory.GetPdfViewer(pdf);
|
|
Show(title, control, null, pOptions);
|
|
}
|
|
|
|
private void Show(string title, Control control, WindowViewModel windowViewModel, BeWoWindowOptions options)
|
|
{
|
|
if (options.ShowAsModal)
|
|
{
|
|
var modal = _windowFactory.GetModalViewWindow(title, control, options.Height, options.Width);
|
|
modal.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, (s, e) => BeWoApp.MainControl.CloseCurrentPopUp()));
|
|
BeWoApp.MainControl.ShowControlAsModalPopup(modal);
|
|
}
|
|
else
|
|
{
|
|
var window = _windowFactory.GetAnimatedBeWoWindow(title, control, options.Height, options.Width);
|
|
|
|
window.ViewModel = windowViewModel;
|
|
|
|
if (windowViewModel is DialogViewModel dialogViewModel)
|
|
{
|
|
dialogViewModel.RequestClose += (s, e) => window.Close();
|
|
}
|
|
|
|
if (options.ShowAsDialog)
|
|
{
|
|
window.ShowDialog();
|
|
}
|
|
else
|
|
{
|
|
throw new NotImplementedException();
|
|
window.Show();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|