1
0
mirror of synced 2024-11-14 17:33:49 +00:00
PettingZoo/ViewModel/ConnectionViewModel.cs
PsychoMark ccfde19d2d Changed Model namespace to Connection, moved bits out to Infrastructure
Added Mock connection
Fixed AutoScroll failing with high rate message flow
2016-07-12 16:57:24 +02:00

65 lines
1.5 KiB
C#

using System;
using System.Windows.Input;
using AutoMapper;
using PettingZoo.Connection;
using PettingZoo.Infrastructure;
namespace PettingZoo.ViewModel
{
public class ConnectionViewModel : BaseViewModel
{
private static readonly IMapper ModelMapper = new MapperConfiguration(cfg =>
cfg.CreateMap<ConnectionInfo, ConnectionViewModel>().ReverseMap()
).CreateMapper();
private readonly DelegateCommand okCommand;
public string Host { get; set; }
public string VirtualHost { get; set; }
public int Port { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Exchange { get; set; }
public string RoutingKey { get; set; }
public ICommand OkCommand { get { return okCommand; } }
public event EventHandler CloseWindow;
public ConnectionViewModel()
{
okCommand = new DelegateCommand(OkExecute, OkCanExecute);
}
public ConnectionViewModel(ConnectionInfo model) : this()
{
ModelMapper.Map(model, this);
}
public ConnectionInfo ToModel()
{
return ModelMapper.Map<ConnectionInfo>(this);
}
private void OkExecute()
{
if (CloseWindow != null)
CloseWindow(this, EventArgs.Empty);
}
private bool OkCanExecute()
{
return true;
}
}
}