PageRenderTime 15ms CodeModel.GetById 11ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/V4/MVVM RI/MVVM.Client/ViewModels/QuestionViewModel.cs

#
C# | 59 lines | 33 code | 7 blank | 19 comment | 2 complexity | abd3c2aee14cd41cc122db8ce771d626 MD5 | raw file
 1//===================================================================================
 2// Microsoft patterns & practices
 3// Composite Application Guidance for Windows Presentation Foundation and Silverlight
 4//===================================================================================
 5// Copyright (c) Microsoft Corporation.  All rights reserved.
 6// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
 7// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
 8// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 9// FITNESS FOR A PARTICULAR PURPOSE.
10//===================================================================================
11// The example companies, organizations, products, domain names,
12// e-mail addresses, logos, people, places, and events depicted
13// herein are fictitious.  No association with any real company,
14// organization, product, domain name, email address, logo, person,
15// places, or events is intended or should be inferred.
16//===================================================================================
17using System;
18using Microsoft.Practices.Prism.ViewModel;
19
20namespace MVVM.Client.ViewModels
21{
22    /// <summary>
23    /// View model for a question.
24    /// </summary>
25    public abstract class QuestionViewModel : NotificationObject
26    {
27        private bool hasChanges;
28
29        protected QuestionViewModel()
30        {
31        }
32
33        public event EventHandler<EventArgs> ResponseChanged;
34
35        public bool HasChanges
36        {
37            get
38            {
39                return this.hasChanges;
40            }
41        }
42
43        public abstract bool ResponseComplete { get; }
44
45        protected void OnResponseChanged()
46        {
47            var handler = this.ResponseChanged;
48            if (handler != null)
49            {
50                handler(this, EventArgs.Empty);
51            }
52        }
53
54        protected void SetHasChanges()
55        {
56            this.hasChanges = true;
57        }
58    }
59}