-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathShellViewModel.cs
More file actions
121 lines (101 loc) · 3.9 KB
/
Copy pathShellViewModel.cs
File metadata and controls
121 lines (101 loc) · 3.9 KB
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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dragablz;
using Dragablz.Dockablz;
using Visualizer.Services;
using Visualizer.Visualizers;
namespace Visualizer
{
public class ShellViewModel : ViewModelBase<ShellView>
{
private readonly IInterTabClient _interTabClient = new ShellInterTabClient();
private readonly ObservableCollection<HeaderedItemViewModel> _items;
private readonly ObservableCollection<HeaderedItemViewModel> _toolItems = new ObservableCollection<HeaderedItemViewModel>();
// selected view ??
public ShellViewModel() : base(new ShellView())
{
_items = new ObservableCollection<HeaderedItemViewModel>(new HeaderedItemViewModel[] { NewItemFactory() });
}
public ShellViewModel(bool addCreateTab) : base(new ShellView())
{
_items = addCreateTab
? new ObservableCollection<HeaderedItemViewModel>(new[] { NewItemFactory() })
: new ObservableCollection<HeaderedItemViewModel>();
}
public ShellViewModel(params HeaderedItemViewModel[] items) : base(new ShellView())
{
_items = new ObservableCollection<HeaderedItemViewModel>(items);
}
public Func<HeaderedItemViewModel> NewItemFactory => () => new NewVisualizerViewModel(CreateVizualizer);
public Action<NewVisualizerViewModel> CreateVizualizer
{
get
{
return (tabModel) =>
{
var index = Items.IndexOf(tabModel);
var newModel = GetVisualizerModel(tabModel);
Items.Insert(index, newModel);
Items.Remove(tabModel);
};
}
}
private static HeaderedItemViewModel GetVisualizerModel(NewVisualizerViewModel tabModel)
{
return TabViewFactory.VisualizerTypeViews[tabModel.SelectedVisualizerType].Invoke(tabModel.GridSize);
}
public ObservableCollection<HeaderedItemViewModel> Items
{
get { return _items; }
}
public static Guid TabPartition
{
get { return new Guid("2AE89D18-F236-4D20-9605-6C03319038E6"); }
}
public IInterTabClient InterTabClient
{
get { return _interTabClient; }
}
public ObservableCollection<HeaderedItemViewModel> ToolItems
{
get { return _toolItems; }
}
public ItemActionCallback ClosingTabItemHandler
{
get { return ClosingTabItemHandlerImpl; }
}
/// <summary>
/// Callback to handle tab closing.
/// </summary>
private static void ClosingTabItemHandlerImpl(ItemActionCallbackArgs<TabablzControl> args)
{
//in here you can dispose stuff or cancel the close
//here's your view model:
var viewModel = args.DragablzItem.DataContext as HeaderedItemViewModel;
//Debug.Assert(viewModel != null);
//here's how you can cancel stuff:
//args.Cancel();
}
public ClosingFloatingItemCallback ClosingFloatingItemHandler
{
get { return ClosingFloatingItemHandlerImpl; }
}
/// <summary>
/// Callback to handle floating toolbar/MDI window closing.
/// </summary>
private static void ClosingFloatingItemHandlerImpl(ItemActionCallbackArgs<Layout> args)
{
//in here you can dispose stuff or cancel the close
//here's your view model:
var disposable = args.DragablzItem.DataContext as IDisposable;
if (disposable != null)
disposable.Dispose();
//here's how you can cancel stuff:
//args.Cancel();
}
}
}