annotate Chronosv2/source/Presentation/ViewModel/WindowViewModel.cs @ 19:09d18d6e5f40

airport work
author stevenh7776 stevenhollidge@hotmail.com
date Thu, 15 Mar 2012 06:59:15 +0000
parents 443821e55f06
children
rev   line source
19
09d18d6e5f40 airport work
stevenh7776 stevenhollidge@hotmail.com
parents: 10
diff changeset
1 using System;
10
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
2 using System.ComponentModel;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
3 using System.Threading;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
4 using System.Threading.Tasks;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
5 using Chronos.Presentation.Core.ViewModel;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
6 using Chronos.Presentation.Core.Windows;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
7 using NLog;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
8 using nRoute.Components;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
9
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
10 namespace Chronos.Presentation.ViewModel
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
11 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
12 public abstract class WindowViewModel<TEntity>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
13 : NavigationViewModel, IWindowViewModel where TEntity: class, new()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
14 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
15 #region · Logger ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
16
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
17 private static Logger Logger = LogManager.GetCurrentClassLogger();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
18
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
19 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
20
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
21 #region · Inner Types ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
22
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
23 [Serializable]
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
24 protected enum InquiryActionResultType
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
25 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
26 DataFetched,
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
27 RequestedNew,
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
28 DataNotFound
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
29 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
30
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
31 protected sealed class InquiryActionResult<TResult>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
32 where TResult : class
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
33 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
34 #region · Properties ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
35
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
36 public TResult Data
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
37 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
38 get;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
39 set;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
40 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
41
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
42 public InquiryActionResultType Result
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
43 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
44 get;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
45 set;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
46 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
47
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
48 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
49
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
50 #region · Constructors ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
51
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
52 public InquiryActionResult()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
53 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
54 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
55
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
56 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
57 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
58
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
59 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
60
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
61 #region · PropertyChangedEventArgs Cached Instances ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
62
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
63 private static readonly PropertyChangedEventArgs ViewModeChangedArgs = CreateArgs<WindowViewModel<TEntity>>(x => x.ViewMode);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
64 private static readonly PropertyChangedEventArgs StatusMessageChangedArgs = CreateArgs<WindowViewModel<TEntity>>(x => x.StatusMessage);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
65 private static readonly PropertyChangedEventArgs NotificationMessageChangedArgs = CreateArgs<WindowViewModel<TEntity>>(x => x.NotificationMessage);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
66
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
67 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
68
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
69 #region · Events ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
70
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
71 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
72 /// Occurs when view mode is changed.
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
73 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
74 public event EventHandler ViewModeChanged;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
75
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
76 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
77
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
78 #region · Fields ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
79
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
80 private TEntity originalEntity;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
81 private string statusMessage;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
82 private string notificationMessage;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
83 private TEntity entity;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
84 private ViewModeType viewMode;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
85 private PropertyStateCollection<TEntity> propertyStates;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
86
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
87 #region · Commands ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
88
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
89 private ActionCommand inquiryCommand;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
90
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
91 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
92
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
93 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
94
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
95 #region · Properties ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
96
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
97 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
98 /// Gets the property state collection
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
99 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
100 public PropertyStateCollection<TEntity> PropertyStates
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
101 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
102 get
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
103 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
104 if (this.propertyStates == null)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
105 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
106 this.propertyStates = new PropertyStateCollection<TEntity>();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
107 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
108
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
109 return this.propertyStates;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
110 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
111 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
112
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
113 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
114 /// Gets or sets the state of the smart part.
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
115 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
116 /// <value>The state of the smart part.</value>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
117 public ViewModeType ViewMode
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
118 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
119 get { return this.viewMode; }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
120 set
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
121 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
122 if (this.viewMode != value)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
123 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
124 this.viewMode = value;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
125 try
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
126 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
127 this.OnViewModeChanged();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
128 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
129 catch
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
130 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
131 #warning TODO: This is done to prevent DataGrid erroros when discarding changes on new records
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
132 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
133 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
134 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
135 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
136
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
137 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
138 /// Gets the inquiry data command
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
139 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
140 public ActionCommand InquiryCommand
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
141 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
142 get
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
143 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
144 if (this.inquiryCommand == null)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
145 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
146 this.inquiryCommand = new ActionCommand
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
147 (
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
148 () => OnInquiryData(),
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
149 () => CanInquiryData()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
150 );
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
151 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
152
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
153 return this.inquiryCommand;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
154 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
155 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
156
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
157 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
158 /// Gets or sets the status message text
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
159 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
160 public string StatusMessage
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
161 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
162 get { return this.statusMessage; }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
163 set
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
164 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
165 if (this.statusMessage != value)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
166 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
167 this.statusMessage = value;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
168 this.NotifyPropertyChanged(StatusMessageChangedArgs);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
169 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
170 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
171 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
172
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
173 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
174 /// Gets or sets the notification message text
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
175 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
176 public string NotificationMessage
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
177 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
178 get { return this.notificationMessage; }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
179 set
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
180 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
181 if (this.notificationMessage != value)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
182 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
183 this.notificationMessage = value;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
184 this.NotifyPropertyChanged(NotificationMessageChangedArgs);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
185 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
186 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
187 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
188
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
189 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
190
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
191 #region · Protected Properties ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
192
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
193 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
194 /// Gets or sets the data model.
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
195 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
196 /// <value>The data model.</value>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
197 protected TEntity Entity
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
198 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
199 get { return this.entity; }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
200 private set
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
201 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
202 if (!Object.ReferenceEquals(this.entity, value))
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
203 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
204 this.entity = value;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
205 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
206 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
207 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
208
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
209 protected TEntity OriginalEntity
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
210 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
211 get { return this.originalEntity; }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
212 set { this.originalEntity = value; }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
213 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
214
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
215 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
216
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
217 #region · Constructors ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
218
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
219 protected WindowViewModel()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
220 : base()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
221 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
222 this.InitializePropertyStates();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
223
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
224 this.Entity = new TEntity();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
225 this.ViewMode = ViewModeType.ViewOnly;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
226 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
227
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
228 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
229
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
230 #region · Command Actions ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
231
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
232 #region · Inquiry ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
233
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
234 protected virtual bool CanInquiryData()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
235 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
236 return (this.ViewMode == ViewModeType.ViewOnly);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
237 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
238
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
239 protected void OnInquiryData()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
240 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
241 InquiryActionResult<TEntity> result = new InquiryActionResult<TEntity>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
242 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
243 Result = InquiryActionResultType.DataNotFound
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
244 };
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
245
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
246 this.ViewMode = ViewModeType.Busy;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
247 this.StatusMessage = "Obteniendo datos, espere por favor ...";
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
248
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
249 Task task = Task.Factory.StartNew
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
250 (
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
251 (o) =>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
252 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
253 Logger.Debug("Obteniendo datos '{0}'", this.Entity.ToString());
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
254
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
255 this.OnInquiryAction(result);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
256 }, result
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
257 );
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
258
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
259 task.ContinueWith
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
260 (
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
261 (t) =>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
262 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
263 Logger.Debug("Error al obtener datos '{0}'", t.Exception.InnerException.ToString());
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
264
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
265 this.OnInquiryActionFailed();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
266
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
267 Exception exception = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
268 this.OriginalEntity = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
269
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
270 if (t.Exception.InnerException != null)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
271 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
272 exception = t.Exception.InnerException;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
273 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
274 else
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
275 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
276 exception = t.Exception;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
277 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
278
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
279 this.NotificationMessage = exception.Message;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
280 },
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
281 CancellationToken.None,
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
282 TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.AttachedToParent,
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
283 TaskScheduler.FromCurrentSynchronizationContext()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
284 );
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
285
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
286 task.ContinueWith
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
287 (
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
288 _ =>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
289 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
290 Logger.Debug("Datos obtenidos correctamente '{0}'", this.Entity.ToString());
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
291
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
292 this.StatusMessage = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
293 this.OnInquiryActionComplete(result);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
294 },
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
295 CancellationToken.None,
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
296 TaskContinuationOptions.OnlyOnRanToCompletion | TaskContinuationOptions.AttachedToParent,
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
297 TaskScheduler.FromCurrentSynchronizationContext()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
298 );
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
299 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
300
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
301 protected abstract void OnInquiryAction(InquiryActionResult<TEntity> result);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
302
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
303 protected virtual void OnInquiryActionComplete(InquiryActionResult<TEntity> result)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
304 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
305 switch (result.Result)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
306 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
307 case InquiryActionResultType.DataNotFound:
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
308 this.OriginalEntity = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
309
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
310 this.ResetDataModel();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
311
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
312 this.ViewMode = ViewModeType.ViewOnly;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
313 break;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
314
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
315 case InquiryActionResultType.RequestedNew:
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
316 throw new InvalidOperationException("Requested New is not valid on this type of ViewModel");
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
317
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
318 case InquiryActionResultType.DataFetched:
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
319 this.ResetDataModel(result.Data);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
320
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
321 this.OriginalEntity = this.entity;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
322 this.ViewMode = ViewModeType.ViewOnly;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
323 break;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
324 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
325 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
326
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
327 protected virtual void OnInquiryActionFailed()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
328 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
329 this.ViewMode = ViewModeType.ViewOnly;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
330 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
331
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
332 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
333
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
334 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
335
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
336 #region · Overriden Methods ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
337
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
338 /// <summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
339 /// Called when the related view is being closed.
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
340 /// </summary>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
341 public override void Close()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
342 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
343 Logger.Debug("Cerrar ventana '{0}'", this.GetType());
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
344
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
345 if (this.originalEntity != null)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
346 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
347 this.originalEntity = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
348 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
349 if (this.entity != null)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
350 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
351 this.entity = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
352 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
353 if (this.propertyStates != null)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
354 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
355 this.propertyStates.Clear();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
356 this.propertyStates = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
357 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
358
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
359 this.inquiryCommand = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
360 this.statusMessage = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
361 this.notificationMessage = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
362
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
363 base.Close();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
364 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
365
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
366 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
367
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
368 #region · DataModel Reset Methods ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
369
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
370 protected void ResetDataModel()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
371 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
372 Logger.Debug("Resetar model '{0}'", this.GetType());
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
373 this.ResetDataModel(new TEntity());
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
374 Logger.Debug("Model reseteado '{0}'", this.GetType());
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
375 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
376
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
377 protected virtual void ResetDataModel(TEntity model)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
378 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
379 this.OnResetingDataModel(this.Entity, model);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
380
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
381 this.OriginalEntity = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
382 this.Entity = model;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
383
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
384 this.OnResetedDataModel(model);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
385 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
386
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
387 protected virtual void OnResetingDataModel(TEntity oldModel, TEntity newModel)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
388 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
389 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
390
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
391 protected virtual void OnResetedDataModel(TEntity newModel)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
392 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
393 this.NotifyAllPropertiesChanged();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
394 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
395
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
396 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
397
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
398 #region · Protected Methods ·
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
399
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
400 protected virtual void InitializePropertyStates()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
401 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
402 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
403
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
404 protected virtual void OnViewModeChanged()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
405 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
406 if (this.ViewModeChanged != null)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
407 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
408 this.ViewModeChanged(this, new EventArgs());
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
409 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
410
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
411 this.NotifyPropertyChanged(ViewModeChangedArgs);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
412 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
413
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
414 protected virtual void UpdateAllowedUserActions()
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
415 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
416 this.Invoke
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
417 (
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
418 () =>
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
419 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
420 this.InquiryCommand.RequeryCanExecute();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
421 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
422 );
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
423 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
424
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
425 protected override void NotifyPropertyChanged(PropertyChangedEventArgs args)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
426 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
427 if (args != StatusMessageChangedArgs)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
428 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
429 this.StatusMessage = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
430 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
431 if (args != NotificationMessageChangedArgs)
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
432 {
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
433 this.NotificationMessage = null;
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
434 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
435
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
436 this.UpdateAllowedUserActions();
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
437 base.NotifyPropertyChanged(args);
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
438 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
439
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
440 #endregion
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
441 }
443821e55f06 Initial cleaned up add from Codeplex files
stevenh7776 stevenhollidge@hotmail.com
parents:
diff changeset
442 }