27
|
1 using System;
|
|
2 using System.Windows.Input;
|
26
|
3 using Common;
|
|
4 using Common.Logger;
|
27
|
5 using Common.Messages;
|
26
|
6 using GalaSoft.MvvmLight;
|
|
7 using GalaSoft.MvvmLight.Command;
|
|
8 using System.Windows;
|
27
|
9 using GalaSoft.MvvmLight.Messaging;
|
|
10 using Server.EndPoints;
|
26
|
11 using Server.Interfaces;
|
27
|
12 using Server.Listeners;
|
26
|
13
|
|
14 namespace Server.UI
|
|
15 {
|
|
16 public class MainWindowViewModel : ViewModelBase
|
|
17 {
|
|
18 #region Properties
|
|
19
|
|
20 #region OverrideSwitch
|
|
21
|
|
22 public const string OverrideSwitchPropertyName = "OverrideSwitch";
|
|
23 private bool? _overrideSwitch = false;
|
|
24 public bool? OverrideSwitch
|
|
25 {
|
|
26 get { return _overrideSwitch; }
|
|
27 set
|
|
28 {
|
|
29 if (_overrideSwitch == value) return;
|
|
30 var oldValue = _overrideSwitch;
|
|
31 _overrideSwitch = value;
|
|
32 RaisePropertyChanged(() => OverrideSwitch, oldValue, value, false);
|
|
33 }
|
|
34 }
|
|
35
|
|
36 #endregion
|
|
37
|
|
38 #endregion
|
|
39
|
|
40 public ICommand CloseCommand { get; set; }
|
|
41
|
27
|
42 public BaseEndPoint SocketEndPoint { get; set; }
|
|
43 public BaseEndPoint RabbitEndPoint { get; set; }
|
|
44 public BaseEndPoint RabbitProtoEndPoint { get; set; }
|
26
|
45
|
|
46 #region Constructor
|
|
47
|
|
48 public MainWindowViewModel()
|
|
49 {
|
27
|
50 InitSocketEndPoint(Settings.SocketsPortNumber);
|
|
51 InitRabbitEndPoint(Settings.RabbitPortNumber);
|
|
52 InitRabbitProtoEndPoint(Settings.RabbitProtoPortNumber);
|
26
|
53
|
|
54 CloseCommand = new RelayCommand(CloseCommandExecute);
|
27
|
55
|
|
56 }
|
|
57
|
|
58 private void InitSocketEndPoint(int port)
|
|
59 {
|
|
60 IListener listener = new AsyncSocketListener(port);
|
|
61 SocketEndPoint = new SocketEndPoint(listener)
|
|
62 {
|
|
63 DisplayText = "Async Sockets",
|
|
64 ToolTip = "Listening over TCP/IP on socket localhost:" + port
|
|
65 };
|
26
|
66 }
|
|
67
|
27
|
68 private void InitRabbitEndPoint(int port)
|
|
69 {
|
|
70 IListener listener = new RabbitQueueListener(port);
|
|
71 RabbitEndPoint = new RabbitEndPoint(listener)
|
|
72 {
|
|
73 DisplayText = "RabbitMQ",
|
|
74 ToolTip = "Listening..." + port
|
|
75 };
|
|
76 }
|
|
77
|
|
78 private void InitRabbitProtoEndPoint(int port)
|
|
79 {
|
|
80 IListener listener = null;
|
|
81 RabbitProtoEndPoint = new RabbitProtoEndPoint(listener)
|
|
82 {
|
|
83 DisplayText = "RabbitMQ with Protobuf-net",
|
|
84 ToolTip = "Listening...." + port
|
|
85 };
|
|
86 }
|
26
|
87 private void CloseCommandExecute()
|
|
88 {
|
|
89 Log.Write("Closing command executed");
|
|
90 Application.Current.Shutdown();
|
|
91 }
|
|
92
|
|
93 #endregion
|
|
94 }
|
|
95 }
|