Mercurial > silverbladetech
diff Messaging/Server/UI/MainWindowViewModel.cs @ 31:7d9de5746f18
Working version
author | adminsh@apollo |
---|---|
date | Thu, 22 Mar 2012 08:09:41 +0000 |
parents | 9919ee227c93 |
children | 874e51b94623 |
line wrap: on
line diff
--- a/Messaging/Server/UI/MainWindowViewModel.cs Wed Mar 21 22:26:48 2012 +0000 +++ b/Messaging/Server/UI/MainWindowViewModel.cs Thu Mar 22 08:09:41 2012 +0000 @@ -1,12 +1,11 @@ using System.Windows.Input; using Common; -using Common.Logger; using Common.Messages; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using System.Windows; +using GalaSoft.MvvmLight.Messaging; using Server.EndPoints; -using Server.Interfaces; using Server.Listeners; namespace Server.UI @@ -25,9 +24,13 @@ set { if (_overrideSwitch == value) return; - var oldValue = _overrideSwitch; _overrideSwitch = value; - RaisePropertyChanged(() => OverrideSwitch, oldValue, value, false); + RaisePropertyChanged(() => OverrideSwitch); + if (OverrideSwitch == null) return; + + Messenger.Default.Send((bool) OverrideSwitch + ? new OverrideSwitchMessage() {Switch = Switch.On} + : new OverrideSwitchMessage() {Switch = Switch.Off}); } } @@ -38,18 +41,16 @@ public ICommand CloseCommand { get; set; } public MessageEndPoint<MsmqClientMessage, MsmqLogMessage> MsmqEndPoint { get; set; } - public MessageEndPoint<SocketClientMessage, SocketLogMessage> SocketEndPoint { get; set; } public MessageEndPoint<RabbitClientMessage, RabbitLogMessage> RabbitEndPoint { get; set; } - public MessageEndPoint<RabbitProtoClientMessage, RabbitProtoLogMessage> RabbitProtoEndPoint { get; set; } + public MessageEndPoint<ZeroMqClientMessage, ZeroMqLogMessage> ZeroMqEndPoint { get; set; } #region Constructor public MainWindowViewModel() { InitMsmqEndPoint(Settings.MsmqQueueName); - //InitSocketEndPoint(Settings.SocketsPortNumber); InitRabbitEndPoint(Settings.RabbitPortNumber, Settings.RabbitQueueName); - InitRabbitProtoEndPoint(Settings.RabbitProtoPortNumber); + InitZeroMqEndPoint(Settings.ZeroMqAddress); CloseCommand = new RelayCommand(CloseCommandExecute); } @@ -66,40 +67,29 @@ }; } - private void InitSocketEndPoint(int port) - { - IListener listener = new AsyncSocketListener(port); - SocketEndPoint = new MessageEndPoint<SocketClientMessage, SocketLogMessage>(listener) - { - DisplayText = "Async Sockets", - ToolTip = "Listening over TCP/IP on socket localhost:" + port - }; - } - private void InitRabbitEndPoint(int port, string queueName) { IListener listener = new RabbitQueueListener(port, queueName); RabbitEndPoint = new MessageEndPoint<RabbitClientMessage, RabbitLogMessage>(listener) { DisplayText = "RabbitMQ", - ToolTip = "Listening..." + port + ToolTip = string.Format("Listening on port {0} to queue {1} and binding it to amq.direct", port, queueName) }; } - private void InitRabbitProtoEndPoint(int port) + private void InitZeroMqEndPoint(string address) { - IListener listener = null; - RabbitProtoEndPoint = new MessageEndPoint<RabbitProtoClientMessage, RabbitProtoLogMessage>(listener) + IListener listener = new ZeroMqListener(address); + ZeroMqEndPoint = new MessageEndPoint<ZeroMqClientMessage, ZeroMqLogMessage>(listener) { - DisplayText = "RabbitMQ with Protobuf-net", - ToolTip = "Listening...." + port + DisplayText = "ZeroMq", + ToolTip = "Listening on " + address }; } private void CloseCommandExecute() { - Log.Write("Closing command executed"); Application.Current.Shutdown(); } } -} +} \ No newline at end of file