-
Notifications
You must be signed in to change notification settings - Fork 0
/
DocumentsViewModel.cs
37 lines (36 loc) · 1.25 KB
/
DocumentsViewModel.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DevExpress.Mvvm;
using DevExpress.Mvvm.POCO;
namespace MVVMSample {
public class DocumentsViewModel {
private readonly string viewNameSuffix = "View";
public IDocumentManagerService DocumentManagerService {
get { return this.GetRequiredService<IDocumentManagerService>(); }
}
public virtual DocumentType DocumentType { get; set; }
protected void OnDocumentTypeChanged() {
LoadDocument();
}
public void LoadDocument() {
if (DocumentType != MVVMSample.DocumentType.None && DocumentManagerService != null) {
IDocument document = DocumentManagerService.FindDocumentByIdOrCreate(DocumentType, x => CreateDocument());
document.Show();
}
}
IDocument CreateDocument() {
var document = DocumentManagerService.CreateDocument(DocumentType.ToString() + viewNameSuffix, null, this);
document.Title = DocumentType;
document.DestroyOnClose = false;
return document;
}
}
public enum DocumentType {
None,
Customers,
Orders
}
}