comparison Tools/DocGen/Content/Doc/EditableObjects/ManualEditableObject.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 public class TestObject : INotifyPropertyChanged
2 {
3 // The FirstName editable property.
4 //
5 private string _originalFirstName;
6 private string _currentFirstName;
7
8 public override string FirstName
9 {
10 get { return _currentFirstName; }
11 set
12 {
13 _currentFirstName = value;
14 OnPropertyChanged("FirstName");
15 }
16 }
17
18 bool IsFirstNameDirty
19 {
20 get { return _currentFirstName != _originalFirstName; }
21 }
22
23 void AcceptFirstNameChange()
24 {
25 if (IsFirstNameDirty)
26 {
27 _originalFirstName = _currentFirstName;
28 OnPropertyChanged("FirstName");
29 }
30 }
31
32 void RejectFirstNameChange()
33 {
34 if (IsFirstNameDirty)
35 {
36 _currentFirstName = _originalFirstName;
37 OnPropertyChanged("FirstName");
38 }
39 }
40
41 // The LastName editable property.
42 //
43 private string _originalLastName;
44 private string _currentLastName;
45
46 public override string LastName
47 {
48 get { return _currentLastName; }
49 set
50 {
51 _currentLastName = value;
52 OnPropertyChanged("LastName");
53 }
54 }
55
56 bool IsLastNameDirty
57 {
58 get { return _currentLastName != _originalLastName; }
59 }
60
61 void AcceptLastNameChange()
62 {
63 if (IsLastNameDirty)
64 {
65 _originalLastName = _currentLastName;
66 OnPropertyChanged("LastName");
67 }
68 }
69
70 void RejectLastNameChange()
71 {
72 if (IsLastNameDirty)
73 {
74 _currentLastName = _originalLastName;
75 OnPropertyChanged("LastName");
76 }
77 }
78
79 // Common members.
80 //
81 public bool IsDirty
82 {
83 get
84 {
85 return IsFirstNameChange || IsLastNameChange;
86 }
87 }
88
89 public void AcceptChanges()
90 {
91 AcceptFirstNameChange();
92 AcceptLastNameChange();
93 }
94
95 public void RejectChanges()
96 {
97 RejectFirstNameChange();
98 RejectLastNameChange();
99 }
100
101 public virtual event PropertyChangedEventHandler PropertyChanged;
102
103 protected virtual void OnPropertyChanged(string propertyName)
104 {
105 if (PropertyChanged != null)
106 PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
107 }
108 }