-
-
Notifications
You must be signed in to change notification settings - Fork 578
/
Copy pathDockManagerViewModel.cs
44 lines (38 loc) · 1.45 KB
/
DockManagerViewModel.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
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenRPA.ViewModel
{
public class DockManagerViewModel
{
/// <summary>Gets a collection of all visible documents</summary>
public ObservableCollection<DockWindowViewModel> Documents { get; private set; }
public ObservableCollection<object> Anchorables { get; private set; }
public DockManagerViewModel(IEnumerable<DockWindowViewModel> dockWindowViewModels)
{
this.Documents = new ObservableCollection<DockWindowViewModel>();
this.Anchorables = new ObservableCollection<object>();
foreach (var document in dockWindowViewModels)
{
document.PropertyChanged += DockWindowViewModel_PropertyChanged;
if (!document.IsClosed)
this.Documents.Add(document);
}
}
private void DockWindowViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
DockWindowViewModel document = sender as DockWindowViewModel;
if (e.PropertyName == nameof(DockWindowViewModel.IsClosed))
{
if (!document.IsClosed)
this.Documents.Add(document);
else
this.Documents.Remove(document);
}
}
}
}