Restructured the VM/Vs folder layout while it's still feasible

This commit is contained in:
Robert committed 2019-11-15 15:53:55 +01:00
1 parent 7443c0eda7
commit 368b73ce9c
48 files changed
+397 -469

No files matched your search

@@ -0,0 +1,71 @@
using System.Threading.Tasks;
using Artemis.UI.Screens.Dialogs;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.ViewModels.Dialogs;
using MaterialDesignThemes.Wpf;
using Ninject;
using Ninject.Parameters;
using Stylet;
namespace Artemis.UI.Services
{
public class DialogService : IDialogService
{
private readonly IKernel _kernel;
private readonly IViewManager _viewManager;
public DialogService(IKernel kernel, IViewManager viewManager)
{
_kernel = kernel;
_viewManager = viewManager;
}
public async Task<bool> ShowConfirmDialog(string header, string text, string confirmText = "Confirm", string cancelText = "Cancel")
{
var arguments = new IParameter[]
{
new ConstructorArgument("header", header),
new ConstructorArgument("text", text),
new ConstructorArgument("confirmText", confirmText),
new ConstructorArgument("cancelText", cancelText)
};
var result = await ShowDialog<ConfirmDialogViewModel>(arguments);
return (bool) result;
}
public async Task<bool> ShowConfirmDialogAt(string identifier, string header, string text, string confirmText = "Confirm", string cancelText = "Cancel")
{
var arguments = new IParameter[]
{
new ConstructorArgument("header", header),
new ConstructorArgument("text", text),
new ConstructorArgument("confirmText", confirmText),
new ConstructorArgument("cancelText", cancelText)
};
var result = await ShowDialogAt<ConfirmDialogViewModel>(identifier, arguments);
return (bool) result;
}
public async Task<object> ShowDialog<T>(IParameter[] parameters = null) where T : DialogViewModelBase
{
var viewModel = parameters != null ? _kernel.Get<T>(parameters) : _kernel.Get<T>();
return await ShowDialog(null, viewModel);
}
public async Task<object> ShowDialogAt<T>(string identifier, IParameter[] parameters = null) where T : DialogViewModelBase
{
var viewModel = parameters != null ? _kernel.Get<T>(parameters) : _kernel.Get<T>();
return await ShowDialog(identifier, viewModel);
}
private async Task<object> ShowDialog(string identifier, DialogViewModelBase viewModel)
{
var view = _viewManager.CreateViewForModel(viewModel);
_viewManager.BindViewToModel(view, viewModel);
if (identifier == null)
return await DialogHost.Show(view, viewModel.OnDialogClosed);
return await DialogHost.Show(view, identifier, viewModel.OnDialogOpened, viewModel.OnDialogClosed);
}
}
}