59
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
1 using System;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
2 using System.ComponentModel;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
3 using System.Linq;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
4 using System.Windows;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
5 using System.Windows.Input;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
6 using FluentValidation;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
7 using SilverlightValidation.Interfaces;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
8 using SilverlightValidation.Validators;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
9 using SilverlightValidation.Models;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
10 using SilverlightValidation.Commands;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
11
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
12 namespace SilverlightValidation.ViewModels
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
13 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
14 public class UserViewModel : ViewModelBase, IUserModel, IChangeTracking, IEditableObject
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
15 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
16 #region Fields
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
17
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
18 private readonly UserModelValidator _validator;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
19 private UserModel _data;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
20 private UserModel _backup;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
21
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
22 #endregion
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
23
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
24 #region Constructor
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
25
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
26 public UserViewModel(UserModel model, UserModelValidator validator)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
27 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
28 _validator = validator;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
29 _data = model;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
30 _backup = model.Clone();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
31
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
32 OkCommand = new RelayCommand(OkCommandExecute);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
33 CancelCommand = new RelayCommand(CancelCommandExecute);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
34 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
35
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
36 #endregion
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
37
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
38 #region Methods
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
39
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
40 private void SetProperties(IUserModel source)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
41 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
42 Username = source.Username;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
43 Password = source.Password;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
44 Email = source.Email;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
45 DateOfBirth = source.DateOfBirth;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
46 Description = source.Description;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
47 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
48
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
49 #endregion
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
50
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
51 #region Properties
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
52
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
53 private const string UsernameProperty = "Username";
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
54 public string Username
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
55 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
56 get { return _data.Username; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
57 set
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
58 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
59 if (_data.Username != value)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
60 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
61 _data.Username = value;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
62 RaisePropertyChanged(UsernameProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
63 IsChanged = true;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
64 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
65
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
66 ClearError(UsernameProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
67 var validationResult = _validator.Validate(this, UsernameProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
68 if (!validationResult.IsValid)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
69 validationResult.Errors.ToList().ForEach(x => SetError(UsernameProperty, x.ErrorMessage));
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
70 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
71 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
72
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
73 private const string PasswordProperty = "Password";
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
74 public string Password
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
75 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
76 get { return _data.Password; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
77 set
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
78 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
79 if (_data.Password != value)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
80 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
81 _data.Password = value;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
82 RaisePropertyChanged(PasswordProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
83 IsChanged = true;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
84 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
85
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
86 ClearError(PasswordProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
87 var validationResult = _validator.Validate(this, PasswordProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
88 if (!validationResult.IsValid)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
89 validationResult.Errors.ToList().ForEach(x => SetError(PasswordProperty, x.ErrorMessage));
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
90 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
91 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
92
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
93 private const string EmailProperty = "Email";
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
94 public string Email
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
95 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
96 get { return _data.Email; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
97 set
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
98 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
99 if (_data.Email != value)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
100 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
101 _data.Email = value;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
102 RaisePropertyChanged(EmailProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
103 IsChanged = true;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
104 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
105
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
106 ClearError(EmailProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
107 var validationResult = _validator.Validate(this, EmailProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
108 if (!validationResult.IsValid)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
109 validationResult.Errors.ToList().ForEach(x => SetError(EmailProperty, x.ErrorMessage));
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
110 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
111 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
112
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
113 private const string DateOfBirthProperty = "DateOfBirth";
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
114 public DateTime? DateOfBirth
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
115 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
116 get { return _data.DateOfBirth; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
117 set
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
118 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
119 if (_data.DateOfBirth != value)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
120 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
121 _data.DateOfBirth = value;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
122 RaisePropertyChanged(DateOfBirthProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
123 IsChanged = true;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
124 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
125
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
126 ClearError(DateOfBirthProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
127 var validationResult = _validator.Validate(this, DateOfBirthProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
128 if (!validationResult.IsValid)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
129 validationResult.Errors.ToList().ForEach(x => SetError(DateOfBirthProperty, x.ErrorMessage));
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
130 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
131 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
132
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
133 private const string DescriptionProperty = "Description";
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
134 public string Description
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
135 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
136 get { return _data.Description; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
137 set
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
138 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
139 if (_data.Description != value)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
140 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
141 _data.Description = value;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
142 RaisePropertyChanged(DescriptionProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
143 IsChanged = true;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
144 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
145
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
146 ClearError(DescriptionProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
147 var validationResult = _validator.Validate(this, DescriptionProperty);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
148 if (!validationResult.IsValid)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
149 validationResult.Errors.ToList().ForEach(x => SetError(DescriptionProperty, x.ErrorMessage));
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
150 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
151 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
152
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
153 #endregion
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
154
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
155 #region Commands
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
156
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
157 public ICommand OkCommand { get; set; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
158 public ICommand CancelCommand { get; set; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
159
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
160 private void OkCommandExecute(object obj)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
161 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
162 SetProperties(_data);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
163
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
164 if (IsChanged && !HasErrors)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
165 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
166 AcceptChanges();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
167 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
168 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
169
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
170 private void CancelCommandExecute(object obj)
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
171 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
172 CancelChanges();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
173 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
174
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
175 #endregion
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
176
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
177 #region IChangeTrack plus Cancel
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
178
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
179 public void AcceptChanges()
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
180 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
181 MessageBox.Show("Saving...");
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
182 SetProperties(_backup);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
183
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
184 ClearAllErrors();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
185 IsChanged = false;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
186 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
187
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
188 public void CancelChanges()
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
189 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
190 if (!IsChanged) return;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
191 SetProperties(_backup);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
192 ClearAllErrors();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
193 IsChanged = false;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
194 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
195
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
196 public bool IsChanged { get; private set; }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
197
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
198 #endregion
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
199
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
200 #region
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
201
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
202 private bool inEdit;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
203 public void BeginEdit()
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
204 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
205 if (inEdit) return;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
206 inEdit = true;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
207 SetProperties(_backup);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
208 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
209
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
210 public void CancelEdit()
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
211 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
212 if (!inEdit) return;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
213 inEdit = false;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
214 CancelChanges();
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
215 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
216
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
217 public void EndEdit()
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
218 {
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
219 if (!inEdit) return;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
220 inEdit = false;
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
221 SetProperties(_backup);
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
222 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
223
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
224 #endregion
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
225
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
226 }
|
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff
changeset
|
227 }
|