annotate Messaging/Server/UI/MainWindowViewModel.cs @ 26:045dac571339

Working on data binding to a user control
author adminsh@apollo
date Wed, 21 Mar 2012 15:39:53 +0000
parents
children 96fdf58e05b4
rev   line source
26
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
1 using System.Windows.Input;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
2 using Common;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
3 using Common.Logger;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
4 using GalaSoft.MvvmLight;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
5 using GalaSoft.MvvmLight.Command;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
6 using System.Windows;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
7 using Server.Interfaces;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
8 using Server.Sockets;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
9
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
10 namespace Server.UI
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
11 {
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
12 public class MainWindowViewModel : ViewModelBase
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
13 {
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
14 #region Properties
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
15
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
16 #region OverrideSwitch
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
17
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
18 public const string OverrideSwitchPropertyName = "OverrideSwitch";
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
19 private bool? _overrideSwitch = false;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
20 public bool? OverrideSwitch
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
21 {
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
22 get { return _overrideSwitch; }
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
23 set
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
24 {
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
25 if (_overrideSwitch == value) return;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
26 var oldValue = _overrideSwitch;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
27 _overrideSwitch = value;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
28 RaisePropertyChanged(() => OverrideSwitch, oldValue, value, false);
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
29 }
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
30 }
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
31
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
32 #endregion
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
33
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
34 #endregion
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
35
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
36
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
37 #region DisplayText
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
38
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
39 public const string DisplayTextPropertyName = "DisplayText";
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
40 private string _displayText;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
41 public string DisplayText
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
42 {
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
43 get { return _displayText; }
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
44 set
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
45 {
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
46 if (_displayText == value) return;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
47 _displayText = value;
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
48 RaisePropertyChanged(() => DisplayText);
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
49 }
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
50 }
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
51
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
52 #endregion
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
53
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
54 public ICommand CloseCommand { get; set; }
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
55
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
56 public MessagingEndPoint SocketEndPoint { get; set; }
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
57 public MessagingEndPoint RabbitEndPoint { get; set; }
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
58 public MessagingEndPoint RabbitProtoEndPoint { get; set; }
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
59
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
60 #region Constructor
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
61
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
62 public MainWindowViewModel()
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
63 {
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
64 IListener listener = new AsyncSocketListener(Settings.SocketsPortNumber);
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
65 SocketEndPoint = new MessagingEndPoint(listener)
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
66 {
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
67 DisplayText = "Async Sockets",
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
68 ToolTip = "Listening over TCP/IP on localhost:" + Settings.SocketsPortNumber,
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
69 DisplayCount = 9,
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
70 DisplayLog = "test for display log"
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
71 };
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
72
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
73 DisplayText = "Does this work?!";
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
74
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
75 CloseCommand = new RelayCommand(CloseCommandExecute);
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
76 }
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
77
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
78 private void CloseCommandExecute()
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
79 {
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
80 Log.Write("Closing command executed");
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
81 Application.Current.Shutdown();
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
82 }
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
83
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
84 #endregion
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
85 }
045dac571339 Working on data binding to a user control
adminsh@apollo
parents:
diff changeset
86 }