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