Cosmos/source/Cosmos.Build.Builder/Services/DialogService.cs
José Pedro f969601a53
Builder improvements.
- Added check for dependencies, which can be installed from the builder.
- Replaced CosmosTask with CosmosBuildDefinition, which is much simpler.
- The builder can be opened without any command line arguments.
- If the VS path is not specified as a command line argument, it can be selected in a dialog.
2018-03-30 19:44:19 +01:00

35 lines
864 B
C#

using System;
using System.Windows;
namespace Cosmos.Build.Builder.Services
{
internal class DialogService<TView, TViewModel> : IDialogService<TViewModel> where TView : Window
{
private Func<TView> _dialogFactory;
private Window _owner;
public DialogService(Func<TView> dialogFactory, Window owner = null)
{
_dialogFactory = dialogFactory;
_owner = owner;
}
public bool? ShowDialog(TViewModel viewModel)
{
var dialog = _dialogFactory?.Invoke();
if (dialog != null)
{
if (_owner != null)
{
dialog.Owner = _owner;
}
dialog.DataContext = viewModel;
return dialog.ShowDialog();
}
return null;
}
}
}