blob: 7064a48e1e05adc3fb9968a2b96e58324bdbcb76 (
plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL;
using Tango.Core.DI;
using Tango.PPC.Common.Application;
using Tango.PPC.Common.Authentication;
using Tango.PPC.Common.Bit;
using Tango.PPC.Common.Build;
using Tango.PPC.Common.Connection;
using Tango.PPC.Common.Connectivity;
using Tango.PPC.Common.EventLogging;
using Tango.PPC.Common.ExternalBridge;
using Tango.PPC.Common.HotSpot;
using Tango.PPC.Common.Navigation;
using Tango.PPC.Common.Notifications;
using Tango.PPC.Common.Printing;
using Tango.PPC.Common.RemoteAssistance;
using Tango.PPC.Common.RemoteDesktop;
using Tango.PPC.Common.RemoteJobUpload;
using Tango.PPC.Common.Resume;
using Tango.PPC.Common.Storage;
using Tango.PPC.Common.Synchronization;
using Tango.PPC.Common.ThreadLoading;
using Tango.Settings;
using Tango.SharedUI;
using static Tango.SharedUI.Controls.NavigationControl;
namespace Tango.PPC.Common
{
/// <summary>
/// Represents a PPC view model base class.
/// </summary>
/// <seealso cref="Tango.SharedUI.ViewModel" />
public abstract class PPCViewModel : ViewModel, INavigationBlocker
{
/// <summary>
/// Gets the static observable entities adapter.
/// </summary>
public ObservablesStaticCollections Adapter
{
get { return ObservablesStaticCollections.Instance; }
}
/// <summary>
/// Gets or sets the application manager.
/// </summary>
[TangoInject]
public IPPCApplicationManager ApplicationManager { get; set; }
/// <summary>
/// Gets or sets the authentication provider.
/// </summary>
[TangoInject]
public IAuthenticationProvider AuthenticationProvider { get; set; }
/// <summary>
/// Gets or sets the navigation manager.
/// </summary>
[TangoInject]
public INavigationManager NavigationManager { get; set; }
/// <summary>
/// Gets or sets the notification provider.
/// </summary>
[TangoInject]
public INotificationProvider NotificationProvider { get; set; }
/// <summary>
/// Gets or sets the machine provider.
/// </summary>
[TangoInject]
public IMachineProvider MachineProvider { get; set; }
/// <summary>
/// Gets or sets the external bridge service.
/// </summary>
[TangoInject]
public IPPCExternalBridgeService ExternalBridgeService { get; set; }
/// <summary>
/// Gets or sets the printing manager.
/// </summary>
[TangoInject]
public IPrintingManager PrintingManager { get; set; }
/// <summary>
/// Gets or sets the connectivity provider.
/// </summary>
[TangoInject]
public IConnectivityProvider ConnectivityProvider { get; set; }
/// <summary>
/// Gets or sets the hot spot provider.
/// </summary>
[TangoInject]
public IHotSpotProvider HotSpotProvider { get; set; }
/// <summary>
/// Gets or sets the remote assistance provider.
/// </summary>
[TangoInject]
public IRemoteAssistanceProvider RemoteAssistanceProvider { get; set; }
/// <summary>
/// Gets or sets the storage provider.
/// </summary>
[TangoInject]
public IStorageProvider StorageProvider { get; set; }
/// <summary>
/// Gets or sets the event logger.
/// </summary>
[TangoInject]
public IEventLogger EventLogger { get; set; }
/// <summary>
/// Gets or sets the machine data synchronizer.
/// </summary>
[TangoInject]
public IMachineDataSynchronizer MachineDataSynchronizer { get; set; }
/// <summary>
/// Gets or sets the remote desktop service.
/// </summary>
[TangoInject]
public IRemoteDesktopService RemoteDesktopService { get; set; }
/// <summary>
/// Gets or sets the thread loading service.
/// </summary>
[TangoInject]
public IThreadLoadingService ThreadLoadingService { get; set; }
/// <summary>
/// Gets or sets the bit manager.
/// </summary>
[TangoInject]
public IBitManager BitManager { get; set; }
[TangoInject]
public IRemoteJobUploadService RemoteJobUploadService { get; set; }
[TangoInject]
public IBuildProvider BuildProvider { get; set; }
[TangoInject]
public IJobResumeManager JobResumeManager { get; set; }
private PPCSettings _settings;
/// <summary>
/// Gets the main PPC settings.
/// </summary>
public PPCSettings Settings
{
get
{
if (_settings == null)
{
_settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
}
return _settings;
}
private set { _settings = value; }
}
private bool _isVisible;
/// <summary>
/// Gets or sets a value indicating whether this <see cref="PPCViewModel"/> view is visible.
/// </summary>
public bool IsVisible
{
get { return _isVisible; }
private set { _isVisible = value; RaisePropertyChangedAuto(); }
}
/// <summary>
/// Called when the application has been started.
/// </summary>
public abstract void OnApplicationStarted();
/// <summary>
/// Called when the application is shutting down.
/// </summary>
public virtual void OnApplicationShuttingDown()
{
}
/// <summary>
/// Called when the navigation system has navigated to this VM view.
/// </summary>
public virtual void OnNavigatedTo()
{
IsVisible = true;
}
/// <summary>
/// Called when the navigation system has navigated to this VM view.
/// </summary>
/// <param name="fromVM">The view model instance of the previous view model</param>
public virtual void OnNavigatedTo(PPCViewModel fromVM)
{
}
/// <summary>
/// Called when the navigation system has navigated from this VM view.
/// </summary>
public virtual void OnNavigatedFrom()
{
IsVisible = false;
}
/// <summary>
/// Called before the navigation system has navigated to this VM view.
/// </summary>
public virtual void OnBeforeNavigatedTo()
{
}
/// <summary>
/// Called before the navigation system has navigated from this VM view.
/// </summary>
public virtual void OnBeforeNavigatedFrom()
{
IsVisible = false;
}
/// <summary>
/// Raises the specified message using the default <see cref="TangoMessenger"/>.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="message">The message.</param>
protected void RaiseMessage<T>(T message) where T : class
{
TangoMessenger.Default.Send<T>(message);
}
/// <summary>
/// Raises the specified message using the default <see cref="TangoMessenger"/>.
/// </summary>
/// <typeparam name="T"></typeparam>
protected void RaiseMessage<T>() where T : class
{
TangoMessenger.Default.Send<T>(Activator.CreateInstance<T>());
}
/// <summary>
/// Registers a message handle for the specified message type T.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="handler">The handler.</param>
protected void RegisterForMessage<T>(Action<T> handler)
{
TangoMessenger.Default.Register<T>(handler);
}
/// <summary>
/// Called before the navigation system navigates from this object.
/// Return false to abort the navigation.
/// </summary>
/// <returns></returns>
public virtual Task<bool> OnNavigateOutRequest()
{
return Task.FromResult(true);
}
/// <summary>
/// Called before the navigation system navigates back from this object.
/// Return false to abort the navigation.
/// </summary>
/// <returns></returns>
public virtual Task<bool> OnNavigateBackRequest()
{
return Task.FromResult(true);
}
/// <summary>
/// Called when the application is ready and all modules views are loaded.
/// </summary>
public virtual void OnApplicationReady()
{
}
}
/// <summary>
/// Represents a PPC view model base class a View property as an instance of a <see cref="IPPCView"/> contract.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <seealso cref="Tango.SharedUI.ViewModel" />
public abstract class PPCViewModel<T> : PPCViewModel where T : IPPCView
{
private T _view;
/// <summary>
/// Gets the IPPCView instance.
/// </summary>
[TangoInject(TangoInjectMode.WhenAvailable)]
public T View
{
get { return _view; }
set
{
_view = value;
ViewAttached = true;
OnViewAttached();
}
}
/// <summary>
/// Gets a value indicating whether the instance of IPPCView is available.
/// </summary>
public bool ViewAttached { get; private set; }
/// <summary>
/// Called when the application has been started.
/// </summary>
public override void OnApplicationStarted()
{
}
/// <summary>
/// Called when the instance of IPPCView is available.
/// </summary>
public virtual void OnViewAttached()
{
}
}
}
|