mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Profile editor - Many runtime fixes, UI is back to usable!
This commit is contained in:
1 parent
db9d9fb4e6
commit
7fff1a593f
38 files changed
+309
-352
No files matched your search
+28
-11
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user