-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatModel.cs
More file actions
113 lines (104 loc) · 3 KB
/
ChatModel.cs
File metadata and controls
113 lines (104 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// **********************************************************************
//
// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
//
// **********************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
namespace ChatDemoGUI
{
public class ChatModel : INotifyPropertyChanged
{
public ChatModel()
{
_state = Coordinator.ClientState.Disconnected;
_currentFrame = "LoginView.xaml";
_loginInfo = new LoginInfo();
_loginInfo.load();
}
//
// This property stores the visible frame inside the
// MainView. This can be LoginView.xaml or ChatView.xaml.
//
public string CurrentFrame
{
get
{
return _currentFrame;
}
set
{
if(value != _currentFrame)
{
_currentFrame = value;
OnPropertyChanged(new PropertyChangedEventArgs("CurrentFrame"));
}
}
}
public Coordinator.ClientState State
{
get
{
return _state;
}
set
{
if(_state != value)
{
_state = value;
if(_state == Coordinator.ClientState.Disconnected)
{
CurrentFrame = "LoginView.xaml";
}
else if(_state == Coordinator.ClientState.Connected)
{
CurrentFrame = "ChatView.xaml";
}
OnPropertyChanged(new PropertyChangedEventArgs("State"));
}
}
}
//
// Property to store information needed for login.
//
public LoginInfo LoginData
{
get
{
return _loginInfo;
}
}
//
// This property stores whether the UI should show advanced options.
//
public bool ShowAdvanced
{
get
{
return _showAdvanced;
}
set
{
_showAdvanced = value;
OnPropertyChanged(new PropertyChangedEventArgs("ShowAdvanced"));
}
}
#region INotifyPropertyChanged Members
protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
{
if(PropertyChanged != null)
{
PropertyChanged(this, args);
}
}
public event PropertyChangedEventHandler PropertyChanged;
#endregion
private Coordinator.ClientState _state = Coordinator.ClientState.Disconnected;
private string _currentFrame;
private LoginInfo _loginInfo = null;
private bool _showAdvanced = false;
}
}