-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathHostModel.cs
144 lines (133 loc) · 3.3 KB
/
HostModel.cs
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
using System.ComponentModel;
using System.Windows;
namespace _007_Host_Mapping
{
public class HostModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
#region index
private int _index;
public int Index
{
get { return _index; }
set
{
if (_index != value)
{
_index = value;
NotifyPropertyChanged("Index");
}
}
}
#endregion
#region enable
private bool _enable;
public bool Enable
{
get { return _enable; }
set
{
if (_enable != value)
{
_enable = value;
NotifyPropertyChanged("CheckShow");
NotifyPropertyChanged("CheckHide");
}
}
}
public Visibility CheckShow
{
get
{
return _enable ? Visibility.Visible : Visibility.Collapsed;
}
}
public Visibility CheckHide
{
get
{
return _enable ? Visibility.Collapsed : Visibility.Visible;
}
}
#endregion
#region ip and port
private string _ip;
public string IP
{
get { return _ip; }
set
{
if (_ip != value)
{
_ip = value;
NotifyPropertyChanged("IpAndPort");
}
}
}
private string _port;
public string Port
{
get { return _port; }
set
{
if (_port != value)
{
_port = value;
NotifyPropertyChanged("IpAndPort");
}
}
}
public string IpAndPort
{
get
{
if (_port.Length <= 0)
{
return "IP / " + _ip;
}
else
{
return "IP / " + _ip + ":" + _port;
}
}
}
#endregion
#region url
private string _url;
public string Url
{
get { return _url; }
set
{
if (_url != value)
{
_url = value;
NotifyPropertyChanged("TipsAndUrl");
}
}
}
public string TipsAndUrl
{
get { return "URL / " + _url; }
}
#endregion
public HostModel(int index, bool enable, string ip, string port, string url)
{
_index = index;
_enable = enable;
_ip = ip;
_port = port;
_url = url;
}
#region 通知UI更新数据
protected void NotifyPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
}
}