2016-06-18 14:50:32 +00:00
|
|
|
|
using System.Windows;
|
|
|
|
|
using PettingZoo.Model;
|
|
|
|
|
using PettingZoo.ViewModel;
|
|
|
|
|
|
|
|
|
|
namespace PettingZoo.View
|
|
|
|
|
{
|
|
|
|
|
public class WindowConnectionInfoBuilder : IConnectionInfoBuilder
|
|
|
|
|
{
|
|
|
|
|
public ConnectionInfo Build()
|
|
|
|
|
{
|
2016-06-20 10:30:03 +00:00
|
|
|
|
var viewModel = new ConnectionViewModel(ConnectionInfo.Default());
|
|
|
|
|
|
2016-06-18 14:50:32 +00:00
|
|
|
|
var dialog = new ConnectionWindow(viewModel)
|
|
|
|
|
{
|
|
|
|
|
Owner = Application.Current.MainWindow
|
|
|
|
|
};
|
|
|
|
|
|
2016-06-20 10:30:03 +00:00
|
|
|
|
viewModel.CloseWindow += (sender, args) =>
|
|
|
|
|
{
|
|
|
|
|
dialog.DialogResult = true;
|
|
|
|
|
};
|
2016-06-18 14:50:32 +00:00
|
|
|
|
|
2016-06-20 10:30:03 +00:00
|
|
|
|
return dialog.ShowDialog().GetValueOrDefault() ? viewModel.ToModel() : null;
|
2016-06-18 14:50:32 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-06-20 12:20:37 +00:00
|
|
|
|
public partial class ConnectionWindow
|
2016-06-18 14:50:32 +00:00
|
|
|
|
{
|
2016-06-18 18:30:12 +00:00
|
|
|
|
public ConnectionWindow(ConnectionViewModel viewModel)
|
2016-06-18 14:50:32 +00:00
|
|
|
|
{
|
2016-06-18 18:30:12 +00:00
|
|
|
|
WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
|
|
|
|
|
2016-06-18 14:50:32 +00:00
|
|
|
|
InitializeComponent();
|
|
|
|
|
DataContext = viewModel;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|