-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUser.cs
64 lines (63 loc) · 2.24 KB
/
User.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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace software_application_24point
{
class UsersCollection//ObservableCollection集合类,用于未来添加多用户显示功能时实时反馈用户数据变化
{
public static ObservableCollection<User> Users = new ObservableCollection<User>();//ObservableCollection将在集合内容变化时提供反馈
}
class User : INotifyPropertyChanged//INotifyPropertyChanged接口用于通知绑定控件绑定数值发生变化
{
public event PropertyChangedEventHandler PropertyChanged;//declare the interface
private int wintimes;//means the number of this user's total winning times
private string name;//user name
private int losetimes;//number of total losing
public int Losetimes//define a property to represent losetimes
{
get { return losetimes; }//get property value
set
{
losetimes = value;
if (this.PropertyChanged != null)//define PropertyChangedEventHandler interface
{
PropertyChanged(this, new PropertyChangedEventArgs("Losetimes"));//PropertyChangedEventArgs will give property name
}
}
}
public int Wintimes//define a property
{
get { return wintimes; }
set
{
wintimes = value;
if (this.PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("Wintimes"));
}
}
}
public string Name
{
get { return name; }
set
{
name = value;
if (this.PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("Name"));
}
}
}
public User(int wintimes,int losetimes,string name)//constructor
{
this.wintimes = wintimes;
this.name = name;
this.losetimes = losetimes;
}
}
}