Profile editor - Many runtime fixes, UI is back to usable!

This commit is contained in:
SpoinkyNL committed 2020-09-12 23:11:08 +02:00
1 parent db9d9fb4e6
commit 7fff1a593f
38 files changed
+309 -352

No files matched your search

@@ -1,32 +1,49 @@
using System;
using System.Linq;
using Artemis.Core;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Shared.Services;
using Stylet;
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
{
public class DataBindingsViewModel<T> : Conductor<IDataBindingViewModel>.Collection.AllActive
public class DataBindingsViewModel : Conductor<IDataBindingViewModel>.Collection.AllActive
{
private readonly IDataBindingsVmFactory _dataBindingsVmFactory;
public DataBindingsViewModel(LayerProperty<T> layerProperty, IDataBindingsVmFactory dataBindingsVmFactory)
private readonly IProfileEditorService _profileEditorService;
public DataBindingsViewModel(IProfileEditorService profileEditorService, IDataBindingsVmFactory dataBindingsVmFactory)
{
_profileEditorService = profileEditorService;
_dataBindingsVmFactory = dataBindingsVmFactory;
LayerProperty = layerProperty;
Initialise();
_profileEditorService.SelectedDataBindingChanged += ProfileEditorServiceOnSelectedDataBindingChanged;
CreateDataBindingViewModels();
}
public LayerProperty<T> LayerProperty { get; }
private void Initialise()
private void CreateDataBindingViewModels()
{
var registrations = LayerProperty.GetAllDataBindingRegistrations();
Items.Clear();
var layerProperty = _profileEditorService.SelectedDataBinding;
if (layerProperty == null)
return;
var registrations = layerProperty.GetAllDataBindingRegistrations();
// Create a data binding VM for each data bindable property. These VMs will be responsible for retrieving
// and creating the actual data bindings
foreach (var registration in registrations)
ActivateItem(_dataBindingsVmFactory.DataBindingViewModel(registration));
}
protected override void OnClose()
{
_profileEditorService.SelectedDataBindingChanged -= ProfileEditorServiceOnSelectedDataBindingChanged;
base.OnClose();
}
private void ProfileEditorServiceOnSelectedDataBindingChanged(object? sender, EventArgs e)
{
CreateDataBindingViewModels();
}
}
}
@@ -23,42 +23,62 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
public class LayerPropertiesViewModel : Conductor<IScreen>.Collection.AllActive, IProfileEditorPanelViewModel, IDropTarget
{
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
private readonly IDataBindingsVmFactory _dataBindingsVmFactory;
private LayerPropertyGroupViewModel _brushPropertyGroup;
private DataBindingsViewModel _dataBindingsViewModel;
private EffectsViewModel _effectsViewModel;
private TimelineSegmentViewModel _endTimelineSegmentViewModel;
private BindableCollection<LayerPropertyGroupViewModel> _layerPropertyGroups;
private TimelineSegmentViewModel _mainTimelineSegmentViewModel;
private bool _playing;
private int _propertyTreeIndex;
private bool _repeatAfterLastKeyframe;
private int _rightSideIndex;
private RenderProfileElement _selectedProfileElement;
private TimelineSegmentViewModel _startTimelineSegmentViewModel;
private TimelineViewModel _timelineViewModel;
private TreeViewModel _treeViewModel;
public LayerPropertiesViewModel(IProfileEditorService profileEditorService,
ICoreService coreService,
ISettingsService settingsService,
ILayerPropertyVmFactory layerPropertyVmFactory,
IDataBindingsVmFactory dataBindingsVmFactory)
DataBindingsViewModel dataBindingsViewModel)
{
_layerPropertyVmFactory = layerPropertyVmFactory;
_dataBindingsVmFactory = dataBindingsVmFactory;
ProfileEditorService = profileEditorService;
CoreService = coreService;
SettingsService = settingsService;
EffectsViewModel = _layerPropertyVmFactory.EffectsViewModel(this);
Items.Add(EffectsViewModel);
LayerPropertyGroups = new BindableCollection<LayerPropertyGroupViewModel>();
PropertyChanged += HandlePropertyTreeIndexChanged;
// Left side
TreeViewModel = _layerPropertyVmFactory.TreeViewModel(this, LayerPropertyGroups);
EffectsViewModel = _layerPropertyVmFactory.EffectsViewModel(this);
Items.Add(TreeViewModel);
Items.Add(EffectsViewModel);
// Right side
StartTimelineSegmentViewModel = _layerPropertyVmFactory.TimelineSegmentViewModel(SegmentViewModelType.Start, LayerPropertyGroups);
MainTimelineSegmentViewModel = _layerPropertyVmFactory.TimelineSegmentViewModel(SegmentViewModelType.Main, LayerPropertyGroups);
EndTimelineSegmentViewModel = _layerPropertyVmFactory.TimelineSegmentViewModel(SegmentViewModelType.End, LayerPropertyGroups);
TimelineViewModel = _layerPropertyVmFactory.TimelineViewModel(this, LayerPropertyGroups);
DataBindingsViewModel = dataBindingsViewModel;
Items.Add(StartTimelineSegmentViewModel);
Items.Add(MainTimelineSegmentViewModel);
Items.Add(EndTimelineSegmentViewModel);
Items.Add(TimelineViewModel);
Items.Add(DataBindingsViewModel);
}
public BindableCollection<LayerPropertyGroupViewModel> LayerPropertyGroups { get; }
#region Child VMs
public TreeViewModel TreeViewModel { get; }
public EffectsViewModel EffectsViewModel { get; }
public TimelineSegmentViewModel StartTimelineSegmentViewModel { get; }
public TimelineSegmentViewModel MainTimelineSegmentViewModel { get; }
public TimelineSegmentViewModel EndTimelineSegmentViewModel { get; }
public TimelineViewModel TimelineViewModel { get; }
public DataBindingsViewModel DataBindingsViewModel { get; }
#endregion
public IProfileEditorService ProfileEditorService { get; }
public ICoreService CoreService { get; }
public ISettingsService SettingsService { get; }
@@ -115,53 +135,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
public Layer SelectedLayer => SelectedProfileElement as Layer;
public Folder SelectedFolder => SelectedProfileElement as Folder;
public BindableCollection<LayerPropertyGroupViewModel> LayerPropertyGroups
{
get => _layerPropertyGroups;
set => SetAndNotify(ref _layerPropertyGroups, value);
}
public TreeViewModel TreeViewModel
{
get => _treeViewModel;
set => SetAndNotify(ref _treeViewModel, value);
}
public EffectsViewModel EffectsViewModel
{
get => _effectsViewModel;
set => SetAndNotify(ref _effectsViewModel, value);
}
public DataBindingsViewModel DataBindingsViewModel
{
get => _dataBindingsViewModel;
set => SetAndNotify(ref _dataBindingsViewModel, value);
}
public TimelineViewModel TimelineViewModel
{
get => _timelineViewModel;
set => SetAndNotify(ref _timelineViewModel, value);
}
public TimelineSegmentViewModel StartTimelineSegmentViewModel
{
get => _startTimelineSegmentViewModel;
set => SetAndNotify(ref _startTimelineSegmentViewModel, value);
}
public TimelineSegmentViewModel MainTimelineSegmentViewModel
{
get => _mainTimelineSegmentViewModel;
set => SetAndNotify(ref _mainTimelineSegmentViewModel, value);
}
public TimelineSegmentViewModel EndTimelineSegmentViewModel
{
get => _endTimelineSegmentViewModel;
set => SetAndNotify(ref _endTimelineSegmentViewModel, value);
}
#region Segments
@@ -197,18 +170,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
ProfileEditorService.PixelsPerSecondChanged -= ProfileEditorServiceOnPixelsPerSecondChanged;
PopulateProperties(null);
TimelineViewModel?.Dispose();
TimelineViewModel = null;
StartTimelineSegmentViewModel?.Dispose();
StartTimelineSegmentViewModel = null;
MainTimelineSegmentViewModel?.Dispose();
MainTimelineSegmentViewModel = null;
EndTimelineSegmentViewModel?.Dispose();
EndTimelineSegmentViewModel = null;
DataBindingsViewModel?.Dispose();
DataBindingsViewModel = null;
base.OnClose();
}
@@ -242,15 +203,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
private void ProfileEditorServiceOnSelectedDataBindingChanged(object? sender, EventArgs e)
{
if (ProfileEditorService.SelectedDataBinding != null)
{
RightSideIndex = 1;
DataBindingsViewModel?.Dispose();
// TODO
// DataBindingsViewModel = _dataBindingsVmFactory.DataBindingsViewModel(ProfileEditorService.SelectedDataBinding);
}
else
RightSideIndex = 0;
RightSideIndex = ProfileEditorService.SelectedDataBinding != null ? 1 : 0;
}
#region View model managament
@@ -293,23 +246,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
LayerPropertyGroups.Add(_layerPropertyVmFactory.LayerPropertyGroupViewModel(SelectedLayer.Transform));
}
TreeViewModel = _layerPropertyVmFactory.TreeViewModel(this, LayerPropertyGroups);
DeactivateItem(TimelineViewModel);
DeactivateItem(StartTimelineSegmentViewModel);
DeactivateItem(MainTimelineSegmentViewModel);
DeactivateItem(EndTimelineSegmentViewModel);
TimelineViewModel = _layerPropertyVmFactory.TimelineViewModel(this, LayerPropertyGroups);
ActivateItem(TimelineViewModel);
StartTimelineSegmentViewModel?.Dispose();
StartTimelineSegmentViewModel = _layerPropertyVmFactory.TimelineSegmentViewModel(SegmentViewModelType.Start, LayerPropertyGroups);
MainTimelineSegmentViewModel?.Dispose();
MainTimelineSegmentViewModel = _layerPropertyVmFactory.TimelineSegmentViewModel(SegmentViewModelType.Main, LayerPropertyGroups);
EndTimelineSegmentViewModel?.Dispose();
EndTimelineSegmentViewModel = _layerPropertyVmFactory.TimelineSegmentViewModel(SegmentViewModelType.End, LayerPropertyGroups);
ApplyLayerBrush();
ApplyEffects();
}
@@ -361,21 +297,18 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
private void ApplyEffects()
{
RenderProfileElement renderElement;
if (SelectedLayer != null)
renderElement = SelectedLayer;
else if (SelectedFolder != null)
renderElement = SelectedFolder;
else
if (SelectedProfileElement == null)
return;
// Remove VMs of effects no longer applied on the layer
var toRemove = LayerPropertyGroups.Where(l => l.LayerPropertyGroup.LayerEffect != null && !renderElement.LayerEffects.Contains(l.LayerPropertyGroup.LayerEffect)).ToList();
var toRemove = LayerPropertyGroups
.Where(l => l.LayerPropertyGroup.LayerEffect != null && !SelectedProfileElement.LayerEffects.Contains(l.LayerPropertyGroup.LayerEffect))
.ToList();
LayerPropertyGroups.RemoveRange(toRemove);
foreach (var layerPropertyGroupViewModel in toRemove)
layerPropertyGroupViewModel.Dispose();
foreach (var layerEffect in renderElement.LayerEffects)
foreach (var layerEffect in SelectedProfileElement.LayerEffects)
{
if (LayerPropertyGroups.Any(l => l.LayerPropertyGroup.LayerEffect == layerEffect))
continue;
@@ -1,5 +1,6 @@
using System;
using Artemis.Core;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline;
using Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree;
using Ninject;
@@ -10,25 +11,20 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
{
public class LayerPropertyViewModel : PropertyChangedBase, IDisposable
{
public LayerPropertyViewModel(ILayerProperty layerProperty, IKernel kernel)
public LayerPropertyViewModel(ILayerProperty layerProperty, IPropertyVmFactory propertyVmFactory)
{
LayerProperty = layerProperty;
var parameter = new ConstructorArgument("layerProperty", LayerProperty);
var treeViewModelType = typeof(TreePropertyViewModel<>).MakeGenericType(layerProperty.GetType().GetGenericArguments());
var timelineViewModelType = typeof(TimelinePropertyViewModel<>).MakeGenericType(layerProperty.GetType().GetGenericArguments());
TreePropertyViewModel = (ITreePropertyViewModel) kernel.Get(treeViewModelType, parameter);
TimelinePropertyViewModel = (ITimelinePropertyViewModel) kernel.Get(timelineViewModelType, parameter);
TreePropertyViewModel = propertyVmFactory.TreePropertyViewModel(layerProperty, this);
TimelinePropertyViewModel = propertyVmFactory.TimelinePropertyViewModel(layerProperty, this);
}
public ILayerProperty LayerProperty { get; }
public ITreePropertyViewModel TreePropertyViewModel { get; }
public ITimelinePropertyViewModel TimelinePropertyViewModel { get; }
public bool IsVisible { get; set; }
public bool IsExpanded { get; set; }
public bool IsVisible => !LayerProperty.IsHidden;
public void Dispose()
{
TreePropertyViewModel?.Dispose();
@@ -60,10 +60,16 @@
</ItemsControl.ItemContainerStyle>
<ItemsControl.Resources>
<DataTemplate DataType="{x:Type layerProperties:LayerPropertyGroupViewModel}">
<ContentControl s:View.Model="{Binding TimelineGroupViewModel}" IsTabStop="False" HorizontalAlignment="Stretch" />
<ContentControl s:View.Model="{Binding TimelineGroupViewModel}"
IsTabStop="False"
HorizontalAlignment="Stretch"
Visibility="{Binding IsVisible, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"/>
</DataTemplate>
<DataTemplate DataType="{x:Type layerProperties:LayerPropertyViewModel}">
<ContentControl s:View.Model="{Binding TimelinePropertyViewModel}" IsTabStop="False" HorizontalAlignment="Stretch" />
<ContentControl s:View.Model="{Binding TimelinePropertyViewModel}"
IsTabStop="False"
HorizontalAlignment="Stretch"
Visibility="{Binding IsVisible, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
</DataTemplate>
</ItemsControl.Resources>
</ItemsControl>
@@ -9,7 +9,6 @@
xmlns:timeline="clr-namespace:Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Visibility="{Binding LayerPropertyBaseViewModel.IsVisible, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"
MinWidth="{Binding Width}"
HorizontalAlignment="Stretch">
<Border Height="25" BorderThickness="0,0,0,1" BorderBrush="{DynamicResource MaterialDesignDivider}">
@@ -19,6 +19,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
LayerProperty = layerProperty;
LayerPropertyViewModel = layerPropertyViewModel;
UpdateKeyframes();
}
public List<ITimelineKeyframeViewModel> GetAllKeyframeViewModels()
@@ -11,7 +11,7 @@ using Stylet;
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
{
public class TimelineSegmentViewModel : PropertyChangedBase, IDisposable
public class TimelineSegmentViewModel : Screen, IDisposable
{
private bool _draggingSegment;
private bool _showDisableButton;
@@ -43,7 +43,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
UpdateDisplay();
ProfileEditorService.PixelsPerSecondChanged += ProfileEditorServiceOnPixelsPerSecondChanged;
SelectedProfileElement.PropertyChanged += SelectedProfileElementOnPropertyChanged;
ProfileEditorService.ProfileElementSelected += ProfileEditorServiceOnProfileElementSelected;
if (ProfileEditorService.SelectedProfileElement != null)
ProfileEditorService.SelectedProfileElement.PropertyChanged += SelectedProfileElementOnPropertyChanged;
}
public RenderProfileElement SelectedProfileElement { get; }
@@ -97,6 +99,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
{
get
{
if (SelectedProfileElement == null)
return 0;
return Segment switch
{
SegmentViewModelType.Start => 0,
@@ -128,7 +133,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
public void Dispose()
{
ProfileEditorService.PixelsPerSecondChanged -= ProfileEditorServiceOnPixelsPerSecondChanged;
SelectedProfileElement.PropertyChanged -= SelectedProfileElementOnPropertyChanged;
ProfileEditorService.ProfileElementSelected -= ProfileEditorServiceOnProfileElementSelected;
if (SelectedProfileElement != null)
SelectedProfileElement.PropertyChanged -= SelectedProfileElementOnPropertyChanged;
}
public void DisableSegment()
@@ -260,6 +267,13 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
UpdateDisplay();
}
private void ProfileEditorServiceOnProfileElementSelected(object? sender, RenderProfileElementEventArgs e)
{
if (e.PreviousRenderProfileElement != null)
e.PreviousRenderProfileElement.PropertyChanged -= SelectedProfileElementOnPropertyChanged;
e.RenderProfileElement.PropertyChanged += SelectedProfileElementOnPropertyChanged;
}
private void SelectedProfileElementOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(RenderProfileElement.StartSegmentLength) ||
@@ -37,7 +37,7 @@
HorizontalAlignment="Left">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ContentControl s:View.Model="{Binding TimelinePropertyGroupViewModel}" HorizontalContentAlignment="Left" />
<ContentControl s:View.Model="{Binding TimelineGroupViewModel}" HorizontalContentAlignment="Left" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
@@ -27,13 +26,14 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
LayerPropertyGroups = layerPropertyGroups;
SelectionRectangle = new RectangleGeometry();
SelectedProfileElement = layerPropertiesViewModel.SelectedProfileElement;
SelectedProfileElement.PropertyChanged += SelectedProfileElementOnPropertyChanged;
_profileEditorService.PixelsPerSecondChanged += ProfileEditorServiceOnPixelsPerSecondChanged;
_profileEditorService.ProfileElementSelected += ProfileEditorServiceOnProfileElementSelected;
if (_profileEditorService.SelectedProfileElement != null)
_profileEditorService.SelectedProfileElement.PropertyChanged += SelectedProfileElementOnPropertyChanged;
}
public RenderProfileElement SelectedProfileElement { get; set; }
public RenderProfileElement SelectedProfileElement => _profileEditorService.SelectedProfileElement;
public BindableCollection<LayerPropertyGroupViewModel> LayerPropertyGroups { get; }
@@ -43,23 +43,25 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
set => SetAndNotify(ref _selectionRectangle, value);
}
public double StartSegmentWidth => _profileEditorService.PixelsPerSecond * SelectedProfileElement.StartSegmentLength.TotalSeconds;
public double StartSegmentWidth => _profileEditorService.PixelsPerSecond * (SelectedProfileElement?.StartSegmentLength.TotalSeconds ?? 0);
public double StartSegmentEndPosition => StartSegmentWidth;
public double MainSegmentWidth => _profileEditorService.PixelsPerSecond * SelectedProfileElement.MainSegmentLength.TotalSeconds;
public double MainSegmentWidth => _profileEditorService.PixelsPerSecond * (SelectedProfileElement?.MainSegmentLength.TotalSeconds ?? 0);
public double MainSegmentEndPosition => StartSegmentWidth + MainSegmentWidth;
public double EndSegmentWidth => _profileEditorService.PixelsPerSecond * SelectedProfileElement.EndSegmentLength.TotalSeconds;
public double EndSegmentWidth => _profileEditorService.PixelsPerSecond * (SelectedProfileElement?.EndSegmentLength.TotalSeconds ?? 0);
public double EndSegmentEndPosition => StartSegmentWidth + MainSegmentWidth + EndSegmentWidth;
public double TotalTimelineWidth => _profileEditorService.PixelsPerSecond * SelectedProfileElement.TimelineLength.TotalSeconds;
public double TotalTimelineWidth => _profileEditorService.PixelsPerSecond * (SelectedProfileElement?.TimelineLength.TotalSeconds ?? 0);
public bool StartSegmentEnabled => SelectedProfileElement.StartSegmentLength != TimeSpan.Zero;
public bool EndSegmentEnabled => SelectedProfileElement.EndSegmentLength != TimeSpan.Zero;
public bool StartSegmentEnabled => SelectedProfileElement?.StartSegmentLength != TimeSpan.Zero;
public bool EndSegmentEnabled => SelectedProfileElement?.EndSegmentLength != TimeSpan.Zero;
public void Dispose()
{
_profileEditorService.PixelsPerSecondChanged -= ProfileEditorServiceOnPixelsPerSecondChanged;
SelectedProfileElement.PropertyChanged -= SelectedProfileElementOnPropertyChanged;
_profileEditorService.ProfileElementSelected -= ProfileEditorServiceOnProfileElementSelected;
if (_profileEditorService.SelectedProfileElement != null)
_profileEditorService.SelectedProfileElement.PropertyChanged -= SelectedProfileElementOnPropertyChanged;
}
private void SelectedProfileElementOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(_profileEditorService.SelectedProfileElement.StartSegmentLength))
@@ -98,6 +100,13 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
NotifyOfPropertyChange(nameof(TotalTimelineWidth));
}
private void ProfileEditorServiceOnProfileElementSelected(object? sender, RenderProfileElementEventArgs e)
{
if (e.PreviousRenderProfileElement != null)
e.PreviousRenderProfileElement.PropertyChanged -= SelectedProfileElementOnPropertyChanged;
e.RenderProfileElement.PropertyChanged += SelectedProfileElementOnPropertyChanged;
}
#region Command handlers
public void KeyframeMouseDown(object sender, MouseButtonEventArgs e)
@@ -321,7 +330,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
var viewModels = new List<ITimelineKeyframeViewModel>();
foreach (var layerPropertyGroupViewModel in LayerPropertyGroups)
viewModels.AddRange(layerPropertyGroupViewModel.GetAllKeyframeViewModels(false));
return viewModels;
}
@@ -35,6 +35,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
LayerPropertyGroupViewModel = layerPropertyGroupViewModel;
LayerPropertyGroup = LayerPropertyGroupViewModel.LayerPropertyGroup;
DetermineGroupType();
}
public LayerPropertyGroupViewModel LayerPropertyGroupViewModel { get; }
@@ -98,7 +98,7 @@
</Style>
</TreeView.ItemContainerStyle>
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type local:LayerPropertyGroupViewModel}" ItemsSource="{Binding Items}">
<HierarchicalDataTemplate DataType="{x:Type local:LayerPropertyGroupViewModel}" ItemsSource="{Binding Children}">
<ContentControl s:View.Model="{Binding TreeGroupViewModel}" />
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type local:LayerPropertyViewModel}">
@@ -36,7 +36,10 @@ namespace Artemis.UI.Screens.ProfileEditor
private PluginSetting<GridLength> _sidePanelsWidth;
public ProfileEditorViewModel(ProfileModule module,
ICollection<IProfileEditorPanelViewModel> viewModels,
ProfileViewModel profileViewModel,
ProfileTreeViewModel profileTreeViewModel,
DisplayConditionsViewModel displayConditionsViewModel,
LayerPropertiesViewModel layerPropertiesViewModel,
IProfileEditorService profileEditorService,
IProfileService profileService,
IDialogService dialogService,
@@ -55,15 +58,17 @@ namespace Artemis.UI.Screens.ProfileEditor
DialogService = dialogService;
Profiles = new BindableCollection<ProfileDescriptor>();
// Run this first to let VMs activate without causing constant UI updates
Items.AddRange(viewModels);
// Populate the panels
ProfileViewModel = (ProfileViewModel) viewModels.First(vm => vm is ProfileViewModel);
ProfileTreeViewModel = (ProfileTreeViewModel) viewModels.First(vm => vm is ProfileTreeViewModel);
DisplayConditionsViewModel = (DisplayConditionsViewModel) viewModels.First(vm => vm is DisplayConditionsViewModel);
LayerPropertiesViewModel = (LayerPropertiesViewModel) viewModels.First(vm => vm is LayerPropertiesViewModel);
ProfileViewModel = profileViewModel;
ProfileTreeViewModel = profileTreeViewModel;
DisplayConditionsViewModel = displayConditionsViewModel;
LayerPropertiesViewModel = layerPropertiesViewModel;
Items.Add(ProfileViewModel);
Items.Add(ProfileTreeViewModel);
Items.Add(DisplayConditionsViewModel);
Items.Add(LayerPropertiesViewModel);
}
public ProfileModule Module { get; }